@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 8.8 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(1536),e.exports=s(1536)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},19:function(e,t){e.exports=require("../kendo.core")},1536:function(e,t,s){var r,i,o;!function(n,define){i=[s(19),s(1537)],r=n,o="function"==typeof r?r.apply(t,i):r,!(void 0!==o&&(e.exports=o))}(function(){!function(e){var t,s,r,i,o,n;e.support.browser.msie&&e.support.browser.version<9||(t=e.jQuery,s=e._outerWidth,r=".",i=" ",o={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-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-bare",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)).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,o,a){var l,h,c,d,u,p,_,f,m,B,v,g=this,b=n.classNames;g._isRtl=e.support.isRtl(g.element),g._sheets=t,g._selectedIndex=o,g._renderHtml(a,!0),g._scrollableAllowed()&&(c=g._sheetsWrapper(),d=c.children(r+b.sheetsBarPrev),u=c.children(r+b.sheetsBarNext),p=2,_=g.element.find(r+b.sheetsBarAdd),f=s(_)+_.position().left+p,m=s(d)+p,B=g._sheetsGroup(),d.css({left:f}),c.addClass(b.sheetsBarScrollable+i+b.sheetsBarSheetsWrapper),B.css({marginLeft:f}),l=c[0].offsetWidth,h=B[0].scrollWidth,h+f>l?(v=Math.ceil(e.parseFloat(u.css("right"))),g._scrollableModeActive||(g._nowScrollingSheets=!1,g._scrollableModeActive=!0),B.css({marginLeft:m+f,marginRight:s(u)+v+p})):g._scrollableModeActive&&h<=l?(g._scrollableModeActive=!1,B.css({marginLeft:f,marginRight:""})):B.css({marginLeft:f}),g._toggleScrollButtons())},_toggleScrollButtons:function(e){var t=this,s=t._sheetsGroup(),i=t._sheetsWrapper(),o=s.scrollLeft(),a=i.find(r+n.classNames.sheetsBarPrev),l=i.find(r+n.classNames.sheetsBarNext);e===!1?(a.toggle(!1),l.toggle(!1)):(a.toggle(t._isRtl?o<s[0].scrollWidth-s[0].offsetWidth-1:0!==o),l.toggle(t._isRtl?0!==o:o<s[0].scrollWidth-s[0].offsetWidth-1))},_toggleScrollEvents:function(e){var t=this,s=n.classNames,i=t.options,o=t._sheetsWrapper(),a=o.children(r+s.sheetsBarPrev),l=o.children(r+s.sheetsBarNext);e?(a.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))}),a.add(l).on("mouseup",function(){t._nowScrollingSheets=!1})):(a.off(),l.off())},_renderHtml:function(t,s){var r,o,a,l,h,c,d=[],u=e.dom,p=u.element,_=this._sheets,f=this._selectedIndex,m=n.classNames;for(r=0;r<_.length;r++)o=_[r],a=r===f,l={className:m.sheetsBarKItem+i},h=[],l.className+=a?m.sheetsBarKActive+i+m.sheetsBarActive:m.sheetsBarInactive,a&&t?h.push(p("input",{type:"text",value:o.name(),className:m.sheetsBarKTextbox+i+m.sheetsBarEditor,maxlength:50},[])):(h.push(p("span",{className:m.sheetsBarKLink,title:o.name()},[u.text(o.name())])),_.length>1&&(c=p("span",{className:m.sheetsBarKIcon+i+m.sheetsBarKFontIcon+i+m.sheetsBarKIconX},[]),h.push(p("span",{className:m.sheetsBarKLink+i+m.sheetsBarRemove},[c])))),d.push(p("li",l,h));this._tree.render([this._addButton(),this._createSheetsWrapper(d,s)])},_createSheetsWrapper:function(t,s){var r,o=e.dom.element,a=n.classNames,l=[o("ul",{className:a.sheetsBarKReset},t)];return s=!0,s&&(r=a.sheetsBarKButton+i+a.sheetsBarKButtonBare+i,l.push(o("span",{className:r+a.sheetsBarPrev},[o("span",{className:a.sheetsBarKIcon+i+a.sheetsBarKArrowW},[])])),l.push(o("span",{className:r+a.sheetsBarNext},[o("span",{className:a.sheetsBarKIcon+i+a.sheetsBarKArrowE},[])]))),o("div",{className:a.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(e){var t,r,i,o,n,a,l,h=this;h._scrollableModeActive&&(t=h._sheetsGroup(),r=t.scrollLeft(),i=s(e),o=h._isRtl?e.position().left:e.position().left-t.children().first().position().left,n=t[0].offsetWidth,a=Math.ceil(parseFloat(t.css("padding-left"))),h._isRtl?o<0?l=r+o-(n-r)-a:o+i>n&&(l=r+o-i+2*a):r+n<o+i?l=o+i-n+2*a:r>o&&(l=o-a),t.finish().animate({scrollLeft:l},"fast","linear",function(){h._toggleScrollButtons()}))},_sheetsGroup:function(){return this._sheetsWrapper().children("ul")},_sheetsWrapper:function(){return this.element.find(r+n.classNames.sheetsBarItems)},_scrollSheetsByDelta:function(e){var t=this,s=t._sheetsGroup(),r=s.scrollLeft();s.finish().animate({scrollLeft:r+e},"fast","linear",function(){t._nowScrollingSheets?t._scrollSheetsByDelta(e):t._toggleScrollButtons()})}}),e.spreadsheet.SheetsBar=n,t.extend(!0,n,{classNames:o}))}(window.kendo)},s(3))},1537:function(e,t){e.exports=require("../kendo.sortable")}});