7 lines
42 KiB
JavaScript
7 lines
42 KiB
JavaScript
|
/*! StateRestore 1.4.1
|
||
|
* © SpryMedia Ltd - datatables.net/license
|
||
|
*/
|
||
|
import jQuery from"jquery";import DataTable from"datatables.net";let $=jQuery;!function(){"use strict";var u,m;n.prototype.remove=function(e){var t,s,o,a,i=this;return void 0===e&&(e=!1),!!this.c.remove&&(o={action:"remove",stateRestore:((t={})[this.s.identifier]=this.s.savedState,t)},a=function(){i.dom.confirmation.trigger("dtsr-remove"),u(i.s.dt.table().node()).trigger("stateRestore-change"),i.dom.background.click(),i.dom.confirmation.remove(),u(document).unbind("keyup",function(e){return i._keyupFunction(e)}),i.dom.confirmationButton.off("click")},this.c.ajax?"string"==typeof this.c.ajax&&this.s.dt.settings()[0]._bInitComplete?s=function(){return u.ajax({data:o,success:a,type:"POST",url:i.c.ajax}),!0}:"function"==typeof this.c.ajax&&(s=function(){return"function"==typeof i.c.ajax&&i.c.ajax.call(i.s.dt,o,a),!0}):s=function(){try{localStorage.removeItem("DataTables_stateRestore_"+i.s.identifier+"_"+location.pathname+(i.s.tableId?"_"+i.s.tableId:"")),a()}catch(e){return i.dom.confirmation.children("."+i.classes.modalError).remove(),i.dom.confirmation.append(i.dom.removeError),"remove"}return!0},e?(this.dom.confirmation.appendTo(this.dom.dtContainer),u(this.s.dt.table().node()).trigger("dtsr-modal-inserted"),s(),this.dom.confirmation.remove()):this._newModal(this.dom.removeTitle,this.s.dt.i18n("stateRestore.removeSubmit",this.c.i18n.removeSubmit),s,this.dom.removeContents),!0)},n.prototype.compare=function(e){if(this.c.saveState.order||(e.order=void 0),this.c.saveState.search||(e.search=void 0),this.c.saveState.columns&&e.columns)for(var t=0,s=e.columns.length;t<s;t++)"boolean"==typeof this.c.saveState.columns||this.c.saveState.columns.visible||(e.columns[t].visible=void 0),"boolean"==typeof this.c.saveState.columns||this.c.saveState.columns.search||(e.columns[t].search=void 0);else this.c.saveState.columns||(e.columns=void 0);this.c.saveState.paging||(e.page=void 0),this.c.saveState.searchBuilder||(e.searchBuilder=void 0),this.c.saveState.searchPanes||(e.searchPanes=void 0),this.c.saveState.select||(e.select=void 0),this.c.saveState.colReorder||(e.ColReorder=void 0),this.c.saveState.scroller||(e.scroller=void 0)!==m.Scroller&&(e.start=0),this.c.saveState.paging||(e.start=0),this.c.saveState.length||(e.length=void 0),delete e.time;var o=this.s.savedState;return delete o.time,delete o.c,delete o.stateRestore,this._deepCompare(e,o)},n.prototype.destroy=function(){u.each(this.dom,function(e,t){t.off().remove()})},n.prototype.load=function(){function e(){o.s.dt.one("preDraw",function(e,s){setTimeout(function(){var e=s._iDisplayStart/s._iDisplayLength,t=a.start/a.length;0<=e&&0<=t&&e!=t&&o.s.dt.page(t).draw(!1)},50)}),o.s.dt.draw(!1)}var o=this,a=this.s.savedState,t=this.s.dt.settings()[0];a.time=+new Date,t.oLoadedState=u.extend(!0,{},a),u("div.dt-button-background").click();return DataTable.versionCheck("2")?(this.s.dt.state(a),e()):DataTable.ext.oApi._fnImplementState(t,a,e),a},n.prototype.rename=function(s,o){var a=this;if(void 0===s&&(s=null),this.c.rename){var e=function(){if(null===s){var e=u("input."+a.classes.input.replace(/ /g,".")).val();if(0===e.length)return a.dom.confirmation.children("."+a.classes.modalError).remove(),a.dom.confirmation.append(a.dom.emptyError),"empty";if(o.includes(e))return a.dom.confirmation.children("."+a.classes.modalError).remove(),a.dom.confirmation.append(a.dom.duplicateError),"duplicate";s=e}function t(){a.s.identifier=s,a.save(a.s.savedState,function(){return null},!1),a.dom.removeContents=u('<div class="'+a.classes.confirmationText+'"><span>'+a.s.dt.i18n("stateRestore.removeConfirm",a.c.i18n.removeConfirm).replace(/%s/g,a.s.identifier)+"</span></div>"),a.dom.confirmation.trigger("dtsr-rename"),a.dom.background.click(),a.dom.confirmation.remove(),u(document).unbind("keyup",function(e){return a._keyupFunction(e)}),a.dom.confirmationButton.off("click")}e={action:"rename",stateRestore:((e={})[a.s.identifier]=s,e)};if(a.c.ajax)"string"==typeof a.c.ajax&&a.s.dt.settings()[0]._bInitComplete?u.ajax({data:e,success:t,type:"POST",url:a.c.ajax}):"function"==typeof a.c.ajax&&a.c.ajax.call(a.s.dt
|
||
|
/*! StateRestore 1.4.1
|
||
|
* © SpryMedia Ltd - datatables.net/license
|
||
|
*/var s=r;function r(e,t){var o=this;if(!i||!i.versionCheck||!i.versionCheck("1.10.0"))throw new Error("StateRestore requires DataTables 1.10 or newer");if(!i.Buttons)throw new Error("StateRestore requires Buttons");var s,a,e=new i.Api(e);if(this.classes=g.extend(!0,{},r.classes),void 0===e.settings()[0]._stateRestore)return this.c=g.extend(!0,{},r.defaults,t),this.s={dt:e,hasColReorder:void 0!==i.ColReorder,hasScroller:void 0!==i.Scroller,hasSearchBuilder:void 0!==i.SearchBuilder,hasSearchPanes:void 0!==i.SearchPanes,hasSelect:void 0!==i.select,states:[]},this.s.dt.on("xhr",function(e,t,s){s&&s.stateRestore&&o._addPreDefined(s.stateRestore)}),this.dom={background:g('<div class="'+this.classes.background+'"/>'),checkboxInputRow:g('<div class="'+this.classes.formRow+'"><label class="'+this.classes.nameLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.toggleLabel",this.c.i18n.creationModal.toggleLabel)+'</label><div class="dtsr-input"></div></div>'),closeButton:g('<div class="'+this.classes.closeButton+'">x</div>'),colReorderToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.colReorderToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.colReorder",this.c.i18n.creationModal.colReorder)+"</div>"),columnsSearchToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.columnsSearchToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.columns.search",this.c.i18n.creationModal.columns.search)+"</div>"),columnsVisibleToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.columnsVisibleToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.columns.visible",this.c.i18n.creationModal.columns.visible)+"</div>"),confirmation:g('<div class="'+this.classes.confirmation+'"/>'),confirmationTitleRow:g('<div class="'+this.classes.confirmationTitleRow+'"></div>'),createButtonRow:g('<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:g('<div class="'+this.classes.creation+'"/>'),creationForm:g('<div class="'+this.classes.creationForm+'"/>'),creationTitle:g('<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: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>"),lengthToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.lengthToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.length",this.c.i18n.creationModal.length)+"</div>"),nameInputRow:g('<div class="'+this.classes.formRow+'"><label class="'+this.classes.nameLabel+'">'+this.s.dt.i18n("stateRestore.creationModal.name",this.c.i18n.creationModal.name)+'</label><div class="dtsr-input"><input class="'+this.classes.nameInput+'" type="text"></div></div>'),orderToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.orderToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.order",this.c.i18n.creationModal.order)+"</div>"),pagingToggle:g('<div class="'+this.classes.checkLabel+'"><input type="checkbox" class="'+this.classes.pagingToggle+" "+this.classes.checkBox+'" checked>'+this.s.dt.i18n("stateRestore.creationModal.paging",this.c.i18n.creationModal.paging)+"</div>"),removeContents:g('<div class="'+this.classes.confirmationText+'"><span></span></div>'),removeTitle:g('<div class="'+this.classes.creationText+'"><h2
|