@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 4.73 kB
JavaScript
module.exports=function(o){var s={};function i(t){if(s[t])return s[t].exports;var e=s[t]={exports:{},id:t,loaded:!1};return o[t].call(e.exports,e,e.exports,i),e.loaded=!0,e.exports}return i.m=o,i.c=s,i.p="",i(0)}({0:function(t,e,o){t.exports=o(1098)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},1098:function(t,e,o){var s;o(3),o=[o(1099),o(1100),o(1101)],void 0===(e="function"==typeof(s=function(){var t={id:"chat",name:"Chat",category:"web",description:"The Chat component.",depends:["core","draganddrop"]},e=window.kendo.jQuery,i=void 0,r=window.kendo,s=r.ui.Widget,n=e.extend,a=".",o={wrapper:"k-widget k-chat",canvas:"k-chat-canvas",viewWrapper:"k-message-list",messageBoxWrapper:"k-message-box",toolbarBoxWrapper:"k-toolbar-box"},l=s.extend({init:function(t,e,o){s.fn.init.call(this,t,e);if(o)this._events=o;this._user();this._wrapper();this._view();this._messageBox();if(e&&e.toolbar&&e.toolbar.buttons)this._toolbar();r.notify(this)},events:["typingStart","typingEnd","post","sendMessage","actionClick","toolClick"],options:{user:{name:"User",iconUrl:""},name:"Chat",messages:{messageListLabel:"Message list",placeholder:"Type a message...",toggleButton:"Toggle toolbar",sendButton:"Send message"},toolbar:false},setOptions:function(t){this._setEvents(t);e.extend(true,this.options,t);if(this.toolbar&&"toolbar"in t){this.toolbar.destroy();this.toolbar=null}if(this.messageBox){this.messageBox.unbind();this.messageBox.destroy();this.messageBox=null}this._messageBox();if("toolbar"in t){this._resetToolbarButtons(t);this._toolbar()}},_resetToolbarButtons:function(t){var e=this.wrapper.find(a+o.toolbarBoxWrapper);if(!e.is(":visible"))e.show();if(t.toolbar&&typeof t.toolbar=="object"&&"buttons"in t.toolbar)this.options.toolbar.buttons=t.toolbar.buttons},destroy:function(){if(this.view){this.view.unbind();this.view.destroy();this.view=null}if(this.messageBox){this.messageBox.unbind();this.messageBox.destroy();this.messageBox=null}if(this.toolbar){this.toolbar.destroy();this.toolbar=null}s.fn.destroy.call(this)},_user:function(){this.options.user.id=r.guid()},getUser:function(){return n(true,{},this.options.user)},_wrapper:function(){var t=l.styles;var e=this.options;var o=e.height;var s=e.width;var i="<div class='"+t.viewWrapper+"'></div>"+"<span class='"+t.messageBoxWrapper+"'></span>"+"<div class='"+t.toolbarBoxWrapper+"' role='toolbar' style='display:none;'></div>";this.wrapper=this.element.addClass(t.wrapper).append(i);if(e.toolbar&&e.toolbar.buttons&&e.toolbar.buttons.length)this.wrapper.find(a+t.toolbarBoxWrapper).show();if(o)this.wrapper.height(o);if(s)this.wrapper.css("max-width",s)},_view:function(){var e=this;var t=l.styles;var o=n(true,{},this.options);var s=this.wrapper.find(a+t.viewWrapper+"");this.view=new r.chat.ChatView(s,o);this.view.bind("actionClick",function(t){e.trigger("actionClick",t);e.postMessage(t.text)})},_messageBox:function(){var e=this;var t=l.styles;var o=n(true,{},this.options);var s=this.wrapper.find(a+t.messageBoxWrapper+"");this.messageBox=new r.chat.ChatMessageBox(s,o);this.messageBox.bind("typingStart",function(t){e.trigger("typingStart",t)}).bind("typingEnd",function(t){e.trigger("typingEnd",t)}).bind("sendMessage",function(t){e.trigger("sendMessage",t);e.postMessage(t.text)}).bind("toggleToolbar",function(){e.toggleToolbar()})},_toolbar:function(){var e=this;var t=l.styles;var o=n(true,{},e.options);var s=e.wrapper.find(a+t.toolbarBoxWrapper+"");if(o.toolbar.scrollable===i)this.options.toolbar.scrollable=o.toolbar.scrollable=true;if(o.toolbar.toggleable===i)this.options.toolbar.toggleable=o.toolbar.toggleable=false;e.toolbar=new r.chat.ChatToolBar(s,o);e.toolbar.bind("click",function(t){e.trigger("toolClick",{sender:e,name:t.name,button:t.button,messageBox:e.messageBox.input[0],originalEvent:t.originalEvent})})},postMessage:function(t){var e=n(true,{},{text:t,type:"message",timestamp:new Date,from:this.getUser()});this.trigger("post",e);this.renderMessage(e,e.from)},renderMessage:function(t,e){this.view.renderMessage(t,e)},renderSuggestedActions:function(t){this.view.renderSuggestedActions(t)},renderAttachments:function(t,e){this.view.renderAttachments(t,e)},toggleToolbar:function(t){this.toolbar.toggle(t)},renderUserTypingIndicator:function(t){this.view._renderTypingIndicator(t)},clearUserTypingIndicator:function(t){this.view._removeTypingParticipant(t)},removeTypingIndicator:function(){this.view._removeTypingIndicator()}});return r.ui.plugin(l),n(true,l,{styles:o}),window.kendo})?s.apply(e,o):s)||(t.exports=e)},1099:function(t,e){t.exports=require("./chat/messageBox")},1100:function(t,e){t.exports=require("./chat/toolbar")},1101:function(t,e){t.exports=require("./chat/view")}});