@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 8.27 kB
JavaScript
module.exports=function(e){function t(r){if(s[r])return s[r].exports;var i=s[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var s={};return t.m=e,t.c=s,t.p="",t(0)}({0:function(e,t,s){s(1676),e.exports=s(1676)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},20:function(e,t){e.exports=require("../kendo.core")},1676:function(e,t,s){var r,i,a;!function(n,define){i=[s(20),s(1677)],r=n,a="function"==typeof r?r.apply(t,i):r,!(void 0!==a&&(e.exports=a))}(function(){!function(e){var t=e.jQuery,s=e._outerWidth,r=".",i=" ",a={sheetsBarWrapper:"k-widget k-header",sheetsBarSheetsWrapper:"k-tabstrip k-floatwrap k-tabstrip-bottom",sheetsBarActive:"k-spreadsheet-sheets-bar-active",sheetsBarInactive:"k-spreadsheet-sheets-bar-inactive",sheetsBarAdd:"k-spreadsheet-sheets-bar-add",sheetsBarRemove:"k-spreadsheet-sheets-remove",sheetsBarItems:"k-spreadsheet-sheets-items",sheetsBarEditor:"k-spreadsheet-sheets-editor",sheetsBarScrollable:"k-tabstrip-scrollable",sheetsBarNext:"k-tabstrip-next",sheetsBarPrev:"k-tabstrip-prev",sheetsBarKItem:"k-item k-tabstrip-item k-state-default",sheetsBarKActive:"k-state-active k-state-tab-on-top",sheetsBarKTextbox:"k-textbox",sheetsBarKLink:"k-link",sheetsBarKIcon:"k-icon",sheetsBarKFontIcon:"k-icon",sheetsBarKButton:"k-button k-button-icon",sheetsBarKButtonBare:"k-flat",sheetsBarKArrowW:"k-i-arrow-60-left",sheetsBarKArrowE:"k-i-arrow-60-right",sheetsBarKReset:"k-reset k-tabstrip-items",sheetsBarKIconX:"k-i-close",sheetsBarKSprite:"k-sprite",sheetsBarKIconPlus:"k-i-plus",sheetsBarHintWrapper:"k-widget k-tabstrip k-tabstrip-bottom k-spreadsheet-sheets-items-hint",sheetsBarKResetItems:"k-reset k-tabstrip-items"},n=e.ui.Widget.extend({init:function(t,s){var i=n.classNames;e.ui.Widget.call(this,t,s),t=this.element,t.addClass(i.sheetsBarWrapper),this._openDialog=s.openDialog,this._tree=new e.dom.Tree(t[0]),this._tree.render([this._addButton(),this._createSheetsWrapper([])]),this._toggleScrollEvents(!0),this._createSortable(),this._sortable.bind("start",this._onSheetReorderStart.bind(this)),this._sortable.bind("end",this._onSheetReorderEnd.bind(this)),t.on("click",r+i.sheetsBarRemove,this._onSheetRemove.bind(this)),t.on("click","li",this._onSheetSelect.bind(this)),t.on("dblclick","li"+r+i.sheetsBarActive,this._createEditor.bind(this)),t.on("click",r+i.sheetsBarAdd,this._onAddSelect.bind(this))},options:{name:"SheetsBar",scrollable:{distance:200}},events:["select","reorder","rename"],_createEditor:function(){this._editor||(this._renderSheets(this._sheets,this._selectedIndex,!0),this._editor=this.element.find(e.format("input{0}{1}",r,n.classNames.sheetsBarEditor)).trigger("focus").on("keydown",this._onEditorKeydown.bind(this)).on("blur",this._onEditorBlur.bind(this)))},_destroyEditor:function(e){var t=e?null:this._editor.val();this._editor.off(),this._editor=null,this._renderSheets(this._sheets,this._selectedIndex,!1),this._onSheetRename(t)},renderSheets:function(e,t){!e||t<0||this._renderSheets(e,t,!1)},_renderSheets:function(t,s,r){var a,o=this,l=n.classNames;o._isRtl=e.support.isRtl(o.element),o._sheets=t,o._selectedIndex=s,o._renderHtml(r,!0),o._scrollableAllowed()&&(a=o._sheetsWrapper(),a.addClass(l.sheetsBarScrollable+i+l.sheetsBarSheetsWrapper),o._toggleScrollButtons())},_toggleScrollButtons:function(t){var s=this,i=s._sheetsGroup(),a=s._sheetsWrapper(),o=e.scrollLeft(i),l=a.find(r+n.classNames.sheetsBarPrev),h=a.find(r+n.classNames.sheetsBarNext);t===!1?(l.addClass("k-disabled"),h.addClass("k-disabled")):(l.toggleClass("k-disabled",!(s._isRtl?o<i[0].scrollWidth-i[0].offsetWidth-1:0!==o)),h.toggleClass("k-disabled",!(s._isRtl?0!==o:o<i[0].scrollWidth-i[0].offsetWidth-1)))},_toggleScrollEvents:function(e){var t=this,s=n.classNames,i=t.options,a=t._sheetsWrapper(),o=a.find(r+s.sheetsBarPrev),l=a.find(r+s.sheetsBarNext);e?(o.on("mousedown",function(){t._nowScrollingSheets=!0,t._scrollSheetsByDelta(i.scrollable.distance*(t._isRtl?1:-1))}),l.on("mousedown",function(){t._nowScrollingSheets=!0,t._scrollSheetsByDelta(i.scrollable.distance*(t._isRtl?-1:1))}),o.add(l).on("mouseup",function(){t._nowScrollingSheets=!1})):(o.off(),l.off())},_renderHtml:function(t,s){var r,a,o,l,h,d,c=[],u=e.dom,p=u.element,_=this._sheets,m=this._selectedIndex,B=n.classNames;for(r=0;r<_.length;r++)a=_[r],o=r===m,l={className:B.sheetsBarKItem+i},h=[],l.className+=o?B.sheetsBarKActive+i+B.sheetsBarActive:B.sheetsBarInactive,o&&t?h.push(p("input",{type:"text",value:a.name(),className:B.sheetsBarKTextbox+i+B.sheetsBarEditor,maxlength:50},[])):(h.push(p("span",{className:B.sheetsBarKLink,title:a.name()},[u.text(a.name())])),_.length>1&&(d=p("span",{className:B.sheetsBarKIcon+i+B.sheetsBarKFontIcon+i+B.sheetsBarKIconX},[]),h.push(p("span",{className:B.sheetsBarKLink+i+B.sheetsBarRemove,"data-type":"remove"},[d])))),c.push(p("li",l,h));this._tree.render([this._addButton(),this._createSheetsWrapper(c,s)])},_createSheetsWrapper:function(t,s){var r,a=e.dom.element,o=n.classNames,l=a("div",{className:"k-tabstrip-items-wrapper k-hstack"}),h=[null,a("ul",{className:o.sheetsBarKReset},t),null];return s=!0,s&&(r=o.sheetsBarKButton+i+o.sheetsBarKButtonBare+i,h[0]=a("span",{className:r+o.sheetsBarPrev},[a("span",{className:o.sheetsBarKIcon+i+o.sheetsBarKArrowW},[])]),h[2]=a("span",{className:r+o.sheetsBarNext},[a("span",{className:o.sheetsBarKIcon+i+o.sheetsBarKArrowE},[])])),l.children=h,a("div",{className:o.sheetsBarItems},[l])},_createSortable:function(){var s=n.classNames;this._sortable=new e.ui.Sortable(this.element,{filter:e.format("ul li.{0},ul li.{1}",s.sheetsBarActive,s.sheetsBarInactive),container:r+s.sheetsBarItems,axis:"x",animation:!1,ignore:"input",end:function(){this.draggable.hint&&this.draggable.hint.remove()},hint:function(e){var r=t(e).clone();return r.wrap("<div class='"+s.sheetsBarHintWrapper+"'><ul class='"+s.sheetsBarKResetItems+"'></ul></div>").closest("div")}})},_onEditorKeydown:function(e){this._editor&&(13===e.which&&this._destroyEditor(),27===e.which&&this._destroyEditor(!0))},_onEditorBlur:function(){this._editor&&this._destroyEditor()},_onSheetReorderEnd:function(e){e.preventDefault(),this.trigger("reorder",{oldIndex:e.oldIndex,newIndex:e.newIndex})},_onSheetReorderStart:function(e){this._editor&&e.preventDefault()},_onSheetRemove:function(e){var s,r=t(e.target).closest("li").text();this._editor&&this._destroyEditor(),s=function(e){var t=e.sender;t.isConfirmed()&&this.trigger("remove",{name:r,confirmation:!0})}.bind(this),this._openDialog("confirmation",{close:s})},_onSheetSelect:function(e){var s=t(e.target).text();return t(e.target).is(r+n.classNames.sheetsBarEditor)||!s?void e.preventDefault():(this._editor&&this._destroyEditor(),this._scrollSheetsToItem(t(e.target).closest("li")),void this.trigger("select",{name:s,isAddButton:!1}))},_onSheetRename:function(e){this._sheets[this._selectedIndex].name()!==e&&null!==e&&this.trigger("rename",{name:e,sheetIndex:this._selectedIndex})},_onAddSelect:function(){this.trigger("select",{isAddButton:!0})},_addButton:function(){var t=e.dom.element,s=n.classNames;return t("a",{className:s.sheetsBarAdd+i+s.sheetsBarKButton},[t("span",{className:s.sheetsBarKIcon+i+s.sheetsBarKFontIcon+i+s.sheetsBarKIconPlus},[])])},destroy:function(){this._sortable.destroy()},_scrollableAllowed:function(){var e=this.options;return e.scrollable&&!isNaN(e.scrollable.distance)},_scrollSheetsToItem:function(t){var r,i=this,a=i._sheetsGroup(),n=e.scrollLeft(a),o=s(t),l=i._isRtl?t.position().left:t.position().left-a.children().first().position().left,h=a[0].offsetWidth;i._isRtl?l<0?r=n+l-(h-n):l+o>h&&(r=n+l-o):n+h<l+o?r=l+o-h:n>l&&(r=l),a.finish().animate({scrollLeft:r},"fast","linear",function(){i._toggleScrollButtons()})},_sheetsGroup:function(){return this._sheetsWrapper().find("ul")},_sheetsWrapper:function(){return this.element.find(r+n.classNames.sheetsBarItems)},_scrollSheetsByDelta:function(t){var s=this,r=s._sheetsGroup(),i=e.scrollLeft(r);r.finish().animate({scrollLeft:i+t},"fast","linear",function(){s._nowScrollingSheets?s._scrollSheetsByDelta(t):s._toggleScrollButtons()})}});e.spreadsheet.SheetsBar=n,t.extend(!0,n,{classNames:a})}(window.kendo)},s(3))},1677:function(e,t){e.exports=require("../kendo.sortable")}});