@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 4.38 kB
JavaScript
module.exports=function(t){function o(e){if(n[e])return n[e].exports;var i=n[e]={exports:{},id:e,loaded:!1};return t[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}var n={};return o.m=t,o.c=n,o.p="",o(0)}({0:function(t,o,n){n(20),t.exports=n(20)},3:function(t,o){t.exports=function(){throw Error("define cannot be used indirect")}},19:function(t,o){t.exports=require("../kendo.core")},20:function(t,o,n){var e,i,s;!function(l,define){i=[n(19)],e=l,s="function"==typeof e?e.apply(o,i):e,!(void 0!==s&&(t.exports=s))}(function(){return function(t,o){var n=window.kendo,e=n.ui.Widget,i=t.extend,s=t.proxy,l=".",r=".kendoChat",a="kButtonName",c="chatToolbarScrollLeft",u="chatToolbarScrollRight",h=":visible",d={effects:"expand:vertical",duration:200},f={expand:{show:!0},collapse:{hide:!0}},p={button:"k-button",buttonFlat:"k-flat",buttonList:"k-button-list",scrollButton:"k-scroll-button",scrollButtonLeft:"k-scroll-button-left",scrollButtonRight:"k-scroll-button-right",scrollButtonLeftIcon:"k-icon k-i-arrow-chevron-left",scrollButtonRightIcon:"k-icon k-i-arrow-chevron-right",buttonIcon:"k-button-icon"},b=e.extend({init:function(t,o){var n,l;o=i({},o,{name:"ChatToolbar"}),n=o.toolbar,l=n.buttons&&n.buttons.length,e.fn.init.call(this,t,o),l&&this._createButtonList(),l&&n.scrollable&&this.buttonsWidth()>this.element.width()&&this._initScrolling(),this._setupAnimation(),n.toggleable&&this.toggle(!0),this.element.on("click"+r,s(this._onClick,this))},events:["click"],destroy:function(){e.fn.destroy.call(this),this.element.off(r),this.element.empty()},_createButtonList:function(){var o,n,e=this,i=b.styles,s=e.options.toolbar.buttons,l=t("<div class='"+i.buttonList+"'></div>");for(o=0;o<s.length;o++)n=e._createButton(s[o]),l.append(n);l.appendTo(this.element),this.buttonList=l},_createButton:function(o){var n=b.styles,e=t("<button>");return"string"==typeof o&&(o={name:o}),e.attr(o.attr||{}).attr("title",o.text).attr("type","button").addClass(o.name).data(a,o.name).addClass(n.button),o.iconClass&&(e.addClass(n.buttonIcon),e.prepend("<span class='"+o.iconClass+"'></span>")),e},_onClick:function(o){var n=b.styles,e=t(o.target).closest(l+n.button);e.is(l+n.scrollButton)&&!this._scrolling&&this._scroll(e.data(a)),e.data(a)&&this.trigger("click",{button:e[0],name:e.data(a),originalEvent:o})},_initScrolling:function(){var t=b.styles;this.scrollButtonLeft=this._createButton({name:c,iconClass:t.scrollButtonLeftIcon,attr:{"class":t.scrollButton+" "+t.scrollButtonLeft}}),this.scrollButtonRight=this._createButton({name:u,iconClass:t.scrollButtonRightIcon,attr:{"class":t.scrollButton+" "+t.scrollButtonRight}}),this.element.prepend(this.scrollButtonLeft),this.element.append(this.scrollButtonRight),this._refreshScrollButtons(),this.element.on("keydown"+r,s(this._refreshScrollButtons,this))},_scroll:function(t){var o=this,n=o.buttonWidth(),e=this.maxScrollSize(),i=t===c?n*-1:n,s=this.currentScrollLeft(),l=s+i;l=Math.min(Math.max(l,0),e),t!==c&&t!==u||(o.buttonList.scrollLeft(l),o._refreshScrollButtons(l))},_refreshScrollButtons:function(t){var n=this.maxScrollSize(),e=t===o||isNaN(parseInt(t,10))?this.currentScrollLeft():t;(this.scrollButtonLeft||this.scrollButtonRight)&&(this.scrollButtonLeft.toggle(0!==e),this.scrollButtonRight.toggle(e!==n))},_setupAnimation:function(){var t=this.options.toolbar.animation,o=i({},d),n=i({reverse:!0,hide:!0},d);t=t===!1?i(!0,{},f):i(!0,{expand:o,collapse:n},t),this.options.toolbar.animation=t},_animationComplete:function(){this._refreshScrollButtons()},currentScrollLeft:function(){return Math.round(this.buttonList.scrollLeft())},maxScrollSize:function(){return Math.round(this.buttonList[0].scrollWidth-this.buttonList[0].clientWidth)},buttons:function(){var t=b.styles;return this.buttonList?this.buttonList.children(l+t.button):null},buttonWidth:function(){return Math.round(this.buttons().last().outerWidth(!0))},buttonsWidth:function(){var t=0;return this.buttons()&&(t=this.buttonWidth()*this.buttons().length),t},toggle:function(t){var o=this.options.toolbar.animation;t&&(o=i(!0,{},f)),o.expand.complete=s(this._animationComplete,this),o.collapse.complete=s(this._animationComplete,this),this.element.is(h)?this.element.kendoStop().kendoAnimate(o.collapse):this.element.kendoStop().kendoAnimate(o.expand)}});i(!0,b,{styles:p}),i(n.chat,{ChatToolBar:b})}(window.kendo.jQuery),window.kendo},n(3))}});