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

10 lines
116 KiB
JavaScript
Raw Normal View History

2016-05-08 07:33:19 +02:00
/**
2016-05-15 04:56:12 +02:00
* tablefilter v0.2.26 by Max Guglielmi
* build date: 2016-05-15T02:51:02.828Z
2016-05-08 07:33:19 +02:00
* MIT License
*/
2016-05-15 04:56:12 +02:00
!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=s(a),u=i(5),f=s(u),d=i(4),c=i(6),p=s(c),g=i(7),b=s(g),v=i(2),m=i(8),y=i(9),_=i(12),C=i(13),w=i(14),x=i(15),T=i(18),E=i(19),P=i(20),R=i(21),F=i(22),S=i(23),I=i(24),O=i(25),N=i(26),L=i(11),k=v.root.document;e.TableFilter=function(){function t(){var e=this;n(this,t),this.id=null,this.version="0.2.26",this.year=(new Date).getFullYear(),this.tbl=null,this.startRow=null,this.refRow=null,this.headersRow=null,this.cfg={},this.nbFilterableRows=null,this.nbRows=null,this.nbCells=null,this._hasGrid=!1;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,d.isString)(t)?(e.id=t,e.tbl=h["default"].id(t)):(0,d.isNumber)(t)?e.startRow=t:(0,d.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 m.Emitter,this.refRow=null===this.startRow?2:this.startRow+1;try{this.nbCells=this.getCellsNb(this.refRow)}catch(a){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,d.isString)(l.filters_cell_tag)?l.filters_cell_tag:L.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,d.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,d.isFn)(l.on_before_filter)?l.on_before_filter:null,this.onAfterFilter=(0,d.isFn)(l.on_after_filter)?l.on_after_filter:null,this.caseSensitive=Boolean(
i=!0;break}return i},t.prototype["import"]=function(t,e,i,s){var n=s?s:"script",r=this.isImported(e,n);if(!r){var o=this,l=!1,a=void 0,u=h["default"].tag(k,"head")[0];a="link"===f["default"].lower(n)?h["default"].create("link",["id",t],["type","text/css"],["rel","stylesheet"],["href",e]):h["default"].create("script",["id",t],["type","text/javascript"],["src",e]),a.onload=a.onreadystatechange=function(){l||this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(l=!0,"function"==typeof i&&i.call(null,o))},a.onerror=function(){throw new Error("TableFilter could not load: "+e)},u.appendChild(a)}},t.prototype.hasGrid=function(){return this._hasGrid},t.prototype.getFiltersId=function(){return this.fltIds||[]},t.prototype.getValidRows=function(t){if(!t)return this.validRowsIndex;this.validRowsIndex=[];for(var e=this.refRow;e<this.getRowsNb(!0);e++){var i=this.tbl.rows[e];this.paging?"true"!==i.getAttribute("validRow")&&null!==i.getAttribute("validRow")||this.validRowsIndex.push(i.rowIndex):this.getRowDisplay(i)!==L.NONE&&this.validRowsIndex.push(i.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(){return this.nbRows-1},t.prototype.getHeaderElement=function(t){for(var e=this.gridLayout?this.Mod.gridLayout.headTbl:this.tbl,i=h["default"].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=h["default"].getFirstTextNode(s);e.push(n)}return e},t.prototype.getFilterType=function(t){var e=this.cfg["col_"+t];return e?f["default"].lower(e):L.INPUT},t.prototype.getFilterableRowsNb=function(){return this.getRowsNb(!1)},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(t){return t&&t.__esModule?t:{"default":t}}function n(){return document.documentElement.classList}Object.defineProperty(e,"__esModule",{value:!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(4),l=i(5),a=s(l);e["default"]={getText:function(t){return(0,o.isUndef)(t.textContent)?a["default"].trim(t.innerText):a["default"].trim(t.textContent)},getFirstTextNode:function(t){for(var e=0;e<t.childNodes.length;e++){var i=t.childNodes[e];if(3===i.nodeType)return i.data}},create:function(t){if(t&&""!==t){var e=document.createEle
},e.prototype.addOptions=function(t,e,i,s){var n=this.tf,r=e.value;e.innerHTML="",e=this.addFirstOption(e);for(var o=0;o<this.opts.length;o++)if(""!==this.opts[o]){var l=this.opts[o],a=this.isCustom?this.optsTxt[o]:l,u=!1;i&&n.disableExcludedOptions&&f["default"].has(s,c["default"].matchCase(l,n.matchCase),n.matchCase)&&(u=!0);var d=void 0;d=n.loadFltOnDemand&&r===this.opts[o]&&n.getFilterType(t)===m.SELECT?h["default"].createOpt(a,l,!0):h["default"].createOpt(a,l,!1),u&&(d.disabled=!0),e.appendChild(d)}e.setAttribute("filled","1")},e.prototype.addFirstOption=function(t){var e=this.tf,i=h["default"].createOpt(this.enableSlcResetFilter?e.displayAllText:"","");if(this.enableSlcResetFilter||(i.style.display=m.NONE),t.appendChild(i),e.enableEmptyOption){var s=h["default"].createOpt(e.emptyText,e.emOperator);t.appendChild(s)}if(e.enableNonEmptyOption){var n=h["default"].createOpt(e.nonEmptyText,e.nmOperator);t.appendChild(n)}return t},e.prototype.selectOptions=function(t){var e=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],i=this.tf;if(i.getFilterType(t)===m.MULTIPLE&&0!==e.length){var s=i.getFilterElement(t);[].forEach.call(s.options,function(t){""!==e[0]&&""!==t.value||(t.selected=!1),""!==t.value&&f["default"].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";function s(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(5),r=s(n);e["default"]={has:function(t,e,i){for(var s=void 0===i?!1:i,n=0;n<t.length;n++)if(r["default"].matchCase(t[n].toString(),s)==e)return!0;return!1}}},function(t,e,i){"use strict";function s(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var n=i(5),r=s(n);e["default"]={ignoreCase:function(t,e){var i=r["default"].lower(t),s=r["default"].lower(e);return s>i?-1:i>s?1:0},numSortAsc:function(t,e){return t-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=s(a),u=i(16),f=s(u),d=i(5),c=s(d),p=i(17),g=s(p),b=i(1),v=s(b),m=i(4),y=i(11),_="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=v["default"].target(t)
var e=t.feature("store").getPageLength();""!==e&&(this.resultsPerPageSlc.options[e].selected=!0,this.changeResultsPerPage()),this.emitter.emit("after-reset-page-length",t,e)}},e.prototype.destroy=function(){var t=this,e=this.tf;if(this.initialized){var i=u["default"].id(this.prfxBtnNextSpan+e.id),s=u["default"].id(this.prfxBtnPrevSpan+e.id),n=u["default"].id(this.prfxBtnLastSpan+e.id),r=u["default"].id(this.prfxBtnFirstSpan+e.id),o=u["default"].id(this.prfxPgBeforeSpan+e.id),l=u["default"].id(this.prfxPgAfterSpan+e.id),a=u["default"].id(this.prfxPgSpan+e.id),h=this.evt;this.pagingSlc&&(this.pageSelectorType===b.SELECT?g["default"].remove(this.pagingSlc,"change",h.slcPagesChange):this.pageSelectorType===b.INPUT&&g["default"].remove(this.pagingSlc,"keypress",h._detectKey),u["default"].remove(this.pagingSlc)),i&&(g["default"].remove(i,"click",h.next),u["default"].remove(i)),s&&(g["default"].remove(s,"click",h.prev),u["default"].remove(s)),n&&(g["default"].remove(n,"click",h.last),u["default"].remove(n)),r&&(g["default"].remove(r,"click",h.first),u["default"].remove(r)),o&&u["default"].remove(o),l&&u["default"].remove(l),a&&u["default"].remove(a),this.hasResultsPerPage&&this.removeResultsPerPage(),this.emitter.off(["after-filtering"],function(){return t.resetPagingInfo()}),this.emitter.off(["change-page"],function(e,i){return t.setPage(i)}),this.emitter.off(["change-page-results"],function(e,i){return t.changeResultsPerPage(i)}),this.pagingSlc=null,this.nbPages=0,this.disable(),this.initialized=!1}},e}(a.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.ClearButton=void 0;var l=i(10),a=i(3),h=s(a),u=i(1),f=s(u);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=h["default"].create("span",["id",this.prfxResetSpan+e.id]);this.btnResetTgtId||e.setToolbar();var s=this.btnResetTgtId?h["default"].id(this.btnResetTgtId):e.rDiv;if(s.appendChild(i),this.btnResetHtml){i.innerHTML=this.btnResetHtml;var n=i.firstChild;f["default"].add(n,"click",function(){t.onClick()})}else{var r=h["default"].create("a",["href","javascript:void(0);"]);r.className=e.btnResetCssClass,r.appendChild(h["default"].text(this.btnResetText)),i.appendChild(r),f["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=h["default"].id(this.prfxResetSpan+t.id);e&&h["default"].remove(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