@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 21.2 kB
JavaScript
module.exports=function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}({0:function(e,t,n){n(1597),e.exports=n(1597)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},20:function(e,t){e.exports=require("../kendo.core")},968:function(e,t){e.exports=require("../kendo.window")},1578:function(e,t){e.exports=require("../kendo.binder")},1597:function(e,t,n){var i,r,a;!function(s,define){r=[n(20),n(1578),n(968),n(1598),n(1599)],i=s,a="function"==typeof i?i.apply(t,r):i,!(void 0!==a&&(e.exports=a))}(function(){!function(e){var t,n,i,r,a,s,o,h,d=e.jQuery,c={AUTO_FILL:"autoFill",CLEAR:"clear",CUT:"cut",EDIT:"edit",PASTE:"paste",VALIDATION:"validation"},u=e.spreadsheet.Command=e.Class.extend({init:function(e){this.options=e,this._workbook=e.workbook,this._property=e&&e.property,this._state={}},range:function(e){return void 0!==e&&this._setRange(e),this._range},_setRange:function(e){this._range=e},redo:function(){this.range().select(),this.exec()},undo:function(){this.setState(this._state)},getState:function(){this._state=this.range().getState(this._property)},setState:function(e){this.range().setState(e)},rejectState:function(e){return this.undo(),{title:e.title,body:e.message,reason:"error",type:"validationError"}},_forEachCell:function(e){var t=this.range(),n=t._ref;n.forEach(function(n){t.sheet().forEach(n.toRangeRef(),e.bind(this))}.bind(this))},usesImage:function(){return!1}});e.spreadsheet.DrawingUpdateCommand=u.extend({init:function(e){this._sheet=e.sheet,this._drawing=e.drawing,this._orig=this._drawing.clone(),this._previous=e.previous},exec:function(){},undo:function(){this._drawing.reset(this._previous),this._sheet._activeDrawing=this._drawing,this._sheet.triggerChange({layout:!0})},redo:function(){this._drawing.reset(this._orig),this._sheet._activeDrawing=this._drawing,this._sheet.triggerChange({layout:!0})},usesImage:function(e){return this._drawing.image===e||this._orig.image===e||this._previous.image===e}}),t=u.extend({init:function(e){u.fn.init.call(this,e),this._drawing=e.drawing},usesImage:function(e){return this._drawing.image===e}}),e.spreadsheet.InsertImageCommand=t.extend({init:function(e){t.fn.init.call(this,e),this._blob=e.blob,this._width=e.width,this._height=e.height},exec:function(){var e=this.range(),t=e.sheet(),n=this._width,i=this._height,r=n/i;n>i?(n=Math.min(n,300),i=n/r):(i=Math.min(i,300),n=i*r),this._drawing=t.addDrawing({topLeftCell:e.topLeft(),offsetX:5,offsetY:5,width:n,height:i,opacity:1,image:this._workbook.addImage(this._blob)},!0),this._blob=null},undo:function(){var e=this.range().sheet();e._activeDrawing=null,e.removeDrawing(this._drawing)},redo:function(){var e=this.range().sheet();e._activeDrawing=this._drawing,e.addDrawing(this._drawing)}}),e.spreadsheet.DeleteDrawingCommand=t.extend({exec:function(){var e=this.range().sheet();e._activeDrawing=null,e.removeDrawing(this._drawing)},undo:function(){var e=this.range().sheet();e._activeDrawing=this._drawing,e.addDrawing(this._drawing)},redo:function(){this.exec()}}),n=t.extend({exec:function(){var e=this.range().sheet();this._origIndex=e._drawings.indexOf(this._drawing),e._drawings.splice(this._origIndex,1),this._newIndex=this._reorder(),e._drawings.splice(this._newIndex,0,this._drawing),e.triggerChange({drawings:!0})},undo:function(){var e=this.range().sheet();e._drawings.splice(this._newIndex,1),e._drawings.splice(this._origIndex,0,this._drawing),e.triggerChange({drawings:!0})}}),e.spreadsheet.BringToFrontCommand=n.extend({_reorder:function(){return this.range().sheet()._drawings.length}}),e.spreadsheet.SendToBackCommand=n.extend({_reorder:function(){return 0}}),i=u.extend({init:function(e){u.fn.init.call(this,e),this._target=e.target,this._value=e.value},exec:function(){this.getState(),this.setState(this._value)}}),e.spreadsheet.ColumnWidthCommand=i.extend({getState:function(){this._state=this.range().sheet().columnWidth(this._target)},setState:function(e){this.range().sheet().columnWidth(this._target,e)}}),e.spreadsheet.RowHeightCommand=i.extend({getState:function(){this._state=this.range().sheet().rowHeight(this._target)},setState:function(e){this.range().sheet().rowHeight(this._target,e)}}),e.spreadsheet.HyperlinkCommand=u.extend({init:function(e){u.fn.init.call(this,e),this._link=e.link},exec:function(){var e=this.range();this._prevLink=e.link(),this._prevUnderline=e.underline(),e.link(this._link),e.underline(!0),null==e.value()&&(this._hasSetValue=!0,e.value(this._link))},undo:function(){var e=this.range();e.link(this._prevLink),e.underline(this._prevUnderline),this._hasSetValue&&e.value(null)}}),e.spreadsheet.GridLinesChangeCommand=i.extend({getState:function(){this._state=this._range.sheet().showGridLines()},setState:function(e){this._range.sheet().showGridLines(e)}}),r=e.spreadsheet.PropertyChangeCommand=u.extend({_setRange:function(e){u.prototype._setRange.call(this,e.skipHiddenCells())},init:function(e){u.fn.init.call(this,e),this._value=e.value},exec:function(){var e=this.range();e.enable()&&(this.getState(),"format"===this.options.property&&this._workbook.trigger("changeFormat",{range:e}),e[this._property](this._value))}}),e.spreadsheet.ClearContentCommand=u.extend({exec:function(){var e,t,n,i,r,a=[];return this.range().enable()?this.range().canEditArrayFormula()?(this.getState(),e=this.range().skipHiddenCells(),e._ref.refs&&e._ref.refs.length>1?e._ref.refs.forEach(function(t){r=e.sheet().range(t),a=a.concat(r.values())}):a=e.values(),n=[],a.forEach(function(e){t=[],e.forEach(function(){t.push(null)}),n.push(t)}),e.sheet().trigger("changing",{data:n,range:e,changeType:c.CLEAR})?void 0:(e.clearContent(),i=e._getValidationState(),i?this.rejectState(i):void 0)):{reason:"error",type:"intersectsArray"}:{reason:"error",type:"cannotModifyDisabled"}},undo:function(){var e,t=this.range().skipHiddenCells(),n=t.sheet(),i=this._state.data,r=[];i.forEach(function(t){e=[],t.forEach(function(t){e.push(t.value)}),r.push(e)}),n.trigger("changing",{data:r,range:t,changeType:c.CLEAR})||this.setState(this._state)}}),e.spreadsheet.EditCommand=r.extend({init:function(e){e.property=e.property||"input",r.fn.init.call(this,e)},_setRange:function(e){r.prototype._setRange.apply(this,arguments),this._editRange=this.options.arrayFormula?e:e.sheet().activeCellSelection()},getState:function(){this._state=this.range().getState()},exec:function(){return this.range().sheet().withCultureDecimals(this._exec.bind(this))},undo:function(){var e=this._editRange,t=this._state;e.sheet().trigger("changing",{data:t.data[0][0].value,range:e,changeType:c.EDIT})||this.setState(this._state)},_exec:function(){var t,n,i=this.options.arrayFormula,r=this._editRange;if(!r.enable())return{reason:"error",type:"rangeDisabled"};if(!r.canEditArrayFormula())return{reason:"error",type:"intersectsArray"};if(t=this._value,this.getState(),!this.range().sheet().trigger("changing",{data:t,range:this._editRange,changeType:c.EDIT})){if("value"==this._property)return void r.value(t);try{if(r.link(null),""===t?r.value(null):(r.input(t,{arrayFormula:i}),/\n/.test(r.value())&&r.wrap(!0)),r._adjustRowHeight(),n=r._getValidationState())return this.rejectState(n)}catch(a){if(a instanceof e.spreadsheet.calc.ParseError)return{title:"Error in formula",body:a+"",reason:"error"};throw a}}}}),e.spreadsheet.InsertCommentCommand=r.extend({init:function(e){e.property="comment",r.fn.init.call(this,e)}}),e.spreadsheet.TextWrapCommand=r.extend({init:function(e){e.property="wrap",r.fn.init.call(this,e),this._value=e.value},getState:function(){var e={};this.range().forEachRow(function(t){var n=t.topLeft().row;e[n]=t.sheet().rowHeight(n)}),this._state=this.range().getState(this._property),this._rowHeight=e},undo:function(){var e,t=this.range().sheet(),n=this._rowHeight;this.range().setState(this._state);for(e in n)t.rowHeight(e,n[e])}}),e.spreadsheet.AdjustDecimalsCommand=u.extend({init:function(e){this._delta=e.value,e.property="format",u.fn.init.call(this,e)},exec:function(){var t=this.range().sheet(),n=this._delta,i=e.spreadsheet.formatting;this.getState(),t.batch(function(){this.range().forEachCell(function(e,r,a){var s,o=a.format;o||(s=a.value,"number"==typeof s&&/\./.test(s)&&(o="0."+(s+"").split(".")[1].replace(/\d/g,"0"))),(o||n>0)&&(o=i.adjustDecimals(o||"0",n),t.range(e,r).format(o))})}.bind(this))}}),e.spreadsheet.BorderChangeCommand=u.extend({init:function(e){e.property="border",u.fn.init.call(this,e),this._type=e.border,this._style=e.style},_batch:function(e){return this.range().sheet().batch(e,{})},exec:function(){var e=this;e.getState(),e._batch(function(){e[e._type](e._style)})},noBorders:function(){this.range().insideBorders(null),this.outsideBorders(null)},allBorders:function(e){this.range().insideBorders(e),this.outsideBorders(e)},leftBorder:function(e){this.range().leftColumn().borderLeft(e)},rightBorder:function(e){this.range().rightColumn().borderRight(e)},topBorder:function(e){this.range().topRow().borderTop(e)},bottomBorder:function(e){this.range().bottomRow().borderBottom(e)},outsideBorders:function(e){var t=this.range();t.leftColumn().borderLeft(e),t.topRow().borderTop(e),t.rightColumn().borderRight(e),t.bottomRow().borderBottom(e)},insideBorders:function(e){this.range().insideBorders(e),this.outsideBorders(null)},insideHorizontalBorders:function(e){this.range().insideHorizontalBorders(e)},insideVerticalBorders:function(e){this.range().insideVerticalBorders(e)}}),e.spreadsheet.MergeCellCommand=u.extend({init:function(e){u.fn.init.call(this,e),this._type=e.value},exec:function(){this.getState(),this[this._type]()},activate:function(e){this.range().sheet().activeCell(e)},getState:function(){this._state=this.range().getState()},undo:function(){"unmerge"!==this._type&&(this.range().unmerge(),this.activate(this.range().topLeft())),this.range().setState(this._state)},cells:function(){var e=this.range(),t=e._ref;e.merge(),this.activate(t)},horizontally:function(){var e=this.range().topRow()._ref;this.range().forEachRow(function(e){e.merge()}),this.activate(e)},vertically:function(){var e=this.range().leftColumn()._ref;this.range().forEachColumn(function(e){e.merge()}),this.activate(e)},unmerge:function(){var e=this.range(),t=e._ref.topLeft;e.unmerge(),this.activate(t)}}),e.spreadsheet.FreezePanesCommand=u.extend({init:function(e){u.fn.init.call(this,e),this._type=e.value},exec:function(){this.getState(),this._topLeft=this.range().topLeft(),this[this._type]()},getState:function(){this._state=this.range().sheet().getState()},undo:function(){this.range().sheet().setState(this._state)},panes:function(){var e=this._topLeft,t=this.range().sheet();t.frozenColumns(e.col).frozenRows(e.row)},rows:function(){var e=this._topLeft,t=this.range().sheet();t.frozenRows(e.row)},columns:function(){var e=this._topLeft,t=this.range().sheet();t.frozenColumns(e.col)},unfreeze:function(){var e=this.range().sheet();e.frozenRows(0).frozenColumns(0)}}),e.spreadsheet.PasteCommand=u.extend({init:function(e){u.fn.init.call(this,e),this._clipboard=e.workbook.clipboard(),this._clipboard.parse(),this._event=e.event,this._clipboardContent=this._clipboard._content,this._clipboardPasteRef=this._clipboard.pasteRef(),this._sheet=this._workbook.activeSheet(),this._range=this._sheet.range(this._clipboard.pasteRef()),this._state=this._range.getState()},exec:function(){return this.range().sheet().withCultureDecimals(this._exec.bind(this))},undo:function(){var e=this._sheet,t=e.range(this._clipboardPasteRef);e.trigger("changing",{data:this._state.data,range:t,changeType:c.PASTE})||this.setState(this._state)},_exec:function(){var e,t=this._clipboard.canPaste();return t.canPaste?(e=this._sheet.range(this._clipboardPasteRef),this._workbook.trigger("paste",{range:e,clipboardContent:this._clipboardContent})||this._sheet.trigger("changing",{data:this._clipboardContent.data,range:e,changeType:c.PASTE})?void this._event.preventDefault():(this._sheet.range(this._clipboardPasteRef).setState(this._clipboardContent,this._clipboard),void e._adjustRowHeight())):t.menuInvoked?{reason:"error",type:"useKeyboard"}:t.pasteOnMerged?{reason:"error",type:"modifyMerged"}:t.overflow?{reason:"error",type:"overflow"}:t.pasteOnDisabled?(this._event.preventDefault(),{reason:"error",type:"cannotModifyDisabled"}):{reason:"error"}}}),e.spreadsheet.AdjustRowHeightCommand=u.extend({exec:function(){var e=this.options,t=this._workbook.activeSheet(),n=e.range||t.range(e.rowIndex);n._adjustRowHeight()}}),e.spreadsheet.ToolbarPasteCommand=u.extend({exec:function(){return e.support.clipboard.paste?(this._workbook._view.clipboard.focus().select(),void document.execCommand("paste")):{reason:"error",type:"useKeyboard"}}}),e.spreadsheet.CutCommand=u.extend({_eventType:"cut",init:function(e){u.fn.init.call(this,e),this._clipboard=e.workbook.clipboard(),this._event=e.event},exec:function(){var e,t,n,i=this._clipboard.canCopy(),r=[];if(i.canCopy){if(n=this._workbook.activeSheet().selection(),"cut"==this._eventType){if(!n.enable())return this._event.preventDefault(),{reason:"error",type:"cannotModifyDisabled"};this.getState()}if(this._workbook.trigger(this._eventType,{range:n}))this._event.preventDefault();else if("cut"==this._eventType){if(e=n.values(),e.forEach(function(e){t=[],e.forEach(function(){t.push({})}),r.push(t)}),n.sheet().trigger("changing",{data:r,range:n,changeType:c.CUT}))return;this._clipboard.cut()}else this._clipboard.copy()}else{if(i.menuInvoked)return{reason:"error",type:"useKeyboard"};if(i.multiSelection)return{reason:"error",type:"unsupportedSelection"}}},undo:function(){var e=this.range();e.sheet().trigger("changing",{data:this._state.data,range:e,changeType:c.CUT})||this.setState(this._state)}}),e.spreadsheet.CopyCommand=e.spreadsheet.CutCommand.extend({_eventType:"copy",undo:d.noop}),e.spreadsheet.ToolbarCopyCommand=u.extend({init:function(e){u.fn.init.call(this,e),this._clipboard=e.workbook.clipboard()},undo:d.noop,exec:function(){return e.support.clipboard.copy?void document.execCommand("copy"):{reason:"error",type:"useKeyboard"}}}),e.spreadsheet.AutoFillCommand=u.extend({init:function(e){u.fn.init.call(this,e)},origin:function(e){this._origin=e},exec:function(){var t,n=this.range();if(!n.enable())return{reason:"error",type:"rangeDisabled"};if(n.intersectingArrayFormula())return{reason:"error",type:"intersectsArray"};this.getState();try{if(t=n._previewFillFrom(this._origin),n.sheet().trigger("changing",{data:t.props,range:t.dest,changeType:c.AUTO_FILL}))return;t.dest._properties(t.props,!0)}catch(i){if(i instanceof e.spreadsheet.Range.FillError)return{reason:"error",type:i.code};throw i}},undo:function(){var e=this.range(),t=this._state;e.sheet().trigger("changing",{data:t.data,range:e,changeType:c.AUTO_FILL})||this.setState(this._state)}}),e.spreadsheet.ToolbarCutCommand=u.extend({cannotUndo:!0,init:function(e){u.fn.init.call(this,e),this._clipboard=e.workbook.clipboard()},exec:function(){return e.support.clipboard.copy?void document.execCommand("cut"):{reason:"error",type:"useKeyboard"}}}),e.spreadsheet.FilterCommand=u.extend({undo:function(){this.range().filter(this._state)},exec:function(){var e=this.range();this._state=e.hasFilter(),e.filter(!this._state)}}),e.spreadsheet.SortCommand=u.extend({undo:function(){var e=this.range().sheet();e.setState(this._state)},exec:function(){var e,t=this.range(),n=t.sheet(),i=n.activeCell(),r=this.options.sheet?i.topLeft.col:this.options.column||0,a="asc"===this.options.value;return this._state=n.getState(),this.options.sheet&&(t=this.expandRange()),(e=t.cantSort())?{reason:"error",type:e.code}:void t.sort({column:r,ascending:a})},expandRange:function(){var t=this.range().sheet();return new e.spreadsheet.Range(t._sheetRef,t)}}),a=e.spreadsheet.ApplyFilterCommand=u.extend({column:function(){return this.options.column||0},undo:function(){var e=this.range().sheet();e.clearFilter(this.column()),this._state.length&&this.range().filter(this._state)},getState:function(){var e=this.range().sheet(),t=e.filter();t&&(this._state=t.columns.filter(function(e){return e.index==this.column()}.bind(this)))},exec:function(){var t,n,i=this.range(),r=this.column(),a=i.sheet().filter(),s=!1;this.options.valueFilter?n={column:r,filter:new e.spreadsheet.ValueFilter(this.options.valueFilter)}:this.options.customFilter&&(n={column:r,filter:new e.spreadsheet.CustomFilter(this.options.customFilter)}),this.getState(),a&&a.ref.eq(i._ref)&&a.columns.length?(a.columns.forEach(function(e){e.index===r&&(s=!0)}),t=a.columns.map(function(e){return e.index===r?n:{column:e.index,filter:e.filter}}),s||t.push(n)):t=n,i.filter(t)}}),e.spreadsheet.ClearFilterCommand=a.extend({exec:function(){var e=this.range(),t=this.column();this.getState(),e.clearFilter(t)}}),e.spreadsheet.HideLineCommand=u.extend({init:function(e){u.fn.init.call(this,e),this.axis=e.axis},undo:function(){var e=this.range().sheet();e.setAxisState(this._state)},exec:function(){var e=this.range().sheet();this._state=e.getAxisState(),"row"==this.axis?e.axisManager().hideSelectedRows():e.axisManager().hideSelectedColumns()}}),e.spreadsheet.UnHideLineCommand=e.spreadsheet.HideLineCommand.extend({exec:function(){var e=this.range().sheet();this._state=e.getAxisState(),"row"==this.axis?e.axisManager().unhideSelectedRows():e.axisManager().unhideSelectedColumns()}}),s=u.extend({exec:function(){this._expandedRange=this._expand(this.range()),this._state=this._expandedRange.getState(),this._indexes=this._exec(this._expandedRange.sheet())},undo:function(){var e=this,t=e._expandedRange,n=t.sheet();n.batch(function(){e._indexes.forEach(function(t){e._undoOne(n,t),n._restoreModifiedFormulas(t.formulas)}),t.setState(e._state)},{layout:!0,recalc:!0,ref:t._ref})}}),e.spreadsheet.DeleteRowCommand=s.extend({_expand:function(e){return e.resize({left:-(1/0),right:+(1/0)})},_exec:function(e){return e.axisManager().deleteSelectedRows()},_undoOne:function(e,t){e.insertRow(t.index),e.rowHeight(t.index,t.height)}}),e.spreadsheet.DeleteColumnCommand=s.extend({_expand:function(e){return e.resize({top:-(1/0),bottom:+(1/0)})},_exec:function(e){return e.axisManager().deleteSelectedColumns()},_undoOne:function(e,t){e.insertColumn(t.index),e.columnWidth(t.index,t.width)}}),o=u.extend({init:function(e){u.fn.init.call(this,e),this._value=e.value},undo:function(){var e=this,t=e.range().sheet();t.batch(function(){for(var n=e._pos.count;--n>=0;)e._undoOne(t,e._pos.base)},{layout:!0,recalc:!0})}}),e.spreadsheet.AddColumnCommand=o.extend({exec:function(){var e=this._value,t=this.range().sheet(),n=t.axisManager().preventAddColumn();return n||"right"!==e||(n=t.axisManager().preventAddColumnAfterLast()),n?n:void(this._pos="left"===e?t.axisManager().addColumnLeft():t.axisManager().addColumnRight())},_undoOne:function(e,t){e.deleteColumn(t)}}),e.spreadsheet.AddRowCommand=o.extend({exec:function(){var e=this._value,t=this.range().sheet(),n=t.axisManager().preventAddRow();return n||"below"!==e||(n=t.axisManager().preventAddRowAfterLast()),n?n:void(this._pos="above"===e?t.axisManager().addRowAbove():t.axisManager().addRowBelow())},_undoOne:function(e,t){e.deleteRow(t)}}),e.spreadsheet.EditValidationCommand=u.extend({init:function(e){u.fn.init.call(this,e),this._value=e.value},exec:function(){var e=this,t=e.range().sheet();this.getState(),t.trigger("changing",{data:e._value,range:e.range(),changeType:c.VALIDATION})||t.withCultureDecimals(function(){e.range().validation(e._value)})},undo:function(){var e=this.range(),t=this._state;e.sheet().trigger("changing",{data:t.data[0][0].validation,range:e,changeType:c.VALIDATION})||this.setState(this._state)}}),e.spreadsheet.OpenCommand=u.extend({cannotUndo:!0,exec:function(){var e,t=this.options.file;return null===t.name.match(/.xlsx$/i)?{reason:"error",type:"openUnsupported"}:(e=this.options.workbook,void e.fromFile(this.options.file).then(function(){var t=e.excelImportErrors;t&&t.length&&e._view.openDialog("importError",{errors:t})}))}}),e.spreadsheet.SaveAsCommand=u.extend({cannotUndo:!0,exec:function(){var e=this.options.name+this.options.extension;".xlsx"===this.options.extension?this.options.workbook.saveAsExcel({fileName:e}):".pdf"===this.options.extension&&this.options.workbook.saveAsPDF(d.extend(this.options.pdf,{workbook:this.options.workbook,fileName:e}))}}),h=u.extend({init:function(e){u.fn.init.call(this,e),this._name=e.name,this._value=e.value},getState:function(){this._state=this._workbook.nameDefinition(this._name)},setState:function(){this._workbook.nameDefinition(this._name,this._state),this._workbook.trigger("change",{recalc:!0})}}),e.spreadsheet.DefineNameCommand=h.extend({exec:function(){this.getState();try{this._workbook.defineName(this._name,this._value),this._workbook.trigger("change",{recalc:!0})}catch(e){return{title:"Error",body:e+"",reason:"error"}}}}),e.spreadsheet.DeleteNameCommand=h.extend({exec:function(){this.getState(),this._workbook.undefineName(this._name),this._workbook.trigger("change",{recalc:!0})}})}(kendo)},n(3))},1598:function(e,t){e.exports=require("../kendo.list")},1599:function(e,t){e.exports=require("../kendo.tabstrip")}});