slickgrid
Version:
A lightning fast JavaScript grid/spreadsheet
9 lines • 5.68 kB
JavaScript
/**
* SlickGrid v3.0.2
* (c) 2009-present Michael Leibman
* homepage: http://github.com/mleibman/slickgrid
* license: MIT
* date: 2022-11-14
* file: ./slick.core.js
*/
!function(t){function u(){var t=!1,n=!1;this.stopPropagation=function(){t=!0},this.isPropagationStopped=function(){return t},this.stopImmediatePropagation=function(){n=!0},this.isImmediatePropagationStopped=function(){return n}}function n(){this.__nonDataRow=!0}function i(){this.__group=!0,this.level=0,this.count=0,this.value=null,this.title=null,this.collapsed=!1,this.selectChecked=!1,this.totals=null,this.rows=[],this.groups=null,this.groupingKey=null}function e(){this.__groupTotals=!0,this.group=null,this.initialized=!1}function o(){var n=null;this.isActive=function(t){return t?n===t:null!==n},this.activate=function(t){if(t!==n){if(null!==n)throw new Error("SlickGrid.EditorLock.activate: an editController is still active, can't activate another editController");if(!t.commitCurrentEdit)throw new Error("SlickGrid.EditorLock.activate: editController must implement .commitCurrentEdit()");if(!t.cancelCurrentEdit)throw new Error("SlickGrid.EditorLock.activate: editController must implement .cancelCurrentEdit()");n=t}},this.deactivate=function(t){if(n){if(n!==t)throw new Error("SlickGrid.EditorLock.deactivate: specified editController is not the currently active one");n=null}},this.commitCurrentEdit=function(){return!n||n.commitCurrentEdit()},this.cancelCurrentEdit=function(){return!n||n.cancelCurrentEdit()}}(i.prototype=new n).equals=function(t){return this.value===t.value&&this.count===t.count&&this.collapsed===t.collapsed&&this.title===t.title},e.prototype=new n;var r="Map"in window?window.Map:function(){var i={};this.get=function(t){return i[t]},this.set=function(t,n){i[t]=n},this.has=function(t){return t in i},this.delete=function(t){delete i[t]}};t.extend(!0,window,{Slick:{Event:function(){var r=[];this.subscribe=function(t){r.push(t)},this.unsubscribe=function(t){for(var n=r.length-1;0<=n;n--)r[n]===t&&r.splice(n,1)},this.notify=function(t,n,i){var e;n=n||new u,i=i||this;for(var o=0;o<r.length&&!n.isPropagationStopped()&&!n.isImmediatePropagationStopped();o++)e=r[o].call(i,n,t);return e}},EventData:u,EventHandler:function(){var e=[];this.subscribe=function(t,n){return e.push({event:t,handler:n}),t.subscribe(n),this},this.unsubscribe=function(t,n){for(var i=e.length;i--;)if(e[i].event===t&&e[i].handler===n)return e.splice(i,1),void t.unsubscribe(n);return this},this.unsubscribeAll=function(){for(var t=e.length;t--;)e[t].event.unsubscribe(e[t].handler);return e=[],this}},Range:function(t,n,i,e){void 0===i&&void 0===e&&(i=t,e=n),this.fromRow=Math.min(t,i),this.fromCell=Math.min(n,e),this.toRow=Math.max(t,i),this.toCell=Math.max(n,e),this.isSingleRow=function(){return this.fromRow==this.toRow},this.isSingleCell=function(){return this.fromRow==this.toRow&&this.fromCell==this.toCell},this.contains=function(t,n){return t>=this.fromRow&&t<=this.toRow&&n>=this.fromCell&&n<=this.toCell},this.toString=function(){return this.isSingleCell()?"("+this.fromRow+":"+this.fromCell+")":"("+this.fromRow+":"+this.fromCell+" - "+this.toRow+":"+this.toCell+")"}},Map:r,NonDataRow:n,Group:i,GroupTotals:e,RegexSanitizer:function(t){return t.replace(/(\b)(on[a-z]+)(\s*)=|javascript:([^>]*)[^>]*|(<\s*)(\/*)script([<>]*).*(<\s*)(\/*)script(>*)|(<)(\/*)(script|script defer)(.*)(>|>">)/gi,"")},EditorLock:o,GlobalEditorLock:new o,TreeColumns:function(n){var i={};function e(t,i){return t.filter(function(t){var n=i.call(t);return n&&t.columns&&(t.columns=e(t.columns,i)),n&&(!t.columns||t.columns.length)})}function o(t){return void 0===t?-1:t}function u(t){var n=[];if(t.hasOwnProperty("length"))for(var i=0;i<t.length;i++)n=n.concat(u(t[i]));else{if(!t.hasOwnProperty("columns"))return t;n=n.concat(u(t.columns))}return n}function r(){return t.extend(!0,[],n)}!function n(t){t.forEach(function(t){(i[t.id]=t).columns&&n(t.columns)})}(n),this.hasDepth=function(){for(var t in n)if(n[t].hasOwnProperty("columns"))return!0;return!1},this.getTreeColumns=function(){return n},this.extractColumns=function(){return this.hasDepth()?u(n):n},this.getDepth=function(){return function t(n){if(!n.length)return n.columns?1+t(n.columns):1;for(var i in n)return t(n[i])}(n)},this.getColumnsInDepth=function(t){return function t(n,i,e){var o,r=[];if(i==(e=e||0))return n.length&&n.forEach(function(t){t.columns&&(t.extractColumns=function(){return u(t)})}),n;for(o in n)n[o].columns&&(r=r.concat(t(n[o].columns,i,e+1)));return r}(n,t)},this.getColumnsInGroup=u,this.visibleColumns=function(){return e(r(),function(){return this.visible})},this.filter=function(t){return e(r(),t)},this.reOrder=function(t){return function n(t,i){t.sort(function(t,n){return o(i.getColumnIndex(t.id))-o(i.getColumnIndex(n.id))}).forEach(function(t){t.columns&&n(t.columns,i)})}(n,t)},this.getById=function(t){return i[t]},this.getInIds=function(t){return t.map(function(t){return i[t]})}},keyCode:{SPACE:8,BACKSPACE:8,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,RIGHT:39,TAB:9,UP:38,A:65},preClickClassName:"slick-edit-preclick",GridAutosizeColsMode:{None:"NOA",LegacyOff:"LOF",LegacyForceFit:"LFF",IgnoreViewport:"IGV",FitColsToViewport:"FCV",FitViewportToCols:"FVC"},ColAutosizeMode:{Locked:"LCK",Guide:"GUI",Content:"CON",ContentExpandOnly:"CXO",ContentIntelligent:"CTI"},RowSelectionMode:{FirstRow:"FS1",FirstNRows:"FSN",AllRows:"ALL",LastRow:"LS1"},ValueFilterMode:{None:"NONE",DeDuplicate:"DEDP",GetGreatestAndSub:"GR8T",GetLongestTextAndSub:"LNSB",GetLongestText:"LNSC"},WidthEvalMode:{Auto:"AUTO",TextOnly:"CANV",HTML:"HTML"}}})}(jQuery);