UNPKG

@progress/kendo-ui

Version:

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

1 lines 21.3 kB
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(1492),e.exports=n(1492)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},19:function(e,t){e.exports=require("../kendo.core")},943:function(e,t){e.exports=require("../kendo.window")},1492:function(e,t,n){var i,r,a;!function(s,define){r=[n(19),n(1493),n(943),n(1494),n(1495)],i=s,a="function"==typeof i?i.apply(t,r):i,!(void 0!==a&&(e.exports=a))}(function(){!function(e){function t(e){var t=document.createElement("textarea");n(t).addClass("k-spreadsheet-clipboard").val(e).appendTo(document.body).focus().select(),document.execCommand("copy"),n(t).remove()}var n,i,r,a,s,o,h,d,c,u,l;e.support.browser.msie&&e.support.browser.version<9||(n=e.jQuery,i={AUTO_FILL:"autoFill",CLEAR:"clear",CUT:"cut",EDIT:"edit",PASTE:"paste",VALIDATION:"validation"},r=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=r.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}}),a=r.extend({init:function(e){r.fn.init.call(this,e),this._drawing=e.drawing},usesImage:function(e){return this._drawing.image===e}}),e.spreadsheet.InsertImageCommand=a.extend({init:function(e){a.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=a.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()}}),s=a.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=s.extend({_reorder:function(){return this.range().sheet()._drawings.length}}),e.spreadsheet.SendToBackCommand=s.extend({_reorder:function(){return 0}}),o=r.extend({init:function(e){r.fn.init.call(this,e),this._target=e.target,this._value=e.value},exec:function(){this.getState(),this.setState(this._value)}}),e.spreadsheet.ColumnWidthCommand=o.extend({getState:function(){this._state=this.range().sheet().columnWidth(this._target)},setState:function(e){this.range().sheet().columnWidth(this._target,e)}}),e.spreadsheet.RowHeightCommand=o.extend({getState:function(){this._state=this.range().sheet().rowHeight(this._target)},setState:function(e){this.range().sheet().rowHeight(this._target,e)}}),e.spreadsheet.HyperlinkCommand=r.extend({init:function(e){r.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=o.extend({getState:function(){this._state=this._range.sheet().showGridLines()},setState:function(e){this._range.sheet().showGridLines(e)}}),h=e.spreadsheet.PropertyChangeCommand=r.extend({_setRange:function(e){r.prototype._setRange.call(this,e.skipHiddenCells())},init:function(e){r.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=r.extend({exec:function(){var e,t,n,r,a,s=[];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){a=e.sheet().range(t),s=s.concat(a.values())}):s=e.values(),n=[],s.forEach(function(e){t=[],e.forEach(function(){t.push(null)}),n.push(t)}),e.sheet().trigger("changing",{data:n,range:e,changeType:i.CLEAR})?void 0:(e.clearContent(),r=e._getValidationState(),r?this.rejectState(r):void 0)):{reason:"error",type:"intersectsArray"}:{reason:"error",type:"cannotModifyDisabled"}},undo:function(){var e,t=this.range().skipHiddenCells(),n=t.sheet(),r=this._state.data,a=[];r.forEach(function(t){e=[],t.forEach(function(t){e.push(t.value)}),a.push(e)}),n.trigger("changing",{data:a,range:t,changeType:i.CLEAR})||this.setState(this._state)}}),e.spreadsheet.EditCommand=h.extend({init:function(e){e.property=e.property||"input",h.fn.init.call(this,e)},_setRange:function(e){h.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:i.EDIT})||this.setState(this._state)},_exec:function(){var t,n,r=this.options.arrayFormula,a=this._editRange;if(!a.enable())return{reason:"error",type:"rangeDisabled"};if(!a.canEditArrayFormula())return{reason:"error",type:"intersectsArray"};if(t=this._value,this.getState(),!this.range().sheet().trigger("changing",{data:t,range:this._editRange,changeType:i.EDIT})){if("value"==this._property)return void a.value(t);try{if(a.link(null),""===t?a.value(null):(a.input(t,{arrayFormula:r}),/\n/.test(a.value())&&a.wrap(!0)),a._adjustRowHeight(),n=a._getValidationState())return this.rejectState(n)}catch(s){if(s instanceof e.spreadsheet.calc.ParseError)return{title:"Error in formula",body:s+"",reason:"error"};throw s}}}}),e.spreadsheet.InsertCommentCommand=h.extend({init:function(e){e.property="comment",h.fn.init.call(this,e)}}),e.spreadsheet.TextWrapCommand=h.extend({init:function(e){e.property="wrap",h.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=r.extend({init:function(e){this._delta=e.value,e.property="format",r.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=r.extend({init:function(e){e.property="border",r.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=r.extend({init:function(e){r.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=r.extend({init:function(e){r.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=r.extend({init:function(e){r.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:i.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:i.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=r.extend({exec:function(){var e=this.options,t=this._workbook.activeSheet(),n=e.range||t.range(e.rowIndex);n._adjustRowHeight()}}),e.spreadsheet.ToolbarPasteCommand=r.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=r.extend({_eventType:"cut",init:function(e){r.fn.init.call(this,e),this._clipboard=e.workbook.clipboard(),this._event=e.event},exec:function(){var e,t,n,r=this._clipboard.canCopy(),a=[];if(r.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({})}),a.push(t)}),n.sheet().trigger("changing",{data:a,range:n,changeType:i.CUT}))return;this._clipboard.cut()}else this._clipboard.copy()}else{if(r.menuInvoked)return{reason:"error",type:"useKeyboard"};if(r.multiSelection)return{reason:"error",type:"unsupportedSelection"}}},undo:function(){var e=this.range();e.sheet().trigger("changing",{data:this._state.data,range:e,changeType:i.CUT})||this.setState(this._state)}}),e.spreadsheet.CopyCommand=e.spreadsheet.CutCommand.extend({_eventType:"copy",undo:n.noop}),e.spreadsheet.ToolbarCopyCommand=r.extend({init:function(e){r.fn.init.call(this,e),this._clipboard=e.workbook.clipboard()},undo:n.noop,exec:function(){if(!e.support.clipboard.copy)return{reason:"error",type:"useKeyboard"};var n=this._workbook._view.clipboard;t(n.html()),n.trigger("copy")}}),e.spreadsheet.AutoFillCommand=r.extend({init:function(e){r.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:i.AUTO_FILL}))return;t.dest._properties(t.props,!0)}catch(r){if(r instanceof e.spreadsheet.Range.FillError)return{reason:"error",type:r.code};throw r}},undo:function(){var e=this.range(),t=this._state;e.sheet().trigger("changing",{data:t.data,range:e,changeType:i.AUTO_FILL})||this.setState(this._state)}}),e.spreadsheet.ToolbarCutCommand=r.extend({init:function(e){r.fn.init.call(this,e),this._clipboard=e.workbook.clipboard()},exec:function(){if(!e.support.clipboard.copy)return{reason:"error",type:"useKeyboard"};var n=this._workbook._view.clipboard;t(n.html()),n.trigger("cut")}}),e.spreadsheet.FilterCommand=r.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=r.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)}}),d=e.spreadsheet.ApplyFilterCommand=r.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=d.extend({exec:function(){var e=this.range(),t=this.column();this.getState(),e.clearFilter(t)}}),e.spreadsheet.HideLineCommand=r.extend({init:function(e){r.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()}}),c=r.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=c.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=c.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)}}),u=r.extend({init:function(e){r.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=u.extend({exec:function(){var e=this.range().sheet(),t=e.axisManager().preventAddColumn();return t?t:void(this._pos="left"===this._value?e.axisManager().addColumnLeft():e.axisManager().addColumnRight())},_undoOne:function(e,t){e.deleteColumn(t)}}),e.spreadsheet.AddRowCommand=u.extend({exec:function(){var e=this.range().sheet(),t=e.axisManager().preventAddRow();return t?t:void(this._pos="above"===this._value?e.axisManager().addRowAbove():e.axisManager().addRowBelow())},_undoOne:function(e,t){e.deleteRow(t)}}),e.spreadsheet.EditValidationCommand=r.extend({init:function(e){r.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:i.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:i.VALIDATION})||this.setState(this._state)}}),e.spreadsheet.OpenCommand=r.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=r.extend({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(n.extend(this.options.pdf,{workbook:this.options.workbook,fileName:e}))}}),l=r.extend({init:function(e){r.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=l.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=l.extend({exec:function(){this.getState(),this._workbook.undefineName(this._name),this._workbook.trigger("change",{recalc:!0})}}))}(kendo)},n(3))},1493:function(e,t){e.exports=require("../kendo.binder")},1494:function(e,t){e.exports=require("../kendo.list")},1495:function(e,t){e.exports=require("../kendo.tabstrip")}});