99 lines
48 KiB
JavaScript
99 lines
48 KiB
JavaScript
/*!
|
|
SearchPanes 1.3.0
|
|
2019-2021 SpryMedia Ltd - datatables.net/license
|
|
*/
|
|
(function(){function G(n){l=n;A=n.fn.dataTable}function H(n){p=n;B=n.fn.dataTable}var l,A,E=function(){function n(a,b,f,c,e,d){var g=this;void 0===d&&(d=null);if(!A||!A.versionCheck||!A.versionCheck("1.10.0"))throw Error("SearchPane requires DataTables 1.10 or newer");if(!A.select)throw Error("SearchPane requires Select");a=new A.Api(a);this.classes=l.extend(!0,{},n.classes);this.c=l.extend(!0,{},n.defaults,b);void 0!==b&&void 0!==b.hideCount&&void 0===b.viewCount&&(this.c.viewCount=!this.c.hideCount);
|
|
this.customPaneSettings=d;this.s={cascadeRegen:!1,clearing:!1,colOpts:[],deselect:!1,displayed:!1,dt:a,dtPane:void 0,filteringActive:!1,forceViewTotal:!1,index:f,indexes:[],lastCascade:!1,lastSelect:!1,listSet:!1,name:void 0,redraw:!1,rowData:{arrayFilter:[],arrayOriginal:[],arrayTotals:[],bins:{},binsOriginal:{},binsTotal:{},filterMap:new Map,totalOptions:0},scrollTop:0,searchFunction:void 0,selectPresent:!1,serverSelect:[],serverSelecting:!1,showFiltered:!1,tableLength:null,updating:!1};b=a.columns().eq(0).toArray().length;
|
|
this.colExists=this.s.index<b;this.c.layout=c;b=parseInt(c.split("-")[1],10);this.dom={buttonGroup:l("<div/>").addClass(this.classes.buttonGroup),clear:l('<button type="button">×</button>').addClass(this.classes.disabledButton).attr("disabled","true").addClass(this.classes.paneButton).addClass(this.classes.clearButton),container:l("<div/>").addClass(this.classes.container).addClass(this.classes.layout+(10>b?c:c.split("-")[0]+"-9")),countButton:l('<button type="button"></button>').addClass(this.classes.paneButton).addClass(this.classes.countButton),
|
|
dtP:l("<table><thead><tr><th>"+(this.colExists?l(a.column(this.colExists?this.s.index:0).header()).text():this.customPaneSettings.header||"Custom Pane")+"</th><th/></tr></thead></table>"),lower:l("<div/>").addClass(this.classes.subRow2).addClass(this.classes.narrowButton),nameButton:l('<button type="button"></button>').addClass(this.classes.paneButton).addClass(this.classes.nameButton),panesContainer:e,searchBox:l("<input/>").addClass(this.classes.paneInputButton).addClass(this.classes.search),searchButton:l('<button type = "button" class="'+
|
|
this.classes.searchIcon+'"></button>').addClass(this.classes.paneButton),searchCont:l("<div/>").addClass(this.classes.searchCont),searchLabelCont:l("<div/>").addClass(this.classes.searchLabelCont),topRow:l("<div/>").addClass(this.classes.topRow),upper:l("<div/>").addClass(this.classes.subRow1).addClass(this.classes.narrowSearch)};this.s.displayed=!1;a=this.s.dt;this.selections=[];this.s.colOpts=this.colExists?this._getOptions():this._getBonusOptions();var h=this.s.colOpts;c=l('<button type="button">X</button>').addClass(this.classes.paneButton);
|
|
l(c).text(a.i18n("searchPanes.clearPane",this.c.i18n.clearPane));this.dom.container.addClass(h.className);this.dom.container.addClass(null!==this.customPaneSettings&&void 0!==this.customPaneSettings.className?this.customPaneSettings.className:"");this.s.name=void 0!==this.s.colOpts.name?this.s.colOpts.name:null!==this.customPaneSettings&&void 0!==this.customPaneSettings.name?this.customPaneSettings.name:this.colExists?l(a.column(this.s.index).header()).text():this.customPaneSettings.header||"Custom Pane";
|
|
l(e).append(this.dom.container);var m=a.table(0).node();this.s.searchFunction=function(k,r,v,t){if(0===g.selections.length||k.nTable!==m)return!0;k=null;g.colExists&&(k=r[g.s.index],"filter"!==h.orthogonal.filter&&(k=g.s.rowData.filterMap.get(v),k instanceof l.fn.dataTable.Api&&(k=k.toArray())));return g._search(k,v)};l.fn.dataTable.ext.search.push(this.s.searchFunction);if(this.c.clear)l(c).on("click",function(){g.dom.container.find("."+g.classes.search.replace(/\s+/g,".")).each(function(){l(this).val("");
|
|
l(this).trigger("input")});g.clearPane()});a.on("draw.dtsp",function(){g.adjustTopRow()});a.on("buttons-action",function(){g.adjustTopRow()});a.on("column-reorder.dtsp",function(k,r,v){g.s.index=v.mapping[g.s.index]});return this}n.prototype.addRow=function(a,b,f,c,e,d,g){for(var h,m=0,k=this.s.indexes;m<k.length;m++){var r=k[m];r.filter===b&&(h=r.index)}void 0===h&&(h=this.s.indexes.length,this.s.indexes.push({filter:b,index:h}));return this.s.dtPane.row.add({className:g,display:""!==a?a:this.emptyMessage(),
|
|
filter:b,index:h,shown:f,sort:e,total:c,type:d})};n.prototype.adjustTopRow=function(){var a=this.dom.container.find("."+this.classes.subRowsContainer.replace(/\s+/g,".")),b=this.dom.container.find("."+this.classes.subRow1.replace(/\s+/g,".")),f=this.dom.container.find("."+this.classes.subRow2.replace(/\s+/g,".")),c=this.dom.container.find("."+this.classes.topRow.replace(/\s+/g,"."));(252>l(a[0]).width()||252>l(c[0]).width())&&0!==l(a[0]).width()?(l(a[0]).addClass(this.classes.narrow),l(b[0]).addClass(this.classes.narrowSub).removeClass(this.classes.narrowSearch),
|
|
l(f[0]).addClass(this.classes.narrowSub).removeClass(this.classes.narrowButton)):(l(a[0]).removeClass(this.classes.narrow),l(b[0]).removeClass(this.classes.narrowSub).addClass(this.classes.narrowSearch),l(f[0]).removeClass(this.classes.narrowSub).addClass(this.classes.narrowButton))};n.prototype.clearData=function(){this.s.rowData={arrayFilter:[],arrayOriginal:[],arrayTotals:[],bins:{},binsOriginal:{},binsTotal:{},filterMap:new Map,totalOptions:0}};n.prototype.clearPane=function(){this.s.dtPane.rows({selected:!0}).deselect();
|
|
this.updateTable();return this};n.prototype.destroy=function(){l(this.s.dtPane).off(".dtsp");l(this.s.dt).off(".dtsp");l(this.dom.nameButton).off(".dtsp");l(this.dom.countButton).off(".dtsp");l(this.dom.clear).off(".dtsp");l(this.dom.searchButton).off(".dtsp");l(this.dom.container).remove();for(var a=l.fn.dataTable.ext.search.indexOf(this.s.searchFunction);-1!==a;)l.fn.dataTable.ext.search.splice(a,1),a=l.fn.dataTable.ext.search.indexOf(this.s.searchFunction);void 0!==this.s.dtPane&&this.s.dtPane.destroy();
|
|
this.s.listSet=!1};n.prototype.emptyMessage=function(){var a=this.c.i18n.emptyMessage;this.c.emptyMessage&&(a=this.c.emptyMessage);!1!==this.s.colOpts.emptyMessage&&null!==this.s.colOpts.emptyMessage&&(a=this.s.colOpts.emptyMessage);return this.s.dt.i18n("searchPanes.emptyMessage",a)};n.prototype.getPaneCount=function(){return void 0!==this.s.dtPane?this.s.dtPane.rows({selected:!0}).data().toArray().length:0};n.prototype.rebuildPane=function(a,b,f,c){void 0===a&&(a=!1);void 0===b&&(b=null);void 0===
|
|
f&&(f=null);void 0===c&&(c=!1);this.clearData();var e=[];this.s.serverSelect=[];var d=null;void 0!==this.s.dtPane&&(c&&(this.s.dt.page.info().serverSide?this.s.serverSelect=this.s.dtPane.rows({selected:!0}).data().toArray():e=this.s.dtPane.rows({selected:!0}).data().toArray()),this.s.dtPane.clear().destroy(),d=l(this.dom.container).prev(),this.destroy(),this.s.dtPane=void 0,l.fn.dataTable.ext.search.push(this.s.searchFunction));this.dom.container.removeClass(this.classes.hidden);this.s.displayed=
|
|
!1;this._buildPane(this.s.dt.page.info().serverSide?this.s.serverSelect:e,a,b,f,d);return this};n.prototype.removePane=function(){this.s.displayed=!1;l(this.dom.container).hide()};n.prototype.resize=function(a){this.c.layout=a;var b=parseInt(a.split("-")[1],10);l(this.dom.container).removeClass().addClass(this.classes.container).addClass(this.classes.layout+(10>b?a:a.split("-")[0]+"-9")).addClass(this.s.colOpts.className).addClass(null!==this.customPaneSettings&&void 0!==this.customPaneSettings.className?
|
|
this.customPaneSettings.className:"").addClass(this.classes.show);this.adjustTopRow()};n.prototype.setCascadeRegen=function(a){this.s.cascadeRegen=a};n.prototype.setClear=function(a){this.s.clearing=a};n.prototype.updatePane=function(a){void 0===a&&(a=!1);this.s.updating=!0;this._updateCommon(a);this.s.updating=!1};n.prototype.updateTable=function(){this.selections=this.s.dtPane.rows({selected:!0}).data().toArray();this._searchExtras();(this.c.cascadePanes||this.c.viewTotal)&&this.updatePane()};n.prototype._setListeners=
|
|
function(){var a=this,b=this.s.rowData,f;this.s.dtPane.on("select.dtsp",function(){clearTimeout(f);a.s.dt.page.info().serverSide&&!a.s.updating?a.s.serverSelecting||(a.s.serverSelect=a.s.dtPane.rows({selected:!0}).data().toArray(),a.s.scrollTop=l(a.s.dtPane.table().node()).parent()[0].scrollTop,a.s.selectPresent=!0,a.s.dt.draw(!1)):(l(a.dom.clear).removeClass(a.classes.disabledButton).removeAttr("disabled"),a.s.updating||(a.s.selectPresent=!0,a._makeSelection(),a.s.selectPresent=!1))});this.s.dtPane.on("deselect.dtsp",
|
|
function(){f=setTimeout(function(){a.s.dt.page.info().serverSide&&!a.s.updating?a.s.serverSelecting||(a.s.serverSelect=a.s.dtPane.rows({selected:!0}).data().toArray(),a.s.deselect=!0,a.s.dt.draw(!1)):(a.s.deselect=!0,0===a.s.dtPane.rows({selected:!0}).data().toArray().length&&l(a.dom.clear).addClass(a.classes.disabledButton).attr("disabled","true"),a._makeSelection(),a.s.deselect=!1,a.s.dt.state.save())},50)});this.s.dt.on("stateSaveParams.dtsp",function(c,e,d){if(l.isEmptyObject(d))a.s.dtPane.state.clear();
|
|
else{c=[];if(void 0!==a.s.dtPane){c=a.s.dtPane.rows({selected:!0}).data().map(function(r){return r.filter.toString()}).toArray();var g=l(a.dom.searchBox).val();var h=a.s.dtPane.order();var m=b.binsOriginal;var k=b.arrayOriginal}void 0===d.searchPanes&&(d.searchPanes={});void 0===d.searchPanes.panes&&(d.searchPanes.panes=[]);for(e=0;e<d.searchPanes.panes.length;e++)d.searchPanes.panes[e].id===a.s.index&&(d.searchPanes.panes.splice(e,1),e--);d.searchPanes.panes.push({arrayFilter:k,bins:m,id:a.s.index,
|
|
order:h,searchTerm:g,selected:c})}});this.s.dtPane.on("user-select.dtsp",function(c,e,d,g,h){h.stopPropagation()});this.s.dtPane.on("draw.dtsp",function(){a.adjustTopRow()});l(this.dom.nameButton).on("click.dtsp",function(){var c=a.s.dtPane.order()[0][1];a.s.dtPane.order([0,"asc"===c?"desc":"asc"]).draw();a.s.dt.state.save()});l(this.dom.countButton).on("click.dtsp",function(){var c=a.s.dtPane.order()[0][1];a.s.dtPane.order([1,"asc"===c?"desc":"asc"]).draw();a.s.dt.state.save()});l(this.dom.clear).on("click.dtsp",
|
|
function(){a.dom.container.find("."+a.classes.search.replace(/ /g,".")).each(function(){l(this).val("");l(this).trigger("input")});a.clearPane()});l(this.dom.searchButton).on("click.dtsp",function(){l(a.dom.searchBox).focus()});l(this.dom.searchBox).on("input.dtsp",function(){var c=l(a.dom.searchBox).val();a.s.dtPane.search(c).draw();0<c.length||0===c.length&&0<a.s.dtPane.rows({selected:!0}).data().toArray().length?a.dom.clear.removeClass(a.classes.disabledButton).removeAttr("disabled"):a.dom.clear.addClass(a.classes.disabledButton).attr("disabled",
|
|
"true");a.s.dt.state.save()});this.s.dt.state.save();return!0};n.prototype._addOption=function(a,b,f,c,e,d){if(Array.isArray(a)||a instanceof A.Api)if(a instanceof A.Api&&(a=a.toArray(),b=b.toArray()),a.length===b.length)for(var g=0;g<a.length;g++)d[a[g]]?d[a[g]]++:(d[a[g]]=1,e.push({display:b[g],filter:a[g],sort:f[g],type:c[g]})),this.s.rowData.totalOptions++;else throw Error("display and filter not the same length");else"string"===typeof this.s.colOpts.orthogonal?(d[a]?d[a]++:(d[a]=1,e.push({display:b,
|
|
filter:a,sort:f,type:c})),this.s.rowData.totalOptions++):e.push({display:b,filter:a,sort:f,type:c})};n.prototype._buildPane=function(a,b,f,c,e){var d=this;void 0===a&&(a=[]);void 0===b&&(b=!1);void 0===f&&(f=null);void 0===c&&(c=null);void 0===e&&(e=null);this.selections=[];var g=this.s.dt,h=g.column(this.colExists?this.s.index:0),m=this.s.colOpts,k=this.s.rowData,r=g.i18n("searchPanes.count",this.c.i18n.count),v=g.i18n("searchPanes.countFiltered",this.c.i18n.countFiltered),t=g.state.loaded();this.s.listSet&&
|
|
(t=g.state());if(this.colExists){var u=-1;if(t&&t.searchPanes&&t.searchPanes.panes)for(var q=0;q<t.searchPanes.panes.length;q++)if(t.searchPanes.panes[q].id===this.s.index){u=q;break}if((!1===m.show||void 0!==m.show&&!0!==m.show)&&-1===u)return this.dom.container.addClass(this.classes.hidden),this.s.displayed=!1;if(!0===m.show||-1!==u)this.s.displayed=!0;if(!this.s.dt.page.info().serverSide&&(null===f||null===f.searchPanes||null===f.searchPanes.options)){if(0===k.arrayFilter.length){this._populatePane(b);
|
|
this.s.rowData.totalOptions=0;this._detailsPane();if(t&&t.searchPanes&&t.searchPanes.panes&&-1===u){this.dom.container.addClass(this.classes.hidden);this.s.displayed=!1;return}k.arrayOriginal=k.arrayTotals;k.binsOriginal=k.binsTotal}q=Object.keys(k.binsOriginal).length;b=this._uniqueRatio(q,g.rows()[0].length);if(!1===this.s.displayed&&((void 0===m.show&&null===m.threshold?b>this.c.threshold:b>m.threshold)||!0!==m.show&&1>=q)){this.dom.container.addClass(this.classes.hidden);this.s.displayed=!1;return}this.c.viewTotal&&
|
|
0===k.arrayTotals.length?(this.s.rowData.totalOptions=0,this._detailsPane()):k.binsTotal=k.bins;this.dom.container.addClass(this.classes.show);this.s.displayed=!0}else if(null!==f&&null!==f.searchPanes&&null!==f.searchPanes.options){if(void 0!==f.tableLength)this.s.tableLength=f.tableLength,this.s.rowData.totalOptions=this.s.tableLength;else if(null===this.s.tableLength||g.rows()[0].length>this.s.tableLength)this.s.tableLength=g.rows()[0].length,this.s.rowData.totalOptions=this.s.tableLength;b=g.column(this.s.index).dataSrc();
|
|
if(void 0!==f.searchPanes.options[b])for(q=0,b=f.searchPanes.options[b];q<b.length;q++)u=b[q],this.s.rowData.arrayFilter.push({display:u.label,filter:u.value,sort:u.label,type:u.label}),this.s.rowData.bins[u.value]=this.c.viewTotal||this.c.cascadePanes?u.count:u.total,this.s.rowData.binsTotal[u.value]=u.total;q=Object.keys(k.binsTotal).length;b=this._uniqueRatio(q,this.s.tableLength);if(!1===this.s.displayed&&((void 0===m.show&&null===m.threshold?b>this.c.threshold:b>m.threshold)||!0!==m.show&&1>=
|
|
q)){this.dom.container.addClass(this.classes.hidden);this.s.displayed=!1;return}this.s.rowData.arrayOriginal=this.s.rowData.arrayFilter;this.s.rowData.binsOriginal=this.s.rowData.bins;this.s.displayed=!0}}else this.s.displayed=!0;this._displayPane();if(!this.s.listSet)this.dom.dtP.on("stateLoadParams.dt",function(x,C,y){l.isEmptyObject(g.state.loaded())&&l.each(y,function(z,I){delete y[z]})});null!==e&&0<l(this.dom.panesContainer).has(e).length?l(this.dom.container).insertAfter(e):l(this.dom.panesContainer).prepend(this.dom.container);
|
|
q=l.fn.dataTable.ext.errMode;l.fn.dataTable.ext.errMode="none";e=A.Scroller;this.s.dtPane=l(this.dom.dtP).DataTable(l.extend(!0,{columnDefs:[{className:"dtsp-nameColumn",data:"display",render:function(x,C,y){if("sort"===C)return y.sort;if("type"===C)return y.type;var z=(d.s.filteringActive||d.s.showFiltered)&&d.c.viewTotal||d.c.viewTotal&&d.s.forceViewTotal?v.replace(/{total}/,y.total):r.replace(/{total}/,y.total);for(z=z.replace(/{shown}/,y.shown);-1!==z.indexOf("{total}");)z=z.replace(/{total}/,
|
|
y.total);for(;-1!==z.indexOf("{shown}");)z=z.replace(/{shown}/,y.shown);y='<span class="'+d.classes.pill+'">'+z+"</span>";d.c.viewCount&&m.viewCount||(y="");return"filter"===C?"string"===typeof x&&null!==x.match(/<[^>]*>/)?x.replace(/<[^>]*>/g,""):x:'<div class="'+d.classes.nameCont+'"><span title="'+("string"===typeof x&&null!==x.match(/<[^>]*>/)?x.replace(/<[^>]*>/g,""):x)+'" class="'+d.classes.name+'">'+x+"</span>"+y+"</div>"},targets:0,type:void 0!==g.settings()[0].aoColumns[this.s.index]?g.settings()[0].aoColumns[this.s.index]._sManualType:
|
|
null},{className:"dtsp-countColumn "+this.classes.badgePill,data:"shown",orderData:[1,2],targets:1,visible:!1},{data:"total",targets:2,visible:!1}],deferRender:!0,dom:"t",info:!1,language:this.s.dt.settings()[0].oLanguage,paging:e?!0:!1,scrollX:!1,scrollY:"200px",scroller:e?!0:!1,select:!0,stateSave:g.settings()[0].oFeatures.bStateSave?!0:!1},this.c.dtOpts,void 0!==m?m.dtOpts:{},void 0===this.s.colOpts.options&&this.colExists?void 0:{createdRow:function(x,C,y){l(x).addClass(C.className)}},null!==
|
|
this.customPaneSettings&&void 0!==this.customPaneSettings.dtOpts?this.customPaneSettings.dtOpts:{},l.fn.dataTable.versionCheck("2")?{layout:{bottomLeft:null,bottomRight:null,topLeft:null,topRight:null}}:{}));l(this.dom.dtP).addClass(this.classes.table);e="Custom Pane";this.customPaneSettings&&this.customPaneSettings.header?e=this.customPaneSettings.header:m.header?e=m.header:this.colExists&&(e=l.fn.dataTable.versionCheck("2")?g.column(this.s.index).title():g.settings()[0].aoColumns[this.s.index].sTitle);
|
|
this.dom.searchBox.attr("placeholder",e);l.fn.dataTable.select.init(this.s.dtPane);l.fn.dataTable.ext.errMode=q;if(this.colExists){h=(h=h.search())?h.substr(1,h.length-2).split("|"):[];var w=0;k.arrayFilter.forEach(function(x){""===x.filter&&w++});q=0;for(e=k.arrayFilter.length;q<e;q++){h=!1;u=0;for(var D=this.s.serverSelect;u<D.length;u++)b=D[u],b.filter===k.arrayFilter[q].filter&&(h=!0);if(this.s.dt.page.info().serverSide&&(!this.c.cascadePanes||this.c.cascadePanes&&0!==k.bins[k.arrayFilter[q].filter]||
|
|
this.c.cascadePanes&&null!==c||h))for(h=this.addRow(k.arrayFilter[q].display,k.arrayFilter[q].filter,c?k.binsTotal[k.arrayFilter[q].filter]:k.bins[k.arrayFilter[q].filter],this.c.viewTotal||c?String(k.binsTotal[k.arrayFilter[q].filter]):k.bins[k.arrayFilter[q].filter],k.arrayFilter[q].sort,k.arrayFilter[q].type),u=0,D=this.s.serverSelect;u<D.length;u++)b=D[u],b.filter===k.arrayFilter[q].filter&&(this.s.serverSelecting=!0,h.select(),this.s.serverSelecting=!1);else this.s.dt.page.info().serverSide||
|
|
!k.arrayFilter[q]||void 0===k.bins[k.arrayFilter[q].filter]&&this.c.cascadePanes?this.s.dt.page.info().serverSide||this.addRow("",w,w,"","",""):this.addRow(k.arrayFilter[q].display,k.arrayFilter[q].filter,k.bins[k.arrayFilter[q].filter],k.binsTotal[k.arrayFilter[q].filter],k.arrayFilter[q].sort,k.arrayFilter[q].type)}}A.select.init(this.s.dtPane);(void 0!==m.options||null!==this.customPaneSettings&&void 0!==this.customPaneSettings.options)&&this._getComparisonRows();this.s.dtPane.draw();this.adjustTopRow();
|
|
this.s.listSet||(this._setListeners(),this.s.listSet=!0);for(c=0;c<a.length;c++)if(k=a[c],void 0!==k)for(q=0,e=this.s.dtPane.rows().indexes().toArray();q<e.length;q++)h=e[q],void 0!==this.s.dtPane.row(h).data()&&k.filter===this.s.dtPane.row(h).data().filter&&(this.s.dt.page.info().serverSide?(this.s.serverSelecting=!0,this.s.dtPane.row(h).select(),this.s.serverSelecting=!1):this.s.dtPane.row(h).select());this.s.dt.page.info().serverSide&&this.s.dtPane.search(l(this.dom.searchBox).val()).draw();if(t&&
|
|
t.searchPanes&&t.searchPanes.panes&&(null===f||1===f.draw))for(this.c.cascadePanes||this._reloadSelect(t),f=0,t=t.searchPanes.panes;f<t.length;f++)a=t[f],a.id===this.s.index&&(l(this.dom.searchBox).val(a.searchTerm),l(this.dom.searchBox).trigger("input"),this.s.dtPane.order(a.order).draw());this.s.dt.state.save();return!0};n.prototype._detailsPane=function(){var a=this.s.dt;this.s.rowData.arrayTotals=[];this.s.rowData.binsTotal={};var b=this.s.dt.settings()[0];a=a.rows().indexes();if(!this.s.dt.page.info().serverSide)for(var f=
|
|
0;f<a.length;f++)this._populatePaneArray(a[f],this.s.rowData.arrayTotals,b,this.s.rowData.binsTotal)};n.prototype._displayPane=function(){var a=this.dom.container,b=this.s.colOpts,f=parseInt(this.c.layout.split("-")[1],10);l(this.dom.topRow).empty();l(this.dom.dtP).empty();l(this.dom.topRow).addClass(this.classes.topRow);3<f&&l(this.dom.container).addClass(this.classes.smallGap);l(this.dom.topRow).addClass(this.classes.subRowsContainer);l(this.dom.upper).appendTo(this.dom.topRow);l(this.dom.lower).appendTo(this.dom.topRow);
|
|
l(this.dom.searchCont).appendTo(this.dom.upper);l(this.dom.buttonGroup).appendTo(this.dom.lower);(!1===this.c.dtOpts.searching||void 0!==b.dtOpts&&!1===b.dtOpts.searching||!this.c.controls||!b.controls||null!==this.customPaneSettings&&void 0!==this.customPaneSettings.dtOpts&&void 0!==this.customPaneSettings.dtOpts.searching&&!this.customPaneSettings.dtOpts.searching)&&l(this.dom.searchBox).removeClass(this.classes.paneInputButton).addClass(this.classes.disabledButton).attr("disabled","true");l(this.dom.searchBox).appendTo(this.dom.searchCont);
|
|
this._searchContSetup();this.c.clear&&this.c.controls&&b.controls&&l(this.dom.clear).appendTo(this.dom.buttonGroup);this.c.orderable&&b.orderable&&this.c.controls&&b.controls&&l(this.dom.nameButton).appendTo(this.dom.buttonGroup);this.c.viewCount&&b.viewCount&&this.c.orderable&&b.orderable&&this.c.controls&&b.controls&&l(this.dom.countButton).appendTo(this.dom.buttonGroup);l(this.dom.topRow).prependTo(this.dom.container);l(a).append(this.dom.dtP);l(a).show()};n.prototype._getBonusOptions=function(){return l.extend(!0,
|
|
{},n.defaults,{orthogonal:{threshold:null},threshold:null},void 0!==this.c?this.c:{})};n.prototype._getComparisonRows=function(){var a=this.s.colOpts;a=void 0!==a.options?a.options:null!==this.customPaneSettings&&void 0!==this.customPaneSettings.options?this.customPaneSettings.options:void 0;if(void 0!==a){var b=this.s.dt.rows({search:"applied"}).data().toArray(),f=this.s.dt.rows({search:"applied"}),c=this.s.dt.rows().data().toArray(),e=this.s.dt.rows(),d=[];this.s.dtPane.clear();for(var g=0;g<a.length;g++){var h=
|
|
a[g],m=""!==h.label?h.label:this.emptyMessage(),k=h.className,r=m,v="function"===typeof h.value?h.value:[],t=0,u=m,q=0;if("function"===typeof h.value){for(var w=0;w<b.length;w++)h.value.call(this.s.dt,b[w],f[0][w])&&t++;for(w=0;w<c.length;w++)h.value.call(this.s.dt,c[w],e[0][w])&&q++;"function"!==typeof v&&v.push(h.filter)}(!this.c.cascadePanes||this.c.cascadePanes&&0!==t)&&d.push(this.addRow(r,v,t,q,u,m,k))}return d}};n.prototype._getOptions=function(){var a=this.s.dt.settings()[0].aoColumns[this.s.index].searchPanes,
|
|
b=l.extend(!0,{},n.defaults,{emptyMessage:!1,orthogonal:{threshold:null},threshold:null},a);void 0!==a&&void 0!==a.hideCount&&void 0===a.viewCount&&(b.viewCount=!a.hideCount);return b};n.prototype._makeSelection=function(){this.updateTable();this.s.updating=!0;this.s.dt.draw();this.s.updating=!1};n.prototype._populatePane=function(a){void 0===a&&(a=!1);var b=this.s.dt;this.s.rowData.arrayFilter=[];this.s.rowData.bins={};var f=this.s.dt.settings()[0];if(!this.s.dt.page.info().serverSide){var c=0;for(a=
|
|
(!this.c.cascadePanes&&!this.c.viewTotal||this.s.clearing||a?b.rows().indexes():b.rows({search:"applied"}).indexes()).toArray();c<a.length;c++)this._populatePaneArray(a[c],this.s.rowData.arrayFilter,f)}};n.prototype._populatePaneArray=function(a,b,f,c){void 0===c&&(c=this.s.rowData.bins);var e=this.s.colOpts;if("string"===typeof e.orthogonal)f=f.oApi._fnGetCellData(f,a,this.s.index,e.orthogonal),this.s.rowData.filterMap.set(a,f),this._addOption(f,f,f,f,b,c);else{var d=f.oApi._fnGetCellData(f,a,this.s.index,
|
|
e.orthogonal.search);null===d&&(d="");"string"===typeof d&&(d=d.replace(/<[^>]*>/g,""));this.s.rowData.filterMap.set(a,d);c[d]?c[d]++:(c[d]=1,this._addOption(d,f.oApi._fnGetCellData(f,a,this.s.index,e.orthogonal.display),f.oApi._fnGetCellData(f,a,this.s.index,e.orthogonal.sort),f.oApi._fnGetCellData(f,a,this.s.index,e.orthogonal.type),b,c));this.s.rowData.totalOptions++}};n.prototype._reloadSelect=function(a){if(void 0!==a){for(var b,f=0;f<a.searchPanes.panes.length;f++)if(a.searchPanes.panes[f].id===
|
|
this.s.index){b=f;break}if(void 0!==b){f=this.s.dtPane;var c=f.rows({order:"index"}).data().map(function(g){return null!==g.filter?g.filter.toString():null}).toArray(),e=0;for(a=a.searchPanes.panes[b].selected;e<a.length;e++){b=a[e];var d=-1;null!==b&&(d=c.indexOf(b.toString()));-1<d&&(this.s.serverSelecting=!0,f.row(d).select(),this.s.serverSelecting=!1)}}}};n.prototype._search=function(a,b){for(var f=this.s.colOpts,c=this.s.dt,e=0,d=this.selections;e<d.length;e++){var g=d[e];"string"===typeof g.filter&&
|
|
"string"===typeof a&&(g.filter=g.filter.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"'));if(Array.isArray(a)){if(-1!==a.indexOf(g.filter))return!0}else if("function"===typeof g.filter)if(g.filter.call(c,c.row(b).data(),b)){if("or"===f.combiner)return!0}else{if("and"===f.combiner)return!1}else if(a===g.filter||("string"!==typeof a||0!==a.length)&&a==g.filter||null===g.filter&&"string"===typeof a&&""===a)return!0}return"and"===f.combiner?!0:!1};n.prototype._searchContSetup=
|
|
function(){this.c.controls&&this.s.colOpts.controls&&l(this.dom.searchButton).appendTo(this.dom.searchLabelCont);!1===this.c.dtOpts.searching||!1===this.s.colOpts.dtOpts.searching||null!==this.customPaneSettings&&void 0!==this.customPaneSettings.dtOpts&&void 0!==this.customPaneSettings.dtOpts.searching&&!this.customPaneSettings.dtOpts.searching||l(this.dom.searchLabelCont).appendTo(this.dom.searchCont)};n.prototype._searchExtras=function(){var a=this.s.updating;this.s.updating=!0;var b=this.s.dtPane.rows({selected:!0}).data().pluck("filter").toArray(),
|
|
f=b.indexOf(this.emptyMessage()),c=l(this.s.dtPane.table().container());-1<f&&(b[f]="");0<b.length?c.addClass(this.classes.selected):0===b.length&&c.removeClass(this.classes.selected);this.s.updating=a};n.prototype._uniqueRatio=function(a,b){return 0<b&&(0<this.s.rowData.totalOptions&&!this.s.dt.page.info().serverSide||this.s.dt.page.info().serverSide&&0<this.s.tableLength)?a/this.s.rowData.totalOptions:1};n.prototype._updateCommon=function(a){void 0===a&&(a=!1);if(!(this.s.dt.page.info().serverSide||
|
|
void 0===this.s.dtPane||this.s.filteringActive&&!this.c.cascadePanes&&!0!==a||!0===this.c.cascadePanes&&!0===this.s.selectPresent||this.s.lastSelect&&this.s.lastCascade)){var b=this.s.colOpts,f=this.s.dtPane.rows({selected:!0}).data().toArray();a=l(this.s.dtPane.table().node()).parent()[0].scrollTop;var c=this.s.rowData;this.s.dtPane.clear();if(this.colExists){0===c.arrayFilter.length?this._populatePane(!this.s.filteringActive):this.c.cascadePanes&&this.s.dt.rows().data().toArray().length===this.s.dt.rows({search:"applied"}).data().toArray().length?
|
|
(c.arrayFilter=c.arrayOriginal,c.bins=c.binsOriginal):(this.c.viewTotal||this.c.cascadePanes)&&this._populatePane(!this.s.filteringActive);this.c.viewTotal?this._detailsPane():c.binsTotal=c.bins;this.c.viewTotal&&!this.c.cascadePanes&&(c.arrayFilter=c.arrayTotals);for(var e=function(m){if(m&&(void 0!==c.bins[m.filter]&&0!==c.bins[m.filter]&&d.c.cascadePanes||!d.c.cascadePanes||d.s.clearing)){var k=d.addRow(m.display,m.filter,d.c.viewTotal?void 0!==c.bins[m.filter]?c.bins[m.filter]:0:c.bins[m.filter],
|
|
d.c.viewTotal?String(c.binsTotal[m.filter]):c.bins[m.filter],m.sort,m.type),r=f.findIndex(function(v){return v.filter===m.filter});-1!==r&&(k.select(),f.splice(r,1))}},d=this,g=0,h=c.arrayFilter;g<h.length;g++)e(h[g])}if(void 0!==b.searchPanes&&void 0!==b.searchPanes.options||void 0!==b.options||null!==this.customPaneSettings&&void 0!==this.customPaneSettings.options)for(e=function(m){var k=f.findIndex(function(r){if(r.display===m.data().display)return!0});-1!==k&&(m.select(),f.splice(k,1))},g=0,
|
|
h=this._getComparisonRows();g<h.length;g++)b=h[g],e(b);for(e=0;e<f.length;e++)b=f[e],b=this.addRow(b.display,b.filter,0,this.c.viewTotal?b.total:0,b.display,b.display),this.s.updating=!0,b.select(),this.s.updating=!1;this.s.dtPane.draw();this.s.dtPane.table().node().parentNode.scrollTop=a}};n.version="1.3.0";n.classes={buttonGroup:"dtsp-buttonGroup",buttonSub:"dtsp-buttonSub",clear:"dtsp-clear",clearAll:"dtsp-clearAll",clearButton:"clearButton",container:"dtsp-searchPane",countButton:"dtsp-countButton",
|
|
disabledButton:"dtsp-disabledButton",hidden:"dtsp-hidden",hide:"dtsp-hide",layout:"dtsp-",name:"dtsp-name",nameButton:"dtsp-nameButton",nameCont:"dtsp-nameCont",narrow:"dtsp-narrow",paneButton:"dtsp-paneButton",paneInputButton:"dtsp-paneInputButton",pill:"dtsp-pill",search:"dtsp-search",searchCont:"dtsp-searchCont",searchIcon:"dtsp-searchIcon",searchLabelCont:"dtsp-searchButtonCont",selected:"dtsp-selected",smallGap:"dtsp-smallGap",subRow1:"dtsp-subRow1",subRow2:"dtsp-subRow2",subRowsContainer:"dtsp-subRowsContainer",
|
|
title:"dtsp-title",topRow:"dtsp-topRow"};n.defaults={cascadePanes:!1,clear:!0,combiner:"or",container:function(a){return a.table().container()},controls:!0,dtOpts:{},emptyMessage:null,hideCount:!1,i18n:{clearPane:"×",count:"{total}",countFiltered:"{shown} ({total})",emptyMessage:"<em>No data</em>"},layout:"auto",name:void 0,orderable:!0,orthogonal:{display:"display",filter:"filter",hideCount:!1,search:"filter",show:void 0,sort:"sort",threshold:.6,type:"type",viewCount:!0},preSelect:[],threshold:.6,
|
|
viewCount:!0,viewTotal:!1};return n}(),p,B,F=function(){function n(a,b,f){var c=this;void 0===f&&(f=!1);this.regenerating=!1;if(!B||!B.versionCheck||!B.versionCheck("1.10.0"))throw Error("SearchPane requires DataTables 1.10 or newer");if(!B.select)throw Error("SearchPane requires Select");var e=new B.Api(a);this.classes=p.extend(!0,{},n.classes);this.c=p.extend(!0,{},n.defaults,b);this.dom={clearAll:p('<button type="button">Clear All</button>').addClass(this.classes.clearAll),container:p("<div/>").addClass(this.classes.panes).text(e.i18n("searchPanes.loadMessage",
|
|
this.c.i18n.loadMessage)),emptyMessage:p("<div/>").addClass(this.classes.emptyMessage),options:p("<div/>").addClass(this.classes.container),panes:p("<div/>").addClass(this.classes.container),title:p("<div/>").addClass(this.classes.title),titleRow:p("<div/>").addClass(this.classes.titleRow),wrapper:p("<div/>")};this.s={colOpts:[],dt:e,filterCount:0,filterPane:-1,page:0,panes:[],selectionList:[],serverData:{},stateRead:!1,updating:!1};if(void 0===e.settings()[0]._searchPanes){this._getState();if(this.s.dt.page.info().serverSide)e.on("preXhr.dt",
|
|
function(d,g,h){void 0===h.searchPanes&&(h.searchPanes={});void 0===h.searchPanes_null&&(h.searchPanes_null={});d=0;for(g=c.s.selectionList;d<g.length;d++){var m=g[d],k=c.s.dt.column(m.index).dataSrc();void 0===h.searchPanes[k]&&(h.searchPanes[k]={});void 0===h.searchPanes_null[k]&&(h.searchPanes_null[k]={});for(var r=0;r<m.rows.length;r++)h.searchPanes[k][r]=m.rows[r].filter,null===h.searchPanes[k][r]&&(h.searchPanes_null[k][r]=!0)}});e.on("xhr",function(d,g,h,m){h&&h.searchPanes&&h.searchPanes.options&&
|
|
(c.s.serverData=h,c.s.serverData.tableLength=h.recordsTotal,c._serverTotals())});e.settings()[0]._searchPanes=this;this.dom.clearAll.text(e.i18n("searchPanes.clearMessage",this.c.i18n.clearMessage));if(this.s.dt.settings()[0]._bInitComplete||f)this._paneDeclare(e,a,b);else e.one("preInit.dt",function(d){c._paneDeclare(e,a,b)});return this}}n.prototype.clearSelections=function(){this.dom.container.find("."+this.classes.search.replace(/\s+/g,".")).each(function(){p(this).val("");p(this).trigger("input")});
|
|
for(var a=[],b=0,f=this.s.panes;b<f.length;b++){var c=f[b];void 0!==c.s.dtPane&&a.push(c.clearPane())}return a};n.prototype.getNode=function(){return this.dom.container};n.prototype.rebuild=function(a,b){void 0===a&&(a=!1);void 0===b&&(b=!1);p(this.dom.emptyMessage).remove();var f=[];!1===a&&p(this.dom.panes).empty();for(var c=0,e=this.s.panes;c<e.length;c++){var d=e[c];if(!1===a||d.s.index===a)d.clearData(),f.push(d.rebuildPane(void 0!==this.s.selectionList[this.s.selectionList.length-1]?d.s.index===
|
|
this.s.selectionList[this.s.selectionList.length-1].index:!1,this.s.dt.page.info().serverSide?this.s.serverData:void 0,null,b)),p(this.dom.panes).append(d.dom.container)}this.c.cascadePanes||this.c.viewTotal?this.redrawPanes(!0):this._updateSelection();this._updateFilterCount();this._attachPaneContainer();this.s.dt.draw();this.resizePanes();return 1===f.length?f[0]:f};n.prototype.redrawPanes=function(a){void 0===a&&(a=!1);var b=this.s.dt;if(!this.s.updating&&!this.s.dt.page.info().serverSide){for(var f=
|
|
!0,c=this.s.filterPane,e=null,d=0,g=this.s.panes;d<g.length;d++){var h=g[d];void 0!==h.s.dtPane&&(e+=h.s.dtPane.rows({selected:!0}).data().toArray().length)}if(0===e&&b.rows({search:"applied"}).data().toArray().length===b.rows().data().toArray().length)f=!1;else if(this.c.viewTotal){d=0;for(g=this.s.panes;d<g.length;d++)if(h=g[d],void 0!==h.s.dtPane){var m=h.s.dtPane.rows({selected:!0}).data().toArray().length;if(0===m)for(var k=0,r=this.s.selectionList;k<r.length;k++){var v=r[k];v.index===h.s.index&&
|
|
0!==v.rows.length&&(m=v.rows.length)}0<m&&-1===c?c=h.s.index:0<m&&(c=null)}0===e&&(c=null)}g=void 0;d=[];if(this.regenerating){b=-1;1===d.length&&null!==e&&0!==e&&(b=d[0].index);a=0;for(d=this.s.panes;a<d.length;a++)if(h=d[a],void 0!==h.s.dtPane){g=!0;h.s.filteringActive=!0;if(-1!==c&&null!==c&&c===h.s.index||!1===f||h.s.index===b)g=!1,h.s.filteringActive=!1;h.updatePane(g?f:g)}this._updateFilterCount()}else{m=0;for(k=this.s.panes;m<k.length;m++)if(h=k[m],h.s.selectPresent){this.s.selectionList.push({index:h.s.index,
|
|
protect:!1,rows:h.s.dtPane.rows({selected:!0}).data().toArray()});b.state.save();break}else h.s.deselect&&(g=h.s.index,r=h.s.dtPane.rows({selected:!0}).data().toArray(),0<r.length&&this.s.selectionList.push({index:h.s.index,protect:!0,rows:r}));if(0<this.s.selectionList.length)for(b=this.s.selectionList[this.s.selectionList.length-1].index,m=0,k=this.s.panes;m<k.length;m++)h=k[m],h.s.lastSelect=h.s.index===b;for(h=0;h<this.s.selectionList.length;h++)if(this.s.selectionList[h].index!==g||!0===this.s.selectionList[h].protect){b=
|
|
!1;for(m=h+1;m<this.s.selectionList.length;m++)this.s.selectionList[m].index===this.s.selectionList[h].index&&(b=!0);b||(d.push(this.s.selectionList[h]),this.s.selectionList[h].protect=!1)}b=-1;1===d.length&&null!==e&&0!==e&&(b=d[0].index);m=0;for(k=this.s.panes;m<k.length;m++)if(h=k[m],void 0!==h.s.dtPane){g=!0;h.s.filteringActive=!0;if(-1!==c&&null!==c&&c===h.s.index||!1===f||h.s.index===b)g=!1,h.s.filteringActive=!1;h.updatePane(g?f:!1)}this._updateFilterCount();if(0<d.length&&(d.length<this.s.selectionList.length||
|
|
a))for(this._cascadeRegen(d,e),b=d[d.length-1].index,c=0,a=this.s.panes;c<a.length;c++)h=a[c],h.s.lastSelect=h.s.index===b;else if(0<d.length)for(h=0,a=this.s.panes;h<a.length;h++)if(d=a[h],void 0!==d.s.dtPane){g=!0;d.s.filteringActive=!0;if(-1!==c&&null!==c&&c===d.s.index||!1===f||d.s.index===b)g=!1,d.s.filteringActive=!1;d.updatePane(g?f:g)}}f&&0!==e||(this.s.selectionList=[])}};n.prototype.resizePanes=function(){if("auto"===this.c.layout){var a=p(this.s.dt.searchPanes.container()).width(),b=Math.floor(a/
|
|
260);a=1;for(var f=0,c=[],e=0,d=this.s.panes;e<d.length;e++){var g=d[e];g.s.displayed&&c.push(g.s.index)}g=c.length;if(b===g)a=b;else for(;1<b;b--)if(e=g%b,0===e){a=b;f=0;break}else e>f&&(a=b,f=e);c=0!==f?c.slice(c.length-f,c.length):[];b=0;for(e=this.s.panes;b<e.length;b++)g=e[b],g.s.displayed&&(d="columns-"+(-1===c.indexOf(g.s.index)?a:f),g.resize(d))}else for(a=0,f=this.s.panes;a<f.length;a++)g=f[a],g.adjustTopRow();return this};n.prototype._attach=function(){var a=this;p(this.dom.container).removeClass(this.classes.hide);
|
|
p(this.dom.titleRow).removeClass(this.classes.hide);p(this.dom.titleRow).remove();p(this.dom.title).appendTo(this.dom.titleRow);this.c.clear&&(p(this.dom.clearAll).appendTo(this.dom.titleRow),p(this.dom.clearAll).on("click.dtsps",function(){a.clearSelections()}));p(this.dom.titleRow).appendTo(this.dom.container);for(var b=0,f=this.s.panes;b<f.length;b++)p(f[b].dom.container).appendTo(this.dom.panes);p(this.dom.panes).appendTo(this.dom.container);0===p("div."+this.classes.container).length&&p(this.dom.container).prependTo(this.s.dt);
|
|
return this.dom.container};n.prototype._attachExtras=function(){p(this.dom.container).removeClass(this.classes.hide);p(this.dom.titleRow).removeClass(this.classes.hide);p(this.dom.titleRow).remove();p(this.dom.title).appendTo(this.dom.titleRow);this.c.clear&&p(this.dom.clearAll).appendTo(this.dom.titleRow);p(this.dom.titleRow).appendTo(this.dom.container);return this.dom.container};n.prototype._attachMessage=function(){try{var a=this.s.dt.i18n("searchPanes.emptyPanes",this.c.i18n.emptyPanes)}catch(b){a=
|
|
null}if(null===a)p(this.dom.container).addClass(this.classes.hide),p(this.dom.titleRow).removeClass(this.classes.hide);else return p(this.dom.container).removeClass(this.classes.hide),p(this.dom.titleRow).addClass(this.classes.hide),p(this.dom.emptyMessage).text(a),this.dom.emptyMessage.appendTo(this.dom.container),this.dom.container};n.prototype._attachPaneContainer=function(){for(var a=0,b=this.s.panes;a<b.length;a++)if(!0===b[a].s.displayed)return this._attach();return this._attachMessage()};n.prototype._cascadeRegen=
|
|
function(a,b){this.regenerating=!0;var f=-1;1===a.length&&null!==b&&0!==b&&(f=a[0].index);for(var c=0,e=this.s.panes;c<e.length;c++)b=e[c],b.setCascadeRegen(!0),b.setClear(!0),(void 0!==b.s.dtPane&&b.s.index===f||void 0!==b.s.dtPane)&&b.clearPane(),b.setClear(!1);this.s.dt.draw();f=this.s.dt.rows({search:"applied"}).data().toArray().length;c=this.s.dt.rows().data().toArray().length;if(c!==f){e=0;for(var d=this.s.panes;e<d.length;e++)b=d[e],b.s.forceViewTotal=!0}e=0;for(d=this.s.panes;e<d.length;e++)b=
|
|
d[e],b.updatePane(!0);this._makeCascadeSelections(a);this.s.selectionList=a;a=0;for(e=this.s.panes;a<e.length;a++)b=e[a],b.setCascadeRegen(!1);this.regenerating=!1;if(c!==f)for(a=0,f=this.s.panes;a<f.length;a++)b=f[a],b.s.forceViewTotal=!1};n.prototype._checkMessage=function(){for(var a=0,b=this.s.panes;a<b.length;a++)if(!0===b[a].s.displayed){p(this.dom.emptyMessage).remove();p(this.dom.titleRow).removeClass(this.classes.hide);return}return this._attachMessage()};n.prototype._getState=function(){var a=
|
|
this.s.dt.state.loaded();a&&a.searchPanes&&void 0!==a.searchPanes.selectionList&&(this.s.selectionList=a.searchPanes.selectionList)};n.prototype._makeCascadeSelections=function(a){for(var b=0;b<a.length;b++)for(var f=function(g){if(g.s.index===a[b].index&&void 0!==g.s.dtPane){b===a.length-1&&(g.s.lastCascade=!0);0<g.s.dtPane.rows({selected:!0}).data().toArray().length&&void 0!==g.s.dtPane&&(g.setClear(!0),g.clearPane(),g.setClear(!1));for(var h=function(r){var v=!1;g.s.dtPane.rows().every(function(t){void 0!==
|
|
g.s.dtPane.row(t).data()&&void 0!==r&&g.s.dtPane.row(t).data().filter===r.filter&&(v=!0,g.s.dtPane.row(t).select())});v||g.addRow(r.display,r.filter,0,r.total,r.sort,r.type,r.className).select()},m=0,k=a[b].rows;m<k.length;m++)h(k[m]);g.s.dtPane.draw();c._updateFilterCount();g.s.lastCascade=!1}},c=this,e=0,d=this.s.panes;e<d.length;e++)f(d[e]);this.s.dt.state.save()};n.prototype._paneDeclare=function(a,b,f){var c=this;a.columns(0<this.c.columns.length?this.c.columns:void 0).eq(0).each(function(h){c.s.panes.push(new E(b,
|
|
f,h,c.c.layout,c.dom.panes))});for(var e=a.columns().eq(0).toArray().length,d=this.c.panes.length,g=0;g<d;g++)this.s.panes.push(new E(b,f,e+g,this.c.layout,this.dom.panes,this.c.panes[g]));if(0<this.c.order.length)for(e=this.c.order.map(function(h,m,k){return c._findPane(h)}),this.dom.panes.empty(),this.s.panes=e,e=0,d=this.s.panes;e<d.length;e++)this.dom.panes.append(d[e].dom.container);this.s.dt.settings()[0]._bInitComplete?this._startup(a):this.s.dt.settings()[0].aoInitComplete.push({fn:function(){c._startup(a)}})};
|
|
n.prototype._findPane=function(a){for(var b=0,f=this.s.panes;b<f.length;b++){var c=f[b];if(a===c.s.name)return c}};n.prototype._serverTotals=function(){for(var a=!1,b=!1,f=this.s.dt,c=0,e=this.s.panes;c<e.length;c++){var d=e[c];if(d.s.selectPresent){this.s.selectionList.push({index:d.s.index,protect:!1,rows:d.s.dtPane.rows({selected:!0}).data().toArray()});f.state.save();d.s.selectPresent=!1;a=!0;break}else d.s.deselect&&(b=d.s.dtPane.rows({selected:!0}).data().toArray(),0<b.length&&this.s.selectionList.push({index:d.s.index,
|
|
protect:!0,rows:b}),b=a=!0)}if(a){f=[];for(c=0;c<this.s.selectionList.length;c++){d=!1;for(e=c+1;e<this.s.selectionList.length;e++)this.s.selectionList[e].index===this.s.selectionList[c].index&&(d=!0);if(!d){e=!1;a=0;for(var g=this.s.panes;a<g.length;a++)d=g[a],d.s.index===this.s.selectionList[c].index&&0<d.s.dtPane.rows({selected:!0}).data().toArray().length&&(e=!0);e&&f.push(this.s.selectionList[c])}}this.s.selectionList=f}else this.s.selectionList=[];f=-1;if(b&&1===this.s.selectionList.length)for(b=
|
|
0,c=this.s.panes;b<c.length;b++)d=c[b],d.s.lastSelect=!1,d.s.deselect=!1,void 0!==d.s.dtPane&&0<d.s.dtPane.rows({selected:!0}).data().toArray().length&&(f=d.s.index);else if(0<this.s.selectionList.length)for(b=this.s.selectionList[this.s.selectionList.length-1].index,c=0,e=this.s.panes;c<e.length;c++)d=e[c],d.s.lastSelect=d.s.index===b,d.s.deselect=!1;else if(0===this.s.selectionList.length)for(b=0,c=this.s.panes;b<c.length;b++)d=c[b],d.s.lastSelect=!1,d.s.deselect=!1;p(this.dom.panes).empty();b=
|
|
0;for(c=this.s.panes;b<c.length;b++)d=c[b],d.s.lastSelect?d._setListeners():d.rebuildPane(void 0,this.s.dt.page.info().serverSide?this.s.serverData:void 0,d.s.index===f?!0:null,!0),p(this.dom.panes).append(d.dom.container),void 0!==d.s.dtPane&&(p(d.s.dtPane.table().node()).parent()[0].scrollTop=d.s.scrollTop,p.fn.dataTable.select.init(d.s.dtPane));this._updateSelection()};n.prototype._startup=function(a){var b=this;p(this.dom.container).text("");this._attachExtras();p(this.dom.container).append(this.dom.panes);
|
|
p(this.dom.panes).empty();var f=this.s.dt.state.loaded();if(this.c.viewTotal&&!this.c.cascadePanes&&null!==f&&void 0!==f&&void 0!==f.searchPanes&&void 0!==f.searchPanes.panes){for(var c=!1,e=0,d=f.searchPanes.panes;e<d.length;e++){var g=d[e];if(0<g.selected.length){c=!0;break}}if(c)for(c=0,e=this.s.panes;c<e.length;c++)g=e[c],g.s.showFiltered=!0}c=0;for(e=this.s.panes;c<e.length;c++)g=e[c],g.rebuildPane(void 0,0<Object.keys(this.s.serverData).length?this.s.serverData:void 0),p(this.dom.panes).append(g.dom.container);
|
|
"auto"===this.c.layout&&this.resizePanes();this.s.stateRead||null===f||void 0===f||(this.s.dt.page(f.start/this.s.dt.page.len()),this.s.dt.draw("page"));this.s.stateRead=!0;if(this.c.viewTotal&&!this.c.cascadePanes)for(f=0,c=this.s.panes;f<c.length;f++)g=c[f],g.updatePane();this._updateFilterCount();this._checkMessage();a.on("preDraw.dtsps",function(){b.s.updating||(b._updateFilterCount(),!b.c.cascadePanes&&!b.c.viewTotal||b.s.dt.page.info().serverSide?b._updateSelection():b.redrawPanes(b.c.viewTotal),
|
|
b.s.filterPane=-1)});p(window).on("resize.dtsp",B.util.throttle(function(){b.resizePanes()}));this.s.dt.on("stateSaveParams.dtsp",function(h,m,k){void 0===k.searchPanes&&(k.searchPanes={});k.searchPanes.selectionList=b.s.selectionList});if(this.s.dt.page.info().serverSide)a.off("page"),a.on("page",function(){b.s.page=b.s.dt.page()}),a.off("preXhr.dt"),a.on("preXhr.dt",function(h,m,k){void 0===k.searchPanes&&(k.searchPanes={});void 0===k.searchPanes_null&&(k.searchPanes_null={});m=h=0;for(var r=b.s.panes;m<
|
|
r.length;m++){var v=r[m],t=b.s.dt.column(v.s.index).dataSrc();void 0===k.searchPanes[t]&&(k.searchPanes[t]={});void 0===k.searchPanes_null[t]&&(k.searchPanes_null[t]={});if(void 0!==v.s.dtPane){v=v.s.dtPane.rows({selected:!0}).data().toArray();for(var u=0;u<v.length;u++)k.searchPanes[t][u]=v[u].filter,null===k.searchPanes[t][u]&&(k.searchPanes_null[t][u]=!0),h++}}b.c.viewTotal&&b._prepViewTotal(h);0<h&&(h!==b.s.filterCount?(k.start=0,b.s.page=0):k.start=b.s.page*b.s.dt.page.len(),b.s.dt.page(b.s.page),
|
|
b.s.filterCount=h)});else a.on("preXhr.dt",function(h,m,k){h=0;for(m=b.s.panes;h<m.length;h++)m[h].clearData()});this.s.dt.on("xhr",function(h,m,k,r){if(m.nTable===b.s.dt.table().node()){var v=!1;if(!b.s.dt.page.info().serverSide)b.s.dt.one("preDraw",function(){if(!v){var t=b.s.dt.page();v=!0;b.s.updating=!0;p(b.dom.panes).empty();for(var u=0,q=b.s.panes;u<q.length;u++){var w=q[u];w.clearData();w.rebuildPane(void 0!==b.s.selectionList[b.s.selectionList.length-1]?w.s.index===b.s.selectionList[b.s.selectionList.length-
|
|
1].index:!1,void 0,void 0,!0);p(b.dom.panes).append(w.dom.container)}b.s.dt.page.info().serverSide||b.s.dt.draw();b.s.updating=!1;b.c.cascadePanes||b.c.viewTotal?b.redrawPanes(b.c.cascadePanes):b._updateSelection();b._checkMessage();b.s.dt.one("draw",function(){b.s.updating=!0;b.s.dt.page(t).draw(!1);b.s.updating=!1})}})}});f=0;for(c=this.s.panes;f<c.length;f++)if(g=c[f],void 0!==g&&void 0!==g.s.dtPane&&(void 0!==g.s.colOpts.preSelect&&0<g.s.colOpts.preSelect.length||null!==g.customPaneSettings&&
|
|
void 0!==g.customPaneSettings.preSelect&&0<g.customPaneSettings.preSelect.length)){e=g.s.dtPane.rows().data().toArray().length;for(d=0;d<e;d++)(-1!==g.s.colOpts.preSelect.indexOf(g.s.dtPane.cell(d,0).data())||null!==g.customPaneSettings&&void 0!==g.customPaneSettings.preSelect&&-1!==g.customPaneSettings.preSelect.indexOf(g.s.dtPane.cell(d,0).data()))&&g.s.dtPane.row(d).select();g.updateTable()}if(void 0!==this.s.selectionList&&0<this.s.selectionList.length)for(f=this.s.selectionList[this.s.selectionList.length-
|
|
1].index,c=0,e=this.s.panes;c<e.length;c++)g=e[c],g.s.lastSelect=g.s.index===f;0<this.s.selectionList.length&&this.c.cascadePanes&&this._cascadeRegen(this.s.selectionList,this.s.selectionList.length);this._updateFilterCount();a.on("destroy.dtsps",function(){for(var h=0,m=b.s.panes;h<m.length;h++)m[h].destroy();a.off(".dtsps");p(b.dom.clearAll).off(".dtsps");p(b.dom.container).remove();b.clearSelections()});if(this.c.clear)p(this.dom.clearAll).on("click.dtsps",function(){b.clearSelections()});a.settings()[0]._searchPanes=
|
|
this;this.s.dt.state.save()};n.prototype._prepViewTotal=function(a){for(var b=this.s.filterPane,f=!1,c=0,e=this.s.panes;c<e.length;c++){var d=e[c];if(void 0!==d.s.dtPane){var g=d.s.dtPane.rows({selected:!0}).data().toArray().length;0<g&&-1===b?(b=d.s.index,f=!0):0<g&&(b=null)}}null!==a&&0!==a&&(b=null);a=0;for(c=this.s.panes;a<c.length;a++)if(d=c[a],void 0!==d.s.dtPane&&(d.s.filteringActive=!0,-1!==b&&null!==b&&b===d.s.index||!1===f))d.s.filteringActive=!1};n.prototype._updateFilterCount=function(){for(var a=
|
|
0,b=0,f=this.s.panes;b<f.length;b++){var c=f[b];void 0!==c.s.dtPane&&(a+=c.getPaneCount())}b=this.s.dt.i18n("searchPanes.title",this.c.i18n.title,a);p(this.dom.title).text(b);void 0!==this.c.filterChanged&&"function"===typeof this.c.filterChanged&&this.c.filterChanged.call(this.s.dt,a);0===a?p(this.dom.clearAll).addClass(this.classes.disabledButton).attr("disabled","true"):p(this.dom.clearAll).removeClass(this.classes.disabledButton).removeAttr("disabled")};n.prototype._updateSelection=function(){this.s.selectionList=
|
|
[];for(var a=0,b=this.s.panes;a<b.length;a++){var f=b[a];void 0!==f.s.dtPane&&this.s.selectionList.push({index:f.s.index,protect:!1,rows:f.s.dtPane.rows({selected:!0}).data().toArray()})}this.s.dt.state.save()};n.version="1.3.0";n.classes={clear:"dtsp-clear",clearAll:"dtsp-clearAll",container:"dtsp-searchPanes",disabledButton:"dtsp-disabledButton",emptyMessage:"dtsp-emptyMessage",hide:"dtsp-hidden",panes:"dtsp-panesContainer",search:"dtsp-search",title:"dtsp-title",titleRow:"dtsp-titleRow"};n.defaults=
|
|
{cascadePanes:!1,clear:!0,columns:[],container:function(a){return a.table().container()},filterChanged:void 0,i18n:{clearMessage:"Clear All",clearPane:"×",collapse:{0:"SearchPanes",_:"SearchPanes (%d)"},count:"{total}",countFiltered:"{shown} ({total})",emptyMessage:"<em>No data</em>",emptyPanes:"No SearchPanes",loadMessage:"Loading Search Panes...",title:"Filters Active - %d"},layout:"auto",order:[],panes:[],viewTotal:!1};return n}();(function(n){"function"===typeof define&&define.amd?define(["jquery",
|
|
"datatables.net"],function(a){return n(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);b&&b.fn.dataTable||(b=require("datatables.net")(a,b).$);return n(b,a,a.document)}:n(window.jQuery,window,document)})(function(n,a,b){function f(e,d,g){void 0===d&&(d=null);void 0===g&&(g=!1);e=new c.Api(e);d=d?d:e.init().searchPanes||c.defaults.searchPanes;return(new F(e,d,g)).getNode()}G(n);H(n);var c=n.fn.dataTable;n.fn.dataTable.SearchPanes=F;n.fn.DataTable.SearchPanes=
|
|
F;n.fn.dataTable.SearchPane=E;n.fn.DataTable.SearchPane=E;a=n.fn.dataTable.Api.register;a("searchPanes()",function(){return this});a("searchPanes.clearSelections()",function(){return this.iterator("table",function(e){e._searchPanes&&e._searchPanes.clearSelections()})});a("searchPanes.rebuildPane()",function(e,d){return this.iterator("table",function(g){g._searchPanes&&g._searchPanes.rebuild(e,d)})});a("searchPanes.resizePanes()",function(){var e=this.context[0];return e._searchPanes?e._searchPanes.resizePanes():
|
|
null});a("searchPanes.container()",function(){var e=this.context[0];return e._searchPanes?e._searchPanes.getNode():null});n.fn.dataTable.ext.buttons.searchPanesClear={action:function(e,d,g,h){d.searchPanes.clearSelections()},text:"Clear Panes"};n.fn.dataTable.ext.buttons.searchPanes={action:function(e,d,g,h){e.stopPropagation();this.popover(h._panes.getNode(),{align:"dt-container"});h._panes.rebuild(void 0,!0)},config:{},init:function(e,d,g){var h=new n.fn.dataTable.SearchPanes(e,n.extend({filterChanged:function(k){e.button(d).text(e.i18n("searchPanes.collapse",
|
|
h.c.i18n.collapse,k))}},g.config)),m=e.i18n("searchPanes.collapse",h.c.i18n.collapse,0);e.button(d).text(m);g._panes=h},text:"Search Panes"};n(b).on("preInit.dt.dtsp",function(e,d,g){"dt"===e.namespace&&(d.oInit.searchPanes||c.defaults.searchPanes)&&(d._searchPanes||f(d,null,!0))});c.ext.feature.push({cFeature:"P",fnInit:f});c.ext.features&&c.ext.features.register("searchPanes",f)})})();
|