1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-06 16:02:39 +02:00
TableFilter/dist/tablefilter/tablefilter.js

10 lines
112 KiB
JavaScript
Raw Normal View History

/**
2016-08-17 09:31:41 +02:00
* tablefilter v0.2.56 by Max Guglielmi
* build date: 2016-08-22T16:27:40.696Z
* MIT License
*/
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,function(){return function(t){function e(i){if(s[i])return s[i].exports;var n=s[i]={exports:{},id:i,loaded:!1};return t[i].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i=window.webpackJsonp;window.webpackJsonp=function(s,r){for(var o,a,l=0,h=[];l<s.length;l++)a=s[l],n[a]&&h.push.apply(h,n[a]),n[a]=0;for(o in r)t[o]=r[o];for(i&&i(s,r);h.length;)h.shift().call(null,e)};var s={},n={0:0};return e.e=function(t,i){if(0===n[t])return i.call(null,e);if(void 0!==n[t])n[t].push(i);else{n[t]=[i];var s=document.getElementsByTagName("head")[0],r=document.createElement("script");r.type="text/javascript",r.charset="utf-8",r.async=!0,r.src=e.p+"tf-"+({}[t]||t)+".js",s.appendChild(r)}},e.m=t,e.c=s,e.p="",e(0)}([function(t,e,i){"use strict";function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.TableFilter=void 0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},r=i(1),o=i(3),a=i(5),l=i(4),h=i(6),c=i(7),f=i(2),p=i(8),u=i(9),d=i(12),g=i(13),m=i(14),v=i(15),b=i(18),y=i(19),_=i(20),C=i(21),x=i(22),w=i(23),E=i(24),T=i(25),P=i(26),S=i(11),F=f.root.document;e.TableFilter=function(){function t(){var e=this;s(this,t),this.id=null,this.version="0.2.56",this.year=(new Date).getFullYear(),this.tbl=null,this.refRow=null,this.headersRow=null,this.cfg={},this.nbFilterableRows=0,this.nbCells=null;for(var i=void 0,r=arguments.length,a=Array(r),h=0;h<r;h++)a[h]=arguments[h];if(a.forEach(function(t){"object"===("undefined"==typeof t?"undefined":n(t))&&"TABLE"===t.nodeName?(e.tbl=t,e.id=t.id||"tf_"+(new Date).getTime()+"_"):(0,l.isString)(t)?(e.id=t,e.tbl=(0,o.elm)(t)):(0,l.isNumber)(t)?i=t:(0,l.isObj)(t)&&(e.cfg=t)}),!this.tbl||"TABLE"!==this.tbl.nodeName||0===this.getRowsNb())throw new Error("Could not instantiate TableFilter: HTML table\n DOM element not found.");var c=this.cfg;this.emitter=new p.Emitter,this.refRow=(0,l.isUndef)(i)?2:i+1;try{this.nbCells=this.getCellsNb(this.refRow)}catch(f){this.nbCells=this.getCellsNb(0)}this.basePath=c.base_path||"tablefilter/",this.fltGrid=c.grid!==!1,this.gridLayout=Boolean(c.grid_layout),this.filtersRowIndex=isNaN(c.filters_row_index)?0:c.filters_row_index,this.headersRow=isNaN(c.headers_row_index)?0===this.filtersRowIndex?1:0:c.headers_row_index,this.fltCellTag=(0,l.isString)(c.filters_cell_tag)?c.filters_cell_tag:S.CELL_TAG,this.fltIds=[],this.validRowsIndex=[],this.infDiv=null,this.lDiv=null,this.rDiv=null,this.mDiv=null,this.infDivCssClass=c.inf_div_css_class||"inf",this.lDivCssClass=c.left_div_css_class||"ldiv",this.rDivCssClass=c.right_div_css_class||"rdiv",this.mDivCssClass=c.middle_div_css_class||"mdiv",this.stylePath=c.style_path||this.basePath+"style/",this.stylesheet=c.stylesheet||this.stylePath+"tablefilter.css",this.stylesheetId=this.id+"_style",this.fltsRowCssClass=c.flts_row_css_class||"fltrow",this.enableIcons=c.enable_icons!==!1,this.alternateRows=Boolean(c.alternate_rows),this.hasColWidths=(0,l.isArray)(c.col_widths),this.colWidths=this.hasColWidths?c.col_widths:[],this.fltCssClass=c.flt_css_class||"flt",this.fltMultiCssClass=c.flt_multi_css_class||"flt_multi",this.fltSmallCssClass=c.flt_small_css_class||"flt_s",this.singleFltCssClass=c.single_flt_css_class||"single_flt",this.enterKey=c.enter_key!==!1,this.onBeforeFilter=(0,l.isFn)(c.on_before_filter)?c.on_before_filter:null,this.onAfterFilter=(0,l.isFn)(c.on_after_filter)?c.on_after_filter:null,this.caseSensitive=Boolean(c.case_sensitive),this.hasExactMatchByCol=(0,l.isArray)(c.columns_exact_match),this.exactMatchByCol=this.hasExactMatchByCol?c.columns_exact_match:[],this.exactMatch=Boolean(c.exact_match),this.linkedFilters=Boolean(c.linked_filters),this.disableExcludedOpti
var e=this.getRowsNb(!0);this.validRowsIndex=[];for(var i=this.refRow;i<e;i++){var s=this.tbl.rows[i];this.paging?"true"!==s.getAttribute("validRow")&&null!==s.getAttribute("validRow")||this.validRowsIndex.push(s.rowIndex):this.getRowDisplay(s)!==S.NONE&&this.validRowsIndex.push(s.rowIndex)}return this.validRowsIndex},t.prototype.getFiltersRowIndex=function(){return this.filtersRowIndex},t.prototype.getHeadersRowIndex=function(){return this.headersRow},t.prototype.getStartRowIndex=function(){return this.refRow},t.prototype.getLastRowIndex=function(){var t=this.getRowsNb(!0);return t-1},t.prototype.getHeaderElement=function(t){for(var e=this.gridLayout?this.Mod.gridLayout.headTbl:this.tbl,i=(0,o.tag)(e,"thead"),s=this.headersRow,n=void 0,r=0;r<this.nbCells;r++)if(r===t){0===i.length&&(n=e.rows[s].cells[r]),1===i.length&&(n=i[0].rows[s].cells[r]);break}return n},t.prototype.getHeadersText=function(){for(var t=!(arguments.length<=0||void 0===arguments[0])&&arguments[0],e=[],i=0;i<this.nbCells;i++)if(!(t&&this.hasExtension("colsVisibility")&&this.extension("colsVisibility").isColHidden(i))){var s=this.getHeaderElement(i),n=(0,o.getFirstTextNode)(s);e.push(n)}return e},t.prototype.getFilterType=function(t){var e=this.cfg["col_"+t];return e?e.toLowerCase():S.INPUT},t.prototype.getFilterableRowsNb=function(){return this.getRowsNb(!1)},t.prototype.getValidRowsNb=function(){var t=!(arguments.length<=0||void 0===arguments[0])&&arguments[0];return this.getValidRows(t).length},t.prototype.config=function(){return this.cfg},t}()},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.keyCode=e.targetEvt=e.cancelEvt=e.stopEvt=e.removeEvt=e.addEvt=void 0;var s=i(2);e.addEvt=function(t,e,i,s){t.addEventListener?t.addEventListener(e,i,s):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i},e.removeEvt=function(t,e,i,s){t.detachEvent?t.detachEvent("on"+e,i):t.removeEventListener?t.removeEventListener(e,i,s):t["on"+e]=null},e.stopEvt=function(t){t||(t=s.root.event),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0},e.cancelEvt=function(t){t||(t=s.root.event),t.preventDefault?t.preventDefault():t.returnValue=!1},e.targetEvt=function(t){return t||(t=s.root.event),t.target||t.srcElement},e.keyCode=function(t){return t.charCode?t.charCode:t.keyCode?t.keyCode:t.which?t.which:0}},function(t,e){(function(t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};e.root="object"===("undefined"==typeof self?"undefined":i(self))&&self.self===self&&self||"object"===("undefined"==typeof t?"undefined":i(t))&&t.global===t&&t||void 0}).call(e,function(){return this}())},function(t,e,i){"use strict";function s(){return a.documentElement.classList}Object.defineProperty(e,"__esModule",{value:!0}),e.tag=e.elm=e.createCheckItem=e.createOpt=e.removeClass=e.addClass=e.hasClass=e.createText=e.removeElm=e.createElm=e.getFirstTextNode=e.getText=void 0;var n=i(2),r=i(4),o=i(5),a=n.root.document,l=(e.getText=function(t){return(0,r.isUndef)(t.textContent)?(0,o.trim)(t.innerText):(0,o.trim)(t.textContent)},e.getFirstTextNode=function(t){for(var e=0;e<t.childNodes.length;e++){var i=t.childNodes[e];if(3===i.nodeType)return i.data}},e.createElm=function(){for(var t=arguments.length,e=Array(t),i=0;i<t;i++)e[i]=arguments[i];var s=e[0];if(!(0,r.isString)(s))return null;for(var n=a.createElement(s),o=0;o<e.length;o++){var l=e[o];(0,r.isArray)(l)&&2===l.length&&n.setAttribute(l[0],l[1])}return n}),h=(e.removeElm=function(t){return t.parentNode.removeChild(t)},e.createText=function(t){return a.createTextNode(t)}),c=e.hasClass=function(t,e){return!(0,r.isUndef)(t)&&(s()?t.classList.contains(e):t.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)")))};e.addClass=function(t,e){if(!(0,r.isUndef)(t))return s()?void t.classList.add(e):void(""===t.className?t.className=e:c(t,e)||(t.className+=" "+e))},e.removeClass=function(t,e){if(!(0,r.isUndef)(t)){if(s())return void
value:!0});e.ignoreCase=function(t,e){var i=t.toLowerCase(),s=e.toLowerCase();return i<s?-1:i>s?1:0},e.numSortAsc=function(t,e){return t-e},e.numSortDesc=function(t,e){return e-t}},function(t,e,i){"use strict";function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.CheckList=void 0;var o=i(10),a=i(3),l=i(16),h=i(5),c=i(17),f=i(1),p=i(4),u=i(11),d="Filter options for column {0} cannot be sorted in {1} manner.";e.CheckList=function(t){function e(i){s(this,e);var r=n(this,t.call(this,i,"checkList")),o=r.config;return r.containers=[],r.containerCssClass=o.div_checklist_css_class||"div_checklist",r.filterCssClass=o.checklist_css_class||"flt_checklist",r.itemCssClass=o.checklist_item_css_class||"flt_checklist_item",r.selectedItemCssClass=o.checklist_selected_item_css_class||"flt_checklist_slc_item",r.activateText=o.activate_checklist_text||"Click to load filter data",r.disabledItemCssClass=o.checklist_item_disabled_css_class||"flt_checklist_item_disabled",r.enableResetOption=o.enable_checklist_reset_filter!==!1,r.prfx="chkdiv_",r.isCustom=!1,r.opts=[],r.optsTxt=[],r.excludedOpts=[],r}return r(e,t),e.prototype.optionClick=function(t){var e=(0,f.targetEvt)(t),i=this.tf;this.emitter.emit("filter-focus",i,e),this.setCheckListValues(e),i.filter()},e.prototype.onCheckListClick=function(t){var e=this,i=(0,f.targetEvt)(t);if(this.tf.loadFltOnDemand&&"0"===i.getAttribute("filled")){var s=i.getAttribute("ct"),n=this.containers[s];this.build(s),(0,f.removeEvt)(n,"click",function(t){return e.onCheckListClick(t)})}},e.prototype.init=function(t,e,i){var s=this,n=this.tf,r=e?n.externalFltTgtIds[t]:null,o=(0,a.createElm)("div",["id",this.prfx+t+"_"+n.id],["ct",t],["filled","0"]);o.className=this.containerCssClass,r?(0,a.elm)(r).appendChild(o):i.appendChild(o),this.containers[t]=o,n.fltIds.push(n.prfxFlt+t+"_"+n.id),n.loadFltOnDemand?((0,f.addEvt)(o,"click",function(t){return s.onCheckListClick(t)}),o.appendChild((0,a.createText)(this.activateText))):this.build(t),this.emitter.on(["build-checklist-filter"],function(t,e){return s.build(e)}),this.emitter.on(["select-checklist-options"],function(t,e,i){return s.selectOptions(e,i)}),this.initialized=!0},e.prototype.build=function(t){var e=this.tf;t=parseInt(t,10),this.emitter.emit("before-populating-filter",e,t),this.opts=[],this.optsTxt=[];var i=this.containers[t],s=(0,a.createElm)("ul",["id",e.fltIds[t]],["colIndex",t]);s.className=this.filterCssClass;var n=e.tbl.rows,r=e.getRowsNb(!0),o=e.caseSensitive;this.isCustom=e.isCustomOptions(t);var f=void 0,p=e.getActiveFilterId();e.linkedFilters&&p&&(f=e.getColumnIndexFromFilterId(p));var u=[];e.linkedFilters&&e.disableExcludedOptions&&(this.excludedOpts=[]),i.innerHTML="";for(var g=e.refRow;g<r;g++)if(!e.hasVisibleRows||e.visibleRows.indexOf(g)===-1){var m=n[g].cells,v=m.length;if(v===e.nbCells&&!this.isCustom)for(var b=0;b<v;b++)if(t===b&&(!e.linkedFilters||e.linkedFilters&&e.disableExcludedOptions)||t===b&&e.linkedFilters&&(""===n[g].style.display&&!e.paging||e.paging&&(!f||f===t||f!==t&&e.validRowsIndex.indexOf(g)!==-1))){var y=e.getCellData(m[b]),_=(0,h.matchCase)(y,o);(0,l.has)(this.opts,_,o)||this.opts.push(y);var C=u[b];e.linkedFilters&&e.disableExcludedOptions&&(C||(C=e.getFilteredDataCol(b)),(0,l.has)(C,_,o)||(0,l.has)(this.excludedOpts,_,o)||this.excludedOpts.push(y))}}if(this.isCustom){var x=e.getCustomOptions(t);this.opts=x[0],this.optsTxt=x[1]}if(e.sortSlc&&!this.isCustom&&(o?(this.opts.sort(),this.excludedOpts&&this.excludedOpts.sort()):(this.opts.sort(c.ignoreCase),this.excluded
return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.Help=void 0;var o=i(10),a=i(3),l=i(1),h=i(11),c="https://github.com/koalyptus/TableFilter/wiki/4.-Filter-operators",f="http://koalyptus.github.io/TableFilter/";e.Help=function(t){function e(i){s(this,e);var r=n(this,t.call(this,i,"help")),o=r.config;return r.tgtId=o.help_instructions_target_id||null,r.contTgtId=o.help_instructions_container_target_id||null,r.instrText=o.help_instructions_text?o.help_instructions_text:'Use the filters above each column to filter and limit table data. Advanced searches can be performed by using the following operators: <br /><b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>=</b>, <b>*</b>, <b>!</b>, <b>{</b>, <b>}</b>, <b>||</b>,<b>&amp;&amp;</b>, <b>[empty]</b>, <b>[nonempty]</b>, <b>rgx:</b><br/><a href="'+c+'" target="_blank">Learn more</a><hr/>',r.instrHtml=o.help_instructions_html||null,r.btnText=o.help_instructions_btn_text||"?",r.btnHtml=o.help_instructions_btn_html||null,r.btnCssClass=o.help_instructions_btn_css_class||"helpBtn",r.contCssClass=o.help_instructions_container_css_class||"helpCont",r.btn=null,r.cont=null,r.defaultHtml='<div class="helpFooter"><h4>TableFilter v'+i.version+'</h4><a href="'+f+'" target="_blank">'+f+"</a><br/><span>&copy;2015-"+i.year+' Max Guglielmi</span><div align="center" style="margin-top:8px;"><a href="javascript:void(0);" class="close">Close</a></div></div>',r.prfxHelpSpan="helpSpan_",r.prfxHelpDiv="helpDiv_",r.emitter.on(["init-help"],function(){return r.init()}),r}return r(e,t),e.prototype.init=function(){var t=this;if(!this.initialized){var e=this.tf,i=(0,a.createElm)("span",["id",this.prfxHelpSpan+e.id]),s=(0,a.createElm)("div",["id",this.prfxHelpDiv+e.id]);this.tgtId||e.setToolbar();var n=this.tgtId?(0,a.elm)(this.tgtId):e.rDiv;n.appendChild(i);var r=this.contTgtId?(0,a.elm)(this.contTgtId):i;if(this.btnHtml){i.innerHTML=this.btnHtml;var o=i.firstChild;(0,l.addEvt)(o,"click",function(){return t.toggle()}),r.appendChild(s)}else{r.appendChild(s);var h=(0,a.createElm)("a",["href","javascript:void(0);"]);h.className=this.btnCssClass,h.appendChild((0,a.createText)(this.btnText)),i.appendChild(h),(0,l.addEvt)(h,"click",function(){return t.toggle()})}this.instrHtml?(this.contTgtId&&r.appendChild(s),s.innerHTML=this.instrHtml,this.contTgtId||(s.className=this.contCssClass,(0,l.addEvt)(s,"dblclick",function(){return t.toggle()}))):(s.innerHTML=this.instrText,s.className=this.contCssClass,(0,l.addEvt)(s,"dblclick",function(){return t.toggle()})),s.innerHTML+=this.defaultHtml,(0,l.addEvt)(s,"click",function(){return t.toggle()}),this.cont=s,this.btn=i,this.initialized=!0}},e.prototype.toggle=function(){if(this.enabled!==!1){var t=this.cont.style.display;""===t||t===h.NONE?this.cont.style.display="inline":this.cont.style.display=h.NONE}},e.prototype.destroy=function(){this.initialized&&((0,a.removeElm)(this.btn),this.btn=null,this.cont&&((0,a.removeElm)(this.cont),this.cont=null,this.initialized=!1))},e}(o.Feature)},function(t,e,i){"use strict";function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.AlternateRows=void 0;var o=i(10),a=i(3);e.AlternateRows=function(t){function e(i