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

10 lines
114 KiB
JavaScript
Raw Normal View History

2016-05-29 12:44:27 +02:00
/**
* tablefilter v0.2.33 by Max Guglielmi
* build date: 2016-05-29T09:43:48.489Z
* 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,l,a=0,h=[];a<s.length;a++)l=s[a],n[l]&&h.push.apply(h,n[l]),n[l]=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){return t&&t.__esModule?t:{"default":t}}function n(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 r="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},o=i(1),l=s(o),a=i(3),h=i(5),c=i(4),p=i(6),u=i(7),f=i(2),d=i(8),g=i(9),m=i(12),v=i(13),b=i(14),y=i(15),_=i(18),C=i(19),w=i(20),x=i(21),E=i(22),T=i(23),F=i(24),P=i(25),S=i(26),R=i(11),I=f.root.document;e.TableFilter=function(){function t(){var e=this;n(this,t),this.id=null,this.version="0.2.33",this.year=(new Date).getFullYear(),this.tbl=null,this.startRow=null,this.refRow=null,this.headersRow=null,this.cfg={},this.nbFilterableRows=0,this.nbCells=null;for(var i=arguments.length,s=Array(i),o=0;i>o;o++)s[o]=arguments[o];if(s.forEach(function(t){"object"===("undefined"==typeof t?"undefined":r(t))&&"TABLE"===t.nodeName?(e.tbl=t,e.id=t.id||"tf_"+(new Date).getTime()+"_"):(0,c.isString)(t)?(e.id=t,e.tbl=(0,a.elm)(t)):(0,c.isNumber)(t)?e.startRow=t:(0,c.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 l=this.cfg;this.emitter=new d.Emitter,this.refRow=null===this.startRow?2:this.startRow+1;try{this.nbCells=this.getCellsNb(this.refRow)}catch(h){this.nbCells=this.getCellsNb(0)}this.basePath=l.base_path||"tablefilter/",this.fltGrid=l.grid!==!1,this.gridLayout=Boolean(l.grid_layout),this.filtersRowIndex=isNaN(l.filters_row_index)?0:l.filters_row_index,this.headersRow=isNaN(l.headers_row_index)?0===this.filtersRowIndex?1:0:l.headers_row_index,this.fltCellTag=(0,c.isString)(l.filters_cell_tag)?l.filters_cell_tag:R.CELL_TAG,this.fltIds=[],this.fltElms=[],this.validRowsIndex=[],this.fltGridEl=null,this.infDiv=null,this.lDiv=null,this.rDiv=null,this.mDiv=null,this.infDivCssClass=l.inf_div_css_class||"inf",this.lDivCssClass=l.left_div_css_class||"ldiv",this.rDivCssClass=l.right_div_css_class||"rdiv",this.mDivCssClass=l.middle_div_css_class||"mdiv",this.contDivCssClass=l.content_div_css_class||"cont",this.stylePath=l.style_path||this.basePath+"style/",this.stylesheet=l.stylesheet||this.stylePath+"tablefilter.css",this.stylesheetId=this.id+"_style",this.fltsRowCssClass=l.flts_row_css_class||"fltrow",this.enableIcons=l.enable_icons!==!1,this.alternateRows=Boolean(l.alternate_rows),this.hasColWidths=(0,c.isArray)(l.col_widths),this.colWidths=this.hasColWidths?l.col_widths:null,this.fltCssClass=l.flt_css_class||"flt",this.fltMultiCssClass=l.flt_multi_css_class||"flt_multi",this.fltSmallCssClass=l.flt_small_css_class||"flt_s",this.singleFltCssClass=l.single_flt_css_class||"single_flt",this.enterKey=l.enter_key!==!1,this.onBeforeFilter=(0,c.isFn)(l.on_before_filter)?l.on_before_filter:null,this.onAfterFilter=(0,c.isFn)(l.on_after_filter)?l.on_after_filter:null,this.caseSensitive=Boolean(l.case_sensitive),this.hasExactMatchByCol=(0,c.isArray)(l.columns_exact
throw new Error("TableFilter could not load: "+e)},c.appendChild(h)}},t.prototype.isInitialized=function(){return this.initialized},t.prototype.getFiltersId=function(){return this.fltIds||[]},t.prototype.getValidRows=function(t){if(!t)return this.validRowsIndex;var e=this.getRowsNb(!0);this.validRowsIndex=[];for(var i=this.refRow;e>i;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)!==R.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,a.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]?!1: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,a.getFirstTextNode)(s);e.push(n)}return e},t.prototype.getFilterType=function(t){var e=this.cfg["col_"+t];return e?e.toLowerCase():R.INPUT},t.prototype.getFilterableRowsNb=function(){return this.getRowsNb(!1)},t.prototype.getValidRowsNb=function(){var t=arguments.length<=0||void 0===arguments[0]?!1: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});var s=i(2);e["default"]={add:function(t,e,i,s){t.addEventListener?t.addEventListener(e,i,s):t.attachEvent?t.attachEvent("on"+e,i):t["on"+e]=i},remove:function(t,e,i,s){t.detachEvent?t.detachEvent("on"+e,i):t.removeEventListener?t.removeEventListener(e,i,s):t["on"+e]=null},stop:function(t){t||(t=s.root.event),t.stopPropagation?t.stopPropagation():t.cancelBubble=!0},cancel:function(t){t||(t=s.root.event),t.preventDefault?t.preventDefault():t.returnValue=!1},target:function(t){return t&&t.target||s.root.event&&s.root.event.srcElement},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 l.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),l=n.root.document,a=(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;t>i;i++)e[i]=arguments[i];var s=e[0];if(!(0,r.isString)(s))return null;for(var n=l.createElement(s),o=0;o<e.length;o++){var a=e[o];(0,r.isArray)(a)&&2===a.length&&n.setAttribute(a[0],a[1])}return n}),h=(e.removeElm=function(t){return t.parentNode.removeChild(t)},e.createText=function(t){return l.createTextNode(t)}),c=e.hasClass=function(t,e){return(0,r.isUndef)(t)?!1:s()?t.classList.contains(e):t.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))};e.addClass=function(t,e){return(0
if(i.getFilterType(t)===d.MULTIPLE&&0!==e.length){var s=i.getFilterElement(t);[].forEach.call(s.options,function(t){""!==e[0]&&""!==t.value||(t.selected=!1),""!==t.value&&(0,h.has)(e,t.value,!0)&&(t.selected=!0)})}},e.prototype.getValues=function(t){var e=this.tf,i=e.getFilterElement(t),s=[];return i.selectedOptions?[].forEach.call(i.selectedOptions,function(t){return s.push(t.value)}):[].forEach.call(i.options,function(t){t.selected&&s.push(t.value)}),s},e.prototype.destroy=function(){var t=this;this.emitter.off(["build-select-filter"],function(e,i,s){return t.build(e,i,s)}),this.emitter.off(["select-options"],function(e,i,s){return t.selectOptions(i,s)})},e}(l.Feature)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.has=void 0;var s=i(5);e.has=function(t,e,i){for(var n=Boolean(i),r=0,o=t.length;o>r;r++)if((0,s.matchCase)(t[r].toString(),n)===e)return!0;return!1}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.ignoreCase=function(t,e){var i=t.toLowerCase(),s=e.toLowerCase();return s>i?-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){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(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 o(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 l=i(10),a=i(3),h=i(16),c=i(5),p=i(17),u=i(1),f=s(u),d=i(4),g=i(11),m="Filter options for column {0} cannot be sorted in {1} manner.";e.CheckList=function(t){function e(i){n(this,e);var s=r(this,t.call(this,i,"checkList")),o=i.config();return s.checkListDiv=[],s.checkListDivCssClass=o.div_checklist_css_class||"div_checklist",s.checkListCssClass=o.checklist_css_class||"flt_checklist",s.checkListItemCssClass=o.checklist_item_css_class||"flt_checklist_item",s.checkListSlcItemCssClass=o.checklist_selected_item_css_class||"flt_checklist_slc_item",s.activateCheckListTxt=o.activate_checklist_text||"Click to load filter data",s.checkListItemDisabledCssClass=o.checklist_item_disabled_css_class||"flt_checklist_item_disabled",s.enableCheckListResetFilter=o.enable_checklist_reset_filter!==!1,s.prfxCheckListDiv="chkdiv_",s.isCustom=null,s.opts=null,s.optsTxt=null,s.excludedOpts=null,s}return o(e,t),e.prototype.onChange=function(t){var e=f["default"].target(t),i=this.tf;this.emitter.emit("filter-focus",i,e),i.filter()},e.prototype.optionClick=function(t){this.setCheckListValues(t.target),this.onChange(t)},e.prototype.onCheckListClick=function(t){var e=this,i=f["default"].target(t);if(this.tf.loadFltOnDemand&&"0"===i.getAttribute("filled")){var s=i.getAttribute("ct"),n=this.checkListDiv[s];this.build(s),f["default"].remove(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.prfxCheckListDiv+t+"_"+n.id],["ct",t],["filled","0"]);o.className=this.checkListDivCssClass,r?((0,a.elm)(r).appendChild(o),n.externalFltEls.push(o)):i.appendChild(o),this.checkListDiv[t]=o,n.fltIds.push(n.prfxFlt+t+"_"+n.id),n.loadFltOnDemand?(f["default"].add(o,"click",function(t){return s.onCheckListClick(t)}),o.appendChild((0,a.createText)(this.activateCheckListTxt))):this.build(t),this.emitter.on(["build-checklist-filter"],function(t,e,i){return s.build(e,i)}),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,i=this.tf;t=parseInt(t,10),this.emitter.emit("before-populating-filter",i,t),this.opt
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.ClearButton=void 0;var l=i(10),a=i(3),h=i(1),c=s(h);e.ClearButton=function(t){function e(i){n(this,e);var s=r(this,t.call(this,i,"btnReset")),o=s.config;return s.btnResetTgtId=o.btn_reset_target_id||null,s.btnResetEl=null,s.btnResetText=o.btn_reset_text||"Reset",s.btnResetTooltip=o.btn_reset_tooltip||"Clear filters",s.btnResetHtml=o.btn_reset_html||(i.enableIcons?'<input type="button" value="" class="'+i.btnResetCssClass+'" title="'+s.btnResetTooltip+'" />':null),s.prfxResetSpan="resetspan_",s}return o(e,t),e.prototype.onClick=function(){this.isEnabled()&&this.tf.clearFilters()},e.prototype.init=function(){var t=this,e=this.tf;if(!this.initialized){var i=(0,a.createElm)("span",["id",this.prfxResetSpan+e.id]);this.btnResetTgtId||e.setToolbar();var s=this.btnResetTgtId?(0,a.elm)(this.btnResetTgtId):e.rDiv;if(s.appendChild(i),this.btnResetHtml){i.innerHTML=this.btnResetHtml;var n=i.firstChild;c["default"].add(n,"click",function(){t.onClick()})}else{var r=(0,a.createElm)("a",["href","javascript:voelm(0);"]);r.className=e.btnResetCssClass,r.appendChild((0,a.createText)(this.btnResetText)),i.appendChild(r),c["default"].add(r,"click",function(){t.onClick()})}this.btnResetEl=i.firstChild,this.initialized=!0}},e.prototype.destroy=function(){var t=this.tf;if(this.initialized){var e=(0,a.elm)(this.prfxResetSpan+t.id);e&&(0,a.removeElm)(e),this.btnResetEl=null,this.initialized=!1}},e}(l.Feature)},function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{"default":t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(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 o(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 l=i(10),a=i(3),h=i(1),c=s(h),p=i(11),u="https://github.com/koalyptus/TableFilter/wiki/4.-Filter-operators",f="http://koalyptus.github.io/TableFilter/";e.Help=function(t){function e(i){n(this,e);var s=r(this,t.call(this,i,"help")),o=s.config;return s.tgtId=o.help_instructions_target_id||null,s.contTgtId=o.help_instructions_container_target_id||null,s.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="'+u+'" target="_blank">Learn more</a><hr/>',s.instrHtml=o.help_instructions_html||null,s.btnText=o.help_instructions_btn_text||"?",s.btnHtml=o.help_instructions_btn_html||null,s.btnCssClass=o.help_instructions_btn_css_class||"helpBtn",s.contCssClass=o.help_instructions_container_css_class||"helpCont",s.btn=null,s.cont=null,s.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>',s.prfxHelpSpan="helpSpan_",s.prfxHelpDiv="helpDiv_",s.emitter.on(["init-help"],function(){return s.init()}),s}return o(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.appe