123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171 |
- (function () {
- 'use strict';
- var $;
- var dataTable;
- function setJQuery(jq) {
- $ = jq;
- dataTable = jq.fn.dataTable;
- }
- var SearchPane = (function () {
-
- function SearchPane(paneSettings, opts, idx, layout, panesContainer, panes) {
- var _this = this;
- if (panes === void 0) { panes = null; }
-
- if (!dataTable || !dataTable.versionCheck || !dataTable.versionCheck('1.10.0')) {
- throw new Error('SearchPane requires DataTables 1.10 or newer');
- }
-
-
- if (!dataTable.select) {
- throw new Error('SearchPane requires Select');
- }
- var table = new dataTable.Api(paneSettings);
- this.classes = $.extend(true, {}, SearchPane.classes);
-
- this.c = $.extend(true, {}, SearchPane.defaults, opts);
- if (opts !== undefined && opts.hideCount !== undefined && opts.viewCount === undefined) {
- this.c.viewCount = !this.c.hideCount;
- }
- this.customPaneSettings = panes;
- this.s = {
- cascadeRegen: false,
- clearing: false,
- colOpts: [],
- deselect: false,
- displayed: false,
- dt: table,
- dtPane: undefined,
- filteringActive: false,
- firstSet: true,
- forceViewTotal: false,
- index: idx,
- indexes: [],
- lastCascade: false,
- lastSelect: false,
- listSet: false,
- name: undefined,
- redraw: false,
- rowData: {
- arrayFilter: [],
- arrayOriginal: [],
- arrayTotals: [],
- bins: {},
- binsOriginal: {},
- binsTotal: {},
- filterMap: new Map(),
- totalOptions: 0
- },
- scrollTop: 0,
- searchFunction: undefined,
- selectPresent: false,
- serverSelect: [],
- serverSelecting: false,
- showFiltered: false,
- tableLength: null,
- updating: false
- };
- var rowLength = table.columns().eq(0).toArray().length;
- this.colExists = this.s.index < rowLength;
-
- this.c.layout = layout;
- var layVal = parseInt(layout.split('-')[1], 10);
- this.dom = {
- buttonGroup: $('<div/>').addClass(this.classes.buttonGroup),
- clear: $('<button type="button">×</button>')
- .addClass(this.classes.disabledButton)
- .attr('disabled', 'true')
- .addClass(this.classes.paneButton)
- .addClass(this.classes.clearButton),
- collapseButton: $('<button type="button"><span class="dtsp-caret">^</span></button>')
- .addClass(this.classes.paneButton)
- .addClass(this.classes.collapseButton),
- container: $('<div/>')
- .addClass(this.classes.container)
- .addClass(this.classes.layout +
- (layVal < 10 ? layout : layout.split('-')[0] + '-9')),
- countButton: $('<button type="button"></button>')
- .addClass(this.classes.paneButton)
- .addClass(this.classes.countButton),
- dtP: $('<table><thead><tr><th>' +
- (this.colExists
- ? $(table.column(this.colExists ? this.s.index : 0).header()).text()
- : this.customPaneSettings.header || 'Custom Pane') + '</th><th/></tr></thead></table>'),
- lower: $('<div/>').addClass(this.classes.subRow2).addClass(this.classes.narrowButton),
- nameButton: $('<button type="button"></button>')
- .addClass(this.classes.paneButton)
- .addClass(this.classes.nameButton),
- panesContainer: panesContainer,
- searchBox: $('<input/>').addClass(this.classes.paneInputButton).addClass(this.classes.search),
- searchButton: $('<button type = "button" class="' + this.classes.searchIcon + '"></button>')
- .addClass(this.classes.paneButton),
- searchCont: $('<div/>').addClass(this.classes.searchCont),
- searchLabelCont: $('<div/>').addClass(this.classes.searchLabelCont),
- topRow: $('<div/>').addClass(this.classes.topRow),
- upper: $('<div/>').addClass(this.classes.subRow1).addClass(this.classes.narrowSearch)
- };
- this.s.displayed = false;
- table = this.s.dt;
- this.selections = [];
- this.s.colOpts = this.colExists ? this._getOptions() : this._getBonusOptions();
- var colOpts = this.s.colOpts;
- var clear = $('<button type="button">X</button>').addClass(this.classes.paneButton);
- clear.text(table.i18n('searchPanes.clearPane', this.c.i18n.clearPane));
- this.dom.container.addClass(colOpts.className);
- this.dom.container.addClass(this.customPaneSettings !== null && this.customPaneSettings.className !== undefined
- ? this.customPaneSettings.className
- : '');
-
- if (this.s.colOpts.name !== undefined) {
- this.s.name = this.s.colOpts.name;
- }
- else if (this.customPaneSettings !== null && this.customPaneSettings.name !== undefined) {
- this.s.name = this.customPaneSettings.name;
- }
- else {
- this.s.name = this.colExists ?
- $(table.column(this.s.index).header()).text() :
- this.customPaneSettings.header || 'Custom Pane';
- }
- $(panesContainer).append(this.dom.container);
- var tableNode = table.table(0).node();
-
- this.s.searchFunction = function (settings, searchData, dataIndex, origData) {
-
- if (_this.selections.length === 0) {
- return true;
- }
- if (settings.nTable !== tableNode) {
- return true;
- }
- var filter = null;
- if (_this.colExists) {
-
- filter = searchData[_this.s.index];
- if (colOpts.orthogonal.filter !== 'filter') {
-
- filter = _this.s.rowData.filterMap.get(dataIndex);
- if (filter instanceof $.fn.dataTable.Api) {
-
- filter = filter.toArray();
- }
- }
- }
- return _this._search(filter, dataIndex);
- };
- $.fn.dataTable.ext.search.push(this.s.searchFunction);
-
- if (this.c.clear) {
- clear.on('click', function () {
- var searches = _this.dom.container.find('.' + _this.classes.search.replace(/\s+/g, '.'));
- searches.each(function () {
- $(this).val('');
- $(this).trigger('input');
- });
- _this.clearPane();
- });
- }
-
-
-
- table.on('draw.dtsp', function () {
- _this.adjustTopRow();
- });
- table.on('buttons-action', function () {
- _this.adjustTopRow();
- });
-
-
- table.on('column-reorder.dtsp', function (e, settings, details) {
- _this.s.index = details.mapping[_this.s.index];
- });
- return this;
- }
-
- SearchPane.prototype.addRow = function (display, filter, shown, total, sort, type, className) {
- var index;
- for (var _i = 0, _a = this.s.indexes; _i < _a.length; _i++) {
- var entry = _a[_i];
- if (entry.filter === filter) {
- index = entry.index;
- }
- }
- if (index === undefined) {
- index = this.s.indexes.length;
- this.s.indexes.push({ filter: filter, index: index });
- }
- return this.s.dtPane.row.add({
- className: className,
- display: display !== '' ?
- display :
- this.emptyMessage(),
- filter: filter,
- index: index,
- shown: shown,
- sort: sort,
- total: total,
- type: type
- });
- };
-
- SearchPane.prototype.adjustTopRow = function () {
- var subContainers = this.dom.container.find('.' + this.classes.subRowsContainer.replace(/\s+/g, '.'));
- var subRow1 = this.dom.container.find('.' + this.classes.subRow1.replace(/\s+/g, '.'));
- var subRow2 = this.dom.container.find('.' + this.classes.subRow2.replace(/\s+/g, '.'));
- var topRow = this.dom.container.find('.' + this.classes.topRow.replace(/\s+/g, '.'));
-
-
- if (($(subContainers[0]).width() < 252 || $(topRow[0]).width() < 252) && $(subContainers[0]).width() !== 0) {
- $(subContainers[0]).addClass(this.classes.narrow);
- $(subRow1[0]).addClass(this.classes.narrowSub).removeClass(this.classes.narrowSearch);
- $(subRow2[0]).addClass(this.classes.narrowSub).removeClass(this.classes.narrowButton);
- }
- else {
- $(subContainers[0]).removeClass(this.classes.narrow);
- $(subRow1[0]).removeClass(this.classes.narrowSub).addClass(this.classes.narrowSearch);
- $(subRow2[0]).removeClass(this.classes.narrowSub).addClass(this.classes.narrowButton);
- }
- };
-
- SearchPane.prototype.clearData = function () {
- this.s.rowData = {
- arrayFilter: [],
- arrayOriginal: [],
- arrayTotals: [],
- bins: {},
- binsOriginal: {},
- binsTotal: {},
- filterMap: new Map(),
- totalOptions: 0
- };
- };
-
- SearchPane.prototype.clearPane = function () {
-
- this.s.dtPane.rows({ selected: true }).deselect();
- this.updateTable();
- return this;
- };
-
- SearchPane.prototype.collapse = function () {
- var _this = this;
- if (!this.s.displayed ||
- (!this.c.collapse && this.s.colOpts.collapse !== true ||
- this.s.colOpts.collapse === false)) {
- return;
- }
- this.dom.collapseButton.addClass(this.classes.rotated);
- $(this.s.dtPane.table().container()).addClass(this.classes.hidden);
- this.dom.topRow.addClass(this.classes.bordered);
- this.dom.countButton.addClass(this.classes.disabledButton);
- this.dom.nameButton.addClass(this.classes.disabledButton);
- this.dom.searchButton.addClass(this.classes.disabledButton);
- this.dom.topRow.one('click', function () {
- _this.show();
- });
- };
-
- SearchPane.prototype.destroy = function () {
- if (this.s.dtPane !== undefined) {
- this.s.dtPane.off('.dtsp');
- }
- this.dom.nameButton.off('.dtsp');
- this.dom.collapseButton.off('.dtsp');
- this.dom.countButton.off('.dtsp');
- this.dom.clear.off('.dtsp');
- this.dom.searchButton.off('.dtsp');
- this.dom.container.remove();
- var searchIdx = $.fn.dataTable.ext.search.indexOf(this.s.searchFunction);
- while (searchIdx !== -1) {
- $.fn.dataTable.ext.search.splice(searchIdx, 1);
- searchIdx = $.fn.dataTable.ext.search.indexOf(this.s.searchFunction);
- }
-
- if (this.s.dtPane !== undefined) {
- this.s.dtPane.destroy();
- }
- this.s.listSet = false;
- };
-
- SearchPane.prototype.emptyMessage = function () {
- var def = this.c.i18n.emptyMessage;
-
- if (this.c.emptyMessage) {
- def = this.c.emptyMessage;
- }
-
- if (this.s.colOpts.emptyMessage !== false && this.s.colOpts.emptyMessage !== null) {
- def = this.s.colOpts.emptyMessage;
- }
- return this.s.dt.i18n('searchPanes.emptyMessage', def);
- };
-
- SearchPane.prototype.getPaneCount = function () {
- return this.s.dtPane !== undefined ?
- this.s.dtPane.rows({ selected: true }).data().toArray().length :
- 0;
- };
-
- SearchPane.prototype.rebuildPane = function (last, dataIn, init, maintainSelection) {
- if (last === void 0) { last = false; }
- if (dataIn === void 0) { dataIn = null; }
- if (init === void 0) { init = null; }
- if (maintainSelection === void 0) { maintainSelection = false; }
- this.clearData();
- var selectedRows = [];
- this.s.serverSelect = [];
- var prevEl = null;
-
- if (this.s.dtPane !== undefined) {
- if (maintainSelection) {
- if (!this.s.dt.page.info().serverSide) {
- selectedRows = this.s.dtPane.rows({ selected: true }).data().toArray();
- }
- else {
- this.s.serverSelect = this.s.dtPane.rows({ selected: true }).data().toArray();
- }
- }
- this.s.dtPane.clear().destroy();
- prevEl = this.dom.container.prev();
- this.destroy();
- this.s.dtPane = undefined;
- $.fn.dataTable.ext.search.push(this.s.searchFunction);
- }
- this.dom.container.removeClass(this.classes.hidden);
- this.s.displayed = false;
- this._buildPane(!this.s.dt.page.info().serverSide ?
- selectedRows :
- this.s.serverSelect, last, dataIn, init, prevEl);
- return this;
- };
-
- SearchPane.prototype.removePane = function () {
- this.s.displayed = false;
- this.dom.container.hide();
- };
-
- SearchPane.prototype.resize = function (layout) {
- this.c.layout = layout;
- var layVal = parseInt(layout.split('-')[1], 10);
- this.dom.container
- .removeClass()
- .addClass(this.classes.container)
- .addClass(this.classes.layout +
- (layVal < 10 ? layout : layout.split('-')[0] + '-9'))
- .addClass(this.s.colOpts.className)
- .addClass(this.customPaneSettings !== null && this.customPaneSettings.className !== undefined
- ? this.customPaneSettings.className
- : '')
- .addClass(this.classes.show);
- this.adjustTopRow();
- };
-
- SearchPane.prototype.setCascadeRegen = function (val) {
- this.s.cascadeRegen = val;
- };
-
- SearchPane.prototype.setClear = function (val) {
- this.s.clearing = val;
- };
-
- SearchPane.prototype.show = function () {
- if (!this.s.displayed) {
- return;
- }
- this.dom.collapseButton.removeClass(this.classes.rotated);
- $(this.s.dtPane.table().container()).removeClass(this.classes.hidden);
- this.dom.topRow.removeClass(this.classes.bordered);
- this.dom.countButton.removeClass(this.classes.disabledButton);
- this.dom.nameButton.removeClass(this.classes.disabledButton);
- this.dom.searchButton.removeClass(this.classes.disabledButton);
- };
-
- SearchPane.prototype.updatePane = function (draw) {
- if (draw === void 0) { draw = false; }
- this.s.updating = true;
- this._updateCommon(draw);
- this.s.updating = false;
- };
-
- SearchPane.prototype.updateTable = function () {
- var selectedRows = this.s.dtPane.rows({ selected: true }).data().toArray();
- this.selections = selectedRows;
- this._searchExtras();
-
- if (this.c.cascadePanes || this.c.viewTotal) {
- this.updatePane();
- }
- };
-
- SearchPane.prototype._setListeners = function () {
- var _this = this;
- var rowData = this.s.rowData;
- var t0;
-
-
- this.s.dtPane.off('select.dtsp');
- this.s.dtPane.on('select.dtsp', function () {
- clearTimeout(t0);
- if (_this.s.dt.page.info().serverSide && !_this.s.updating) {
- if (!_this.s.serverSelecting) {
- _this.s.serverSelect = _this.s.dtPane.rows({ selected: true }).data().toArray();
- _this.s.scrollTop = $(_this.s.dtPane.table().node()).parent()[0].scrollTop;
- _this.s.selectPresent = true;
- _this.s.dt.draw(false);
- }
- }
- else if (!_this.s.updating) {
- _this.s.selectPresent = true;
- _this._makeSelection();
- _this.s.selectPresent = false;
- }
- _this.dom.clear.removeClass(_this.classes.disabledButton).removeAttr('disabled');
- });
-
-
- this.s.dtPane.off('deselect.dtsp');
- this.s.dtPane.on('deselect.dtsp', function () {
- t0 = setTimeout(function () {
- _this.s.scrollTop = $(_this.s.dtPane.table().node()).parent()[0].scrollTop;
- if (_this.s.dt.page.info().serverSide && !_this.s.updating) {
- if (!_this.s.serverSelecting) {
- _this.s.serverSelect = _this.s.dtPane.rows({ selected: true }).data().toArray();
- _this.s.deselect = true;
- _this.s.dt.draw(false);
- }
- }
- else {
- _this.s.deselect = true;
- _this._makeSelection();
- _this.s.deselect = false;
- }
- if (_this.s.dtPane.rows({ selected: true }).data().toArray().length === 0) {
- _this.dom.clear.addClass(_this.classes.disabledButton).attr('disabled', 'true');
- }
- }, 50);
- });
-
-
- if (this.s.firstSet) {
- this.s.firstSet = false;
-
- this.s.dt.on('stateSaveParams.dtsp', function (e, settings, data) {
-
-
- if ($.isEmptyObject(data)) {
- _this.s.dtPane.state.clear();
- return;
- }
- var selected = [];
- var searchTerm;
- var order;
- var bins;
- var arrayFilter;
- var collapsed;
-
- if (_this.s.dtPane !== undefined) {
- selected = _this.s.dtPane
- .rows({ selected: true })
- .data()
- .map(function (item) { return item.filter.toString(); })
- .toArray();
- searchTerm = _this.dom.searchBox.val();
- order = _this.s.dtPane.order();
- bins = rowData.binsOriginal;
- arrayFilter = rowData.arrayOriginal;
- collapsed = _this.dom.collapseButton.hasClass(_this.classes.rotated);
- }
- if (data.searchPanes === undefined) {
- data.searchPanes = {};
- }
- if (data.searchPanes.panes === undefined) {
- data.searchPanes.panes = [];
- }
- for (var i = 0; i < data.searchPanes.panes.length; i++) {
- if (data.searchPanes.panes[i].id === _this.s.index) {
- data.searchPanes.panes.splice(i, 1);
- i--;
- }
- }
-
- data.searchPanes.panes.push({
- arrayFilter: arrayFilter,
- bins: bins,
- collapsed: collapsed,
- id: _this.s.index,
- order: order,
- searchTerm: searchTerm,
- selected: selected
- });
- });
- }
- this.s.dtPane.off('user-select.dtsp');
- this.s.dtPane.on('user-select.dtsp', function (e, _dt, type, cell, originalEvent) {
- originalEvent.stopPropagation();
- });
- this.s.dtPane.off('draw.dtsp');
- this.s.dtPane.on('draw.dtsp', function () {
- _this.adjustTopRow();
- });
-
-
- this.dom.nameButton.off('click.dtsp');
- this.dom.nameButton.on('click.dtsp', function () {
- var currentOrder = _this.s.dtPane.order()[0][1];
- _this.s.dtPane.order([0, currentOrder === 'asc' ? 'desc' : 'asc']).draw();
-
- _this.s.dt.state.save();
- });
-
-
- this.dom.countButton.off('click.dtsp');
- this.dom.countButton.on('click.dtsp', function () {
- var currentOrder = _this.s.dtPane.order()[0][1];
- _this.s.dtPane.order([1, currentOrder === 'asc' ? 'desc' : 'asc']).draw();
-
- _this.s.dt.state.save();
- });
-
-
- this.dom.collapseButton.off('click.dtsp');
- this.dom.collapseButton.on('click.dtsp', function (e) {
- e.stopPropagation();
- var container = $(_this.s.dtPane.table().container());
-
- _this.dom.collapseButton.toggleClass(_this.classes.rotated);
- container.toggleClass(_this.classes.hidden);
- _this.dom.topRow.toggleClass(_this.classes.bordered);
- _this.dom.countButton.toggleClass(_this.classes.disabledButton);
- _this.dom.nameButton.toggleClass(_this.classes.disabledButton);
- _this.dom.searchButton.toggleClass(_this.classes.disabledButton);
- if (container.hasClass(_this.classes.hidden)) {
- _this.dom.topRow.on('click', function () { return _this.dom.collapseButton.click(); });
- }
- else {
- _this.dom.topRow.off('click');
- }
- _this.s.dt.state.save();
- return;
- });
-
- this.dom.clear.off('click.dtsp');
- this.dom.clear.on('click.dtsp', function () {
- var searches = _this.dom.container.find('.' + _this.classes.search.replace(/ /g, '.'));
- searches.each(function () {
-
- $(this).val('');
- $(this).trigger('input');
- });
- _this.clearPane();
- });
-
- this.dom.searchButton.off('click.dtsp');
- this.dom.searchButton.on('click.dtsp', function () {
- _this.dom.searchBox.focus();
- });
-
-
- this.dom.searchBox.off('click.dtsp');
- this.dom.searchBox.on('input.dtsp', function () {
- var searchval = _this.dom.searchBox.val();
- _this.s.dtPane.search(searchval).draw();
- if (typeof searchval === 'string' &&
- (searchval.length > 0 ||
- searchval.length === 0 && _this.s.dtPane.rows({ selected: true }).data().toArray().length > 0)) {
- _this.dom.clear.removeClass(_this.classes.disabledButton).removeAttr('disabled');
- }
- else {
- _this.dom.clear.addClass(_this.classes.disabledButton).attr('disabled', 'true');
- }
-
- _this.s.dt.state.save();
- });
- return true;
- };
-
- SearchPane.prototype._addOption = function (filter, display, sort, type, arrayFilter, bins) {
-
- if (Array.isArray(filter) || filter instanceof dataTable.Api) {
-
- if (filter instanceof dataTable.Api) {
- filter = filter.toArray();
- display = display.toArray();
- }
- if (filter.length === display.length) {
- for (var i = 0; i < filter.length; i++) {
-
- if (!bins[filter[i]]) {
- bins[filter[i]] = 1;
- arrayFilter.push({
- display: display[i],
- filter: filter[i],
- sort: sort[i],
- type: type[i]
- });
- }
-
- else {
- bins[filter[i]]++;
- }
- this.s.rowData.totalOptions++;
- }
- return;
- }
- else {
- throw new Error('display and filter not the same length');
- }
- }
-
- else if (typeof this.s.colOpts.orthogonal === 'string') {
- if (!bins[filter]) {
- bins[filter] = 1;
- arrayFilter.push({
- display: display,
- filter: filter,
- sort: sort,
- type: type
- });
- this.s.rowData.totalOptions++;
- }
- else {
- bins[filter]++;
- this.s.rowData.totalOptions++;
- return;
- }
- }
-
- else {
- arrayFilter.push({
- display: display,
- filter: filter,
- sort: sort,
- type: type
- });
- }
- };
-
- SearchPane.prototype._buildPane = function (selectedRows, last, dataIn, init, prevEl) {
- var _this = this;
- if (selectedRows === void 0) { selectedRows = []; }
- if (last === void 0) { last = false; }
- if (dataIn === void 0) { dataIn = null; }
- if (init === void 0) { init = null; }
- if (prevEl === void 0) { prevEl = null; }
-
- this.selections = [];
- var table = this.s.dt;
- var column = table.column(this.colExists ? this.s.index : 0);
- var colOpts = this.s.colOpts;
- var rowData = this.s.rowData;
-
- var countMessage = table.i18n('searchPanes.count', this.c.i18n.count);
- var filteredMessage = table.i18n('searchPanes.countFiltered', this.c.i18n.countFiltered);
- var loadedFilter = table.state.loaded();
-
- if (this.s.listSet) {
- loadedFilter = table.state();
- }
-
- if (this.colExists) {
- var idx = -1;
- if (loadedFilter && loadedFilter.searchPanes && loadedFilter.searchPanes.panes) {
- for (var i = 0; i < loadedFilter.searchPanes.panes.length; i++) {
- if (loadedFilter.searchPanes.panes[i].id === this.s.index) {
- idx = i;
- break;
- }
- }
- }
-
- if ((colOpts.show === false ||
- colOpts.show !== undefined && colOpts.show !== true) &&
- idx === -1) {
- this.dom.container.addClass(this.classes.hidden);
- this.s.displayed = false;
- return false;
- }
- else if (colOpts.show === true || idx !== -1) {
- this.s.displayed = true;
- }
- if (!this.s.dt.page.info().serverSide &&
- (dataIn === null ||
- dataIn.searchPanes === null ||
- dataIn.searchPanes.options === null)) {
-
- if (rowData.arrayFilter.length === 0) {
- this._populatePane(last);
- this.s.rowData.totalOptions = 0;
- this._detailsPane();
- rowData.arrayOriginal = rowData.arrayTotals;
- rowData.binsOriginal = rowData.binsTotal;
- }
- var binLength = Object.keys(rowData.binsOriginal).length;
- var uniqueRatio = this._uniqueRatio(binLength, table.rows()[0].length);
-
-
- if (this.s.displayed === false &&
- ((colOpts.show === undefined && colOpts.threshold === null ?
- uniqueRatio > this.c.threshold :
- uniqueRatio > colOpts.threshold) ||
- colOpts.show !== true && binLength <= 1)) {
- this.dom.container.addClass(this.classes.hidden);
- this.s.displayed = false;
- return;
- }
-
-
- if (this.c.viewTotal && rowData.arrayTotals.length === 0) {
- this.s.rowData.totalOptions = 0;
- this._detailsPane();
- }
- else {
- rowData.binsTotal = rowData.bins;
- }
- this.dom.container.addClass(this.classes.show);
- this.s.displayed = true;
- }
- else if (dataIn !== null && dataIn.searchPanes !== null && dataIn.searchPanes.options !== null) {
- if (dataIn.tableLength !== undefined) {
- this.s.tableLength = dataIn.tableLength;
- this.s.rowData.totalOptions = this.s.tableLength;
- }
- else if (this.s.tableLength === null || table.rows()[0].length > this.s.tableLength) {
- this.s.tableLength = table.rows()[0].length;
- this.s.rowData.totalOptions = this.s.tableLength;
- }
- var colTitle = table.column(this.s.index).dataSrc();
- if (dataIn.searchPanes.options[colTitle] !== undefined) {
- for (var _i = 0, _a = dataIn.searchPanes.options[colTitle]; _i < _a.length; _i++) {
- var dataPoint = _a[_i];
- this.s.rowData.arrayFilter.push({
- display: dataPoint.label,
- filter: dataPoint.value,
- sort: dataPoint.label,
- type: dataPoint.label
- });
- this.s.rowData.bins[dataPoint.value] = this.c.viewTotal || this.c.cascadePanes ?
- dataPoint.count :
- dataPoint.total;
- this.s.rowData.binsTotal[dataPoint.value] = dataPoint.total;
- }
- }
- var binLength = Object.keys(rowData.binsTotal).length;
- var uniqueRatio = this._uniqueRatio(binLength, this.s.tableLength);
-
- if (this.s.displayed === false &&
- ((colOpts.show === undefined && colOpts.threshold === null ?
- uniqueRatio > this.c.threshold :
- uniqueRatio > colOpts.threshold) ||
- colOpts.show !== true && binLength <= 1)) {
- this.dom.container.addClass(this.classes.hidden);
- this.s.displayed = false;
- return;
- }
- this.s.rowData.arrayOriginal = this.s.rowData.arrayFilter;
- this.s.rowData.binsOriginal = this.s.rowData.bins;
- this.s.displayed = true;
- }
- }
- else {
- this.s.displayed = true;
- }
-
- this._displayPane();
- if (!this.s.listSet) {
-
-
- this.dom.dtP.on('stateLoadParams.dt', function (e, settings, data) {
- if ($.isEmptyObject(table.state.loaded())) {
- $.each(data, function (index, value) {
- delete data[index];
- });
- }
- });
- }
-
- if (prevEl !== null && this.dom.panesContainer.has(prevEl).length > 0) {
- this.dom.container.insertAfter(prevEl);
- }
- else {
- this.dom.panesContainer.prepend(this.dom.container);
- }
-
- var errMode = $.fn.dataTable.ext.errMode;
- $.fn.dataTable.ext.errMode = 'none';
-
- var haveScroller = dataTable.Scroller;
- this.s.dtPane = this.dom.dtP.DataTable($.extend(true, {
- columnDefs: [
- {
- className: 'dtsp-nameColumn',
- data: 'display',
- render: function (data, type, row) {
- if (type === 'sort') {
- return row.sort;
- }
- else if (type === 'type') {
- return row.type;
- }
- var message;
- message =
- (_this.s.filteringActive || _this.s.showFiltered) && _this.c.viewTotal ||
- _this.c.viewTotal && _this.s.forceViewTotal ?
- filteredMessage.replace(/{total}/, row.total) :
- countMessage.replace(/{total}/, row.total);
- message = message.replace(/{shown}/, row.shown);
- while (message.includes('{total}')) {
- message = message.replace(/{total}/, row.total);
- }
- while (message.includes('{shown}')) {
- message = message.replace(/{shown}/, row.shown);
- }
-
-
-
- var pill = '<span class="' + _this.classes.pill + '">' + message + '</span>';
- if (!_this.c.viewCount || !colOpts.viewCount) {
- pill = '';
- }
- if (type === 'filter') {
- return typeof data === 'string' && data.match(/<[^>]*>/) !== null ?
- data.replace(/<[^>]*>/g, '') :
- data;
- }
- return '<div class="' + _this.classes.nameCont + '"><span title="' +
- (typeof data === 'string' && data.match(/<[^>]*>/) !== null ?
- data.replace(/<[^>]*>/g, '') :
- data) +
- '" class="' + _this.classes.name + '">' +
- data + '</span>' +
- pill + '</div>';
- },
- targets: 0,
-
-
-
- type: table.settings()[0].aoColumns[this.s.index] !== undefined ?
- table.settings()[0].aoColumns[this.s.index]._sManualType :
- null
- },
- {
- className: 'dtsp-countColumn ' + this.classes.badgePill,
- data: 'shown',
- orderData: [1, 2],
- searchable: false,
- targets: 1,
- visible: false
- },
- {
- data: 'total',
- searchable: false,
- targets: 2,
- visible: false
- }
- ],
- deferRender: true,
- dom: 't',
- info: false,
- language: this.s.dt.settings()[0].oLanguage,
- paging: haveScroller ? true : false,
- scrollX: false,
- scrollY: '200px',
- scroller: haveScroller ? true : false,
- select: true,
- stateSave: table.settings()[0].oFeatures.bStateSave ? true : false
- }, this.c.dtOpts, colOpts !== undefined ? colOpts.dtOpts : {}, this.s.colOpts.options !== undefined || !this.colExists ?
- {
- createdRow: function (row, data, dataIndex) {
- $(row).addClass(data.className);
- }
- } :
- undefined, this.customPaneSettings !== null && this.customPaneSettings.dtOpts !== undefined ?
- this.customPaneSettings.dtOpts :
- {}, $.fn.dataTable.versionCheck('2')
- ? {
- layout: {
- bottomLeft: null,
- bottomRight: null,
- topLeft: null,
- topRight: null
- }
- }
- : {}));
- this.dom.dtP.addClass(this.classes.table);
-
- var headerText = 'Custom Pane';
- if (this.customPaneSettings && this.customPaneSettings.header) {
- headerText = this.customPaneSettings.header;
- }
- else if (colOpts.header) {
- headerText = colOpts.header;
- }
- else if (this.colExists) {
- headerText = $.fn.dataTable.versionCheck('2')
- ? table.column(this.s.index).title()
- : table.settings()[0].aoColumns[this.s.index].sTitle;
- }
- this.dom.searchBox.attr('placeholder', headerText);
-
-
- $.fn.dataTable.select.init(this.s.dtPane);
- $.fn.dataTable.ext.errMode = errMode;
-
- if (this.colExists) {
-
-
- var search = column.search();
- search = search ? search.substr(1, search.length - 2).split('|') : [];
-
- var count_1 = 0;
- rowData.arrayFilter.forEach(function (element) {
- if (element.filter === '') {
- count_1++;
- }
- });
-
- for (var i = 0, ien = rowData.arrayFilter.length; i < ien; i++) {
- var selected = false;
- for (var _b = 0, _c = this.s.serverSelect; _b < _c.length; _b++) {
- var option = _c[_b];
- if (option.filter === rowData.arrayFilter[i].filter) {
- selected = true;
- }
- }
- if (this.s.dt.page.info().serverSide &&
- (!this.c.cascadePanes ||
- this.c.cascadePanes && rowData.bins[rowData.arrayFilter[i].filter] !== 0 ||
- this.c.cascadePanes && init !== null ||
- selected)) {
- var row = this.addRow(rowData.arrayFilter[i].display, rowData.arrayFilter[i].filter, init ?
- rowData.binsTotal[rowData.arrayFilter[i].filter] :
- rowData.bins[rowData.arrayFilter[i].filter], this.c.viewTotal || init
- ? String(rowData.binsTotal[rowData.arrayFilter[i].filter])
- : rowData.bins[rowData.arrayFilter[i].filter], rowData.arrayFilter[i].sort, rowData.arrayFilter[i].type);
- for (var _d = 0, _e = this.s.serverSelect; _d < _e.length; _d++) {
- var option = _e[_d];
- if (option.filter === rowData.arrayFilter[i].filter) {
- this.s.serverSelecting = true;
- row.select();
- this.s.serverSelecting = false;
- }
- }
- }
- else if (!this.s.dt.page.info().serverSide &&
- rowData.arrayFilter[i] &&
- (rowData.bins[rowData.arrayFilter[i].filter] !== undefined || !this.c.cascadePanes)) {
- this.addRow(rowData.arrayFilter[i].display, rowData.arrayFilter[i].filter, rowData.bins[rowData.arrayFilter[i].filter], rowData.binsTotal[rowData.arrayFilter[i].filter], rowData.arrayFilter[i].sort, rowData.arrayFilter[i].type);
- }
- else if (!this.s.dt.page.info().serverSide) {
-
- this.addRow('', count_1, count_1, '', '', '');
- }
- }
- }
-
- dataTable.select.init(this.s.dtPane);
-
- if (colOpts.options !== undefined ||
- this.customPaneSettings !== null && this.customPaneSettings.options !== undefined) {
- this._getComparisonRows();
- }
-
- this.s.dtPane.draw();
- this.s.dtPane.table().node().parentNode.scrollTop = this.s.scrollTop;
- this.adjustTopRow();
- if (!this.s.listSet) {
- this._setListeners();
- this.s.listSet = true;
- }
- for (var _f = 0, selectedRows_1 = selectedRows; _f < selectedRows_1.length; _f++) {
- var selection = selectedRows_1[_f];
- if (selection !== undefined) {
- for (var _g = 0, _h = this.s.dtPane.rows().indexes().toArray(); _g < _h.length; _g++) {
- var row = _h[_g];
- if (this.s.dtPane.row(row).data() !== undefined &&
- selection.filter === this.s.dtPane.row(row).data().filter) {
-
-
- if (this.s.dt.page.info().serverSide) {
- this.s.serverSelecting = true;
- this.s.dtPane.row(row).select();
- this.s.serverSelecting = false;
- }
- else {
- this.s.dtPane.row(row).select();
- }
- }
- }
- }
- }
-
- if (this.s.dt.page.info().serverSide) {
- this.s.dtPane.search(this.dom.searchBox.val()).draw();
- }
- if ((this.c.initCollapsed && this.s.colOpts.initCollapsed !== false ||
- this.s.colOpts.initCollapsed) &&
- (this.c.collapse && this.s.colOpts.collapse !== false ||
- this.s.colOpts.collapse)) {
- this.collapse();
- }
-
-
- if (loadedFilter &&
- loadedFilter.searchPanes &&
- loadedFilter.searchPanes.panes &&
- (dataIn === null ||
- dataIn.draw === 1)) {
- if (!this.c.cascadePanes) {
- this._reloadSelect(loadedFilter);
- }
- for (var _j = 0, _k = loadedFilter.searchPanes.panes; _j < _k.length; _j++) {
- var pane = _k[_j];
- if (pane.id === this.s.index) {
-
- if (pane.searchTerm && pane.searchTerm.length > 0) {
- this.dom.searchBox.val(pane.searchTerm);
- this.dom.searchBox.trigger('input');
- }
- this.s.dtPane.order(pane.order).draw();
-
- if (pane.collapsed) {
- this.collapse();
- }
- else {
- this.show();
- }
- }
- }
- }
- return true;
- };
-
- SearchPane.prototype._detailsPane = function () {
- var table = this.s.dt;
- this.s.rowData.arrayTotals = [];
- this.s.rowData.binsTotal = {};
- var settings = this.s.dt.settings()[0];
- var indexArray = table.rows().indexes();
- if (!this.s.dt.page.info().serverSide) {
- for (var _i = 0, indexArray_1 = indexArray; _i < indexArray_1.length; _i++) {
- var rowIdx = indexArray_1[_i];
- this._populatePaneArray(rowIdx, this.s.rowData.arrayTotals, settings, this.s.rowData.binsTotal);
- }
- }
- };
-
- SearchPane.prototype._displayPane = function () {
- var container = this.dom.container;
- var colOpts = this.s.colOpts;
- var layVal = parseInt(this.c.layout.split('-')[1], 10);
-
- this.dom.topRow.empty();
- this.dom.dtP.empty();
- this.dom.topRow.addClass(this.classes.topRow);
-
- if (layVal > 3) {
- this.dom.container.addClass(this.classes.smallGap);
- }
- this.dom.topRow.addClass(this.classes.subRowsContainer);
- this.dom.upper.appendTo(this.dom.topRow);
- this.dom.lower.appendTo(this.dom.topRow);
- this.dom.searchCont.appendTo(this.dom.upper);
- this.dom.buttonGroup.appendTo(this.dom.lower);
-
- if (this.c.dtOpts.searching === false ||
- colOpts.dtOpts !== undefined && colOpts.dtOpts.searching === false ||
- (!this.c.controls || !colOpts.controls) ||
- this.customPaneSettings !== null &&
- this.customPaneSettings.dtOpts !== undefined &&
- this.customPaneSettings.dtOpts.searching !== undefined &&
- !this.customPaneSettings.dtOpts.searching) {
- this.dom.searchBox
- .removeClass(this.classes.paneInputButton)
- .addClass(this.classes.disabledButton)
- .attr('disabled', 'true');
- }
- this.dom.searchBox.appendTo(this.dom.searchCont);
-
- this._searchContSetup();
-
- if (this.c.clear && this.c.controls && colOpts.controls) {
- this.dom.clear.appendTo(this.dom.buttonGroup);
- }
- if (this.c.orderable && colOpts.orderable && this.c.controls && colOpts.controls) {
- this.dom.nameButton.appendTo(this.dom.buttonGroup);
- }
-
- if (this.c.viewCount &&
- colOpts.viewCount &&
- this.c.orderable &&
- colOpts.orderable &&
- this.c.controls &&
- colOpts.controls) {
- this.dom.countButton.appendTo(this.dom.buttonGroup);
- }
- if ((this.c.collapse && this.s.colOpts.collapse !== false ||
- this.s.colOpts.collapse) &&
- this.c.controls && colOpts.controls) {
- this.dom.collapseButton.appendTo(this.dom.buttonGroup);
- }
- this.dom.topRow.prependTo(this.dom.container);
- container.append(this.dom.dtP);
- container.show();
- };
-
- SearchPane.prototype._getBonusOptions = function () {
-
- var defaultMutator = {
- orthogonal: {
- threshold: null
- },
- threshold: null
- };
- return $.extend(true, {}, SearchPane.defaults, defaultMutator, this.c !== undefined ? this.c : {});
- };
-
- SearchPane.prototype._getComparisonRows = function () {
- var colOpts = this.s.colOpts;
-
- var options = colOpts.options !== undefined
- ? colOpts.options
- : this.customPaneSettings !== null && this.customPaneSettings.options !== undefined
- ? this.customPaneSettings.options
- : undefined;
- if (options === undefined) {
- return;
- }
- var tableVals = this.s.dt.rows({ search: 'applied' }).data().toArray();
- var appRows = this.s.dt.rows({ search: 'applied' });
- var tableValsTotal = this.s.dt.rows().data().toArray();
- var allRows = this.s.dt.rows();
- var rows = [];
-
- this.s.dtPane.clear();
- for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
- var comp = options_1[_i];
-
- var insert = comp.label !== '' ?
- comp.label :
- this.emptyMessage();
- var comparisonObj = {
- className: comp.className,
- display: insert,
- filter: typeof comp.value === 'function' ? comp.value : [],
- shown: 0,
- sort: insert,
- total: 0,
- type: insert
- };
-
- if (typeof comp.value === 'function') {
-
- for (var tVal = 0; tVal < tableVals.length; tVal++) {
- if (comp.value.call(this.s.dt, tableVals[tVal], appRows[0][tVal])) {
- comparisonObj.shown++;
- }
- }
-
- for (var i = 0; i < tableValsTotal.length; i++) {
- if (comp.value.call(this.s.dt, tableValsTotal[i], allRows[0][i])) {
- comparisonObj.total++;
- }
- }
-
- if (typeof comparisonObj.filter !== 'function') {
- comparisonObj.filter.push(comp.filter);
- }
- }
-
- if (!this.c.cascadePanes || this.c.cascadePanes && comparisonObj.shown !== 0) {
- rows.push(this.addRow(comparisonObj.display, comparisonObj.filter, comparisonObj.shown, comparisonObj.total, comparisonObj.sort, comparisonObj.type, comparisonObj.className));
- }
- }
- return rows;
- };
-
- SearchPane.prototype._getOptions = function () {
- var table = this.s.dt;
-
- var defaultMutator = {
- collapse: null,
- emptyMessage: false,
- initCollapsed: null,
- orthogonal: {
- threshold: null
- },
- threshold: null
- };
- var columnOptions = table.settings()[0].aoColumns[this.s.index].searchPanes;
- var colOpts = $.extend(true, {}, SearchPane.defaults, defaultMutator, columnOptions);
- if (columnOptions !== undefined &&
- columnOptions.hideCount !== undefined &&
- columnOptions.viewCount === undefined) {
- colOpts.viewCount = !columnOptions.hideCount;
- }
- return colOpts;
- };
-
- SearchPane.prototype._makeSelection = function () {
- this.updateTable();
- this.s.updating = true;
- this.s.dt.draw();
- this.s.updating = false;
- };
-
- SearchPane.prototype._populatePane = function (last) {
- if (last === void 0) { last = false; }
- var table = this.s.dt;
- this.s.rowData.arrayFilter = [];
- this.s.rowData.bins = {};
- var settings = this.s.dt.settings()[0];
-
-
-
- if (!this.s.dt.page.info().serverSide) {
- var indexArray = (this.c.cascadePanes || this.c.viewTotal) && (!this.s.clearing && !last) ?
- table.rows({ search: 'applied' }).indexes() :
- table.rows().indexes();
- for (var _i = 0, _a = indexArray.toArray(); _i < _a.length; _i++) {
- var index = _a[_i];
- this._populatePaneArray(index, this.s.rowData.arrayFilter, settings);
- }
- }
- };
-
- SearchPane.prototype._populatePaneArray = function (rowIdx, arrayFilter, settings, bins) {
- if (bins === void 0) { bins = this.s.rowData.bins; }
- var colOpts = this.s.colOpts;
-
-
- if (typeof colOpts.orthogonal === 'string') {
- var rendered = settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal);
- this.s.rowData.filterMap.set(rowIdx, rendered);
- this._addOption(rendered, rendered, rendered, rendered, arrayFilter, bins);
- }
- else {
- var filter = settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal.search);
-
- if (filter === null) {
- filter = '';
- }
- if (typeof filter === 'string') {
- filter = filter.replace(/<[^>]*>/g, '');
- }
- this.s.rowData.filterMap.set(rowIdx, filter);
- if (!bins[filter]) {
- bins[filter] = 1;
- this._addOption(filter, settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal.display), settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal.sort), settings.oApi._fnGetCellData(settings, rowIdx, this.s.index, colOpts.orthogonal.type), arrayFilter, bins);
- this.s.rowData.totalOptions++;
- }
- else {
- bins[filter]++;
- this.s.rowData.totalOptions++;
- return;
- }
- }
- };
-
- SearchPane.prototype._reloadSelect = function (loadedFilter) {
-
- if (loadedFilter === undefined) {
- return;
- }
- var idx;
-
-
- for (var i = 0; i < loadedFilter.searchPanes.panes.length; i++) {
- if (loadedFilter.searchPanes.panes[i].id === this.s.index) {
- idx = i;
- break;
- }
- }
- if (idx !== undefined) {
- var table = this.s.dtPane;
- var rows = table.rows({ order: 'index' }).data().map(function (item) { return item.filter !== null ?
- item.filter.toString() :
- null; }).toArray();
- for (var _i = 0, _a = loadedFilter.searchPanes.panes[idx].selected; _i < _a.length; _i++) {
- var filter = _a[_i];
- var id = -1;
- if (filter !== null) {
- id = rows.indexOf(filter.toString());
- }
- if (id > -1) {
- this.s.serverSelecting = true;
- table.row(id).select();
- this.s.serverSelecting = false;
- }
- }
- }
- };
-
- SearchPane.prototype._search = function (filter, dataIndex) {
- var colOpts = this.s.colOpts;
- var table = this.s.dt;
-
- for (var _i = 0, _a = this.selections; _i < _a.length; _i++) {
- var colSelect = _a[_i];
- if (typeof colSelect.filter === 'string' && typeof filter === 'string') {
-
-
- colSelect.filter = colSelect.filter
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/"/g, '"');
- }
-
- if (Array.isArray(filter)) {
- if (filter.includes(colSelect.filter)) {
- return true;
- }
- }
-
- else if (typeof colSelect.filter === 'function') {
- if (colSelect.filter.call(table, table.row(dataIndex).data(), dataIndex)) {
- if (colOpts.combiner === 'or') {
- return true;
- }
- }
-
-
- else if (colOpts.combiner === 'and') {
- return false;
- }
- }
-
- else if (filter === colSelect.filter ||
-
-
- !(typeof filter === 'string' && filter.length === 0) && filter == colSelect.filter ||
- colSelect.filter === null && typeof filter === 'string' && filter === '') {
- return true;
- }
- }
-
-
- if (colOpts.combiner === 'and') {
- return true;
- }
-
- else {
- return false;
- }
- };
-
- SearchPane.prototype._searchContSetup = function () {
- if (this.c.controls && this.s.colOpts.controls) {
- this.dom.searchButton.appendTo(this.dom.searchLabelCont);
- }
- if (!(this.c.dtOpts.searching === false ||
- this.s.colOpts.dtOpts.searching === false ||
- this.customPaneSettings !== null &&
- this.customPaneSettings.dtOpts !== undefined &&
- this.customPaneSettings.dtOpts.searching !== undefined &&
- !this.customPaneSettings.dtOpts.searching)) {
- this.dom.searchLabelCont.appendTo(this.dom.searchCont);
- }
- };
-
- SearchPane.prototype._searchExtras = function () {
- var updating = this.s.updating;
- this.s.updating = true;
- var filters = this.s.dtPane.rows({ selected: true }).data().pluck('filter').toArray();
- var nullIndex = filters.indexOf(this.emptyMessage());
- var container = $(this.s.dtPane.table().container());
-
- if (nullIndex > -1) {
- filters[nullIndex] = '';
- }
-
- if (filters.length > 0) {
- container.addClass(this.classes.selected);
- }
- else if (filters.length === 0) {
- container.removeClass(this.classes.selected);
- }
- this.s.updating = updating;
- };
-
- SearchPane.prototype._uniqueRatio = function (bins, rowCount) {
- if (rowCount > 0 &&
- (this.s.rowData.totalOptions > 0 && !this.s.dt.page.info().serverSide ||
- this.s.dt.page.info().serverSide && this.s.tableLength > 0)) {
- return bins / this.s.rowData.totalOptions;
- }
- else {
- return 1;
- }
- };
-
- SearchPane.prototype._updateCommon = function (draw) {
- if (draw === void 0) { draw = false; }
-
-
- if (!this.s.dt.page.info().serverSide &&
- this.s.dtPane !== undefined &&
- (!this.s.filteringActive || this.c.cascadePanes || draw === true) &&
- (this.c.cascadePanes !== true || this.s.selectPresent !== true) &&
- (!this.s.lastSelect || !this.s.lastCascade)) {
- var colOpts = this.s.colOpts;
- var selected = this.s.dtPane.rows({ selected: true }).data().toArray();
- var rowData = this.s.rowData;
-
- this.s.dtPane.clear();
-
- if (this.colExists) {
-
- if (rowData.arrayFilter.length === 0) {
- this._populatePane(!this.s.filteringActive);
- }
-
-
- else if (this.c.cascadePanes &&
- this.s.dt.rows().data().toArray().length ===
- this.s.dt.rows({ search: 'applied' }).data().toArray().length) {
- rowData.arrayFilter = rowData.arrayOriginal;
- rowData.bins = rowData.binsOriginal;
- }
-
- else if (this.c.viewTotal || this.c.cascadePanes) {
- this._populatePane(!this.s.filteringActive);
- }
-
- if (this.c.viewTotal) {
- this._detailsPane();
- }
- else {
- rowData.binsTotal = rowData.bins;
- }
- if (this.c.viewTotal && !this.c.cascadePanes) {
- rowData.arrayFilter = rowData.arrayTotals;
- }
- var _loop_1 = function (dataP) {
-
-
-
- if (dataP &&
- (rowData.bins[dataP.filter] !== undefined &&
- rowData.bins[dataP.filter] !== 0 &&
- this_1.c.cascadePanes ||
- !this_1.c.cascadePanes ||
- this_1.s.clearing)) {
- var row = this_1.addRow(dataP.display, dataP.filter, !this_1.c.viewTotal ?
- rowData.bins[dataP.filter] :
- rowData.bins[dataP.filter] !== undefined ?
- rowData.bins[dataP.filter] :
- 0, this_1.c.viewTotal ?
- String(rowData.binsTotal[dataP.filter]) :
- rowData.bins[dataP.filter], dataP.sort, dataP.type);
-
-
- var selectIndex = selected.findIndex(function (element) {
- return element.filter === dataP.filter;
- });
- if (selectIndex !== -1) {
- row.select();
- selected.splice(selectIndex, 1);
- }
- }
- };
- var this_1 = this;
- for (var _i = 0, _a = rowData.arrayFilter; _i < _a.length; _i++) {
- var dataP = _a[_i];
- _loop_1(dataP);
- }
- }
- if (colOpts.searchPanes !== undefined && colOpts.searchPanes.options !== undefined ||
- colOpts.options !== undefined ||
- this.customPaneSettings !== null && this.customPaneSettings.options !== undefined) {
- var rows = this._getComparisonRows();
- var _loop_2 = function (row) {
- var selectIndex = selected.findIndex(function (element) {
- if (element.display === row.data().display) {
- return true;
- }
- });
- if (selectIndex !== -1) {
- row.select();
- selected.splice(selectIndex, 1);
- }
- };
- for (var _b = 0, rows_1 = rows; _b < rows_1.length; _b++) {
- var row = rows_1[_b];
- _loop_2(row);
- }
- }
-
-
- for (var _c = 0, selected_1 = selected; _c < selected_1.length; _c++) {
- var selectedEl = selected_1[_c];
- var row = this.addRow(selectedEl.display, selectedEl.filter, 0, this.c.viewTotal
- ? selectedEl.total
- : 0, selectedEl.display, selectedEl.display);
- this.s.updating = true;
- row.select();
- this.s.updating = false;
- }
- this.s.dtPane.draw();
- this.s.dtPane.table().node().parentNode.scrollTop = this.s.scrollTop;
- }
- };
- SearchPane.version = '1.3.0';
- SearchPane.classes = {
- bordered: 'dtsp-bordered',
- buttonGroup: 'dtsp-buttonGroup',
- buttonSub: 'dtsp-buttonSub',
- clear: 'dtsp-clear',
- clearAll: 'dtsp-clearAll',
- clearButton: 'clearButton',
- collapseAll: 'dtsp-collapseAll',
- collapseButton: 'dtsp-collapseButton',
- 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',
- rotated: 'dtsp-rotated',
- 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'
- };
-
- SearchPane.defaults = {
- cascadePanes: false,
- clear: true,
- collapse: true,
- combiner: 'or',
- container: function (dt) {
- return dt.table().container();
- },
- controls: true,
- dtOpts: {},
- emptyMessage: null,
- hideCount: false,
- i18n: {
- clearPane: '×',
- count: '{total}',
- countFiltered: '{shown} ({total})',
- emptyMessage: '<em>No data</em>'
- },
- initCollapsed: false,
- layout: 'auto',
- name: undefined,
- orderable: true,
- orthogonal: {
- display: 'display',
- filter: 'filter',
- hideCount: false,
- search: 'filter',
- show: undefined,
- sort: 'sort',
- threshold: 0.6,
- type: 'type',
- viewCount: true
- },
- preSelect: [],
- threshold: 0.6,
- viewCount: true,
- viewTotal: false
- };
- return SearchPane;
- }());
- var $$1;
- var dataTable$1;
- function setJQuery$1(jq) {
- $$1 = jq;
- dataTable$1 = jq.fn.dataTable;
- }
- var SearchPanes = (function () {
- function SearchPanes(paneSettings, opts, fromInit) {
- var _this = this;
- if (fromInit === void 0) { fromInit = false; }
- this.regenerating = false;
-
- if (!dataTable$1 || !dataTable$1.versionCheck || !dataTable$1.versionCheck('1.10.0')) {
- throw new Error('SearchPane requires DataTables 1.10 or newer');
- }
-
-
- if (!dataTable$1.select) {
- throw new Error('SearchPane requires Select');
- }
- var table = new dataTable$1.Api(paneSettings);
- this.classes = $$1.extend(true, {}, SearchPanes.classes);
-
- this.c = $$1.extend(true, {}, SearchPanes.defaults, opts);
-
- this.dom = {
- clearAll: $$1('<button type="button">Clear All</button>').addClass(this.classes.clearAll),
- collapseAll: $$1('<button type="button">Collapse All</button>').addClass(this.classes.collapseAll),
- container: $$1('<div/>').addClass(this.classes.panes).text(table.i18n('searchPanes.loadMessage', this.c.i18n.loadMessage)),
- emptyMessage: $$1('<div/>').addClass(this.classes.emptyMessage),
- options: $$1('<div/>').addClass(this.classes.container),
- panes: $$1('<div/>').addClass(this.classes.container),
- showAll: $$1('<button type="button">Show All</button>')
- .addClass(this.classes.showAll)
- .addClass(this.classes.disabledButton)
- .attr('disabled', 'true'),
- title: $$1('<div/>').addClass(this.classes.title),
- titleRow: $$1('<div/>').addClass(this.classes.titleRow),
- wrapper: $$1('<div/>')
- };
- this.s = {
- colOpts: [],
- dt: table,
- filterCount: 0,
- filterPane: -1,
- page: 0,
- paging: false,
- panes: [],
- selectionList: [],
- serverData: {},
- stateRead: false,
- updating: false
- };
- if (table.settings()[0]._searchPanes !== undefined) {
- return;
- }
- this._getState();
- if (this.s.dt.page.info().serverSide) {
- table.on('preXhr.dt', function (e, settings, data) {
- if (data.searchPanes === undefined) {
- data.searchPanes = {};
- }
- if (data.searchPanes_null === undefined) {
- data.searchPanes_null = {};
- }
- for (var _i = 0, _a = _this.s.selectionList; _i < _a.length; _i++) {
- var selection = _a[_i];
- var src = _this.s.dt.column(selection.index).dataSrc();
- if (data.searchPanes[src] === undefined) {
- data.searchPanes[src] = {};
- }
- if (data.searchPanes_null[src] === undefined) {
- data.searchPanes_null[src] = {};
- }
- for (var i = 0; i < selection.rows.length; i++) {
- data.searchPanes[src][i] = selection.rows[i].filter;
- if (data.searchPanes[src][i] === null) {
- data.searchPanes_null[src][i] = true;
- }
- }
- }
- });
- }
-
-
- table.on('xhr', function (e, settings, json, xhr) {
- if (json && json.searchPanes && json.searchPanes.options) {
- _this.s.serverData = json;
- _this.s.serverData.tableLength = json.recordsTotal;
- _this._serverTotals();
- }
- });
- table.settings()[0]._searchPanes = this;
- this.dom.clearAll.text(table.i18n('searchPanes.clearMessage', this.c.i18n.clearMessage));
- this.dom.collapseAll.text(table.i18n('searchPanes.collapseMessage', this.c.i18n.collapseMessage));
- this.dom.showAll.text(table.i18n('searchPanes.showMessage', this.c.i18n.showMessage));
- if (this.s.dt.settings()[0]._bInitComplete || fromInit) {
- this._paneDeclare(table, paneSettings, opts);
- }
- else {
- table.one('preInit.dt', function (settings) {
- _this._paneDeclare(table, paneSettings, opts);
- });
- }
- return this;
- }
-
- SearchPanes.prototype.clearSelections = function () {
-
- var searches = this.dom.container.find('.' + this.classes.search.replace(/\s+/g, '.'));
-
-
- searches.each(function () {
- $$1(this).val('');
- $$1(this).trigger('input');
- });
- var returnArray = [];
-
- this.s.selectionList = [];
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.dtPane !== undefined) {
- returnArray.push(pane.clearPane());
- }
- }
- return returnArray;
- };
-
- SearchPanes.prototype.getNode = function () {
- return this.dom.container;
- };
-
- SearchPanes.prototype.rebuild = function (targetIdx, maintainSelection) {
- if (targetIdx === void 0) { targetIdx = false; }
- if (maintainSelection === void 0) { maintainSelection = false; }
- this.dom.emptyMessage.remove();
-
- var returnArray = [];
-
- if (targetIdx === false) {
- this.dom.panes.empty();
- }
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (targetIdx !== false && pane.s.index !== targetIdx) {
- continue;
- }
- pane.clearData();
- returnArray.push(
-
- pane.rebuildPane(this.s.selectionList[this.s.selectionList.length - 1] !== undefined ?
- pane.s.index === this.s.selectionList[this.s.selectionList.length - 1].index :
- false, this.s.dt.page.info().serverSide ?
- this.s.serverData :
- undefined, null, maintainSelection));
- this.dom.panes.append(pane.dom.container);
- }
- if (this.c.cascadePanes || this.c.viewTotal) {
- this.redrawPanes(true);
- }
- else {
- this._updateSelection();
- }
-
- this._updateFilterCount();
- this._attachPaneContainer();
-
-
- this.s.dt.draw(!maintainSelection);
-
- this.resizePanes();
-
- if (returnArray.length === 1) {
- return returnArray[0];
- }
-
- else {
- return returnArray;
- }
- };
-
- SearchPanes.prototype.redrawPanes = function (rebuild) {
- if (rebuild === void 0) { rebuild = false; }
- var table = this.s.dt;
-
- if (!this.s.updating && !this.s.dt.page.info().serverSide) {
- var filterActive = true;
- var filterPane = this.s.filterPane;
- var selectTotal = null;
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.dtPane !== undefined) {
- selectTotal += pane.s.dtPane.rows({ selected: true }).data().toArray().length;
- }
- }
-
-
- if (selectTotal === 0 &&
- table.rows({ search: 'applied' }).data().toArray().length === table.rows().data().toArray().length) {
- filterActive = false;
- }
-
-
-
- else if (this.c.viewTotal) {
- for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) {
- var pane = _c[_b];
- if (pane.s.dtPane !== undefined) {
- var selectLength = pane.s.dtPane.rows({ selected: true }).data().toArray().length;
- if (selectLength === 0) {
- for (var _d = 0, _e = this.s.selectionList; _d < _e.length; _d++) {
- var selection = _e[_d];
- if (selection.index === pane.s.index && selection.rows.length !== 0) {
- selectLength = selection.rows.length;
- }
- }
- }
-
-
- if (selectLength > 0 && filterPane === -1) {
- filterPane = pane.s.index;
- }
-
-
- else if (selectLength > 0) {
- filterPane = null;
- }
- }
- }
-
- if (selectTotal === 0) {
- filterPane = null;
- }
- }
- var deselectIdx = void 0;
- var newSelectionList = [];
-
- if (!this.regenerating) {
- for (var _f = 0, _g = this.s.panes; _f < _g.length; _f++) {
- var pane = _g[_f];
-
- if (pane.s.selectPresent) {
- this.s.selectionList.push({
- index: pane.s.index,
- protect: false,
- rows: pane.s.dtPane.rows({ selected: true }).data().toArray()
- });
- break;
- }
- else if (pane.s.deselect) {
- deselectIdx = pane.s.index;
- var selectedData = pane.s.dtPane.rows({ selected: true }).data().toArray();
- if (selectedData.length > 0) {
- this.s.selectionList.push({
- index: pane.s.index,
- protect: true,
- rows: selectedData
- });
- }
- }
- }
- if (this.s.selectionList.length > 0) {
- var last = this.s.selectionList[this.s.selectionList.length - 1].index;
- for (var _h = 0, _j = this.s.panes; _h < _j.length; _h++) {
- var pane = _j[_h];
- pane.s.lastSelect = pane.s.index === last;
- }
- }
-
- for (var i = 0; i < this.s.selectionList.length; i++) {
- if (this.s.selectionList[i].index !== deselectIdx || this.s.selectionList[i].protect === true) {
- var further = false;
-
- for (var j = i + 1; j < this.s.selectionList.length; j++) {
- if (this.s.selectionList[j].index === this.s.selectionList[i].index) {
- further = true;
- }
- }
-
- if (!further) {
- newSelectionList.push(this.s.selectionList[i]);
- this.s.selectionList[i].protect = false;
- }
- }
- }
- var solePane = -1;
- if (newSelectionList.length === 1 && selectTotal !== null && selectTotal !== 0) {
- solePane = newSelectionList[0].index;
- }
-
- for (var _k = 0, _l = this.s.panes; _k < _l.length; _k++) {
- var pane = _l[_k];
- if (pane.s.dtPane !== undefined) {
- var tempFilter = true;
- pane.s.filteringActive = true;
- if (filterPane !== -1 && filterPane !== null && filterPane === pane.s.index ||
- filterActive === false ||
- pane.s.index === solePane) {
- tempFilter = false;
- pane.s.filteringActive = false;
- }
- pane.updatePane(!tempFilter ? false : filterActive);
- }
- }
-
-
- if (newSelectionList.length > 0 && (newSelectionList.length < this.s.selectionList.length || rebuild)) {
- this._cascadeRegen(newSelectionList, selectTotal);
- var last = newSelectionList[newSelectionList.length - 1].index;
- for (var _m = 0, _o = this.s.panes; _m < _o.length; _m++) {
- var pane = _o[_m];
- pane.s.lastSelect = pane.s.index === last;
- }
- }
- else if (newSelectionList.length > 0) {
-
- for (var _p = 0, _q = this.s.panes; _p < _q.length; _p++) {
- var paneUpdate = _q[_p];
- if (paneUpdate.s.dtPane !== undefined) {
- var tempFilter = true;
- paneUpdate.s.filteringActive = true;
- if (filterPane !== -1 && filterPane !== null && filterPane === paneUpdate.s.index ||
- filterActive === false ||
- paneUpdate.s.index === solePane) {
- tempFilter = false;
- paneUpdate.s.filteringActive = false;
- }
- paneUpdate.updatePane(!tempFilter ? tempFilter : filterActive);
- }
- }
- }
-
- this._updateFilterCount();
- }
- else {
- var solePane = -1;
- if (newSelectionList.length === 1 && selectTotal !== null && selectTotal !== 0) {
- solePane = newSelectionList[0].index;
- }
- for (var _r = 0, _s = this.s.panes; _r < _s.length; _r++) {
- var pane = _s[_r];
- if (pane.s.dtPane !== undefined) {
- var tempFilter = true;
- pane.s.filteringActive = true;
- if (filterPane !== -1 && filterPane !== null && filterPane === pane.s.index ||
- filterActive === false ||
- pane.s.index === solePane) {
- tempFilter = false;
- pane.s.filteringActive = false;
- }
- pane.updatePane(!tempFilter ? tempFilter : filterActive);
- }
- }
-
- this._updateFilterCount();
- }
- if (!filterActive || selectTotal === 0) {
- this.s.selectionList = [];
- }
- }
- };
-
- SearchPanes.prototype.resizePanes = function () {
- if (this.c.layout === 'auto') {
- var contWidth = $$1(this.s.dt.searchPanes.container()).width();
- var target = Math.floor(contWidth / 260.0);
- var highest = 1;
- var highestmod = 0;
- var dispIndex = [];
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.displayed) {
- dispIndex.push(pane.s.index);
- }
- }
- var displayCount = dispIndex.length;
-
- if (target === displayCount) {
- highest = target;
- }
- else {
-
- for (var ppr = target; ppr > 1; ppr--) {
- var rem = displayCount % ppr;
- if (rem === 0) {
- highest = ppr;
- highestmod = 0;
- break;
- }
-
-
- else if (rem > highestmod) {
- highest = ppr;
- highestmod = rem;
- }
- }
- }
-
- var widerIndexes = highestmod !== 0 ? dispIndex.slice(dispIndex.length - highestmod, dispIndex.length) : [];
- for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) {
- var pane = _c[_b];
-
- if (pane.s.displayed) {
- var layout = 'columns-' + (!widerIndexes.includes(pane.s.index) ? highest : highestmod);
- pane.resize(layout);
- }
- }
- }
- else {
- for (var _d = 0, _e = this.s.panes; _d < _e.length; _d++) {
- var pane = _e[_d];
- pane.adjustTopRow();
- }
- }
- return this;
- };
-
- SearchPanes.prototype._attach = function () {
- var _this = this;
- this.dom.container.removeClass(this.classes.hide);
- this.dom.titleRow.removeClass(this.classes.hide);
- this.dom.titleRow.remove();
- this.dom.title.appendTo(this.dom.titleRow);
-
- if (this.c.clear) {
- this.dom.clearAll.appendTo(this.dom.titleRow);
- this.dom.clearAll.on('click.dtsps', function () {
- _this.clearSelections();
- });
- }
- if (this.c.collapse) {
- this._setCollapseListener();
- }
- this.dom.titleRow.appendTo(this.dom.container);
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- pane.dom.container.appendTo(this.dom.panes);
- }
-
- this.dom.panes.appendTo(this.dom.container);
- if ($$1('div.' + this.classes.container).length === 0) {
- this.dom.container.prependTo(this.s.dt);
- }
- return this.dom.container;
- };
-
- SearchPanes.prototype._attachExtras = function () {
- this.dom.container.removeClass(this.classes.hide);
- this.dom.titleRow.removeClass(this.classes.hide);
- this.dom.titleRow.remove();
- this.dom.title.appendTo(this.dom.titleRow);
-
- if (this.c.clear) {
- this.dom.clearAll.appendTo(this.dom.titleRow);
- }
-
- if (this.c.collapse) {
- this.dom.showAll.appendTo(this.dom.titleRow);
- this.dom.collapseAll.appendTo(this.dom.titleRow);
- }
- this.dom.titleRow.appendTo(this.dom.container);
- return this.dom.container;
- };
-
- SearchPanes.prototype._attachMessage = function () {
-
- var message;
- try {
- message = this.s.dt.i18n('searchPanes.emptyPanes', this.c.i18n.emptyPanes);
- }
- catch (error) {
- message = null;
- }
-
-
- if (message === null) {
- this.dom.container.addClass(this.classes.hide);
- this.dom.titleRow.removeClass(this.classes.hide);
- return;
- }
- else {
- this.dom.container.removeClass(this.classes.hide);
- this.dom.titleRow.addClass(this.classes.hide);
- }
-
- this.dom.emptyMessage.text(message);
- this.dom.emptyMessage.appendTo(this.dom.container);
- return this.dom.container;
- };
-
- SearchPanes.prototype._attachPaneContainer = function () {
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.displayed === true) {
- return this._attach();
- }
- }
-
- return this._attachMessage();
- };
-
- SearchPanes.prototype._cascadeRegen = function (newSelectionList, selectTotal) {
-
- this.regenerating = true;
-
- var solePane = -1;
- if (newSelectionList.length === 1 && selectTotal !== null && selectTotal !== 0) {
- solePane = newSelectionList[0].index;
- }
-
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- pane.setCascadeRegen(true);
- pane.setClear(true);
-
- if (pane.s.dtPane !== undefined && pane.s.index === solePane || pane.s.dtPane !== undefined) {
- pane.clearPane();
- }
- pane.setClear(false);
- }
-
- this.s.dt.draw();
-
-
- var noSelectionsTableLength = this.s.dt.rows({ search: 'applied' }).data().toArray().length;
- var tableLength = this.s.dt.rows().data().toArray().length;
- if (tableLength !== noSelectionsTableLength) {
- for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) {
- var pane = _c[_b];
- pane.s.forceViewTotal = true;
- }
- }
- for (var _d = 0, _e = this.s.panes; _d < _e.length; _d++) {
- var pane = _e[_d];
- pane.updatePane(true);
- }
-
- this._makeCascadeSelections(newSelectionList);
-
- this.s.selectionList = newSelectionList;
-
- for (var _f = 0, _g = this.s.panes; _f < _g.length; _f++) {
- var pane = _g[_f];
- pane.setCascadeRegen(false);
- }
- this.regenerating = false;
-
- if (tableLength !== noSelectionsTableLength) {
- for (var _h = 0, _j = this.s.panes; _h < _j.length; _h++) {
- var pane = _j[_h];
- pane.s.forceViewTotal = false;
- }
- }
- };
-
- SearchPanes.prototype._checkMessage = function () {
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.displayed === true) {
-
- this.dom.emptyMessage.remove();
- this.dom.titleRow.removeClass(this.classes.hide);
- return;
- }
- }
-
- return this._attachMessage();
- };
-
- SearchPanes.prototype._checkCollapse = function () {
- var disableClose = true;
- var disableShow = true;
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.displayed) {
-
- if (!pane.dom.collapseButton.hasClass(pane.classes.rotated)) {
-
- this.dom.collapseAll.removeClass(this.classes.disabledButton).removeAttr('disabled');
- disableClose = false;
- }
- else {
-
- this.dom.showAll.removeClass(this.classes.disabledButton).removeAttr('disabled');
- disableShow = false;
- }
- }
- }
-
- if (disableClose) {
- this.dom.collapseAll.addClass(this.classes.disabledButton).attr('disabled', 'true');
- }
-
- if (disableShow) {
- this.dom.showAll.addClass(this.classes.disabledButton).attr('disabled', 'true');
- }
- };
-
- SearchPanes.prototype._collapseAll = function () {
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- pane.collapse();
- }
- };
-
- SearchPanes.prototype._getState = function () {
- var loadedFilter = this.s.dt.state.loaded();
- if (loadedFilter && loadedFilter.searchPanes && loadedFilter.searchPanes.selectionList !== undefined) {
- this.s.selectionList = loadedFilter.searchPanes.selectionList;
- }
- };
-
- SearchPanes.prototype._makeCascadeSelections = function (newSelectionList) {
-
-
- for (var i = 0; i < newSelectionList.length; i++) {
- var _loop_1 = function (pane) {
- if (pane.s.index === newSelectionList[i].index && pane.s.dtPane !== undefined) {
-
-
-
- if (i === newSelectionList.length - 1) {
- pane.s.lastCascade = true;
- }
-
-
- if (pane.s.dtPane.rows({ selected: true }).data().toArray().length > 0 && pane.s.dtPane !== undefined) {
- pane.setClear(true);
- pane.clearPane();
- pane.setClear(false);
- }
- var _loop_2 = function (row) {
- var found = false;
- pane.s.dtPane.rows().every(function (rowIdx) {
- if (pane.s.dtPane.row(rowIdx).data() !== undefined &&
- row !== undefined &&
- pane.s.dtPane.row(rowIdx).data().filter === row.filter) {
- found = true;
- pane.s.dtPane.row(rowIdx).select();
- }
- });
- if (!found) {
- var newRow = pane.addRow(row.display, row.filter, 0, row.total, row.sort, row.type, row.className);
- newRow.select();
- }
- };
-
- for (var _i = 0, _a = newSelectionList[i].rows; _i < _a.length; _i++) {
- var row = _a[_i];
- _loop_2(row);
- }
- pane.s.scrollTop = $$1(pane.s.dtPane.table().node()).parent()[0].scrollTop;
- pane.s.dtPane.draw();
- pane.s.dtPane.table().node().parentNode.scrollTop = pane.s.scrollTop;
- pane.s.lastCascade = false;
- }
- };
-
-
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- _loop_1(pane);
- }
- }
- };
-
- SearchPanes.prototype._paneDeclare = function (table, paneSettings, opts) {
- var _this = this;
-
- table
- .columns(this.c.columns.length > 0 ? this.c.columns : undefined)
- .eq(0)
- .each(function (idx) {
- _this.s.panes.push(new SearchPane(paneSettings, opts, idx, _this.c.layout, _this.dom.panes));
- });
-
- var rowLength = table.columns().eq(0).toArray().length;
- var paneLength = this.c.panes.length;
- for (var i = 0; i < paneLength; i++) {
- var id = rowLength + i;
- this.s.panes.push(new SearchPane(paneSettings, opts, id, this.c.layout, this.dom.panes, this.c.panes[i]));
- }
-
- if (this.c.order.length > 0) {
-
- var newPanes = this.c.order.map(function (name, index, values) { return _this._findPane(name); });
-
- this.dom.panes.empty();
- this.s.panes = newPanes;
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- this.dom.panes.append(pane.dom.container);
- }
- }
-
- if (this.s.dt.settings()[0]._bInitComplete) {
- this._startup(table);
- }
- else {
-
-
-
- this.s.dt.settings()[0].aoInitComplete.push({ fn: function () {
- _this._startup(table);
- } });
- }
- };
-
- SearchPanes.prototype._findPane = function (name) {
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (name === pane.s.name) {
- return pane;
- }
- }
- };
-
- SearchPanes.prototype._serverTotals = function () {
- var selectPresent = false;
- var deselectPresent = false;
- var table = this.s.dt;
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
-
- if (pane.s.selectPresent) {
- this.s.selectionList.push({
- index: pane.s.index,
- protect: false,
- rows: pane.s.dtPane.rows({ selected: true }).data().toArray()
- });
- pane.s.selectPresent = false;
- selectPresent = true;
- break;
- }
- else if (pane.s.deselect) {
- var selectedData = pane.s.dtPane.rows({ selected: true }).data().toArray();
- if (selectedData.length > 0) {
- this.s.selectionList.push({
- index: pane.s.index,
- protect: true,
- rows: selectedData
- });
- }
- selectPresent = true;
- deselectPresent = true;
- }
- }
-
- if (!selectPresent) {
- this.s.selectionList = [];
- }
- else {
- var newSelectionList = [];
- for (var i = 0; i < this.s.selectionList.length; i++) {
- var further = false;
-
- for (var j = i + 1; j < this.s.selectionList.length; j++) {
- if (this.s.selectionList[j].index === this.s.selectionList[i].index) {
- further = true;
- }
- }
-
- if (!further) {
- var push = false;
- for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) {
- var pane = _c[_b];
- if (pane.s.index === this.s.selectionList[i].index &&
- pane.s.dtPane.rows({ selected: true }).data().toArray().length > 0) {
- push = true;
- }
- }
- if (push) {
- newSelectionList.push(this.s.selectionList[i]);
- }
- }
- }
- this.s.selectionList = newSelectionList;
- }
- var initIdx = -1;
-
- if (deselectPresent && this.s.selectionList.length === 1) {
- for (var _d = 0, _e = this.s.panes; _d < _e.length; _d++) {
- var pane = _e[_d];
- pane.s.lastSelect = false;
- pane.s.deselect = false;
- if (pane.s.dtPane !== undefined && pane.s.dtPane.rows({ selected: true }).data().toArray().length > 0) {
- initIdx = pane.s.index;
- }
- }
- }
-
- else if (this.s.selectionList.length > 0) {
- var last = this.s.selectionList[this.s.selectionList.length - 1].index;
- for (var _f = 0, _g = this.s.panes; _f < _g.length; _f++) {
- var pane = _g[_f];
- pane.s.lastSelect = pane.s.index === last;
- pane.s.deselect = false;
- }
- }
-
- else if (this.s.selectionList.length === 0) {
- for (var _h = 0, _j = this.s.panes; _h < _j.length; _h++) {
- var pane = _j[_h];
-
- pane.s.lastSelect = false;
- pane.s.deselect = false;
- }
- }
- this.dom.panes.empty();
-
- for (var _k = 0, _l = this.s.panes; _k < _l.length; _k++) {
- var pane = _l[_k];
- if (!pane.s.lastSelect) {
- pane.rebuildPane(undefined, this.s.dt.page.info().serverSide ? this.s.serverData : undefined, pane.s.index === initIdx ? true : null, true);
- }
- else {
- pane._setListeners();
- }
-
- this.dom.panes.append(pane.dom.container);
- if (pane.s.dtPane !== undefined) {
- $$1(pane.s.dtPane.table().node()).parent()[0].scrollTop = pane.s.scrollTop;
-
- $$1.fn.dataTable.select.init(pane.s.dtPane);
- }
- }
- this._updateSelection();
- };
-
- SearchPanes.prototype._setCollapseListener = function () {
- var _this = this;
- this.dom.collapseAll.on('click.dtsps', function () {
- _this._collapseAll();
- _this.dom.collapseAll.addClass(_this.classes.disabledButton).attr('disabled', 'true');
- _this.dom.showAll.removeClass(_this.classes.disabledButton).removeAttr('disabled');
- _this.s.dt.state.save();
- });
- this.dom.showAll.on('click.dtsps', function () {
- _this._showAll();
- _this.dom.showAll.addClass(_this.classes.disabledButton).attr('disabled', 'true');
- _this.dom.collapseAll.removeClass(_this.classes.disabledButton).removeAttr('disabled');
- _this.s.dt.state.save();
- });
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
-
- pane.dom.collapseButton.on('click', function () { return _this._checkCollapse(); });
- }
- this._checkCollapse();
- };
-
- SearchPanes.prototype._showAll = function () {
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- pane.show();
- }
- };
-
- SearchPanes.prototype._startup = function (table) {
- var _this = this;
- this.dom.container.text('');
-
- this._attachExtras();
- this.dom.container.append(this.dom.panes);
- this.dom.panes.empty();
- var loadedFilter = this.s.dt.state.loaded();
- if (this.c.viewTotal && !this.c.cascadePanes) {
- if (loadedFilter !== null &&
- loadedFilter !== undefined &&
- loadedFilter.searchPanes !== undefined &&
- loadedFilter.searchPanes.panes !== undefined) {
- var filterActive = false;
- for (var _i = 0, _a = loadedFilter.searchPanes.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.selected.length > 0) {
- filterActive = true;
- break;
- }
- }
- if (filterActive) {
- for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) {
- var pane = _c[_b];
- pane.s.showFiltered = true;
- }
- }
- }
- }
- for (var _d = 0, _e = this.s.panes; _d < _e.length; _d++) {
- var pane = _e[_d];
- pane.rebuildPane(undefined, Object.keys(this.s.serverData).length > 0 ? this.s.serverData : undefined);
- this.dom.panes.append(pane.dom.container);
- }
-
- if (this.c.layout === 'auto') {
- this.resizePanes();
- }
-
- if (!this.s.stateRead && loadedFilter !== null && loadedFilter !== undefined) {
- this.s.dt.page(loadedFilter.start / this.s.dt.page.len());
- this.s.dt.draw('page');
- }
- this.s.stateRead = true;
- if (this.c.viewTotal && !this.c.cascadePanes) {
- for (var _f = 0, _g = this.s.panes; _f < _g.length; _f++) {
- var pane = _g[_f];
- pane.updatePane();
- }
- }
- this._checkMessage();
-
- table.on('preDraw.dtsps', function () {
-
-
- if (!_this.s.updating && !_this.s.paging) {
- if ((_this.c.cascadePanes || _this.c.viewTotal) && !_this.s.dt.page.info().serverSide) {
- _this.redrawPanes(_this.c.viewTotal);
- }
- else {
- _this._updateFilterCount();
- _this._updateSelection();
- }
- _this.s.filterPane = -1;
- }
-
- _this.s.paging = false;
- });
- $$1(window).on('resize.dtsp', dataTable$1.util.throttle(function () {
- _this.resizePanes();
- }));
-
- this.s.dt.on('stateSaveParams.dtsp', function (e, settings, data) {
- if (data.searchPanes === undefined) {
- data.searchPanes = {};
- }
- data.searchPanes.selectionList = _this.s.selectionList;
- });
-
- table.off('page');
- table.on('page', function () {
- _this.s.paging = true;
- _this.s.page = _this.s.dt.page();
- });
- if (this.s.dt.page.info().serverSide) {
- table.off('preXhr.dt');
- table.on('preXhr.dt', function (e, settings, data) {
- if (data.searchPanes === undefined) {
- data.searchPanes = {};
- }
- if (data.searchPanes_null === undefined) {
- data.searchPanes_null = {};
- }
-
- var filterCount = 0;
- for (var _i = 0, _a = _this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- var src = _this.s.dt.column(pane.s.index).dataSrc();
- if (data.searchPanes[src] === undefined) {
- data.searchPanes[src] = {};
- }
- if (data.searchPanes_null[src] === undefined) {
- data.searchPanes_null[src] = {};
- }
- if (pane.s.dtPane !== undefined) {
- var rowData = pane.s.dtPane.rows({ selected: true }).data().toArray();
- for (var i = 0; i < rowData.length; i++) {
- data.searchPanes[src][i] = rowData[i].filter;
- if (data.searchPanes[src][i] === null) {
- data.searchPanes_null[src][i] = true;
- }
- filterCount++;
- }
- }
- }
- if (_this.c.viewTotal) {
- _this._prepViewTotal(filterCount);
- }
-
-
- if (filterCount > 0) {
-
-
- if (filterCount !== _this.s.filterCount) {
- data.start = 0;
- _this.s.page = 0;
- }
-
- else {
- data.start = _this.s.page * _this.s.dt.page.len();
- }
- _this.s.dt.page(_this.s.page);
- _this.s.filterCount = filterCount;
- }
- });
- }
- else {
- table.on('preXhr.dt', function (e, settings, data) {
- for (var _i = 0, _a = _this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- pane.clearData();
- }
- });
- }
-
-
- this.s.dt.on('xhr', function (e, settings, json, xhr) {
- if (settings.nTable !== _this.s.dt.table().node()) {
- return;
- }
- var processing = false;
- if (!_this.s.dt.page.info().serverSide) {
- _this.s.dt.one('preDraw', function () {
- if (processing) {
- return;
- }
- var page = _this.s.dt.page();
- processing = true;
- _this.s.updating = true;
- _this.dom.panes.empty();
- for (var _i = 0, _a = _this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- pane.clearData();
-
-
- pane.rebuildPane(_this.s.selectionList[_this.s.selectionList.length - 1] !== undefined ?
- pane.s.index === _this.s.selectionList[_this.s.selectionList.length - 1].index :
- false, undefined, undefined, true);
- _this.dom.panes.append(pane.dom.container);
- }
- if (!_this.s.dt.page.info().serverSide) {
- _this.s.dt.draw();
- }
- _this.s.updating = false;
- if (_this.c.cascadePanes || _this.c.viewTotal) {
- _this.redrawPanes(_this.c.cascadePanes);
- }
- else {
- _this._updateSelection();
- }
- _this._checkMessage();
- _this.s.dt.one('draw', function () {
- _this.s.updating = true;
- _this.s.dt.page(page).draw(false);
- _this.s.updating = false;
- });
- });
- }
- });
-
- for (var _h = 0, _j = this.s.panes; _h < _j.length; _h++) {
- var pane = _j[_h];
- if (pane !== undefined &&
- pane.s.dtPane !== undefined &&
- (pane.s.colOpts.preSelect !== undefined && pane.s.colOpts.preSelect.length > 0 ||
- pane.customPaneSettings !== null &&
- pane.customPaneSettings.preSelect !== undefined &&
- pane.customPaneSettings.preSelect.length > 0)) {
- var tableLength = pane.s.dtPane.rows().data().toArray().length;
- for (var i = 0; i < tableLength; i++) {
- if (pane.s.colOpts.preSelect.includes(pane.s.dtPane.cell(i, 0).data()) ||
- pane.customPaneSettings !== null &&
- pane.customPaneSettings.preSelect !== undefined &&
- pane.customPaneSettings.preSelect.includes(pane.s.dtPane.cell(i, 0).data())) {
- pane.s.dtPane.row(i).select();
- }
- }
- pane.updateTable();
- }
- }
- if (this.s.selectionList !== undefined && this.s.selectionList.length > 0) {
- var last = this.s.selectionList[this.s.selectionList.length - 1].index;
- for (var _k = 0, _l = this.s.panes; _k < _l.length; _k++) {
- var pane = _l[_k];
- pane.s.lastSelect = pane.s.index === last;
- }
- }
-
- if (this.s.selectionList.length > 0 && this.c.cascadePanes) {
- this._cascadeRegen(this.s.selectionList, this.s.selectionList.length);
- }
-
- this._updateFilterCount();
-
- table.on('destroy.dtsps', function () {
- for (var _i = 0, _a = _this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- pane.destroy();
- }
- table.off('.dtsps');
- _this.dom.collapseAll.off('.dtsps');
- _this.dom.showAll.off('.dtsps');
- _this.dom.clearAll.off('.dtsps');
- _this.dom.container.remove();
- _this.clearSelections();
- });
- if (this.c.collapse) {
- this._setCollapseListener();
- }
-
- if (this.c.clear) {
- this.dom.clearAll.on('click.dtsps', function () {
- _this.clearSelections();
- });
- }
- table.settings()[0]._searchPanes = this;
-
- this.s.dt.state.save();
- };
- SearchPanes.prototype._prepViewTotal = function (selectTotal) {
- var filterPane = this.s.filterPane;
- var filterActive = false;
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.dtPane !== undefined) {
- var selectLength = pane.s.dtPane.rows({ selected: true }).data().toArray().length;
-
-
- if (selectLength > 0 && filterPane === -1) {
- filterPane = pane.s.index;
- filterActive = true;
- }
-
-
- else if (selectLength > 0) {
- filterPane = null;
- }
- }
- }
- if (selectTotal !== null && selectTotal !== 0) {
- filterPane = null;
- }
-
- for (var _b = 0, _c = this.s.panes; _b < _c.length; _b++) {
- var pane = _c[_b];
- if (pane.s.dtPane !== undefined) {
- pane.s.filteringActive = true;
- if (filterPane !== -1 && filterPane !== null && filterPane === pane.s.index ||
- filterActive === false) {
- pane.s.filteringActive = false;
- }
- }
- }
- };
-
- SearchPanes.prototype._updateFilterCount = function () {
- var filterCount = 0;
-
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.dtPane !== undefined) {
- filterCount += pane.getPaneCount();
- }
- }
-
- var message = this.s.dt.i18n('searchPanes.title', this.c.i18n.title, filterCount);
- this.dom.title.text(message);
- if (this.c.filterChanged !== undefined && typeof this.c.filterChanged === 'function') {
- this.c.filterChanged.call(this.s.dt, filterCount);
- }
- if (filterCount === 0) {
- this.dom.clearAll.addClass(this.classes.disabledButton).attr('disabled', 'true');
- }
- else {
- this.dom.clearAll.removeClass(this.classes.disabledButton).removeAttr('disabled');
- }
- };
-
- SearchPanes.prototype._updateSelection = function () {
- this.s.selectionList = [];
- for (var _i = 0, _a = this.s.panes; _i < _a.length; _i++) {
- var pane = _a[_i];
- if (pane.s.dtPane !== undefined) {
- this.s.selectionList.push({
- index: pane.s.index,
- protect: false,
- rows: pane.s.dtPane.rows({ selected: true }).data().toArray()
- });
- }
- }
- };
- SearchPanes.version = '1.4.0';
- SearchPanes.classes = {
- clear: 'dtsp-clear',
- clearAll: 'dtsp-clearAll',
- collapseAll: 'dtsp-collapseAll',
- container: 'dtsp-searchPanes',
- disabledButton: 'dtsp-disabledButton',
- emptyMessage: 'dtsp-emptyMessage',
- hide: 'dtsp-hidden',
- panes: 'dtsp-panesContainer',
- search: 'dtsp-search',
- showAll: 'dtsp-showAll',
- title: 'dtsp-title',
- titleRow: 'dtsp-titleRow'
- };
-
- SearchPanes.defaults = {
- cascadePanes: false,
- clear: true,
- collapse: true,
- columns: [],
- container: function (dt) {
- return dt.table().container();
- },
- filterChanged: undefined,
- i18n: {
- clearMessage: 'Clear All',
- clearPane: '×',
- collapse: {
- 0: 'SearchPanes',
- _: 'SearchPanes (%d)'
- },
- collapseMessage: 'Collapse All',
- count: '{total}',
- countFiltered: '{shown} ({total})',
- emptyMessage: '<em>No data</em>',
- emptyPanes: 'No SearchPanes',
- loadMessage: 'Loading Search Panes...',
- showMessage: 'Show All',
- title: 'Filters Active - %d'
- },
- layout: 'auto',
- order: [],
- panes: [],
- viewTotal: false
- };
- return SearchPanes;
- }());
-
-
-
-
- (function (factory) {
- if (typeof define === 'function' && define.amd) {
-
- define(['jquery', 'datatables.net'], function ($) {
- return factory($, window, document);
- });
- }
- else if (typeof exports === 'object') {
-
- module.exports = function (root, $) {
- if (!root) {
- root = window;
- }
- if (!$ || !$.fn.dataTable) {
-
- $ = require('datatables.net')(root, $).$;
- }
- return factory($, root, root.document);
- };
- }
- else {
-
-
- factory(window.jQuery, window, document);
- }
- }(function ($, window, document) {
- setJQuery($);
- setJQuery$1($);
- var dataTable = $.fn.dataTable;
-
- $.fn.dataTable.SearchPanes = SearchPanes;
-
- $.fn.DataTable.SearchPanes = SearchPanes;
-
- $.fn.dataTable.SearchPane = SearchPane;
-
- $.fn.DataTable.SearchPane = SearchPane;
-
- var apiRegister = $.fn.dataTable.Api.register;
- apiRegister('searchPanes()', function () {
- return this;
- });
- apiRegister('searchPanes.clearSelections()', function () {
- return this.iterator('table', function (ctx) {
- if (ctx._searchPanes) {
- ctx._searchPanes.clearSelections();
- }
- });
- });
- apiRegister('searchPanes.rebuildPane()', function (targetIdx, maintainSelections) {
- return this.iterator('table', function (ctx) {
- if (ctx._searchPanes) {
- ctx._searchPanes.rebuild(targetIdx, maintainSelections);
- }
- });
- });
- apiRegister('searchPanes.resizePanes()', function () {
- var ctx = this.context[0];
- return ctx._searchPanes ?
- ctx._searchPanes.resizePanes() :
- null;
- });
- apiRegister('searchPanes.container()', function () {
- var ctx = this.context[0];
- return ctx._searchPanes
- ? ctx._searchPanes.getNode()
- : null;
- });
- $.fn.dataTable.ext.buttons.searchPanesClear = {
- action: function (e, dt, node, config) {
- dt.searchPanes.clearSelections();
- },
- text: 'Clear Panes'
- };
- $.fn.dataTable.ext.buttons.searchPanes = {
- action: function (e, dt, node, config) {
- e.stopPropagation();
- this.popover(config._panes.getNode(), {
- align: 'dt-container'
- });
- config._panes.rebuild(undefined, true);
- },
- config: {},
- init: function (dt, node, config) {
- var panes = new $.fn.dataTable.SearchPanes(dt, $.extend({
- filterChanged: function (count) {
-
- dt.button(node).text(dt.i18n('searchPanes.collapse', dt.context[0].oLanguage.searchPanes !== undefined ?
- dt.context[0].oLanguage.searchPanes.collapse :
- dt.context[0]._searchPanes.c.i18n.collapse, count));
- }
- }, config.config));
- var message = dt.i18n('searchPanes.collapse', panes.c.i18n.collapse, 0);
- dt.button(node).text(message);
- config._panes = panes;
- },
- text: 'Search Panes'
- };
- function _init(settings, options, fromPre) {
- if (options === void 0) { options = null; }
- if (fromPre === void 0) { fromPre = false; }
- var api = new dataTable.Api(settings);
- var opts = options
- ? options
- : api.init().searchPanes || dataTable.defaults.searchPanes;
- var searchPanes = new SearchPanes(api, opts, fromPre);
- var node = searchPanes.getNode();
- return node;
- }
-
-
- $(document).on('preInit.dt.dtsp', function (e, settings, json) {
- if (e.namespace !== 'dt') {
- return;
- }
- if (settings.oInit.searchPanes ||
- dataTable.defaults.searchPanes) {
- if (!settings._searchPanes) {
- _init(settings, null, true);
- }
- }
- });
-
- dataTable.ext.feature.push({
- cFeature: 'P',
- fnInit: _init
- });
-
- if (dataTable.ext.features) {
- dataTable.ext.features.register('searchPanes', _init);
- }
- }));
- }());
|