UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 8.79 kB
module.exports=function(s){var r={};function a(e){if(r[e])return r[e].exports;var t=r[e]={exports:{},id:e,loaded:!1};return s[e].call(t.exports,t,t.exports,a),t.loaded=!0,t.exports}return a.m=s,a.c=r,a.p="",a(0)}({0:function(e,t,s){e.exports=s(1732)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},20:function(e,t){e.exports=require("../kendo.core")},1732:function(e,t,s){var r;s(3),s=[s(20),s(1733)],void 0===(t="function"==typeof(r=function(){var p=window.kendo,r=p.jQuery,l=p._outerWidth,o=".",_=" ",e={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",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-icon-button",sheetsBarKButtonDefaults:"k-button-md k-rounded-md k-button-solid k-button-solid-base",sheetsBarKButtonBare:"k-button-md k-rounded-md k-button-flat k-button-flat-base",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"},m=p.ui.Widget.extend({init:function(e,t){var s=m.classNames;p.ui.Widget.call(this,e,t);e=this.element;e.addClass(s.sheetsBarWrapper);this._openDialog=t.openDialog;this._tree=new p.dom.Tree(e[0]);this._tree.render([this._addButton(),this._createSheetsWrapper([])]);this._toggleScrollEvents(true);this._createSortable();this._sortable.bind("start",this._onSheetReorderStart.bind(this));this._sortable.bind("end",this._onSheetReorderEnd.bind(this));e.on("click",o+s.sheetsBarRemove,this._onSheetRemove.bind(this));e.on("click","li",this._onSheetSelect.bind(this));e.on("dblclick","li"+o+s.sheetsBarActive,this._createEditor.bind(this));e.on("click",o+s.sheetsBarAdd,this._onAddSelect.bind(this))},options:{name:"SheetsBar",scrollable:{distance:200}},events:["select","reorder","rename"],_createEditor:function(){if(this._editor)return;this._renderSheets(this._sheets,this._selectedIndex,true);this._editor=this.element.find(p.format("input{0}{1}",o,m.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,false);this._onSheetRename(t)},renderSheets:function(e,t){if(!e||t<0)return;this._renderSheets(e,t,false)},_renderSheets:function(e,t,s){var r=this;var a=m.classNames;r._isRtl=p.support.isRtl(r.element);r._sheets=e;r._selectedIndex=t;r._renderHtml(s,true);if(!r._scrollableAllowed())return;var i=r._sheetsWrapper();i.addClass(a.sheetsBarScrollable+_+a.sheetsBarSheetsWrapper);r._toggleScrollButtons()},_toggleScrollButtons:function(e){var t=this;var s=t._sheetsGroup();var r=t._sheetsWrapper();var a=p.scrollLeft(s);var i=r.find(o+m.classNames.sheetsBarPrev);var n=r.find(o+m.classNames.sheetsBarNext);if(e===false){i.addClass("k-disabled");n.addClass("k-disabled")}else{i.toggleClass("k-disabled",!(t._isRtl?a<s[0].scrollWidth-s[0].offsetWidth-1:a!==0));n.toggleClass("k-disabled",!(t._isRtl?a!==0:a<s[0].scrollWidth-s[0].offsetWidth-1))}},_toggleScrollEvents:function(e){var t=this;var s=m.classNames;var r=t.options;var a;var i;var n=t._sheetsWrapper();a=n.find(o+s.sheetsBarPrev);i=n.find(o+s.sheetsBarNext);if(e){a.on("mousedown",function(e){e.preventDefault();e.stopPropagation();t._nowScrollingSheets=true;t._scrollSheetsByDelta(r.scrollable.distance*(t._isRtl?1:-1))});i.on("mousedown",function(e){e.preventDefault();e.stopPropagation();t._nowScrollingSheets=true;t._scrollSheetsByDelta(r.scrollable.distance*(t._isRtl?-1:1))});a.add(i).on("mouseup",function(){t._nowScrollingSheets=false})}else{a.off();i.off()}},_renderHtml:function(d,c){var e;var t=[];var s=p.dom;var r=s.element;var a=this._sheets;var u=this._selectedIndex;var i=m.classNames;for(e=0;e<a.length;e++){var n=a[e];var o=e===u;var l={className:i.sheetsBarKItem+_};var h=[];if(o)l.className+=i.sheetsBarKActive+_+i.sheetsBarActive;else l.className+=i.sheetsBarInactive;if(o&&d)h.push(r("input",{type:"text",value:n.name(),className:i.sheetsBarKTextbox+_+i.sheetsBarEditor,maxlength:50},[]));else{h.push(r("span",{className:i.sheetsBarKLink,title:n.name()},[s.text(n.name())]));if(a.length>1){var f=r("span",{className:i.sheetsBarKIcon+_+i.sheetsBarKFontIcon+_+i.sheetsBarKIconX},[]);h.push(r("span",{className:i.sheetsBarKLink+_+i.sheetsBarRemove,"data-type":"remove"},[f]))}}t.push(r("li",l,h))}this._tree.render([this._addButton(),this._createSheetsWrapper(t,c)])},_createSheetsWrapper:function(e,t){var s=p.dom.element;var r=m.classNames;var a=s("div",{className:"k-tabstrip-items-wrapper k-hstack"});var i=[null,s("ul",{className:r.sheetsBarKReset},e),null];t=true;if(t){var n=r.sheetsBarKButton+_+r.sheetsBarKButtonBare+_;i[0]=s("span",{className:n+r.sheetsBarPrev},[s("span",{className:"k-button-icon"+_+r.sheetsBarKIcon+_+r.sheetsBarKArrowW},[])]);i[2]=s("span",{className:n+r.sheetsBarNext},[s("span",{className:"k-button-icon"+_+r.sheetsBarKIcon+_+r.sheetsBarKArrowE},[])])}a.children=i;return s("div",{className:r.sheetsBarItems},[a])},_createSortable:function(){var s=m.classNames;this._sortable=new p.ui.Sortable(this.element,{filter:p.format("ul li.{0},ul li.{1}",s.sheetsBarActive,s.sheetsBarInactive),container:o+s.sheetsBarItems,axis:"x",animation:false,ignore:"input",end:function(){if(this.draggable.hint)this.draggable.hint.remove()},hint:function(e){var t=r(e).clone();return t.wrap("<div class='"+s.sheetsBarHintWrapper+"'><ul class='"+s.sheetsBarKResetItems+"'></ul></div>").closest("div")}})},_onEditorKeydown:function(e){if(this._editor){if(e.which===13)this._destroyEditor();if(e.which===27)this._destroyEditor(true)}},_onEditorBlur:function(){if(this._editor)this._destroyEditor()},_onSheetReorderEnd:function(e){e.preventDefault();this.trigger("reorder",{oldIndex:e.oldIndex,newIndex:e.newIndex})},_onSheetReorderStart:function(e){if(this._editor)e.preventDefault()},_onSheetRemove:function(e){var s=r(e.target).closest("li").text();if(this._editor)this._destroyEditor();var t=function(e){var t=e.sender;if(t.isConfirmed())this.trigger("remove",{name:s,confirmation:true})}.bind(this);this._openDialog("confirmation",{close:t})},_onSheetSelect:function(e){var t=r(e.target).text();if(r(e.target).is(o+m.classNames.sheetsBarEditor)||!t){e.preventDefault();return}if(this._editor)this._destroyEditor();this._scrollSheetsToItem(r(e.target).closest("li"));this.trigger("select",{name:t,isAddButton:false})},_onSheetRename:function(e){if(this._sheets[this._selectedIndex].name()===e||e===null)return;this.trigger("rename",{name:e,sheetIndex:this._selectedIndex})},_onAddSelect:function(){this.trigger("select",{isAddButton:true})},_addButton:function(){var e=p.dom.element;var t=m.classNames;return e("a",{className:t.sheetsBarAdd+_+t.sheetsBarKButton+_+t.sheetsBarKButtonDefaults},[e("span",{className:"k-button-icon"+_+t.sheetsBarKIcon+_+t.sheetsBarKFontIcon+_+t.sheetsBarKIconPlus},[])])},destroy:function(){this._sortable.destroy()},_scrollableAllowed:function(){var e=this.options;return e.scrollable&&!isNaN(e.scrollable.distance)},_scrollSheetsToItem:function(e){var t=this;var s=t._sheetsGroup();var r=p.scrollLeft(s);var a=l(e);var i=t._isRtl?e.position().left:e.position().left-s.children().first().position().left;var n=s[0].offsetWidth;var o;if(t._isRtl){if(i<0)o=r+i-(n-r);else if(i+a>n)o=r+i-a}else if(r+n<i+a)o=i+a-n;else if(r>i)o=i;s.finish().animate({scrollLeft:o},"fast","linear",function(){t._toggleScrollButtons()})},_sheetsGroup:function(){return this._sheetsWrapper().find("ul")},_sheetsWrapper:function(){return this.element.find(o+m.classNames.sheetsBarItems)},_scrollSheetsByDelta:function(e){var t=this;var s=t._sheetsGroup();var r=p.scrollLeft(s);s.finish().animate({scrollLeft:r+e},"fast","linear",function(){if(t._nowScrollingSheets)t._scrollSheetsByDelta(e);else t._toggleScrollButtons()})}});r.extend(true,p.spreadsheet.SheetsBar=m,{classNames:e})})?r.apply(t,s):r)||(e.exports=t)},1733:function(e,t){e.exports=require("../kendo.sortable")}});