diff --git a/src/messenger/webim/js/compiled/chat/app.js b/src/messenger/webim/js/compiled/chat/app.js index 8c26a9c1..a2374ef6 100644 --- a/src/messenger/webim/js/compiled/chat/app.js +++ b/src/messenger/webim/js/compiled/chat/app.js @@ -6,7 +6,7 @@ License: http://mibew.org/license.php */ (function(a,j,k){var f=new j.Marionette.Application;f.addRegions({controlsRegion:"#controls-region",avatarRegion:"#avatar-region",messagesRegion:a.Regions.Messages,statusRegion:"#status-region",messageFormRegion:"#message-form-region",soundRegion:"#sound-region"});f.addInitializer(function(d){var g=a.Objects,c=a.Objects.Models,b=a.Objects.Models.Controls,h=a.Objects.Models.Status;g.server=new a.Server(k.extend({interactionType:MibewAPIChatInteraction},d.server));g.thread=new a.Thread(d.thread);c.user= -new a.Models.User(d.user);c.page=new a.Models.Page(d.page);var e=new a.Collections.Controls;c.user.get("isAgent")||(b.userName=new a.Models.UserNameControl({weight:220}),e.push(b.userName),b.sendMail=new a.Models.SendMailControl({weight:200,link:d.links.mailLink}),e.push(b.sendMail));c.user.get("isAgent")&&(b.redirect=new a.Models.RedirectControl({weight:200,link:d.links.redirectLink}),e.push(b.redirect),b.history=new a.Models.HistoryControl({weight:180,link:d.links.historyLink}),e.push(b.history)); +new a.Models.ChatUser(d.user);c.page=new a.Models.Page(d.page);var e=new a.Collections.Controls;c.user.get("isAgent")||(b.userName=new a.Models.UserNameControl({weight:220}),e.push(b.userName),b.sendMail=new a.Models.SendMailControl({weight:200,link:d.links.mailLink}),e.push(b.sendMail));c.user.get("isAgent")&&(b.redirect=new a.Models.RedirectControl({weight:200,link:d.links.redirectLink}),e.push(b.redirect),b.history=new a.Models.HistoryControl({weight:180,link:d.links.historyLink}),e.push(b.history)); b.sound=new a.Models.SoundControl({weight:160});e.push(b.sound);b.refresh=new a.Models.RefreshControl({weight:140});e.push(b.refresh);d.links.sslLink&&(b.secureMode=new a.Models.SecureModeControl({weight:120,link:d.links.sslLink}),e.push(b.secureMode));b.close=new a.Models.CloseControl({weight:100});e.push(b.close);g.Collections.controls=e;f.controlsRegion.show(new a.Views.ControlsCollection({collection:e}));h.message=new a.Models.StatusMessage({hideTimeout:5E3});h.typing=new a.Models.StatusTyping({hideTimeout:5E3}); g.Collections.status=new a.Collections.Status([h.message,h.typing]);f.statusRegion.show(new a.Views.StatusCollection({collection:g.Collections.status}));c.user.get("isAgent")||(c.avatar=new a.Models.Avatar,f.avatarRegion.show(new a.Views.Avatar({model:c.avatar})));g.Collections.messages=new a.Collections.Messages;c.messageForm=new a.Models.MessageForm(d.messageForm);f.messageFormRegion.show(new a.Views.MessageForm({model:c.messageForm}));f.messagesRegion.show(new a.Views.MessagesCollection({collection:g.Collections.messages})); c.sound=new a.Models.Sound;f.soundRegion.show(new a.Views.Sound({model:c.sound}));g.server.runUpdater()});a.Application=f})(Mibew,Backbone,_); diff --git a/src/messenger/webim/js/compiled/chat/models/chat_user.js b/src/messenger/webim/js/compiled/chat/models/chat_user.js new file mode 100644 index 00000000..781ae6d8 --- /dev/null +++ b/src/messenger/webim/js/compiled/chat/models/chat_user.js @@ -0,0 +1,8 @@ +/* + This file is part of Mibew Messenger project. + http://mibew.org + + Copyright (c) 2005-2011 Mibew Messenger Community + License: http://mibew.org/license.php +*/ +(function(a,b){a.Models.ChatUser=a.Models.User.extend({defaults:b.extend({},a.Models.User.prototype.defaults,{canPost:!0,typing:!1,canChangeName:!1,dafaultName:!0})})})(Mibew,_); diff --git a/src/messenger/webim/js/compiled/chat_app.js b/src/messenger/webim/js/compiled/chat_app.js index 4ce02eb4..a6795313 100644 --- a/src/messenger/webim/js/compiled/chat_app.js +++ b/src/messenger/webim/js/compiled/chat_app.js @@ -9,6 +9,7 @@ MibewAPIChatInteraction=function(){this.obligatoryArguments={"*":{threadId:null,token:null,"return":{},references:{}},result:{errorCode:0}};this.reservedFunctionNames=["result"]};MibewAPIChatInteraction.prototype=new MibewAPIInteraction; (function(b,c){b.Models.Status=b.Models.Base.extend({defaults:{visible:!0,weight:0,hideTimeout:4E3,title:""},initialize:function(){this.hideTimer=null},autoHide:function(a){a=a||this.get("hideTimeout");this.hideTimer&&clearTimeout(this.hideTimer);this.hideTimer=setTimeout(c.bind(function(){this.set({visible:!1})},this),a)}})})(Mibew,_); (function(a,b){a.Models.Avatar=a.Models.Base.extend({defaults:{imageLink:!1},initialize:function(){a.Objects.server.registerFunction("setupAvatar",b.bind(this.apiSetupAvatar,this))},apiSetupAvatar:function(a){a.imageLink&&this.set({imageLink:a.imageLink})}})})(Mibew,_); +(function(a,b){a.Models.ChatUser=a.Models.User.extend({defaults:b.extend({},a.Models.User.prototype.defaults,{canPost:!0,typing:!1,canChangeName:!1,dafaultName:!0})})})(Mibew,_); (function(a){a.Models.CloseControl=a.Models.Control.extend({getModelType:function(){return"CloseControl"},closeThread:function(){var b=a.Objects.thread;a.Objects.server.callFunctions([{"function":"close",arguments:{references:{},"return":{closed:"closed"},threadId:b.threadId,token:b.token,lastId:b.lastId,user:!a.Objects.Models.user.get("isAgent")}}],function(b){b.closed?window.close():a.Objects.Models.Status.message.setMessage(b.errorMessage||"Cannot close")},!0)}})})(Mibew); (function(a,b){a.Models.HistoryControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1}),getModelType:function(){return"HistoryControl"}})})(Mibew,_); (function(a,b){a.Models.RedirectControl=a.Models.Control.extend({defaults:b.extend({},a.Models.Control.prototype.defaults,{link:!1}),getModelType:function(){return"RedirectControl"}})})(Mibew,_); @@ -50,7 +51,7 @@ c=""!=this.ui.message.val();c!=a.get("typing")&&a.set({typing:c})},setFocus:func (function(a){a.Views.StatusCollection=a.Views.CollectionBase.extend({itemView:a.Views.Status,className:"status-collection"})})(Mibew); (function(a,b){a.Regions.Messages=b.Marionette.Region.extend({el:"#messages-region",onShow:function(a){a.on("after:item:added",this.scrollToBottom,this)},scrollToBottom:function(){this.$el.scrollTop(this.$el.prop("scrollHeight"))}})})(Mibew,Backbone); (function(a,j,k){var f=new j.Marionette.Application;f.addRegions({controlsRegion:"#controls-region",avatarRegion:"#avatar-region",messagesRegion:a.Regions.Messages,statusRegion:"#status-region",messageFormRegion:"#message-form-region",soundRegion:"#sound-region"});f.addInitializer(function(d){var g=a.Objects,c=a.Objects.Models,b=a.Objects.Models.Controls,h=a.Objects.Models.Status;g.server=new a.Server(k.extend({interactionType:MibewAPIChatInteraction},d.server));g.thread=new a.Thread(d.thread);c.user= -new a.Models.User(d.user);c.page=new a.Models.Page(d.page);var e=new a.Collections.Controls;c.user.get("isAgent")||(b.userName=new a.Models.UserNameControl({weight:220}),e.push(b.userName),b.sendMail=new a.Models.SendMailControl({weight:200,link:d.links.mailLink}),e.push(b.sendMail));c.user.get("isAgent")&&(b.redirect=new a.Models.RedirectControl({weight:200,link:d.links.redirectLink}),e.push(b.redirect),b.history=new a.Models.HistoryControl({weight:180,link:d.links.historyLink}),e.push(b.history)); +new a.Models.ChatUser(d.user);c.page=new a.Models.Page(d.page);var e=new a.Collections.Controls;c.user.get("isAgent")||(b.userName=new a.Models.UserNameControl({weight:220}),e.push(b.userName),b.sendMail=new a.Models.SendMailControl({weight:200,link:d.links.mailLink}),e.push(b.sendMail));c.user.get("isAgent")&&(b.redirect=new a.Models.RedirectControl({weight:200,link:d.links.redirectLink}),e.push(b.redirect),b.history=new a.Models.HistoryControl({weight:180,link:d.links.historyLink}),e.push(b.history)); b.sound=new a.Models.SoundControl({weight:160});e.push(b.sound);b.refresh=new a.Models.RefreshControl({weight:140});e.push(b.refresh);d.links.sslLink&&(b.secureMode=new a.Models.SecureModeControl({weight:120,link:d.links.sslLink}),e.push(b.secureMode));b.close=new a.Models.CloseControl({weight:100});e.push(b.close);g.Collections.controls=e;f.controlsRegion.show(new a.Views.ControlsCollection({collection:e}));h.message=new a.Models.StatusMessage({hideTimeout:5E3});h.typing=new a.Models.StatusTyping({hideTimeout:5E3}); g.Collections.status=new a.Collections.Status([h.message,h.typing]);f.statusRegion.show(new a.Views.StatusCollection({collection:g.Collections.status}));c.user.get("isAgent")||(c.avatar=new a.Models.Avatar,f.avatarRegion.show(new a.Views.Avatar({model:c.avatar})));g.Collections.messages=new a.Collections.Messages;c.messageForm=new a.Models.MessageForm(d.messageForm);f.messageFormRegion.show(new a.Views.MessageForm({model:c.messageForm}));f.messagesRegion.show(new a.Views.MessagesCollection({collection:g.Collections.messages})); c.sound=new a.Models.Sound;f.soundRegion.show(new a.Views.Sound({model:c.sound}));g.server.runUpdater()});a.Application=f})(Mibew,Backbone,_); diff --git a/src/messenger/webim/js/compiled/default/models/user.js b/src/messenger/webim/js/compiled/default/models/user.js index 3f276a80..13247b8a 100644 --- a/src/messenger/webim/js/compiled/default/models/user.js +++ b/src/messenger/webim/js/compiled/default/models/user.js @@ -5,4 +5,4 @@ Copyright (c) 2005-2011 Mibew Messenger Community License: http://mibew.org/license.php */ -(function(a,b){a.Models.User=b.Model.extend({defaults:{isAgent:!1,canPost:!0,typing:!1,name:"",canChangeName:!1,dafaultName:!0}})})(Mibew,Backbone); +(function(a,b){a.Models.User=b.Model.extend({defaults:{isAgent:!1,name:""}})})(Mibew,Backbone); diff --git a/src/messenger/webim/js/compiled/default_app.js b/src/messenger/webim/js/compiled/default_app.js index 93bce77a..0097a964 100644 --- a/src/messenger/webim/js/compiled/default_app.js +++ b/src/messenger/webim/js/compiled/default_app.js @@ -21,7 +21,7 @@ b.Server.prototype.registerFunction=function(a,b){a in this.functions||(this.fun (function(a){a.Models.Control=a.Models.Base.extend({defaults:{title:"",weight:0}})})(Mibew); (function(a,b){a.Models.Page=b.Model.extend()})(Mibew,Backbone); (function(a,b){a.Models.Sound=b.Model.extend({play:function(a){this.set({file:a});this.trigger("sound:play",this)}})})(Mibew,Backbone); -(function(a,b){a.Models.User=b.Model.extend({defaults:{isAgent:!1,canPost:!0,typing:!1,name:"",canChangeName:!1,dafaultName:!0}})})(Mibew,Backbone); +(function(a,b){a.Models.User=b.Model.extend({defaults:{isAgent:!1,name:""}})})(Mibew,Backbone); (function(a,b){a.Collections.Controls=b.Collection.extend({comparator:function(a){return a.get("weight")}})})(Mibew,Backbone); (function(b,c,d){b.Views.Control=c.Marionette.ItemView.extend({template:d.templates.default_control,modelEvents:{change:"render"},events:{mouseover:"mouseOver",mouseleave:"mouseLeave"},attributes:function(){var a=[];a.push("control");this.className&&(a.push(this.className),this.className="");var b=this.getDashedControlType();b&&a.push(b);return{"class":a.join(" ")}},mouseOver:function(){var a=this.getDashedControlType();this.$el.addClass("active"+(a?"-"+a:""))},mouseLeave:function(){var a=this.getDashedControlType(); this.$el.removeClass("active"+(a?"-"+a:""))},getDashedControlType:function(){"undefined"==typeof this.dashedControlType&&(this.dashedControlType=b.Utils.toDashFormat(this.model.getModelType())||"");return this.dashedControlType}})})(Mibew,Backbone,Handlebars); diff --git a/src/messenger/webim/js/source/chat/app.js b/src/messenger/webim/js/source/chat/app.js index 12749edb..d3b769e9 100644 --- a/src/messenger/webim/js/source/chat/app.js +++ b/src/messenger/webim/js/source/chat/app.js @@ -38,7 +38,7 @@ options.server )); objs.thread = new Mibew.Thread(options.thread); - models.user = new Mibew.Models.User(options.user); + models.user = new Mibew.Models.ChatUser(options.user); // Initialize Page diff --git a/src/messenger/webim/js/source/chat/models/chat_user.js b/src/messenger/webim/js/source/chat/models/chat_user.js new file mode 100644 index 00000000..773ac1ea --- /dev/null +++ b/src/messenger/webim/js/source/chat/models/chat_user.js @@ -0,0 +1,56 @@ +/** + * @preserve This file is part of Mibew Messenger project. + * http://mibew.org + * + * Copyright (c) 2005-2011 Mibew Messenger Community + * License: http://mibew.org/license.php + */ + +(function(Mibew, _) { + + /** + * @class Represents an user. + */ + Mibew.Models.ChatUser = Mibew.Models.User.extend( + /** @lends Mibew.Models.ChatUser.prototype */ + { + /** + * A list of default model values. + * Inherits values from Mibew.Models.User + * @type Object + */ + defaults: _.extend( + {}, + Mibew.Models.User.prototype.defaults, + { + /** + * Indicates if user can post messages or not. + * @type Boolean + */ + canPost: true, + + /** + * Indicates if user typing a message at the moment. + * @type Boolean + */ + typing: false, + + /** + * Indicates if user can change name or not. + * Not applicable for agents. + * @type Boolean + */ + canChangeName: false, + + /** + * Indicates if user have default name. + * Not applicable for agents. + * @type Boolean + */ + dafaultName: true + } + ) + } + ); + +})(Mibew, _); \ No newline at end of file diff --git a/src/messenger/webim/js/source/default/models/user.js b/src/messenger/webim/js/source/default/models/user.js index 9d89d30c..c2d233b8 100644 --- a/src/messenger/webim/js/source/default/models/user.js +++ b/src/messenger/webim/js/source/default/models/user.js @@ -9,7 +9,7 @@ (function(Mibew, Backbone) { /** - * @class Represents a user + * @class Represents an user */ Mibew.Models.User = Backbone.Model.extend( /** @lends Mibew.Models.User.prototype */ @@ -26,38 +26,11 @@ */ isAgent: false, - /** - * Indicates if user can post messages or not. - * @type Boolean - */ - canPost: true, - - /** - * Indicates if user typing a message at the moment. - * @type Boolean - */ - typing: false, - /** * Represents user name. - * Not applicable for agents. * @type String */ - name: '', - - /** - * Indicates if user can change name or not. - * Not applicable for agents. - * @type Boolean - */ - canChangeName: false, - - /** - * Indicates if user have default name. - * Not applicable for agents. - * @type Boolean - */ - dafaultName: true + name: '' } } );