99 lines
46 KiB
JavaScript
99 lines
46 KiB
JavaScript
|
/*!
|
||
|
StateRestore 1.1.0
|
||
|
2019-2022 SpryMedia Ltd - datatables.net/license
|
||
|
*/
|
||
|
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.owns=function(h,r){return Object.prototype.hasOwnProperty.call(h,r)};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(h,r,g){if(h==Array.prototype||h==Object.prototype)return h;h[r]=g.value;return h};
|
||
|
$jscomp.getGlobal=function(h){h=["object"==typeof globalThis&&globalThis,h,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var r=0;r<h.length;++r){var g=h[r];if(g&&g.Math==Math)return g}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};
|
||
|
$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(h,r){var g=$jscomp.propertyToPolyfillSymbol[r];if(null==g)return h[r];g=h[g];return void 0!==g?g:h[r]};$jscomp.polyfill=function(h,r,g,t){r&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(h,r,g,t):$jscomp.polyfillUnisolated(h,r,g,t))};
|
||
|
$jscomp.polyfillUnisolated=function(h,r,g,t){g=$jscomp.global;h=h.split(".");for(t=0;t<h.length-1;t++){var u=h[t];if(!(u in g))return;g=g[u]}h=h[h.length-1];t=g[h];r=r(t);r!=t&&null!=r&&$jscomp.defineProperty(g,h,{configurable:!0,writable:!0,value:r})};
|
||
|
$jscomp.polyfillIsolated=function(h,r,g,t){var u=h.split(".");h=1===u.length;t=u[0];t=!h&&t in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var m=0;m<u.length-1;m++){var x=u[m];if(!(x in t))return;t=t[x]}u=u[u.length-1];g=$jscomp.IS_SYMBOL_NATIVE&&"es6"===g?t[u]:null;r=r(g);null!=r&&(h?$jscomp.defineProperty($jscomp.polyfills,u,{configurable:!0,writable:!0,value:r}):r!==g&&($jscomp.propertyToPolyfillSymbol[u]=$jscomp.IS_SYMBOL_NATIVE?$jscomp.global.Symbol(u):$jscomp.POLYFILL_PREFIX+u,u=
|
||
|
$jscomp.propertyToPolyfillSymbol[u],$jscomp.defineProperty(t,u,{configurable:!0,writable:!0,value:r})))};$jscomp.polyfill("Object.values",function(h){return h?h:function(r){var g=[],t;for(t in r)$jscomp.owns(r,t)&&g.push(r[t]);return g}},"es8","es3");$jscomp.polyfill("Object.is",function(h){return h?h:function(r,g){return r===g?0!==r||1/r===1/g:r!==r&&g!==g}},"es6","es3");
|
||
|
$jscomp.polyfill("Array.prototype.includes",function(h){return h?h:function(r,g){var t=this;t instanceof String&&(t=String(t));var u=t.length;g=g||0;for(0>g&&(g=Math.max(g+u,0));g<u;g++){var m=t[g];if(m===r||Object.is(m,r))return!0}return!1}},"es7","es3");
|
||
|
$jscomp.checkStringArgs=function(h,r,g){if(null==h)throw new TypeError("The 'this' value for String.prototype."+g+" must not be null or undefined");if(r instanceof RegExp)throw new TypeError("First argument to String.prototype."+g+" must not be a regular expression");return h+""};$jscomp.polyfill("String.prototype.includes",function(h){return h?h:function(r,g){return-1!==$jscomp.checkStringArgs(this,r,"includes").indexOf(r,g||0)}},"es6","es3");
|
||
|
$jscomp.arrayIteratorImpl=function(h){var r=0;return function(){return r<h.length?{done:!1,value:h[r++]}:{done:!0}}};$jscomp.arrayIterator=function(h){return{next:$jscomp.arrayIteratorImpl(h)}};$jscomp.initSymbol=function(){};
|
||
|
$jscomp.polyfill("Symbol",function(h){if(h)return h;var r=function(u,m){this.$jscomp$symbol$id_=u;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:m})};r.prototype.toString=function(){return this.$jscomp$symbol$id_};var g=0,t=function(u){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new r("jscomp_symbol_"+(u||"")+"_"+g++,u)};return t},"es6","es3");$jscomp.initSymbolIterator=function(){};
|
||
|
$jscomp.polyfill("Symbol.iterator",function(h){if(h)return h;h=Symbol("Symbol.iterator");for(var r="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),g=0;g<r.length;g++){var t=$jscomp.global[r[g]];"function"===typeof t&&"function"!=typeof t.prototype[h]&&$jscomp.defineProperty(t.prototype,h,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}})}return h},"es6",
|
||
|
"es3");$jscomp.initSymbolAsyncIterator=function(){};$jscomp.iteratorPrototype=function(h){h={next:h};h[Symbol.iterator]=function(){return this};return h};$jscomp.iteratorFromArray=function(h,r){h instanceof String&&(h+="");var g=0,t={next:function(){if(g<h.length){var u=g++;return{value:r(u,h[u]),done:!1}}t.next=function(){return{done:!0,value:void 0}};return t.next()}};t[Symbol.iterator]=function(){return t};return t};
|
||
|
$jscomp.polyfill("Array.prototype.keys",function(h){return h?h:function(){return $jscomp.iteratorFromArray(this,function(r){return r})}},"es6","es3");$jscomp.assign=$jscomp.TRUST_ES6_POLYFILLS&&"function"==typeof Object.assign?Object.assign:function(h,r){for(var g=1;g<arguments.length;g++){var t=arguments[g];if(t)for(var u in t)$jscomp.owns(t,u)&&(h[u]=t[u])}return h};$jscomp.polyfill("Object.assign",function(h){return h||$jscomp.assign},"es6","es3");
|
||
|
$jscomp.findInternal=function(h,r,g){h instanceof String&&(h=String(h));for(var t=h.length,u=0;u<t;u++){var m=h[u];if(r.call(g,m,u,h))return{i:u,v:m}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.find",function(h){return h?h:function(r,g){return $jscomp.findInternal(this,r,g).v}},"es6","es3");
|
||
|
(function(){function h(q){g=q;t=q.fn.dataTable}function r(q){m=q;x=q.fn.dataTable}var g,t,u=function(){function q(a,c,d,f,k,b){void 0===f&&(f=void 0);void 0===k&&(k=!1);void 0===b&&(b=function(){return null});if(!t||!t.versionCheck||!t.versionCheck("1.10.0"))throw Error("StateRestore requires DataTables 1.10 or newer");if(!t.Buttons)throw Error("StateRestore requires Buttons");a=new t.Api(a);this.classes=g.extend(!0,{},q.classes);this.c=g.extend(!0,{},q.defaults,c);this.s={dt:a,identifier:d,isPreDefined:k,
|
||
|
savedState:null};this.dom={background:g('<div class="'+this.classes.background+'"/>'),closeButton:g('<div class="'+this.classes.closeButton+'">x</div>'),confirmation:g('<div class="'+this.classes.confirmation+'"/>'),confirmationTitleRow:g('<div class="'+this.classes.confirmationTitleRow+'"></div>'),dtContainer:g(this.s.dt.table().container()),duplicateError:g('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError)+"</span>"),emptyError:g('<span class="'+
|
||
|
this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError)+"</span>"),removeContents:g('<div class="'+this.classes.confirmationText+'"><span>'+this.s.dt.i18n("stateRestore.removeConfirm",this.c.i18n.removeConfirm).replace(/%s/g,this.s.identifier)+"</span></div>"),removeError:g('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.removeError",this.c.i18n.removeError)+"</span>"),removeTitle:g('<h2 class="'+this.classes.confirmationTitle+'">'+this.s.dt.i18n("stateRestore.removeTitle",
|
||
|
this.c.i18n.removeTitle)+"</h2>"),renameContents:g('<div class="'+this.classes.confirmationText+" "+this.classes.renameModal+'"><label class="'+this.classes.confirmationMessage+'">'+this.s.dt.i18n("stateRestore.renameLabel",this.c.i18n.renameLabel).replace(/%s/g,this.s.identifier)+"</label></div>"),renameInput:g('<input class="'+this.classes.input+'" type="text"></input>'),renameTitle:g('<h2 class="'+this.classes.confirmationTitle+'">'+this.s.dt.i18n("stateRestore.renameTitle",this.c.i18n.renameTitle)+
|
||
|
"</h2>")};this.save(f,b)}q.prototype.remove=function(a){var c,d=this;void 0===a&&(a=!1);if(!this.c.remove)return!1;var f,k={action:"remove",stateRestore:(c={},c[this.s.identifier]=this.s.savedState,c)},b=function(){d.dom.confirmation.trigger("dtsr-remove");g(d.s.dt.table().node()).trigger("stateRestore-change")};this.c.ajax?"string"===typeof this.c.ajax&&this.s.dt.settings()[0]._bInitComplete?f=function(){g.ajax({data:k,success:b,type:"POST",url:d.c.ajax});return!0}:"function"===typeof this.c.ajax&&
|
||
|
(f=function(){"function"===typeof d.c.ajax&&d.c.ajax.call(d.s.dt,k,b);return!0}):f=function(){try{localStorage.removeItem("DataTables_stateRestore_"+d.s.identifier+"_"+location.pathname),b()}catch(e){return"remove"}return!0};a?(this.dom.confirmation.appendTo(this.dom.dtContainer),g(this.s.dt.table().node()).trigger("dtsr-modal-inserted"),f(),this.dom.confirmation.remove()):this._newModal(this.dom.removeTitle,this.s.dt.i18n("stateRestore.removeSubmit",this.c.i18n.removeSubmit),f,this.dom.removeContents);
|
||
|
return!0};q.prototype.compare=function(a){this.c.saveState.order||(a.order=void 0);this.c.saveState.search||(a.search=void 0);if(this.c.saveState.columns&&a.columns)for(var c=0,d=a.columns.length;c<d;c++)"boolean"===typeof this.c.saveState.columns||this.c.saveState.columns.visible||(a.columns[c].visible=void 0),"boolean"===typeof this.c.saveState.columns||this.c.saveState.columns.search||(a.columns[c].search=void 0);else this.c.saveState.columns||(a.columns=void 0);this.c.saveState.searchBuilder||
|
||
|
(a.searchBuilder=void 0);this.c.saveState.searchPanes||(a.searchPanes=void 0);this.c.saveState.select||(a.select=void 0);this.c.saveState.colReorder||(a.ColReorder=void 0);this.c.saveState.scroller||(a.scroller=void 0,void 0!==t.Scroller&&(a.start=0));this.c.saveState.paging||(a.start=0);delete a.time;c=this.s.savedState;delete c.time;delete c.c;delete c.stateRestore;return this._deepCompare(a,c)};q.prototype.destroy=function(){Object.values(this.dom).forEach(function(a){return a.off().remove()})};
|
||
|
q.prototype.load=function(){var a=this,c=this.s.savedState,d=this.s.dt.settings()[0];c.time=+new Date;d.oLoadedState=g.extend(!0,{},c);g("div.dt-button-background").click();g.fn.dataTable.ext.oApi._fnImplementState(d,c,function(){a.s.dt.one("preDraw",function(f,k){setTimeout(function(){var b=k._iDisplayStart/k._iDisplayLength,e=c.start/c.length;0<=b&&0<=e&&b!==e&&a.s.dt.page(e).draw(!1)},50)});a.s.dt.draw(!1)});return c};q.prototype.rename=function(a,c){var d=this;void 0===a&&(a=null);if(this.c.rename){var f=
|
||
|
function(){var k;if(null===a){var b=g("input."+d.classes.input.replace(/ /g,".")).val();if(0===b.length)return"empty";if(c.includes(b))return"duplicate";a=b}b={action:"rename",stateRestore:(k={},k[d.s.identifier]=a,k)};k=function(){d.s.identifier=a;d.save(d.s.savedState,function(){return null},!1);d.dom.removeContents=g('<div class="'+d.classes.confirmationText+'"><span>'+d.s.dt.i18n("stateRestore.removeConfirm",d.c.i18n.removeConfirm).replace(/%s/g,d.s.identifier)+"</span></div>");d.dom.confirmation.trigger("dtsr-rename")};
|
||
|
if(d.c.ajax)"string"===typeof d.c.ajax&&d.s.dt.settings()[0]._bInitComplete?g.ajax({data:b,success:k,type:"POST",url:d.c.ajax}):"function"===typeof d.c.ajax&&d.c.ajax.call(d.s.dt,b,k);else try{localStorage.removeItem("DataTables_stateRestore_"+d.s.identifier+"_"+location.pathname),k()}catch(e){return!1}return!0};if(null!==a){if(c.includes(a))throw Error(this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError));if(0===a.length)throw Error(this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError));
|
||
|
this.dom.confirmation.appendTo(this.dom.dtContainer);g(this.s.dt.table().node()).trigger("dtsr-modal-inserted");f();this.dom.confirmation.remove()}else this.dom.renameInput.val(this.s.identifier),this.dom.renameContents.append(this.dom.renameInput),this._newModal(this.dom.renameTitle,this.s.dt.i18n("stateRestore.renameButton",this.c.i18n.renameButton),f,this.dom.renameContents)}};q.prototype.save=function(a,c,d){var f,k=this;void 0===d&&(d=!0);if(this.c.save){this.s.dt.state.save();if(void 0===a)a=
|
||
|
this.s.dt.state();else if("object"!==typeof a)return;a.stateRestore?(a.stateRestore.isPreDefined=this.s.isPreDefined,a.stateRestore.state=this.s.identifier):a.stateRestore={isPreDefined:this.s.isPreDefined,state:this.s.identifier};this.s.savedState=a;this.c.saveState.order||(this.s.savedState.order=void 0);this.c.saveState.search||(this.s.savedState.search=void 0);if(this.c.saveState.columns&&this.s.savedState.columns){a=0;for(var b=this.s.savedState.columns.length;a<b;a++)"boolean"===typeof this.c.saveState.columns||
|
||
|
this.c.saveState.columns.visible||(this.s.savedState.columns[a].visible=void 0),"boolean"===typeof this.c.saveState.columns||this.c.saveState.columns.search||(this.s.savedState.columns[a].search=void 0)}else this.c.saveState.columns||(this.s.savedState.columns=void 0);this.c.saveState.searchBuilder||(this.s.savedState.searchBuilder=void 0);this.c.saveState.searchPanes||(this.s.savedState.searchPanes=void 0);this.c.saveState.select||(this.s.savedState.select=void 0);this.c.saveState.colReorder||(this.s.savedState.ColReorder=
|
||
|
void 0);this.c.saveState.scroller||(this.s.savedState.scroller=void 0,void 0!==t.Scroller&&(this.s.savedState.start=0));this.c.saveState.paging||(this.s.savedState.start=0);this.s.savedState.c=this.c;if(this.s.savedState.c.splitSecondaries.length)for(a=0,b=this.s.savedState.c.splitSecondaries;a<b.length;a++){var e=b[a];e.parent&&(e.parent=void 0)}if(this.s.isPreDefined)c&&c.call(this);else{var l={action:"save",stateRestore:(f={},f[this.s.identifier]=this.s.savedState,f)},p=function(){c&&c.call(k);
|
||
|
k.dom.confirmation.trigger("dtsr-save");g(k.s.dt.table().node()).trigger("stateRestore-change")};if(this.c.ajax)if("string"===typeof this.c.ajax&&d)if(this.s.dt.settings()[0]._bInitComplete)g.ajax({data:l,success:p,type:"POST",url:this.c.ajax});else this.s.dt.one("init",function(){g.ajax({data:l,success:p,type:"POST",url:k.c.ajax})});else"function"===typeof this.c.ajax&&d&&this.c.ajax.call(this.s.dt,l,p);else localStorage.setItem("DataTables_stateRestore_"+this.s.identifier+"_"+location.pathname,
|
||
|
JSON.stringify(this.s.savedState)),p()}}else c&&c.call(this)};q.prototype._deepCompare=function(a,c){var d=[a,c];a=[Object.keys(a).sort(),Object.keys(c).sort()];a[0].includes("scroller")&&(c=a[0].indexOf("start"))&&a[0].splice(c,1);a[1].includes("scroller")&&(c=a[1].indexOf("start"))&&a[1].splice(c,1);for(c=0;c<a[0].length;c++)if(0===a[0][c].indexOf("_")&&(a[0].splice(c,1),c--),"baseRowTop"===a[0][c]||"baseScrollTop"===a[0][c]||"scrollTop"===a[0][c])a[0].splice(c,1),c--;for(c=0;c<a[1].length;c++)if(0===
|
||
|
a[1][c].indexOf("_")&&(a[1].splice(c,1),c--),"baseRowTop"===a[1][c]||"baseScrollTop"===a[1][c]||"scrollTop"===a[1][c])a[1].splice(c,1),c--;if(a[0].length!==a[1].length){var f=a[0].length>a[1].length?0:1;for(c=0;c<a[f].length;c++)if(a[0][c]!==a[1][c])if(this.s.isPreDefined){if(1===f&&void 0===d[0][a[0][c]])return!1;a[f].splice(c,1);c--}else void 0===d[f][a[f][c]]&&(a[f].splice(c,1),c--);if(a[0].length!==a[1].length)return!1}for(c=0;c<a[0].length;c++){if(a[0][c]!==a[1][c]||typeof d[0][a[0][c]]!==typeof d[1][a[1][c]])return!1;
|
||
|
if("object"===typeof d[0][a[0][c]]){if(!this._deepCompare(d[0][a[0][c]],d[1][a[1][c]]))return!1}else if("number"===typeof d[0][a[0][c]]&&"number"===typeof d[1][a[1][c]]){if(Math.round(d[0][a[0][c]])!==Math.round(d[1][a[1][c]]))return!1}else if(d[0][a[0][c]]!==d[1][a[1][c]])return!1}return!0};q.prototype._newModal=function(a,c,d,f){var k=this;this.dom.background.appendTo(this.dom.dtContainer);this.dom.confirmationTitleRow.empty().append(a);var b=g('<button class="'+this.classes.confirmationButton+
|
||
|
" "+this.classes.dtButton+'">'+c+"</button>");this.dom.confirmation.empty().append(this.dom.confirmationTitleRow).append(f).append(g('<div class="'+this.classes.confirmationButtons+'"></div>').append(b)).appendTo(this.dom.dtContainer);g(this.s.dt.table().node()).trigger("dtsr-modal-inserted");a=f.children("input");0<a.length?g(a[0]).focus():b.focus();var e=g("div."+this.classes.background.replace(/ /g,".")),l=function(p){"Enter"===p.key?b.click():"Escape"===p.key&&e.click()};this.c.modalCloseButton&&
|
||
|
(this.dom.confirmation.append(this.dom.closeButton),this.dom.closeButton.on("click",function(){return e.click()}));b.on("click",function(){var p=d();!0===p?(k.dom.background.remove(),k.dom.confirmation.remove(),g(document).unbind("keyup",l),b.off("click")):(k.dom.confirmation.children("."+k.classes.modalError).remove(),k.dom.confirmation.append(k.dom[p+"Error"]))});this.dom.confirmation.on("click",function(p){p.stopPropagation()});e.one("click",function(){k.dom.background.remove();k.dom.confirmation.remove();
|
||
|
g(document).unbind("keyup",l)});g(document).on("keyup",l)};q.prototype._searchToHung=function(a){return{bCaseInsensitive:a.caseInsensitive,bRegex:a.regex,bSmart:a.smart,sSearch:a.search}};q.version="1.1.0";q.classes={background:"dtsr-background",closeButton:"dtsr-popover-close",confirmation:"dtsr-confirmation",confirmationButton:"dtsr-confirmation-button",confirmationButtons:"dtsr-confirmation-buttons",confirmationMessage:"dtsr-confirmation-message dtsr-name-label",confirmationText:"dtsr-confirmation-text",
|
||
|
confirmationTitle:"dtsr-confirmation-title",confirmationTitleRow:"dtsr-confirmation-title-row",dtButton:"dt-button",input:"dtsr-input",modalError:"dtsr-modal-error",renameModal:"dtsr-rename-modal"};q.defaults={_createInSaved:!1,ajax:!1,create:!0,creationModal:!1,i18n:{creationModal:{button:"Create",colReorder:"Column Order:",columns:{search:"Column Search:",visible:"Column Visibility:"},name:"Name:",order:"Sorting:",paging:"Paging:",scroller:"Scroll Position:",search:"Search:",searchBuilder:"SearchBuilder:",
|
||
|
searchPanes:"SearchPanes:",select:"Select:",title:"Create New State",toggleLabel:"Includes:"},duplicateError:"A state with this name already exists.",emptyError:"Name cannot be empty.",emptyStates:"No saved states",removeConfirm:"Are you sure you want to remove %s?",removeError:"Failed to remove state.",removeJoiner:" and ",removeSubmit:"Remove",removeTitle:"Remove State",renameButton:"Rename",renameLabel:"New Name for %s:",renameTitle:"Rename State"},modalCloseButton:!0,remove:!0,rename:!0,save:!0,
|
||
|
saveState:{colReorder:!0,columns:{search:!0,visible:!0},order:!0,paging:!0,scroller:!0,search:!0,searchBuilder:!0,searchPanes:!0,select:!0},splitSecondaries:["updateState","renameState","removeState"],toggle:{colReorder:!1,columns:{search:!1,visible:!1},order:!1,paging:!1,scroller:!1,search:!1,searchBuilder:!1,searchPanes:!1,select:!1}};return q}(),m,x,C=function(){function q(a,c){var d=this;if(!x||!x.versionCheck||!x.versionCheck("1.10.0"))throw Error("StateRestore requires DataTables 1.10 or newer");
|
||
|
if(!x.Buttons)throw Error("StateRestore requires Buttons");a=new x.Api(a);this.classes=m.extend(!0,{},q.classes);if(void 0===a.settings()[0]._stateRestore){this.c=m.extend(!0,{},q.defaults,c);this.s={dt:a,hasColReorder:void 0!==x.ColReorder,hasScroller:void 0!==x.Scroller,hasSearchBuilder:void 0!==x.SearchBuilder,hasSearchPanes:void 0!==x.SearchPanes,hasSelect:void 0!==x.select,states:[]};this.s.dt.on("xhr",function(b,e,l){l&&l.stateRestore&&d._addPreDefined(l.stateRestore)});this.dom={background:m('<div class="'+
|
||
|
this.classes.background+'"/>'),closeButton:m('<div class="'+this.classes.closeButton+'">x</div>'),colReorderToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+'"><input type="checkbox" class="'+this.classes.colReorderToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.colReorder",this.c.i18n.creationModal.colReorder)+"</label></div>"),columnsSearchToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+
|
||
|
'"><input type="checkbox" class="'+this.classes.columnsSearchToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.columns.search",this.c.i18n.creationModal.columns.search)+"</label></div>"),columnsVisibleToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+' "><input type="checkbox" class="'+this.classes.columnsVisibleToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+
|
||
|
'">'+this.s.dt.i18n("stateRestore.creationModal.columns.visible",this.c.i18n.creationModal.columns.visible)+"</label></div>"),confirmation:m('<div class="'+this.classes.confirmation+'"/>'),confirmationTitleRow:m('<div class="'+this.classes.confirmationTitleRow+'"></div>'),createButtonRow:m('<div class="'+this.classes.formRow+" "+this.classes.modalFoot+'"><button class="'+this.classes.creationButton+" "+this.classes.dtButton+'">'+this.s.dt.i18n("stateRestore.creationModal.button",this.c.i18n.creationModal.button)+
|
||
|
"</button></div>"),creation:m('<div class="'+this.classes.creation+'"/>'),creationForm:m('<div class="'+this.classes.creationForm+'"/>'),creationTitle:m('<div class="'+this.classes.creationText+'"><h2 class="'+this.classes.creationTitle+'">'+this.s.dt.i18n("stateRestore.creationModal.title",this.c.i18n.creationModal.title)+"</h2></div>"),dtContainer:m(this.s.dt.table().container()),duplicateError:m('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError)+
|
||
|
"</span>"),emptyError:m('<span class="'+this.classes.modalError+'">'+this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError)+"</span>"),nameInputRow:m('<div class="'+this.classes.formRow+'"><label class="'+this.classes.nameLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.name",this.c.i18n.creationModal.name)+'</label><input class="'+this.classes.nameInput+'" type="text"></div>'),orderToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+'"><input type="checkbox" class="'+
|
||
|
this.classes.orderToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.order",this.c.i18n.creationModal.order)+"</label></div>"),pagingToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+'"><input type="checkbox" class="'+this.classes.pagingToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.paging",this.c.i18n.creationModal.paging)+
|
||
|
"</label></div>"),removeContents:m('<div class="'+this.classes.confirmationText+'"><span></span></div>'),removeTitle:m('<div class="'+this.classes.creationText+'"><h2 class="'+this.classes.creationTitle+'">'+this.s.dt.i18n("stateRestore.removeTitle",this.c.i18n.removeTitle)+"</h2></div>"),scrollerToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+'"><input type="checkbox" class="'+this.classes.scrollerToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+
|
||
|
'">'+this.s.dt.i18n("stateRestore.creationModal.scroller",this.c.i18n.creationModal.scroller)+"</label></div>"),searchBuilderToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+'"><input type="checkbox" class="'+this.classes.searchBuilderToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.searchBuilder",this.c.i18n.creationModal.searchBuilder)+"</label></div>"),searchPanesToggle:m('<div class="'+this.classes.formRow+
|
||
|
" "+this.classes.checkRow+'"><input type="checkbox" class="'+this.classes.searchPanesToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.searchPanes",this.c.i18n.creationModal.searchPanes)+"</label></div>"),searchToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+'"><input type="checkbox" class="'+this.classes.searchToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+
|
||
|
'">'+this.s.dt.i18n("stateRestore.creationModal.search",this.c.i18n.creationModal.search)+"</label></div>"),selectToggle:m('<div class="'+this.classes.formRow+" "+this.classes.checkRow+'"><input type="checkbox" class="'+this.classes.selectToggle+" "+this.classes.checkBox+'" checked><label class="'+this.classes.checkLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.select",this.c.i18n.creationModal.select)+"</label></div>"),toggleLabel:m('<label class="'+this.classes.nameLabel+" "+this.classes.toggleLabel+
|
||
|
'">'+this.s.dt.i18n("stateRestore.creationModal.toggleLabel",this.c.i18n.creationModal.toggleLabel)+"</label>")};a.settings()[0]._stateRestore=this;this._searchForStates();this._addPreDefined(this.c.preDefined);var f,k={action:"load"};"function"===typeof this.c.ajax?f=function(){"function"===typeof d.c.ajax&&d.c.ajax.call(d.s.dt,k,function(b){return d._addPreDefined(b)})}:"string"===typeof this.c.ajax&&(f=function(){m.ajax({data:k,success:function(b){d._addPreDefined(b)},type:"POST",url:d.c.ajax})});
|
||
|
if("function"===typeof f)if(this.s.dt.settings()[0]._bInitComplete)f();else this.s.dt.one("preInit.dtsr",function(){f()});this.s.dt.on("destroy.dtsr",function(){d.destroy()});this.s.dt.on("draw.dtsr buttons-action.dtsr",function(){return d.findActive()});return this}}q.prototype.addState=function(a,c,d){var f=this;if(this.c.create&&this.c.save){var k=function(b,e){if(0===b.length)return"empty";if(c.includes(b))return"duplicate";f.s.dt.state.save();var l=f.s.dt.state();l.stateRestore={isPredefined:!1,
|
||
|
state:b,tableId:f.s.dt.table().node().id};var p=new u(f.s.dt.settings()[0],m.extend(!0,{},f.c,e,d),b,l,!1,function(){f.s.states.push(this);f._collectionRebuild()});m(f.s.dt.table().node()).on("dtsr-modal-inserted",function(){p.dom.confirmation.one("dtsr-remove",function(){return f._removeCallback(p.s.identifier)});p.dom.confirmation.one("dtsr-rename",function(){return f._collectionRebuild()});p.dom.confirmation.one("dtsr-save",function(){return f._collectionRebuild()})});return!0};if(null===this.getState(a))if(this.c.creationModal||
|
||
|
void 0!==d&&d.creationModal)this._creationModal(k,a,d);else{a=k(a,{});if("empty"===a)throw Error(this.s.dt.i18n("stateRestore.emptyError",this.c.i18n.emptyError));if("duplicate"===a)throw Error(this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError));}else throw Error(this.s.dt.i18n("stateRestore.duplicateError",this.c.i18n.duplicateError));}};q.prototype.removeAll=function(a){if(0!==this.s.states.length){var c=this.s.states.map(function(f){return f.s.identifier}),d=c[0];1<c.length&&
|
||
|
(d=c.slice(0,-1).join(", ")+this.s.dt.i18n("stateRestore.removeJoiner",this.c.i18n.removeJoiner)+c.slice(-1));m(this.dom.removeContents.children("span")).text(this.s.dt.i18n("stateRestore.removeConfirm",this.c.i18n.removeConfirm).replace(/%s/g,d));this._newModal(this.dom.removeTitle,this.s.dt.i18n("stateRestore.removeSubmit",this.c.i18n.removeSubmit),a,this.dom.removeContents)}};q.prototype.destroy=function(){for(var a=0,c=this.s.states;a<c.length;a++)c[a].destroy();Object.values(this.dom).forEach(function(d){d.off();
|
||
|
d.remove()});this.s.states=[];this.s.dt.off(".dtsr");m(this.s.dt.table().node()).off(".dtsr")};q.prototype.findActive=function(){this.s.dt.state.save();var a=this.s.dt.state(),c=m("button."+m.fn.DataTable.Buttons.defaults.dom.button.className.replace(/ /g,"."));0===c.length&&(c=m("a."+m.fn.DataTable.Buttons.defaults.dom.button.className.replace(/ /g,".")));for(var d=0,f=c;d<f.length;d++){var k=f[d];this.s.dt.button(m(k).parent()[0]).active(!1)}d=[];f=0;for(var b=this.s.states;f<b.length;f++){var e=
|
||
|
b[f];if(e.compare(a)){d.push({data:e.s.savedState,name:e.s.identifier});for(var l=0,p=c;l<p.length;l++)if(k=p[l],m(k).text()===e.s.identifier){this.s.dt.button(m(k).parent()[0]).active(!0);break}}}return d};q.prototype.getState=function(a){for(var c=0,d=this.s.states;c<d.length;c++){var f=d[c];if(f.s.identifier===a)return f}return null};q.prototype.getStates=function(a){if(void 0===a)return this.s.states;for(var c=[],d=0;d<a.length;d++){for(var f=a[d],k=!1,b=0,e=this.s.states;b<e.length;b++){var l=
|
||
|
e[b];if(f===l.s.identifier){c.push(l);k=!0;break}}k||c.push(void 0)}return c};q.prototype._addPreDefined=function(a){for(var c=this,d=function(e){for(var l=0;l<f.s.states.length;l++)f.s.states[l].s.identifier===e&&f.s.states.splice(l,1);var p=f;l=a[e];var n=new u(f.s.dt,m.extend(!0,{},f.c,void 0!==l.c?{saveState:l.c.saveState}:void 0,!0),e,l,!0,function(){p.s.states.push(this);p._collectionRebuild()});n.s.savedState=l;m(f.s.dt.table().node()).on("dtsr-modal-inserted",function(){n.dom.confirmation.one("dtsr-remove",
|
||
|
function(){return c._removeCallback(n.s.identifier)});n.dom.confirmation.one("dtsr-rename",function(){return c._collectionRebuild()});n.dom.confirmation.one("dtsr-save",function(){return c._collectionRebuild()})})},f=this,k=0,b=Object.keys(a).sort(function(e,l){return e>l?1:e<l?-1:0});k<b.length;k++)d(b[k])};q.prototype._collectionRebuild=function(){var a=[];this.c._createInSaved&&a.push("createState");if(0===this.s.states.length)a.push('<span class="'+this.classes.emptyStates+'">'+this.s.dt.i18n("stateRestore.emptyStates",
|
||
|
this.c.i18n.emptyStates)+"</span>");else{this.s.states=this.s.states.sort(function(b,e){b=b.s.identifier;e=e.s.identifier;return b>e?1:b<e?-1:0});for(var c=0,d=this.s.states;c<d.length;c++){var f=d[c],k=Object.assign([],this.c.splitSecondaries);!k.includes("updateState")||this.c.save&&f.c.save||k.splice(k.indexOf("updateState"),1);!k.includes("renameState")||this.c.save&&f.c.save&&this.c.rename&&f.c.rename||k.splice(k.indexOf("renameState"),1);!k.includes("removeState")||this.c.remove&&f.c.remove||
|
||
|
k.splice(k.indexOf("removeState"),1);0<k.length&&!k.includes("<h3>"+f.s.identifier+"</h3>")&&k.unshift("<h3>"+f.s.identifier+"</h3>");a.push({_stateRestore:f,attr:{title:f.s.identifier},config:{split:k},extend:"stateRestore",text:f.s.identifier})}}this.s.dt.button("SaveStateRestore:name").collectionRebuild(a)};q.prototype._creationModal=function(a,c,d){var f=this;this.dom.creation.empty();this.dom.creationForm.empty();this.dom.nameInputRow.children("input").val(c);this.dom.creationForm.append(this.dom.nameInputRow);
|
||
|
var k=this.s.dt.settings()[0].oInit;c=[];var b=void 0!==d&&void 0!==d.toggle;((!b||void 0===d.toggle.order)&&this.c.toggle.order||b&&d.toggle.order)&&this.c.saveState.order&&(void 0===k.ordering||k.ordering)&&c.push(this.dom.orderToggle);((!b||void 0===d.toggle.search)&&this.c.toggle.search||b&&d.toggle.search)&&this.c.saveState.search&&(void 0===k.searching||k.searching)&&c.push(this.dom.searchToggle);((!b||void 0===d.toggle.paging)&&this.c.toggle.paging||b&&d.toggle.paging)&&this.c.saveState.paging&&
|
||
|
(void 0===k.paging||k.paging)&&c.push(this.dom.pagingToggle);this.s.hasColReorder&&((!b||void 0===d.toggle.colReorder)&&this.c.toggle.colReorder||b&&d.toggle.colReorder)&&this.c.saveState.colReorder&&c.push(this.dom.colReorderToggle);this.s.hasScroller&&((!b||void 0===d.toggle.scroller)&&this.c.toggle.scroller||b&&d.toggle.scroller)&&this.c.saveState.scroller&&c.push(this.dom.scrollerToggle);this.s.hasSearchBuilder&&((!b||void 0===d.toggle.searchBuilder)&&this.c.toggle.searchBuilder||b&&d.toggle.searchBuilder)&&
|
||
|
this.c.saveState.searchBuilder&&c.push(this.dom.searchBuilderToggle);this.s.hasSearchPanes&&((!b||void 0===d.toggle.searchPanes)&&this.c.toggle.searchPanes||b&&d.toggle.searchPanes)&&this.c.saveState.searchPanes&&c.push(this.dom.searchPanesToggle);this.s.hasSelect&&((!b||void 0===d.toggle.select)&&this.c.toggle.select||b&&d.toggle.select)&&this.c.saveState.select&&c.push(this.dom.selectToggle);"boolean"===typeof this.c.toggle.columns&&((!b||void 0===d.toggle.order)&&this.c.toggle.columns||b&&d.toggle.order)&&
|
||
|
this.c.saveState.columns?(c.push(this.dom.columnsSearchToggle),c.push(this.dom.columnsVisibleToggle)):(b&&void 0!==d.toggle.columns||"boolean"===typeof this.c.toggle.columns)&&"boolean"===typeof d.toggle.order||("boolean"!==typeof this.c.saveState.columns&&this.c.saveState.columns?((b&&void 0!==d.toggle.columns&&"boolean"!==typeof d.toggle.columns&&d.toggle.columns.search||(!b||void 0===d.toggle.columns||"boolean"!==typeof d.toggle.columns&&void 0===d.toggle.columns.search)&&"boolean"!==typeof this.c.toggle.columns&&
|
||
|
this.c.toggle.columns.search)&&this.c.saveState.columns.search&&c.push(this.dom.columnsSearchToggle),(b&&void 0!==d.toggle.columns&&"boolean"!==typeof d.toggle.columns&&d.toggle.columns.visible||(!b||void 0===d.toggle.columns||"boolean"!==typeof d.toggle.columns&&void 0===d.toggle.columns.visible)&&"boolean"!==typeof this.c.toggle.columns&&this.c.toggle.columns.visible)&&this.c.saveState.columns.visible&&c.push(this.dom.columnsVisibleToggle)):this.c.saveState.columns&&(c.push(this.dom.columnsSearchToggle),
|
||
|
c.push(this.dom.columnsVisibleToggle)));c.sort(function(n,v){n=n.children("label.dtsr-check-label")[0].innerHTML;v=v.children("label.dtsr-check-label")[0].innerHTML;return n<v?-1:n>v?1:0});for(k=0;k<c.length;k++)d=c[k],this.dom.creationForm.append(d);m(this.dom.creationForm.children("div."+this.classes.checkRow)[0]).prepend(this.dom.toggleLabel);this.dom.background.appendTo(this.dom.dtContainer);this.dom.creation.append(this.dom.creationTitle).append(this.dom.creationForm).append(this.dom.createButtonRow).appendTo(this.dom.dtContainer);
|
||
|
m(this.s.dt.table().node()).trigger("dtsr-modal-inserted");k=function(n){m(n.children("label:last-child")).on("click",function(){n.children("input").prop("checked",!n.children("input").prop("checked"))})};for(b=0;b<c.length;b++)d=c[b],k(d);var e=m("button."+this.classes.creationButton.replace(/ /g,"."));c=this.dom.creationForm.find("input");0<c.length?m(c[0]).focus():e.focus();var l=m("div."+this.classes.background.replace(/ /g,".")),p=function(n){"Enter"===n.key?e.click():"Escape"===n.key&&l.click()};
|
||
|
this.c.modalCloseButton&&(this.dom.creation.append(this.dom.closeButton),this.dom.closeButton.on("click",function(){return l.click()}));e.on("click",function(){var n={colReorder:f.dom.colReorderToggle.children("input").is(":checked"),columns:{search:f.dom.columnsSearchToggle.children("input").is(":checked"),visible:f.dom.columnsVisibleToggle.children("input").is(":checked")},order:f.dom.orderToggle.children("input").is(":checked"),paging:f.dom.pagingToggle.children("input").is(":checked"),scroller:f.dom.scrollerToggle.children("input").is(":checked"),
|
||
|
search:f.dom.searchToggle.children("input").is(":checked"),searchBuilder:f.dom.searchBuilderToggle.children("input").is(":checked"),searchPanes:f.dom.searchPanesToggle.children("input").is(":checked"),select:f.dom.selectToggle.children("input").is(":checked")};n=a(m("input."+f.classes.nameInput.replace(/ /g,".")).val(),{saveState:n});!0===n?(f.dom.background.remove(),f.dom.creation.remove(),m(document).unbind("keyup",p)):(f.dom.creation.children("."+f.classes.modalError).remove(),f.dom.creation.append(f.dom[n+
|
||
|
"Error"]))});l.one("click",function(){f.dom.background.remove();f.dom.creation.remove();m(document).unbind("keyup",p);f._collectionRebuild()});m(document).on("keyup",p);this.s.dt.state.save()};q.prototype._removeCallback=function(a){for(var c=0;c<this.s.states.length;c++)this.s.states[c].s.identifier===a&&(this.s.states.splice(c,1),c--);this._collectionRebuild();return!0};q.prototype._newModal=function(a,c,d,f){var k=this;this.dom.background.appendTo(this.dom.dtContainer);this.dom.confirmationTitleRow.empty().append(a);
|
||
|
var b=m('<button class="'+this.classes.confirmationButton+" "+this.classes.dtButton+'">'+c+"</button>");this.dom.confirmation.empty().append(this.dom.confirmationTitleRow).append(f).append(m('<div class="'+this.classes.confirmationButtons+'"></div>').append(b)).appendTo(this.dom.dtContainer);m(this.s.dt.table().node()).trigger("dtsr-modal-inserted");a=f.children("input");0<a.length?m(a[0]).focus():b.focus();var e=m("div."+this.classes.background.replace(/ /g,".")),l=function(p){"Enter"===p.key?b.click():
|
||
|
"Escape"===p.key&&e.click()};b.on("click",function(){var p=d(!0);!0===p?(k.dom.background.remove(),k.dom.confirmation.remove(),m(document).unbind("keyup",l),b.off("click")):(k.dom.confirmation.children("."+k.classes.modalError).remove(),k.dom.confirmation.append(k.dom[p+"Error"]))});this.dom.confirmation.on("click",function(p){p.stopPropagation()});e.one("click",function(){k.dom.background.remove();k.dom.confirmation.remove();m(document).unbind("keyup",l)});m(document).on("keyup",l)};q.prototype._searchForStates=
|
||
|
function(){for(var a=this,c=function(b){if(b.match(new RegExp("^DataTables_stateRestore_.*_"+location.pathname.replace(/\//g,"/")+"$"))){var e=JSON.parse(localStorage.getItem(b));if(e.stateRestore.isPreDefined||e.stateRestore.tableId&&e.stateRestore.tableId!==d.s.dt.table().node().id)return"continue";var l=d,p=new u(d.s.dt,m.extend(!0,{},d.c,{saveState:e.c.saveState}),e.stateRestore.state,e,!1,function(){this.s.savedState=e;l.s.states.push(this);l._collectionRebuild()});m(d.s.dt.table().node()).on("dtsr-modal-inserted",
|
||
|
function(){p.dom.confirmation.one("dtsr-remove",function(){return a._removeCallback(p.s.identifier)});p.dom.confirmation.one("dtsr-rename",function(){return a._collectionRebuild()});p.dom.confirmation.one("dtsr-save",function(){return a._collectionRebuild()})})}},d=this,f=0,k=Object.keys(localStorage);f<k.length;f++)c(k[f])};q.version="1.0.0";q.classes={background:"dtsr-background",checkBox:"dtsr-check-box",checkLabel:"dtsr-check-label",checkRow:"dtsr-check-row",closeButton:"dtsr-popover-close",colReorderToggle:"dtsr-colReorder-toggle",
|
||
|
columnsSearchToggle:"dtsr-columns-search-toggle",columnsVisibleToggle:"dtsr-columns-visible-toggle",confirmation:"dtsr-confirmation",confirmationButton:"dtsr-confirmation-button",confirmationButtons:"dtsr-confirmation-buttons",confirmationMessage:"dtsr-confirmation-message dtsr-name-label",confirmationText:"dtsr-confirmation-text",confirmationTitle:"dtsr-confirmation-title",confirmationTitleRow:"dtsr-confirmation-title-row",creation:"dtsr-creation",creationButton:"dtsr-creation-button",creationForm:"dtsr-creation-form",
|
||
|
creationText:"dtsr-creation-text",creationTitle:"dtsr-creation-title",dtButton:"dt-button",emptyStates:"dtsr-emptyStates",formRow:"dtsr-form-row",leftSide:"dtsr-left",modalError:"dtsr-modal-error",modalFoot:"dtsr-modal-foot",nameInput:"dtsr-name-input",nameLabel:"dtsr-name-label",orderToggle:"dtsr-order-toggle",pagingToggle:"dtsr-paging-toggle",rightSide:"dtsr-right",scrollerToggle:"dtsr-scroller-toggle",searchBuilderToggle:"dtsr-searchBuilder-toggle",searchPanesToggle:"dtsr-searchPanes-toggle",searchToggle:"dtsr-search-toggle",
|
||
|
selectToggle:"dtsr-select-toggle",toggleLabel:"dtsr-toggle-title"};q.defaults={_createInSaved:!1,ajax:!1,create:!0,creationModal:!1,i18n:{creationModal:{button:"Create",colReorder:"Column Order",columns:{search:"Column Search",visible:"Column Visibility"},name:"Name:",order:"Sorting",paging:"Paging",scroller:"Scroll Position",search:"Search",searchBuilder:"SearchBuilder",searchPanes:"SearchPanes",select:"Select",title:"Create New State",toggleLabel:"Includes:"},duplicateError:"A state with this name already exists.",
|
||
|
emptyError:"Name cannot be empty.",emptyStates:"No saved states",removeConfirm:"Are you sure you want to remove %s?",removeError:"Failed to remove state.",removeJoiner:" and ",removeSubmit:"Remove",removeTitle:"Remove State",renameButton:"Rename",renameLabel:"New Name for %s:",renameTitle:"Rename State"},modalCloseButton:!0,preDefined:{},remove:!0,rename:!0,save:!0,saveState:{colReorder:!0,columns:{search:!0,visible:!0},order:!0,paging:!0,scroller:!0,search:!0,searchBuilder:!0,searchPanes:!0,select:!0},
|
||
|
splitSecondaries:["updateState","renameState","removeState"],toggle:{colReorder:!1,columns:{search:!1,visible:!1},order:!1,paging:!1,scroller:!1,search:!1,searchBuilder:!1,searchPanes:!1,select:!1}};return q}();(function(q){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return q(a,window,document)}):"object"===typeof exports?module.exports=function(a,c){a||(a=window);c&&c.fn.dataTable||(c=require("datatables.net")(a,c).$);return q(c,a,a.document)}:q(window.jQuery,
|
||
|
window,document)})(function(q,a,c){function d(b,e){e=new q.fn.dataTable.StateRestoreCollection(b,e.config);f(b,e)}function f(b,e){var l=b.stateRestore.states(),p=[],n=b.settings()[0]._stateRestore.c;n._createInSaved&&p.push("createState");if(void 0===l||0===l.length)p.push('<span class="'+e.classes.emptyStates+'">'+b.i18n("stateRestore.emptyStates",e.c.i18n.emptyStates)+"</span>");else for(e=0;e<l.length;e++){var v=l[e],w=Object.assign([],n.splitSecondaries);w.includes("updateState")&&!n.save&&w.splice(w.indexOf("updateState"),
|
||
|
1);!w.includes("renameState")||n.save&&n.rename||w.splice(w.indexOf("renameState"),1);w.includes("removeState")&&!n.remove&&w.splice(w.indexOf("removeState"),1);0<w.length&&!w.includes("<h3>"+v.s.identifier+"</h3>")&&w.unshift("<h3>"+v.s.identifier+"</h3>");p.push({_stateRestore:v,attr:{title:v.s.identifier},config:{split:w},extend:"stateRestore",text:v.s.identifier})}b.button("SaveStateRestore:name").collectionRebuild(p)}h(q);r(q);var k=q.fn.dataTable;q.fn.dataTable.StateRestore=u;q.fn.DataTable.StateRestore=
|
||
|
u;q.fn.dataTable.StateRestoreCollection=C;q.fn.DataTable.StateRestoreCollection=C;a=q.fn.dataTable.Api.register;a("stateRestore()",function(){return this});a("stateRestore.state()",function(b){var e=this.context[0];if(!e._stateRestore){var l=q.fn.DataTable.Api(e),p=new q.fn.dataTable.StateRestoreCollection(l,{});f(l,p)}this[0]=e._stateRestore.getState(b);return this});a("stateRestore.state.add()",function(b,e){var l=this.context[0];if(!l._stateRestore){var p=q.fn.DataTable.Api(l),n=new q.fn.dataTable.StateRestoreCollection(p,
|
||
|
{});f(p,n)}if(!l._stateRestore.c.create)return this;if(l._stateRestore.addState){p=[];n=0;for(var v=l._stateRestore.s.states;n<v.length;n++)p.push(v[n].s.identifier);l._stateRestore.addState(b,p,e);return this}});a("stateRestore.states()",function(b){var e=this.context[0];if(!e._stateRestore){var l=q.fn.DataTable.Api(e),p=new q.fn.dataTable.StateRestoreCollection(l,{});f(l,p)}this.length=0;this.push.apply(this,e._stateRestore.getStates(b));return this});a("stateRestore.state().save()",function(){var b=
|
||
|
this[0];b.c.save&&b.save();return this});a("stateRestore.state().rename()",function(b){var e=this.context[0],l=this[0];if(l.c.save){var p=[],n=0;for(e=e._stateRestore.s.states;n<e.length;n++)p.push(e[n].s.identifier);l.rename(b,p)}return this});a("stateRestore.state().load()",function(){this[0].load();return this});a("stateRestore.state().remove()",function(b){var e=this[0];e.c.remove&&e.remove(b);return this});a("stateRestore.states().remove()",function(b){var e=this,l=function(p){var n=!0;e.each(function(v){void 0!==
|
||
|
v&&v.c.remove&&(v=v.remove(p),!0!==v&&(n=v))});return n};this.context[0]._stateRestore.c.remove&&(b?l(b):this.context[0]._stateRestore.removeAll(l));return this});a("stateRestore.activeStates()",function(){var b=this.context[0];this.length=0;if(!b._stateRestore){var e=q.fn.DataTable.Api(b),l=new q.fn.dataTable.StateRestoreCollection(e,{});f(e,l)}b._stateRestore&&this.push.apply(this,b._stateRestore.findActive());return this});q.fn.dataTable.ext.buttons.stateRestore={action:function(b,e,l,p){p._stateRestore.load();
|
||
|
l.blur()},config:{split:["updateState","renameState","removeState"]},text:function(b){return b.i18n("buttons.stateRestore","State %d",b.stateRestore.states()[0].length+1)}};q.fn.dataTable.ext.buttons.updateState={action:function(b,e,l,p){q("div.dt-button-background").click();p.parent._stateRestore.save()},text:function(b){return b.i18n("buttons.updateState","Update")}};q.fn.dataTable.ext.buttons.savedStates={buttons:[],extend:"collection",init:function(b,e,l){b.on("stateRestore-change",function(){b.button(e).text(b.i18n("buttons.savedStates",
|
||
|
"Saved States",b.stateRestore.states().length))});void 0===b.settings()[0]._stateRestore&&d(b,l)},name:"SaveStateRestore",text:function(b){return b.i18n("buttons.savedStates","Saved States",0)}};q.fn.dataTable.ext.buttons.savedStatesCreate={buttons:[],extend:"collection",init:function(b,e,l){b.on("stateRestore-change",function(){b.button(e).text(b.i18n("buttons.savedStates","Saved States",b.stateRestore.states().length))});void 0===b.settings()[0]._stateRestore&&(void 0===l.config&&(l.config={}),
|
||
|
l.config._createInSaved=!0,d(b,l))},name:"SaveStateRestore",text:function(b){return b.i18n("buttons.savedStates","Saved States",0)}};q.fn.dataTable.ext.buttons.createState={action:function(b,e,l,p){b.stopPropagation();b=e.settings()[0]._stateRestore.c;var n=e.settings()[0].oLanguage;if(b.create&&b.save){var v=e.stateRestore.states().toArray();n=void 0!==n.buttons&&void 0!==n.buttons.stateRestore?n.buttons.stateRestore:"State ";if(n.indexOf("%d")===n.length-3)var w=new RegExp(n.replace(/%d/g,""));
|
||
|
else{var B=n.split("%d");w=[];for(var A=0;A<B.length;A++)n=B[A],w.push(new RegExp(n))}var E=function(z){if(Array.isArray(w)){var y=z;for(var D=0,F=w;D<F.length;D++)y=y.replace(F[D],"")}else y=z.replace(w,"");return isNaN(+y)||y.length===z?0:+y};n=v.map(function(z){return E(z.s.identifier)}).sort(function(z,y){return+z<+y?1:+z>+y?-1:0})[0];e.stateRestore.state.add(e.i18n("buttons.stateRestore","State %d",void 0!==n?n+1:1),p.config);p=e.stateRestore.states().sort(function(z,y){z=+E(z.s.identifier);
|
||
|
y=+E(y.s.identifier);return z>y?1:z<y?-1:0});v=[];b._createInSaved&&(v.push("createState"),v.push(""));for(B=0;B<p.length;B++)A=p[B],n=Object.assign([],b.splitSecondaries),n.includes("updateState")&&!b.save&&n.splice(n.indexOf("updateState"),1),!n.includes("renameState")||b.save&&b.rename||n.splice(n.indexOf("renameState"),1),n.includes("removeState")&&!b.remove&&n.splice(n.indexOf("removeState"),1),0<n.length&&!n.includes("<h3>"+A.s.identifier+"</h3>")&&n.unshift("<h3>"+A.s.identifier+"</h3>"),v.push({_stateRestore:A,
|
||
|
attr:{title:A.s.identifier},config:{split:n},extend:"stateRestore",text:A.s.identifier});e.button("SaveStateRestore:name").collectionRebuild(v);l.blur()}},init:function(b,e,l){void 0===b.settings()[0]._stateRestore&&1<b.button("SaveStateRestore:name").length&&d(b,l)},text:function(b){return b.i18n("buttons.createState","Create State")}};q.fn.dataTable.ext.buttons.removeState={action:function(b,e,l,p){p.parent._stateRestore.remove();l.blur()},text:function(b){return b.i18n("buttons.removeState","Remove")}};
|
||
|
q.fn.dataTable.ext.buttons.removeAllStates={action:function(b,e,l){e.stateRestore.states().remove(!0);l.blur()},text:function(b){return b.i18n("buttons.removeAllStates","Remove All States")}};q.fn.dataTable.ext.buttons.renameState={action:function(b,e,l,p){b=[];var n=0;for(e=e.settings()[0]._stateRestore.s.states;n<e.length;n++)b.push(e[n].s.identifier);p.parent._stateRestore.rename(void 0,b);l.blur()},text:function(b){return b.i18n("buttons.renameState","Rename")}};q(c).on("preInit.dt.dtsr",function(b,
|
||
|
e){"dt"!==b.namespace||!e.oInit.stateRestore&&!k.defaults.stateRestore||e._stateRestore||(b=null,void 0===b&&(b=null),e=new k.Api(e),b=b?b:e.init().stateRestore||k.defaults.stateRestore,b=new C(e,b),f(e,b))})})})();
|