diff --git a/dist/tablefilter/style/colsVisibility.css b/dist/tablefilter/style/colsVisibility.css index 9418e488..65f090df 100644 --- a/dist/tablefilter/style/colsVisibility.css +++ b/dist/tablefilter/style/colsVisibility.css @@ -1,6 +1,6 @@ /** * tablefilter v0.2.1 by Max Guglielmi - * build date: 2016-03-20T02:48:14.744Z + * build date: 2016-03-20T04:43:36.438Z * MIT License */ span.colVisSpan{text-align:left;}span.colVisSpan a.colVis{display:inline-block;padding:7px 5px 0;font-size:inherit;font-weight:inherit;vertical-align:top}div.colVisCont{position:relative;background:#fff;-webkit-box-shadow:3px 3px 2px #888;-moz-box-shadow:3px 3px 2px #888;box-shadow:3px 3px 2px #888;position:absolute;display:none;border:1px solid #ccc;height:auto;width:250px;background-color:#fff;margin:35px 0 0 -100px;z-index:10000;padding:10px 10px 10px 10px;text-align:left;font-size:12px;}div.colVisCont:after,div.colVisCont:before{bottom:100%;left:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.colVisCont:after{border-color:rgba(255,255,255,0);border-bottom-color:#fff;border-width:10px;margin-left:-10px}div.colVisCont:before{border-color:rgba(255,255,255,0);border-bottom-color:#ccc;border-width:12px;margin-left:-12px}div.colVisCont p{margin:6px auto 6px auto}div.colVisCont a.colVis{display:initial;font-weight:inherit}ul.cols_checklist{padding:0;margin:0;list-style:none;}ul.cols_checklist label{display:block}ul.cols_checklist input{vertical-align:middle;margin:2px 5px 2px 1px}li.cols_checklist_item{padding:4px;margin:0;}li.cols_checklist_item:hover{background-color:#335ea8;color:#fff}.cols_checklist_slc_item{background-color:#335ea8;color:#fff} \ No newline at end of file diff --git a/dist/tablefilter/style/filtersVisibility.css b/dist/tablefilter/style/filtersVisibility.css index 2efc6533..988d8bb2 100644 --- a/dist/tablefilter/style/filtersVisibility.css +++ b/dist/tablefilter/style/filtersVisibility.css @@ -1,6 +1,6 @@ /** * tablefilter v0.2.1 by Max Guglielmi - * build date: 2016-03-20T02:48:14.744Z + * build date: 2016-03-20T04:43:36.438Z * MIT License */ span.expClpFlt a.btnExpClpFlt{width:35px;height:35px;display:inline-block;}span.expClpFlt a.btnExpClpFlt:hover{background-color:#f4f4f4}span.expClpFlt img{padding:8px 11px 11px 11px} \ No newline at end of file diff --git a/dist/tablefilter/style/tablefilter.css b/dist/tablefilter/style/tablefilter.css index 531a38e9..97813fa9 100644 --- a/dist/tablefilter/style/tablefilter.css +++ b/dist/tablefilter/style/tablefilter.css @@ -1,6 +1,6 @@ /** * tablefilter v0.2.1 by Max Guglielmi - * build date: 2016-03-20T02:48:14.744Z + * build date: 2016-03-20T04:43:36.438Z * MIT License */ .activeHeader{background-color:#66afe9 !important;color:#fff !important} diff --git a/dist/tablefilter/style/themes/default/default.css b/dist/tablefilter/style/themes/default/default.css index 78954f05..d1686bc8 100644 --- a/dist/tablefilter/style/themes/default/default.css +++ b/dist/tablefilter/style/themes/default/default.css @@ -1,6 +1,6 @@ /** * tablefilter v0.2.1 by Max Guglielmi - * build date: 2016-03-20T02:48:14.744Z + * build date: 2016-03-20T04:43:36.438Z * MIT License */ table.TF{border-left:1px solid #ccc;border-top:none;border-right:none;border-bottom:none;}table.TF th{background:#ebecee url("images/bg_th.jpg") left top repeat-x;border-bottom:1px solid #d0d0d0;border-right:1px solid #d0d0d0;border-left:1px solid #fff;border-top:1px solid #fff;color:#333}table.TF td{border-bottom:1px dotted #999;padding:5px}.fltrow{background-color:#ebecee !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #666 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #999 !important}input.flt{width:99% !important}.inf{height:$min-height;background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important}input.reset{background:transparent url("images/btn_eraser.gif") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;}.nextPage:hover{background:transparent url("images/btn_over_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important;}.previousPage:hover{background:transparent url("images/btn_over_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;}.firstPage:hover{background:transparent url("images/btn_over_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;}.lastPage:hover{background:transparent url("images/btn_over_last_page.gif") center center no-repeat !important}div.grd_Cont{background-color:#ebecee !important;border:1px solid #ccc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#d5d5d5}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important;}div.grd_headTblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#ebecee url("images/bg_th.jpg") left top repeat-x !important;border-bottom:1px solid #d0d0d0 !important;border-right:1px solid #d0d0d0 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #999 !important}.grd_inf{background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important;border-top:1px solid #d0d0d0 !important}.loader{border:1px solid #999}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#fff}.odd{background-color:#d5d5d5}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#999 !important} \ No newline at end of file diff --git a/dist/tablefilter/style/themes/mytheme/mytheme.css b/dist/tablefilter/style/themes/mytheme/mytheme.css index 2b622efa..9d4688c8 100644 --- a/dist/tablefilter/style/themes/mytheme/mytheme.css +++ b/dist/tablefilter/style/themes/mytheme/mytheme.css @@ -1,6 +1,6 @@ /** * tablefilter v0.2.1 by Max Guglielmi - * build date: 2016-03-20T02:48:14.744Z + * build date: 2016-03-20T04:43:36.438Z * MIT License */ table.TF{border-left:1px dotted #81963b;border-top:none;border-right:0;border-bottom:none;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x;border-bottom:0;border-right:1px dotted #d0d0d0;border-left:0;border-top:0;color:#fff}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px}.fltrow{background-color:#81963b !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #687830 !important}input.flt{width:99% !important}.inf{background:#d8d8d8;height:$min-height}input.reset{width:53px;background:transparent url("images/btn_filter.png") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important}div.grd_Cont{background:#81963b url("images/bg_headers.jpg") left top repeat-x !important;border:1px solid #ccc !important;padding:0 1px 1px 1px !important;}div.grd_Cont .even{background-color:#bccd83}div.grd_Cont .odd{background-color:#fff}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important;}div.grd_tblCont table td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b}div.grd_tblCont table th,div.grd_headTblCont table th{background:transparent url("images/bg_headers.jpg") 0 0 repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;padding:0 4px 0 4px !important;color:#fff !important;height:35px !important}div.grd_headTblCont table td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;background-color:#81963b !important;padding:1px 3px 1px 3px !important}.grd_inf{background-color:#d8d8d8;border-top:1px solid #d0d0d0 !important}.loader{border:0 !important;background:#81963b !important}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#bccd83}.odd{background-color:#fff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#81963b !important} \ No newline at end of file diff --git a/dist/tablefilter/style/themes/skyblue/skyblue.css b/dist/tablefilter/style/themes/skyblue/skyblue.css index 054fd790..fbcf5b4f 100644 --- a/dist/tablefilter/style/themes/skyblue/skyblue.css +++ b/dist/tablefilter/style/themes/skyblue/skyblue.css @@ -1,6 +1,6 @@ /** * tablefilter v0.2.1 by Max Guglielmi - * build date: 2016-03-20T02:48:14.744Z + * build date: 2016-03-20T04:43:36.438Z * MIT License */ table.TF{padding:0;color:#000;border-right:1px solid #a4bed4;border-top:1px solid #a4bed4;border-left:1px solid #a4bed4;border-bottom:0;}table.TF th{margin:0;color:inherit;background:#d1e5fe url("images/bg_skyblue.gif") 0 0 repeat-x;border-color:#fdfdfd #a4bed4 #a4bed4 #fdfdfd;border-width:1px;border-style:solid}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid #a4bed4;border-left:0;border-top:0;border-right:0}.fltrow{background-color:#d1e5fe !important;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4 !important}input.flt{width:99% !important}.inf{background-color:#e3efff !important;border:1px solid #a4bed4;height:$min-height;color:#004a6f}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#ffe4ab url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#ffe4ab url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#ffe4ab url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#ffe4ab url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.activeHeader{background:#ffe4ab !important;border:1px solid #ffb552 !important;color:inherit !important}div.grd_Cont{background-color:#d9eaed !important;border:1px solid #9cc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#e3efff}div.grd_headTblCont{background-color:#d9eaed !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#d9eaed url("images/bg_skyblue.gif") left top repeat-x;border-bottom:1px solid #a4bed4;border-right:1px solid #a4bed4 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #a4bed4 !important;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:#cce2fe;color:#004a6f;border-top:1px solid #9cc !important;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#2d8eef;border:1px solid #cce2fe;border-radius:5px}.even{background-color:#fff}.odd{background-color:#e3efff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ffdc61 !important;color:inherit}.ezSelectedRow{background-color:#ffe4ab !important;color:inherit}.ezActiveCell{background-color:#fff !important;color:#000 !important;font-weight:bold}.ezETSelectedCell{background-color:#fff !important;font-weight:bold;color:#000 !important} \ No newline at end of file diff --git a/dist/tablefilter/tablefilter.js b/dist/tablefilter/tablefilter.js index 5aecc416..098be69f 100644 --- a/dist/tablefilter/tablefilter.js +++ b/dist/tablefilter/tablefilter.js @@ -114,11 +114,6 @@ return /******/ (function(modules) { // webpackBootstrap var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - // Features - - var _event = __webpack_require__(1); var _event2 = _interopRequireDefault(_event); @@ -179,6 +174,9 @@ return /******/ (function(modules) { // webpackBootstrap function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + // Features + + var global = window, doc = global.document; @@ -487,7 +485,7 @@ return /******/ (function(modules) { // webpackBootstrap this.noResults = _types2.default.isObj(f.no_results_message) || Boolean(f.no_results_message); // stateful - this.hasState = _types2.default.isObj(f.state) || Boolean(f.state); + this.state = _types2.default.isObj(f.state) || Boolean(f.state); /*** data types ***/ //defines default date type (european DMY) @@ -638,1986 +636,1926 @@ return /******/ (function(modules) { // webpackBootstrap */ - _createClass(TableFilter, [{ - key: 'init', - value: function init() { - var _this2 = this; + TableFilter.prototype.init = function init() { + var _this2 = this; - if (this._hasGrid) { - return; - } - - var Mod = this.Mod; - var n = this.singleSearchFlt ? 1 : this.nbCells, - inpclass = void 0; - - //loads stylesheet if not imported - this.import(this.stylesheetId, this.stylesheet, null, 'link'); - - //loads theme - if (this.hasThemes) { - this.loadThemes(); - } - - // Instantiate help feature and initialise only if set true - if (!Mod.help) { - Mod.help = new _help.Help(this); - } - if (this.help) { - Mod.help.init(); - } - - if (this.hasState) { - if (!Mod.state) { - Mod.state = new _state.State(this); - } - Mod.state.init(); - } - - if (this.hasPersistence) { - if (!Mod.store) { - Mod.store = new _store.Store(this); - } - Mod.store.init(); - } - - if (this.gridLayout) { - if (!Mod.gridLayout) { - Mod.gridLayout = new _gridLayout.GridLayout(this); - } - Mod.gridLayout.init(); - } - - if (this.loader) { - if (!Mod.loader) { - Mod.loader = new _loader.Loader(this); - } - Mod.loader.init(); - } - - if (this.highlightKeywords) { - Mod.highlightKeyword = new _highlightKeywords.HighlightKeyword(this); - Mod.highlightKeyword.init(); - } - - if (this.popupFilters) { - if (!Mod.popupFilter) { - Mod.popupFilter = new _popupFilter.PopupFilter(this); - } - Mod.popupFilter.init(); - } - - //filters grid is not generated - if (!this.fltGrid) { - this._initNoFilters(); - } else { - var fltrow = this._insertFiltersRow(); - - this.nbFilterableRows = this.getRowsNb(); - this.nbVisibleRows = this.nbFilterableRows; - this.nbRows = this.tbl.rows.length; - - // Generate filters - for (var i = 0; i < n; i++) { - this.emitter.emit('before-filter-init', this, i); - - var fltcell = _dom2.default.create(this.fltCellTag), - col = this.getFilterType(i); - - if (this.singleSearchFlt) { - fltcell.colSpan = this.nbCells; - } - if (!this.gridLayout) { - fltrow.appendChild(fltcell); - } - inpclass = i == n - 1 && this.displayBtn ? this.fltSmallCssClass : this.fltCssClass; - - //only 1 input for single search - if (this.singleSearchFlt) { - col = this.fltTypeInp; - inpclass = this.singleFltCssClass; - } - - //drop-down filters - if (col === this.fltTypeSlc || col === this.fltTypeMulti) { - if (!Mod.dropdown) { - Mod.dropdown = new _dropdown.Dropdown(this); - } - Mod.dropdown.init(i, this.isExternalFlt, fltcell); - } - // checklist - else if (col === this.fltTypeCheckList) { - if (!Mod.checkList) { - Mod.checkList = new _checkList.CheckList(this); - } - Mod.checkList.init(i, this.isExternalFlt, fltcell); - } else { - this._buildInputFilter(i, inpclass, fltcell); - } - - // this adds submit button - if (i == n - 1 && this.displayBtn) { - this._buildSubmitButton(i, fltcell); - } - - this.emitter.emit('after-filter-init', this, i); - } - } //if this.fltGrid - - /* Features */ - if (this.hasVisibleRows) { - this.emitter.on(['after-filtering'], function () { - return _this2.enforceVisibility(); - }); - this.enforceVisibility(); - } - if (this.rowsCounter) { - Mod.rowsCounter = new _rowsCounter.RowsCounter(this); - Mod.rowsCounter.init(); - } - if (this.statusBar) { - Mod.statusBar = new _statusBar.StatusBar(this); - Mod.statusBar.init(); - } - if (this.paging) { - if (!Mod.paging) { - Mod.paging = new _paging.Paging(this); - Mod.paging.init(); - } else { - Mod.paging.reset(); - } - } - if (this.btnReset) { - Mod.clearButton = new _clearButton.ClearButton(this); - Mod.clearButton.init(); - } - - if (this.hasColWidths && !this.gridLayout) { - this.setColWidths(); - } - if (this.alternateRows) { - Mod.alternateRows = new _alternateRows.AlternateRows(this); - Mod.alternateRows.init(); - } - if (this.noResults) { - if (!Mod.noResults) { - Mod.noResults = new _noResults.NoResults(this); - } - Mod.noResults.init(); - } - - this._hasGrid = true; - - if (this.hasPersistence) { - this.resetFilterValues(); - } - - //TF css class is added to table - if (!this.gridLayout) { - _dom2.default.addClass(this.tbl, this.prfxTf); - } - - /* Loads extensions */ - if (this.hasExtensions) { - this.initExtensions(); - } - - // Subscribe to events - if (this.markActiveColumns) { - this.emitter.on(['before-filtering'], function () { - return _this2.clearActiveColumns(); - }); - this.emitter.on(['cell-processed'], function (tf, colIndex) { - return _this2.markActiveColumn(colIndex); - }); - } - if (this.linkedFilters) { - this.emitter.on(['after-filtering'], function () { - return _this2.linkFilters(); - }); - } - - if (this.onFiltersLoaded) { - this.onFiltersLoaded.call(null, this); - } - - this.initialized = true; - this.emitter.emit('initialized', this); + if (this._hasGrid) { + return; } - /** - * Insert filters row at initialization - */ + var Mod = this.Mod; + var n = this.singleSearchFlt ? 1 : this.nbCells, + inpclass = void 0; - }, { - key: '_insertFiltersRow', - value: function _insertFiltersRow() { - if (this.gridLayout) { - return; - } - var fltrow = void 0; + //loads stylesheet if not imported + this.import(this.stylesheetId, this.stylesheet, null, 'link'); - var thead = _dom2.default.tag(this.tbl, 'thead'); - if (thead.length > 0) { - fltrow = thead[0].insertRow(this.filtersRowIndex); - } else { - fltrow = this.tbl.insertRow(this.filtersRowIndex); - } - - fltrow.className = this.fltsRowCssClass; - - if (this.isExternalFlt) { - fltrow.style.display = 'none'; - } - - this.emitter.emit('filters-row-inserted', this, fltrow); - return fltrow; + //loads theme + if (this.hasThemes) { + this.loadThemes(); } - /** - * Initialize filtersless table - */ + // Instantiate help feature and initialise only if set true + if (!Mod.help) { + Mod.help = new _help.Help(this); + } + if (this.help) { + Mod.help.init(); + } - }, { - key: '_initNoFilters', - value: function _initNoFilters() { - if (this.fltGrid) { - return; + if (this.state) { + if (!Mod.state) { + Mod.state = new _state.State(this); } - this.refRow = this.refRow > 0 ? this.refRow - 1 : 0; + Mod.state.init(); + } + + if (this.hasPersistence) { + if (!Mod.store) { + Mod.store = new _store.Store(this); + } + Mod.store.init(); + } + + if (this.gridLayout) { + if (!Mod.gridLayout) { + Mod.gridLayout = new _gridLayout.GridLayout(this); + } + Mod.gridLayout.init(); + } + + if (this.loader) { + if (!Mod.loader) { + Mod.loader = new _loader.Loader(this); + } + Mod.loader.init(); + } + + if (this.highlightKeywords) { + Mod.highlightKeyword = new _highlightKeywords.HighlightKeyword(this); + Mod.highlightKeyword.init(); + } + + if (this.popupFilters) { + if (!Mod.popupFilter) { + Mod.popupFilter = new _popupFilter.PopupFilter(this); + } + Mod.popupFilter.init(); + } + + //filters grid is not generated + if (!this.fltGrid) { + this._initNoFilters(); + } else { + var fltrow = this._insertFiltersRow(); + this.nbFilterableRows = this.getRowsNb(); this.nbVisibleRows = this.nbFilterableRows; - this.nbRows = this.nbFilterableRows + this.refRow; - } + this.nbRows = this.tbl.rows.length; - /** - * Build input filter type - * @param {Number} colIndex Column index - * @param {String} cssClass Css class applied to filter - * @param {DOMElement} container Container DOM element - */ + // Generate filters + for (var i = 0; i < n; i++) { + this.emitter.emit('before-filter-init', this, i); - }, { - key: '_buildInputFilter', - value: function _buildInputFilter(colIndex, cssClass, container) { - var col = this.getFilterType(colIndex); - var externalFltTgtId = this.isExternalFlt ? this.externalFltTgtIds[colIndex] : null; - var inptype = col === this.fltTypeInp ? 'text' : 'hidden'; - var inp = _dom2.default.create(this.fltTypeInp, ['id', this.prfxFlt + colIndex + '_' + this.id], ['type', inptype], ['ct', colIndex]); + var fltcell = _dom2.default.create(this.fltCellTag), + col = this.getFilterType(i); - if (inptype !== 'hidden' && this.watermark) { - inp.setAttribute('placeholder', this.isWatermarkArray ? this.watermark[colIndex] || '' : this.watermark); - } - inp.className = cssClass || this.fltCssClass; - _event2.default.add(inp, 'focus', this.Evt.onInpFocus.bind(this)); - - //filter is appended in custom element - if (externalFltTgtId) { - _dom2.default.id(externalFltTgtId).appendChild(inp); - this.externalFltEls.push(inp); - } else { - container.appendChild(inp); - } - - this.fltIds.push(inp.id); - - _event2.default.add(inp, 'keypress', this.Evt.detectKey.bind(this)); - _event2.default.add(inp, 'keydown', this.Evt.onKeyDown.bind(this)); - _event2.default.add(inp, 'keyup', this.Evt.onKeyUp.bind(this)); - _event2.default.add(inp, 'blur', this.Evt.onInpBlur.bind(this)); - } - - /** - * Build submit button - * @param {Number} colIndex Column index - * @param {DOMElement} container Container DOM element - */ - - }, { - key: '_buildSubmitButton', - value: function _buildSubmitButton(colIndex, container) { - var _this3 = this; - - var externalFltTgtId = this.isExternalFlt ? this.externalFltTgtIds[colIndex] : null; - var btn = _dom2.default.create(this.fltTypeInp, ['id', this.prfxValButton + colIndex + '_' + this.id], ['type', 'button'], ['value', this.btnText]); - btn.className = this.btnCssClass; - - //filter is appended in custom element - if (externalFltTgtId) { - _dom2.default.id(externalFltTgtId).appendChild(btn); - } else { - container.appendChild(btn); - } - - _event2.default.add(btn, 'click', function () { - return _this3.filter(); - }); - } - - /** - * Return a feature instance for a given name - * @param {String} name Name of the feature - * @return {Object} - */ - - }, { - key: 'feature', - value: function feature(name) { - return this.Mod[name]; - } - - /** - * Initialise all the extensions defined in the configuration object - */ - - }, { - key: 'initExtensions', - value: function initExtensions() { - var exts = this.extensions; - // Set config's publicPath dynamically for Webpack... - __webpack_require__.p = this.basePath; - - this.emitter.emit('before-loading-extensions', this); - for (var i = 0, len = exts.length; i < len; i++) { - var ext = exts[i]; - if (!this.ExtRegistry[ext.name]) { - this.loadExtension(ext); + if (this.singleSearchFlt) { + fltcell.colSpan = this.nbCells; } - } - this.emitter.emit('after-loading-extensions', this); - } - - /** - * Load an extension module - * @param {Object} ext Extension config object - */ - - }, { - key: 'loadExtension', - value: function loadExtension(ext) { - var _this4 = this; - - if (!ext || !ext.name) { - return; - } - - var name = ext.name; - var path = ext.path; - var modulePath = void 0; - - if (name && path) { - modulePath = ext.path + name; - } else { - name = name.replace('.js', ''); - modulePath = 'extensions/{}/{}'.replace(/{}/g, name); - } - - // Require pattern for Webpack - __webpack_require__.e/* require */(1, function(__webpack_require__) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(28)("./" + modulePath)]; (function (mod) { - /* eslint-disable */ - var inst = new mod.default(_this4, ext); - /* eslint-enable */ - inst.init(); - _this4.ExtRegistry[name] = inst; - }.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}); - } - - /** - * Get an extension instance - * @param {String} name Name of the extension - * @return {Object} Extension instance - */ - - }, { - key: 'extension', - value: function extension(name) { - return this.ExtRegistry[name]; - } - - /** - * Check passed extension name exists - * @param {String} name Name of the extension - * @return {Boolean} - */ - - }, { - key: 'hasExtension', - value: function hasExtension(name) { - return !_types2.default.isEmpty(this.ExtRegistry[name]); - } - - /** - * Destroy all the extensions defined in the configuration object - */ - - }, { - key: 'destroyExtensions', - value: function destroyExtensions() { - var exts = this.extensions; - - for (var i = 0, len = exts.length; i < len; i++) { - var ext = exts[i]; - var extInstance = this.ExtRegistry[ext.name]; - if (extInstance) { - extInstance.destroy(); - this.ExtRegistry[ext.name] = null; + if (!this.gridLayout) { + fltrow.appendChild(fltcell); } - } - } + inpclass = i == n - 1 && this.displayBtn ? this.fltSmallCssClass : this.fltCssClass; - /** - * Load themes defined in the configuration object - */ + //only 1 input for single search + if (this.singleSearchFlt) { + col = this.fltTypeInp; + inpclass = this.singleFltCssClass; + } - }, { - key: 'loadThemes', - value: function loadThemes() { - var themes = this.themes; - this.emitter.emit('before-loading-themes', this); - - //Default theme config - if (this.enableDefaultTheme) { - var defaultTheme = { name: 'default' }; - this.themes.push(defaultTheme); - } - if (_types2.default.isArray(themes)) { - for (var i = 0, len = themes.length; i < len; i++) { - var theme = themes[i]; - var name = theme.name; - var path = theme.path; - var styleId = this.prfxTf + name; - if (name && !path) { - path = this.themesPath + name + '/' + name + '.css'; - } else if (!name && theme.path) { - name = 'theme{0}'.replace('{0}', i); - } - - if (!this.isImported(path, 'link')) { - this.import(styleId, path, null, 'link'); + //drop-down filters + if (col === this.fltTypeSlc || col === this.fltTypeMulti) { + if (!Mod.dropdown) { + Mod.dropdown = new _dropdown.Dropdown(this); } + Mod.dropdown.init(i, this.isExternalFlt, fltcell); } - } - - //Some elements need to be overriden for default theme - //Reset button - this.btnResetText = null; - this.btnResetHtml = ''; - - //Paging buttons - this.btnPrevPageHtml = ''; - this.btnNextPageHtml = ''; - this.btnFirstPageHtml = ''; - this.btnLastPageHtml = ''; - - //Loader - this.loader = true; - this.loaderHtml = '
'; - this.loaderText = null; - - this.emitter.emit('after-loading-themes', this); - } - - /** - * Return stylesheet DOM element for a given theme name - * @return {DOMElement} stylesheet element - */ - - }, { - key: 'getStylesheet', - value: function getStylesheet() { - var name = arguments.length <= 0 || arguments[0] === undefined ? 'default' : arguments[0]; - - return _dom2.default.id(this.prfxTf + name); - } - - /** - * Destroy filter grid - */ - - }, { - key: 'destroy', - value: function destroy() { - var _this5 = this; - - if (!this._hasGrid) { - return; - } - var rows = this.tbl.rows, - Mod = this.Mod, - emitter = this.emitter; - - if (this.isExternalFlt && !this.popupFilters) { - this.removeExternalFlts(); - } - if (this.infDiv) { - this.removeToolbar(); - } - if (this.markActiveColumns) { - this.clearActiveColumns(); - emitter.off(['before-filtering'], function () { - return _this5.clearActiveColumns(); - }); - emitter.off(['cell-processed'], function (tf, colIndex) { - return _this5.markActiveColumn(colIndex); - }); - } - if (this.hasExtensions) { - this.destroyExtensions(); - } - - this.validateAllRows(); - - if (this.fltGrid && !this.gridLayout) { - this.fltGridEl = rows[this.filtersRowIndex]; - this.tbl.deleteRow(this.filtersRowIndex); - } - - // broadcast destroy event - emitter.emit('destroy', this); - - // Destroy modules - // TODO: subcribe modules to destroy event instead - Object.keys(Mod).forEach(function (key) { - var feature = Mod[key]; - if (feature && _types2.default.isFn(feature.destroy)) { - feature.destroy(); - } - }); - - // unsubscribe to events - if (this.hasVisibleRows) { - emitter.off(['after-filtering'], function () { - return _this5.enforceVisibility(); - }); - } - if (this.linkedFilters) { - emitter.off(['after-filtering'], function () { - return _this5.linkFilters(); - }); - } - - _dom2.default.removeClass(this.tbl, this.prfxTf); - this.nbHiddenRows = 0; - this.validRowsIndex = []; - this.fltIds = []; - this.activeFlt = null; - this._hasGrid = false; - this.initialized = false; - } - - /** - * Generate container element for paging, reset button, rows counter etc. - */ - - }, { - key: 'setToolbar', - value: function setToolbar() { - if (this.infDiv) { - return; - } - - /*** container div ***/ - var infdiv = _dom2.default.create('div', ['id', this.prfxInfDiv + this.id]); - infdiv.className = this.infDivCssClass; - - //custom container - if (this.toolBarTgtId) { - _dom2.default.id(this.toolBarTgtId).appendChild(infdiv); - } - //grid-layout - else if (this.gridLayout) { - var gridLayout = this.Mod.gridLayout; - gridLayout.tblMainCont.appendChild(infdiv); - infdiv.className = gridLayout.gridInfDivCssClass; - } - //default location: just above the table - else { - var cont = _dom2.default.create('caption'); - cont.appendChild(infdiv); - this.tbl.insertBefore(cont, this.tbl.firstChild); - } - this.infDiv = _dom2.default.id(this.prfxInfDiv + this.id); - - /*** left div containing rows # displayer ***/ - var ldiv = _dom2.default.create('div', ['id', this.prfxLDiv + this.id]); - ldiv.className = this.lDivCssClass; - infdiv.appendChild(ldiv); - this.lDiv = _dom2.default.id(this.prfxLDiv + this.id); - - /*** right div containing reset button - + nb results per page select ***/ - var rdiv = _dom2.default.create('div', ['id', this.prfxRDiv + this.id]); - rdiv.className = this.rDivCssClass; - infdiv.appendChild(rdiv); - this.rDiv = _dom2.default.id(this.prfxRDiv + this.id); - - /*** mid div containing paging elements ***/ - var mdiv = _dom2.default.create('div', ['id', this.prfxMDiv + this.id]); - mdiv.className = this.mDivCssClass; - infdiv.appendChild(mdiv); - this.mDiv = _dom2.default.id(this.prfxMDiv + this.id); - - // emit help initialisation only if undefined - if (_types2.default.isUndef(this.help)) { - this.emitter.emit('init-help', this); - } - } - - /** - * Remove toolbar container element - */ - - }, { - key: 'removeToolbar', - value: function removeToolbar() { - if (!this.infDiv) { - return; - } - _dom2.default.remove(this.infDiv); - this.infDiv = null; - - var tbl = this.tbl; - var captions = _dom2.default.tag(tbl, 'caption'); - if (captions.length > 0) { - [].forEach.call(captions, function (elm) { - return tbl.removeChild(elm); - }); - } - } - - /** - * Remove all the external column filters - */ - - }, { - key: 'removeExternalFlts', - value: function removeExternalFlts() { - if (!this.isExternalFlt) { - return; - } - var ids = this.externalFltTgtIds, - len = ids.length; - for (var ct = 0; ct < len; ct++) { - var externalFltTgtId = ids[ct], - externalFlt = _dom2.default.id(externalFltTgtId); - if (externalFlt) { - externalFlt.innerHTML = ''; - } - } - } - - /** - * Check if given column implements a filter with custom options - * @param {Number} colIndex Column's index - * @return {Boolean} - */ - - }, { - key: 'isCustomOptions', - value: function isCustomOptions(colIndex) { - return this.hasCustomOptions && this.customOptions.cols.indexOf(colIndex) != -1; - } - - /** - * Returns an array [[value0, value1 ...],[text0, text1 ...]] with the - * custom options values and texts - * @param {Number} colIndex Column's index - * @return {Array} - */ - - }, { - key: 'getCustomOptions', - value: function getCustomOptions(colIndex) { - if (_types2.default.isEmpty(colIndex) || !this.isCustomOptions(colIndex)) { - return; - } - - var customOptions = this.customOptions; - var cols = customOptions.cols; - var optTxt = [], - optArray = []; - var index = cols.indexOf(colIndex); - var slcValues = customOptions.values[index]; - var slcTexts = customOptions.texts[index]; - var slcSort = customOptions.sorts[index]; - - for (var r = 0, len = slcValues.length; r < len; r++) { - optArray.push(slcValues[r]); - if (slcTexts[r]) { - optTxt.push(slcTexts[r]); - } else { - optTxt.push(slcValues[r]); - } - } - if (slcSort) { - optArray.sort(); - optTxt.sort(); - } - return [optArray, optTxt]; - } - - /** - * Reset persisted filter values - */ - - }, { - key: 'resetFilterValues', - value: function resetFilterValues() { - var _this6 = this; - - if (!this.rememberGridValues) { - return; - } - - var storeValues = this.Mod.store.getFilterValues(); - storeValues.forEach(function (val, idx) { - if (val !== ' ') { - _this6.setFilterValue(idx, val); - } - }); - this.filter(); - } - - /** - * Filter the table by retrieving the data from each cell in every single - * row and comparing it to the search term for current column. A row is - * hidden when all the search terms are not found in inspected row. - */ - - }, { - key: 'filter', - value: function filter() { - if (!this.fltGrid || !this._hasGrid) { - return; - } - //invoke onbefore callback - if (this.onBeforeFilter) { - this.onBeforeFilter.call(null, this); - } - this.emitter.emit('before-filtering', this); - - var row = this.tbl.rows, - hiddenrows = 0; - - this.validRowsIndex = []; - // search args re-init - var searchArgs = this.getFiltersValue(); - - var numCellData, nbFormat; - var re_le = new RegExp(this.leOperator), - re_ge = new RegExp(this.geOperator), - re_l = new RegExp(this.lwOperator), - re_g = new RegExp(this.grOperator), - re_d = new RegExp(this.dfOperator), - re_lk = new RegExp(_string2.default.rgxEsc(this.lkOperator)), - re_eq = new RegExp(this.eqOperator), - re_st = new RegExp(this.stOperator), - re_en = new RegExp(this.enOperator), - - // re_an = new RegExp(this.anOperator), - // re_cr = new RegExp(this.curExp), - re_em = this.emOperator, - re_nm = this.nmOperator, - re_re = new RegExp(_string2.default.rgxEsc(this.rgxOperator)); - - //keyword highlighting - function highlight(str, ok, cell) { - /*jshint validthis:true */ - if (this.highlightKeywords && ok) { - str = str.replace(re_lk, ''); - str = str.replace(re_eq, ''); - str = str.replace(re_st, ''); - str = str.replace(re_en, ''); - var w = str; - if (re_le.test(str) || re_ge.test(str) || re_l.test(str) || re_g.test(str) || re_d.test(str)) { - w = _dom2.default.getText(cell); - } - if (w !== '') { - this.emitter.emit('highlight-keyword', this, cell, w); - } - } - } - - //looks for search argument in current row - function hasArg(sA, cellData, j) { - /*jshint validthis:true */ - sA = _string2.default.matchCase(sA, this.caseSensitive); - - var occurence = void 0, - removeNbFormat = _helpers2.default.removeNbFormat; - - //Search arg operator tests - var hasLO = re_l.test(sA), - hasLE = re_le.test(sA), - hasGR = re_g.test(sA), - hasGE = re_ge.test(sA), - hasDF = re_d.test(sA), - hasEQ = re_eq.test(sA), - hasLK = re_lk.test(sA), - - // hasAN = re_an.test(sA), - hasST = re_st.test(sA), - hasEN = re_en.test(sA), - hasEM = re_em === sA, - hasNM = re_nm === sA, - hasRE = re_re.test(sA); - - //Search arg dates tests - var isLDate = hasLO && _date2.default.isValid(sA.replace(re_l, ''), dtType); - var isLEDate = hasLE && _date2.default.isValid(sA.replace(re_le, ''), dtType); - var isGDate = hasGR && _date2.default.isValid(sA.replace(re_g, ''), dtType); - var isGEDate = hasGE && _date2.default.isValid(sA.replace(re_ge, ''), dtType); - var isDFDate = hasDF && _date2.default.isValid(sA.replace(re_d, ''), dtType); - var isEQDate = hasEQ && _date2.default.isValid(sA.replace(re_eq, ''), dtType); - - var dte1 = void 0, - dte2 = void 0; - //dates - if (_date2.default.isValid(cellData, dtType)) { - dte1 = _date2.default.format(cellData, dtType); - // lower date - if (isLDate) { - dte2 = _date2.default.format(sA.replace(re_l, ''), dtType); - occurence = dte1 < dte2; - } - // lower equal date - else if (isLEDate) { - dte2 = _date2.default.format(sA.replace(re_le, ''), dtType); - occurence = dte1 <= dte2; + // checklist + else if (col === this.fltTypeCheckList) { + if (!Mod.checkList) { + Mod.checkList = new _checkList.CheckList(this); } - // greater equal date - else if (isGEDate) { - dte2 = _date2.default.format(sA.replace(re_ge, ''), dtType); - occurence = dte1 >= dte2; - } - // greater date - else if (isGDate) { - dte2 = _date2.default.format(sA.replace(re_g, ''), dtType); - occurence = dte1 > dte2; - } - // different date - else if (isDFDate) { - dte2 = _date2.default.format(sA.replace(re_d, ''), dtType); - occurence = dte1.toString() != dte2.toString(); - } - // equal date - else if (isEQDate) { - dte2 = _date2.default.format(sA.replace(re_eq, ''), dtType); - occurence = dte1.toString() == dte2.toString(); - } - // searched keyword with * operator doesn't have to be a date - else if (re_lk.test(sA)) { - // like date - occurence = _string2.default.contains(sA.replace(re_lk, ''), cellData, false, this.caseSensitive); - } else if (_date2.default.isValid(sA, dtType)) { - dte2 = _date2.default.format(sA, dtType); - occurence = dte1.toString() === dte2.toString(); - } - //empty - else if (hasEM) { - occurence = _string2.default.isEmpty(cellData); - } - //non-empty - else if (hasNM) { - occurence = !_string2.default.isEmpty(cellData); - } else { - occurence = _string2.default.contains(sA, cellData, this.isExactMatch(j), this.caseSensitive); - } - } else { - //first numbers need to be formated - if (this.hasColNbFormat && this.colNbFormat[j]) { - numCellData = removeNbFormat(cellData, this.colNbFormat[j]); - nbFormat = this.colNbFormat[j]; + Mod.checkList.init(i, this.isExternalFlt, fltcell); } else { - if (this.thousandsSeparator === ',' && this.decimalSeparator === '.') { - numCellData = removeNbFormat(cellData, 'us'); - nbFormat = 'us'; - } else { - numCellData = removeNbFormat(cellData, 'eu'); - nbFormat = 'eu'; - } + this._buildInputFilter(i, inpclass, fltcell); } - // first checks if there is any operator (<,>,<=,>=,!,*,=,{,}, - // rgx:) - // lower equal - if (hasLE) { - occurence = numCellData <= removeNbFormat(sA.replace(re_le, ''), nbFormat); + // this adds submit button + if (i == n - 1 && this.displayBtn) { + this._buildSubmitButton(i, fltcell); + } + + this.emitter.emit('after-filter-init', this, i); + } + } //if this.fltGrid + + /* Features */ + if (this.hasVisibleRows) { + this.emitter.on(['after-filtering'], function () { + return _this2.enforceVisibility(); + }); + this.enforceVisibility(); + } + if (this.rowsCounter) { + Mod.rowsCounter = new _rowsCounter.RowsCounter(this); + Mod.rowsCounter.init(); + } + if (this.statusBar) { + Mod.statusBar = new _statusBar.StatusBar(this); + Mod.statusBar.init(); + } + if (this.paging) { + if (!Mod.paging) { + Mod.paging = new _paging.Paging(this); + Mod.paging.init(); + } else { + Mod.paging.reset(); + } + } + if (this.btnReset) { + Mod.clearButton = new _clearButton.ClearButton(this); + Mod.clearButton.init(); + } + + if (this.hasColWidths && !this.gridLayout) { + this.setColWidths(); + } + if (this.alternateRows) { + Mod.alternateRows = new _alternateRows.AlternateRows(this); + Mod.alternateRows.init(); + } + if (this.noResults) { + if (!Mod.noResults) { + Mod.noResults = new _noResults.NoResults(this); + } + Mod.noResults.init(); + } + + this._hasGrid = true; + + if (this.hasPersistence) { + this.resetFilterValues(); + } + + //TF css class is added to table + if (!this.gridLayout) { + _dom2.default.addClass(this.tbl, this.prfxTf); + } + + /* Loads extensions */ + if (this.hasExtensions) { + this.initExtensions(); + } + + // Subscribe to events + if (this.markActiveColumns) { + this.emitter.on(['before-filtering'], function () { + return _this2.clearActiveColumns(); + }); + this.emitter.on(['cell-processed'], function (tf, colIndex) { + return _this2.markActiveColumn(colIndex); + }); + } + if (this.linkedFilters) { + this.emitter.on(['after-filtering'], function () { + return _this2.linkFilters(); + }); + } + + if (this.onFiltersLoaded) { + this.onFiltersLoaded.call(null, this); + } + + this.initialized = true; + this.emitter.emit('initialized', this); + }; + + /** + * Insert filters row at initialization + */ + + + TableFilter.prototype._insertFiltersRow = function _insertFiltersRow() { + if (this.gridLayout) { + return; + } + var fltrow = void 0; + + var thead = _dom2.default.tag(this.tbl, 'thead'); + if (thead.length > 0) { + fltrow = thead[0].insertRow(this.filtersRowIndex); + } else { + fltrow = this.tbl.insertRow(this.filtersRowIndex); + } + + fltrow.className = this.fltsRowCssClass; + + if (this.isExternalFlt) { + fltrow.style.display = 'none'; + } + + this.emitter.emit('filters-row-inserted', this, fltrow); + return fltrow; + }; + + /** + * Initialize filtersless table + */ + + + TableFilter.prototype._initNoFilters = function _initNoFilters() { + if (this.fltGrid) { + return; + } + this.refRow = this.refRow > 0 ? this.refRow - 1 : 0; + this.nbFilterableRows = this.getRowsNb(); + this.nbVisibleRows = this.nbFilterableRows; + this.nbRows = this.nbFilterableRows + this.refRow; + }; + + /** + * Build input filter type + * @param {Number} colIndex Column index + * @param {String} cssClass Css class applied to filter + * @param {DOMElement} container Container DOM element + */ + + + TableFilter.prototype._buildInputFilter = function _buildInputFilter(colIndex, cssClass, container) { + var col = this.getFilterType(colIndex); + var externalFltTgtId = this.isExternalFlt ? this.externalFltTgtIds[colIndex] : null; + var inptype = col === this.fltTypeInp ? 'text' : 'hidden'; + var inp = _dom2.default.create(this.fltTypeInp, ['id', this.prfxFlt + colIndex + '_' + this.id], ['type', inptype], ['ct', colIndex]); + + if (inptype !== 'hidden' && this.watermark) { + inp.setAttribute('placeholder', this.isWatermarkArray ? this.watermark[colIndex] || '' : this.watermark); + } + inp.className = cssClass || this.fltCssClass; + _event2.default.add(inp, 'focus', this.Evt.onInpFocus.bind(this)); + + //filter is appended in custom element + if (externalFltTgtId) { + _dom2.default.id(externalFltTgtId).appendChild(inp); + this.externalFltEls.push(inp); + } else { + container.appendChild(inp); + } + + this.fltIds.push(inp.id); + + _event2.default.add(inp, 'keypress', this.Evt.detectKey.bind(this)); + _event2.default.add(inp, 'keydown', this.Evt.onKeyDown.bind(this)); + _event2.default.add(inp, 'keyup', this.Evt.onKeyUp.bind(this)); + _event2.default.add(inp, 'blur', this.Evt.onInpBlur.bind(this)); + }; + + /** + * Build submit button + * @param {Number} colIndex Column index + * @param {DOMElement} container Container DOM element + */ + + + TableFilter.prototype._buildSubmitButton = function _buildSubmitButton(colIndex, container) { + var _this3 = this; + + var externalFltTgtId = this.isExternalFlt ? this.externalFltTgtIds[colIndex] : null; + var btn = _dom2.default.create(this.fltTypeInp, ['id', this.prfxValButton + colIndex + '_' + this.id], ['type', 'button'], ['value', this.btnText]); + btn.className = this.btnCssClass; + + //filter is appended in custom element + if (externalFltTgtId) { + _dom2.default.id(externalFltTgtId).appendChild(btn); + } else { + container.appendChild(btn); + } + + _event2.default.add(btn, 'click', function () { + return _this3.filter(); + }); + }; + + /** + * Return a feature instance for a given name + * @param {String} name Name of the feature + * @return {Object} + */ + + + TableFilter.prototype.feature = function feature(name) { + return this.Mod[name]; + }; + + /** + * Initialise all the extensions defined in the configuration object + */ + + + TableFilter.prototype.initExtensions = function initExtensions() { + var exts = this.extensions; + // Set config's publicPath dynamically for Webpack... + __webpack_require__.p = this.basePath; + + this.emitter.emit('before-loading-extensions', this); + for (var i = 0, len = exts.length; i < len; i++) { + var ext = exts[i]; + if (!this.ExtRegistry[ext.name]) { + this.loadExtension(ext); + } + } + this.emitter.emit('after-loading-extensions', this); + }; + + /** + * Load an extension module + * @param {Object} ext Extension config object + */ + + + TableFilter.prototype.loadExtension = function loadExtension(ext) { + var _this4 = this; + + if (!ext || !ext.name) { + return; + } + + var name = ext.name; + var path = ext.path; + var modulePath = void 0; + + if (name && path) { + modulePath = ext.path + name; + } else { + name = name.replace('.js', ''); + modulePath = 'extensions/{}/{}'.replace(/{}/g, name); + } + + // Require pattern for Webpack + __webpack_require__.e/* require */(1, function(__webpack_require__) { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(28)("./" + modulePath)]; (function (mod) { + /* eslint-disable */ + var inst = new mod.default(_this4, ext); + /* eslint-enable */ + inst.init(); + _this4.ExtRegistry[name] = inst; + }.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}); + }; + + /** + * Get an extension instance + * @param {String} name Name of the extension + * @return {Object} Extension instance + */ + + + TableFilter.prototype.extension = function extension(name) { + return this.ExtRegistry[name]; + }; + + /** + * Check passed extension name exists + * @param {String} name Name of the extension + * @return {Boolean} + */ + + + TableFilter.prototype.hasExtension = function hasExtension(name) { + return !_types2.default.isEmpty(this.ExtRegistry[name]); + }; + + /** + * Destroy all the extensions defined in the configuration object + */ + + + TableFilter.prototype.destroyExtensions = function destroyExtensions() { + var exts = this.extensions; + + for (var i = 0, len = exts.length; i < len; i++) { + var ext = exts[i]; + var extInstance = this.ExtRegistry[ext.name]; + if (extInstance) { + extInstance.destroy(); + this.ExtRegistry[ext.name] = null; + } + } + }; + + /** + * Load themes defined in the configuration object + */ + + + TableFilter.prototype.loadThemes = function loadThemes() { + var themes = this.themes; + this.emitter.emit('before-loading-themes', this); + + //Default theme config + if (this.enableDefaultTheme) { + var defaultTheme = { name: 'default' }; + this.themes.push(defaultTheme); + } + if (_types2.default.isArray(themes)) { + for (var i = 0, len = themes.length; i < len; i++) { + var theme = themes[i]; + var name = theme.name; + var path = theme.path; + var styleId = this.prfxTf + name; + if (name && !path) { + path = this.themesPath + name + '/' + name + '.css'; + } else if (!name && theme.path) { + name = 'theme{0}'.replace('{0}', i); + } + + if (!this.isImported(path, 'link')) { + this.import(styleId, path, null, 'link'); + } + } + } + + //Some elements need to be overriden for default theme + //Reset button + this.btnResetText = null; + this.btnResetHtml = ''; + + //Paging buttons + this.btnPrevPageHtml = ''; + this.btnNextPageHtml = ''; + this.btnFirstPageHtml = ''; + this.btnLastPageHtml = ''; + + //Loader + this.loader = true; + this.loaderHtml = '
'; + this.loaderText = null; + + this.emitter.emit('after-loading-themes', this); + }; + + /** + * Return stylesheet DOM element for a given theme name + * @return {DOMElement} stylesheet element + */ + + + TableFilter.prototype.getStylesheet = function getStylesheet() { + var name = arguments.length <= 0 || arguments[0] === undefined ? 'default' : arguments[0]; + + return _dom2.default.id(this.prfxTf + name); + }; + + /** + * Destroy filter grid + */ + + + TableFilter.prototype.destroy = function destroy() { + var _this5 = this; + + if (!this._hasGrid) { + return; + } + var rows = this.tbl.rows, + Mod = this.Mod, + emitter = this.emitter; + + if (this.isExternalFlt && !this.popupFilters) { + this.removeExternalFlts(); + } + if (this.infDiv) { + this.removeToolbar(); + } + if (this.markActiveColumns) { + this.clearActiveColumns(); + emitter.off(['before-filtering'], function () { + return _this5.clearActiveColumns(); + }); + emitter.off(['cell-processed'], function (tf, colIndex) { + return _this5.markActiveColumn(colIndex); + }); + } + if (this.hasExtensions) { + this.destroyExtensions(); + } + + this.validateAllRows(); + + if (this.fltGrid && !this.gridLayout) { + this.fltGridEl = rows[this.filtersRowIndex]; + this.tbl.deleteRow(this.filtersRowIndex); + } + + // broadcast destroy event + emitter.emit('destroy', this); + + // Destroy modules + // TODO: subcribe modules to destroy event instead + Object.keys(Mod).forEach(function (key) { + var feature = Mod[key]; + if (feature && _types2.default.isFn(feature.destroy)) { + feature.destroy(); + } + }); + + // unsubscribe to events + if (this.hasVisibleRows) { + emitter.off(['after-filtering'], function () { + return _this5.enforceVisibility(); + }); + } + if (this.linkedFilters) { + emitter.off(['after-filtering'], function () { + return _this5.linkFilters(); + }); + } + + _dom2.default.removeClass(this.tbl, this.prfxTf); + this.nbHiddenRows = 0; + this.validRowsIndex = []; + this.fltIds = []; + this.activeFlt = null; + this._hasGrid = false; + this.initialized = false; + }; + + /** + * Generate container element for paging, reset button, rows counter etc. + */ + + + TableFilter.prototype.setToolbar = function setToolbar() { + if (this.infDiv) { + return; + } + + /*** container div ***/ + var infdiv = _dom2.default.create('div', ['id', this.prfxInfDiv + this.id]); + infdiv.className = this.infDivCssClass; + + //custom container + if (this.toolBarTgtId) { + _dom2.default.id(this.toolBarTgtId).appendChild(infdiv); + } + //grid-layout + else if (this.gridLayout) { + var gridLayout = this.Mod.gridLayout; + gridLayout.tblMainCont.appendChild(infdiv); + infdiv.className = gridLayout.gridInfDivCssClass; + } + //default location: just above the table + else { + var cont = _dom2.default.create('caption'); + cont.appendChild(infdiv); + this.tbl.insertBefore(cont, this.tbl.firstChild); + } + this.infDiv = _dom2.default.id(this.prfxInfDiv + this.id); + + /*** left div containing rows # displayer ***/ + var ldiv = _dom2.default.create('div', ['id', this.prfxLDiv + this.id]); + ldiv.className = this.lDivCssClass; + infdiv.appendChild(ldiv); + this.lDiv = _dom2.default.id(this.prfxLDiv + this.id); + + /*** right div containing reset button + + nb results per page select ***/ + var rdiv = _dom2.default.create('div', ['id', this.prfxRDiv + this.id]); + rdiv.className = this.rDivCssClass; + infdiv.appendChild(rdiv); + this.rDiv = _dom2.default.id(this.prfxRDiv + this.id); + + /*** mid div containing paging elements ***/ + var mdiv = _dom2.default.create('div', ['id', this.prfxMDiv + this.id]); + mdiv.className = this.mDivCssClass; + infdiv.appendChild(mdiv); + this.mDiv = _dom2.default.id(this.prfxMDiv + this.id); + + // emit help initialisation only if undefined + if (_types2.default.isUndef(this.help)) { + this.emitter.emit('init-help', this); + } + }; + + /** + * Remove toolbar container element + */ + + + TableFilter.prototype.removeToolbar = function removeToolbar() { + if (!this.infDiv) { + return; + } + _dom2.default.remove(this.infDiv); + this.infDiv = null; + + var tbl = this.tbl; + var captions = _dom2.default.tag(tbl, 'caption'); + if (captions.length > 0) { + [].forEach.call(captions, function (elm) { + return tbl.removeChild(elm); + }); + } + }; + + /** + * Remove all the external column filters + */ + + + TableFilter.prototype.removeExternalFlts = function removeExternalFlts() { + if (!this.isExternalFlt) { + return; + } + var ids = this.externalFltTgtIds, + len = ids.length; + for (var ct = 0; ct < len; ct++) { + var externalFltTgtId = ids[ct], + externalFlt = _dom2.default.id(externalFltTgtId); + if (externalFlt) { + externalFlt.innerHTML = ''; + } + } + }; + + /** + * Check if given column implements a filter with custom options + * @param {Number} colIndex Column's index + * @return {Boolean} + */ + + + TableFilter.prototype.isCustomOptions = function isCustomOptions(colIndex) { + return this.hasCustomOptions && this.customOptions.cols.indexOf(colIndex) != -1; + }; + + /** + * Returns an array [[value0, value1 ...],[text0, text1 ...]] with the + * custom options values and texts + * @param {Number} colIndex Column's index + * @return {Array} + */ + + + TableFilter.prototype.getCustomOptions = function getCustomOptions(colIndex) { + if (_types2.default.isEmpty(colIndex) || !this.isCustomOptions(colIndex)) { + return; + } + + var customOptions = this.customOptions; + var cols = customOptions.cols; + var optTxt = [], + optArray = []; + var index = cols.indexOf(colIndex); + var slcValues = customOptions.values[index]; + var slcTexts = customOptions.texts[index]; + var slcSort = customOptions.sorts[index]; + + for (var r = 0, len = slcValues.length; r < len; r++) { + optArray.push(slcValues[r]); + if (slcTexts[r]) { + optTxt.push(slcTexts[r]); + } else { + optTxt.push(slcValues[r]); + } + } + if (slcSort) { + optArray.sort(); + optTxt.sort(); + } + return [optArray, optTxt]; + }; + + /** + * Reset persisted filter values + */ + + + TableFilter.prototype.resetFilterValues = function resetFilterValues() { + var _this6 = this; + + if (!this.rememberGridValues) { + return; + } + + var storeValues = this.Mod.store.getFilterValues(); + storeValues.forEach(function (val, idx) { + if (val !== ' ') { + _this6.setFilterValue(idx, val); + } + }); + this.filter(); + }; + + /** + * Filter the table by retrieving the data from each cell in every single + * row and comparing it to the search term for current column. A row is + * hidden when all the search terms are not found in inspected row. + */ + + + TableFilter.prototype.filter = function filter() { + if (!this.fltGrid || !this._hasGrid) { + return; + } + //invoke onbefore callback + if (this.onBeforeFilter) { + this.onBeforeFilter.call(null, this); + } + this.emitter.emit('before-filtering', this); + + var row = this.tbl.rows, + hiddenrows = 0; + + this.validRowsIndex = []; + // search args re-init + var searchArgs = this.getFiltersValue(); + + var numCellData, nbFormat; + var re_le = new RegExp(this.leOperator), + re_ge = new RegExp(this.geOperator), + re_l = new RegExp(this.lwOperator), + re_g = new RegExp(this.grOperator), + re_d = new RegExp(this.dfOperator), + re_lk = new RegExp(_string2.default.rgxEsc(this.lkOperator)), + re_eq = new RegExp(this.eqOperator), + re_st = new RegExp(this.stOperator), + re_en = new RegExp(this.enOperator), + + // re_an = new RegExp(this.anOperator), + // re_cr = new RegExp(this.curExp), + re_em = this.emOperator, + re_nm = this.nmOperator, + re_re = new RegExp(_string2.default.rgxEsc(this.rgxOperator)); + + //keyword highlighting + function highlight(str, ok, cell) { + /*jshint validthis:true */ + if (this.highlightKeywords && ok) { + str = str.replace(re_lk, ''); + str = str.replace(re_eq, ''); + str = str.replace(re_st, ''); + str = str.replace(re_en, ''); + var w = str; + if (re_le.test(str) || re_ge.test(str) || re_l.test(str) || re_g.test(str) || re_d.test(str)) { + w = _dom2.default.getText(cell); + } + if (w !== '') { + this.emitter.emit('highlight-keyword', this, cell, w); + } + } + } + + //looks for search argument in current row + function hasArg(sA, cellData, j) { + /*jshint validthis:true */ + sA = _string2.default.matchCase(sA, this.caseSensitive); + + var occurence = void 0, + removeNbFormat = _helpers2.default.removeNbFormat; + + //Search arg operator tests + var hasLO = re_l.test(sA), + hasLE = re_le.test(sA), + hasGR = re_g.test(sA), + hasGE = re_ge.test(sA), + hasDF = re_d.test(sA), + hasEQ = re_eq.test(sA), + hasLK = re_lk.test(sA), + + // hasAN = re_an.test(sA), + hasST = re_st.test(sA), + hasEN = re_en.test(sA), + hasEM = re_em === sA, + hasNM = re_nm === sA, + hasRE = re_re.test(sA); + + //Search arg dates tests + var isLDate = hasLO && _date2.default.isValid(sA.replace(re_l, ''), dtType); + var isLEDate = hasLE && _date2.default.isValid(sA.replace(re_le, ''), dtType); + var isGDate = hasGR && _date2.default.isValid(sA.replace(re_g, ''), dtType); + var isGEDate = hasGE && _date2.default.isValid(sA.replace(re_ge, ''), dtType); + var isDFDate = hasDF && _date2.default.isValid(sA.replace(re_d, ''), dtType); + var isEQDate = hasEQ && _date2.default.isValid(sA.replace(re_eq, ''), dtType); + + var dte1 = void 0, + dte2 = void 0; + //dates + if (_date2.default.isValid(cellData, dtType)) { + dte1 = _date2.default.format(cellData, dtType); + // lower date + if (isLDate) { + dte2 = _date2.default.format(sA.replace(re_l, ''), dtType); + occurence = dte1 < dte2; + } + // lower equal date + else if (isLEDate) { + dte2 = _date2.default.format(sA.replace(re_le, ''), dtType); + occurence = dte1 <= dte2; } - //greater equal - else if (hasGE) { - occurence = numCellData >= removeNbFormat(sA.replace(re_ge, ''), nbFormat); + // greater equal date + else if (isGEDate) { + dte2 = _date2.default.format(sA.replace(re_ge, ''), dtType); + occurence = dte1 >= dte2; } - //lower - else if (hasLO) { - occurence = numCellData < removeNbFormat(sA.replace(re_l, ''), nbFormat); + // greater date + else if (isGDate) { + dte2 = _date2.default.format(sA.replace(re_g, ''), dtType); + occurence = dte1 > dte2; } - //greater - else if (hasGR) { - occurence = numCellData > removeNbFormat(sA.replace(re_g, ''), nbFormat); + // different date + else if (isDFDate) { + dte2 = _date2.default.format(sA.replace(re_d, ''), dtType); + occurence = dte1.toString() != dte2.toString(); } - //different - else if (hasDF) { - occurence = _string2.default.contains(sA.replace(re_d, ''), cellData, false, this.caseSensitive) ? false : true; + // equal date + else if (isEQDate) { + dte2 = _date2.default.format(sA.replace(re_eq, ''), dtType); + occurence = dte1.toString() == dte2.toString(); } - //like - else if (hasLK) { + // searched keyword with * operator doesn't have to be a date + else if (re_lk.test(sA)) { + // like date occurence = _string2.default.contains(sA.replace(re_lk, ''), cellData, false, this.caseSensitive); + } else if (_date2.default.isValid(sA, dtType)) { + dte2 = _date2.default.format(sA, dtType); + occurence = dte1.toString() === dte2.toString(); } - //equal - else if (hasEQ) { - occurence = _string2.default.contains(sA.replace(re_eq, ''), cellData, true, this.caseSensitive); + //empty + else if (hasEM) { + occurence = _string2.default.isEmpty(cellData); } - //starts with - else if (hasST) { - occurence = cellData.indexOf(sA.replace(re_st, '')) === 0 ? true : false; + //non-empty + else if (hasNM) { + occurence = !_string2.default.isEmpty(cellData); + } else { + occurence = _string2.default.contains(sA, cellData, this.isExactMatch(j), this.caseSensitive); } - //ends with - else if (hasEN) { - var searchArg = sA.replace(re_en, ''); - occurence = cellData.lastIndexOf(searchArg, cellData.length - 1) === cellData.length - 1 - (searchArg.length - 1) && cellData.lastIndexOf(searchArg, cellData.length - 1) > -1 ? true : false; + } else { + //first numbers need to be formated + if (this.hasColNbFormat && this.colNbFormat[j]) { + numCellData = removeNbFormat(cellData, this.colNbFormat[j]); + nbFormat = this.colNbFormat[j]; + } else { + if (this.thousandsSeparator === ',' && this.decimalSeparator === '.') { + numCellData = removeNbFormat(cellData, 'us'); + nbFormat = 'us'; + } else { + numCellData = removeNbFormat(cellData, 'eu'); + nbFormat = 'eu'; + } + } + + // first checks if there is any operator (<,>,<=,>=,!,*,=,{,}, + // rgx:) + // lower equal + if (hasLE) { + occurence = numCellData <= removeNbFormat(sA.replace(re_le, ''), nbFormat); + } + //greater equal + else if (hasGE) { + occurence = numCellData >= removeNbFormat(sA.replace(re_ge, ''), nbFormat); + } + //lower + else if (hasLO) { + occurence = numCellData < removeNbFormat(sA.replace(re_l, ''), nbFormat); + } + //greater + else if (hasGR) { + occurence = numCellData > removeNbFormat(sA.replace(re_g, ''), nbFormat); + } + //different + else if (hasDF) { + occurence = _string2.default.contains(sA.replace(re_d, ''), cellData, false, this.caseSensitive) ? false : true; + } + //like + else if (hasLK) { + occurence = _string2.default.contains(sA.replace(re_lk, ''), cellData, false, this.caseSensitive); + } + //equal + else if (hasEQ) { + occurence = _string2.default.contains(sA.replace(re_eq, ''), cellData, true, this.caseSensitive); + } + //starts with + else if (hasST) { + occurence = cellData.indexOf(sA.replace(re_st, '')) === 0 ? true : false; + } + //ends with + else if (hasEN) { + var searchArg = sA.replace(re_en, ''); + occurence = cellData.lastIndexOf(searchArg, cellData.length - 1) === cellData.length - 1 - (searchArg.length - 1) && cellData.lastIndexOf(searchArg, cellData.length - 1) > -1 ? true : false; + } + //empty + else if (hasEM) { + occurence = _string2.default.isEmpty(cellData); } - //empty - else if (hasEM) { - occurence = _string2.default.isEmpty(cellData); + //non-empty + else if (hasNM) { + occurence = !_string2.default.isEmpty(cellData); } - //non-empty - else if (hasNM) { - occurence = !_string2.default.isEmpty(cellData); - } - //regexp - else if (hasRE) { - //in case regexp fires an exception - try { - //operator is removed - var srchArg = sA.replace(re_re, ''); - var rgx = new RegExp(srchArg); - occurence = rgx.test(cellData); - } catch (e) { - occurence = false; - } - } else { - occurence = _string2.default.contains(sA, cellData, this.isExactMatch(j), this.caseSensitive); + //regexp + else if (hasRE) { + //in case regexp fires an exception + try { + //operator is removed + var srchArg = sA.replace(re_re, ''); + var rgx = new RegExp(srchArg); + occurence = rgx.test(cellData); + } catch (e) { + occurence = false; } - } //else - return occurence; - } //fn + } else { + occurence = _string2.default.contains(sA, cellData, this.isExactMatch(j), this.caseSensitive); + } + } //else + return occurence; + } //fn - for (var k = this.refRow; k < this.nbRows; k++) { - // already filtered rows display re-init - row[k].style.display = ''; + for (var k = this.refRow; k < this.nbRows; k++) { + // already filtered rows display re-init + row[k].style.display = ''; - var cell = row[k].cells, - nchilds = cell.length; + var cell = row[k].cells, + nchilds = cell.length; - // checks if row has exact cell # - if (nchilds !== this.nbCells) { + // checks if row has exact cell # + if (nchilds !== this.nbCells) { + continue; + } + + var occurence = [], + isRowValid = true, + + //only for single filter search + singleFltRowValid = false; + + // this loop retrieves cell data + for (var j = 0; j < nchilds; j++) { + //searched keyword + var sA = searchArgs[this.singleSearchFlt ? 0 : j]; + var dtType = this.hasColDateType ? this.colDateType[j] : this.defaultDateType; + + if (sA === '') { continue; } - var occurence = [], - isRowValid = true, + var cellData = _string2.default.matchCase(this.getCellData(cell[j]), this.caseSensitive); - //only for single filter search - singleFltRowValid = false; + //multiple search parameter operator || + var sAOrSplit = sA.toString().split(this.orOperator), + //multiple search || parameter boolean + hasMultiOrSA = sAOrSplit.length > 1, + + //multiple search parameter operator && + sAAndSplit = sA.toString().split(this.anOperator), + + //multiple search && parameter boolean + hasMultiAndSA = sAAndSplit.length > 1; + + //detect operators or array query + if (_types2.default.isArray(sA) || hasMultiOrSA || hasMultiAndSA) { + var cS = void 0, + s = void 0, + occur = false; + if (_types2.default.isArray(sA)) { + s = sA; + } else { + s = hasMultiOrSA ? sAOrSplit : sAAndSplit; + } + // TODO: improve clarity/readability of this block + for (var w = 0, len = s.length; w < len; w++) { + cS = _string2.default.trim(s[w]); + occur = hasArg.call(this, cS, cellData, j); + highlight.call(this, cS, occur, cell[j]); + if (hasMultiOrSA && occur || hasMultiAndSA && !occur) { + break; + } + if (_types2.default.isArray(sA) && occur) { + break; + } + } + occurence[j] = occur; + } + //single search parameter + else { + occurence[j] = hasArg.call(this, _string2.default.trim(sA), cellData, j); + highlight.call(this, sA, occurence[j], cell[j]); + } //else single param + + if (!occurence[j]) { + isRowValid = false; + } + if (this.singleSearchFlt && occurence[j]) { + singleFltRowValid = true; + } + + this.emitter.emit('cell-processed', this, j, cell[j]); + } //for j + + if (this.singleSearchFlt && singleFltRowValid) { + isRowValid = true; + } + + if (!isRowValid) { + this.validateRow(k, false); + hiddenrows++; + } else { + this.validateRow(k, true); + } + + this.emitter.emit('row-processed', this, k, this.validRowsIndex.length, isRowValid); + } // for k + + this.nbVisibleRows = this.validRowsIndex.length; + this.nbHiddenRows = hiddenrows; + + //invokes onafterfilter callback + if (this.onAfterFilter) { + this.onAfterFilter.call(null, this); + } + + this.emitter.emit('after-filtering', this, searchArgs); + }; + + /** + * Return the data of a specified column + * @param {Number} colIndex Column index + * @param {Boolean} includeHeaders Optional: include headers row + * @param {Boolean} num Optional: return unformatted number + * @param {Array} exclude Optional: list of row indexes to be excluded + * @return {Array} Flat list of data for a column + */ + + + TableFilter.prototype.getColValues = function getColValues(colIndex) { + var includeHeaders = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + var num = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; + var exclude = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; + + if (!this.fltGrid) { + return; + } + var row = this.tbl.rows, + colValues = []; + + if (includeHeaders) { + colValues.push(this.getHeadersText()[colIndex]); + } + + for (var i = this.refRow; i < this.nbRows; i++) { + var isExludedRow = false; + // checks if current row index appears in exclude array + if (exclude.length > 0) { + isExludedRow = exclude.indexOf(i) != -1; + } + var cell = row[i].cells, + nchilds = cell.length; + + // checks if row has exact cell # and is not excluded + if (nchilds === this.nbCells && !isExludedRow) { // this loop retrieves cell data for (var j = 0; j < nchilds; j++) { - //searched keyword - var sA = searchArgs[this.singleSearchFlt ? 0 : j]; - var dtType = this.hasColDateType ? this.colDateType[j] : this.defaultDateType; - - if (sA === '') { + if (j != colIndex || row[i].style.display !== '') { continue; } - - var cellData = _string2.default.matchCase(this.getCellData(cell[j]), this.caseSensitive); - - //multiple search parameter operator || - var sAOrSplit = sA.toString().split(this.orOperator), - - //multiple search || parameter boolean - hasMultiOrSA = sAOrSplit.length > 1, - - //multiple search parameter operator && - sAAndSplit = sA.toString().split(this.anOperator), - - //multiple search && parameter boolean - hasMultiAndSA = sAAndSplit.length > 1; - - //detect operators or array query - if (_types2.default.isArray(sA) || hasMultiOrSA || hasMultiAndSA) { - var cS = void 0, - s = void 0, - occur = false; - if (_types2.default.isArray(sA)) { - s = sA; - } else { - s = hasMultiOrSA ? sAOrSplit : sAAndSplit; - } - // TODO: improve clarity/readability of this block - for (var w = 0, len = s.length; w < len; w++) { - cS = _string2.default.trim(s[w]); - occur = hasArg.call(this, cS, cellData, j); - highlight.call(this, cS, occur, cell[j]); - if (hasMultiOrSA && occur || hasMultiAndSA && !occur) { - break; - } - if (_types2.default.isArray(sA) && occur) { - break; - } - } - occurence[j] = occur; - } - //single search parameter - else { - occurence[j] = hasArg.call(this, _string2.default.trim(sA), cellData, j); - highlight.call(this, sA, occurence[j], cell[j]); - } //else single param - - if (!occurence[j]) { - isRowValid = false; - } - if (this.singleSearchFlt && occurence[j]) { - singleFltRowValid = true; - } - - this.emitter.emit('cell-processed', this, j, cell[j]); - } //for j - - if (this.singleSearchFlt && singleFltRowValid) { - isRowValid = true; + var cellData = this.getCellData(cell[j]), + nbFormat = this.colNbFormat ? this.colNbFormat[colIndex] : null, + data = num ? _helpers2.default.removeNbFormat(cellData, nbFormat) : cellData; + colValues.push(data); } - - if (!isRowValid) { - this.validateRow(k, false); - hiddenrows++; - } else { - this.validateRow(k, true); - } - - this.emitter.emit('row-processed', this, k, this.validRowsIndex.length, isRowValid); - } // for k - - this.nbVisibleRows = this.validRowsIndex.length; - this.nbHiddenRows = hiddenrows; - - //invokes onafterfilter callback - if (this.onAfterFilter) { - this.onAfterFilter.call(null, this); } + } + return colValues; + }; - this.emitter.emit('after-filtering', this, searchArgs); + /** + * Return the filter's value of a specified column + * @param {Number} index Column index + * @return {String} Filter value + */ + + + TableFilter.prototype.getFilterValue = function getFilterValue(index) { + if (!this.fltGrid) { + return; + } + var fltValue = '', + fltValues = [], + flt = this.getFilterElement(index); + if (!flt) { + return ''; } - /** - * Return the data of a specified column - * @param {Number} colIndex Column index - * @param {Boolean} includeHeaders Optional: include headers row - * @param {Boolean} num Optional: return unformatted number - * @param {Array} exclude Optional: list of row indexes to be excluded - * @return {Array} Flat list of data for a column - */ - - }, { - key: 'getColValues', - value: function getColValues(colIndex) { - var includeHeaders = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - var num = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; - var exclude = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3]; - - if (!this.fltGrid) { - return; - } - var row = this.tbl.rows, - colValues = []; - - if (includeHeaders) { - colValues.push(this.getHeadersText()[colIndex]); - } - - for (var i = this.refRow; i < this.nbRows; i++) { - var isExludedRow = false; - // checks if current row index appears in exclude array - if (exclude.length > 0) { - isExludedRow = exclude.indexOf(i) != -1; - } - var cell = row[i].cells, - nchilds = cell.length; - - // checks if row has exact cell # and is not excluded - if (nchilds === this.nbCells && !isExludedRow) { - // this loop retrieves cell data - for (var j = 0; j < nchilds; j++) { - if (j != colIndex || row[i].style.display !== '') { - continue; - } - var cellData = this.getCellData(cell[j]), - nbFormat = this.colNbFormat ? this.colNbFormat[colIndex] : null, - data = num ? _helpers2.default.removeNbFormat(cellData, nbFormat) : cellData; - colValues.push(data); + var fltColType = this.getFilterType(index); + if (fltColType !== this.fltTypeMulti && fltColType !== this.fltTypeCheckList) { + fltValue = flt.value; + } + //mutiple select + else if (fltColType === this.fltTypeMulti) { + // TODO: extract a method in dropdown module from below + for (var j = 0, len = flt.options.length; j < len; j++) { + if (flt.options[j].selected) { + fltValues.push(flt.options[j].value); } } + //return empty string if collection is empty + fltValue = fltValues.length > 0 ? fltValues : ''; } - return colValues; - } - - /** - * Return the filter's value of a specified column - * @param {Number} index Column index - * @return {String} Filter value - */ - - }, { - key: 'getFilterValue', - value: function getFilterValue(index) { - if (!this.fltGrid) { - return; - } - var fltValue = '', - fltValues = [], - flt = this.getFilterElement(index); - if (!flt) { - return ''; - } - - var fltColType = this.getFilterType(index); - if (fltColType !== this.fltTypeMulti && fltColType !== this.fltTypeCheckList) { - fltValue = flt.value; - } - //mutiple select - else if (fltColType === this.fltTypeMulti) { - // TODO: extract a method in dropdown module from below - for (var j = 0, len = flt.options.length; j < len; j++) { - if (flt.options[j].selected) { - fltValues.push(flt.options[j].value); - } + //checklist + else if (fltColType === this.fltTypeCheckList) { + // TODO: extract a method in checklist module from below + if (flt.getAttribute('value') !== null) { + fltValues = flt.getAttribute('value'); + //removes last operator || + fltValues = fltValues.substr(0, fltValues.length - 3); + //convert || separated values into array + fltValues = fltValues.split(' ' + this.orOperator + ' '); } //return empty string if collection is empty fltValue = fltValues.length > 0 ? fltValues : ''; } - //checklist - else if (fltColType === this.fltTypeCheckList) { - // TODO: extract a method in checklist module from below - if (flt.getAttribute('value') !== null) { - fltValues = flt.getAttribute('value'); - //removes last operator || - fltValues = fltValues.substr(0, fltValues.length - 3); - //convert || separated values into array - fltValues = fltValues.split(' ' + this.orOperator + ' '); - } - //return empty string if collection is empty - fltValue = fltValues.length > 0 ? fltValues : ''; - } - //return an empty string if collection contains a single empty string - if (_types2.default.isArray(fltValue) && fltValue.length === 1 && fltValue[0] === '') { - fltValue = ''; - } - return fltValue; + //return an empty string if collection contains a single empty string + if (_types2.default.isArray(fltValue) && fltValue.length === 1 && fltValue[0] === '') { + fltValue = ''; } + return fltValue; + }; - /** - * Return the filters' values - * @return {Array} List of filters' values - */ + /** + * Return the filters' values + * @return {Array} List of filters' values + */ - }, { - key: 'getFiltersValue', - value: function getFiltersValue() { - if (!this.fltGrid) { - return; - } - var searchArgs = []; - for (var i = 0, len = this.fltIds.length; i < len; i++) { - var fltValue = this.getFilterValue(i); - if (_types2.default.isArray(fltValue)) { - searchArgs.push(fltValue); - } else { - searchArgs.push(_string2.default.trim(fltValue)); - } - } - return searchArgs; + + TableFilter.prototype.getFiltersValue = function getFiltersValue() { + if (!this.fltGrid) { + return; } - - /** - * Return the ID of the filter of a specified column - * @param {Number} index Column's index - * @return {String} ID of the filter element - */ - - }, { - key: 'getFilterId', - value: function getFilterId(index) { - if (!this.fltGrid) { - return; - } - return this.fltIds[index]; - } - - /** - * Return the list of ids of filters matching a specified type. - * Note: hidden filters are also returned - * - * @param {String} type Filter type string ('input', 'select', 'multiple', - * 'checklist') - * @param {Boolean} bool If true returns columns indexes instead of IDs - * @return {[type]} List of element IDs or column indexes - */ - - }, { - key: 'getFiltersByType', - value: function getFiltersByType(type, bool) { - if (!this.fltGrid) { - return; - } - var arr = []; - for (var i = 0, len = this.fltIds.length; i < len; i++) { - var fltType = this.getFilterType(i); - if (fltType === _string2.default.lower(type)) { - var a = bool ? i : this.fltIds[i]; - arr.push(a); - } - } - return arr; - } - - /** - * Return the filter's DOM element for a given column - * @param {Number} index Column's index - * @return {DOMElement} - */ - - }, { - key: 'getFilterElement', - value: function getFilterElement(index) { - var fltId = this.fltIds[index]; - return _dom2.default.id(fltId); - } - - /** - * Return the number of cells for a given row index - * @param {Number} rowIndex Index of the row - * @return {Number} Number of cells - */ - - }, { - key: 'getCellsNb', - value: function getCellsNb() { - var rowIndex = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; - - var tr = this.tbl.rows[rowIndex]; - return tr.cells.length; - } - - /** - * Return the number of filterable rows starting from reference row if - * defined - * @param {Boolean} includeHeaders Include the headers row - * @return {Number} Number of filterable rows - */ - - }, { - key: 'getRowsNb', - value: function getRowsNb(includeHeaders) { - var s = _types2.default.isUndef(this.refRow) ? 0 : this.refRow, - ntrs = this.tbl.rows.length; - if (includeHeaders) { - s = 0; - } - return parseInt(ntrs - s, 10); - } - - /** - * Return the data of a given cell - * @param {DOMElement} cell Cell's DOM object - * @return {String} - */ - - }, { - key: 'getCellData', - value: function getCellData(cell) { - var idx = cell.cellIndex; - //Check for customCellData callback - if (this.customCellData && this.customCellDataCols.indexOf(idx) != -1) { - return this.customCellData.call(null, this, cell, idx); + var searchArgs = []; + for (var i = 0, len = this.fltIds.length; i < len; i++) { + var fltValue = this.getFilterValue(i); + if (_types2.default.isArray(fltValue)) { + searchArgs.push(fltValue); } else { - return _dom2.default.getText(cell); + searchArgs.push(_string2.default.trim(fltValue)); } } + return searchArgs; + }; - /** - * Return the table data with following format: - * [ - * [rowIndex, [value0, value1...]], - * [rowIndex, [value0, value1...]] - * ] - * @param {Boolean} includeHeaders Optional: include headers row - * @param {Boolean} excludeHiddenCols Optional: exclude hidden columns - * @return {Array} - * - * TODO: provide an API returning data in JSON format - */ + /** + * Return the ID of the filter of a specified column + * @param {Number} index Column's index + * @return {String} ID of the filter element + */ - }, { - key: 'getTableData', - value: function getTableData() { - var includeHeaders = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; - var excludeHiddenCols = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - var rows = this.tbl.rows; - var tblData = []; - if (includeHeaders) { - var headers = this.getHeadersText(excludeHiddenCols); - tblData.push([this.getHeadersRowIndex(), headers]); - } - for (var k = this.refRow; k < this.nbRows; k++) { - var rowData = [k, []]; - var cells = rows[k].cells; - for (var j = 0, len = cells.length; j < len; j++) { - if (excludeHiddenCols && this.hasExtension('colsVisibility')) { - if (this.extension('colsVisibility').isColHidden(j)) { - continue; - } - } - var cellData = this.getCellData(cells[j]); - rowData[1].push(cellData); - } - tblData.push(rowData); - } - return tblData; + TableFilter.prototype.getFilterId = function getFilterId(index) { + if (!this.fltGrid) { + return; } + return this.fltIds[index]; + }; - /** - * Return the filtered data with following format: - * [ - * [rowIndex, [value0, value1...]], - * [rowIndex, [value0, value1...]] - * ] - * @param {Boolean} includeHeaders Optional: include headers row - * @param {Boolean} excludeHiddenCols Optional: exclude hidden columns - * @return {Array} - * - * TODO: provide an API returning data in JSON format - */ + /** + * Return the list of ids of filters matching a specified type. + * Note: hidden filters are also returned + * + * @param {String} type Filter type string ('input', 'select', 'multiple', + * 'checklist') + * @param {Boolean} bool If true returns columns indexes instead of IDs + * @return {[type]} List of element IDs or column indexes + */ - }, { - key: 'getFilteredData', - value: function getFilteredData() { - var includeHeaders = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; - var excludeHiddenCols = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - if (!this.validRowsIndex) { - return []; - } - var rows = this.tbl.rows, - filteredData = []; - if (includeHeaders) { - var headers = this.getHeadersText(excludeHiddenCols); - filteredData.push([this.getHeadersRowIndex(), headers]); - } - - var validRows = this.getValidRows(true); - for (var i = 0; i < validRows.length; i++) { - var rData = [this.validRowsIndex[i], []], - cells = rows[this.validRowsIndex[i]].cells; - for (var k = 0; k < cells.length; k++) { - if (excludeHiddenCols && this.hasExtension('colsVisibility')) { - if (this.extension('colsVisibility').isColHidden(k)) { - continue; - } - } - var cellData = this.getCellData(cells[k]); - rData[1].push(cellData); - } - filteredData.push(rData); - } - return filteredData; + TableFilter.prototype.getFiltersByType = function getFiltersByType(type, bool) { + if (!this.fltGrid) { + return; } - - /** - * Return the filtered data for a given column index - * @param {Number} colIndex Colmun's index - * @param {Boolean} includeHeaders Optional: include headers row - * @return {Array} Flat list of values ['val0','val1','val2'...] - * - * TODO: provide an API returning data in JSON format - */ - - }, { - key: 'getFilteredDataCol', - value: function getFilteredDataCol(colIndex) { - var includeHeaders = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - - if (_types2.default.isUndef(colIndex)) { - return []; - } - var data = this.getFilteredData(), - colData = []; - if (includeHeaders) { - colData.push(this.getHeadersText()[colIndex]); - } - for (var i = 0, len = data.length; i < len; i++) { - var r = data[i], - - //cols values of current row - d = r[1], - - //data of searched column - c = d[colIndex]; - colData.push(c); - } - return colData; - } - - /** - * Get the display value of a row - * @param {RowElement} row DOM element of the row - * @return {String} Usually 'none' or '' - */ - - }, { - key: 'getRowDisplay', - value: function getRowDisplay(row) { - if (!_types2.default.isObj(row)) { - return null; - } - return row.style.display; - } - - /** - * Validate/invalidate row by setting the 'validRow' attribute on the row - * @param {Number} rowIndex Index of the row - * @param {Boolean} isValid - */ - - }, { - key: 'validateRow', - value: function validateRow(rowIndex, isValid) { - var row = this.tbl.rows[rowIndex]; - if (!row || typeof isValid !== 'boolean') { - return; - } - - // always visible rows are valid - if (this.hasVisibleRows && this.visibleRows.indexOf(rowIndex) !== -1) { - isValid = true; - } - - var displayFlag = isValid ? '' : 'none', - validFlag = isValid ? 'true' : 'false'; - row.style.display = displayFlag; - - if (this.paging) { - row.setAttribute('validRow', validFlag); - } - - if (isValid) { - if (this.validRowsIndex.indexOf(rowIndex) === -1) { - this.validRowsIndex.push(rowIndex); - } - - if (this.onRowValidated) { - this.onRowValidated.call(null, this, rowIndex); - } - - this.emitter.emit('row-validated', this, rowIndex); + var arr = []; + for (var i = 0, len = this.fltIds.length; i < len; i++) { + var fltType = this.getFilterType(i); + if (fltType === _string2.default.lower(type)) { + var a = bool ? i : this.fltIds[i]; + arr.push(a); } } + return arr; + }; - /** - * Validate all filterable rows - */ + /** + * Return the filter's DOM element for a given column + * @param {Number} index Column's index + * @return {DOMElement} + */ - }, { - key: 'validateAllRows', - value: function validateAllRows() { - if (!this._hasGrid) { - return; - } - this.validRowsIndex = []; - for (var k = this.refRow; k < this.nbFilterableRows; k++) { - this.validateRow(k, true); - } + + TableFilter.prototype.getFilterElement = function getFilterElement(index) { + var fltId = this.fltIds[index]; + return _dom2.default.id(fltId); + }; + + /** + * Return the number of cells for a given row index + * @param {Number} rowIndex Index of the row + * @return {Number} Number of cells + */ + + + TableFilter.prototype.getCellsNb = function getCellsNb() { + var rowIndex = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; + + var tr = this.tbl.rows[rowIndex]; + return tr.cells.length; + }; + + /** + * Return the number of filterable rows starting from reference row if + * defined + * @param {Boolean} includeHeaders Include the headers row + * @return {Number} Number of filterable rows + */ + + + TableFilter.prototype.getRowsNb = function getRowsNb(includeHeaders) { + var s = _types2.default.isUndef(this.refRow) ? 0 : this.refRow, + ntrs = this.tbl.rows.length; + if (includeHeaders) { + s = 0; } + return parseInt(ntrs - s, 10); + }; - /** - * Set search value to a given filter - * @param {Number} index Column's index - * @param {String or Array} query searcharg Search term - */ + /** + * Return the data of a given cell + * @param {DOMElement} cell Cell's DOM object + * @return {String} + */ - }, { - key: 'setFilterValue', - value: function setFilterValue(index) { - var query = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1]; - if (!this.fltGrid) { - return; - } - var slc = this.getFilterElement(index), - fltColType = this.getFilterType(index); - - if (fltColType !== this.fltTypeMulti && fltColType != this.fltTypeCheckList) { - if (this.loadFltOnDemand && !this.initialized) { - this.emitter.emit('build-select-filter', this, index, this.linkedFilters, this.isExternalFlt); - } - slc.value = query; - } - //multiple selects - else if (fltColType === this.fltTypeMulti) { - var values = _types2.default.isArray(query) ? query : query.split(' ' + this.orOperator + ' '); - - if (this.loadFltOnDemand && !this.initialized) { - this.emitter.emit('build-select-filter', this, index, this.linkedFilters, this.isExternalFlt); - } - - this.emitter.emit('select-options', this, index, values); - } - //checklist - else if (fltColType === this.fltTypeCheckList) { - var values = []; - if (this.loadFltOnDemand && !this.initialized) { - this.emitter.emit('build-checklist-filter', this, index, this.isExternalFlt); - } - if (_types2.default.isArray(query)) { - values = query; - } else { - query = _string2.default.matchCase(query, this.caseSensitive); - values = query.split(' ' + this.orOperator + ' '); - } - - this.emitter.emit('select-checklist-options', this, index, values); - } + TableFilter.prototype.getCellData = function getCellData(cell) { + var idx = cell.cellIndex; + //Check for customCellData callback + if (this.customCellData && this.customCellDataCols.indexOf(idx) != -1) { + return this.customCellData.call(null, this, cell, idx); + } else { + return _dom2.default.getText(cell); } + }; - /** - * Set them columns' widths as per configuration - * @param {Element} tbl DOM element - */ + /** + * Return the table data with following format: + * [ + * [rowIndex, [value0, value1...]], + * [rowIndex, [value0, value1...]] + * ] + * @param {Boolean} includeHeaders Optional: include headers row + * @param {Boolean} excludeHiddenCols Optional: exclude hidden columns + * @return {Array} + * + * TODO: provide an API returning data in JSON format + */ - }, { - key: 'setColWidths', - value: function setColWidths(tbl) { - if (!this.hasColWidths) { - return; - } - tbl = tbl || this.tbl; - setWidths.call(this); + TableFilter.prototype.getTableData = function getTableData() { + var includeHeaders = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; + var excludeHiddenCols = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - function setWidths() { - var nbCols = this.nbCells; - var colWidths = this.colWidths; - var colTags = _dom2.default.tag(tbl, 'col'); - var tblHasColTag = colTags.length > 0; - var frag = !tblHasColTag ? doc.createDocumentFragment() : null; - for (var k = 0; k < nbCols; k++) { - var col = void 0; - if (tblHasColTag) { - col = colTags[k]; - } else { - col = _dom2.default.create('col', ['id', this.id + '_col_' + k]); - frag.appendChild(col); - } - col.style.width = colWidths[k]; - } - if (!tblHasColTag) { - tbl.insertBefore(frag, tbl.firstChild); - } - } + var rows = this.tbl.rows; + var tblData = []; + if (includeHeaders) { + var headers = this.getHeadersText(excludeHiddenCols); + tblData.push([this.getHeadersRowIndex(), headers]); } - - /** - * Makes defined rows always visible - */ - - }, { - key: 'enforceVisibility', - value: function enforceVisibility() { - if (!this.hasVisibleRows) { - return; - } - for (var i = 0, len = this.visibleRows.length; i < len; i++) { - var row = this.visibleRows[i]; - //row index cannot be > nrows - if (row <= this.nbRows) { - this.validateRow(row, true); - } - } - } - - /** - * Clear all the filters' values - */ - - }, { - key: 'clearFilters', - value: function clearFilters() { - if (!this.fltGrid) { - return; - } - - this.emitter.emit('before-clearing-filters', this); - - if (this.onBeforeReset) { - this.onBeforeReset.call(null, this, this.getFiltersValue()); - } - for (var i = 0, len = this.fltIds.length; i < len; i++) { - this.setFilterValue(i, ''); - } - - this.filter(); - - if (this.onAfterReset) { - this.onAfterReset.call(null, this); - } - this.emitter.emit('after-clearing-filters', this); - } - - /** - * Clears filtered columns visual indicator (background color) - */ - - }, { - key: 'clearActiveColumns', - value: function clearActiveColumns() { - for (var i = 0, len = this.getCellsNb(this.headersRow); i < len; i++) { - _dom2.default.removeClass(this.getHeaderElement(i), this.activeColumnsCssClass); - } - } - - /** - * Mark currently filtered column - * @param {Number} colIndex Column index - */ - - }, { - key: 'markActiveColumn', - value: function markActiveColumn(colIndex) { - var header = this.getHeaderElement(colIndex); - if (_dom2.default.hasClass(header, this.activeColumnsCssClass)) { - return; - } - if (this.onBeforeActiveColumn) { - this.onBeforeActiveColumn.call(null, this, colIndex); - } - _dom2.default.addClass(header, this.activeColumnsCssClass); - if (this.onAfterActiveColumn) { - this.onAfterActiveColumn.call(null, this, colIndex); - } - } - - /** - * Refresh the filters subject to linking ('select', 'multiple', - * 'checklist' type) - */ - - }, { - key: 'linkFilters', - value: function linkFilters() { - if (!this.linkedFilters || !this.activeFilterId) { - return; - } - var slcA1 = this.getFiltersByType(this.fltTypeSlc, true), - slcA2 = this.getFiltersByType(this.fltTypeMulti, true), - slcA3 = this.getFiltersByType(this.fltTypeCheckList, true), - slcIndex = slcA1.concat(slcA2); - slcIndex = slcIndex.concat(slcA3); - - var activeFlt = this.activeFilterId.split('_')[0]; - activeFlt = activeFlt.split(this.prfxFlt)[1]; - var slcSelectedValue = void 0; - for (var i = 0, len = slcIndex.length; i < len; i++) { - var curSlc = _dom2.default.id(this.fltIds[slcIndex[i]]); - slcSelectedValue = this.getFilterValue(slcIndex[i]); - - // Welcome to cyclomatic complexity hell :) - // TODO: simplify/refactor if statement - if (activeFlt !== slcIndex[i] || this.paging && slcA1.indexOf(slcIndex[i]) != -1 && activeFlt === slcIndex[i] || !this.paging && (slcA3.indexOf(slcIndex[i]) != -1 || slcA2.indexOf(slcIndex[i]) != -1) || slcSelectedValue === this.displayAllText) { - - //1st option needs to be inserted - if (this.loadFltOnDemand) { - var opt0 = _dom2.default.createOpt(this.displayAllText, ''); - curSlc.innerHTML = ''; - curSlc.appendChild(opt0); - } - - if (slcA3.indexOf(slcIndex[i]) != -1) { - this.emitter.emit('build-checklist-filter', this, slcIndex[i]); - } else { - this.emitter.emit('build-select-filter', this, slcIndex[i], true); - } - - this.setFilterValue(slcIndex[i], slcSelectedValue); - } - } // for i - } - - /** - * Determines if passed filter column implements exact query match - * @param {Number} colIndex [description] - * @return {Boolean} [description] - */ - - }, { - key: 'isExactMatch', - value: function isExactMatch(colIndex) { - var fltType = this.getFilterType(colIndex); - return this.exactMatchByCol[colIndex] || this.exactMatch || fltType !== this.fltTypeInp; - } - - /** - * Check if passed script or stylesheet is already imported - * @param {String} filePath Ressource path - * @param {String} type Possible values: 'script' or 'link' - * @return {Boolean} - */ - - }, { - key: 'isImported', - value: function isImported(filePath, type) { - var imported = false, - importType = !type ? 'script' : type, - attr = importType == 'script' ? 'src' : 'href', - files = _dom2.default.tag(doc, importType); - for (var i = 0, len = files.length; i < len; i++) { - if (files[i][attr] === undefined) { - continue; - } - if (files[i][attr].match(filePath)) { - imported = true; - break; - } - } - return imported; - } - - /** - * Import script or stylesheet - * @param {String} fileId Ressource ID - * @param {String} filePath Ressource path - * @param {Function} callback Callback - * @param {String} type Possible values: 'script' or 'link' - */ - - }, { - key: 'import', - value: function _import(fileId, filePath, callback, type) { - var ftype = !type ? 'script' : type, - imported = this.isImported(filePath, ftype); - if (imported) { - return; - } - var o = this, - isLoaded = false, - file = void 0, - head = _dom2.default.tag(doc, 'head')[0]; - - if (_string2.default.lower(ftype) === 'link') { - file = _dom2.default.create('link', ['id', fileId], ['type', 'text/css'], ['rel', 'stylesheet'], ['href', filePath]); - } else { - file = _dom2.default.create('script', ['id', fileId], ['type', 'text/javascript'], ['src', filePath]); - } - - //Browser <> IE onload event works only for scripts, not for stylesheets - file.onload = file.onreadystatechange = function () { - if (!isLoaded && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) { - isLoaded = true; - if (typeof callback === 'function') { - callback.call(null, o); - } - } - }; - file.onerror = function () { - throw new Error('TF script could not load: ' + filePath); - }; - head.appendChild(file); - } - - /** - * Check if table has filters grid - * @return {Boolean} - */ - - }, { - key: 'hasGrid', - value: function hasGrid() { - return this._hasGrid; - } - - /** - * Get list of filter IDs - * @return {[type]} [description] - */ - - }, { - key: 'getFiltersId', - value: function getFiltersId() { - return this.fltIds || []; - } - - /** - * Get filtered (valid) rows indexes - * @param {Boolean} reCalc Force calculation of filtered rows list - * @return {Array} List of row indexes - */ - - }, { - key: 'getValidRows', - value: function getValidRows(reCalc) { - if (!reCalc) { - return this.validRowsIndex; - } - - this.validRowsIndex = []; - for (var k = this.refRow; k < this.getRowsNb(true); k++) { - var r = this.tbl.rows[k]; - if (!this.paging) { - if (this.getRowDisplay(r) !== 'none') { - this.validRowsIndex.push(r.rowIndex); - } - } else { - if (r.getAttribute('validRow') === 'true' || r.getAttribute('validRow') === null) { - this.validRowsIndex.push(r.rowIndex); - } - } - } - return this.validRowsIndex; - } - - /** - * Get the index of the row containing the filters - * @return {Number} - */ - - }, { - key: 'getFiltersRowIndex', - value: function getFiltersRowIndex() { - return this.filtersRowIndex; - } - - /** - * Get the index of the headers row - * @return {Number} - */ - - }, { - key: 'getHeadersRowIndex', - value: function getHeadersRowIndex() { - return this.headersRow; - } - - /** - * Get the row index from where the filtering process start (1st filterable - * row) - * @return {Number} - */ - - }, { - key: 'getStartRowIndex', - value: function getStartRowIndex() { - return this.refRow; - } - - /** - * Get the index of the last row - * @return {Number} - */ - - }, { - key: 'getLastRowIndex', - value: function getLastRowIndex() { - return this.nbRows - 1; - } - - /** - * Get the header DOM element for a given column index - * @param {Number} colIndex Column index - * @return {Object} - */ - - }, { - key: 'getHeaderElement', - value: function getHeaderElement(colIndex) { - var table = this.gridLayout ? this.Mod.gridLayout.headTbl : this.tbl; - var tHead = _dom2.default.tag(table, 'thead'); - var headersRow = this.headersRow; - var header = void 0; - for (var i = 0; i < this.nbCells; i++) { - if (i !== colIndex) { - continue; - } - if (tHead.length === 0) { - header = table.rows[headersRow].cells[i]; - } - if (tHead.length === 1) { - header = tHead[0].rows[headersRow].cells[i]; - } - break; - } - return header; - } - - /** - * Return the list of headers' text - * @param {Boolean} excludeHiddenCols Optional: exclude hidden columns - * @return {Array} list of headers' text - */ - - }, { - key: 'getHeadersText', - value: function getHeadersText() { - var excludeHiddenCols = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; - - var headers = []; - for (var j = 0; j < this.nbCells; j++) { + for (var k = this.refRow; k < this.nbRows; k++) { + var rowData = [k, []]; + var cells = rows[k].cells; + for (var j = 0, len = cells.length; j < len; j++) { if (excludeHiddenCols && this.hasExtension('colsVisibility')) { if (this.extension('colsVisibility').isColHidden(j)) { continue; } } - var header = this.getHeaderElement(j); - var headerText = _dom2.default.getFirstTextNode(header); - headers.push(headerText); + var cellData = this.getCellData(cells[j]); + rowData[1].push(cellData); } - return headers; + tblData.push(rowData); + } + return tblData; + }; + + /** + * Return the filtered data with following format: + * [ + * [rowIndex, [value0, value1...]], + * [rowIndex, [value0, value1...]] + * ] + * @param {Boolean} includeHeaders Optional: include headers row + * @param {Boolean} excludeHiddenCols Optional: exclude hidden columns + * @return {Array} + * + * TODO: provide an API returning data in JSON format + */ + + + TableFilter.prototype.getFilteredData = function getFilteredData() { + var includeHeaders = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; + var excludeHiddenCols = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + + if (!this.validRowsIndex) { + return []; + } + var rows = this.tbl.rows, + filteredData = []; + if (includeHeaders) { + var headers = this.getHeadersText(excludeHiddenCols); + filteredData.push([this.getHeadersRowIndex(), headers]); } - /** - * Return the filter type for a specified column - * @param {Number} colIndex Column's index - * @return {String} - */ + var validRows = this.getValidRows(true); + for (var i = 0; i < validRows.length; i++) { + var rData = [this.validRowsIndex[i], []], + cells = rows[this.validRowsIndex[i]].cells; + for (var k = 0; k < cells.length; k++) { + if (excludeHiddenCols && this.hasExtension('colsVisibility')) { + if (this.extension('colsVisibility').isColHidden(k)) { + continue; + } + } + var cellData = this.getCellData(cells[k]); + rData[1].push(cellData); + } + filteredData.push(rData); + } + return filteredData; + }; - }, { - key: 'getFilterType', - value: function getFilterType(colIndex) { - var colType = this.cfg['col_' + colIndex]; - return !colType ? this.fltTypeInp : _string2.default.lower(colType); + /** + * Return the filtered data for a given column index + * @param {Number} colIndex Colmun's index + * @param {Boolean} includeHeaders Optional: include headers row + * @return {Array} Flat list of values ['val0','val1','val2'...] + * + * TODO: provide an API returning data in JSON format + */ + + + TableFilter.prototype.getFilteredDataCol = function getFilteredDataCol(colIndex) { + var includeHeaders = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + + if (_types2.default.isUndef(colIndex)) { + return []; + } + var data = this.getFilteredData(), + colData = []; + if (includeHeaders) { + colData.push(this.getHeadersText()[colIndex]); + } + for (var i = 0, len = data.length; i < len; i++) { + var r = data[i], + + //cols values of current row + d = r[1], + + //data of searched column + c = d[colIndex]; + colData.push(c); + } + return colData; + }; + + /** + * Get the display value of a row + * @param {RowElement} row DOM element of the row + * @return {String} Usually 'none' or '' + */ + + + TableFilter.prototype.getRowDisplay = function getRowDisplay(row) { + if (!_types2.default.isObj(row)) { + return null; + } + return row.style.display; + }; + + /** + * Validate/invalidate row by setting the 'validRow' attribute on the row + * @param {Number} rowIndex Index of the row + * @param {Boolean} isValid + */ + + + TableFilter.prototype.validateRow = function validateRow(rowIndex, isValid) { + var row = this.tbl.rows[rowIndex]; + if (!row || typeof isValid !== 'boolean') { + return; } - /** - * Get the total number of filterable rows - * @return {Number} - */ - - }, { - key: 'getFilterableRowsNb', - value: function getFilterableRowsNb() { - return this.getRowsNb(false); + // always visible rows are valid + if (this.hasVisibleRows && this.visibleRows.indexOf(rowIndex) !== -1) { + isValid = true; } - /** - * Get the configuration object (literal object) - * @return {Object} - */ + var displayFlag = isValid ? '' : 'none', + validFlag = isValid ? 'true' : 'false'; + row.style.display = displayFlag; - }, { - key: 'config', - value: function config() { - return this.cfg; + if (this.paging) { + row.setAttribute('validRow', validFlag); } - }]); + + if (isValid) { + if (this.validRowsIndex.indexOf(rowIndex) === -1) { + this.validRowsIndex.push(rowIndex); + } + + if (this.onRowValidated) { + this.onRowValidated.call(null, this, rowIndex); + } + + this.emitter.emit('row-validated', this, rowIndex); + } + }; + + /** + * Validate all filterable rows + */ + + + TableFilter.prototype.validateAllRows = function validateAllRows() { + if (!this._hasGrid) { + return; + } + this.validRowsIndex = []; + for (var k = this.refRow; k < this.nbFilterableRows; k++) { + this.validateRow(k, true); + } + }; + + /** + * Set search value to a given filter + * @param {Number} index Column's index + * @param {String or Array} query searcharg Search term + */ + + + TableFilter.prototype.setFilterValue = function setFilterValue(index) { + var query = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1]; + + if (!this.fltGrid) { + return; + } + var slc = this.getFilterElement(index), + fltColType = this.getFilterType(index); + + if (fltColType !== this.fltTypeMulti && fltColType != this.fltTypeCheckList) { + if (this.loadFltOnDemand && !this.initialized) { + this.emitter.emit('build-select-filter', this, index, this.linkedFilters, this.isExternalFlt); + } + slc.value = query; + } + //multiple selects + else if (fltColType === this.fltTypeMulti) { + var values = _types2.default.isArray(query) ? query : query.split(' ' + this.orOperator + ' '); + + if (this.loadFltOnDemand && !this.initialized) { + this.emitter.emit('build-select-filter', this, index, this.linkedFilters, this.isExternalFlt); + } + + this.emitter.emit('select-options', this, index, values); + } + //checklist + else if (fltColType === this.fltTypeCheckList) { + var values = []; + if (this.loadFltOnDemand && !this.initialized) { + this.emitter.emit('build-checklist-filter', this, index, this.isExternalFlt); + } + if (_types2.default.isArray(query)) { + values = query; + } else { + query = _string2.default.matchCase(query, this.caseSensitive); + values = query.split(' ' + this.orOperator + ' '); + } + + this.emitter.emit('select-checklist-options', this, index, values); + } + }; + + /** + * Set them columns' widths as per configuration + * @param {Element} tbl DOM element + */ + + + TableFilter.prototype.setColWidths = function setColWidths(tbl) { + if (!this.hasColWidths) { + return; + } + tbl = tbl || this.tbl; + + setWidths.call(this); + + function setWidths() { + var nbCols = this.nbCells; + var colWidths = this.colWidths; + var colTags = _dom2.default.tag(tbl, 'col'); + var tblHasColTag = colTags.length > 0; + var frag = !tblHasColTag ? doc.createDocumentFragment() : null; + for (var k = 0; k < nbCols; k++) { + var col = void 0; + if (tblHasColTag) { + col = colTags[k]; + } else { + col = _dom2.default.create('col', ['id', this.id + '_col_' + k]); + frag.appendChild(col); + } + col.style.width = colWidths[k]; + } + if (!tblHasColTag) { + tbl.insertBefore(frag, tbl.firstChild); + } + } + }; + + /** + * Makes defined rows always visible + */ + + + TableFilter.prototype.enforceVisibility = function enforceVisibility() { + if (!this.hasVisibleRows) { + return; + } + for (var i = 0, len = this.visibleRows.length; i < len; i++) { + var row = this.visibleRows[i]; + //row index cannot be > nrows + if (row <= this.nbRows) { + this.validateRow(row, true); + } + } + }; + + /** + * Clear all the filters' values + */ + + + TableFilter.prototype.clearFilters = function clearFilters() { + if (!this.fltGrid) { + return; + } + + this.emitter.emit('before-clearing-filters', this); + + if (this.onBeforeReset) { + this.onBeforeReset.call(null, this, this.getFiltersValue()); + } + for (var i = 0, len = this.fltIds.length; i < len; i++) { + this.setFilterValue(i, ''); + } + + this.filter(); + + if (this.onAfterReset) { + this.onAfterReset.call(null, this); + } + this.emitter.emit('after-clearing-filters', this); + }; + + /** + * Clears filtered columns visual indicator (background color) + */ + + + TableFilter.prototype.clearActiveColumns = function clearActiveColumns() { + for (var i = 0, len = this.getCellsNb(this.headersRow); i < len; i++) { + _dom2.default.removeClass(this.getHeaderElement(i), this.activeColumnsCssClass); + } + }; + + /** + * Mark currently filtered column + * @param {Number} colIndex Column index + */ + + + TableFilter.prototype.markActiveColumn = function markActiveColumn(colIndex) { + var header = this.getHeaderElement(colIndex); + if (_dom2.default.hasClass(header, this.activeColumnsCssClass)) { + return; + } + if (this.onBeforeActiveColumn) { + this.onBeforeActiveColumn.call(null, this, colIndex); + } + _dom2.default.addClass(header, this.activeColumnsCssClass); + if (this.onAfterActiveColumn) { + this.onAfterActiveColumn.call(null, this, colIndex); + } + }; + + /** + * Refresh the filters subject to linking ('select', 'multiple', + * 'checklist' type) + */ + + + TableFilter.prototype.linkFilters = function linkFilters() { + if (!this.linkedFilters || !this.activeFilterId) { + return; + } + var slcA1 = this.getFiltersByType(this.fltTypeSlc, true), + slcA2 = this.getFiltersByType(this.fltTypeMulti, true), + slcA3 = this.getFiltersByType(this.fltTypeCheckList, true), + slcIndex = slcA1.concat(slcA2); + slcIndex = slcIndex.concat(slcA3); + + var activeFlt = this.activeFilterId.split('_')[0]; + activeFlt = activeFlt.split(this.prfxFlt)[1]; + var slcSelectedValue = void 0; + for (var i = 0, len = slcIndex.length; i < len; i++) { + var curSlc = _dom2.default.id(this.fltIds[slcIndex[i]]); + slcSelectedValue = this.getFilterValue(slcIndex[i]); + + // Welcome to cyclomatic complexity hell :) + // TODO: simplify/refactor if statement + if (activeFlt !== slcIndex[i] || this.paging && slcA1.indexOf(slcIndex[i]) != -1 && activeFlt === slcIndex[i] || !this.paging && (slcA3.indexOf(slcIndex[i]) != -1 || slcA2.indexOf(slcIndex[i]) != -1) || slcSelectedValue === this.displayAllText) { + + //1st option needs to be inserted + if (this.loadFltOnDemand) { + var opt0 = _dom2.default.createOpt(this.displayAllText, ''); + curSlc.innerHTML = ''; + curSlc.appendChild(opt0); + } + + if (slcA3.indexOf(slcIndex[i]) != -1) { + this.emitter.emit('build-checklist-filter', this, slcIndex[i]); + } else { + this.emitter.emit('build-select-filter', this, slcIndex[i], true); + } + + this.setFilterValue(slcIndex[i], slcSelectedValue); + } + } // for i + }; + + /** + * Determines if passed filter column implements exact query match + * @param {Number} colIndex [description] + * @return {Boolean} [description] + */ + + + TableFilter.prototype.isExactMatch = function isExactMatch(colIndex) { + var fltType = this.getFilterType(colIndex); + return this.exactMatchByCol[colIndex] || this.exactMatch || fltType !== this.fltTypeInp; + }; + + /** + * Check if passed script or stylesheet is already imported + * @param {String} filePath Ressource path + * @param {String} type Possible values: 'script' or 'link' + * @return {Boolean} + */ + + + TableFilter.prototype.isImported = function isImported(filePath, type) { + var imported = false, + importType = !type ? 'script' : type, + attr = importType == 'script' ? 'src' : 'href', + files = _dom2.default.tag(doc, importType); + for (var i = 0, len = files.length; i < len; i++) { + if (files[i][attr] === undefined) { + continue; + } + if (files[i][attr].match(filePath)) { + imported = true; + break; + } + } + return imported; + }; + + /** + * Import script or stylesheet + * @param {String} fileId Ressource ID + * @param {String} filePath Ressource path + * @param {Function} callback Callback + * @param {String} type Possible values: 'script' or 'link' + */ + + + TableFilter.prototype.import = function _import(fileId, filePath, callback, type) { + var ftype = !type ? 'script' : type, + imported = this.isImported(filePath, ftype); + if (imported) { + return; + } + var o = this, + isLoaded = false, + file = void 0, + head = _dom2.default.tag(doc, 'head')[0]; + + if (_string2.default.lower(ftype) === 'link') { + file = _dom2.default.create('link', ['id', fileId], ['type', 'text/css'], ['rel', 'stylesheet'], ['href', filePath]); + } else { + file = _dom2.default.create('script', ['id', fileId], ['type', 'text/javascript'], ['src', filePath]); + } + + //Browser <> IE onload event works only for scripts, not for stylesheets + file.onload = file.onreadystatechange = function () { + if (!isLoaded && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) { + isLoaded = true; + if (typeof callback === 'function') { + callback.call(null, o); + } + } + }; + file.onerror = function () { + throw new Error('TF script could not load: ' + filePath); + }; + head.appendChild(file); + }; + + /** + * Check if table has filters grid + * @return {Boolean} + */ + + + TableFilter.prototype.hasGrid = function hasGrid() { + return this._hasGrid; + }; + + /** + * Get list of filter IDs + * @return {[type]} [description] + */ + + + TableFilter.prototype.getFiltersId = function getFiltersId() { + return this.fltIds || []; + }; + + /** + * Get filtered (valid) rows indexes + * @param {Boolean} reCalc Force calculation of filtered rows list + * @return {Array} List of row indexes + */ + + + TableFilter.prototype.getValidRows = function getValidRows(reCalc) { + if (!reCalc) { + return this.validRowsIndex; + } + + this.validRowsIndex = []; + for (var k = this.refRow; k < this.getRowsNb(true); k++) { + var r = this.tbl.rows[k]; + if (!this.paging) { + if (this.getRowDisplay(r) !== 'none') { + this.validRowsIndex.push(r.rowIndex); + } + } else { + if (r.getAttribute('validRow') === 'true' || r.getAttribute('validRow') === null) { + this.validRowsIndex.push(r.rowIndex); + } + } + } + return this.validRowsIndex; + }; + + /** + * Get the index of the row containing the filters + * @return {Number} + */ + + + TableFilter.prototype.getFiltersRowIndex = function getFiltersRowIndex() { + return this.filtersRowIndex; + }; + + /** + * Get the index of the headers row + * @return {Number} + */ + + + TableFilter.prototype.getHeadersRowIndex = function getHeadersRowIndex() { + return this.headersRow; + }; + + /** + * Get the row index from where the filtering process start (1st filterable + * row) + * @return {Number} + */ + + + TableFilter.prototype.getStartRowIndex = function getStartRowIndex() { + return this.refRow; + }; + + /** + * Get the index of the last row + * @return {Number} + */ + + + TableFilter.prototype.getLastRowIndex = function getLastRowIndex() { + return this.nbRows - 1; + }; + + /** + * Get the header DOM element for a given column index + * @param {Number} colIndex Column index + * @return {Object} + */ + + + TableFilter.prototype.getHeaderElement = function getHeaderElement(colIndex) { + var table = this.gridLayout ? this.Mod.gridLayout.headTbl : this.tbl; + var tHead = _dom2.default.tag(table, 'thead'); + var headersRow = this.headersRow; + var header = void 0; + for (var i = 0; i < this.nbCells; i++) { + if (i !== colIndex) { + continue; + } + if (tHead.length === 0) { + header = table.rows[headersRow].cells[i]; + } + if (tHead.length === 1) { + header = tHead[0].rows[headersRow].cells[i]; + } + break; + } + return header; + }; + + /** + * Return the list of headers' text + * @param {Boolean} excludeHiddenCols Optional: exclude hidden columns + * @return {Array} list of headers' text + */ + + + TableFilter.prototype.getHeadersText = function getHeadersText() { + var excludeHiddenCols = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; + + var headers = []; + for (var j = 0; j < this.nbCells; j++) { + if (excludeHiddenCols && this.hasExtension('colsVisibility')) { + if (this.extension('colsVisibility').isColHidden(j)) { + continue; + } + } + var header = this.getHeaderElement(j); + var headerText = _dom2.default.getFirstTextNode(header); + headers.push(headerText); + } + return headers; + }; + + /** + * Return the filter type for a specified column + * @param {Number} colIndex Column's index + * @return {String} + */ + + + TableFilter.prototype.getFilterType = function getFilterType(colIndex) { + var colType = this.cfg['col_' + colIndex]; + return !colType ? this.fltTypeInp : _string2.default.lower(colType); + }; + + /** + * Get the total number of filterable rows + * @return {Number} + */ + + + TableFilter.prototype.getFilterableRowsNb = function getFilterableRowsNb() { + return this.getRowsNb(false); + }; + + /** + * Get the configuration object (literal object) + * @return {Object} + */ + + + TableFilter.prototype.config = function config() { + return this.cfg; + }; return TableFilter; }(); @@ -2987,6 +2925,16 @@ return /******/ (function(modules) { // webpackBootstrap }, + /** + * Check argument is a string + * @param {String} val Value + * @returns {Boolean} + */ + isString: function isString(val) { + return Object.prototype.toString.call(val) === '[object String]'; + }, + + /** * Determine if argument is undefined * @param {Any} o @@ -3241,8 +3189,6 @@ return /******/ (function(modules) { // webpackBootstrap value: true }); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** @@ -3267,51 +3213,46 @@ return /******/ (function(modules) { // webpackBootstrap */ - _createClass(Emitter, [{ - key: "on", - value: function on(evts, fn) { - var _this = this; + Emitter.prototype.on = function on(evts, fn) { + var _this = this; - evts.forEach(function (evt) { - _this.events[evt] = _this.events[evt] || []; - _this.events[evt].push(fn); - }); - } + evts.forEach(function (evt) { + _this.events[evt] = _this.events[evt] || []; + _this.events[evt].push(fn); + }); + }; - /** - * Unsubscribe to an event - * @param {Array} evts Collection of event names - * @param {Function} fn Function invoked when event is emitted - */ + /** + * Unsubscribe to an event + * @param {Array} evts Collection of event names + * @param {Function} fn Function invoked when event is emitted + */ - }, { - key: "off", - value: function off(evts, fn) { - var _this2 = this; - evts.forEach(function (evt) { - if (evt in _this2.events) { - _this2.events[evt].splice(_this2.events[evt].indexOf(fn), 1); - } - }); - } + Emitter.prototype.off = function off(evts, fn) { + var _this2 = this; - /** - * Emit an event - * @param {String} evt Event name followed by any other argument passed to - * the invoked function - */ + evts.forEach(function (evt) { + if (evt in _this2.events) { + _this2.events[evt].splice(_this2.events[evt].indexOf(fn), 1); + } + }); + }; - }, { - key: "emit", - value: function emit(evt /*, args...*/) { - if (evt in this.events) { - for (var i = 0; i < this.events[evt].length; i++) { - this.events[evt][i].apply(this, [].slice.call(arguments, 1)); - } + /** + * Emit an event + * @param {String} evt Event name followed by any other argument passed to + * the invoked function + */ + + + Emitter.prototype.emit = function emit(evt /*, args...*/) { + if (evt in this.events) { + for (var i = 0; i < this.events[evt].length; i++) { + this.events[evt][i].apply(this, [].slice.call(arguments, 1)); } } - }]); + }; return Emitter; }(); @@ -3327,8 +3268,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.Store = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _cookie = __webpack_require__(9); var _cookie2 = _interopRequireDefault(_cookie); @@ -3368,151 +3307,140 @@ return /******/ (function(modules) { // webpackBootstrap this.emitter = tf.emitter; } - _createClass(Store, [{ - key: 'init', - value: function init() { - var _this = this; + Store.prototype.init = function init() { + var _this = this; - this.emitter.on(['after-filtering'], function () { - return _this.saveFilterValues(); - }); - this.emitter.on(['after-clearing-filters'], function () { - return _this.clearCookies(); - }); - this.emitter.on(['after-page-change'], function (tf, index) { - return _this.savePageNb(index); - }); - this.emitter.on(['after-page-length-change'], function (tf, index) { - return _this.savePageLength(index); - }); + this.emitter.on(['after-filtering'], function () { + return _this.saveFilterValues(); + }); + this.emitter.on(['after-clearing-filters'], function () { + return _this.clearCookies(); + }); + this.emitter.on(['after-page-change'], function (tf, index) { + return _this.savePageNb(index); + }); + this.emitter.on(['after-page-length-change'], function (tf, index) { + return _this.savePageLength(index); + }); + }; + + /** + * Store filters' values in cookie + */ + + + Store.prototype.saveFilterValues = function saveFilterValues() { + var tf = this.tf; + var fltValues = []; + + if (!tf.rememberGridValues) { + return; } - /** - * Store filters' values in cookie - */ - - }, { - key: 'saveFilterValues', - value: function saveFilterValues() { - var tf = this.tf; - var fltValues = []; - - if (!tf.rememberGridValues) { - return; + //store filters' values + for (var i = 0; i < tf.fltIds.length; i++) { + var value = tf.getFilterValue(i); + //convert array to a || separated values + if (_types2.default.isArray(value)) { + var rgx = new RegExp(tf.separator, 'g'); + value = value.toString().replace(rgx, ' ' + tf.orOperator + ' '); } - - //store filters' values - for (var i = 0; i < tf.fltIds.length; i++) { - var value = tf.getFilterValue(i); - //convert array to a || separated values - if (_types2.default.isArray(value)) { - var rgx = new RegExp(tf.separator, 'g'); - value = value.toString().replace(rgx, ' ' + tf.orOperator + ' '); - } - if (value === '') { - value = ' '; - } - fltValues.push(value); + if (value === '') { + value = ' '; } - - //write cookie - _cookie2.default.write(this.fltsValuesCookie, fltValues.join(tf.separator), this.duration); + fltValues.push(value); } - /** - * Retrieve filters' values from cookie - * @return {Array} - */ + //write cookie + _cookie2.default.write(this.fltsValuesCookie, fltValues.join(tf.separator), this.duration); + }; - }, { - key: 'getFilterValues', - value: function getFilterValues() { - var flts = _cookie2.default.read(this.fltsValuesCookie); - var rgx = new RegExp(this.tf.separator, 'g'); - // filters' values array - return flts.split(rgx); + /** + * Retrieve filters' values from cookie + * @return {Array} + */ + + + Store.prototype.getFilterValues = function getFilterValues() { + var flts = _cookie2.default.read(this.fltsValuesCookie); + var rgx = new RegExp(this.tf.separator, 'g'); + // filters' values array + return flts.split(rgx); + }; + + /** + * Store page number in cookie + * @param {Number} pageIndex page index to persist + */ + + + Store.prototype.savePageNb = function savePageNb(pageIndex) { + if (!this.tf.rememberPageNb) { + return; } + _cookie2.default.write(this.pgNbCookie, pageIndex, this.duration); + }; - /** - * Store page number in cookie - * @param {Number} pageIndex page index to persist - */ + /** + * Retrieve page number from cookie + * @return {String} + */ - }, { - key: 'savePageNb', - value: function savePageNb(pageIndex) { - if (!this.tf.rememberPageNb) { - return; - } - _cookie2.default.write(this.pgNbCookie, pageIndex, this.duration); + + Store.prototype.getPageNb = function getPageNb() { + return _cookie2.default.read(this.pgNbCookie); + }; + + /** + * Store page length in cookie + * @param {Number} index page length index to persist + */ + + + Store.prototype.savePageLength = function savePageLength(index) { + if (!this.tf.rememberPageLen) { + return; } + _cookie2.default.write(this.pgLenCookie, index, this.duration); + }; - /** - * Retrieve page number from cookie - * @return {String} - */ + /** + * Retrieve page length from cookie + * @return {String} + */ - }, { - key: 'getPageNb', - value: function getPageNb() { - return _cookie2.default.read(this.pgNbCookie); - } - /** - * Store page length in cookie - * @param {Number} index page length index to persist - */ + Store.prototype.getPageLength = function getPageLength() { + return _cookie2.default.read(this.pgLenCookie); + }; - }, { - key: 'savePageLength', - value: function savePageLength(index) { - if (!this.tf.rememberPageLen) { - return; - } - _cookie2.default.write(this.pgLenCookie, index, this.duration); - } + /** + * Remove all cookies + */ - /** - * Retrieve page length from cookie - * @return {String} - */ - }, { - key: 'getPageLength', - value: function getPageLength() { - return _cookie2.default.read(this.pgLenCookie); - } + Store.prototype.clearCookies = function clearCookies() { + _cookie2.default.remove(this.fltsValuesCookie); + _cookie2.default.remove(this.pgLenCookie); + _cookie2.default.remove(this.pgNbCookie); + }; - /** - * Remove all cookies - */ + Store.prototype.destroy = function destroy() { + var _this2 = this; - }, { - key: 'clearCookies', - value: function clearCookies() { - _cookie2.default.remove(this.fltsValuesCookie); - _cookie2.default.remove(this.pgLenCookie); - _cookie2.default.remove(this.pgNbCookie); - } - }, { - key: 'destroy', - value: function destroy() { - var _this2 = this; - - this.emitter.off(['after-filtering'], function () { - return _this2.saveFilterValues(); - }); - this.emitter.off(['after-clearing-filters'], function () { - return _this2.clearCookies(); - }); - this.emitter.off(['after-page-change'], function (tf, index) { - return _this2.savePageNb(index); - }); - this.emitter.off(['after-page-length-change'], function (tf, index) { - return _this2.savePageLength(index); - }); - } - }]); + this.emitter.off(['after-filtering'], function () { + return _this2.saveFilterValues(); + }); + this.emitter.off(['after-clearing-filters'], function () { + return _this2.clearCookies(); + }); + this.emitter.off(['after-page-change'], function (tf, index) { + return _this2.savePageNb(index); + }); + this.emitter.off(['after-page-length-change'], function (tf, index) { + return _this2.savePageLength(index); + }); + }; return Store; }(); @@ -3590,8 +3518,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.GridLayout = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -3629,7 +3555,7 @@ return /******/ (function(modules) { // webpackBootstrap function GridLayout(tf) { _classCallCheck(this, GridLayout); - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(GridLayout).call(this, tf, 'gridLayout')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'gridLayout')); var f = _this.config; @@ -3682,292 +3608,288 @@ return /******/ (function(modules) { // webpackBootstrap */ - _createClass(GridLayout, [{ - key: 'init', - value: function init() { - var _this2 = this; + GridLayout.prototype.init = function init() { + var _this2 = this; - var tf = this.tf; - var f = this.config; - var tbl = tf.tbl; + var tf = this.tf; + var f = this.config; + var tbl = tf.tbl; - if (this.initialized) { - return; - } - - // Override reference rows indexes - tf.refRow = _types2.default.isNull(tf.startRow) ? 0 : tf.startRow; - tf.headersRow = 0; - tf.filtersRowIndex = 1; - - tf.isExternalFlt = true; - - // default width of 100px if column widths not set - if (!tf.hasColWidths) { - tf.colWidths = []; - for (var k = 0; k < tf.nbCells; k++) { - var colW = void 0, - cell = tbl.rows[this.gridHeadRowIndex].cells[k]; - if (cell.width !== '') { - colW = cell.width; - } else if (cell.style.width !== '') { - colW = parseInt(cell.style.width, 10); - } else { - colW = this.gridDefaultColWidth; - } - tf.colWidths[k] = colW; - } - tf.hasColWidths = true; - } - tf.setColWidths(); - - var tblW = void 0; //initial table width - if (tbl.width !== '') { - tblW = tbl.width; - } else if (tbl.style.width !== '') { - tblW = parseInt(tbl.style.width, 10); - } else { - tblW = tbl.clientWidth; - } - - //Main container: it will contain all the elements - this.tblMainCont = _dom2.default.create('div', ['id', this.prfxMainTblCont + tf.id]); - this.tblMainCont.className = this.gridMainContCssClass; - if (this.gridWidth) { - this.tblMainCont.style.width = this.gridWidth; - } - tbl.parentNode.insertBefore(this.tblMainCont, tbl); - - //Table container: div wrapping content table - this.tblCont = _dom2.default.create('div', ['id', this.prfxTblCont + tf.id]); - this.tblCont.className = this.gridContCssClass; - if (this.gridWidth) { - if (this.gridWidth.indexOf('%') != -1) { - this.tblCont.style.width = '100%'; - } else { - this.tblCont.style.width = this.gridWidth; - } - } - if (this.gridHeight) { - this.tblCont.style.height = this.gridHeight; - } - tbl.parentNode.insertBefore(this.tblCont, tbl); - var t = _dom2.default.remove(tbl); - this.tblCont.appendChild(t); - - //In case table width is expressed in % - if (tbl.style.width === '') { - tbl.style.width = (_string2.default.contains('%', tblW) ? tbl.clientWidth : tblW) + 'px'; - } - - var d = _dom2.default.remove(this.tblCont); - this.tblMainCont.appendChild(d); - - //Headers table container: div wrapping headers table - this.headTblCont = _dom2.default.create('div', ['id', this.prfxHeadTblCont + tf.id]); - this.headTblCont.className = this.gridHeadContCssClass; - if (this.gridWidth) { - if (this.gridWidth.indexOf('%') != -1) { - this.headTblCont.style.width = '100%'; - } else { - this.headTblCont.style.width = this.gridWidth; - } - } - - //Headers table - this.headTbl = _dom2.default.create('table', ['id', this.prfxHeadTbl + tf.id]); - var tH = _dom2.default.create('tHead'); - - //1st row should be headers row, ids are added if not set - //Those ids are used by the sort feature - var hRow = tbl.rows[this.gridHeadRowIndex]; - var sortTriggers = []; - for (var n = 0; n < tf.nbCells; n++) { - var c = hRow.cells[n]; - var thId = c.getAttribute('id'); - if (!thId || thId === '') { - thId = this.prfxGridTh + n + '_' + tf.id; - c.setAttribute('id', thId); - } - sortTriggers.push(thId); - } - - //Filters row is created - var filtersRow = _dom2.default.create('tr'); - if (this.gridEnableFilters && tf.fltGrid) { - tf.externalFltTgtIds = []; - for (var j = 0; j < tf.nbCells; j++) { - var fltTdId = tf.prfxFlt + j + this.prfxGridFltTd + tf.id; - var cl = _dom2.default.create(tf.fltCellTag, ['id', fltTdId]); - filtersRow.appendChild(cl); - tf.externalFltTgtIds[j] = fltTdId; - } - } - - //Headers row are moved from content table to headers table - if (!this.noHeaders) { - for (var i = 0; i < this.gridHeadRows.length; i++) { - var headRow = tbl.rows[this.gridHeadRows[0]]; - tH.appendChild(headRow); - } - } else { - // Handle table with no headers, assuming here headers do not - // exist - tH.appendChild(_dom2.default.create('tr')); - } - - this.headTbl.appendChild(tH); - if (tf.filtersRowIndex === 0) { - tH.insertBefore(filtersRow, hRow); - } else { - tH.appendChild(filtersRow); - } - - this.headTblCont.appendChild(this.headTbl); - this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont); - - //THead needs to be removed in content table for sort feature - var thead = _dom2.default.tag(tbl, 'thead'); - if (thead.length > 0) { - tbl.removeChild(thead[0]); - } - - //Headers table style - this.headTbl.style.tableLayout = 'fixed'; - tbl.style.tableLayout = 'fixed'; - this.headTbl.cellPadding = tbl.cellPadding; - this.headTbl.cellSpacing = tbl.cellSpacing; - // this.headTbl.style.width = tbl.style.width; - - //content table without headers needs col widths to be reset - tf.setColWidths(this.headTbl); - - //Headers container width - // this.headTblCont.style.width = this.tblCont.clientWidth+'px'; - - tbl.style.width = ''; - // - this.headTbl.style.width = tbl.clientWidth + 'px'; - // - - //scroll synchronisation - _event2.default.add(this.tblCont, 'scroll', function (evt) { - var elm = _event2.default.target(evt); - var scrollLeft = elm.scrollLeft; - _this2.headTblCont.scrollLeft = scrollLeft; - //New pointerX calc taking into account scrollLeft - // if(!o.isPointerXOverwritten){ - // try{ - // o.Evt.pointerX = function(evt){ - // let e = evt || global.event; - // let bdScrollLeft = tf_StandardBody().scrollLeft + - // scrollLeft; - // return (e.pageX + scrollLeft) || - // (e.clientX + bdScrollLeft); - // }; - // o.isPointerXOverwritten = true; - // } catch(err) { - // o.isPointerXOverwritten = false; - // } - // } - }); - - //Configure sort extension if any - var sort = (f.extensions || []).filter(function (itm) { - return itm.name === 'sort'; - }); - if (sort.length === 1) { - sort[0].async_sort = true; - sort[0].trigger_ids = sortTriggers; - } - - //Cols generation for all browsers excepted IE<=7 - this.tblHasColTag = _dom2.default.tag(tbl, 'col').length > 0 ? true : false; - - //Col elements are enough to keep column widths after sorting and - //filtering - var createColTags = function createColTags() { - for (var k = tf.nbCells - 1; k >= 0; k--) { - var col = _dom2.default.create('col', ['id', tf.id + '_col_' + k]); - tbl.insertBefore(col, tbl.firstChild); - col.style.width = tf.colWidths[k]; - this.gridColElms[k] = col; - } - this.tblHasColTag = true; - }; - - if (!this.tblHasColTag) { - createColTags.call(this); - } else { - var cols = _dom2.default.tag(tbl, 'col'); - for (var ii = 0; ii < tf.nbCells; ii++) { - cols[ii].setAttribute('id', tf.id + '_col_' + ii); - cols[ii].style.width = tf.colWidths[ii]; - this.gridColElms.push(cols[ii]); - } - } - - var afterColResizedFn = _types2.default.isFn(f.on_after_col_resized) ? f.on_after_col_resized : null; - f.on_after_col_resized = function (o, colIndex) { - if (!colIndex) { - return; - } - var w = o.crWColsRow.cells[colIndex].style.width; - var col = o.gridColElms[colIndex]; - col.style.width = w; - - var thCW = o.crWColsRow.cells[colIndex].clientWidth; - var tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth; - - if (thCW != tdCW) { - o.headTbl.style.width = tbl.clientWidth + 'px'; - } - - if (afterColResizedFn) { - afterColResizedFn.call(null, o, colIndex); - } - }; - - if (tf.popupFilters) { - filtersRow.style.display = 'none'; - } - - if (tbl.clientWidth !== this.headTbl.clientWidth) { - tbl.style.width = this.headTbl.clientWidth + 'px'; - } - - this.initialized = true; + if (this.initialized) { + return; } - /** - * Removes the grid layout - */ + // Override reference rows indexes + tf.refRow = _types2.default.isNull(tf.startRow) ? 0 : tf.startRow; + tf.headersRow = 0; + tf.filtersRowIndex = 1; - }, { - key: 'destroy', - value: function destroy() { - var tf = this.tf; - var tbl = tf.tbl; + tf.isExternalFlt = true; - if (!this.initialized) { + // default width of 100px if column widths not set + if (!tf.hasColWidths) { + tf.colWidths = []; + for (var k = 0; k < tf.nbCells; k++) { + var colW = void 0, + cell = tbl.rows[this.gridHeadRowIndex].cells[k]; + if (cell.width !== '') { + colW = cell.width; + } else if (cell.style.width !== '') { + colW = parseInt(cell.style.width, 10); + } else { + colW = this.gridDefaultColWidth; + } + tf.colWidths[k] = colW; + } + tf.hasColWidths = true; + } + tf.setColWidths(); + + var tblW = void 0; //initial table width + if (tbl.width !== '') { + tblW = tbl.width; + } else if (tbl.style.width !== '') { + tblW = parseInt(tbl.style.width, 10); + } else { + tblW = tbl.clientWidth; + } + + //Main container: it will contain all the elements + this.tblMainCont = _dom2.default.create('div', ['id', this.prfxMainTblCont + tf.id]); + this.tblMainCont.className = this.gridMainContCssClass; + if (this.gridWidth) { + this.tblMainCont.style.width = this.gridWidth; + } + tbl.parentNode.insertBefore(this.tblMainCont, tbl); + + //Table container: div wrapping content table + this.tblCont = _dom2.default.create('div', ['id', this.prfxTblCont + tf.id]); + this.tblCont.className = this.gridContCssClass; + if (this.gridWidth) { + if (this.gridWidth.indexOf('%') != -1) { + this.tblCont.style.width = '100%'; + } else { + this.tblCont.style.width = this.gridWidth; + } + } + if (this.gridHeight) { + this.tblCont.style.height = this.gridHeight; + } + tbl.parentNode.insertBefore(this.tblCont, tbl); + var t = _dom2.default.remove(tbl); + this.tblCont.appendChild(t); + + //In case table width is expressed in % + if (tbl.style.width === '') { + tbl.style.width = (_string2.default.contains('%', tblW) ? tbl.clientWidth : tblW) + 'px'; + } + + var d = _dom2.default.remove(this.tblCont); + this.tblMainCont.appendChild(d); + + //Headers table container: div wrapping headers table + this.headTblCont = _dom2.default.create('div', ['id', this.prfxHeadTblCont + tf.id]); + this.headTblCont.className = this.gridHeadContCssClass; + if (this.gridWidth) { + if (this.gridWidth.indexOf('%') != -1) { + this.headTblCont.style.width = '100%'; + } else { + this.headTblCont.style.width = this.gridWidth; + } + } + + //Headers table + this.headTbl = _dom2.default.create('table', ['id', this.prfxHeadTbl + tf.id]); + var tH = _dom2.default.create('tHead'); + + //1st row should be headers row, ids are added if not set + //Those ids are used by the sort feature + var hRow = tbl.rows[this.gridHeadRowIndex]; + var sortTriggers = []; + for (var n = 0; n < tf.nbCells; n++) { + var c = hRow.cells[n]; + var thId = c.getAttribute('id'); + if (!thId || thId === '') { + thId = this.prfxGridTh + n + '_' + tf.id; + c.setAttribute('id', thId); + } + sortTriggers.push(thId); + } + + //Filters row is created + var filtersRow = _dom2.default.create('tr'); + if (this.gridEnableFilters && tf.fltGrid) { + tf.externalFltTgtIds = []; + for (var j = 0; j < tf.nbCells; j++) { + var fltTdId = tf.prfxFlt + j + this.prfxGridFltTd + tf.id; + var cl = _dom2.default.create(tf.fltCellTag, ['id', fltTdId]); + filtersRow.appendChild(cl); + tf.externalFltTgtIds[j] = fltTdId; + } + } + + //Headers row are moved from content table to headers table + if (!this.noHeaders) { + for (var i = 0; i < this.gridHeadRows.length; i++) { + var headRow = tbl.rows[this.gridHeadRows[0]]; + tH.appendChild(headRow); + } + } else { + // Handle table with no headers, assuming here headers do not + // exist + tH.appendChild(_dom2.default.create('tr')); + } + + this.headTbl.appendChild(tH); + if (tf.filtersRowIndex === 0) { + tH.insertBefore(filtersRow, hRow); + } else { + tH.appendChild(filtersRow); + } + + this.headTblCont.appendChild(this.headTbl); + this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont); + + //THead needs to be removed in content table for sort feature + var thead = _dom2.default.tag(tbl, 'thead'); + if (thead.length > 0) { + tbl.removeChild(thead[0]); + } + + //Headers table style + this.headTbl.style.tableLayout = 'fixed'; + tbl.style.tableLayout = 'fixed'; + this.headTbl.cellPadding = tbl.cellPadding; + this.headTbl.cellSpacing = tbl.cellSpacing; + // this.headTbl.style.width = tbl.style.width; + + //content table without headers needs col widths to be reset + tf.setColWidths(this.headTbl); + + //Headers container width + // this.headTblCont.style.width = this.tblCont.clientWidth+'px'; + + tbl.style.width = ''; + // + this.headTbl.style.width = tbl.clientWidth + 'px'; + // + + //scroll synchronisation + _event2.default.add(this.tblCont, 'scroll', function (evt) { + var elm = _event2.default.target(evt); + var scrollLeft = elm.scrollLeft; + _this2.headTblCont.scrollLeft = scrollLeft; + //New pointerX calc taking into account scrollLeft + // if(!o.isPointerXOverwritten){ + // try{ + // o.Evt.pointerX = function(evt){ + // let e = evt || global.event; + // let bdScrollLeft = tf_StandardBody().scrollLeft + + // scrollLeft; + // return (e.pageX + scrollLeft) || + // (e.clientX + bdScrollLeft); + // }; + // o.isPointerXOverwritten = true; + // } catch(err) { + // o.isPointerXOverwritten = false; + // } + // } + }); + + //Configure sort extension if any + var sort = (f.extensions || []).filter(function (itm) { + return itm.name === 'sort'; + }); + if (sort.length === 1) { + sort[0].async_sort = true; + sort[0].trigger_ids = sortTriggers; + } + + //Cols generation for all browsers excepted IE<=7 + this.tblHasColTag = _dom2.default.tag(tbl, 'col').length > 0 ? true : false; + + //Col elements are enough to keep column widths after sorting and + //filtering + var createColTags = function createColTags() { + for (var k = tf.nbCells - 1; k >= 0; k--) { + var col = _dom2.default.create('col', ['id', tf.id + '_col_' + k]); + tbl.insertBefore(col, tbl.firstChild); + col.style.width = tf.colWidths[k]; + this.gridColElms[k] = col; + } + this.tblHasColTag = true; + }; + + if (!this.tblHasColTag) { + createColTags.call(this); + } else { + var cols = _dom2.default.tag(tbl, 'col'); + for (var ii = 0; ii < tf.nbCells; ii++) { + cols[ii].setAttribute('id', tf.id + '_col_' + ii); + cols[ii].style.width = tf.colWidths[ii]; + this.gridColElms.push(cols[ii]); + } + } + + var afterColResizedFn = _types2.default.isFn(f.on_after_col_resized) ? f.on_after_col_resized : null; + f.on_after_col_resized = function (o, colIndex) { + if (!colIndex) { return; } - var t = _dom2.default.remove(tbl); - this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont); - _dom2.default.remove(this.tblMainCont); + var w = o.crWColsRow.cells[colIndex].style.width; + var col = o.gridColElms[colIndex]; + col.style.width = w; - this.tblMainCont = null; - this.headTblCont = null; - this.headTbl = null; - this.tblCont = null; + var thCW = o.crWColsRow.cells[colIndex].clientWidth; + var tdCW = o.crWRowDataTbl.cells[colIndex].clientWidth; - tbl.outerHTML = this.sourceTblHtml; - //needed to keep reference of table element for future usage - this.tf.tbl = _dom2.default.id(tf.id); + if (thCW != tdCW) { + o.headTbl.style.width = tbl.clientWidth + 'px'; + } - this.initialized = false; + if (afterColResizedFn) { + afterColResizedFn.call(null, o, colIndex); + } + }; + + if (tf.popupFilters) { + filtersRow.style.display = 'none'; } - }]); + + if (tbl.clientWidth !== this.headTbl.clientWidth) { + tbl.style.width = this.headTbl.clientWidth + 'px'; + } + + this.initialized = true; + }; + + /** + * Removes the grid layout + */ + + + GridLayout.prototype.destroy = function destroy() { + var tf = this.tf; + var tbl = tf.tbl; + + if (!this.initialized) { + return; + } + var t = _dom2.default.remove(tbl); + this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont); + _dom2.default.remove(this.tblMainCont); + + this.tblMainCont = null; + this.headTblCont = null; + this.headTbl = null; + this.tblCont = null; + + tbl.outerHTML = this.sourceTblHtml; + //needed to keep reference of table element for future usage + this.tf.tbl = _dom2.default.id(tf.id); + + this.initialized = false; + }; return GridLayout; }(_feature.Feature); @@ -3982,8 +3904,6 @@ return /******/ (function(modules) { // webpackBootstrap value: true }); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var NOTIMPLEMENTED = 'Not implemented.'; @@ -3994,44 +3914,36 @@ return /******/ (function(modules) { // webpackBootstrap this.tf = tf; this.feature = feature; - this.enabled = tf[feature]; + this.enabled = Boolean(tf[feature]); this.config = tf.config(); this.emitter = tf.emitter; this.initialized = false; } - _createClass(Feature, [{ - key: 'init', - value: function init() { - throw new Error(NOTIMPLEMENTED); - } - }, { - key: 'reset', - value: function reset() { - this.enable(); - this.init(); - } - }, { - key: 'destroy', - value: function destroy() { - throw new Error(NOTIMPLEMENTED); - } - }, { - key: 'enable', - value: function enable() { - this.enabled = true; - } - }, { - key: 'disable', - value: function disable() { - this.enabled = false; - } - }, { - key: 'isEnabled', - value: function isEnabled() { - return this.enabled; - } - }]); + Feature.prototype.init = function init() { + throw new Error(NOTIMPLEMENTED); + }; + + Feature.prototype.reset = function reset() { + this.enable(); + this.init(); + }; + + Feature.prototype.destroy = function destroy() { + throw new Error(NOTIMPLEMENTED); + }; + + Feature.prototype.enable = function enable() { + this.enabled = true; + }; + + Feature.prototype.disable = function disable() { + this.enabled = false; + }; + + Feature.prototype.isEnabled = function isEnabled() { + return this.enabled; + }; return Feature; }(); @@ -4047,8 +3959,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.Loader = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -4082,7 +3992,7 @@ return /******/ (function(modules) { // webpackBootstrap // TableFilter configuration - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Loader).call(this, tf, 'loader')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'loader')); var f = _this.config; @@ -4107,96 +4017,91 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(Loader, [{ - key: 'init', - value: function init() { - var _this2 = this; + Loader.prototype.init = function init() { + var _this2 = this; - if (this.initialized) { + if (this.initialized) { + return; + } + + var tf = this.tf; + var emitter = this.emitter; + + var containerDiv = _dom2.default.create('div', ['id', this.prfxLoader + tf.id]); + containerDiv.className = this.loaderCssClass; + + var targetEl = !this.loaderTgtId ? tf.tbl.parentNode : _dom2.default.id(this.loaderTgtId); + if (!this.loaderTgtId) { + targetEl.insertBefore(containerDiv, tf.tbl); + } else { + targetEl.appendChild(containerDiv); + } + this.loaderDiv = containerDiv; + if (!this.loaderHtml) { + this.loaderDiv.appendChild(_dom2.default.text(this.loaderText)); + } else { + this.loaderDiv.innerHTML = this.loaderHtml; + } + + this.show('none'); + + // Subscribe to events + emitter.on(['before-filtering', 'before-populating-filter', 'before-page-change', 'before-clearing-filters', 'before-page-length-change', 'before-reset-page', 'before-reset-page-length', 'before-loading-extensions', 'before-loading-themes'], function () { + return _this2.show(''); + }); + emitter.on(['after-filtering', 'after-populating-filter', 'after-page-change', 'after-clearing-filters', 'after-page-length-change', 'after-reset-page', 'after-reset-page-length', 'after-loading-extensions', 'after-loading-themes'], function () { + return _this2.show('none'); + }); + + this.initialized = true; + }; + + Loader.prototype.show = function show(p) { + var _this3 = this; + + if (!this.isEnabled() /*|| this.loaderDiv.style.display === p*/) { return; } - var tf = this.tf; - var emitter = this.emitter; - - var containerDiv = _dom2.default.create('div', ['id', this.prfxLoader + tf.id]); - containerDiv.className = this.loaderCssClass; - - var targetEl = !this.loaderTgtId ? tf.tbl.parentNode : _dom2.default.id(this.loaderTgtId); - if (!this.loaderTgtId) { - targetEl.insertBefore(containerDiv, tf.tbl); - } else { - targetEl.appendChild(containerDiv); - } - this.loaderDiv = containerDiv; - if (!this.loaderHtml) { - this.loaderDiv.appendChild(_dom2.default.text(this.loaderText)); - } else { - this.loaderDiv.innerHTML = this.loaderHtml; - } - - this.show('none'); - - // Subscribe to events - emitter.on(['before-filtering', 'before-populating-filter', 'before-page-change', 'before-clearing-filters', 'before-page-length-change', 'before-reset-page', 'before-reset-page-length', 'before-loading-extensions', 'before-loading-themes'], function () { - return _this2.show(''); - }); - emitter.on(['after-filtering', 'after-populating-filter', 'after-page-change', 'after-clearing-filters', 'after-page-length-change', 'after-reset-page', 'after-reset-page-length', 'after-loading-extensions', 'after-loading-themes'], function () { - return _this2.show('none'); - }); - - this.initialized = true; - } - }, { - key: 'show', - value: function show(p) { - var _this3 = this; - - if (!this.isEnabled() /*|| this.loaderDiv.style.display === p*/) { - return; - } - - var displayLoader = function displayLoader() { - if (!_this3.loaderDiv) { - return; - } - if (_this3.onShowLoader && p !== 'none') { - _this3.onShowLoader.call(null, _this3); - } - _this3.loaderDiv.style.display = p; - if (_this3.onHideLoader && p === 'none') { - _this3.onHideLoader.call(null, _this3); - } - }; - - var t = p === 'none' ? this.loaderCloseDelay : 1; - global.setTimeout(displayLoader, t); - } - }, { - key: 'destroy', - value: function destroy() { - var _this4 = this; - - if (!this.initialized) { + var displayLoader = function displayLoader() { + if (!_this3.loaderDiv) { return; } + if (_this3.onShowLoader && p !== 'none') { + _this3.onShowLoader.call(null, _this3); + } + _this3.loaderDiv.style.display = p; + if (_this3.onHideLoader && p === 'none') { + _this3.onHideLoader.call(null, _this3); + } + }; - var emitter = this.emitter; + var t = p === 'none' ? this.loaderCloseDelay : 1; + global.setTimeout(displayLoader, t); + }; - _dom2.default.remove(this.loaderDiv); - this.loaderDiv = null; + Loader.prototype.destroy = function destroy() { + var _this4 = this; - // Unsubscribe to events - emitter.off(['before-filtering', 'before-populating-filter', 'before-page-change', 'before-clearing-filters', 'before-page-length-change', 'before-reset-page', 'before-reset-page-length', 'before-loading-extensions', 'before-loading-themes'], function () { - return _this4.show(''); - }); - emitter.off(['after-filtering', 'after-populating-filter', 'after-page-change', 'after-clearing-filters', 'after-page-length-change', 'after-reset-page', 'after-reset-page-length', 'after-loading-extensions', 'after-loading-themes'], function () { - return _this4.show('none'); - }); - - this.initialized = false; + if (!this.initialized) { + return; } - }]); + + var emitter = this.emitter; + + _dom2.default.remove(this.loaderDiv); + this.loaderDiv = null; + + // Unsubscribe to events + emitter.off(['before-filtering', 'before-populating-filter', 'before-page-change', 'before-clearing-filters', 'before-page-length-change', 'before-reset-page', 'before-reset-page-length', 'before-loading-extensions', 'before-loading-themes'], function () { + return _this4.show(''); + }); + emitter.off(['after-filtering', 'after-populating-filter', 'after-page-change', 'after-clearing-filters', 'after-page-length-change', 'after-reset-page', 'after-reset-page-length', 'after-loading-extensions', 'after-loading-themes'], function () { + return _this4.show('none'); + }); + + this.initialized = false; + }; return Loader; }(_feature.Feature); @@ -4212,8 +4117,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.HighlightKeyword = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _dom = __webpack_require__(2); var _dom2 = _interopRequireDefault(_dom); @@ -4249,140 +4152,133 @@ return /******/ (function(modules) { // webpackBootstrap this.emitter = tf.emitter; } - _createClass(HighlightKeyword, [{ - key: 'init', - value: function init() { - var _this = this; + HighlightKeyword.prototype.init = function init() { + var _this = this; - this.emitter.on(['before-filtering', 'destroy'], function () { - return _this.unhighlightAll(); - }); - this.emitter.on(['highlight-keyword'], function (tf, cell, word) { - return _this.highlight(cell, word, _this.highlightCssClass); - }); + this.emitter.on(['before-filtering', 'destroy'], function () { + return _this.unhighlightAll(); + }); + this.emitter.on(['highlight-keyword'], function (tf, cell, word) { + return _this.highlight(cell, word, _this.highlightCssClass); + }); + }; + + /** + * highlight occurences of searched term in passed node + * @param {Node} node + * @param {String} word Searched term + * @param {String} cssClass Css class name + */ + + + HighlightKeyword.prototype.highlight = function highlight(node, word, cssClass) { + // Iterate into this nodes childNodes + if (node.hasChildNodes) { + var children = node.childNodes; + for (var i = 0; i < children.length; i++) { + this.highlight(children[i], word, cssClass); + } } - /** - * highlight occurences of searched term in passed node - * @param {Node} node - * @param {String} word Searched term - * @param {String} cssClass Css class name - */ + if (node.nodeType === 3) { + var tempNodeVal = _string2.default.lower(node.nodeValue); + var tempWordVal = _string2.default.lower(word); + if (tempNodeVal.indexOf(tempWordVal) != -1) { + var pn = node.parentNode; + if (pn && pn.className != cssClass) { + // word not highlighted yet + var nv = node.nodeValue, + ni = tempNodeVal.indexOf(tempWordVal), - }, { - key: 'highlight', - value: function highlight(node, word, cssClass) { - // Iterate into this nodes childNodes - if (node.hasChildNodes) { - var children = node.childNodes; - for (var i = 0; i < children.length; i++) { - this.highlight(children[i], word, cssClass); + // Create a load of replacement nodes + before = _dom2.default.text(nv.substr(0, ni)), + docWordVal = nv.substr(ni, word.length), + after = _dom2.default.text(nv.substr(ni + word.length)), + hiwordtext = _dom2.default.text(docWordVal), + hiword = _dom2.default.create('span'); + hiword.className = cssClass; + hiword.appendChild(hiwordtext); + pn.insertBefore(before, node); + pn.insertBefore(hiword, node); + pn.insertBefore(after, node); + pn.removeChild(node); + this.highlightedNodes.push(hiword.firstChild); } } + } + }; - if (node.nodeType === 3) { - var tempNodeVal = _string2.default.lower(node.nodeValue); - var tempWordVal = _string2.default.lower(word); - if (tempNodeVal.indexOf(tempWordVal) != -1) { - var pn = node.parentNode; - if (pn && pn.className != cssClass) { - // word not highlighted yet - var nv = node.nodeValue, - ni = tempNodeVal.indexOf(tempWordVal), + /** + * Removes highlight to nodes matching passed string + * @param {String} word + * @param {String} cssClass Css class to remove + */ - // Create a load of replacement nodes - before = _dom2.default.text(nv.substr(0, ni)), - docWordVal = nv.substr(ni, word.length), - after = _dom2.default.text(nv.substr(ni + word.length)), - hiwordtext = _dom2.default.text(docWordVal), - hiword = _dom2.default.create('span'); - hiword.className = cssClass; - hiword.appendChild(hiwordtext); - pn.insertBefore(before, node); - pn.insertBefore(hiword, node); - pn.insertBefore(after, node); - pn.removeChild(node); - this.highlightedNodes.push(hiword.firstChild); + + HighlightKeyword.prototype.unhighlight = function unhighlight(word, cssClass) { + var arrRemove = []; + var highlightedNodes = this.highlightedNodes; + for (var i = 0; i < highlightedNodes.length; i++) { + var n = highlightedNodes[i]; + if (!n) { + continue; + } + var tempNodeVal = _string2.default.lower(n.nodeValue), + tempWordVal = _string2.default.lower(word); + if (tempNodeVal.indexOf(tempWordVal) !== -1) { + var pn = n.parentNode; + if (pn && pn.className === cssClass) { + var prevSib = pn.previousSibling, + nextSib = pn.nextSibling; + if (!prevSib || !nextSib) { + continue; } + nextSib.nodeValue = prevSib.nodeValue + n.nodeValue + nextSib.nodeValue; + prevSib.nodeValue = ''; + n.nodeValue = ''; + arrRemove.push(i); } } } - - /** - * Removes highlight to nodes matching passed string - * @param {String} word - * @param {String} cssClass Css class to remove - */ - - }, { - key: 'unhighlight', - value: function unhighlight(word, cssClass) { - var arrRemove = []; - var highlightedNodes = this.highlightedNodes; - for (var i = 0; i < highlightedNodes.length; i++) { - var n = highlightedNodes[i]; - if (!n) { - continue; - } - var tempNodeVal = _string2.default.lower(n.nodeValue), - tempWordVal = _string2.default.lower(word); - if (tempNodeVal.indexOf(tempWordVal) !== -1) { - var pn = n.parentNode; - if (pn && pn.className === cssClass) { - var prevSib = pn.previousSibling, - nextSib = pn.nextSibling; - if (!prevSib || !nextSib) { - continue; - } - nextSib.nodeValue = prevSib.nodeValue + n.nodeValue + nextSib.nodeValue; - prevSib.nodeValue = ''; - n.nodeValue = ''; - arrRemove.push(i); - } - } - } - for (var k = 0; k < arrRemove.length; k++) { - highlightedNodes.splice(arrRemove[k], 1); - } + for (var k = 0; k < arrRemove.length; k++) { + highlightedNodes.splice(arrRemove[k], 1); } + }; - /** - * Clear all occurrences of highlighted nodes - */ + /** + * Clear all occurrences of highlighted nodes + */ - }, { - key: 'unhighlightAll', - value: function unhighlightAll() { - var _this2 = this; - if (!this.tf.highlightKeywords) { - return; + HighlightKeyword.prototype.unhighlightAll = function unhighlightAll() { + var _this2 = this; + + if (!this.tf.highlightKeywords) { + return; + } + // iterate filters values to unhighlight all values + this.tf.getFiltersValue().forEach(function (val) { + if (_types2.default.isArray(val)) { + val.forEach(function (item) { + return _this2.unhighlight(item, _this2.highlightCssClass); + }); + } else { + _this2.unhighlight(val, _this2.highlightCssClass); } - // iterate filters values to unhighlight all values - this.tf.getFiltersValue().forEach(function (val) { - if (_types2.default.isArray(val)) { - val.forEach(function (item) { - return _this2.unhighlight(item, _this2.highlightCssClass); - }); - } else { - _this2.unhighlight(val, _this2.highlightCssClass); - } - }); - this.highlightedNodes = []; - } - }, { - key: 'destroy', - value: function destroy() { - var _this3 = this; + }); + this.highlightedNodes = []; + }; - this.emitter.off(['before-filtering', 'destroy'], function () { - return _this3.unhighlightAll(); - }); - this.emitter.off(['highlight-keyword'], function (tf, cell, word) { - return _this3.highlight(cell, word, _this3.highlightCssClass); - }); - } - }]); + HighlightKeyword.prototype.destroy = function destroy() { + var _this3 = this; + + this.emitter.off(['before-filtering', 'destroy'], function () { + return _this3.unhighlightAll(); + }); + this.emitter.off(['highlight-keyword'], function (tf, cell, word) { + return _this3.highlight(cell, word, _this3.highlightCssClass); + }); + }; return HighlightKeyword; }(); @@ -4398,8 +4294,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.PopupFilter = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _types = __webpack_require__(4); @@ -4435,7 +4329,7 @@ return /******/ (function(modules) { // webpackBootstrap // Configuration object - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(PopupFilter).call(this, tf, 'popupFilters')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'popupFilters')); var f = _this.config; @@ -4474,263 +4368,251 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(PopupFilter, [{ - key: 'onClick', - value: function onClick(e) { - var evt = e || global.event, - elm = evt.target.parentNode, - colIndex = parseInt(elm.getAttribute('ci'), 10); + PopupFilter.prototype.onClick = function onClick(e) { + var evt = e || global.event, + elm = evt.target.parentNode, + colIndex = parseInt(elm.getAttribute('ci'), 10); - this.closeAll(colIndex); - this.toggle(colIndex); + this.closeAll(colIndex); + this.toggle(colIndex); - if (this.popUpFltAdjustToContainer) { - var popUpDiv = this.popUpFltElms[colIndex], - header = this.tf.getHeaderElement(colIndex), - headerWidth = header.clientWidth * 0.95; - popUpDiv.style.width = parseInt(headerWidth, 10) + 'px'; - } - _event2.default.cancel(evt); - _event2.default.stop(evt); + if (this.popUpFltAdjustToContainer) { + var popUpDiv = this.popUpFltElms[colIndex], + header = this.tf.getHeaderElement(colIndex), + headerWidth = header.clientWidth * 0.95; + popUpDiv.style.width = parseInt(headerWidth, 10) + 'px'; + } + _event2.default.cancel(evt); + _event2.default.stop(evt); + }; + + /** + * Initialize DOM elements + */ + + + PopupFilter.prototype.init = function init() { + var _this2 = this; + + if (this.initialized) { + return; } - /** - * Initialize DOM elements - */ + var tf = this.tf; - }, { - key: 'init', - value: function init() { - var _this2 = this; - - if (this.initialized) { - return; - } - - var tf = this.tf; - - // Override headers row index if no grouped headers - if (tf.headersRow <= 1) { - tf.headersRow = 0; - } - - for (var i = 0; i < tf.nbCells; i++) { - if (tf.getFilterType(i) === tf.fltTypeNone) { - continue; - } - var popUpSpan = _dom2.default.create('span', ['id', this.prfxPopUpSpan + tf.id + '_' + i], ['ci', i]); - popUpSpan.innerHTML = this.popUpImgFltHtml; - var header = tf.getHeaderElement(i); - header.appendChild(popUpSpan); - _event2.default.add(popUpSpan, 'click', function (evt) { - _this2.onClick(evt); - }); - this.popUpFltSpans[i] = popUpSpan; - this.popUpFltImgs[i] = popUpSpan.firstChild; - } - - // subscribe to events - this.emitter.on(['before-filtering'], function () { - return _this2.buildIcons(); - }); - this.emitter.on(['after-filtering'], function () { - return _this2.closeAll(); - }); - this.emitter.on(['cell-processed'], function (tf, cellIndex) { - return _this2.buildIcon(cellIndex, true); - }); - this.emitter.on(['filters-row-inserted'], function () { - return _this2.tf.headersRow++; - }); - this.emitter.on(['before-filter-init'], function (tf, colIndex) { - return _this2.build(colIndex); - }); - - this.initialized = true; + // Override headers row index if no grouped headers + if (tf.headersRow <= 1) { + tf.headersRow = 0; } - /** - * Reset previously destroyed feature - */ - - }, { - key: 'reset', - value: function reset() { - this.enable(); - this.init(); - this.buildAll(); + for (var i = 0; i < tf.nbCells; i++) { + if (tf.getFilterType(i) === tf.fltTypeNone) { + continue; + } + var popUpSpan = _dom2.default.create('span', ['id', this.prfxPopUpSpan + tf.id + '_' + i], ['ci', i]); + popUpSpan.innerHTML = this.popUpImgFltHtml; + var header = tf.getHeaderElement(i); + header.appendChild(popUpSpan); + _event2.default.add(popUpSpan, 'click', function (evt) { + _this2.onClick(evt); + }); + this.popUpFltSpans[i] = popUpSpan; + this.popUpFltImgs[i] = popUpSpan.firstChild; } - /** - * Build all pop-up filters elements - */ + // subscribe to events + this.emitter.on(['before-filtering'], function () { + return _this2.buildIcons(); + }); + this.emitter.on(['after-filtering'], function () { + return _this2.closeAll(); + }); + this.emitter.on(['cell-processed'], function (tf, cellIndex) { + return _this2.buildIcon(cellIndex, true); + }); + this.emitter.on(['filters-row-inserted'], function () { + return _this2.tf.headersRow++; + }); + this.emitter.on(['before-filter-init'], function (tf, colIndex) { + return _this2.build(colIndex); + }); - }, { - key: 'buildAll', - value: function buildAll() { - for (var i = 0; i < this.popUpFltElmCache.length; i++) { - this.build(i, this.popUpFltElmCache[i]); + this.initialized = true; + }; + + /** + * Reset previously destroyed feature + */ + + + PopupFilter.prototype.reset = function reset() { + this.enable(); + this.init(); + this.buildAll(); + }; + + /** + * Build all pop-up filters elements + */ + + + PopupFilter.prototype.buildAll = function buildAll() { + for (var i = 0; i < this.popUpFltElmCache.length; i++) { + this.build(i, this.popUpFltElmCache[i]); + } + }; + + /** + * Build a specified pop-up filter elements + * @param {Number} colIndex Column index + * @param {Object} div Optional container DOM element + */ + + + PopupFilter.prototype.build = function build(colIndex, div) { + var tf = this.tf; + var popUpDiv = !div ? _dom2.default.create('div', ['id', this.prfxPopUpDiv + tf.id + '_' + colIndex]) : div; + popUpDiv.className = this.popUpDivCssClass; + tf.externalFltTgtIds.push(popUpDiv.id); + var header = tf.getHeaderElement(colIndex); + header.insertBefore(popUpDiv, header.firstChild); + _event2.default.add(popUpDiv, 'click', function (evt) { + return _event2.default.stop(evt); + }); + this.popUpFltElms[colIndex] = popUpDiv; + }; + + /** + * Toogle visibility of specified filter + * @param {Number} colIndex Column index + */ + + + PopupFilter.prototype.toggle = function toggle(colIndex) { + var tf = this.tf, + popUpFltElm = this.popUpFltElms[colIndex]; + + if (popUpFltElm.style.display === 'none' || popUpFltElm.style.display === '') { + if (this.onBeforePopUpOpen) { + this.onBeforePopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex); + } + popUpFltElm.style.display = 'block'; + if (tf.getFilterType(colIndex) === tf.fltTypeInp) { + var flt = tf.getFilterElement(colIndex); + if (flt) { + flt.focus(); + } + } + if (this.onAfterPopUpOpen) { + this.onAfterPopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex); + } + } else { + if (this.onBeforePopUpClose) { + this.onBeforePopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex); + } + popUpFltElm.style.display = 'none'; + if (this.onAfterPopUpClose) { + this.onAfterPopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex); } } + }; - /** - * Build a specified pop-up filter elements - * @param {Number} colIndex Column index - * @param {Object} div Optional container DOM element - */ + /** + * Close all filters excepted for the specified one if any + * @param {Number} exceptIdx Column index of the filter to not close + */ - }, { - key: 'build', - value: function build(colIndex, div) { - var tf = this.tf; - var popUpDiv = !div ? _dom2.default.create('div', ['id', this.prfxPopUpDiv + tf.id + '_' + colIndex]) : div; - popUpDiv.className = this.popUpDivCssClass; - tf.externalFltTgtIds.push(popUpDiv.id); - var header = tf.getHeaderElement(colIndex); - header.insertBefore(popUpDiv, header.firstChild); - _event2.default.add(popUpDiv, 'click', function (evt) { - return _event2.default.stop(evt); - }); - this.popUpFltElms[colIndex] = popUpDiv; - } - /** - * Toogle visibility of specified filter - * @param {Number} colIndex Column index - */ - - }, { - key: 'toggle', - value: function toggle(colIndex) { - var tf = this.tf, - popUpFltElm = this.popUpFltElms[colIndex]; - - if (popUpFltElm.style.display === 'none' || popUpFltElm.style.display === '') { - if (this.onBeforePopUpOpen) { - this.onBeforePopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex); - } - popUpFltElm.style.display = 'block'; - if (tf.getFilterType(colIndex) === tf.fltTypeInp) { - var flt = tf.getFilterElement(colIndex); - if (flt) { - flt.focus(); - } - } - if (this.onAfterPopUpOpen) { - this.onAfterPopUpOpen.call(null, this, this.popUpFltElms[colIndex], colIndex); - } - } else { - if (this.onBeforePopUpClose) { - this.onBeforePopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex); - } + PopupFilter.prototype.closeAll = function closeAll(exceptIdx) { + for (var i = 0; i < this.popUpFltElms.length; i++) { + if (i === exceptIdx) { + continue; + } + var popUpFltElm = this.popUpFltElms[i]; + if (popUpFltElm) { popUpFltElm.style.display = 'none'; - if (this.onAfterPopUpClose) { - this.onAfterPopUpClose.call(null, this, this.popUpFltElms[colIndex], colIndex); - } } } + }; - /** - * Close all filters excepted for the specified one if any - * @param {Number} exceptIdx Column index of the filter to not close - */ + /** + * Build all the icons representing the pop-up filters + */ - }, { - key: 'closeAll', - value: function closeAll(exceptIdx) { - for (var i = 0; i < this.popUpFltElms.length; i++) { - if (i === exceptIdx) { - continue; - } - var popUpFltElm = this.popUpFltElms[i]; - if (popUpFltElm) { - popUpFltElm.style.display = 'none'; - } - } + + PopupFilter.prototype.buildIcons = function buildIcons() { + for (var i = 0; i < this.popUpFltImgs.length; i++) { + this.buildIcon(i, false); + } + }; + + /** + * Apply specified icon state + * @param {Number} colIndex Column index + * @param {Boolean} active Apply active state + */ + + + PopupFilter.prototype.buildIcon = function buildIcon(colIndex, active) { + if (this.popUpFltImgs[colIndex]) { + this.popUpFltImgs[colIndex].src = active ? this.popUpImgFltActive : this.popUpImgFlt; + } + }; + + /** + * Remove pop-up filters + */ + + + PopupFilter.prototype.destroy = function destroy() { + var _this3 = this; + + if (!this.initialized) { + return; } - /** - * Build all the icons representing the pop-up filters - */ - - }, { - key: 'buildIcons', - value: function buildIcons() { - for (var i = 0; i < this.popUpFltImgs.length; i++) { - this.buildIcon(i, false); + this.popUpFltElmCache = []; + for (var i = 0; i < this.popUpFltElms.length; i++) { + var popUpFltElm = this.popUpFltElms[i], + popUpFltSpan = this.popUpFltSpans[i], + popUpFltImg = this.popUpFltImgs[i]; + if (popUpFltElm) { + _dom2.default.remove(popUpFltElm); + this.popUpFltElmCache[i] = popUpFltElm; } + popUpFltElm = null; + if (popUpFltSpan) { + _dom2.default.remove(popUpFltSpan); + } + popUpFltSpan = null; + if (popUpFltImg) { + _dom2.default.remove(popUpFltImg); + } + popUpFltImg = null; } + this.popUpFltElms = []; + this.popUpFltSpans = []; + this.popUpFltImgs = []; - /** - * Apply specified icon state - * @param {Number} colIndex Column index - * @param {Boolean} active Apply active state - */ + // unsubscribe to events + this.emitter.off(['before-filtering'], function () { + return _this3.buildIcons(); + }); + this.emitter.off(['after-filtering'], function () { + return _this3.closeAll(); + }); + this.emitter.off(['cell-processed'], function (tf, cellIndex) { + return _this3.buildIcon(cellIndex, true); + }); + this.emitter.off(['filters-row-inserted'], function () { + return _this3.tf.headersRow++; + }); + this.emitter.off(['before-filter-init'], function (tf, colIndex) { + return _this3.build(colIndex); + }); - }, { - key: 'buildIcon', - value: function buildIcon(colIndex, active) { - if (this.popUpFltImgs[colIndex]) { - this.popUpFltImgs[colIndex].src = active ? this.popUpImgFltActive : this.popUpImgFlt; - } - } - - /** - * Remove pop-up filters - */ - - }, { - key: 'destroy', - value: function destroy() { - var _this3 = this; - - if (!this.initialized) { - return; - } - - this.popUpFltElmCache = []; - for (var i = 0; i < this.popUpFltElms.length; i++) { - var popUpFltElm = this.popUpFltElms[i], - popUpFltSpan = this.popUpFltSpans[i], - popUpFltImg = this.popUpFltImgs[i]; - if (popUpFltElm) { - _dom2.default.remove(popUpFltElm); - this.popUpFltElmCache[i] = popUpFltElm; - } - popUpFltElm = null; - if (popUpFltSpan) { - _dom2.default.remove(popUpFltSpan); - } - popUpFltSpan = null; - if (popUpFltImg) { - _dom2.default.remove(popUpFltImg); - } - popUpFltImg = null; - } - this.popUpFltElms = []; - this.popUpFltSpans = []; - this.popUpFltImgs = []; - - // unsubscribe to events - this.emitter.off(['before-filtering'], function () { - return _this3.buildIcons(); - }); - this.emitter.off(['after-filtering'], function () { - return _this3.closeAll(); - }); - this.emitter.off(['cell-processed'], function (tf, cellIndex) { - return _this3.buildIcon(cellIndex, true); - }); - this.emitter.off(['filters-row-inserted'], function () { - return _this3.tf.headersRow++; - }); - this.emitter.off(['before-filter-init'], function (tf, colIndex) { - return _this3.build(colIndex); - }); - - this.initialized = false; - } - }]); + this.initialized = false; + }; return PopupFilter; }(_feature.Feature); @@ -4747,8 +4629,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.Dropdown = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -4794,7 +4674,7 @@ return /******/ (function(modules) { // webpackBootstrap // Configuration object - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Dropdown).call(this, tf, 'dropdown')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'dropdown')); var f = tf.config(); @@ -4813,338 +4693,328 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(Dropdown, [{ - key: 'onSlcFocus', - value: function onSlcFocus(e) { - var elm = _event2.default.target(e); - var tf = this.tf; - tf.activeFilterId = elm.getAttribute('id'); - tf.activeFlt = _dom2.default.id(tf.activeFilterId); - // select is populated when element has focus - if (tf.loadFltOnDemand && elm.getAttribute('filled') === '0') { - var ct = elm.getAttribute('ct'); - this.build(ct); - } - this.emitter.emit('filter-focus', tf, this); + Dropdown.prototype.onSlcFocus = function onSlcFocus(e) { + var elm = _event2.default.target(e); + var tf = this.tf; + tf.activeFilterId = elm.getAttribute('id'); + tf.activeFlt = _dom2.default.id(tf.activeFilterId); + // select is populated when element has focus + if (tf.loadFltOnDemand && elm.getAttribute('filled') === '0') { + var ct = elm.getAttribute('ct'); + this.build(ct); } - }, { - key: 'onSlcChange', - value: function onSlcChange() { - if (this.tf.onSlcChange) { - this.tf.filter(); - } + this.emitter.emit('filter-focus', tf, this); + }; + + Dropdown.prototype.onSlcChange = function onSlcChange() { + if (this.tf.onSlcChange) { + this.tf.filter(); + } + }; + + /** + * Initialize drop-down filter + * @param {Number} colIndex Column index + * @param {Boolean} isExternal External filter flag + * @param {DOMElement} container Dom element containing the filter + */ + + + Dropdown.prototype.init = function init(colIndex, isExternal, container) { + var _this2 = this; + + var tf = this.tf; + var col = tf.getFilterType(colIndex); + var externalFltTgtId = isExternal ? tf.externalFltTgtIds[colIndex] : null; + + var slc = _dom2.default.create(tf.fltTypeSlc, ['id', tf.prfxFlt + colIndex + '_' + tf.id], ['ct', colIndex], ['filled', '0']); + + if (col === tf.fltTypeMulti) { + slc.multiple = tf.fltTypeMulti; + slc.title = this.multipleSlcTooltip; + } + slc.className = _string2.default.lower(col) === tf.fltTypeSlc ? tf.fltCssClass : tf.fltMultiCssClass; + + //filter is appended in container element + if (externalFltTgtId) { + _dom2.default.id(externalFltTgtId).appendChild(slc); + tf.externalFltEls.push(slc); + } else { + container.appendChild(slc); } - /** - * Initialize drop-down filter - * @param {Number} colIndex Column index - * @param {Boolean} isExternal External filter flag - * @param {DOMElement} container Dom element containing the filter - */ + tf.fltIds.push(slc.id); - }, { - key: 'init', - value: function init(colIndex, isExternal, container) { - var _this2 = this; - - var tf = this.tf; - var col = tf.getFilterType(colIndex); - var externalFltTgtId = isExternal ? tf.externalFltTgtIds[colIndex] : null; - - var slc = _dom2.default.create(tf.fltTypeSlc, ['id', tf.prfxFlt + colIndex + '_' + tf.id], ['ct', colIndex], ['filled', '0']); - - if (col === tf.fltTypeMulti) { - slc.multiple = tf.fltTypeMulti; - slc.title = this.multipleSlcTooltip; - } - slc.className = _string2.default.lower(col) === tf.fltTypeSlc ? tf.fltCssClass : tf.fltMultiCssClass; - - //filter is appended in container element - if (externalFltTgtId) { - _dom2.default.id(externalFltTgtId).appendChild(slc); - tf.externalFltEls.push(slc); - } else { - container.appendChild(slc); - } - - tf.fltIds.push(slc.id); - - if (!tf.loadFltOnDemand) { - this.build(colIndex); - } else { - //1st option is created here since build isn't invoked - var opt0 = _dom2.default.createOpt(tf.displayAllText, ''); - slc.appendChild(opt0); - } - - _event2.default.add(slc, 'change', function () { - return _this2.onSlcChange(); - }); - _event2.default.add(slc, 'focus', function (e) { - return _this2.onSlcFocus(e); - }); - - this.emitter.on(['build-select-filter'], function (tf, colIndex, isLinked, isExternal) { - return _this2.build(colIndex, isLinked, isExternal); - }); - this.emitter.on(['select-options'], function (tf, colIndex, values) { - return _this2.selectOptions(colIndex, values); - }); - - this.initialized = true; - } - - /** - * Build drop-down filter UI - * @param {Number} colIndex Column index - * @param {Boolean} isLinked Enable linked refresh behaviour - */ - - }, { - key: 'build', - value: function build(colIndex) { - var isLinked = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - - var tf = this.tf; - colIndex = parseInt(colIndex, 10); - - this.emitter.emit('before-populating-filter', tf, colIndex); - - this.opts = []; - this.optsTxt = []; - this.slcInnerHtml = ''; - - var slcId = tf.fltIds[colIndex]; - var slc = _dom2.default.id(slcId), - rows = tf.tbl.rows, - matchCase = tf.matchCase; - - //custom select test - this.isCustom = tf.isCustomOptions(colIndex); - - //custom selects text - var activeFlt = void 0; - if (isLinked && tf.activeFilterId) { - activeFlt = tf.activeFilterId.split('_')[0]; - activeFlt = activeFlt.split(tf.prfxFlt)[1]; - } - - var excludedOpts = null, - filteredDataCol = null; - if (isLinked && tf.disableExcludedOptions) { - excludedOpts = []; - filteredDataCol = []; - } - - for (var k = tf.refRow; k < tf.nbRows; k++) { - // always visible rows don't need to appear on selects as always - // valid - if (tf.hasVisibleRows && tf.visibleRows.indexOf(k) !== -1) { - continue; - } - - var cell = rows[k].cells, - nchilds = cell.length; - - // checks if row has exact cell # - if (nchilds !== tf.nbCells || this.isCustom) { - continue; - } - - // this loop retrieves cell data - for (var j = 0; j < nchilds; j++) { - // WTF: cyclomatic complexity hell - if (colIndex === j && (!isLinked || isLinked && tf.disableExcludedOptions) || colIndex === j && isLinked && (rows[k].style.display === '' && !tf.paging || tf.paging && (!tf.validRowsIndex || tf.validRowsIndex && tf.validRowsIndex.indexOf(k) != -1) && (activeFlt === undefined || activeFlt === colIndex || activeFlt != colIndex && tf.validRowsIndex.indexOf(k) != -1))) { - var cellData = tf.getCellData(cell[j]), - - //Vary Peter's patch - cellString = _string2.default.matchCase(cellData, matchCase); - - // checks if celldata is already in array - if (!_array2.default.has(this.opts, cellString, matchCase)) { - this.opts.push(cellData); - } - - if (isLinked && tf.disableExcludedOptions) { - var filteredCol = filteredDataCol[j]; - if (!filteredCol) { - filteredCol = tf.getFilteredDataCol(j); - } - if (!_array2.default.has(filteredCol, cellString, matchCase) && !_array2.default.has(excludedOpts, cellString, matchCase)) { - excludedOpts.push(cellData); - } - } - } //if colIndex==j - } //for j - } //for k - - //Retrieves custom values - if (this.isCustom) { - var customValues = tf.getCustomOptions(colIndex); - this.opts = customValues[0]; - this.optsTxt = customValues[1]; - } - - if (tf.sortSlc && !this.isCustom) { - if (!matchCase) { - this.opts.sort(_sort2.default.ignoreCase); - if (excludedOpts) { - excludedOpts.sort(_sort2.default.ignoreCase); - } - } else { - this.opts.sort(); - if (excludedOpts) { - excludedOpts.sort(); - } - } - } - - //asc sort - if (tf.sortNumAsc.indexOf(colIndex) != -1) { - try { - this.opts.sort(_sort2.default.numSortAsc); - if (excludedOpts) { - excludedOpts.sort(_sort2.default.numSortAsc); - } - if (this.isCustom) { - this.optsTxt.sort(_sort2.default.numSortAsc); - } - } catch (e) { - throw new Error(SORT_ERROR.replace('{0}', colIndex).replace('{1}', 'ascending')); - } //in case there are alphanumeric values - } - //desc sort - if (tf.sortNumDesc.indexOf(colIndex) != -1) { - try { - this.opts.sort(_sort2.default.numSortDesc); - if (excludedOpts) { - excludedOpts.sort(_sort2.default.numSortDesc); - } - if (this.isCustom) { - this.optsTxt.sort(_sort2.default.numSortDesc); - } - } catch (e) { - throw new Error(SORT_ERROR.replace('{0}', colIndex).replace('{1}', 'ascending')); - } //in case there are alphanumeric values - } - - //populates drop-down - this.addOptions(colIndex, slc, isLinked, excludedOpts); - - this.emitter.emit('after-populating-filter', tf, colIndex, slc); - } - - /** - * Add drop-down options - * @param {Number} colIndex Column index - * @param {Object} slc Select Dom element - * @param {Boolean} isLinked Enable linked refresh behaviour - * @param {Array} excludedOpts Array of excluded options - */ - - }, { - key: 'addOptions', - value: function addOptions(colIndex, slc, isLinked, excludedOpts) { - var tf = this.tf, - slcValue = slc.value; - - slc.innerHTML = ''; - slc = this.addFirstOption(slc); - - for (var y = 0; y < this.opts.length; y++) { - if (this.opts[y] === '') { - continue; - } - var val = this.opts[y]; //option value - var lbl = this.isCustom ? this.optsTxt[y] : val; //option text - var isDisabled = false; - if (isLinked && tf.disableExcludedOptions && _array2.default.has(excludedOpts, _string2.default.matchCase(val, tf.matchCase), tf.matchCase)) { - isDisabled = true; - } - - var opt = void 0; - //fill select on demand - if (tf.loadFltOnDemand && slcValue === this.opts[y] && tf.getFilterType(colIndex) === tf.fltTypeSlc) { - opt = _dom2.default.createOpt(lbl, val, true); - } else { - opt = _dom2.default.createOpt(lbl, val, false); - } - if (isDisabled) { - opt.disabled = true; - } - slc.appendChild(opt); - } // for y - - slc.setAttribute('filled', '1'); - } - - /** - * Add drop-down header option - * @param {Object} slc Select DOM element - */ - - }, { - key: 'addFirstOption', - value: function addFirstOption(slc) { - var tf = this.tf; - - var opt0 = _dom2.default.createOpt(!this.enableSlcResetFilter ? '' : tf.displayAllText, ''); - if (!this.enableSlcResetFilter) { - opt0.style.display = 'none'; - } + if (!tf.loadFltOnDemand) { + this.build(colIndex); + } else { + //1st option is created here since build isn't invoked + var opt0 = _dom2.default.createOpt(tf.displayAllText, ''); slc.appendChild(opt0); - if (tf.enableEmptyOption) { - var opt1 = _dom2.default.createOpt(tf.emptyText, tf.emOperator); - slc.appendChild(opt1); - } - if (tf.enableNonEmptyOption) { - var opt2 = _dom2.default.createOpt(tf.nonEmptyText, tf.nmOperator); - slc.appendChild(opt2); - } - return slc; } - /** - * Select filter options programmatically - * @param {Number} colIndex Column index - * @param {Array} values Array of option values to select - */ + _event2.default.add(slc, 'change', function () { + return _this2.onSlcChange(); + }); + _event2.default.add(slc, 'focus', function (e) { + return _this2.onSlcFocus(e); + }); - }, { - key: 'selectOptions', - value: function selectOptions(colIndex) { - var values = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + this.emitter.on(['build-select-filter'], function (tf, colIndex, isLinked, isExternal) { + return _this2.build(colIndex, isLinked, isExternal); + }); + this.emitter.on(['select-options'], function (tf, colIndex, values) { + return _this2.selectOptions(colIndex, values); + }); - var tf = this.tf; - if (tf.getFilterType(colIndex) !== tf.fltTypeMulti || values.length === 0) { - return; + this.initialized = true; + }; + + /** + * Build drop-down filter UI + * @param {Number} colIndex Column index + * @param {Boolean} isLinked Enable linked refresh behaviour + */ + + + Dropdown.prototype.build = function build(colIndex) { + var isLinked = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; + + var tf = this.tf; + colIndex = parseInt(colIndex, 10); + + this.emitter.emit('before-populating-filter', tf, colIndex); + + this.opts = []; + this.optsTxt = []; + this.slcInnerHtml = ''; + + var slcId = tf.fltIds[colIndex]; + var slc = _dom2.default.id(slcId), + rows = tf.tbl.rows, + matchCase = tf.matchCase; + + //custom select test + this.isCustom = tf.isCustomOptions(colIndex); + + //custom selects text + var activeFlt = void 0; + if (isLinked && tf.activeFilterId) { + activeFlt = tf.activeFilterId.split('_')[0]; + activeFlt = activeFlt.split(tf.prfxFlt)[1]; + } + + var excludedOpts = null, + filteredDataCol = null; + if (isLinked && tf.disableExcludedOptions) { + excludedOpts = []; + filteredDataCol = []; + } + + for (var k = tf.refRow; k < tf.nbRows; k++) { + // always visible rows don't need to appear on selects as always + // valid + if (tf.hasVisibleRows && tf.visibleRows.indexOf(k) !== -1) { + continue; } - var slc = tf.getFilterElement(colIndex); - [].forEach.call(slc.options, function (option) { - // Empty value means clear all selections and first option is the - // clear all option - if (values[0] === '' || option.value === '') { - option.selected = false; + + var cell = rows[k].cells, + nchilds = cell.length; + + // checks if row has exact cell # + if (nchilds !== tf.nbCells || this.isCustom) { + continue; + } + + // this loop retrieves cell data + for (var j = 0; j < nchilds; j++) { + // WTF: cyclomatic complexity hell + if (colIndex === j && (!isLinked || isLinked && tf.disableExcludedOptions) || colIndex === j && isLinked && (rows[k].style.display === '' && !tf.paging || tf.paging && (!tf.validRowsIndex || tf.validRowsIndex && tf.validRowsIndex.indexOf(k) != -1) && (activeFlt === undefined || activeFlt === colIndex || activeFlt != colIndex && tf.validRowsIndex.indexOf(k) != -1))) { + var cellData = tf.getCellData(cell[j]), + + //Vary Peter's patch + cellString = _string2.default.matchCase(cellData, matchCase); + + // checks if celldata is already in array + if (!_array2.default.has(this.opts, cellString, matchCase)) { + this.opts.push(cellData); + } + + if (isLinked && tf.disableExcludedOptions) { + var filteredCol = filteredDataCol[j]; + if (!filteredCol) { + filteredCol = tf.getFilteredDataCol(j); + } + if (!_array2.default.has(filteredCol, cellString, matchCase) && !_array2.default.has(excludedOpts, cellString, matchCase)) { + excludedOpts.push(cellData); + } + } + } //if colIndex==j + } //for j + } //for k + + //Retrieves custom values + if (this.isCustom) { + var customValues = tf.getCustomOptions(colIndex); + this.opts = customValues[0]; + this.optsTxt = customValues[1]; + } + + if (tf.sortSlc && !this.isCustom) { + if (!matchCase) { + this.opts.sort(_sort2.default.ignoreCase); + if (excludedOpts) { + excludedOpts.sort(_sort2.default.ignoreCase); } - - if (option.value !== '' && _array2.default.has(values, option.value, true)) { - option.selected = true; - } //if - }); + } else { + this.opts.sort(); + if (excludedOpts) { + excludedOpts.sort(); + } + } } - }, { - key: 'destroy', - value: function destroy() { - var _this3 = this; - this.emitter.off(['build-select-filter'], function (colIndex, isLinked, isExternal) { - return _this3.build(colIndex, isLinked, isExternal); - }); - this.emitter.off(['select-options'], function (tf, colIndex, values) { - return _this3.selectOptions(colIndex, values); - }); + //asc sort + if (tf.sortNumAsc.indexOf(colIndex) != -1) { + try { + this.opts.sort(_sort2.default.numSortAsc); + if (excludedOpts) { + excludedOpts.sort(_sort2.default.numSortAsc); + } + if (this.isCustom) { + this.optsTxt.sort(_sort2.default.numSortAsc); + } + } catch (e) { + throw new Error(SORT_ERROR.replace('{0}', colIndex).replace('{1}', 'ascending')); + } //in case there are alphanumeric values } - }]); + //desc sort + if (tf.sortNumDesc.indexOf(colIndex) != -1) { + try { + this.opts.sort(_sort2.default.numSortDesc); + if (excludedOpts) { + excludedOpts.sort(_sort2.default.numSortDesc); + } + if (this.isCustom) { + this.optsTxt.sort(_sort2.default.numSortDesc); + } + } catch (e) { + throw new Error(SORT_ERROR.replace('{0}', colIndex).replace('{1}', 'ascending')); + } //in case there are alphanumeric values + } + + //populates drop-down + this.addOptions(colIndex, slc, isLinked, excludedOpts); + + this.emitter.emit('after-populating-filter', tf, colIndex, slc); + }; + + /** + * Add drop-down options + * @param {Number} colIndex Column index + * @param {Object} slc Select Dom element + * @param {Boolean} isLinked Enable linked refresh behaviour + * @param {Array} excludedOpts Array of excluded options + */ + + + Dropdown.prototype.addOptions = function addOptions(colIndex, slc, isLinked, excludedOpts) { + var tf = this.tf, + slcValue = slc.value; + + slc.innerHTML = ''; + slc = this.addFirstOption(slc); + + for (var y = 0; y < this.opts.length; y++) { + if (this.opts[y] === '') { + continue; + } + var val = this.opts[y]; //option value + var lbl = this.isCustom ? this.optsTxt[y] : val; //option text + var isDisabled = false; + if (isLinked && tf.disableExcludedOptions && _array2.default.has(excludedOpts, _string2.default.matchCase(val, tf.matchCase), tf.matchCase)) { + isDisabled = true; + } + + var opt = void 0; + //fill select on demand + if (tf.loadFltOnDemand && slcValue === this.opts[y] && tf.getFilterType(colIndex) === tf.fltTypeSlc) { + opt = _dom2.default.createOpt(lbl, val, true); + } else { + opt = _dom2.default.createOpt(lbl, val, false); + } + if (isDisabled) { + opt.disabled = true; + } + slc.appendChild(opt); + } // for y + + slc.setAttribute('filled', '1'); + }; + + /** + * Add drop-down header option + * @param {Object} slc Select DOM element + */ + + + Dropdown.prototype.addFirstOption = function addFirstOption(slc) { + var tf = this.tf; + + var opt0 = _dom2.default.createOpt(!this.enableSlcResetFilter ? '' : tf.displayAllText, ''); + if (!this.enableSlcResetFilter) { + opt0.style.display = 'none'; + } + slc.appendChild(opt0); + if (tf.enableEmptyOption) { + var opt1 = _dom2.default.createOpt(tf.emptyText, tf.emOperator); + slc.appendChild(opt1); + } + if (tf.enableNonEmptyOption) { + var opt2 = _dom2.default.createOpt(tf.nonEmptyText, tf.nmOperator); + slc.appendChild(opt2); + } + return slc; + }; + + /** + * Select filter options programmatically + * @param {Number} colIndex Column index + * @param {Array} values Array of option values to select + */ + + + Dropdown.prototype.selectOptions = function selectOptions(colIndex) { + var values = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + var tf = this.tf; + if (tf.getFilterType(colIndex) !== tf.fltTypeMulti || values.length === 0) { + return; + } + var slc = tf.getFilterElement(colIndex); + [].forEach.call(slc.options, function (option) { + // Empty value means clear all selections and first option is the + // clear all option + if (values[0] === '' || option.value === '') { + option.selected = false; + } + + if (option.value !== '' && _array2.default.has(values, option.value, true)) { + option.selected = true; + } //if + }); + }; + + Dropdown.prototype.destroy = function destroy() { + var _this3 = this; + + this.emitter.off(['build-select-filter'], function (colIndex, isLinked, isExternal) { + return _this3.build(colIndex, isLinked, isExternal); + }); + this.emitter.off(['select-options'], function (tf, colIndex, values) { + return _this3.selectOptions(colIndex, values); + }); + }; return Dropdown; }(_feature.Feature); @@ -5220,8 +5090,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.CheckList = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -5267,7 +5135,7 @@ return /******/ (function(modules) { // webpackBootstrap // Configuration object - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(CheckList).call(this, tf, 'checkList')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'checkList')); var f = tf.config(); @@ -5295,436 +5163,424 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(CheckList, [{ - key: 'onChange', - value: function onChange(evt) { - var elm = evt.target; - var tf = this.tf; - tf.activeFilterId = elm.getAttribute('id'); - tf.activeFlt = _dom2.default.id(tf.activeFilterId); - tf.filter(); - } - }, { - key: 'optionClick', - value: function optionClick(evt) { - this.setCheckListValues(evt.target); - this.onChange(evt); - } - }, { - key: 'onCheckListClick', - value: function onCheckListClick(evt) { - var _this2 = this; + CheckList.prototype.onChange = function onChange(evt) { + var elm = evt.target; + var tf = this.tf; + tf.activeFilterId = elm.getAttribute('id'); + tf.activeFlt = _dom2.default.id(tf.activeFilterId); + tf.filter(); + }; - var elm = _event2.default.target(evt); - if (this.tf.loadFltOnDemand && elm.getAttribute('filled') === '0') { - var ct = elm.getAttribute('ct'); - var div = this.checkListDiv[ct]; - this.build(ct); - _event2.default.remove(div, 'click', function (evt) { - return _this2.onCheckListClick(evt); - }); + CheckList.prototype.optionClick = function optionClick(evt) { + this.setCheckListValues(evt.target); + this.onChange(evt); + }; + + CheckList.prototype.onCheckListClick = function onCheckListClick(evt) { + var _this2 = this; + + var elm = _event2.default.target(evt); + if (this.tf.loadFltOnDemand && elm.getAttribute('filled') === '0') { + var ct = elm.getAttribute('ct'); + var div = this.checkListDiv[ct]; + this.build(ct); + _event2.default.remove(div, 'click', function (evt) { + return _this2.onCheckListClick(evt); + }); + } + }; + + /** + * Initialize checklist filter + * @param {Number} colIndex Column index + * @param {Boolean} isExternal External filter flag + * @param {DOMElement} container Dom element containing the filter + */ + + + CheckList.prototype.init = function init(colIndex, isExternal, container) { + var _this3 = this; + + var tf = this.tf; + var externalFltTgtId = isExternal ? tf.externalFltTgtIds[colIndex] : null; + + var divCont = _dom2.default.create('div', ['id', this.prfxCheckListDiv + colIndex + '_' + tf.id], ['ct', colIndex], ['filled', '0']); + divCont.className = this.checkListDivCssClass; + + //filter is appended in desired element + if (externalFltTgtId) { + _dom2.default.id(externalFltTgtId).appendChild(divCont); + tf.externalFltEls.push(divCont); + } else { + container.appendChild(divCont); + } + + this.checkListDiv[colIndex] = divCont; + tf.fltIds.push(tf.prfxFlt + colIndex + '_' + tf.id); + + if (!tf.loadFltOnDemand) { + this.build(colIndex); + } else { + _event2.default.add(divCont, 'click', function (evt) { + return _this3.onCheckListClick(evt); + }); + divCont.appendChild(_dom2.default.text(this.activateCheckListTxt)); + } + + this.emitter.on(['build-checklist-filter'], function (tf, colIndex, isExternal) { + return _this3.build(colIndex, isExternal); + }); + + this.emitter.on(['select-checklist-options'], function (tf, colIndex, values) { + return _this3.selectOptions(colIndex, values); + }); + + this.initialized = true; + }; + + /** + * Build checklist UI + * @param {Number} colIndex Column index + */ + + + CheckList.prototype.build = function build(colIndex) { + var _this4 = this; + + var tf = this.tf; + colIndex = parseInt(colIndex, 10); + + this.emitter.emit('before-populating-filter', tf, colIndex); + + this.opts = []; + this.optsTxt = []; + + var flt = this.checkListDiv[colIndex]; + var ul = _dom2.default.create('ul', ['id', tf.fltIds[colIndex]], ['colIndex', colIndex]); + ul.className = this.checkListCssClass; + _event2.default.add(ul, 'change', function (evt) { + return _this4.onChange(evt); + }); + + var rows = tf.tbl.rows; + this.isCustom = tf.isCustomOptions(colIndex); + + var activeFlt = void 0; + if (tf.linkedFilters && tf.activeFilterId) { + activeFlt = tf.activeFilterId.split('_')[0]; + activeFlt = activeFlt.split(tf.prfxFlt)[1]; + } + + var filteredDataCol = []; + if (tf.linkedFilters && tf.disableExcludedOptions) { + this.excludedOpts = []; + } + + flt.innerHTML = ''; + + for (var k = tf.refRow; k < tf.nbRows; k++) { + // always visible rows don't need to appear on selects as always + // valid + if (tf.hasVisibleRows && tf.visibleRows.indexOf(k) !== -1) { + continue; + } + + var cells = rows[k].cells; + var ncells = cells.length; + + // checks if row has exact cell # + if (ncells !== tf.nbCells || this.isCustom) { + continue; + } + + // this loop retrieves cell data + for (var j = 0; j < ncells; j++) { + // WTF: cyclomatic complexity hell :) + if (colIndex === j && (!tf.linkedFilters || tf.linkedFilters && tf.disableExcludedOptions) || colIndex === j && tf.linkedFilters && (rows[k].style.display === '' && !tf.paging || tf.paging && (!activeFlt || activeFlt === colIndex || activeFlt != colIndex && tf.validRowsIndex.indexOf(k) != -1))) { + + var cellData = tf.getCellData(cells[j]); + //Vary Peter's patch + var cellString = _string2.default.matchCase(cellData, tf.matchCase); + // checks if celldata is already in array + if (!_array2.default.has(this.opts, cellString, tf.matchCase)) { + this.opts.push(cellData); + } + var filteredCol = filteredDataCol[j]; + if (tf.linkedFilters && tf.disableExcludedOptions) { + if (!filteredCol) { + filteredCol = tf.getFilteredDataCol(j); + } + if (!_array2.default.has(filteredCol, cellString, tf.matchCase) && !_array2.default.has(this.excludedOpts, cellString, tf.matchCase)) { + this.excludedOpts.push(cellData); + } + } + } } } - /** - * Initialize checklist filter - * @param {Number} colIndex Column index - * @param {Boolean} isExternal External filter flag - * @param {DOMElement} container Dom element containing the filter - */ + //Retrieves custom values + if (this.isCustom) { + var customValues = tf.getCustomOptions(colIndex); + this.opts = customValues[0]; + this.optsTxt = customValues[1]; + } - }, { - key: 'init', - value: function init(colIndex, isExternal, container) { - var _this3 = this; - - var tf = this.tf; - var externalFltTgtId = isExternal ? tf.externalFltTgtIds[colIndex] : null; - - var divCont = _dom2.default.create('div', ['id', this.prfxCheckListDiv + colIndex + '_' + tf.id], ['ct', colIndex], ['filled', '0']); - divCont.className = this.checkListDivCssClass; - - //filter is appended in desired element - if (externalFltTgtId) { - _dom2.default.id(externalFltTgtId).appendChild(divCont); - tf.externalFltEls.push(divCont); + if (tf.sortSlc && !this.isCustom) { + if (!tf.matchCase) { + this.opts.sort(_sort2.default.ignoreCase); + if (this.excludedOpts) { + this.excludedOpts.sort(_sort2.default.ignoreCase); + } } else { - container.appendChild(divCont); + this.opts.sort(); + if (this.excludedOpts) { + this.excludedOpts.sort(); + } } - - this.checkListDiv[colIndex] = divCont; - tf.fltIds.push(tf.prfxFlt + colIndex + '_' + tf.id); - - if (!tf.loadFltOnDemand) { - this.build(colIndex); - } else { - _event2.default.add(divCont, 'click', function (evt) { - return _this3.onCheckListClick(evt); - }); - divCont.appendChild(_dom2.default.text(this.activateCheckListTxt)); - } - - this.emitter.on(['build-checklist-filter'], function (tf, colIndex, isExternal) { - return _this3.build(colIndex, isExternal); - }); - - this.emitter.on(['select-checklist-options'], function (tf, colIndex, values) { - return _this3.selectOptions(colIndex, values); - }); - - this.initialized = true; + } + //asc sort + if (tf.sortNumAsc.indexOf(colIndex) != -1) { + try { + this.opts.sort(_sort2.default.numSortAsc); + if (this.excludedOpts) { + this.excludedOpts.sort(_sort2.default.numSortAsc); + } + if (this.isCustom) { + this.optsTxt.sort(_sort2.default.numSortAsc); + } + } catch (e) { + throw new Error(SORT_ERROR.replace('{0}', colIndex).replace('{1}', 'ascending')); + } //in case there are alphanumeric values + } + //desc sort + if (tf.sortNumDesc.indexOf(colIndex) != -1) { + try { + this.opts.sort(_sort2.default.numSortDesc); + if (this.excludedOpts) { + this.excludedOpts.sort(_sort2.default.numSortDesc); + } + if (this.isCustom) { + this.optsTxt.sort(_sort2.default.numSortDesc); + } + } catch (e) { + throw new Error(SORT_ERROR.replace('{0}', colIndex).replace('{1}', 'descending')); + } //in case there are alphanumeric values } - /** - * Build checklist UI - * @param {Number} colIndex Column index - */ - - }, { - key: 'build', - value: function build(colIndex) { - var _this4 = this; - - var tf = this.tf; - colIndex = parseInt(colIndex, 10); - - this.emitter.emit('before-populating-filter', tf, colIndex); - - this.opts = []; - this.optsTxt = []; - - var flt = this.checkListDiv[colIndex]; - var ul = _dom2.default.create('ul', ['id', tf.fltIds[colIndex]], ['colIndex', colIndex]); - ul.className = this.checkListCssClass; - _event2.default.add(ul, 'change', function (evt) { - return _this4.onChange(evt); - }); - - var rows = tf.tbl.rows; - this.isCustom = tf.isCustomOptions(colIndex); - - var activeFlt = void 0; - if (tf.linkedFilters && tf.activeFilterId) { - activeFlt = tf.activeFilterId.split('_')[0]; - activeFlt = activeFlt.split(tf.prfxFlt)[1]; - } - - var filteredDataCol = []; - if (tf.linkedFilters && tf.disableExcludedOptions) { - this.excludedOpts = []; - } + this.addChecks(colIndex, ul); + if (tf.loadFltOnDemand) { flt.innerHTML = ''; - - for (var k = tf.refRow; k < tf.nbRows; k++) { - // always visible rows don't need to appear on selects as always - // valid - if (tf.hasVisibleRows && tf.visibleRows.indexOf(k) !== -1) { - continue; - } - - var cells = rows[k].cells; - var ncells = cells.length; - - // checks if row has exact cell # - if (ncells !== tf.nbCells || this.isCustom) { - continue; - } - - // this loop retrieves cell data - for (var j = 0; j < ncells; j++) { - // WTF: cyclomatic complexity hell :) - if (colIndex === j && (!tf.linkedFilters || tf.linkedFilters && tf.disableExcludedOptions) || colIndex === j && tf.linkedFilters && (rows[k].style.display === '' && !tf.paging || tf.paging && (!activeFlt || activeFlt === colIndex || activeFlt != colIndex && tf.validRowsIndex.indexOf(k) != -1))) { - - var cellData = tf.getCellData(cells[j]); - //Vary Peter's patch - var cellString = _string2.default.matchCase(cellData, tf.matchCase); - // checks if celldata is already in array - if (!_array2.default.has(this.opts, cellString, tf.matchCase)) { - this.opts.push(cellData); - } - var filteredCol = filteredDataCol[j]; - if (tf.linkedFilters && tf.disableExcludedOptions) { - if (!filteredCol) { - filteredCol = tf.getFilteredDataCol(j); - } - if (!_array2.default.has(filteredCol, cellString, tf.matchCase) && !_array2.default.has(this.excludedOpts, cellString, tf.matchCase)) { - this.excludedOpts.push(cellData); - } - } - } - } - } - - //Retrieves custom values - if (this.isCustom) { - var customValues = tf.getCustomOptions(colIndex); - this.opts = customValues[0]; - this.optsTxt = customValues[1]; - } - - if (tf.sortSlc && !this.isCustom) { - if (!tf.matchCase) { - this.opts.sort(_sort2.default.ignoreCase); - if (this.excludedOpts) { - this.excludedOpts.sort(_sort2.default.ignoreCase); - } - } else { - this.opts.sort(); - if (this.excludedOpts) { - this.excludedOpts.sort(); - } - } - } - //asc sort - if (tf.sortNumAsc.indexOf(colIndex) != -1) { - try { - this.opts.sort(_sort2.default.numSortAsc); - if (this.excludedOpts) { - this.excludedOpts.sort(_sort2.default.numSortAsc); - } - if (this.isCustom) { - this.optsTxt.sort(_sort2.default.numSortAsc); - } - } catch (e) { - throw new Error(SORT_ERROR.replace('{0}', colIndex).replace('{1}', 'ascending')); - } //in case there are alphanumeric values - } - //desc sort - if (tf.sortNumDesc.indexOf(colIndex) != -1) { - try { - this.opts.sort(_sort2.default.numSortDesc); - if (this.excludedOpts) { - this.excludedOpts.sort(_sort2.default.numSortDesc); - } - if (this.isCustom) { - this.optsTxt.sort(_sort2.default.numSortDesc); - } - } catch (e) { - throw new Error(SORT_ERROR.replace('{0}', colIndex).replace('{1}', 'descending')); - } //in case there are alphanumeric values - } - - this.addChecks(colIndex, ul); - - if (tf.loadFltOnDemand) { - flt.innerHTML = ''; - } - flt.appendChild(ul); - flt.setAttribute('filled', '1'); - - this.emitter.emit('after-populating-filter', tf, colIndex, flt); } + flt.appendChild(ul); + flt.setAttribute('filled', '1'); - /** - * Add checklist options - * @param {Number} colIndex Column index - * @param {Object} ul Ul element - */ + this.emitter.emit('after-populating-filter', tf, colIndex, flt); + }; - }, { - key: 'addChecks', - value: function addChecks(colIndex, ul) { - var _this5 = this; + /** + * Add checklist options + * @param {Number} colIndex Column index + * @param {Object} ul Ul element + */ - var tf = this.tf; - var chkCt = this.addTChecks(colIndex, ul); - for (var y = 0; y < this.opts.length; y++) { - var val = this.opts[y]; //item value - var lbl = this.isCustom ? this.optsTxt[y] : val; //item text - var li = _dom2.default.createCheckItem(tf.fltIds[colIndex] + '_' + (y + chkCt), val, lbl); - li.className = this.checkListItemCssClass; - if (tf.linkedFilters && tf.disableExcludedOptions && _array2.default.has(this.excludedOpts, _string2.default.matchCase(val, tf.matchCase), tf.matchCase)) { - _dom2.default.addClass(li, this.checkListItemDisabledCssClass); - li.check.disabled = true; - li.disabled = true; - } else { - _event2.default.add(li.check, 'click', function (evt) { - return _this5.optionClick(evt); - }); - } - ul.appendChild(li); + CheckList.prototype.addChecks = function addChecks(colIndex, ul) { + var _this5 = this; - if (val === '') { - //item is hidden - li.style.display = 'none'; - } + var tf = this.tf; + var chkCt = this.addTChecks(colIndex, ul); + + for (var y = 0; y < this.opts.length; y++) { + var val = this.opts[y]; //item value + var lbl = this.isCustom ? this.optsTxt[y] : val; //item text + var li = _dom2.default.createCheckItem(tf.fltIds[colIndex] + '_' + (y + chkCt), val, lbl); + li.className = this.checkListItemCssClass; + if (tf.linkedFilters && tf.disableExcludedOptions && _array2.default.has(this.excludedOpts, _string2.default.matchCase(val, tf.matchCase), tf.matchCase)) { + _dom2.default.addClass(li, this.checkListItemDisabledCssClass); + li.check.disabled = true; + li.disabled = true; + } else { + _event2.default.add(li.check, 'click', function (evt) { + return _this5.optionClick(evt); + }); + } + ul.appendChild(li); + + if (val === '') { + //item is hidden + li.style.display = 'none'; } } + }; - /** - * Add checklist header option - * @param {Number} colIndex Column index - * @param {Object} ul Ul element - */ + /** + * Add checklist header option + * @param {Number} colIndex Column index + * @param {Object} ul Ul element + */ - }, { - key: 'addTChecks', - value: function addTChecks(colIndex, ul) { - var _this6 = this; - var tf = this.tf; - var chkCt = 1; - var li0 = _dom2.default.createCheckItem(tf.fltIds[colIndex] + '_0', '', tf.displayAllText); - li0.className = this.checkListItemCssClass; - ul.appendChild(li0); + CheckList.prototype.addTChecks = function addTChecks(colIndex, ul) { + var _this6 = this; - _event2.default.add(li0.check, 'click', function (evt) { + var tf = this.tf; + var chkCt = 1; + var li0 = _dom2.default.createCheckItem(tf.fltIds[colIndex] + '_0', '', tf.displayAllText); + li0.className = this.checkListItemCssClass; + ul.appendChild(li0); + + _event2.default.add(li0.check, 'click', function (evt) { + return _this6.optionClick(evt); + }); + + if (!this.enableCheckListResetFilter) { + li0.style.display = 'none'; + } + + if (tf.enableEmptyOption) { + var li1 = _dom2.default.createCheckItem(tf.fltIds[colIndex] + '_1', tf.emOperator, tf.emptyText); + li1.className = this.checkListItemCssClass; + ul.appendChild(li1); + _event2.default.add(li1.check, 'click', function (evt) { return _this6.optionClick(evt); }); - - if (!this.enableCheckListResetFilter) { - li0.style.display = 'none'; - } - - if (tf.enableEmptyOption) { - var li1 = _dom2.default.createCheckItem(tf.fltIds[colIndex] + '_1', tf.emOperator, tf.emptyText); - li1.className = this.checkListItemCssClass; - ul.appendChild(li1); - _event2.default.add(li1.check, 'click', function (evt) { - return _this6.optionClick(evt); - }); - chkCt++; - } - - if (tf.enableNonEmptyOption) { - var li2 = _dom2.default.createCheckItem(tf.fltIds[colIndex] + '_2', tf.nmOperator, tf.nonEmptyText); - li2.className = this.checkListItemCssClass; - ul.appendChild(li2); - _event2.default.add(li2.check, 'click', function (evt) { - return _this6.optionClick(evt); - }); - chkCt++; - } - return chkCt; + chkCt++; } - /** - * Store checked options in DOM element attribute - * @param {Object} o checklist option DOM element - */ + if (tf.enableNonEmptyOption) { + var li2 = _dom2.default.createCheckItem(tf.fltIds[colIndex] + '_2', tf.nmOperator, tf.nonEmptyText); + li2.className = this.checkListItemCssClass; + ul.appendChild(li2); + _event2.default.add(li2.check, 'click', function (evt) { + return _this6.optionClick(evt); + }); + chkCt++; + } + return chkCt; + }; - }, { - key: 'setCheckListValues', - value: function setCheckListValues(o) { - if (!o) { - return; - } + /** + * Store checked options in DOM element attribute + * @param {Object} o checklist option DOM element + */ - var tf = this.tf; - var chkValue = o.value; //checked item value - var chkIndex = parseInt(o.id.split('_')[2], 10); - // TODO: provide helper to extract column index, ugly! - var colIdx = o.id.split('_')[0].replace(tf.prfxFlt, ''); - var itemTag = 'LI'; - var n = tf.getFilterElement(parseInt(colIdx, 10)); - var li = n.childNodes[chkIndex]; - var colIndex = n.getAttribute('colIndex'); - var fltValue = n.getAttribute('value'); //filter value (ul tag) - var fltIndexes = n.getAttribute('indexes'); //selected items (ul tag) + CheckList.prototype.setCheckListValues = function setCheckListValues(o) { + if (!o) { + return; + } - if (o.checked) { - //show all item - if (chkValue === '') { - if (fltIndexes && fltIndexes !== '') { - //items indexes - var indSplit = fltIndexes.split(tf.separator); - //checked items loop - for (var u = 0; u < indSplit.length; u++) { - //checked item - var cChk = _dom2.default.id(tf.fltIds[colIndex] + '_' + indSplit[u]); - if (cChk) { - cChk.checked = false; - _dom2.default.removeClass(n.childNodes[indSplit[u]], this.checkListSlcItemCssClass); - } + var tf = this.tf; + var chkValue = o.value; //checked item value + var chkIndex = parseInt(o.id.split('_')[2], 10); + // TODO: provide helper to extract column index, ugly! + var colIdx = o.id.split('_')[0].replace(tf.prfxFlt, ''); + var itemTag = 'LI'; + + var n = tf.getFilterElement(parseInt(colIdx, 10)); + var li = n.childNodes[chkIndex]; + var colIndex = n.getAttribute('colIndex'); + var fltValue = n.getAttribute('value'); //filter value (ul tag) + var fltIndexes = n.getAttribute('indexes'); //selected items (ul tag) + + if (o.checked) { + //show all item + if (chkValue === '') { + if (fltIndexes && fltIndexes !== '') { + //items indexes + var indSplit = fltIndexes.split(tf.separator); + //checked items loop + for (var u = 0; u < indSplit.length; u++) { + //checked item + var cChk = _dom2.default.id(tf.fltIds[colIndex] + '_' + indSplit[u]); + if (cChk) { + cChk.checked = false; + _dom2.default.removeClass(n.childNodes[indSplit[u]], this.checkListSlcItemCssClass); } } - n.setAttribute('value', ''); - n.setAttribute('indexes', ''); - } else { - fltValue = fltValue ? fltValue : ''; - chkValue = _string2.default.trim(fltValue + ' ' + chkValue + ' ' + tf.orOperator); - chkIndex = fltIndexes + chkIndex + tf.separator; - n.setAttribute('value', chkValue); - n.setAttribute('indexes', chkIndex); - //1st option unchecked - if (_dom2.default.id(tf.fltIds[colIndex] + '_0')) { - _dom2.default.id(tf.fltIds[colIndex] + '_0').checked = false; - } - } - - if (li.nodeName === itemTag) { - _dom2.default.removeClass(n.childNodes[0], this.checkListSlcItemCssClass); - _dom2.default.addClass(li, this.checkListSlcItemCssClass); } + n.setAttribute('value', ''); + n.setAttribute('indexes', ''); } else { - //removes values and indexes - if (chkValue !== '') { - var replaceValue = new RegExp(_string2.default.rgxEsc(chkValue + ' ' + tf.orOperator)); - fltValue = fltValue.replace(replaceValue, ''); - n.setAttribute('value', _string2.default.trim(fltValue)); - - var replaceIndex = new RegExp(_string2.default.rgxEsc(chkIndex + tf.separator)); - fltIndexes = fltIndexes.replace(replaceIndex, ''); - n.setAttribute('indexes', fltIndexes); - } - if (li.nodeName === itemTag) { - _dom2.default.removeClass(li, this.checkListSlcItemCssClass); + fltValue = fltValue ? fltValue : ''; + chkValue = _string2.default.trim(fltValue + ' ' + chkValue + ' ' + tf.orOperator); + chkIndex = fltIndexes + chkIndex + tf.separator; + n.setAttribute('value', chkValue); + n.setAttribute('indexes', chkIndex); + //1st option unchecked + if (_dom2.default.id(tf.fltIds[colIndex] + '_0')) { + _dom2.default.id(tf.fltIds[colIndex] + '_0').checked = false; } } - } - /** - * Select filter options programmatically - * @param {Number} colIndex Column index - * @param {Array} values Array of option values to select - */ - - }, { - key: 'selectOptions', - value: function selectOptions(colIndex) { - var values = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; - - var tf = this.tf; - if (tf.getFilterType(colIndex) !== tf.fltTypeCheckList || values.length === 0) { - return; + if (li.nodeName === itemTag) { + _dom2.default.removeClass(n.childNodes[0], this.checkListSlcItemCssClass); + _dom2.default.addClass(li, this.checkListSlcItemCssClass); } - var flt = tf.getFilterElement(colIndex); + } else { + //removes values and indexes + if (chkValue !== '') { + var replaceValue = new RegExp(_string2.default.rgxEsc(chkValue + ' ' + tf.orOperator)); + fltValue = fltValue.replace(replaceValue, ''); + n.setAttribute('value', _string2.default.trim(fltValue)); - var lisNb = _dom2.default.tag(flt, 'li').length; - - flt.setAttribute('value', ''); - flt.setAttribute('indexes', ''); - - for (var k = 0; k < lisNb; k++) { - var li = _dom2.default.tag(flt, 'li')[k], - lbl = _dom2.default.tag(li, 'label')[0], - chk = _dom2.default.tag(li, 'input')[0], - lblTxt = _string2.default.matchCase(_dom2.default.getText(lbl), tf.caseSensitive); - if (lblTxt !== '' && _array2.default.has(values, lblTxt, tf.caseSensitive)) { - chk.checked = true; - this.setCheckListValues(chk); - } else { - chk.checked = false; - this.setCheckListValues(chk); - } + var replaceIndex = new RegExp(_string2.default.rgxEsc(chkIndex + tf.separator)); + fltIndexes = fltIndexes.replace(replaceIndex, ''); + n.setAttribute('indexes', fltIndexes); + } + if (li.nodeName === itemTag) { + _dom2.default.removeClass(li, this.checkListSlcItemCssClass); } } - }, { - key: 'destroy', - value: function destroy() { - var _this7 = this; + }; - this.emitter.off(['build-checklist-filter'], function (tf, colIndex, isExternal) { - return _this7.build(colIndex, isExternal); - }); - this.emitter.off(['select-checklist-options'], function (tf, colIndex, values) { - return _this7.selectOptions(colIndex, values); - }); + /** + * Select filter options programmatically + * @param {Number} colIndex Column index + * @param {Array} values Array of option values to select + */ + + + CheckList.prototype.selectOptions = function selectOptions(colIndex) { + var values = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; + + var tf = this.tf; + if (tf.getFilterType(colIndex) !== tf.fltTypeCheckList || values.length === 0) { + return; } - }]); + var flt = tf.getFilterElement(colIndex); + + var lisNb = _dom2.default.tag(flt, 'li').length; + + flt.setAttribute('value', ''); + flt.setAttribute('indexes', ''); + + for (var k = 0; k < lisNb; k++) { + var li = _dom2.default.tag(flt, 'li')[k], + lbl = _dom2.default.tag(li, 'label')[0], + chk = _dom2.default.tag(li, 'input')[0], + lblTxt = _string2.default.matchCase(_dom2.default.getText(lbl), tf.caseSensitive); + if (lblTxt !== '' && _array2.default.has(values, lblTxt, tf.caseSensitive)) { + chk.checked = true; + this.setCheckListValues(chk); + } else { + chk.checked = false; + this.setCheckListValues(chk); + } + } + }; + + CheckList.prototype.destroy = function destroy() { + var _this7 = this; + + this.emitter.off(['build-checklist-filter'], function (tf, colIndex, isExternal) { + return _this7.build(colIndex, isExternal); + }); + this.emitter.off(['select-checklist-options'], function (tf, colIndex, values) { + return _this7.selectOptions(colIndex, values); + }); + }; return CheckList; }(_feature.Feature); @@ -5740,8 +5596,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.RowsCounter = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -5773,7 +5627,7 @@ return /******/ (function(modules) { // webpackBootstrap // TableFilter configuration - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(RowsCounter).call(this, tf, 'rowsCounter')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'rowsCounter')); var f = _this.config; @@ -5802,118 +5656,113 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(RowsCounter, [{ - key: 'init', - value: function init() { - var _this2 = this; + RowsCounter.prototype.init = function init() { + var _this2 = this; - if (this.initialized) { - return; - } - - var tf = this.tf; - - //rows counter container - var countDiv = _dom2.default.create('div', ['id', this.prfxCounter + tf.id]); - countDiv.className = this.totRowsCssClass; - //rows counter label - var countSpan = _dom2.default.create('span', ['id', this.prfxTotRows + tf.id]); - var countText = _dom2.default.create('span', ['id', this.prfxTotRowsTxt + tf.id]); - countText.appendChild(_dom2.default.text(this.rowsCounterText)); - - // counter is added to defined element - if (!this.rowsCounterTgtId) { - tf.setToolbar(); - } - var targetEl = !this.rowsCounterTgtId ? tf.lDiv : _dom2.default.id(this.rowsCounterTgtId); - - //default container: 'lDiv' - if (!this.rowsCounterTgtId) { - countDiv.appendChild(countText); - countDiv.appendChild(countSpan); - targetEl.appendChild(countDiv); - } else { - //custom container, no need to append statusDiv - targetEl.appendChild(countText); - targetEl.appendChild(countSpan); - } - this.rowsCounterDiv = countDiv; - this.rowsCounterSpan = countSpan; - - // subscribe to events - this.emitter.on(['after-filtering', 'grouped-by-page'], function () { - return _this2.refresh(tf.nbVisibleRows); - }); - this.emitter.on(['rows-changed'], function () { - return _this2.refresh(); - }); - - this.initialized = true; - this.refresh(); + if (this.initialized) { + return; } - }, { - key: 'refresh', - value: function refresh(p) { - if (!this.initialized || !this.isEnabled()) { - return; - } - var tf = this.tf; + var tf = this.tf; - if (this.onBeforeRefreshCounter) { - this.onBeforeRefreshCounter.call(null, tf, this.rowsCounterSpan); - } + //rows counter container + var countDiv = _dom2.default.create('div', ['id', this.prfxCounter + tf.id]); + countDiv.className = this.totRowsCssClass; + //rows counter label + var countSpan = _dom2.default.create('span', ['id', this.prfxTotRows + tf.id]); + var countText = _dom2.default.create('span', ['id', this.prfxTotRowsTxt + tf.id]); + countText.appendChild(_dom2.default.text(this.rowsCounterText)); - var totTxt; - if (!tf.paging) { - if (p && p !== '') { - totTxt = p; - } else { - totTxt = tf.nbFilterableRows - tf.nbHiddenRows; - } + // counter is added to defined element + if (!this.rowsCounterTgtId) { + tf.setToolbar(); + } + var targetEl = !this.rowsCounterTgtId ? tf.lDiv : _dom2.default.id(this.rowsCounterTgtId); + + //default container: 'lDiv' + if (!this.rowsCounterTgtId) { + countDiv.appendChild(countText); + countDiv.appendChild(countSpan); + targetEl.appendChild(countDiv); + } else { + //custom container, no need to append statusDiv + targetEl.appendChild(countText); + targetEl.appendChild(countSpan); + } + this.rowsCounterDiv = countDiv; + this.rowsCounterSpan = countSpan; + + // subscribe to events + this.emitter.on(['after-filtering', 'grouped-by-page'], function () { + return _this2.refresh(tf.nbVisibleRows); + }); + this.emitter.on(['rows-changed'], function () { + return _this2.refresh(); + }); + + this.initialized = true; + this.refresh(); + }; + + RowsCounter.prototype.refresh = function refresh(p) { + if (!this.initialized || !this.isEnabled()) { + return; + } + + var tf = this.tf; + + if (this.onBeforeRefreshCounter) { + this.onBeforeRefreshCounter.call(null, tf, this.rowsCounterSpan); + } + + var totTxt; + if (!tf.paging) { + if (p && p !== '') { + totTxt = p; } else { - var paging = tf.feature('paging'); - if (paging) { - //paging start row - var paging_start_row = parseInt(paging.startPagingRow, 10) + (tf.nbVisibleRows > 0 ? 1 : 0); - var paging_end_row = paging_start_row + paging.pagingLength - 1 <= tf.nbVisibleRows ? paging_start_row + paging.pagingLength - 1 : tf.nbVisibleRows; - totTxt = paging_start_row + this.fromToTextSeparator + paging_end_row + this.overText + tf.nbVisibleRows; - } + totTxt = tf.nbFilterableRows - tf.nbHiddenRows; } - - this.rowsCounterSpan.innerHTML = totTxt; - if (this.onAfterRefreshCounter) { - this.onAfterRefreshCounter.call(null, tf, this.rowsCounterSpan, totTxt); + } else { + var paging = tf.feature('paging'); + if (paging) { + //paging start row + var paging_start_row = parseInt(paging.startPagingRow, 10) + (tf.nbVisibleRows > 0 ? 1 : 0); + var paging_end_row = paging_start_row + paging.pagingLength - 1 <= tf.nbVisibleRows ? paging_start_row + paging.pagingLength - 1 : tf.nbVisibleRows; + totTxt = paging_start_row + this.fromToTextSeparator + paging_end_row + this.overText + tf.nbVisibleRows; } } - }, { - key: 'destroy', - value: function destroy() { - var _this3 = this; - if (!this.initialized) { - return; - } - - if (!this.rowsCounterTgtId && this.rowsCounterDiv) { - _dom2.default.remove(this.rowsCounterDiv); - } else { - _dom2.default.id(this.rowsCounterTgtId).innerHTML = ''; - } - this.rowsCounterSpan = null; - this.rowsCounterDiv = null; - - // unsubscribe to events - this.emitter.off(['after-filtering', 'grouped-by-page'], function () { - return _this3.refresh(tf.nbVisibleRows); - }); - this.emitter.off(['rows-changed'], function () { - return _this3.refresh(); - }); - - this.initialized = false; + this.rowsCounterSpan.innerHTML = totTxt; + if (this.onAfterRefreshCounter) { + this.onAfterRefreshCounter.call(null, tf, this.rowsCounterSpan, totTxt); } - }]); + }; + + RowsCounter.prototype.destroy = function destroy() { + var _this3 = this; + + if (!this.initialized) { + return; + } + + if (!this.rowsCounterTgtId && this.rowsCounterDiv) { + _dom2.default.remove(this.rowsCounterDiv); + } else { + _dom2.default.id(this.rowsCounterTgtId).innerHTML = ''; + } + this.rowsCounterSpan = null; + this.rowsCounterDiv = null; + + // unsubscribe to events + this.emitter.off(['after-filtering', 'grouped-by-page'], function () { + return _this3.refresh(tf.nbVisibleRows); + }); + this.emitter.off(['rows-changed'], function () { + return _this3.refresh(); + }); + + this.initialized = false; + }; return RowsCounter; }(_feature.Feature); @@ -5929,8 +5778,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.StatusBar = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -5964,7 +5811,7 @@ return /******/ (function(modules) { // webpackBootstrap // Configuration object - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(StatusBar).call(this, tf, 'statusBar')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'statusBar')); var f = _this.config; @@ -6020,165 +5867,160 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(StatusBar, [{ - key: 'init', - value: function init() { - var _this2 = this; + StatusBar.prototype.init = function init() { + var _this2 = this; - if (this.initialized) { + if (this.initialized) { + return; + } + + var tf = this.tf; + var emitter = this.emitter; + + //status bar container + var statusDiv = _dom2.default.create('div', ['id', this.prfxStatus + tf.id]); + statusDiv.className = this.statusBarCssClass; + + //status bar label + var statusSpan = _dom2.default.create('span', ['id', this.prfxStatusSpan + tf.id]); + //preceding text + var statusSpanText = _dom2.default.create('span', ['id', this.prfxStatusTxt + tf.id]); + statusSpanText.appendChild(_dom2.default.text(this.statusBarText)); + + // target element container + if (!this.statusBarTgtId) { + tf.setToolbar(); + } + var targetEl = !this.statusBarTgtId ? tf.lDiv : _dom2.default.id(this.statusBarTgtId); + + //default container: 'lDiv' + if (!this.statusBarTgtId) { + statusDiv.appendChild(statusSpanText); + statusDiv.appendChild(statusSpan); + targetEl.appendChild(statusDiv); + } else { + // custom container, no need to append statusDiv + targetEl.appendChild(statusSpanText); + targetEl.appendChild(statusSpan); + } + + this.statusBarDiv = statusDiv; + this.statusBarSpan = statusSpan; + this.statusBarSpanText = statusSpanText; + + // Subscribe to events + emitter.on(['before-filtering'], function () { + return _this2.message(_this2.msgFilter); + }); + emitter.on(['before-populating-filter'], function () { + return _this2.message(_this2.msgPopulate); + }); + emitter.on(['before-page-change'], function () { + return _this2.message(_this2.msgChangePage); + }); + emitter.on(['before-clearing-filters'], function () { + return _this2.message(_this2.msgClear); + }); + emitter.on(['before-page-length-change'], function () { + return _this2.message(_this2.msgChangeResults); + }); + emitter.on(['before-reset-page'], function () { + return _this2.message(_this2.msgResetPage); + }); + emitter.on(['before-reset-page-length'], function () { + return _this2.message(_this2.msgResetPageLength); + }); + emitter.on(['before-loading-extensions'], function () { + return _this2.message(_this2.msgLoadExtensions); + }); + emitter.on(['before-loading-themes'], function () { + return _this2.message(_this2.msgLoadThemes); + }); + + emitter.on(['after-filtering', 'after-populating-filter', 'after-page-change', 'after-clearing-filters', 'after-page-length-change', 'after-reset-page', 'after-reset-page-length', 'after-loading-extensions', 'after-loading-themes'], function () { + return _this2.message(''); + }); + + this.initialized = true; + }; + + StatusBar.prototype.message = function message() { + var _this3 = this; + + var t = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; + + if (!this.isEnabled()) { + return; + } + + if (this.onBeforeShowMsg) { + this.onBeforeShowMsg.call(null, this.tf, t); + } + + var d = t === '' ? this.statusBarCloseDelay : 1; + global.setTimeout(function () { + if (!_this3.initialized) { return; } - - var tf = this.tf; - var emitter = this.emitter; - - //status bar container - var statusDiv = _dom2.default.create('div', ['id', this.prfxStatus + tf.id]); - statusDiv.className = this.statusBarCssClass; - - //status bar label - var statusSpan = _dom2.default.create('span', ['id', this.prfxStatusSpan + tf.id]); - //preceding text - var statusSpanText = _dom2.default.create('span', ['id', this.prfxStatusTxt + tf.id]); - statusSpanText.appendChild(_dom2.default.text(this.statusBarText)); - - // target element container - if (!this.statusBarTgtId) { - tf.setToolbar(); + _this3.statusBarSpan.innerHTML = t; + if (_this3.onAfterShowMsg) { + _this3.onAfterShowMsg.call(null, _this3.tf, t); } - var targetEl = !this.statusBarTgtId ? tf.lDiv : _dom2.default.id(this.statusBarTgtId); + }, d); + }; - //default container: 'lDiv' - if (!this.statusBarTgtId) { - statusDiv.appendChild(statusSpanText); - statusDiv.appendChild(statusSpan); - targetEl.appendChild(statusDiv); - } else { - // custom container, no need to append statusDiv - targetEl.appendChild(statusSpanText); - targetEl.appendChild(statusSpan); - } + StatusBar.prototype.destroy = function destroy() { + var _this4 = this; - this.statusBarDiv = statusDiv; - this.statusBarSpan = statusSpan; - this.statusBarSpanText = statusSpanText; - - // Subscribe to events - emitter.on(['before-filtering'], function () { - return _this2.message(_this2.msgFilter); - }); - emitter.on(['before-populating-filter'], function () { - return _this2.message(_this2.msgPopulate); - }); - emitter.on(['before-page-change'], function () { - return _this2.message(_this2.msgChangePage); - }); - emitter.on(['before-clearing-filters'], function () { - return _this2.message(_this2.msgClear); - }); - emitter.on(['before-page-length-change'], function () { - return _this2.message(_this2.msgChangeResults); - }); - emitter.on(['before-reset-page'], function () { - return _this2.message(_this2.msgResetPage); - }); - emitter.on(['before-reset-page-length'], function () { - return _this2.message(_this2.msgResetPageLength); - }); - emitter.on(['before-loading-extensions'], function () { - return _this2.message(_this2.msgLoadExtensions); - }); - emitter.on(['before-loading-themes'], function () { - return _this2.message(_this2.msgLoadThemes); - }); - - emitter.on(['after-filtering', 'after-populating-filter', 'after-page-change', 'after-clearing-filters', 'after-page-length-change', 'after-reset-page', 'after-reset-page-length', 'after-loading-extensions', 'after-loading-themes'], function () { - return _this2.message(''); - }); - - this.initialized = true; + if (!this.initialized) { + return; } - }, { - key: 'message', - value: function message() { - var _this3 = this; - var t = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0]; + var emitter = this.emitter; - if (!this.isEnabled()) { - return; - } - - if (this.onBeforeShowMsg) { - this.onBeforeShowMsg.call(null, this.tf, t); - } - - var d = t === '' ? this.statusBarCloseDelay : 1; - global.setTimeout(function () { - if (!_this3.initialized) { - return; - } - _this3.statusBarSpan.innerHTML = t; - if (_this3.onAfterShowMsg) { - _this3.onAfterShowMsg.call(null, _this3.tf, t); - } - }, d); + this.statusBarDiv.innerHTML = ''; + if (!this.statusBarTgtId) { + _dom2.default.remove(this.statusBarDiv); } - }, { - key: 'destroy', - value: function destroy() { - var _this4 = this; + this.statusBarSpan = null; + this.statusBarSpanText = null; + this.statusBarDiv = null; - if (!this.initialized) { - return; - } + // Unsubscribe to events + emitter.off(['before-filtering'], function () { + return _this4.message(_this4.msgFilter); + }); + emitter.off(['before-populating-filter'], function () { + return _this4.message(_this4.msgPopulate); + }); + emitter.off(['before-page-change'], function () { + return _this4.message(_this4.msgChangePage); + }); + emitter.off(['before-clearing-filters'], function () { + return _this4.message(_this4.msgClear); + }); + emitter.off(['before-page-length-change'], function () { + return _this4.message(_this4.msgChangeResults); + }); + emitter.off(['before-reset-page'], function () { + return _this4.message(_this4.msgResetPage); + }); + emitter.off(['before-reset-page-length'], function () { + return _this4.message(_this4.msgResetPageLength); + }); + emitter.off(['before-loading-extensions'], function () { + return _this4.message(_this4.msgLoadExtensions); + }); + emitter.off(['before-loading-themes'], function () { + return _this4.message(_this4.msgLoadThemes); + }); - var emitter = this.emitter; + emitter.off(['after-filtering', 'after-populating-filter', 'after-page-change', 'after-clearing-filters', 'after-page-length-change', 'after-reset-page', 'after-reset-page-length', 'after-loading-extensions', 'after-loading-themes'], function () { + return _this4.message(''); + }); - this.statusBarDiv.innerHTML = ''; - if (!this.statusBarTgtId) { - _dom2.default.remove(this.statusBarDiv); - } - this.statusBarSpan = null; - this.statusBarSpanText = null; - this.statusBarDiv = null; - - // Unsubscribe to events - emitter.off(['before-filtering'], function () { - return _this4.message(_this4.msgFilter); - }); - emitter.off(['before-populating-filter'], function () { - return _this4.message(_this4.msgPopulate); - }); - emitter.off(['before-page-change'], function () { - return _this4.message(_this4.msgChangePage); - }); - emitter.off(['before-clearing-filters'], function () { - return _this4.message(_this4.msgClear); - }); - emitter.off(['before-page-length-change'], function () { - return _this4.message(_this4.msgChangeResults); - }); - emitter.off(['before-reset-page'], function () { - return _this4.message(_this4.msgResetPage); - }); - emitter.off(['before-reset-page-length'], function () { - return _this4.message(_this4.msgResetPageLength); - }); - emitter.off(['before-loading-extensions'], function () { - return _this4.message(_this4.msgLoadExtensions); - }); - emitter.off(['before-loading-themes'], function () { - return _this4.message(_this4.msgLoadThemes); - }); - - emitter.off(['after-filtering', 'after-populating-filter', 'after-page-change', 'after-clearing-filters', 'after-page-length-change', 'after-reset-page', 'after-reset-page-length', 'after-loading-extensions', 'after-loading-themes'], function () { - return _this4.message(''); - }); - - this.initialized = false; - } - }]); + this.initialized = false; + }; return StatusBar; }(_feature.Feature); @@ -6196,8 +6038,6 @@ return /******/ (function(modules) { // webpackBootstrap var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -6237,7 +6077,7 @@ return /******/ (function(modules) { // webpackBootstrap // Configuration object - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Paging).call(this, tf, 'paging')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'paging')); var f = _this.config; @@ -6387,625 +6227,607 @@ return /******/ (function(modules) { // webpackBootstrap */ - _createClass(Paging, [{ - key: 'init', - value: function init() { - var _this2 = this; + Paging.prototype.init = function init() { + var _this2 = this; - var slcPages; - var tf = this.tf; - var evt = this.evt; + var slcPages; + var tf = this.tf; + var evt = this.evt; - if (this.initialized) { - return; + if (this.initialized) { + return; + } + + // Check resultsPerPage is in expected format and initialise the + // results per page component + if (this.hasResultsPerPage) { + if (this.resultsPerPage.length < 2) { + this.hasResultsPerPage = false; + } else { + this.pagingLength = this.resultsPerPage[1][0]; + this.setResultsPerPage(); } + } - // Check resultsPerPage is in expected format and initialise the - // results per page component - if (this.hasResultsPerPage) { - if (this.resultsPerPage.length < 2) { - this.hasResultsPerPage = false; - } else { - this.pagingLength = this.resultsPerPage[1][0]; - this.setResultsPerPage(); - } + evt.slcPagesChange = function (event) { + var slc = event.target; + _this2.changePage(slc.selectedIndex); + }; + + // Paging drop-down list selector + if (this.pageSelectorType === tf.fltTypeSlc) { + slcPages = _dom2.default.create(tf.fltTypeSlc, ['id', this.prfxSlcPages + tf.id]); + slcPages.className = this.pgSlcCssClass; + _event2.default.add(slcPages, 'change', evt.slcPagesChange); + } + + // Paging input selector + if (this.pageSelectorType === tf.fltTypeInp) { + slcPages = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxSlcPages + tf.id], ['value', this.currentPageNb]); + slcPages.className = this.pgInpCssClass; + _event2.default.add(slcPages, 'keypress', evt._detectKey); + } + + // btns containers + var btnNextSpan = _dom2.default.create('span', ['id', this.prfxBtnNextSpan + tf.id]); + var btnPrevSpan = _dom2.default.create('span', ['id', this.prfxBtnPrevSpan + tf.id]); + var btnLastSpan = _dom2.default.create('span', ['id', this.prfxBtnLastSpan + tf.id]); + var btnFirstSpan = _dom2.default.create('span', ['id', this.prfxBtnFirstSpan + tf.id]); + + if (this.hasPagingBtns) { + // Next button + if (!this.btnNextPageHtml) { + var btn_next = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxBtnNext + tf.id], ['type', 'button'], ['value', this.btnNextPageText], ['title', 'Next']); + btn_next.className = this.btnPageCssClass; + _event2.default.add(btn_next, 'click', evt.next); + btnNextSpan.appendChild(btn_next); + } else { + btnNextSpan.innerHTML = this.btnNextPageHtml; + _event2.default.add(btnNextSpan, 'click', evt.next); } + // Previous button + if (!this.btnPrevPageHtml) { + var btn_prev = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxBtnPrev + tf.id], ['type', 'button'], ['value', this.btnPrevPageText], ['title', 'Previous']); + btn_prev.className = this.btnPageCssClass; + _event2.default.add(btn_prev, 'click', evt.prev); + btnPrevSpan.appendChild(btn_prev); + } else { + btnPrevSpan.innerHTML = this.btnPrevPageHtml; + _event2.default.add(btnPrevSpan, 'click', evt.prev); + } + // Last button + if (!this.btnLastPageHtml) { + var btn_last = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxBtnLast + tf.id], ['type', 'button'], ['value', this.btnLastPageText], ['title', 'Last']); + btn_last.className = this.btnPageCssClass; + _event2.default.add(btn_last, 'click', evt.last); + btnLastSpan.appendChild(btn_last); + } else { + btnLastSpan.innerHTML = this.btnLastPageHtml; + _event2.default.add(btnLastSpan, 'click', evt.last); + } + // First button + if (!this.btnFirstPageHtml) { + var btn_first = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxBtnFirst + tf.id], ['type', 'button'], ['value', this.btnFirstPageText], ['title', 'First']); + btn_first.className = this.btnPageCssClass; + _event2.default.add(btn_first, 'click', evt.first); + btnFirstSpan.appendChild(btn_first); + } else { + btnFirstSpan.innerHTML = this.btnFirstPageHtml; + _event2.default.add(btnFirstSpan, 'click', evt.first); + } + } - evt.slcPagesChange = function (event) { - var slc = event.target; - _this2.changePage(slc.selectedIndex); - }; + // paging elements (buttons+drop-down list) are added to defined element + if (!this.pagingTgtId) { + tf.setToolbar(); + } + var targetEl = !this.pagingTgtId ? tf.mDiv : _dom2.default.id(this.pagingTgtId); + targetEl.appendChild(btnFirstSpan); + targetEl.appendChild(btnPrevSpan); - // Paging drop-down list selector + var pgBeforeSpan = _dom2.default.create('span', ['id', this.prfxPgBeforeSpan + tf.id]); + pgBeforeSpan.appendChild(_dom2.default.text(this.pageText)); + pgBeforeSpan.className = this.nbPgSpanCssClass; + targetEl.appendChild(pgBeforeSpan); + targetEl.appendChild(slcPages); + var pgAfterSpan = _dom2.default.create('span', ['id', this.prfxPgAfterSpan + tf.id]); + pgAfterSpan.appendChild(_dom2.default.text(this.ofText)); + pgAfterSpan.className = this.nbPgSpanCssClass; + targetEl.appendChild(pgAfterSpan); + var pgspan = _dom2.default.create('span', ['id', this.prfxPgSpan + tf.id]); + pgspan.className = this.nbPgSpanCssClass; + pgspan.appendChild(_dom2.default.text(' ' + this.nbPages + ' ')); + targetEl.appendChild(pgspan); + targetEl.appendChild(btnNextSpan); + targetEl.appendChild(btnLastSpan); + this.pagingSlc = _dom2.default.id(this.prfxSlcPages + tf.id); + + if (!tf.rememberGridValues) { + this.setPagingInfo(); + } + if (!tf.fltGrid) { + tf.validateAllRows(); + this.setPagingInfo(tf.validRowsIndex); + } + + this.emitter.on(['after-filtering'], function () { + return _this2.resetPagingInfo(); + }); + this.emitter.on(['initialized'], function () { + return _this2.resetValues(); + }); + this.emitter.on(['change-page'], function (tf, pageNumber) { + return _this2.setPage(pageNumber); + }); + this.emitter.on(['change-page-results'], function (tf, pageLength) { + return _this2.changeResultsPerPage(pageLength); + }); + + this.initialized = true; + }; + + /** + * Reset paging when filters are already instantiated + * @param {Boolean} filterTable Execute filtering once paging instanciated + */ + + + Paging.prototype.reset = function reset() { + var filterTable = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; + + var tf = this.tf; + if (this.isEnabled()) { + return; + } + this.enable(); + this.init(); + + if (filterTable) { + tf.filter(); + } + }; + + /** + * Reset paging info from scratch after a filtering process + */ + + + Paging.prototype.resetPagingInfo = function resetPagingInfo() { + this.startPagingRow = 0; + this.currentPageNb = 1; + this.setPagingInfo(this.tf.validRowsIndex); + }; + + /** + * Calculate number of pages based on valid rows + * Refresh paging select according to number of pages + * @param {Array} validRows Collection of valid rows + */ + + + Paging.prototype.setPagingInfo = function setPagingInfo(validRows) { + var tf = this.tf; + var mdiv = !this.pagingTgtId ? tf.mDiv : _dom2.default.id(this.pagingTgtId); + var pgspan = _dom2.default.id(this.prfxPgSpan + tf.id); + + //store valid rows indexes + tf.validRowsIndex = validRows || tf.getValidRows(true); + + //calculate nb of pages + this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pagingLength); + //refresh page nb span + pgspan.innerHTML = this.nbPages; + //select clearing shortcut + if (this.pageSelectorType === tf.fltTypeSlc) { + this.pagingSlc.innerHTML = ''; + } + + if (this.nbPages > 0) { + mdiv.style.visibility = 'visible'; if (this.pageSelectorType === tf.fltTypeSlc) { - slcPages = _dom2.default.create(tf.fltTypeSlc, ['id', this.prfxSlcPages + tf.id]); - slcPages.className = this.pgSlcCssClass; - _event2.default.add(slcPages, 'change', evt.slcPagesChange); - } - - // Paging input selector - if (this.pageSelectorType === tf.fltTypeInp) { - slcPages = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxSlcPages + tf.id], ['value', this.currentPageNb]); - slcPages.className = this.pgInpCssClass; - _event2.default.add(slcPages, 'keypress', evt._detectKey); - } - - // btns containers - var btnNextSpan = _dom2.default.create('span', ['id', this.prfxBtnNextSpan + tf.id]); - var btnPrevSpan = _dom2.default.create('span', ['id', this.prfxBtnPrevSpan + tf.id]); - var btnLastSpan = _dom2.default.create('span', ['id', this.prfxBtnLastSpan + tf.id]); - var btnFirstSpan = _dom2.default.create('span', ['id', this.prfxBtnFirstSpan + tf.id]); - - if (this.hasPagingBtns) { - // Next button - if (!this.btnNextPageHtml) { - var btn_next = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxBtnNext + tf.id], ['type', 'button'], ['value', this.btnNextPageText], ['title', 'Next']); - btn_next.className = this.btnPageCssClass; - _event2.default.add(btn_next, 'click', evt.next); - btnNextSpan.appendChild(btn_next); - } else { - btnNextSpan.innerHTML = this.btnNextPageHtml; - _event2.default.add(btnNextSpan, 'click', evt.next); - } - // Previous button - if (!this.btnPrevPageHtml) { - var btn_prev = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxBtnPrev + tf.id], ['type', 'button'], ['value', this.btnPrevPageText], ['title', 'Previous']); - btn_prev.className = this.btnPageCssClass; - _event2.default.add(btn_prev, 'click', evt.prev); - btnPrevSpan.appendChild(btn_prev); - } else { - btnPrevSpan.innerHTML = this.btnPrevPageHtml; - _event2.default.add(btnPrevSpan, 'click', evt.prev); - } - // Last button - if (!this.btnLastPageHtml) { - var btn_last = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxBtnLast + tf.id], ['type', 'button'], ['value', this.btnLastPageText], ['title', 'Last']); - btn_last.className = this.btnPageCssClass; - _event2.default.add(btn_last, 'click', evt.last); - btnLastSpan.appendChild(btn_last); - } else { - btnLastSpan.innerHTML = this.btnLastPageHtml; - _event2.default.add(btnLastSpan, 'click', evt.last); - } - // First button - if (!this.btnFirstPageHtml) { - var btn_first = _dom2.default.create(tf.fltTypeInp, ['id', this.prfxBtnFirst + tf.id], ['type', 'button'], ['value', this.btnFirstPageText], ['title', 'First']); - btn_first.className = this.btnPageCssClass; - _event2.default.add(btn_first, 'click', evt.first); - btnFirstSpan.appendChild(btn_first); - } else { - btnFirstSpan.innerHTML = this.btnFirstPageHtml; - _event2.default.add(btnFirstSpan, 'click', evt.first); - } - } - - // paging elements (buttons+drop-down list) are added to defined element - if (!this.pagingTgtId) { - tf.setToolbar(); - } - var targetEl = !this.pagingTgtId ? tf.mDiv : _dom2.default.id(this.pagingTgtId); - targetEl.appendChild(btnFirstSpan); - targetEl.appendChild(btnPrevSpan); - - var pgBeforeSpan = _dom2.default.create('span', ['id', this.prfxPgBeforeSpan + tf.id]); - pgBeforeSpan.appendChild(_dom2.default.text(this.pageText)); - pgBeforeSpan.className = this.nbPgSpanCssClass; - targetEl.appendChild(pgBeforeSpan); - targetEl.appendChild(slcPages); - var pgAfterSpan = _dom2.default.create('span', ['id', this.prfxPgAfterSpan + tf.id]); - pgAfterSpan.appendChild(_dom2.default.text(this.ofText)); - pgAfterSpan.className = this.nbPgSpanCssClass; - targetEl.appendChild(pgAfterSpan); - var pgspan = _dom2.default.create('span', ['id', this.prfxPgSpan + tf.id]); - pgspan.className = this.nbPgSpanCssClass; - pgspan.appendChild(_dom2.default.text(' ' + this.nbPages + ' ')); - targetEl.appendChild(pgspan); - targetEl.appendChild(btnNextSpan); - targetEl.appendChild(btnLastSpan); - this.pagingSlc = _dom2.default.id(this.prfxSlcPages + tf.id); - - if (!tf.rememberGridValues) { - this.setPagingInfo(); - } - if (!tf.fltGrid) { - tf.validateAllRows(); - this.setPagingInfo(tf.validRowsIndex); - } - - this.emitter.on(['after-filtering'], function () { - return _this2.resetPagingInfo(); - }); - this.emitter.on(['initialized'], function () { - return _this2.resetValues(); - }); - this.emitter.on(['change-page'], function (tf, pageNumber) { - return _this2.setPage(pageNumber); - }); - this.emitter.on(['change-page-results'], function (tf, pageLength) { - return _this2.changeResultsPerPage(pageLength); - }); - - this.initialized = true; - } - - /** - * Reset paging when filters are already instantiated - * @param {Boolean} filterTable Execute filtering once paging instanciated - */ - - }, { - key: 'reset', - value: function reset() { - var filterTable = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; - - var tf = this.tf; - if (this.isEnabled()) { - return; - } - this.enable(); - this.init(); - - if (filterTable) { - tf.filter(); - } - } - - /** - * Reset paging info from scratch after a filtering process - */ - - }, { - key: 'resetPagingInfo', - value: function resetPagingInfo() { - this.startPagingRow = 0; - this.currentPageNb = 1; - this.setPagingInfo(this.tf.validRowsIndex); - } - - /** - * Calculate number of pages based on valid rows - * Refresh paging select according to number of pages - * @param {Array} validRows Collection of valid rows - */ - - }, { - key: 'setPagingInfo', - value: function setPagingInfo(validRows) { - var tf = this.tf; - var mdiv = !this.pagingTgtId ? tf.mDiv : _dom2.default.id(this.pagingTgtId); - var pgspan = _dom2.default.id(this.prfxPgSpan + tf.id); - - //store valid rows indexes - tf.validRowsIndex = validRows || tf.getValidRows(true); - - //calculate nb of pages - this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pagingLength); - //refresh page nb span - pgspan.innerHTML = this.nbPages; - //select clearing shortcut - if (this.pageSelectorType === tf.fltTypeSlc) { - this.pagingSlc.innerHTML = ''; - } - - if (this.nbPages > 0) { - mdiv.style.visibility = 'visible'; - if (this.pageSelectorType === tf.fltTypeSlc) { - for (var z = 0; z < this.nbPages; z++) { - var opt = _dom2.default.createOpt(z + 1, z * this.pagingLength, false); - this.pagingSlc.options[z] = opt; - } - } else { - //input type - this.pagingSlc.value = this.currentPageNb; + for (var z = 0; z < this.nbPages; z++) { + var opt = _dom2.default.createOpt(z + 1, z * this.pagingLength, false); + this.pagingSlc.options[z] = opt; } } else { - /*** if no results paging select and buttons are hidden ***/ - mdiv.style.visibility = 'hidden'; + //input type + this.pagingSlc.value = this.currentPageNb; } - this.groupByPage(tf.validRowsIndex); + } else { + /*** if no results paging select and buttons are hidden ***/ + mdiv.style.visibility = 'hidden'; + } + this.groupByPage(tf.validRowsIndex); + }; + + /** + * Group table rows by page and display valid rows + * @param {Array} validRows Collection of valid rows + */ + + + Paging.prototype.groupByPage = function groupByPage(validRows) { + var tf = this.tf; + var rows = tf.tbl.rows; + var startPagingRow = parseInt(this.startPagingRow, 10); + var endPagingRow = startPagingRow + parseInt(this.pagingLength, 10); + + //store valid rows indexes + if (validRows) { + tf.validRowsIndex = validRows; } - /** - * Group table rows by page and display valid rows - * @param {Array} validRows Collection of valid rows - */ + //this loop shows valid rows of current page + for (var h = 0, len = tf.validRowsIndex.length; h < len; h++) { + var validRowIdx = tf.validRowsIndex[h]; + var r = rows[validRowIdx]; + var isRowValid = r.getAttribute('validRow'); + var rowDisplayed = false; - }, { - key: 'groupByPage', - value: function groupByPage(validRows) { - var tf = this.tf; - var rows = tf.tbl.rows; - var startPagingRow = parseInt(this.startPagingRow, 10); - var endPagingRow = startPagingRow + parseInt(this.pagingLength, 10); - - //store valid rows indexes - if (validRows) { - tf.validRowsIndex = validRows; - } - - //this loop shows valid rows of current page - for (var h = 0, len = tf.validRowsIndex.length; h < len; h++) { - var validRowIdx = tf.validRowsIndex[h]; - var r = rows[validRowIdx]; - var isRowValid = r.getAttribute('validRow'); - var rowDisplayed = false; - - if (h >= startPagingRow && h < endPagingRow) { - if (_types2.default.isNull(isRowValid) || Boolean(isRowValid === 'true')) { - r.style.display = ''; - rowDisplayed = true; - } - } else { - r.style.display = 'none'; + if (h >= startPagingRow && h < endPagingRow) { + if (_types2.default.isNull(isRowValid) || Boolean(isRowValid === 'true')) { + r.style.display = ''; + rowDisplayed = true; } - this.emitter.emit('row-paged', tf, validRowIdx, h, rowDisplayed); - } - - tf.nbVisibleRows = tf.validRowsIndex.length; - - // broadcast grouping by page - this.emitter.emit('grouped-by-page', tf, this); - } - - /** - * Return the current page number - * @return {Number} Page number - */ - - }, { - key: 'getPage', - value: function getPage() { - return this.currentPageNb; - } - - /** - * Show page based on passed param value (string or number): - * @param {String}/{Number} cmd possible string values: 'next', - * 'previous', 'last', 'first' or page number as per param - */ - - }, { - key: 'setPage', - value: function setPage(cmd) { - var tf = this.tf; - if (!tf.hasGrid() || !this.isEnabled()) { - return; - } - var btnEvt = this.evt, - cmdtype = typeof cmd === 'undefined' ? 'undefined' : _typeof(cmd); - if (cmdtype === 'string') { - switch (_string2.default.lower(cmd)) { - case 'next': - btnEvt.next(); - break; - case 'previous': - btnEvt.prev(); - break; - case 'last': - btnEvt.last(); - break; - case 'first': - btnEvt.first(); - break; - default: - btnEvt.next(); - break; - } - } else if (cmdtype === 'number') { - this.changePage(cmd - 1); - } - } - - /** - * Generates UI elements for the number of results per page drop-down - */ - - }, { - key: 'setResultsPerPage', - value: function setResultsPerPage() { - var _this3 = this; - - var tf = this.tf; - var evt = this.evt; - - if (this.resultsPerPageSlc || !this.resultsPerPage) { - return; - } - - evt.slcResultsChange = function (ev) { - _this3.onChangeResultsPerPage(); - ev.target.blur(); - }; - - var slcR = _dom2.default.create(tf.fltTypeSlc, ['id', this.prfxSlcResults + tf.id]); - slcR.className = this.resultsSlcCssClass; - var slcRText = this.resultsPerPage[0], - slcROpts = this.resultsPerPage[1]; - var slcRSpan = _dom2.default.create('span', ['id', this.prfxSlcResultsTxt + tf.id]); - slcRSpan.className = this.resultsSpanCssClass; - - // results per page select is added to external element - if (!this.resultsPerPageTgtId) { - tf.setToolbar(); - } - var targetEl = !this.resultsPerPageTgtId ? tf.rDiv : _dom2.default.id(this.resultsPerPageTgtId); - slcRSpan.appendChild(_dom2.default.text(slcRText)); - - var help = tf.feature('help'); - if (help && help.btn) { - help.btn.parentNode.insertBefore(slcRSpan, help.btn); - help.btn.parentNode.insertBefore(slcR, help.btn); } else { - targetEl.appendChild(slcRSpan); - targetEl.appendChild(slcR); + r.style.display = 'none'; } - - for (var r = 0; r < slcROpts.length; r++) { - var currOpt = new Option(slcROpts[r], slcROpts[r], false, false); - slcR.options[r] = currOpt; - } - _event2.default.add(slcR, 'change', evt.slcResultsChange); - this.resultsPerPageSlc = slcR; + this.emitter.emit('row-paged', tf, validRowIdx, h, rowDisplayed); } - /** - * Remove number of results per page UI elements - */ + tf.nbVisibleRows = tf.validRowsIndex.length; - }, { - key: 'removeResultsPerPage', - value: function removeResultsPerPage() { - var tf = this.tf; - if (!tf.hasGrid() || !this.resultsPerPageSlc || !this.resultsPerPage) { - return; + // broadcast grouping by page + this.emitter.emit('grouped-by-page', tf, this); + }; + + /** + * Return the current page number + * @return {Number} Page number + */ + + + Paging.prototype.getPage = function getPage() { + return this.currentPageNb; + }; + + /** + * Show page based on passed param value (string or number): + * @param {String}/{Number} cmd possible string values: 'next', + * 'previous', 'last', 'first' or page number as per param + */ + + + Paging.prototype.setPage = function setPage(cmd) { + var tf = this.tf; + if (!tf.hasGrid() || !this.isEnabled()) { + return; + } + var btnEvt = this.evt, + cmdtype = typeof cmd === 'undefined' ? 'undefined' : _typeof(cmd); + if (cmdtype === 'string') { + switch (_string2.default.lower(cmd)) { + case 'next': + btnEvt.next(); + break; + case 'previous': + btnEvt.prev(); + break; + case 'last': + btnEvt.last(); + break; + case 'first': + btnEvt.first(); + break; + default: + btnEvt.next(); + break; } - var slcR = this.resultsPerPageSlc, - slcRSpan = _dom2.default.id(this.prfxSlcResultsTxt + tf.id); - if (slcR) { - _dom2.default.remove(slcR); - } - if (slcRSpan) { - _dom2.default.remove(slcRSpan); - } - this.resultsPerPageSlc = null; + } else if (cmdtype === 'number') { + this.changePage(cmd - 1); + } + }; + + /** + * Generates UI elements for the number of results per page drop-down + */ + + + Paging.prototype.setResultsPerPage = function setResultsPerPage() { + var _this3 = this; + + var tf = this.tf; + var evt = this.evt; + + if (this.resultsPerPageSlc || !this.resultsPerPage) { + return; } - /** - * Change the page according to passed index - * @param {Number} index Index of the page (0-n) - */ + evt.slcResultsChange = function (ev) { + _this3.onChangeResultsPerPage(); + ev.target.blur(); + }; - }, { - key: 'changePage', - value: function changePage(index) { - var tf = this.tf; + var slcR = _dom2.default.create(tf.fltTypeSlc, ['id', this.prfxSlcResults + tf.id]); + slcR.className = this.resultsSlcCssClass; + var slcRText = this.resultsPerPage[0], + slcROpts = this.resultsPerPage[1]; + var slcRSpan = _dom2.default.create('span', ['id', this.prfxSlcResultsTxt + tf.id]); + slcRSpan.className = this.resultsSpanCssClass; - if (!this.isEnabled()) { - return; - } - - this.emitter.emit('before-page-change', tf, index + 1); - - if (index === null) { - index = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.options.selectedIndex : this.pagingSlc.value - 1; - } - if (index >= 0 && index <= this.nbPages - 1) { - if (this.onBeforeChangePage) { - this.onBeforeChangePage.call(null, this, index + 1); - } - this.currentPageNb = parseInt(index, 10) + 1; - if (this.pageSelectorType === tf.fltTypeSlc) { - this.pagingSlc.options[index].selected = true; - } else { - this.pagingSlc.value = this.currentPageNb; - } - - this.startPagingRow = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.value : index * this.pagingLength; - - this.groupByPage(); - - if (this.onAfterChangePage) { - this.onAfterChangePage.call(null, this, index + 1); - } - } - - this.emitter.emit('after-page-change', tf, index + 1); + // results per page select is added to external element + if (!this.resultsPerPageTgtId) { + tf.setToolbar(); } - }, { - key: 'changeResultsPerPage', - value: function changeResultsPerPage(val) { - if (!this.isEnabled() || isNaN(val)) { - return; - } + var targetEl = !this.resultsPerPageTgtId ? tf.rDiv : _dom2.default.id(this.resultsPerPageTgtId); + slcRSpan.appendChild(_dom2.default.text(slcRText)); - this.resultsPerPageSlc.value = val; - this.onChangeResultsPerPage(); + var help = tf.feature('help'); + if (help && help.btn) { + help.btn.parentNode.insertBefore(slcRSpan, help.btn); + help.btn.parentNode.insertBefore(slcR, help.btn); + } else { + targetEl.appendChild(slcRSpan); + targetEl.appendChild(slcR); } - /** - * Change rows according to page results drop-down - */ + for (var r = 0; r < slcROpts.length; r++) { + var currOpt = new Option(slcROpts[r], slcROpts[r], false, false); + slcR.options[r] = currOpt; + } + _event2.default.add(slcR, 'change', evt.slcResultsChange); + this.resultsPerPageSlc = slcR; + }; - }, { - key: 'onChangeResultsPerPage', - value: function onChangeResultsPerPage() { - var tf = this.tf; + /** + * Remove number of results per page UI elements + */ - if (!this.isEnabled()) { - return; - } - this.emitter.emit('before-page-length-change', tf); + Paging.prototype.removeResultsPerPage = function removeResultsPerPage() { + var tf = this.tf; + if (!tf.hasGrid() || !this.resultsPerPageSlc || !this.resultsPerPage) { + return; + } + var slcR = this.resultsPerPageSlc, + slcRSpan = _dom2.default.id(this.prfxSlcResultsTxt + tf.id); + if (slcR) { + _dom2.default.remove(slcR); + } + if (slcRSpan) { + _dom2.default.remove(slcRSpan); + } + this.resultsPerPageSlc = null; + }; - var slcR = this.resultsPerPageSlc; - var slcIndex = slcR.selectedIndex; - var slcPagesSelIndex = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.selectedIndex : parseInt(this.pagingSlc.value - 1, 10); - this.pagingLength = parseInt(slcR.options[slcIndex].value, 10); - this.startPagingRow = this.pagingLength * slcPagesSelIndex; + /** + * Change the page according to passed index + * @param {Number} index Index of the page (0-n) + */ - if (!isNaN(this.pagingLength)) { - if (this.startPagingRow >= tf.nbFilterableRows) { - this.startPagingRow = tf.nbFilterableRows - this.pagingLength; - } - this.setPagingInfo(); - if (this.pageSelectorType === tf.fltTypeSlc) { - var slcIdx = this.pagingSlc.options.length - 1 <= slcPagesSelIndex ? this.pagingSlc.options.length - 1 : slcPagesSelIndex; - this.pagingSlc.options[slcIdx].selected = true; - } - } + Paging.prototype.changePage = function changePage(index) { + var tf = this.tf; - this.emitter.emit('after-page-length-change', tf, this.pagingLength); + if (!this.isEnabled()) { + return; } - /** - * Re-set persisted pagination info - */ + this.emitter.emit('before-page-change', tf, index + 1); - }, { - key: 'resetValues', - value: function resetValues() { - var tf = this.tf; - if (tf.rememberPageLen) { - this.resetPageLength(); + if (index === null) { + index = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.options.selectedIndex : this.pagingSlc.value - 1; + } + if (index >= 0 && index <= this.nbPages - 1) { + if (this.onBeforeChangePage) { + this.onBeforeChangePage.call(null, this, index + 1); } - if (tf.rememberPageNb) { - this.resetPage(); + this.currentPageNb = parseInt(index, 10) + 1; + if (this.pageSelectorType === tf.fltTypeSlc) { + this.pagingSlc.options[index].selected = true; + } else { + this.pagingSlc.value = this.currentPageNb; + } + + this.startPagingRow = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.value : index * this.pagingLength; + + this.groupByPage(); + + if (this.onAfterChangePage) { + this.onAfterChangePage.call(null, this, index + 1); } } - /** - * Re-set page nb at page re-load - */ + this.emitter.emit('after-page-change', tf, index + 1); + }; - }, { - key: 'resetPage', - value: function resetPage() { - var tf = this.tf; - if (!this.isEnabled()) { - return; - } - this.emitter.emit('before-reset-page', tf); - var pgNb = tf.feature('store').getPageNb(); - if (pgNb !== '') { - this.changePage(pgNb - 1); - } - this.emitter.emit('after-reset-page', tf, pgNb); + Paging.prototype.changeResultsPerPage = function changeResultsPerPage(val) { + if (!this.isEnabled() || isNaN(val)) { + return; } - /** - * Re-set page length value at page re-load - */ + this.resultsPerPageSlc.value = val; + this.onChangeResultsPerPage(); + }; - }, { - key: 'resetPageLength', - value: function resetPageLength() { - var tf = this.tf; - if (!this.isEnabled()) { - return; - } - this.emitter.emit('before-reset-page-length', tf); - var pglenIndex = tf.feature('store').getPageLength(); + /** + * Change rows according to page results drop-down + */ - if (pglenIndex !== '') { - this.resultsPerPageSlc.options[pglenIndex].selected = true; - this.changeResultsPerPage(); - } - this.emitter.emit('after-reset-page-length', tf, pglenIndex); + + Paging.prototype.onChangeResultsPerPage = function onChangeResultsPerPage() { + var tf = this.tf; + + if (!this.isEnabled()) { + return; } - /** - * Remove paging feature - */ + this.emitter.emit('before-page-length-change', tf); - }, { - key: 'destroy', - value: function destroy() { - var _this4 = this; + var slcR = this.resultsPerPageSlc; + var slcIndex = slcR.selectedIndex; + var slcPagesSelIndex = this.pageSelectorType === tf.fltTypeSlc ? this.pagingSlc.selectedIndex : parseInt(this.pagingSlc.value - 1, 10); + this.pagingLength = parseInt(slcR.options[slcIndex].value, 10); + this.startPagingRow = this.pagingLength * slcPagesSelIndex; - var tf = this.tf; - - if (!this.initialized) { - return; + if (!isNaN(this.pagingLength)) { + if (this.startPagingRow >= tf.nbFilterableRows) { + this.startPagingRow = tf.nbFilterableRows - this.pagingLength; } - // btns containers - var btnNextSpan = _dom2.default.id(this.prfxBtnNextSpan + tf.id); - var btnPrevSpan = _dom2.default.id(this.prfxBtnPrevSpan + tf.id); - var btnLastSpan = _dom2.default.id(this.prfxBtnLastSpan + tf.id); - var btnFirstSpan = _dom2.default.id(this.prfxBtnFirstSpan + tf.id); - //span containing 'Page' text - var pgBeforeSpan = _dom2.default.id(this.prfxPgBeforeSpan + tf.id); - //span containing 'of' text - var pgAfterSpan = _dom2.default.id(this.prfxPgAfterSpan + tf.id); - //span containing nb of pages - var pgspan = _dom2.default.id(this.prfxPgSpan + tf.id); + this.setPagingInfo(); - var evt = this.evt; - - if (this.pagingSlc) { - if (this.pageSelectorType === tf.fltTypeSlc) { - _event2.default.remove(this.pagingSlc, 'change', evt.slcPagesChange); - } else if (this.pageSelectorType === tf.fltTypeInp) { - _event2.default.remove(this.pagingSlc, 'keypress', evt._detectKey); - } - _dom2.default.remove(this.pagingSlc); + if (this.pageSelectorType === tf.fltTypeSlc) { + var slcIdx = this.pagingSlc.options.length - 1 <= slcPagesSelIndex ? this.pagingSlc.options.length - 1 : slcPagesSelIndex; + this.pagingSlc.options[slcIdx].selected = true; } - - if (btnNextSpan) { - _event2.default.remove(btnNextSpan, 'click', evt.next); - _dom2.default.remove(btnNextSpan); - } - - if (btnPrevSpan) { - _event2.default.remove(btnPrevSpan, 'click', evt.prev); - _dom2.default.remove(btnPrevSpan); - } - - if (btnLastSpan) { - _event2.default.remove(btnLastSpan, 'click', evt.last); - _dom2.default.remove(btnLastSpan); - } - - if (btnFirstSpan) { - _event2.default.remove(btnFirstSpan, 'click', evt.first); - _dom2.default.remove(btnFirstSpan); - } - - if (pgBeforeSpan) { - _dom2.default.remove(pgBeforeSpan); - } - - if (pgAfterSpan) { - _dom2.default.remove(pgAfterSpan); - } - - if (pgspan) { - _dom2.default.remove(pgspan); - } - - if (this.hasResultsPerPage) { - this.removeResultsPerPage(); - } - - this.emitter.off(['after-filtering'], function () { - return _this4.resetPagingInfo(); - }); - this.emitter.off(['initialized'], function () { - return _this4.resetValues(); - }); - this.emitter.off(['change-page'], function (tf, pageNumber) { - return _this4.setPage(pageNumber); - }); - this.emitter.off(['change-page-results'], function (tf, pageLength) { - return _this4.changeResultsPerPage(pageLength); - }); - - this.pagingSlc = null; - this.nbPages = 0; - this.disable(); - this.initialized = false; } - }]); + + this.emitter.emit('after-page-length-change', tf, this.pagingLength); + }; + + /** + * Re-set persisted pagination info + */ + + + Paging.prototype.resetValues = function resetValues() { + var tf = this.tf; + if (tf.rememberPageLen) { + this.resetPageLength(); + } + if (tf.rememberPageNb) { + this.resetPage(); + } + }; + + /** + * Re-set page nb at page re-load + */ + + + Paging.prototype.resetPage = function resetPage() { + var tf = this.tf; + if (!this.isEnabled()) { + return; + } + this.emitter.emit('before-reset-page', tf); + var pgNb = tf.feature('store').getPageNb(); + if (pgNb !== '') { + this.changePage(pgNb - 1); + } + this.emitter.emit('after-reset-page', tf, pgNb); + }; + + /** + * Re-set page length value at page re-load + */ + + + Paging.prototype.resetPageLength = function resetPageLength() { + var tf = this.tf; + if (!this.isEnabled()) { + return; + } + this.emitter.emit('before-reset-page-length', tf); + var pglenIndex = tf.feature('store').getPageLength(); + + if (pglenIndex !== '') { + this.resultsPerPageSlc.options[pglenIndex].selected = true; + this.changeResultsPerPage(); + } + this.emitter.emit('after-reset-page-length', tf, pglenIndex); + }; + + /** + * Remove paging feature + */ + + + Paging.prototype.destroy = function destroy() { + var _this4 = this; + + var tf = this.tf; + + if (!this.initialized) { + return; + } + // btns containers + var btnNextSpan = _dom2.default.id(this.prfxBtnNextSpan + tf.id); + var btnPrevSpan = _dom2.default.id(this.prfxBtnPrevSpan + tf.id); + var btnLastSpan = _dom2.default.id(this.prfxBtnLastSpan + tf.id); + var btnFirstSpan = _dom2.default.id(this.prfxBtnFirstSpan + tf.id); + //span containing 'Page' text + var pgBeforeSpan = _dom2.default.id(this.prfxPgBeforeSpan + tf.id); + //span containing 'of' text + var pgAfterSpan = _dom2.default.id(this.prfxPgAfterSpan + tf.id); + //span containing nb of pages + var pgspan = _dom2.default.id(this.prfxPgSpan + tf.id); + + var evt = this.evt; + + if (this.pagingSlc) { + if (this.pageSelectorType === tf.fltTypeSlc) { + _event2.default.remove(this.pagingSlc, 'change', evt.slcPagesChange); + } else if (this.pageSelectorType === tf.fltTypeInp) { + _event2.default.remove(this.pagingSlc, 'keypress', evt._detectKey); + } + _dom2.default.remove(this.pagingSlc); + } + + if (btnNextSpan) { + _event2.default.remove(btnNextSpan, 'click', evt.next); + _dom2.default.remove(btnNextSpan); + } + + if (btnPrevSpan) { + _event2.default.remove(btnPrevSpan, 'click', evt.prev); + _dom2.default.remove(btnPrevSpan); + } + + if (btnLastSpan) { + _event2.default.remove(btnLastSpan, 'click', evt.last); + _dom2.default.remove(btnLastSpan); + } + + if (btnFirstSpan) { + _event2.default.remove(btnFirstSpan, 'click', evt.first); + _dom2.default.remove(btnFirstSpan); + } + + if (pgBeforeSpan) { + _dom2.default.remove(pgBeforeSpan); + } + + if (pgAfterSpan) { + _dom2.default.remove(pgAfterSpan); + } + + if (pgspan) { + _dom2.default.remove(pgspan); + } + + if (this.hasResultsPerPage) { + this.removeResultsPerPage(); + } + + this.emitter.off(['after-filtering'], function () { + return _this4.resetPagingInfo(); + }); + this.emitter.off(['initialized'], function () { + return _this4.resetValues(); + }); + this.emitter.off(['change-page'], function (tf, pageNumber) { + return _this4.setPage(pageNumber); + }); + this.emitter.off(['change-page-results'], function (tf, pageLength) { + return _this4.changeResultsPerPage(pageLength); + }); + + this.pagingSlc = null; + this.nbPages = 0; + this.disable(); + this.initialized = false; + }; return Paging; }(_feature.Feature); @@ -7021,8 +6843,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.ClearButton = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -7054,7 +6874,7 @@ return /******/ (function(modules) { // webpackBootstrap // Configuration object - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ClearButton).call(this, tf, 'btnReset')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'btnReset')); var f = _this.config; @@ -7073,80 +6893,75 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(ClearButton, [{ - key: 'onClick', - value: function onClick() { - if (!this.isEnabled()) { - return; - } - this.tf.clearFilters(); + ClearButton.prototype.onClick = function onClick() { + if (!this.isEnabled()) { + return; + } + this.tf.clearFilters(); + }; + + /** + * Build DOM elements + */ + + + ClearButton.prototype.init = function init() { + var _this2 = this; + + var tf = this.tf; + + if (this.initialized) { + return; } - /** - * Build DOM elements - */ + var resetspan = _dom2.default.create('span', ['id', this.prfxResetSpan + tf.id]); - }, { - key: 'init', - value: function init() { - var _this2 = this; + // reset button is added to defined element + if (!this.btnResetTgtId) { + tf.setToolbar(); + } + var targetEl = !this.btnResetTgtId ? tf.rDiv : _dom2.default.id(this.btnResetTgtId); + targetEl.appendChild(resetspan); - var tf = this.tf; + if (!this.btnResetHtml) { + var fltreset = _dom2.default.create('a', ['href', 'javascript:void(0);']); + fltreset.className = tf.btnResetCssClass; + fltreset.appendChild(_dom2.default.text(this.btnResetText)); + resetspan.appendChild(fltreset); + _event2.default.add(fltreset, 'click', function () { + _this2.onClick(); + }); + } else { + resetspan.innerHTML = this.btnResetHtml; + var resetEl = resetspan.firstChild; + _event2.default.add(resetEl, 'click', function () { + _this2.onClick(); + }); + } + this.btnResetEl = resetspan.firstChild; - if (this.initialized) { - return; - } + this.initialized = true; + }; - var resetspan = _dom2.default.create('span', ['id', this.prfxResetSpan + tf.id]); + /** + * Remove clear button UI + */ - // reset button is added to defined element - if (!this.btnResetTgtId) { - tf.setToolbar(); - } - var targetEl = !this.btnResetTgtId ? tf.rDiv : _dom2.default.id(this.btnResetTgtId); - targetEl.appendChild(resetspan); - if (!this.btnResetHtml) { - var fltreset = _dom2.default.create('a', ['href', 'javascript:void(0);']); - fltreset.className = tf.btnResetCssClass; - fltreset.appendChild(_dom2.default.text(this.btnResetText)); - resetspan.appendChild(fltreset); - _event2.default.add(fltreset, 'click', function () { - _this2.onClick(); - }); - } else { - resetspan.innerHTML = this.btnResetHtml; - var resetEl = resetspan.firstChild; - _event2.default.add(resetEl, 'click', function () { - _this2.onClick(); - }); - } - this.btnResetEl = resetspan.firstChild; + ClearButton.prototype.destroy = function destroy() { + var tf = this.tf; - this.initialized = true; + if (!this.initialized) { + return; } - /** - * Remove clear button UI - */ - - }, { - key: 'destroy', - value: function destroy() { - var tf = this.tf; - - if (!this.initialized) { - return; - } - - var resetspan = _dom2.default.id(this.prfxResetSpan + tf.id); - if (resetspan) { - _dom2.default.remove(resetspan); - } - this.btnResetEl = null; - this.initialized = false; + var resetspan = _dom2.default.id(this.prfxResetSpan + tf.id); + if (resetspan) { + _dom2.default.remove(resetspan); } - }]); + this.btnResetEl = null; + this.initialized = false; + }; return ClearButton; }(_feature.Feature); @@ -7162,8 +6977,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.Help = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -7196,7 +7009,7 @@ return /******/ (function(modules) { // webpackBootstrap function Help(tf) { _classCallCheck(this, Help); - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Help).call(this, tf, 'help')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'help')); var f = _this.config; @@ -7233,115 +7046,110 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(Help, [{ - key: 'init', - value: function init() { - var _this2 = this; + Help.prototype.init = function init() { + var _this2 = this; - if (this.initialized) { - return; - } + if (this.initialized) { + return; + } - var tf = this.tf; + var tf = this.tf; - var helpspan = _dom2.default.create('span', ['id', this.prfxHelpSpan + tf.id]); - var helpdiv = _dom2.default.create('div', ['id', this.prfxHelpDiv + tf.id]); + var helpspan = _dom2.default.create('span', ['id', this.prfxHelpSpan + tf.id]); + var helpdiv = _dom2.default.create('div', ['id', this.prfxHelpDiv + tf.id]); - //help button is added to defined element - if (!this.tgtId) { - tf.setToolbar(); - } - var targetEl = !this.tgtId ? tf.rDiv : _dom2.default.id(this.tgtId); - targetEl.appendChild(helpspan); + //help button is added to defined element + if (!this.tgtId) { + tf.setToolbar(); + } + var targetEl = !this.tgtId ? tf.rDiv : _dom2.default.id(this.tgtId); + targetEl.appendChild(helpspan); - var divContainer = !this.contTgtId ? helpspan : _dom2.default.id(this.contTgtId); + var divContainer = !this.contTgtId ? helpspan : _dom2.default.id(this.contTgtId); - if (!this.btnHtml) { - divContainer.appendChild(helpdiv); - var helplink = _dom2.default.create('a', ['href', 'javascript:void(0);']); - helplink.className = this.btnCssClass; - helplink.appendChild(_dom2.default.text(this.btnText)); - helpspan.appendChild(helplink); - _event2.default.add(helplink, 'click', function () { - _this2.toggle(); - }); - } else { - helpspan.innerHTML = this.btnHtml; - var helpEl = helpspan.firstChild; - _event2.default.add(helpEl, 'click', function () { - _this2.toggle(); - }); + if (!this.btnHtml) { + divContainer.appendChild(helpdiv); + var helplink = _dom2.default.create('a', ['href', 'javascript:void(0);']); + helplink.className = this.btnCssClass; + helplink.appendChild(_dom2.default.text(this.btnText)); + helpspan.appendChild(helplink); + _event2.default.add(helplink, 'click', function () { + _this2.toggle(); + }); + } else { + helpspan.innerHTML = this.btnHtml; + var helpEl = helpspan.firstChild; + _event2.default.add(helpEl, 'click', function () { + _this2.toggle(); + }); + divContainer.appendChild(helpdiv); + } + + if (!this.instrHtml) { + helpdiv.innerHTML = this.instrText; + helpdiv.className = this.contCssClass; + _event2.default.add(helpdiv, 'dblclick', function () { + _this2.toggle(); + }); + } else { + if (this.contTgtId) { divContainer.appendChild(helpdiv); } - - if (!this.instrHtml) { - helpdiv.innerHTML = this.instrText; + helpdiv.innerHTML = this.instrHtml; + if (!this.contTgtId) { helpdiv.className = this.contCssClass; _event2.default.add(helpdiv, 'dblclick', function () { _this2.toggle(); }); - } else { - if (this.contTgtId) { - divContainer.appendChild(helpdiv); - } - helpdiv.innerHTML = this.instrHtml; - if (!this.contTgtId) { - helpdiv.className = this.contCssClass; - _event2.default.add(helpdiv, 'dblclick', function () { - _this2.toggle(); - }); - } - } - helpdiv.innerHTML += this.defaultHtml; - _event2.default.add(helpdiv, 'click', function () { - _this2.toggle(); - }); - - this.cont = helpdiv; - this.btn = helpspan; - this.initialized = true; - } - - /** - * Toggle help pop-up - */ - - }, { - key: 'toggle', - value: function toggle() { - // check only if explicitily set to false as in this case undefined - // signifies the help feature is enabled by default - if (this.enabled === false) { - return; - } - var divDisplay = this.cont.style.display; - if (divDisplay === '' || divDisplay === 'none') { - this.cont.style.display = 'inline'; - } else { - this.cont.style.display = 'none'; } } + helpdiv.innerHTML += this.defaultHtml; + _event2.default.add(helpdiv, 'click', function () { + _this2.toggle(); + }); - /** - * Remove help UI - */ + this.cont = helpdiv; + this.btn = helpspan; + this.initialized = true; + }; - }, { - key: 'destroy', - value: function destroy() { - if (!this.initialized) { - return; - } - _dom2.default.remove(this.btn); - this.btn = null; - if (!this.cont) { - return; - } - _dom2.default.remove(this.cont); - this.cont = null; - this.initialized = false; + /** + * Toggle help pop-up + */ + + + Help.prototype.toggle = function toggle() { + // check only if explicitily set to false as in this case undefined + // signifies the help feature is enabled by default + if (this.enabled === false) { + return; } - }]); + var divDisplay = this.cont.style.display; + if (divDisplay === '' || divDisplay === 'none') { + this.cont.style.display = 'inline'; + } else { + this.cont.style.display = 'none'; + } + }; + + /** + * Remove help UI + */ + + + Help.prototype.destroy = function destroy() { + if (!this.initialized) { + return; + } + _dom2.default.remove(this.btn); + this.btn = null; + if (!this.cont) { + return; + } + _dom2.default.remove(this.cont); + this.cont = null; + this.initialized = false; + }; return Help; }(_feature.Feature); @@ -7357,8 +7165,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.AlternateRows = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -7384,7 +7190,7 @@ return /******/ (function(modules) { // webpackBootstrap function AlternateRows(tf) { _classCallCheck(this, AlternateRows); - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(AlternateRows).call(this, tf, 'alternateRows')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'alternateRows')); var config = _this.config; //defines css class for even rows @@ -7399,130 +7205,122 @@ return /******/ (function(modules) { // webpackBootstrap */ - _createClass(AlternateRows, [{ - key: 'init', - value: function init() { - var _this2 = this; + AlternateRows.prototype.init = function init() { + var _this2 = this; - if (this.initialized) { - return; - } - - this.processAll(); - - // Subscribe to events - this.emitter.on(['row-processed', 'row-paged'], function (tf, rowIndex, arrIndex, isValid) { - return _this2.processRow(rowIndex, arrIndex, isValid); - }); - this.emitter.on(['column-sorted'], function () { - return _this2.processAll(); - }); - - this.initialized = true; - } - }, { - key: 'processAll', - value: function processAll() { - if (!this.isEnabled()) { - return; - } - var tf = this.tf; - var validRowsIndex = tf.getValidRows(true); - var noValidRowsIndex = validRowsIndex.length === 0; - //1st index - var beginIndex = noValidRowsIndex ? tf.refRow : 0; - // nb indexes - var indexLen = noValidRowsIndex ? tf.nbFilterableRows + beginIndex : validRowsIndex.length; - var idx = 0; - - //alternates bg color - for (var j = beginIndex; j < indexLen; j++) { - var rowIdx = noValidRowsIndex ? j : validRowsIndex[j]; - this.setRowBg(rowIdx, idx); - idx++; - } + if (this.initialized) { + return; } - /** - * Set/remove row background based on row validation - * @param {Number} rowIdx Row index - * @param {Number} arrIdx Array index - * @param {Boolean} isValid Valid row flag - */ + this.processAll(); - }, { - key: 'processRow', - value: function processRow(rowIdx, arrIdx, isValid) { - if (isValid) { - this.setRowBg(rowIdx, arrIdx); - } else { - this.removeRowBg(rowIdx); - } + // Subscribe to events + this.emitter.on(['row-processed', 'row-paged'], function (tf, rowIndex, arrIndex, isValid) { + return _this2.processRow(rowIndex, arrIndex, isValid); + }); + this.emitter.on(['column-sorted'], function () { + return _this2.processAll(); + }); + + this.initialized = true; + }; + + AlternateRows.prototype.processAll = function processAll() { + if (!this.isEnabled()) { + return; } + var tf = this.tf; + var validRowsIndex = tf.getValidRows(true); + var noValidRowsIndex = validRowsIndex.length === 0; + //1st index + var beginIndex = noValidRowsIndex ? tf.refRow : 0; + // nb indexes + var indexLen = noValidRowsIndex ? tf.nbFilterableRows + beginIndex : validRowsIndex.length; + var idx = 0; - /** - * Sets row background color - * @param {Number} rowIdx Row index - * @param {Number} idx Valid rows collection index needed to calculate bg - * color - */ + //alternates bg color + for (var j = beginIndex; j < indexLen; j++) { + var rowIdx = noValidRowsIndex ? j : validRowsIndex[j]; + this.setRowBg(rowIdx, idx); + idx++; + } + }; - }, { - key: 'setRowBg', - value: function setRowBg(rowIdx, idx) { - if (!this.isEnabled() || isNaN(rowIdx)) { - return; - } - var rows = this.tf.tbl.rows; - var i = isNaN(idx) ? rowIdx : idx; + /** + * Set/remove row background based on row validation + * @param {Number} rowIdx Row index + * @param {Number} arrIdx Array index + * @param {Boolean} isValid Valid row flag + */ + + + AlternateRows.prototype.processRow = function processRow(rowIdx, arrIdx, isValid) { + if (isValid) { + this.setRowBg(rowIdx, arrIdx); + } else { this.removeRowBg(rowIdx); + } + }; - _dom2.default.addClass(rows[rowIdx], i % 2 ? this.evenCss : this.oddCss); + /** + * Sets row background color + * @param {Number} rowIdx Row index + * @param {Number} idx Valid rows collection index needed to calculate bg + * color + */ + + + AlternateRows.prototype.setRowBg = function setRowBg(rowIdx, idx) { + if (!this.isEnabled() || isNaN(rowIdx)) { + return; + } + var rows = this.tf.tbl.rows; + var i = isNaN(idx) ? rowIdx : idx; + this.removeRowBg(rowIdx); + + _dom2.default.addClass(rows[rowIdx], i % 2 ? this.evenCss : this.oddCss); + }; + + /** + * Removes row background color + * @param {Number} idx Row index + */ + + + AlternateRows.prototype.removeRowBg = function removeRowBg(idx) { + if (isNaN(idx)) { + return; + } + var rows = this.tf.tbl.rows; + _dom2.default.removeClass(rows[idx], this.oddCss); + _dom2.default.removeClass(rows[idx], this.evenCss); + }; + + /** + * Removes all alternating backgrounds + */ + + + AlternateRows.prototype.destroy = function destroy() { + var _this3 = this; + + if (!this.initialized) { + return; + } + for (var i = 0; i < this.tf.nbRows; i++) { + this.removeRowBg(i); } - /** - * Removes row background color - * @param {Number} idx Row index - */ + // Unsubscribe to events + this.emitter.off(['row-processed', 'row-paged'], function (tf, rowIndex, arrIndex, isValid) { + return _this3.processRow(rowIndex, arrIndex, isValid); + }); + this.emitter.off(['column-sorted'], function () { + return _this3.processAll(); + }); - }, { - key: 'removeRowBg', - value: function removeRowBg(idx) { - if (isNaN(idx)) { - return; - } - var rows = this.tf.tbl.rows; - _dom2.default.removeClass(rows[idx], this.oddCss); - _dom2.default.removeClass(rows[idx], this.evenCss); - } - - /** - * Removes all alternating backgrounds - */ - - }, { - key: 'destroy', - value: function destroy() { - var _this3 = this; - - if (!this.initialized) { - return; - } - for (var i = 0; i < this.tf.nbRows; i++) { - this.removeRowBg(i); - } - - // Unsubscribe to events - this.emitter.off(['row-processed', 'row-paged'], function (tf, rowIndex, arrIndex, isValid) { - return _this3.processRow(rowIndex, arrIndex, isValid); - }); - this.emitter.off(['column-sorted'], function () { - return _this3.processAll(); - }); - - this.initialized = false; - } - }]); + this.initialized = false; + }; return AlternateRows; }(_feature.Feature); @@ -7538,8 +7336,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.NoResults = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _dom = __webpack_require__(2); @@ -7571,7 +7367,7 @@ return /******/ (function(modules) { // webpackBootstrap //configuration object - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(NoResults).call(this, tf, 'noResults')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'noResults')); var f = _this.config.no_results_message; @@ -7596,113 +7392,105 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(NoResults, [{ - key: 'init', - value: function init() { - var _this2 = this; + NoResults.prototype.init = function init() { + var _this2 = this; - if (this.initialized) { - return; - } - var tf = this.tf; - var target = this.customContainer || _dom2.default.id(this.customContainerId) || tf.tbl; + if (this.initialized) { + return; + } + var tf = this.tf; + var target = this.customContainer || _dom2.default.id(this.customContainerId) || tf.tbl; - //container - var cont = _dom2.default.create('div', ['id', this.prfxNoResults + tf.id]); - cont.className = this.cssClass; - cont.innerHTML = this.content; + //container + var cont = _dom2.default.create('div', ['id', this.prfxNoResults + tf.id]); + cont.className = this.cssClass; + cont.innerHTML = this.content; - if (this.isExternal) { - target.appendChild(cont); - } else { - target.parentNode.insertBefore(cont, target.nextSibling); - } + if (this.isExternal) { + target.appendChild(cont); + } else { + target.parentNode.insertBefore(cont, target.nextSibling); + } - this.cont = cont; + this.cont = cont; - // subscribe to after-filtering event - this.emitter.on(['after-filtering'], function () { - return _this2.toggle(); - }); + // subscribe to after-filtering event + this.emitter.on(['after-filtering'], function () { + return _this2.toggle(); + }); - this.initialized = true; + this.initialized = true; + this.hide(); + }; + + NoResults.prototype.toggle = function toggle() { + if (this.tf.nbVisibleRows > 0) { this.hide(); + } else { + this.show(); } - }, { - key: 'toggle', - value: function toggle() { - if (this.tf.nbVisibleRows > 0) { - this.hide(); - } else { - this.show(); - } + }; + + NoResults.prototype.show = function show() { + if (!this.initialized || !this.isEnabled()) { + return; } - }, { - key: 'show', - value: function show() { - if (!this.initialized || !this.isEnabled()) { - return; - } - if (this.onBeforeShowMsg) { - this.onBeforeShowMsg.call(null, this.tf, this); - } - - this.setWidth(); - this.cont.style.display = 'block'; - - if (this.onAfterShowMsg) { - this.onAfterShowMsg.call(null, this.tf, this); - } + if (this.onBeforeShowMsg) { + this.onBeforeShowMsg.call(null, this.tf, this); } - }, { - key: 'hide', - value: function hide() { - if (!this.initialized || !this.isEnabled()) { - return; - } - if (this.onBeforeHideMsg) { - this.onBeforeHideMsg.call(null, this.tf, this); - } + this.setWidth(); + this.cont.style.display = 'block'; - this.cont.style.display = 'none'; - - if (this.onBeforeHideMsg) { - this.onBeforeHideMsg.call(null, this.tf, this); - } + if (this.onAfterShowMsg) { + this.onAfterShowMsg.call(null, this.tf, this); } - }, { - key: 'setWidth', - value: function setWidth() { - if (!this.initialized || this.isExternal || !this.isEnabled()) { - return; - } - if (this.tf.gridLayout) { - var gridLayout = this.tf.feature('gridLayout'); - this.cont.style.width = gridLayout.tblCont.clientWidth + 'px'; - } else { - this.cont.style.width = this.tf.tbl.clientWidth + 'px'; - } - } - }, { - key: 'destroy', - value: function destroy() { - var _this3 = this; + }; - if (!this.initialized) { - return; - } - _dom2.default.remove(this.cont); - this.cont = null; - // unsubscribe to after-filtering event - this.emitter.off(['after-filtering'], function () { - return _this3.toggle(); - }); - - this.initialized = false; + NoResults.prototype.hide = function hide() { + if (!this.initialized || !this.isEnabled()) { + return; } - }]); + + if (this.onBeforeHideMsg) { + this.onBeforeHideMsg.call(null, this.tf, this); + } + + this.cont.style.display = 'none'; + + if (this.onBeforeHideMsg) { + this.onBeforeHideMsg.call(null, this.tf, this); + } + }; + + NoResults.prototype.setWidth = function setWidth() { + if (!this.initialized || this.isExternal || !this.isEnabled()) { + return; + } + if (this.tf.gridLayout) { + var gridLayout = this.tf.feature('gridLayout'); + this.cont.style.width = gridLayout.tblCont.clientWidth + 'px'; + } else { + this.cont.style.width = this.tf.tbl.clientWidth + 'px'; + } + }; + + NoResults.prototype.destroy = function destroy() { + var _this3 = this; + + if (!this.initialized) { + return; + } + _dom2.default.remove(this.cont); + this.cont = null; + // unsubscribe to after-filtering event + this.emitter.off(['after-filtering'], function () { + return _this3.toggle(); + }); + + this.initialized = false; + }; return NoResults; }(_feature.Feature); @@ -7718,8 +7506,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.State = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _feature = __webpack_require__(11); var _hash = __webpack_require__(27); @@ -7740,6 +7526,15 @@ return /******/ (function(modules) { // webpackBootstrap function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + /** + * Reflects the state of features to be persisted via hash, localStorage or + * cookie + * + * @export + * @class State + * @extends {Feature} + */ + var State = exports.State = function (_Feature) { _inherits(State, _Feature); @@ -7752,7 +7547,7 @@ return /******/ (function(modules) { // webpackBootstrap function State(tf) { _classCallCheck(this, State); - var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(State).call(this, tf, 'state')); + var _this = _possibleConstructorReturn(this, _Feature.call(this, tf, 'state')); var cfg = _this.config.state; @@ -7772,154 +7567,184 @@ return /******/ (function(modules) { // webpackBootstrap return _this; } - _createClass(State, [{ - key: 'init', - value: function init() { - var _this2 = this; + /** + * Initialize features state + */ - if (this.initialized) { - return; - } - this.emitter.on(['after-filtering'], function () { - return _this2.update(); - }); - this.emitter.on(['after-page-change'], function (tf, pageNb) { - return _this2.updatePage(pageNb); - }); - this.emitter.on(['after-page-length-change'], function (tf, index) { - return _this2.updatePageLength(index); - }); + State.prototype.init = function init() { + var _this2 = this; - if (this.enableHash) { - this.hash = new _hash.Hash(this); - this.hash.init(); - } - this.initialized = true; + if (this.initialized) { + return; } - }, { - key: 'update', - value: function update() { - var _this3 = this; - if (!this.isEnabled()) { - return; - } - var tf = this.tf; + this.emitter.on(['after-filtering'], function () { + return _this2.update(); + }); + this.emitter.on(['after-page-change'], function (tf, pageNb) { + return _this2.updatePage(pageNb); + }); + this.emitter.on(['after-page-length-change'], function (tf, index) { + return _this2.updatePageLength(index); + }); - if (this.persistFilters) { - var filterValues = tf.getFiltersValue(); + if (this.enableHash) { + this.hash = new _hash.Hash(this); + this.hash.init(); + } + this.initialized = true; + }; - filterValues.forEach(function (val, idx) { - var key = '' + _this3.prfxCol + idx; + /** + * Update state field based on current features state + */ - if (_string2.default.isEmpty(val)) { - if (_this3.state.hasOwnProperty(key)) { - _this3.state[key] = undefined; - } - } else { - _this3.state[key] = _this3.state[key] || {}; - _this3.state[key].flt = val; + + State.prototype.update = function update() { + var _this3 = this; + + if (!this.isEnabled()) { + return; + } + var tf = this.tf; + + if (this.persistFilters) { + var filterValues = tf.getFiltersValue(); + + filterValues.forEach(function (val, idx) { + var key = '' + _this3.prfxCol + idx; + + if (_types2.default.isString(val) && _string2.default.isEmpty(val)) { + if (_this3.state.hasOwnProperty(key)) { + _this3.state[key] = undefined; } - }); - } - - if (this.persistPageNumber) { - if (_types2.default.isNull(this.pageNb)) { - this.state[this.pageNbKey] = undefined; } else { - this.state[this.pageNbKey] = this.pageNb; + _this3.state[key] = _this3.state[key] || {}; + _this3.state[key].flt = val; } - } + }); + } - if (this.persistPageLength) { - if (_types2.default.isNull(this.pageLength)) { - this.state[this.pageLengthKey] = undefined; - } else { - this.state[this.pageLengthKey] = this.pageLength; + if (this.persistPageNumber) { + if (_types2.default.isNull(this.pageNb)) { + this.state[this.pageNbKey] = undefined; + } else { + this.state[this.pageNbKey] = this.pageNb; + } + } + + if (this.persistPageLength) { + if (_types2.default.isNull(this.pageLength)) { + this.state[this.pageLengthKey] = undefined; + } else { + this.state[this.pageLengthKey] = this.pageLength; + } + } + + this.emitter.emit('state-changed', tf, this.state); + }; + + /** + * Refresh page number field on page number change + * + * @param pageNb Current page number + */ + + + State.prototype.updatePage = function updatePage(pageNb) { + this.pageNb = pageNb; + this.update(); + }; + + /** + * Refresh page length field on page length change + * + * @param pageLength Current page length value + */ + + + State.prototype.updatePageLength = function updatePageLength(pageLength) { + this.pageLength = pageLength; + this.update(); + }; + + /** + * Override state field + * + * @param state State object + */ + + + State.prototype.override = function override(state) { + this.state = state; + }; + + /** + * Apply current features state + */ + + + State.prototype.sync = function sync() { + var _this4 = this; + + var state = this.state; + var tf = this.tf; + + if (this.persistFilters) { + Object.keys(state).forEach(function (key) { + if (key.indexOf(_this4.prfxCol) !== -1) { + var colIdx = parseInt(key.replace(_this4.prfxCol, ''), 10); + var val = state[key].flt; + tf.setFilterValue(colIdx, val); } - } - - this.emitter.emit('state-changed', tf, this.state); - } - }, { - key: 'updatePage', - value: function updatePage(pageNb) { - this.pageNb = pageNb; - this.update(); - } - }, { - key: 'updatePageLength', - value: function updatePageLength(pageLength) { - this.pageLength = pageLength; - this.update(); - } - }, { - key: 'override', - value: function override(state) { - this.state = state; - } - }, { - key: 'sync', - value: function sync() { - var _this4 = this; - - var state = this.state; - console.log('sync', state); - var tf = this.tf; - - if (this.persistFilters) { - Object.keys(state).forEach(function (key) { - if (key.indexOf(_this4.prfxCol) !== -1) { - var colIdx = parseInt(key.replace(_this4.prfxCol, ''), 10); - var val = state[key].flt; - tf.setFilterValue(colIdx, val); - } - }); - - tf.filter(); - } - - if (this.persistPageNumber) { - var pageNumber = state[this.pageNbKey]; - console.log('pageNumber', pageNumber); - this.emitter.emit('change-page', this.tf, pageNumber); - } - - if (this.persistPageLength) { - var pageLength = state[this.pageLengthKey]; - this.emitter.emit('change-page-results', this.tf, pageLength); - } - - this.emitter.emit('state-synced', tf, this.state); - } - }, { - key: 'destroy', - value: function destroy() { - var _this5 = this; - - if (!this.initialized) { - return; - } - - this.emitter.off(['after-filtering'], function () { - return _this5.update(); - }); - this.emitter.off(['after-page-change'], function (tf, pageNb) { - return _this5.updatePage(pageNb); - }); - this.emitter.off(['after-page-length-change'], function (tf, index) { - return _this5.updatePageLength(index); }); - if (this.enableHash) { - this.hash.destroy(); - this.hash = null; - } - - this.initialized = false; + tf.filter(); } - }]); + + if (this.persistPageNumber) { + var pageNumber = state[this.pageNbKey]; + this.emitter.emit('change-page', this.tf, pageNumber); + } + + if (this.persistPageLength) { + var pageLength = state[this.pageLengthKey]; + this.emitter.emit('change-page-results', this.tf, pageLength); + } + }; + + /** + * Destroy State instance + */ + + + State.prototype.destroy = function destroy() { + var _this5 = this; + + if (!this.initialized) { + return; + } + + this.state = {}; + + this.emitter.off(['after-filtering'], function () { + return _this5.update(); + }); + this.emitter.off(['after-page-change'], function (tf, pageNb) { + return _this5.updatePage(pageNb); + }); + this.emitter.off(['after-page-length-change'], function (tf, index) { + return _this5.updatePageLength(index); + }); + + if (this.enableHash) { + this.hash.destroy(); + this.hash = null; + } + + this.initialized = false; + }; return State; }(_feature.Feature); @@ -7935,8 +7760,6 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.Hash = exports.hasHashChange = undefined; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _event = __webpack_require__(1); var _event2 = _interopRequireDefault(_event); @@ -7963,81 +7786,74 @@ return /******/ (function(modules) { // webpackBootstrap this.emitter = state.emitter; } - _createClass(Hash, [{ - key: 'init', - value: function init() { - var _this = this; + Hash.prototype.init = function init() { + var _this = this; - if (!hasHashChange()) { - return; - } - - this.lastHash = location.hash; - - this.emitter.on(['state-changed'], function (tf, state) { - return _this.update(state); - }); - this.emitter.on(['initialized'], function () { - return _this.sync(); - }); - _event2.default.add(global, 'hashchange', function () { - return _this.sync(); - }); + if (!hasHashChange()) { + return; } - }, { - key: 'update', - value: function update(state) { - var hash = '#' + JSON.stringify(state); - console.log(hash, this.lastHash, this.lastHash === hash); - if (this.lastHash === hash) { - return; - } - location.hash = hash; - this.lastHash = hash; - } - }, { - key: 'parse', - value: function parse(hash) { - if (hash.indexOf('#') === -1) { - return null; - } - hash = hash.substr(1); - return JSON.parse(hash); - } - }, { - key: 'sync', - value: function sync() { - var state = this.parse(location.hash); - if (!state) { - return; - } + this.lastHash = location.hash; - this.state.disable(); - this.state.override(state); - this.state.sync(); - this.state.enable(); - } - }, { - key: 'destroy', - value: function destroy() { - var _this2 = this; + this.emitter.on(['state-changed'], function (tf, state) { + return _this.update(state); + }); + this.emitter.on(['initialized'], function () { + return _this.sync(); + }); + _event2.default.add(global, 'hashchange', function () { + return _this.sync(); + }); + }; - this.state = null; - this.lastHash = null; - this.emitter = null; - - this.emitter.off(['state-changed'], function (tf, state) { - return _this2.update(state); - }); - this.emitter.off(['initialized'], function () { - return _this2.sync(); - }); - _event2.default.remove(global, 'hashchange', function () { - return _this2.sync(); - }); + Hash.prototype.update = function update(state) { + var hash = '#' + JSON.stringify(state); + console.log(hash, this.lastHash, this.lastHash === hash); + if (this.lastHash === hash) { + return; } - }]); + + location.hash = hash; + this.lastHash = hash; + }; + + Hash.prototype.parse = function parse(hash) { + if (hash.indexOf('#') === -1) { + return null; + } + hash = hash.substr(1); + return JSON.parse(hash); + }; + + Hash.prototype.sync = function sync() { + var state = this.parse(location.hash); + if (!state) { + return; + } + + this.state.disable(); + this.state.override(state); + this.state.sync(); + this.state.enable(); + }; + + Hash.prototype.destroy = function destroy() { + var _this2 = this; + + this.state = null; + this.lastHash = null; + this.emitter = null; + + this.emitter.off(['state-changed'], function (tf, state) { + return _this2.update(state); + }); + this.emitter.off(['initialized'], function () { + return _this2.sync(); + }); + _event2.default.remove(global, 'hashchange', function () { + return _this2.sync(); + }); + }; return Hash; }(); diff --git a/dist/tablefilter/tf-1.js b/dist/tablefilter/tf-1.js index be5397d8..bbe5975b 100644 --- a/dist/tablefilter/tf-1.js +++ b/dist/tablefilter/tf-1.js @@ -98,8 +98,6 @@ webpackJsonp([1],{ value: true }); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _dom = __webpack_require__(2); var _dom2 = _interopRequireDefault(_dom); @@ -144,429 +142,421 @@ webpackJsonp([1],{ */ - _createClass(AdapterEzEditTable, [{ - key: 'init', - value: function init() { - var _this = this; + AdapterEzEditTable.prototype.init = function init() { + var _this = this; - var tf = this.tf; - if (window.EditTable) { - this._setAdvancedGrid(); - } else { - var path = this.vendorPath + this.filename; - tf.import(this.filename, path, function () { - _this._setAdvancedGrid(); - }); - } - if (this.loadStylesheet && !tf.isImported(this.stylesheet, 'link')) { - tf.import(this.stylesheetName, this.stylesheet, null, 'link'); - } - - // TODO: hack to prevent ezEditTable enter key event hijaking. - // Needs to be fixed in the vendor's library - this.emitter.on(['filter-focus', 'filter-blur'], function () { - return _this._toggleForInputFilter(); + var tf = this.tf; + if (window.EditTable) { + this._setAdvancedGrid(); + } else { + var path = this.vendorPath + this.filename; + tf.import(this.filename, path, function () { + _this._setAdvancedGrid(); }); } + if (this.loadStylesheet && !tf.isImported(this.stylesheet, 'link')) { + tf.import(this.stylesheetName, this.stylesheet, null, 'link'); + } - /** - * Instantiate ezEditTable component for advanced grid features - */ + // TODO: hack to prevent ezEditTable enter key event hijaking. + // Needs to be fixed in the vendor's library + this.emitter.on(['filter-focus', 'filter-blur'], function () { + return _this._toggleForInputFilter(); + }); + }; - }, { - key: '_setAdvancedGrid', - value: function _setAdvancedGrid() { - var tf = this.tf; + /** + * Instantiate ezEditTable component for advanced grid features + */ - //start row for EditTable constructor needs to be calculated - var startRow, - cfg = this.cfg, - thead = _dom2.default.tag(tf.tbl, 'thead'); - //if thead exists and startRow not specified, startRow is calculated - //automatically by EditTable - if (thead.length > 0 && !cfg.startRow) { - startRow = undefined; + AdapterEzEditTable.prototype._setAdvancedGrid = function _setAdvancedGrid() { + var tf = this.tf; + + //start row for EditTable constructor needs to be calculated + var startRow, + cfg = this.cfg, + thead = _dom2.default.tag(tf.tbl, 'thead'); + + //if thead exists and startRow not specified, startRow is calculated + //automatically by EditTable + if (thead.length > 0 && !cfg.startRow) { + startRow = undefined; + } + //otherwise startRow config property if any or TableFilter refRow + else { + startRow = cfg.startRow || tf.refRow; } - //otherwise startRow config property if any or TableFilter refRow - else { - startRow = cfg.startRow || tf.refRow; - } - cfg.base_path = cfg.base_path || tf.basePath + 'ezEditTable/'; - var editable = cfg.editable; - var selectable = cfg.selection; + cfg.base_path = cfg.base_path || tf.basePath + 'ezEditTable/'; + var editable = cfg.editable; + var selectable = cfg.selection; - if (selectable) { - cfg.default_selection = cfg.default_selection || 'row'; - } - //CSS Styles - cfg.active_cell_css = cfg.active_cell_css || 'ezETSelectedCell'; + if (selectable) { + cfg.default_selection = cfg.default_selection || 'row'; + } + //CSS Styles + cfg.active_cell_css = cfg.active_cell_css || 'ezETSelectedCell'; - var _lastValidRowIndex = 0; - var _lastRowIndex = 0; + var _lastValidRowIndex = 0; + var _lastRowIndex = 0; - if (selectable) { - //Row navigation needs to be calculated according to TableFilter's - //validRowsIndex array - var onAfterSelection = function onAfterSelection(et, selectedElm, e) { - var slc = et.Selection; - //Next valid filtered row needs to be selected - var doSelect = function doSelect(nextRowIndex) { - if (et.defaultSelection === 'row') { + if (selectable) { + //Row navigation needs to be calculated according to TableFilter's + //validRowsIndex array + var onAfterSelection = function onAfterSelection(et, selectedElm, e) { + var slc = et.Selection; + //Next valid filtered row needs to be selected + var doSelect = function doSelect(nextRowIndex) { + if (et.defaultSelection === 'row') { + /* eslint-disable */ + slc.SelectRowByIndex(nextRowIndex); + /* eslint-enable */ + } else { /* eslint-disable */ - slc.SelectRowByIndex(nextRowIndex); + et.ClearSelections(); /* eslint-enable */ - } else { + var cellIndex = selectedElm.cellIndex, + row = tf.tbl.rows[nextRowIndex]; + if (et.defaultSelection === 'both') { /* eslint-disable */ - et.ClearSelections(); + slc.SelectRowByIndex(nextRowIndex); /* eslint-enable */ - var cellIndex = selectedElm.cellIndex, - row = tf.tbl.rows[nextRowIndex]; - if (et.defaultSelection === 'both') { - /* eslint-disable */ - slc.SelectRowByIndex(nextRowIndex); - /* eslint-enable */ - } - if (row) { - /* eslint-disable */ - slc.SelectCell(row.cells[cellIndex]); - /* eslint-enable */ - } } - //Table is filtered - if (tf.validRowsIndex.length !== tf.getRowsNb()) { - var r = tf.tbl.rows[nextRowIndex]; - if (r) { - r.scrollIntoView(false); - } - if (cell) { - if (cell.cellIndex === tf.getCellsNb() - 1 && tf.gridLayout) { - tf.tblCont.scrollLeft = 100000000; - } else if (cell.cellIndex === 0 && tf.gridLayout) { - tf.tblCont.scrollLeft = 0; - } else { - cell.scrollIntoView(false); - } + if (row) { + /* eslint-disable */ + slc.SelectCell(row.cells[cellIndex]); + /* eslint-enable */ + } + } + //Table is filtered + if (tf.validRowsIndex.length !== tf.getRowsNb()) { + var r = tf.tbl.rows[nextRowIndex]; + if (r) { + r.scrollIntoView(false); + } + if (cell) { + if (cell.cellIndex === tf.getCellsNb() - 1 && tf.gridLayout) { + tf.tblCont.scrollLeft = 100000000; + } else if (cell.cellIndex === 0 && tf.gridLayout) { + tf.tblCont.scrollLeft = 0; + } else { + cell.scrollIntoView(false); } } - }; - - //table is not filtered - if (!tf.validRowsIndex) { - return; } - var validIndexes = tf.validRowsIndex, - validIdxLen = validIndexes.length, - row = et.defaultSelection !== 'row' ? selectedElm.parentNode : selectedElm, + }; - //cell for default_selection = 'both' or 'cell' - cell = selectedElm.nodeName === 'TD' ? selectedElm : null, + //table is not filtered + if (!tf.validRowsIndex) { + return; + } + var validIndexes = tf.validRowsIndex, + validIdxLen = validIndexes.length, + row = et.defaultSelection !== 'row' ? selectedElm.parentNode : selectedElm, - /* eslint-disable */ - keyCode = e !== undefined ? et.Event.GetKey(e) : 0, + //cell for default_selection = 'both' or 'cell' + cell = selectedElm.nodeName === 'TD' ? selectedElm : null, - /* eslint-enable */ - isRowValid = validIndexes.indexOf(row.rowIndex) !== -1, - nextRowIndex, - paging = tf.feature('paging'), + /* eslint-disable */ + keyCode = e !== undefined ? et.Event.GetKey(e) : 0, - //pgup/pgdown keys - d = keyCode === 34 || keyCode === 33 ? paging && paging.pagingLength || et.nbRowsPerPage : 1; + /* eslint-enable */ + isRowValid = validIndexes.indexOf(row.rowIndex) !== -1, + nextRowIndex, + paging = tf.feature('paging'), - //If next row is not valid, next valid filtered row needs to be - //calculated - if (!isRowValid) { - //Selection direction up/down - if (row.rowIndex > _lastRowIndex) { - //last row - if (row.rowIndex >= validIndexes[validIdxLen - 1]) { + //pgup/pgdown keys + d = keyCode === 34 || keyCode === 33 ? paging && paging.pagingLength || et.nbRowsPerPage : 1; + + //If next row is not valid, next valid filtered row needs to be + //calculated + if (!isRowValid) { + //Selection direction up/down + if (row.rowIndex > _lastRowIndex) { + //last row + if (row.rowIndex >= validIndexes[validIdxLen - 1]) { + nextRowIndex = validIndexes[validIdxLen - 1]; + } else { + var calcRowIndex = _lastValidRowIndex + d; + if (calcRowIndex > validIdxLen - 1) { nextRowIndex = validIndexes[validIdxLen - 1]; } else { - var calcRowIndex = _lastValidRowIndex + d; - if (calcRowIndex > validIdxLen - 1) { - nextRowIndex = validIndexes[validIdxLen - 1]; - } else { - nextRowIndex = validIndexes[calcRowIndex]; - } + nextRowIndex = validIndexes[calcRowIndex]; + } + } + } else { + //first row + if (row.rowIndex <= validIndexes[0]) { + nextRowIndex = validIndexes[0]; + } else { + var v = validIndexes[_lastValidRowIndex - d]; + nextRowIndex = v ? v : validIndexes[0]; + } + } + _lastRowIndex = row.rowIndex; + doSelect(nextRowIndex); + } else { + //If filtered row is valid, special calculation for + //pgup/pgdown keys + if (keyCode !== 34 && keyCode !== 33) { + _lastValidRowIndex = validIndexes.indexOf(row.rowIndex); + _lastRowIndex = row.rowIndex; + } else { + if (keyCode === 34) { + //pgdown + //last row + if (_lastValidRowIndex + d <= validIdxLen - 1) { + nextRowIndex = validIndexes[_lastValidRowIndex + d]; + } else { + nextRowIndex = [validIdxLen - 1]; } } else { + //pgup //first row - if (row.rowIndex <= validIndexes[0]) { + if (_lastValidRowIndex - d <= validIndexes[0]) { nextRowIndex = validIndexes[0]; } else { - var v = validIndexes[_lastValidRowIndex - d]; - nextRowIndex = v ? v : validIndexes[0]; + nextRowIndex = validIndexes[_lastValidRowIndex - d]; } } - _lastRowIndex = row.rowIndex; + _lastRowIndex = nextRowIndex; + _lastValidRowIndex = validIndexes.indexOf(nextRowIndex); doSelect(nextRowIndex); - } else { - //If filtered row is valid, special calculation for - //pgup/pgdown keys - if (keyCode !== 34 && keyCode !== 33) { - _lastValidRowIndex = validIndexes.indexOf(row.rowIndex); - _lastRowIndex = row.rowIndex; - } else { - if (keyCode === 34) { - //pgdown - //last row - if (_lastValidRowIndex + d <= validIdxLen - 1) { - nextRowIndex = validIndexes[_lastValidRowIndex + d]; - } else { - nextRowIndex = [validIdxLen - 1]; - } - } else { - //pgup - //first row - if (_lastValidRowIndex - d <= validIndexes[0]) { - nextRowIndex = validIndexes[0]; - } else { - nextRowIndex = validIndexes[_lastValidRowIndex - d]; - } - } - _lastRowIndex = nextRowIndex; - _lastValidRowIndex = validIndexes.indexOf(nextRowIndex); - doSelect(nextRowIndex); - } } - }; + } + }; - //Page navigation has to be enforced whenever selected row is out of - //the current page range - var onBeforeSelection = function onBeforeSelection(et, selectedElm) { - var row = et.defaultSelection !== 'row' ? selectedElm.parentNode : selectedElm; - if (tf.paging) { - if (tf.feature('paging').nbPages > 1) { - var paging = tf.feature('paging'); - //page length is re-assigned in case it has changed - et.nbRowsPerPage = paging.pagingLength; - var validIndexes = tf.validRowsIndex, - validIdxLen = validIndexes.length, - pagingEndRow = parseInt(paging.startPagingRow, 10) + parseInt(paging.pagingLength, 10); - var rowIndex = row.rowIndex; - - if (rowIndex === validIndexes[validIdxLen - 1] && paging.currentPageNb !== paging.nbPages) { - paging.setPage('last'); - } else if (rowIndex == validIndexes[0] && paging.currentPageNb !== 1) { - paging.setPage('first'); - } else if (rowIndex > validIndexes[pagingEndRow - 1] && rowIndex < validIndexes[validIdxLen - 1]) { - paging.setPage('next'); - } else if (rowIndex < validIndexes[paging.startPagingRow] && rowIndex > validIndexes[0]) { - paging.setPage('previous'); - } - } - } - }; - - //Selected row needs to be visible when paging is activated + //Page navigation has to be enforced whenever selected row is out of + //the current page range + var onBeforeSelection = function onBeforeSelection(et, selectedElm) { + var row = et.defaultSelection !== 'row' ? selectedElm.parentNode : selectedElm; if (tf.paging) { - tf.feature('paging').onAfterChangePage = function (paging) { - var advGrid = paging.tf.extension('advancedGrid'); - var et = advGrid._ezEditTable; - var slc = et.Selection; - /* eslint-disable */ - var row = slc.GetActiveRow(); - /* eslint-enable */ - if (row) { - row.scrollIntoView(false); - } - /* eslint-disable */ - var cell = slc.GetActiveCell(); - /* eslint-enable */ - if (cell) { - cell.scrollIntoView(false); - } - }; - } + if (tf.feature('paging').nbPages > 1) { + var paging = tf.feature('paging'); + //page length is re-assigned in case it has changed + et.nbRowsPerPage = paging.pagingLength; + var validIndexes = tf.validRowsIndex, + validIdxLen = validIndexes.length, + pagingEndRow = parseInt(paging.startPagingRow, 10) + parseInt(paging.pagingLength, 10); + var rowIndex = row.rowIndex; - //Rows navigation when rows are filtered is performed with the - //EditTable row selection callback events - if (cfg.default_selection === 'row') { - var fnB = cfg.on_before_selected_row; - cfg.on_before_selected_row = function () { - onBeforeSelection(arguments[0], arguments[1], arguments[2]); - if (fnB) { - fnB.call(null, arguments[0], arguments[1], arguments[2]); + if (rowIndex === validIndexes[validIdxLen - 1] && paging.currentPageNb !== paging.nbPages) { + paging.setPage('last'); + } else if (rowIndex == validIndexes[0] && paging.currentPageNb !== 1) { + paging.setPage('first'); + } else if (rowIndex > validIndexes[pagingEndRow - 1] && rowIndex < validIndexes[validIdxLen - 1]) { + paging.setPage('next'); + } else if (rowIndex < validIndexes[paging.startPagingRow] && rowIndex > validIndexes[0]) { + paging.setPage('previous'); } - }; - var fnA = cfg.on_after_selected_row; - cfg.on_after_selected_row = function () { - onAfterSelection(arguments[0], arguments[1], arguments[2]); - if (fnA) { - fnA.call(null, arguments[0], arguments[1], arguments[2]); - } - }; - } else { - var fnD = cfg.on_before_selected_cell; - cfg.on_before_selected_cell = function () { - onBeforeSelection(arguments[0], arguments[1], arguments[2]); - if (fnD) { - fnD.call(null, arguments[0], arguments[1], arguments[2]); - } - }; - var fnC = cfg.on_after_selected_cell; - cfg.on_after_selected_cell = function () { - onAfterSelection(arguments[0], arguments[1], arguments[2]); - if (fnC) { - fnC.call(null, arguments[0], arguments[1], arguments[2]); - } - }; + } } + }; + + //Selected row needs to be visible when paging is activated + if (tf.paging) { + tf.feature('paging').onAfterChangePage = function (paging) { + var advGrid = paging.tf.extension('advancedGrid'); + var et = advGrid._ezEditTable; + var slc = et.Selection; + /* eslint-disable */ + var row = slc.GetActiveRow(); + /* eslint-enable */ + if (row) { + row.scrollIntoView(false); + } + /* eslint-disable */ + var cell = slc.GetActiveCell(); + /* eslint-enable */ + if (cell) { + cell.scrollIntoView(false); + } + }; } - if (editable) { - //Added or removed rows, TF rows number needs to be re-calculated - var fnE = cfg.on_added_dom_row; - cfg.on_added_dom_row = function () { - tf.nbFilterableRows++; + + //Rows navigation when rows are filtered is performed with the + //EditTable row selection callback events + if (cfg.default_selection === 'row') { + var fnB = cfg.on_before_selected_row; + cfg.on_before_selected_row = function () { + onBeforeSelection(arguments[0], arguments[1], arguments[2]); + if (fnB) { + fnB.call(null, arguments[0], arguments[1], arguments[2]); + } + }; + var fnA = cfg.on_after_selected_row; + cfg.on_after_selected_row = function () { + onAfterSelection(arguments[0], arguments[1], arguments[2]); + if (fnA) { + fnA.call(null, arguments[0], arguments[1], arguments[2]); + } + }; + } else { + var fnD = cfg.on_before_selected_cell; + cfg.on_before_selected_cell = function () { + onBeforeSelection(arguments[0], arguments[1], arguments[2]); + if (fnD) { + fnD.call(null, arguments[0], arguments[1], arguments[2]); + } + }; + var fnC = cfg.on_after_selected_cell; + cfg.on_after_selected_cell = function () { + onAfterSelection(arguments[0], arguments[1], arguments[2]); + if (fnC) { + fnC.call(null, arguments[0], arguments[1], arguments[2]); + } + }; + } + } + if (editable) { + //Added or removed rows, TF rows number needs to be re-calculated + var fnE = cfg.on_added_dom_row; + cfg.on_added_dom_row = function () { + tf.nbFilterableRows++; + if (!tf.paging) { + tf.emitter.emit('rows-changed', tf, this); + //tf.feature('rowsCounter').refresh(); + } else { + tf.nbRows++; + tf.nbVisibleRows++; + tf.nbFilterableRows++; + tf.paging = false; + tf.feature('paging').destroy(); + tf.feature('paging').reset(); + } + if (tf.alternateRows) { + tf.feature('alternateRows').init(); + } + if (fnE) { + fnE.call(null, arguments[0], arguments[1], arguments[2]); + } + }; + if (cfg.actions && cfg.actions['delete']) { + var fnF = cfg.actions['delete'].on_after_submit; + cfg.actions['delete'].on_after_submit = function () { + tf.nbFilterableRows--; if (!tf.paging) { + // tf.feature('rowsCounter').refresh(); tf.emitter.emit('rows-changed', tf, this); - //tf.feature('rowsCounter').refresh(); } else { - tf.nbRows++; - tf.nbVisibleRows++; - tf.nbFilterableRows++; - tf.paging = false; - tf.feature('paging').destroy(); - tf.feature('paging').reset(); - } + tf.nbRows--; + tf.nbVisibleRows--; + tf.nbFilterableRows--; + tf.paging = false; + tf.feature('paging').destroy(); + tf.feature('paging').reset(false); + } if (tf.alternateRows) { tf.feature('alternateRows').init(); } - if (fnE) { - fnE.call(null, arguments[0], arguments[1], arguments[2]); + if (fnF) { + fnF.call(null, arguments[0], arguments[1]); } }; - if (cfg.actions && cfg.actions['delete']) { - var fnF = cfg.actions['delete'].on_after_submit; - cfg.actions['delete'].on_after_submit = function () { - tf.nbFilterableRows--; - if (!tf.paging) { - // tf.feature('rowsCounter').refresh(); - tf.emitter.emit('rows-changed', tf, this); - } else { - tf.nbRows--; - tf.nbVisibleRows--; - tf.nbFilterableRows--; - tf.paging = false; - tf.feature('paging').destroy(); - tf.feature('paging').reset(false); - } - if (tf.alternateRows) { - tf.feature('alternateRows').init(); - } - if (fnF) { - fnF.call(null, arguments[0], arguments[1]); - } - }; - } } + } - try { + try { + /* eslint-disable */ + this._ezEditTable = new EditTable(tf.id, cfg, startRow); + this._ezEditTable.Init(); + /* eslint-enable */ + } catch (e) { + throw new Error(this.err); + } + + this.initialized = true; + }; + + /** + * Reset advanced grid when previously removed + */ + + + AdapterEzEditTable.prototype.reset = function reset() { + var ezEditTable = this._ezEditTable; + if (ezEditTable) { + if (this.cfg.selection) { /* eslint-disable */ - this._ezEditTable = new EditTable(tf.id, cfg, startRow); - this._ezEditTable.Init(); + ezEditTable.Selection.Set(); /* eslint-enable */ - } catch (e) { - throw new Error(this.err); } - - this.initialized = true; - } - - /** - * Reset advanced grid when previously removed - */ - - }, { - key: 'reset', - value: function reset() { - var ezEditTable = this._ezEditTable; - if (ezEditTable) { - if (this.cfg.selection) { - /* eslint-disable */ - ezEditTable.Selection.Set(); - /* eslint-enable */ - } - if (this.cfg.editable) { - /* eslint-disable */ - ezEditTable.Editable.Set(); - /* eslint-enable */ - } + if (this.cfg.editable) { + /* eslint-disable */ + ezEditTable.Editable.Set(); + /* eslint-enable */ } } + }; - /** - * Toggle behaviour - */ + /** + * Toggle behaviour + */ - }, { - key: 'toggle', - value: function toggle() { - var ezEditTable = this._ezEditTable; - if (ezEditTable.editable) { + + AdapterEzEditTable.prototype.toggle = function toggle() { + var ezEditTable = this._ezEditTable; + if (ezEditTable.editable) { + /* eslint-disable */ + ezEditTable.Editable.Remove(); + /* eslint-enable */ + } else { + /* eslint-disable */ + ezEditTable.Editable.Set(); + /* eslint-enable */ + } + if (ezEditTable.selection) { + /* eslint-disable */ + ezEditTable.Selection.Remove(); + /* eslint-enable */ + } else { + /* eslint-disable */ + ezEditTable.Selection.Set(); + /* eslint-enable */ + } + }; + + AdapterEzEditTable.prototype._toggleForInputFilter = function _toggleForInputFilter() { + var tf = this.tf; + if (!tf.activeFlt) { + return; + } + var colIndex = tf.activeFlt.getAttribute('ct'); + var filterType = tf.getFilterType(colIndex); + if (filterType === tf.fltTypeInp) { + this.toggle(); + } + }; + + /** + * Remove advanced grid + */ + + + AdapterEzEditTable.prototype.destroy = function destroy() { + var _this2 = this; + + var ezEditTable = this._ezEditTable; + if (ezEditTable) { + if (this.cfg.selection) { + /* eslint-disable */ + ezEditTable.Selection.ClearSelections(); + ezEditTable.Selection.Remove(); + /* eslint-enable */ + } + if (this.cfg.editable) { /* eslint-disable */ ezEditTable.Editable.Remove(); /* eslint-enable */ - } else { - /* eslint-disable */ - ezEditTable.Editable.Set(); - /* eslint-enable */ - } - if (ezEditTable.selection) { - /* eslint-disable */ - ezEditTable.Selection.Remove(); - /* eslint-enable */ - } else { - /* eslint-disable */ - ezEditTable.Selection.Set(); - /* eslint-enable */ - } - } - }, { - key: '_toggleForInputFilter', - value: function _toggleForInputFilter() { - var tf = this.tf; - if (!tf.activeFlt) { - return; - } - var colIndex = tf.activeFlt.getAttribute('ct'); - var filterType = tf.getFilterType(colIndex); - if (filterType === tf.fltTypeInp) { - this.toggle(); } } - /** - * Remove advanced grid - */ - - }, { - key: 'destroy', - value: function destroy() { - var _this2 = this; - - var ezEditTable = this._ezEditTable; - if (ezEditTable) { - if (this.cfg.selection) { - /* eslint-disable */ - ezEditTable.Selection.ClearSelections(); - ezEditTable.Selection.Remove(); - /* eslint-enable */ - } - if (this.cfg.editable) { - /* eslint-disable */ - ezEditTable.Editable.Remove(); - /* eslint-enable */ - } - } - - this.emitter.off(['filter-focus', 'filter-blur'], function () { - return _this2._toggleForInputFilter(); - }); - this.initialized = false; - } - }]); + this.emitter.off(['filter-focus', 'filter-blur'], function () { + return _this2._toggleForInputFilter(); + }); + this.initialized = false; + }; return AdapterEzEditTable; }(); @@ -605,8 +595,6 @@ webpackJsonp([1],{ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _dom = __webpack_require__(2); var _dom2 = _interopRequireDefault(_dom); @@ -642,303 +630,298 @@ webpackJsonp([1],{ this.tf = tf; } - _createClass(ColOps, [{ - key: 'init', - value: function init() { - var _this = this; + ColOps.prototype.init = function init() { + var _this = this; - // subscribe to events - this.tf.emitter.on(['after-filtering'], function () { - return _this.calc(); - }); + // subscribe to events + this.tf.emitter.on(['after-filtering'], function () { + return _this.calc(); + }); - this.calc(); + this.calc(); + }; + + /** + * Calculates columns' values + * Configuration options are stored in 'opts' property + * - 'id' contains ids of elements showing result (array) + * - 'col' contains the columns' indexes (array) + * - 'operation' contains operation type (array, values: 'sum', 'mean', + * 'min', 'max', 'median', 'q1', 'q3') + * - 'write_method' array defines which method to use for displaying the + * result (innerHTML, setValue, createTextNode) - default: 'innerHTML' + * - 'tot_row_index' defines in which row results are displayed + * (integers array) + * + * - changes made by Nuovella: + * (1) optimized the routine (now it will only process each column once), + * (2) added calculations for the median, lower and upper quartile. + */ + + + ColOps.prototype.calc = function calc() { + var tf = this.tf; + if (!tf.hasGrid()) { + return; } - /** - * Calculates columns' values - * Configuration options are stored in 'opts' property - * - 'id' contains ids of elements showing result (array) - * - 'col' contains the columns' indexes (array) - * - 'operation' contains operation type (array, values: 'sum', 'mean', - * 'min', 'max', 'median', 'q1', 'q3') - * - 'write_method' array defines which method to use for displaying the - * result (innerHTML, setValue, createTextNode) - default: 'innerHTML' - * - 'tot_row_index' defines in which row results are displayed - * (integers array) - * - * - changes made by Nuovella: - * (1) optimized the routine (now it will only process each column once), - * (2) added calculations for the median, lower and upper quartile. - */ + if (this.onBeforeOperation) { + this.onBeforeOperation.call(null, tf); + } - }, { - key: 'calc', - value: function calc() { - var tf = this.tf; - if (!tf.hasGrid()) { - return; - } + var opts = this.opts, + labelId = opts.id, + colIndex = opts.col, + operation = opts.operation, + outputType = opts.write_method, + totRowIndex = opts.tot_row_index, + excludeRow = opts.exclude_row, + decimalPrecision = _types2.default.isUndef(opts.decimal_precision) ? 2 : opts.decimal_precision; - if (this.onBeforeOperation) { - this.onBeforeOperation.call(null, tf); - } + //nuovella: determine unique list of columns to operate on + var ucolIndex = [], + ucolMax = 0; + ucolIndex[ucolMax] = colIndex[0]; - var opts = this.opts, - labelId = opts.id, - colIndex = opts.col, - operation = opts.operation, - outputType = opts.write_method, - totRowIndex = opts.tot_row_index, - excludeRow = opts.exclude_row, - decimalPrecision = _types2.default.isUndef(opts.decimal_precision) ? 2 : opts.decimal_precision; - - //nuovella: determine unique list of columns to operate on - var ucolIndex = [], - ucolMax = 0; - ucolIndex[ucolMax] = colIndex[0]; - - for (var ii = 1; ii < colIndex.length; ii++) { - var saved = 0; - //see if colIndex[ii] is already in the list of unique indexes - for (var jj = 0; jj <= ucolMax; jj++) { - if (ucolIndex[jj] === colIndex[ii]) { - saved = 1; - } - } - //if not saved then, save the index; - if (saved === 0) { - ucolMax++; - ucolIndex[ucolMax] = colIndex[ii]; + for (var ii = 1; ii < colIndex.length; ii++) { + var saved = 0; + //see if colIndex[ii] is already in the list of unique indexes + for (var jj = 0; jj <= ucolMax; jj++) { + if (ucolIndex[jj] === colIndex[ii]) { + saved = 1; } } + //if not saved then, save the index; + if (saved === 0) { + ucolMax++; + ucolIndex[ucolMax] = colIndex[ii]; + } + } - if (_string2.default.lower(typeof labelId === 'undefined' ? 'undefined' : _typeof(labelId)) == 'object' && _string2.default.lower(typeof colIndex === 'undefined' ? 'undefined' : _typeof(colIndex)) == 'object' && _string2.default.lower(typeof operation === 'undefined' ? 'undefined' : _typeof(operation)) == 'object') { - var rows = tf.tbl.rows, - colvalues = []; + if (_string2.default.lower(typeof labelId === 'undefined' ? 'undefined' : _typeof(labelId)) == 'object' && _string2.default.lower(typeof colIndex === 'undefined' ? 'undefined' : _typeof(colIndex)) == 'object' && _string2.default.lower(typeof operation === 'undefined' ? 'undefined' : _typeof(operation)) == 'object') { + var rows = tf.tbl.rows, + colvalues = []; - for (var ucol = 0; ucol <= ucolMax; ucol++) { - //this retrieves col values - //use ucolIndex because we only want to pass through this loop - //once for each column get the values in this unique column - colvalues.push(tf.getColValues(ucolIndex[ucol], false, true, excludeRow)); + for (var ucol = 0; ucol <= ucolMax; ucol++) { + //this retrieves col values + //use ucolIndex because we only want to pass through this loop + //once for each column get the values in this unique column + colvalues.push(tf.getColValues(ucolIndex[ucol], false, true, excludeRow)); - //next: calculate all operations for this column - var result, - nbvalues = 0, - temp, - meanValue = 0, - sumValue = 0, - minValue = null, - maxValue = null, - q1Value = null, - medValue = null, - q3Value = null, - meanFlag = 0, - sumFlag = 0, - minFlag = 0, - maxFlag = 0, - q1Flag = 0, - medFlag = 0, - q3Flag = 0, - theList = [], - opsThisCol = [], - decThisCol = [], - labThisCol = [], - oTypeThisCol = [], - mThisCol = -1; + //next: calculate all operations for this column + var result, + nbvalues = 0, + temp, + meanValue = 0, + sumValue = 0, + minValue = null, + maxValue = null, + q1Value = null, + medValue = null, + q3Value = null, + meanFlag = 0, + sumFlag = 0, + minFlag = 0, + maxFlag = 0, + q1Flag = 0, + medFlag = 0, + q3Flag = 0, + theList = [], + opsThisCol = [], + decThisCol = [], + labThisCol = [], + oTypeThisCol = [], + mThisCol = -1; - for (var k = 0; k < colIndex.length; k++) { - if (colIndex[k] === ucolIndex[ucol]) { - mThisCol++; - opsThisCol[mThisCol] = _string2.default.lower(operation[k]); - decThisCol[mThisCol] = decimalPrecision[k]; - labThisCol[mThisCol] = labelId[k]; - oTypeThisCol = outputType !== undefined && _string2.default.lower(typeof outputType === 'undefined' ? 'undefined' : _typeof(outputType)) === 'object' ? outputType[k] : null; + for (var k = 0; k < colIndex.length; k++) { + if (colIndex[k] === ucolIndex[ucol]) { + mThisCol++; + opsThisCol[mThisCol] = _string2.default.lower(operation[k]); + decThisCol[mThisCol] = decimalPrecision[k]; + labThisCol[mThisCol] = labelId[k]; + oTypeThisCol = outputType !== undefined && _string2.default.lower(typeof outputType === 'undefined' ? 'undefined' : _typeof(outputType)) === 'object' ? outputType[k] : null; - switch (opsThisCol[mThisCol]) { - case 'mean': - meanFlag = 1; - break; - case 'sum': - sumFlag = 1; - break; - case 'min': - minFlag = 1; - break; - case 'max': - maxFlag = 1; - break; - case 'median': - medFlag = 1; - break; - case 'q1': - q1Flag = 1; - break; - case 'q3': - q3Flag = 1; - break; - } - } - } - - for (var j = 0; j < colvalues[ucol].length; j++) { - //sort the list for calculation of median and quartiles - if (q1Flag == 1 || q3Flag == 1 || medFlag == 1) { - if (j < colvalues[ucol].length - 1) { - for (k = j + 1; k < colvalues[ucol].length; k++) { - /* eslint-disable */ - if (eval(colvalues[ucol][k]) < eval(colvalues[ucol][j])) { - /* eslint-enable */ - temp = colvalues[ucol][j]; - colvalues[ucol][j] = colvalues[ucol][k]; - colvalues[ucol][k] = temp; - } - } - } - } - var cvalue = parseFloat(colvalues[ucol][j]); - theList[j] = parseFloat(cvalue); - - if (!isNaN(cvalue)) { - nbvalues++; - if (sumFlag === 1 || meanFlag === 1) { - sumValue += parseFloat(cvalue); - } - if (minFlag === 1) { - if (minValue === null) { - minValue = parseFloat(cvalue); - } else { - minValue = parseFloat(cvalue) < minValue ? parseFloat(cvalue) : minValue; - } - } - if (maxFlag === 1) { - if (maxValue === null) { - maxValue = parseFloat(cvalue); - } else { - maxValue = parseFloat(cvalue) > maxValue ? parseFloat(cvalue) : maxValue; - } - } - } - } //for j - if (meanFlag === 1) { - meanValue = sumValue / nbvalues; - } - if (medFlag === 1) { - var aux = 0; - if (nbvalues % 2 === 1) { - aux = Math.floor(nbvalues / 2); - medValue = theList[aux]; - } else { - medValue = (theList[nbvalues / 2] + theList[nbvalues / 2 - 1]) / 2; - } - } - var posa; - if (q1Flag === 1) { - posa = 0.0; - posa = Math.floor(nbvalues / 4); - if (4 * posa == nbvalues) { - q1Value = (theList[posa - 1] + theList[posa]) / 2; - } else { - q1Value = theList[posa]; - } - } - if (q3Flag === 1) { - posa = 0.0; - var posb = 0.0; - posa = Math.floor(nbvalues / 4); - if (4 * posa === nbvalues) { - posb = 3 * posa; - q3Value = (theList[posb] + theList[posb - 1]) / 2; - } else { - q3Value = theList[nbvalues - posa - 1]; - } - } - - for (var i = 0; i <= mThisCol; i++) { - switch (opsThisCol[i]) { + switch (opsThisCol[mThisCol]) { case 'mean': - result = meanValue; + meanFlag = 1; break; case 'sum': - result = sumValue; + sumFlag = 1; break; case 'min': - result = minValue; + minFlag = 1; break; case 'max': - result = maxValue; + maxFlag = 1; break; case 'median': - result = medValue; + medFlag = 1; break; case 'q1': - result = q1Value; + q1Flag = 1; break; case 'q3': - result = q3Value; + q3Flag = 1; break; } + } + } - var precision = !isNaN(decThisCol[i]) ? decThisCol[i] : 2; - - //if outputType is defined - if (oTypeThisCol && result) { - result = result.toFixed(precision); - - if (_dom2.default.id(labThisCol[i])) { - switch (_string2.default.lower(oTypeThisCol)) { - case 'innerhtml': - if (isNaN(result) || !isFinite(result) || nbvalues === 0) { - _dom2.default.id(labThisCol[i]).innerHTML = '.'; - } else { - _dom2.default.id(labThisCol[i]).innerHTML = result; - } - break; - case 'setvalue': - _dom2.default.id(labThisCol[i]).value = result; - break; - case 'createtextnode': - var oldnode = _dom2.default.id(labThisCol[i]).firstChild; - var txtnode = _dom2.default.text(result); - _dom2.default.id(labThisCol[i]).replaceChild(txtnode, oldnode); - break; - } //switch + for (var j = 0; j < colvalues[ucol].length; j++) { + //sort the list for calculation of median and quartiles + if (q1Flag == 1 || q3Flag == 1 || medFlag == 1) { + if (j < colvalues[ucol].length - 1) { + for (k = j + 1; k < colvalues[ucol].length; k++) { + /* eslint-disable */ + if (eval(colvalues[ucol][k]) < eval(colvalues[ucol][j])) { + /* eslint-enable */ + temp = colvalues[ucol][j]; + colvalues[ucol][j] = colvalues[ucol][k]; + colvalues[ucol][k] = temp; + } } - } else { - try { + } + } + var cvalue = parseFloat(colvalues[ucol][j]); + theList[j] = parseFloat(cvalue); + + if (!isNaN(cvalue)) { + nbvalues++; + if (sumFlag === 1 || meanFlag === 1) { + sumValue += parseFloat(cvalue); + } + if (minFlag === 1) { + if (minValue === null) { + minValue = parseFloat(cvalue); + } else { + minValue = parseFloat(cvalue) < minValue ? parseFloat(cvalue) : minValue; + } + } + if (maxFlag === 1) { + if (maxValue === null) { + maxValue = parseFloat(cvalue); + } else { + maxValue = parseFloat(cvalue) > maxValue ? parseFloat(cvalue) : maxValue; + } + } + } + } //for j + if (meanFlag === 1) { + meanValue = sumValue / nbvalues; + } + if (medFlag === 1) { + var aux = 0; + if (nbvalues % 2 === 1) { + aux = Math.floor(nbvalues / 2); + medValue = theList[aux]; + } else { + medValue = (theList[nbvalues / 2] + theList[nbvalues / 2 - 1]) / 2; + } + } + var posa; + if (q1Flag === 1) { + posa = 0.0; + posa = Math.floor(nbvalues / 4); + if (4 * posa == nbvalues) { + q1Value = (theList[posa - 1] + theList[posa]) / 2; + } else { + q1Value = theList[posa]; + } + } + if (q3Flag === 1) { + posa = 0.0; + var posb = 0.0; + posa = Math.floor(nbvalues / 4); + if (4 * posa === nbvalues) { + posb = 3 * posa; + q3Value = (theList[posb] + theList[posb - 1]) / 2; + } else { + q3Value = theList[nbvalues - posa - 1]; + } + } + + for (var i = 0; i <= mThisCol; i++) { + switch (opsThisCol[i]) { + case 'mean': + result = meanValue; + break; + case 'sum': + result = sumValue; + break; + case 'min': + result = minValue; + break; + case 'max': + result = maxValue; + break; + case 'median': + result = medValue; + break; + case 'q1': + result = q1Value; + break; + case 'q3': + result = q3Value; + break; + } + + var precision = !isNaN(decThisCol[i]) ? decThisCol[i] : 2; + + //if outputType is defined + if (oTypeThisCol && result) { + result = result.toFixed(precision); + + if (_dom2.default.id(labThisCol[i])) { + switch (_string2.default.lower(oTypeThisCol)) { + case 'innerhtml': if (isNaN(result) || !isFinite(result) || nbvalues === 0) { _dom2.default.id(labThisCol[i]).innerHTML = '.'; } else { - _dom2.default.id(labThisCol[i]).innerHTML = result.toFixed(precision); + _dom2.default.id(labThisCol[i]).innerHTML = result; } - } catch (e) {} //catch - } //else - } //for i + break; + case 'setvalue': + _dom2.default.id(labThisCol[i]).value = result; + break; + case 'createtextnode': + var oldnode = _dom2.default.id(labThisCol[i]).firstChild; + var txtnode = _dom2.default.text(result); + _dom2.default.id(labThisCol[i]).replaceChild(txtnode, oldnode); + break; + } //switch + } + } else { + try { + if (isNaN(result) || !isFinite(result) || nbvalues === 0) { + _dom2.default.id(labThisCol[i]).innerHTML = '.'; + } else { + _dom2.default.id(labThisCol[i]).innerHTML = result.toFixed(precision); + } + } catch (e) {} //catch + } //else + } //for i - // row(s) with result are always visible - var totRow = totRowIndex && totRowIndex[ucol] ? rows[totRowIndex[ucol]] : null; - if (totRow) { - totRow.style.display = ''; - } - } //for ucol - } //if typeof + // row(s) with result are always visible + var totRow = totRowIndex && totRowIndex[ucol] ? rows[totRowIndex[ucol]] : null; + if (totRow) { + totRow.style.display = ''; + } + } //for ucol + } //if typeof - if (this.onAfterOperation) { - this.onAfterOperation.call(null, tf); - } + if (this.onAfterOperation) { + this.onAfterOperation.call(null, tf); } - }, { - key: 'destroy', - value: function destroy() { - var _this2 = this; + }; - // unsubscribe to events - this.tf.emitter.off(['after-filtering'], function () { - return _this2.calc(); - }); - } - }]); + ColOps.prototype.destroy = function destroy() { + var _this2 = this; + + // unsubscribe to events + this.tf.emitter.off(['after-filtering'], function () { + return _this2.calc(); + }); + }; return ColOps; }(); @@ -956,8 +939,6 @@ webpackJsonp([1],{ value: true }); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _dom = __webpack_require__(2); var _dom2 = _interopRequireDefault(_dom); @@ -1086,447 +1067,431 @@ webpackJsonp([1],{ this.tf = tf; } - _createClass(ColsVisibility, [{ - key: 'toggle', - value: function toggle() { - var contDisplay = this.contEl.style.display; - var onBeforeOpen = this.onBeforeOpen; - var onBeforeClose = this.onBeforeClose; - var onAfterOpen = this.onAfterOpen; - var onAfterClose = this.onAfterClose; + ColsVisibility.prototype.toggle = function toggle() { + var contDisplay = this.contEl.style.display; + var onBeforeOpen = this.onBeforeOpen; + var onBeforeClose = this.onBeforeClose; + var onAfterOpen = this.onAfterOpen; + var onAfterClose = this.onAfterClose; - if (onBeforeOpen && contDisplay !== 'inline') { - onBeforeOpen.call(null, this); - } - if (onBeforeClose && contDisplay === 'inline') { - onBeforeClose.call(null, this); - } - - this.contEl.style.display = contDisplay === 'inline' ? 'none' : 'inline'; - - if (onAfterOpen && contDisplay !== 'inline') { - onAfterOpen.call(null, this); - } - if (onAfterClose && contDisplay === 'inline') { - onAfterClose.call(null, this); - } + if (onBeforeOpen && contDisplay !== 'inline') { + onBeforeOpen.call(null, this); } - }, { - key: 'checkItem', - value: function checkItem(lbl) { - var li = lbl.parentNode; - if (!li || !lbl) { - return; - } - var isChecked = lbl.firstChild.checked; - var colIndex = lbl.firstChild.getAttribute('id').split('_')[1]; - colIndex = parseInt(colIndex, 10); - if (isChecked) { - _dom2.default.addClass(li, this.listSlcItemCssClass); - } else { - _dom2.default.removeClass(li, this.listSlcItemCssClass); - } - - var hide = false; - if (this.tickToHide && isChecked || !this.tickToHide && !isChecked) { - hide = true; - } - this.setHidden(colIndex, hide); - } - }, { - key: 'init', - value: function init() { - if (!this.manager) { - return; - } - this.buildBtn(); - this.buildManager(); - - this.initialized = true; + if (onBeforeClose && contDisplay === 'inline') { + onBeforeClose.call(null, this); } - /** - * Build main button UI - */ + this.contEl.style.display = contDisplay === 'inline' ? 'none' : 'inline'; - }, { - key: 'buildBtn', - value: function buildBtn() { - var _this = this; + if (onAfterOpen && contDisplay !== 'inline') { + onAfterOpen.call(null, this); + } + if (onAfterClose && contDisplay === 'inline') { + onAfterClose.call(null, this); + } + }; - if (this.btnEl) { - return; - } - var tf = this.tf; - var span = _dom2.default.create('span', ['id', this.prfx + tf.id]); - span.className = this.spanCssClass; - - //Container element (rdiv or custom element) - if (!this.btnTgtId) { - tf.setToolbar(); - } - var targetEl = !this.btnTgtId ? tf.rDiv : _dom2.default.id(this.btnTgtId); - - if (!this.btnTgtId) { - var firstChild = targetEl.firstChild; - firstChild.parentNode.insertBefore(span, firstChild); - } else { - targetEl.appendChild(span); - } - - if (!this.btnHtml) { - var btn = _dom2.default.create('a', ['href', 'javascript:;']); - btn.className = this.btnCssClass; - btn.title = this.desc; - - btn.innerHTML = this.btnText; - span.appendChild(btn); - if (!this.enableHover) { - _event2.default.add(btn, 'click', function (evt) { - _this.toggle(evt); - }); - } else { - _event2.default.add(btn, 'mouseover', function (evt) { - _this.toggle(evt); - }); - } - } else { - //Custom html - span.innerHTML = this.btnHtml; - var colVisEl = span.firstChild; - if (!this.enableHover) { - _event2.default.add(colVisEl, 'click', function (evt) { - _this.toggle(evt); - }); - } else { - _event2.default.add(colVisEl, 'mouseover', function (evt) { - _this.toggle(evt); - }); - } - } - - this.spanEl = span; - this.btnEl = this.spanEl.firstChild; - - if (this.onLoaded) { - this.onLoaded.call(null, this); - } + ColsVisibility.prototype.checkItem = function checkItem(lbl) { + var li = lbl.parentNode; + if (!li || !lbl) { + return; + } + var isChecked = lbl.firstChild.checked; + var colIndex = lbl.firstChild.getAttribute('id').split('_')[1]; + colIndex = parseInt(colIndex, 10); + if (isChecked) { + _dom2.default.addClass(li, this.listSlcItemCssClass); + } else { + _dom2.default.removeClass(li, this.listSlcItemCssClass); } - /** - * Build columns manager UI - */ + var hide = false; + if (this.tickToHide && isChecked || !this.tickToHide && !isChecked) { + hide = true; + } + this.setHidden(colIndex, hide); + }; - }, { - key: 'buildManager', - value: function buildManager() { - var _this2 = this; + ColsVisibility.prototype.init = function init() { + if (!this.manager) { + return; + } + this.buildBtn(); + this.buildManager(); - var tf = this.tf; + this.initialized = true; + }; - var container = !this.contElTgtId ? _dom2.default.create('div', ['id', this.prfxCont + tf.id]) : _dom2.default.id(this.contElTgtId); - container.className = this.contCssClass; + /** + * Build main button UI + */ - //Extension description - var extNameLabel = _dom2.default.create('p'); - extNameLabel.innerHTML = this.text; - container.appendChild(extNameLabel); - //Headers list - var ul = _dom2.default.create('ul', ['id', 'ul' + this.name + '_' + tf.id]); - ul.className = this.listCssClass; + ColsVisibility.prototype.buildBtn = function buildBtn() { + var _this = this; - var tbl = this.headersTbl ? this.headersTbl : tf.tbl; - var headerIndex = this.headersTbl ? this.headersIndex : tf.getHeadersRowIndex(); - var headerRow = tbl.rows[headerIndex]; + if (this.btnEl) { + return; + } + var tf = this.tf; + var span = _dom2.default.create('span', ['id', this.prfx + tf.id]); + span.className = this.spanCssClass; - //Tick all option - if (this.enableTickAll) { - var li = _dom2.default.createCheckItem('col__' + tf.id, this.tickAllText, this.tickAllText); - _dom2.default.addClass(li, this.listItemCssClass); - ul.appendChild(li); - li.check.checked = !this.tickToHide; + //Container element (rdiv or custom element) + if (!this.btnTgtId) { + tf.setToolbar(); + } + var targetEl = !this.btnTgtId ? tf.rDiv : _dom2.default.id(this.btnTgtId); - _event2.default.add(li.check, 'click', function () { - for (var h = 0; h < headerRow.cells.length; h++) { - var itm = _dom2.default.id('col_' + h + '_' + tf.id); - if (itm && li.check.checked !== itm.checked) { - itm.click(); - itm.checked = li.check.checked; - } - } - }); - } + if (!this.btnTgtId) { + var firstChild = targetEl.firstChild; + firstChild.parentNode.insertBefore(span, firstChild); + } else { + targetEl.appendChild(span); + } - for (var i = 0; i < headerRow.cells.length; i++) { - var cell = headerRow.cells[i]; - var cellText = this.headersText && this.headersText[i] ? this.headersText[i] : this._getHeaderText(cell); - var liElm = _dom2.default.createCheckItem('col_' + i + '_' + tf.id, cellText, cellText); - _dom2.default.addClass(liElm, this.listItemCssClass); - if (!this.tickToHide) { - _dom2.default.addClass(liElm, this.listSlcItemCssClass); - } - ul.appendChild(liElm); - if (!this.tickToHide) { - liElm.check.checked = true; - } + if (!this.btnHtml) { + var btn = _dom2.default.create('a', ['href', 'javascript:;']); + btn.className = this.btnCssClass; + btn.title = this.desc; - _event2.default.add(liElm.check, 'click', function (evt) { - var elm = _event2.default.target(evt); - var lbl = elm.parentNode; - _this2.checkItem(lbl); - }); - } - - //separator - var p = _dom2.default.create('p', ['align', 'center']); - var btn; - //Close link - if (!this.btnCloseHtml) { - btn = _dom2.default.create('a', ['href', 'javascript:;']); - btn.className = this.btnCloseCssClass; - btn.innerHTML = this.btnCloseText; + btn.innerHTML = this.btnText; + span.appendChild(btn); + if (!this.enableHover) { _event2.default.add(btn, 'click', function (evt) { - _this2.toggle(evt); + _this.toggle(evt); }); - p.appendChild(btn); } else { - p.innerHTML = this.btnCloseHtml; - btn = p.firstChild; - _event2.default.add(btn, 'click', function (evt) { - _this2.toggle(evt); + _event2.default.add(btn, 'mouseover', function (evt) { + _this.toggle(evt); }); } + } else { + //Custom html + span.innerHTML = this.btnHtml; + var colVisEl = span.firstChild; + if (!this.enableHover) { + _event2.default.add(colVisEl, 'click', function (evt) { + _this.toggle(evt); + }); + } else { + _event2.default.add(colVisEl, 'mouseover', function (evt) { + _this.toggle(evt); + }); + } + } - container.appendChild(ul); - container.appendChild(p); + this.spanEl = span; + this.btnEl = this.spanEl.firstChild; - this.btnEl.parentNode.insertBefore(container, this.btnEl); - this.contEl = container; + if (this.onLoaded) { + this.onLoaded.call(null, this); + } + }; - if (this.atStart) { - var a = this.atStart; - for (var k = 0; k < a.length; k++) { - var itm = _dom2.default.id('col_' + a[k] + '_' + tf.id); - if (itm) { + /** + * Build columns manager UI + */ + + + ColsVisibility.prototype.buildManager = function buildManager() { + var _this2 = this; + + var tf = this.tf; + + var container = !this.contElTgtId ? _dom2.default.create('div', ['id', this.prfxCont + tf.id]) : _dom2.default.id(this.contElTgtId); + container.className = this.contCssClass; + + //Extension description + var extNameLabel = _dom2.default.create('p'); + extNameLabel.innerHTML = this.text; + container.appendChild(extNameLabel); + + //Headers list + var ul = _dom2.default.create('ul', ['id', 'ul' + this.name + '_' + tf.id]); + ul.className = this.listCssClass; + + var tbl = this.headersTbl ? this.headersTbl : tf.tbl; + var headerIndex = this.headersTbl ? this.headersIndex : tf.getHeadersRowIndex(); + var headerRow = tbl.rows[headerIndex]; + + //Tick all option + if (this.enableTickAll) { + var li = _dom2.default.createCheckItem('col__' + tf.id, this.tickAllText, this.tickAllText); + _dom2.default.addClass(li, this.listItemCssClass); + ul.appendChild(li); + li.check.checked = !this.tickToHide; + + _event2.default.add(li.check, 'click', function () { + for (var h = 0; h < headerRow.cells.length; h++) { + var itm = _dom2.default.id('col_' + h + '_' + tf.id); + if (itm && li.check.checked !== itm.checked) { itm.click(); + itm.checked = li.check.checked; } } - } + }); } - /** - * Hide or show specified columns - * @param {Numner} colIndex Column index - * @param {Boolean} hide hide column if true or show if false - */ - - }, { - key: 'setHidden', - value: function setHidden(colIndex, hide) { - var tf = this.tf; - var tbl = tf.tbl; - - if (this.onBeforeColHidden && hide) { - this.onBeforeColHidden.call(null, this, colIndex); + for (var i = 0; i < headerRow.cells.length; i++) { + var cell = headerRow.cells[i]; + var cellText = this.headersText && this.headersText[i] ? this.headersText[i] : this._getHeaderText(cell); + var liElm = _dom2.default.createCheckItem('col_' + i + '_' + tf.id, cellText, cellText); + _dom2.default.addClass(liElm, this.listItemCssClass); + if (!this.tickToHide) { + _dom2.default.addClass(liElm, this.listSlcItemCssClass); } - if (this.onBeforeColDisplayed && !hide) { - this.onBeforeColDisplayed.call(null, this, colIndex); + ul.appendChild(liElm); + if (!this.tickToHide) { + liElm.check.checked = true; } - this._hideCells(tbl, colIndex, hide); - if (this.headersTbl) { - this._hideCells(this.headersTbl, colIndex, hide); - } - - var hiddenCols = this.hiddenCols; - var itemIndex = hiddenCols.indexOf(colIndex); - if (hide) { - if (itemIndex === -1) { - this.hiddenCols.push(colIndex); - } - } else { - if (itemIndex !== -1) { - this.hiddenCols.splice(itemIndex, 1); - } - } - - var gridLayout; - var headTbl; - var gridColElms; - if (this.onAfterColHidden && hide) { - //This event is fired just after a column is displayed for - //grid_layout support - //TODO: grid layout module should be responsible for those - //calculations - if (tf.gridLayout) { - gridLayout = tf.feature('gridLayout'); - headTbl = gridLayout.headTbl; - gridColElms = gridLayout.gridColElms; - var hiddenWidth = parseInt(gridColElms[colIndex].style.width, 10); - - var headTblW = parseInt(headTbl.style.width, 10); - headTbl.style.width = headTblW - hiddenWidth + 'px'; - tbl.style.width = headTbl.style.width; - } - this.onAfterColHidden.call(null, this, colIndex); - } - - if (this.onAfterColDisplayed && !hide) { - //This event is fired just after a column is displayed for - //grid_layout support - //TODO: grid layout module should be responsible for those - //calculations - if (tf.gridLayout) { - gridLayout = tf.feature('gridLayout'); - headTbl = gridLayout.headTbl; - gridColElms = gridLayout.gridColElms; - var width = parseInt(gridColElms[colIndex].style.width, 10); - headTbl.style.width = parseInt(headTbl.style.width, 10) + width + 'px'; - tf.tbl.style.width = headTbl.style.width; - } - this.onAfterColDisplayed.call(null, this, colIndex); - } + _event2.default.add(liElm.check, 'click', function (evt) { + var elm = _event2.default.target(evt); + var lbl = elm.parentNode; + _this2.checkItem(lbl); + }); } - /** - * Show specified column - * @param {Number} colIndex Column index - */ + //separator + var p = _dom2.default.create('p', ['align', 'center']); + var btn; + //Close link + if (!this.btnCloseHtml) { + btn = _dom2.default.create('a', ['href', 'javascript:;']); + btn.className = this.btnCloseCssClass; + btn.innerHTML = this.btnCloseText; + _event2.default.add(btn, 'click', function (evt) { + _this2.toggle(evt); + }); + p.appendChild(btn); + } else { + p.innerHTML = this.btnCloseHtml; + btn = p.firstChild; + _event2.default.add(btn, 'click', function (evt) { + _this2.toggle(evt); + }); + } - }, { - key: 'showCol', - value: function showCol(colIndex) { - if (colIndex === undefined || !this.isColHidden(colIndex)) { - return; - } - if (this.manager && this.contEl) { - var itm = _dom2.default.id('col_' + colIndex + '_' + this.tf.id); + container.appendChild(ul); + container.appendChild(p); + + this.btnEl.parentNode.insertBefore(container, this.btnEl); + this.contEl = container; + + if (this.atStart) { + var a = this.atStart; + for (var k = 0; k < a.length; k++) { + var itm = _dom2.default.id('col_' + a[k] + '_' + tf.id); if (itm) { itm.click(); } - } else { - this.setHidden(colIndex, false); + } + } + }; + + /** + * Hide or show specified columns + * @param {Numner} colIndex Column index + * @param {Boolean} hide hide column if true or show if false + */ + + + ColsVisibility.prototype.setHidden = function setHidden(colIndex, hide) { + var tf = this.tf; + var tbl = tf.tbl; + + if (this.onBeforeColHidden && hide) { + this.onBeforeColHidden.call(null, this, colIndex); + } + if (this.onBeforeColDisplayed && !hide) { + this.onBeforeColDisplayed.call(null, this, colIndex); + } + + this._hideCells(tbl, colIndex, hide); + if (this.headersTbl) { + this._hideCells(this.headersTbl, colIndex, hide); + } + + var hiddenCols = this.hiddenCols; + var itemIndex = hiddenCols.indexOf(colIndex); + if (hide) { + if (itemIndex === -1) { + this.hiddenCols.push(colIndex); + } + } else { + if (itemIndex !== -1) { + this.hiddenCols.splice(itemIndex, 1); } } - /** - * Hide specified column - * @param {Number} colIndex Column index - */ + var gridLayout; + var headTbl; + var gridColElms; + if (this.onAfterColHidden && hide) { + //This event is fired just after a column is displayed for + //grid_layout support + //TODO: grid layout module should be responsible for those + //calculations + if (tf.gridLayout) { + gridLayout = tf.feature('gridLayout'); + headTbl = gridLayout.headTbl; + gridColElms = gridLayout.gridColElms; + var hiddenWidth = parseInt(gridColElms[colIndex].style.width, 10); - }, { - key: 'hideCol', - value: function hideCol(colIndex) { - if (colIndex === undefined || this.isColHidden(colIndex)) { - return; - } - if (this.manager && this.contEl) { - var itm = _dom2.default.id('col_' + colIndex + '_' + this.tf.id); - if (itm) { - itm.click(); - } - } else { - this.setHidden(colIndex, true); + var headTblW = parseInt(headTbl.style.width, 10); + headTbl.style.width = headTblW - hiddenWidth + 'px'; + tbl.style.width = headTbl.style.width; } + this.onAfterColHidden.call(null, this, colIndex); } - /** - * Determine if specified column is hidden - * @param {Number} colIndex Column index - */ - - }, { - key: 'isColHidden', - value: function isColHidden(colIndex) { - if (this.hiddenCols.indexOf(colIndex) !== -1) { - return true; + if (this.onAfterColDisplayed && !hide) { + //This event is fired just after a column is displayed for + //grid_layout support + //TODO: grid layout module should be responsible for those + //calculations + if (tf.gridLayout) { + gridLayout = tf.feature('gridLayout'); + headTbl = gridLayout.headTbl; + gridColElms = gridLayout.gridColElms; + var width = parseInt(gridColElms[colIndex].style.width, 10); + headTbl.style.width = parseInt(headTbl.style.width, 10) + width + 'px'; + tf.tbl.style.width = headTbl.style.width; } - return false; + this.onAfterColDisplayed.call(null, this, colIndex); } + }; - /** - * Toggle visibility of specified column - * @param {Number} colIndex Column index - */ + /** + * Show specified column + * @param {Number} colIndex Column index + */ - }, { - key: 'toggleCol', - value: function toggleCol(colIndex) { - if (colIndex === undefined || this.isColHidden(colIndex)) { - this.showCol(colIndex); - } else { - this.hideCol(colIndex); - } + + ColsVisibility.prototype.showCol = function showCol(colIndex) { + if (colIndex === undefined || !this.isColHidden(colIndex)) { + return; } - - /** - * Returns the indexes of the columns currently hidden - * @return {Array} column indexes - */ - - }, { - key: 'getHiddenCols', - value: function getHiddenCols() { - return this.hiddenCols; + if (this.manager && this.contEl) { + var itm = _dom2.default.id('col_' + colIndex + '_' + this.tf.id); + if (itm) { + itm.click(); + } + } else { + this.setHidden(colIndex, false); } + }; - /** - * Remove the columns manager - */ + /** + * Hide specified column + * @param {Number} colIndex Column index + */ - }, { - key: 'destroy', - value: function destroy() { - if (!this.btnEl && !this.contEl) { - return; - } - if (_dom2.default.id(this.contElTgtId)) { - _dom2.default.id(this.contElTgtId).innerHTML = ''; - } else { - this.contEl.innerHTML = ''; - _dom2.default.remove(this.contEl); - this.contEl = null; - } - this.btnEl.innerHTML = ''; - _dom2.default.remove(this.btnEl); - this.btnEl = null; - this.initialized = false; + + ColsVisibility.prototype.hideCol = function hideCol(colIndex) { + if (colIndex === undefined || this.isColHidden(colIndex)) { + return; } - }, { - key: '_getHeaderText', - value: function _getHeaderText(cell) { - if (!cell.hasChildNodes) { - return ''; + if (this.manager && this.contEl) { + var itm = _dom2.default.id('col_' + colIndex + '_' + this.tf.id); + if (itm) { + itm.click(); } + } else { + this.setHidden(colIndex, true); + } + }; - for (var i = 0; i < cell.childNodes.length; i++) { - var n = cell.childNodes[i]; - if (n.nodeType === 3) { - return n.nodeValue; - } else if (n.nodeType === 1) { - if (n.id && n.id.indexOf('popUp') !== -1) { - continue; - } else { - return _dom2.default.getText(n); - } - } - continue; - } + /** + * Determine if specified column is hidden + * @param {Number} colIndex Column index + */ + + + ColsVisibility.prototype.isColHidden = function isColHidden(colIndex) { + if (this.hiddenCols.indexOf(colIndex) !== -1) { + return true; + } + return false; + }; + + /** + * Toggle visibility of specified column + * @param {Number} colIndex Column index + */ + + + ColsVisibility.prototype.toggleCol = function toggleCol(colIndex) { + if (colIndex === undefined || this.isColHidden(colIndex)) { + this.showCol(colIndex); + } else { + this.hideCol(colIndex); + } + }; + + /** + * Returns the indexes of the columns currently hidden + * @return {Array} column indexes + */ + + + ColsVisibility.prototype.getHiddenCols = function getHiddenCols() { + return this.hiddenCols; + }; + + /** + * Remove the columns manager + */ + + + ColsVisibility.prototype.destroy = function destroy() { + if (!this.btnEl && !this.contEl) { + return; + } + if (_dom2.default.id(this.contElTgtId)) { + _dom2.default.id(this.contElTgtId).innerHTML = ''; + } else { + this.contEl.innerHTML = ''; + _dom2.default.remove(this.contEl); + this.contEl = null; + } + this.btnEl.innerHTML = ''; + _dom2.default.remove(this.btnEl); + this.btnEl = null; + this.initialized = false; + }; + + ColsVisibility.prototype._getHeaderText = function _getHeaderText(cell) { + if (!cell.hasChildNodes) { return ''; } - }, { - key: '_hideCells', - value: function _hideCells(tbl, colIndex, hide) { - for (var i = 0; i < tbl.rows.length; i++) { - var row = tbl.rows[i]; - var cell = row.cells[colIndex]; - if (cell) { - cell.style.display = hide ? 'none' : ''; + + for (var i = 0; i < cell.childNodes.length; i++) { + var n = cell.childNodes[i]; + if (n.nodeType === 3) { + return n.nodeValue; + } else if (n.nodeType === 1) { + if (n.id && n.id.indexOf('popUp') !== -1) { + continue; + } else { + return _dom2.default.getText(n); } } + continue; } - }]); + return ''; + }; + + ColsVisibility.prototype._hideCells = function _hideCells(tbl, colIndex, hide) { + for (var i = 0; i < tbl.rows.length; i++) { + var row = tbl.rows[i]; + var cell = row.cells[colIndex]; + if (cell) { + cell.style.display = hide ? 'none' : ''; + } + } + }; return ColsVisibility; }(); @@ -1544,8 +1509,6 @@ webpackJsonp([1],{ value: true }); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _dom = __webpack_require__(2); var _dom2 = _interopRequireDefault(_dom); @@ -1634,121 +1597,115 @@ webpackJsonp([1],{ */ - _createClass(FiltersVisibility, [{ - key: 'init', - value: function init() { - if (this.initialized) { - return; - } - - this.buildUI(); - this.initialized = true; + FiltersVisibility.prototype.init = function init() { + if (this.initialized) { + return; } - /** - * Build UI elements - */ + this.buildUI(); + this.initialized = true; + }; - }, { - key: 'buildUI', - value: function buildUI() { - var _this = this; + /** + * Build UI elements + */ - var tf = this.tf; - var span = _dom2.default.create('span', ['id', this.prfx + tf.id]); - span.className = this.contCssClass; - //Container element (rdiv or custom element) - if (!this.targetId) { - tf.setToolbar(); - } - var targetEl = !this.targetId ? tf.rDiv : _dom2.default.id(this.targetId); + FiltersVisibility.prototype.buildUI = function buildUI() { + var _this = this; - if (!this.targetId) { - var firstChild = targetEl.firstChild; - firstChild.parentNode.insertBefore(span, firstChild); - } else { - targetEl.appendChild(span); - } + var tf = this.tf; + var span = _dom2.default.create('span', ['id', this.prfx + tf.id]); + span.className = this.contCssClass; - var btn = void 0; - if (!this.btnHtml) { - btn = _dom2.default.create('a', ['href', 'javascript:void(0);']); - btn.className = this.btnCssClass; - btn.title = this.btnText || this.defaultText; - btn.innerHTML = this.collapseBtnHtml; - span.appendChild(btn); - } else { - //Custom html - span.innerHTML = this.btnHtml; - btn = span.firstChild; - } + //Container element (rdiv or custom element) + if (!this.targetId) { + tf.setToolbar(); + } + var targetEl = !this.targetId ? tf.rDiv : _dom2.default.id(this.targetId); - _event2.default.add(btn, 'click', function () { - return _this.toggle(); - }); - - this.contEl = span; - this.btnEl = btn; - - if (!this.visibleAtStart) { - this.toggle(); - } + if (!this.targetId) { + var firstChild = targetEl.firstChild; + firstChild.parentNode.insertBefore(span, firstChild); + } else { + targetEl.appendChild(span); } - /** - * Toggle filters visibility - */ - - }, { - key: 'toggle', - value: function toggle() { - var tf = this.tf; - var tbl = tf.gridLayout ? tf.feature('gridLayout').headTbl : tf.tbl; - var fltRow = tbl.rows[this.filtersRowIndex]; - var fltRowDisplay = fltRow.style.display; - - if (this.onBeforeShow && fltRowDisplay !== '') { - this.onBeforeShow.call(this, this); - } - if (this.onBeforeHide && fltRowDisplay === '') { - this.onBeforeHide.call(null, this); - } - - fltRow.style.display = fltRowDisplay === '' ? 'none' : ''; - if (this.enableIcon && !this.btnHtml) { - this.btnEl.innerHTML = fltRowDisplay === '' ? this.expandBtnHtml : this.collapseBtnHtml; - } - - if (this.onAfterShow && fltRowDisplay !== '') { - this.onAfterShow.call(null, this); - } - if (this.onAfterHide && fltRowDisplay === '') { - this.onAfterHide.call(null, this); - } + var btn = void 0; + if (!this.btnHtml) { + btn = _dom2.default.create('a', ['href', 'javascript:void(0);']); + btn.className = this.btnCssClass; + btn.title = this.btnText || this.defaultText; + btn.innerHTML = this.collapseBtnHtml; + span.appendChild(btn); + } else { + //Custom html + span.innerHTML = this.btnHtml; + btn = span.firstChild; } - /** - * Destroy the UI - */ + _event2.default.add(btn, 'click', function () { + return _this.toggle(); + }); - }, { - key: 'destroy', - value: function destroy() { - if (!this.btnEl && !this.contEl) { - return; - } + this.contEl = span; + this.btnEl = btn; - this.btnEl.innerHTML = ''; - _dom2.default.remove(this.btnEl); - this.btnEl = null; - - this.contEl.innerHTML = ''; - _dom2.default.remove(this.contEl); - this.contEl = null; - this.initialized = false; + if (!this.visibleAtStart) { + this.toggle(); } - }]); + }; + + /** + * Toggle filters visibility + */ + + + FiltersVisibility.prototype.toggle = function toggle() { + var tf = this.tf; + var tbl = tf.gridLayout ? tf.feature('gridLayout').headTbl : tf.tbl; + var fltRow = tbl.rows[this.filtersRowIndex]; + var fltRowDisplay = fltRow.style.display; + + if (this.onBeforeShow && fltRowDisplay !== '') { + this.onBeforeShow.call(this, this); + } + if (this.onBeforeHide && fltRowDisplay === '') { + this.onBeforeHide.call(null, this); + } + + fltRow.style.display = fltRowDisplay === '' ? 'none' : ''; + if (this.enableIcon && !this.btnHtml) { + this.btnEl.innerHTML = fltRowDisplay === '' ? this.expandBtnHtml : this.collapseBtnHtml; + } + + if (this.onAfterShow && fltRowDisplay !== '') { + this.onAfterShow.call(null, this); + } + if (this.onAfterHide && fltRowDisplay === '') { + this.onAfterHide.call(null, this); + } + }; + + /** + * Destroy the UI + */ + + + FiltersVisibility.prototype.destroy = function destroy() { + if (!this.btnEl && !this.contEl) { + return; + } + + this.btnEl.innerHTML = ''; + _dom2.default.remove(this.btnEl); + this.btnEl = null; + + this.contEl.innerHTML = ''; + _dom2.default.remove(this.contEl); + this.contEl = null; + this.initialized = false; + }; return FiltersVisibility; }(); @@ -1766,8 +1723,6 @@ webpackJsonp([1],{ value: true }); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - var _types = __webpack_require__(4); var _types2 = _interopRequireDefault(_types); @@ -1835,332 +1790,324 @@ webpackJsonp([1],{ this.emitter = tf.emitter; } - _createClass(AdapterSortableTable, [{ - key: 'init', - value: function init() { - var tf = this.tf; - var adpt = this; + AdapterSortableTable.prototype.init = function init() { + var tf = this.tf; + var adpt = this; - // SortableTable class sanity check (sortabletable.js) - if (_types2.default.isUndef(SortableTable)) { - throw new Error('SortableTable class not found.'); - } - - this.overrideSortableTable(); - this.setSortTypes(); - - //Column sort at start - var sortColAtStart = adpt.sortColAtStart; - if (sortColAtStart) { - this.stt.sort(sortColAtStart[0], sortColAtStart[1]); - } - - if (this.onSortLoaded) { - this.onSortLoaded.call(null, tf, this); - } - - /*** SortableTable callbacks ***/ - this.stt.onbeforesort = function () { - if (adpt.onBeforeSort) { - adpt.onBeforeSort.call(null, tf, adpt.stt.sortColumn); - } - - /*** sort behaviour for paging ***/ - if (tf.paging) { - tf.feature('paging').disable(); - } - }; - - this.stt.onsort = function () { - adpt.sorted = true; - - //sort behaviour for paging - if (tf.paging) { - var paginator = tf.feature('paging'); - // recalculate valid rows index as sorting may have change it - tf.getValidRows(true); - paginator.enable(); - paginator.setPage(paginator.getPage()); - } - - if (adpt.onAfterSort) { - adpt.onAfterSort.call(null, tf, adpt.stt.sortColumn); - } - - adpt.emitter.emit('column-sorted', tf, adpt.stt.sortColumn); - }; - - this.initialized = true; + // SortableTable class sanity check (sortabletable.js) + if (_types2.default.isUndef(SortableTable)) { + throw new Error('SortableTable class not found.'); } + this.overrideSortableTable(); + this.setSortTypes(); + + //Column sort at start + var sortColAtStart = adpt.sortColAtStart; + if (sortColAtStart) { + this.stt.sort(sortColAtStart[0], sortColAtStart[1]); + } + + if (this.onSortLoaded) { + this.onSortLoaded.call(null, tf, this); + } + + /*** SortableTable callbacks ***/ + this.stt.onbeforesort = function () { + if (adpt.onBeforeSort) { + adpt.onBeforeSort.call(null, tf, adpt.stt.sortColumn); + } + + /*** sort behaviour for paging ***/ + if (tf.paging) { + tf.feature('paging').disable(); + } + }; + + this.stt.onsort = function () { + adpt.sorted = true; + + //sort behaviour for paging + if (tf.paging) { + var paginator = tf.feature('paging'); + // recalculate valid rows index as sorting may have change it + tf.getValidRows(true); + paginator.enable(); + paginator.setPage(paginator.getPage()); + } + + if (adpt.onAfterSort) { + adpt.onAfterSort.call(null, tf, adpt.stt.sortColumn); + } + + adpt.emitter.emit('column-sorted', tf, adpt.stt.sortColumn); + }; + + this.initialized = true; + }; + + /** + * Sort specified column + * @param {Number} colIdx Column index + * @param {Boolean} desc Optional: descending manner + */ + + + AdapterSortableTable.prototype.sortByColumnIndex = function sortByColumnIndex(colIdx, desc) { + this.stt.sort(colIdx, desc); + }; + + AdapterSortableTable.prototype.overrideSortableTable = function overrideSortableTable() { + var adpt = this, + tf = this.tf; + /** - * Sort specified column - * @param {Number} colIdx Column index - * @param {Boolean} desc Optional: descending manner + * Overrides headerOnclick method in order to handle th event + * @param {Object} e [description] */ + SortableTable.prototype.headerOnclick = function (evt) { + if (!adpt.initialized) { + return; + } - }, { - key: 'sortByColumnIndex', - value: function sortByColumnIndex(colIdx, desc) { - this.stt.sort(colIdx, desc); - } - }, { - key: 'overrideSortableTable', - value: function overrideSortableTable() { - var adpt = this, - tf = this.tf; + // find Header element + var el = evt.target || evt.srcElement; - /** - * Overrides headerOnclick method in order to handle th event - * @param {Object} e [description] - */ - SortableTable.prototype.headerOnclick = function (evt) { - if (!adpt.initialized) { + while (el.tagName !== 'TD' && el.tagName !== 'TH') { + el = el.parentNode; + } + + this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex); + }; + + /** + * Overrides getCellIndex IE returns wrong cellIndex when columns are + * hidden + * @param {Object} oTd TD element + * @return {Number} Cell index + */ + SortableTable.getCellIndex = function (oTd) { + var cells = oTd.parentNode.cells, + l = cells.length, + i = void 0; + for (i = 0; cells[i] != oTd && i < l; i++) {} + return i; + }; + + /** + * Overrides initHeader in order to handle filters row position + * @param {Array} oSortTypes + */ + SortableTable.prototype.initHeader = function (oSortTypes) { + var stt = this; + if (!stt.tHead) { + if (tf.gridLayout) { + stt.tHead = tf.feature('gridLayout').headTbl.tHead; + } else { return; } + } - // find Header element - var el = evt.target || evt.srcElement; + stt.headersRow = tf.headersRow; + var cells = stt.tHead.rows[stt.headersRow].cells; + stt.sortTypes = oSortTypes || []; + var l = cells.length; + var img = void 0, + c = void 0; - while (el.tagName !== 'TD' && el.tagName !== 'TH') { - el = el.parentNode; - } - - this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex); - }; - - /** - * Overrides getCellIndex IE returns wrong cellIndex when columns are - * hidden - * @param {Object} oTd TD element - * @return {Number} Cell index - */ - SortableTable.getCellIndex = function (oTd) { - var cells = oTd.parentNode.cells, - l = cells.length, - i = void 0; - for (i = 0; cells[i] != oTd && i < l; i++) {} - return i; - }; - - /** - * Overrides initHeader in order to handle filters row position - * @param {Array} oSortTypes - */ - SortableTable.prototype.initHeader = function (oSortTypes) { - var stt = this; - if (!stt.tHead) { - if (tf.gridLayout) { - stt.tHead = tf.feature('gridLayout').headTbl.tHead; - } else { - return; + for (var i = 0; i < l; i++) { + c = cells[i]; + if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None') { + c.style.cursor = 'pointer'; + img = _dom2.default.create('img', ['src', adpt.imgPath + adpt.imgBlank]); + c.appendChild(img); + if (stt.sortTypes[i] !== null) { + c.setAttribute('_sortType', stt.sortTypes[i]); } + _event2.default.add(c, 'click', stt._headerOnclick); + } else { + c.setAttribute('_sortType', oSortTypes[i]); + c._sortType = 'None'; } + } + stt.updateHeaderArrows(); + }; - stt.headersRow = tf.headersRow; - var cells = stt.tHead.rows[stt.headersRow].cells; - stt.sortTypes = oSortTypes || []; - var l = cells.length; - var img = void 0, - c = void 0; + /** + * Overrides updateHeaderArrows in order to handle arrows indicators + */ + SortableTable.prototype.updateHeaderArrows = function () { + var stt = this; + var cells = void 0, + l = void 0, + img = void 0; - for (var i = 0; i < l; i++) { - c = cells[i]; - if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None') { - c.style.cursor = 'pointer'; + // external headers + if (adpt.asyncSort && adpt.triggerIds.length > 0) { + var triggers = adpt.triggerIds; + cells = []; + l = triggers.length; + for (var j = 0; j < triggers.length; j++) { + cells.push(_dom2.default.id(triggers[j])); + } + } else { + if (!this.tHead) { + return; + } + cells = stt.tHead.rows[stt.headersRow].cells; + l = cells.length; + } + for (var i = 0; i < l; i++) { + var cellAttr = cells[i].getAttribute('_sortType'); + if (cellAttr !== null && cellAttr !== 'None') { + img = cells[i].lastChild || cells[i]; + if (img.nodeName.toLowerCase() !== 'img') { img = _dom2.default.create('img', ['src', adpt.imgPath + adpt.imgBlank]); - c.appendChild(img); - if (stt.sortTypes[i] !== null) { - c.setAttribute('_sortType', stt.sortTypes[i]); - } - _event2.default.add(c, 'click', stt._headerOnclick); + cells[i].appendChild(img); + } + if (i === stt.sortColumn) { + img.className = adpt.imgClassName + ' ' + (this.descending ? adpt.imgDescClassName : adpt.imgAscClassName); } else { - c.setAttribute('_sortType', oSortTypes[i]); - c._sortType = 'None'; + img.className = adpt.imgClassName; } } - stt.updateHeaderArrows(); - }; - - /** - * Overrides updateHeaderArrows in order to handle arrows indicators - */ - SortableTable.prototype.updateHeaderArrows = function () { - var stt = this; - var cells = void 0, - l = void 0, - img = void 0; - - // external headers - if (adpt.asyncSort && adpt.triggerIds.length > 0) { - var triggers = adpt.triggerIds; - cells = []; - l = triggers.length; - for (var j = 0; j < triggers.length; j++) { - cells.push(_dom2.default.id(triggers[j])); - } - } else { - if (!this.tHead) { - return; - } - cells = stt.tHead.rows[stt.headersRow].cells; - l = cells.length; - } - for (var i = 0; i < l; i++) { - var cellAttr = cells[i].getAttribute('_sortType'); - if (cellAttr !== null && cellAttr !== 'None') { - img = cells[i].lastChild || cells[i]; - if (img.nodeName.toLowerCase() !== 'img') { - img = _dom2.default.create('img', ['src', adpt.imgPath + adpt.imgBlank]); - cells[i].appendChild(img); - } - if (i === stt.sortColumn) { - img.className = adpt.imgClassName + ' ' + (this.descending ? adpt.imgDescClassName : adpt.imgAscClassName); - } else { - img.className = adpt.imgClassName; - } - } - } - }; - - /** - * Overrides getRowValue for custom key value feature - * @param {Object} oRow Row element - * @param {String} sType - * @param {Number} nColumn - * @return {String} - */ - SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) { - var stt = this; - // if we have defined a custom getRowValue use that - var sortTypeInfo = stt._sortTypeInfo[sType]; - if (sortTypeInfo && sortTypeInfo.getRowValue) { - return sortTypeInfo.getRowValue(oRow, nColumn); - } - var c = oRow.cells[nColumn]; - var s = SortableTable.getInnerText(c); - return stt.getValueFromString(s, sType); - }; - - /** - * Overrides getInnerText in order to avoid Firefox unexpected sorting - * behaviour with untrimmed text elements - * @param {Object} oNode DOM element - * @return {String} DOM element inner text - */ - SortableTable.getInnerText = function (oNode) { - if (!oNode) { - return; - } - if (oNode.getAttribute(adpt.customKey)) { - return oNode.getAttribute(adpt.customKey); - } else { - return _dom2.default.getText(oNode); - } - }; - } - }, { - key: 'addSortType', - value: function addSortType() { - var args = arguments; - SortableTable.prototype.addSortType(args[0], args[1], args[2], args[3]); - } - }, { - key: 'setSortTypes', - value: function setSortTypes() { - var _this = this; - - var tf = this.tf, - sortTypes = this.sortTypes, - _sortTypes = []; - - for (var i = 0; i < tf.nbCells; i++) { - var colType = void 0; - - if (sortTypes[i]) { - colType = sortTypes[i].toLowerCase(); - if (colType === 'none') { - colType = 'None'; - } - } else { - // resolve column types - if (tf.hasColNbFormat && tf.colNbFormat[i] !== null) { - colType = tf.colNbFormat[i].toLowerCase(); - } else if (tf.hasColDateType && tf.colDateType[i] !== null) { - colType = tf.colDateType[i].toLowerCase() + 'date'; - } else { - colType = 'String'; - } - } - _sortTypes.push(colType); } - - //Public TF method to add sort type - - //Custom sort types - this.addSortType('number', Number); - this.addSortType('caseinsensitivestring', SortableTable.toUpperCase); - this.addSortType('date', SortableTable.toDate); - this.addSortType('string'); - this.addSortType('us', usNumberConverter); - this.addSortType('eu', euNumberConverter); - this.addSortType('dmydate', dmyDateConverter); - this.addSortType('ymddate', ymdDateConverter); - this.addSortType('mdydate', mdyDateConverter); - this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter); - this.addSortType('ipaddress', ipAddress, sortIP); - - this.stt = new SortableTable(tf.tbl, _sortTypes); - - /*** external table headers adapter ***/ - if (this.asyncSort && this.triggerIds.length > 0) { - (function () { - var triggers = _this.triggerIds; - for (var j = 0; j < triggers.length; j++) { - if (triggers[j] === null) { - continue; - } - var trigger = _dom2.default.id(triggers[j]); - if (trigger) { - trigger.style.cursor = 'pointer'; - - _event2.default.add(trigger, 'click', function (evt) { - var elm = evt.target; - if (!_this.tf.sort) { - return; - } - _this.stt.asyncSort(triggers.indexOf(elm.id)); - }); - trigger.setAttribute('_sortType', _sortTypes[j]); - } - } - })(); - } - } + }; /** - * Destroy sort + * Overrides getRowValue for custom key value feature + * @param {Object} oRow Row element + * @param {String} sType + * @param {Number} nColumn + * @return {String} */ + SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) { + var stt = this; + // if we have defined a custom getRowValue use that + var sortTypeInfo = stt._sortTypeInfo[sType]; + if (sortTypeInfo && sortTypeInfo.getRowValue) { + return sortTypeInfo.getRowValue(oRow, nColumn); + } + var c = oRow.cells[nColumn]; + var s = SortableTable.getInnerText(c); + return stt.getValueFromString(s, sType); + }; - }, { - key: 'destroy', - value: function destroy() { - var tf = this.tf; - this.sorted = false; - this.initialized = false; - this.stt.destroy(); + /** + * Overrides getInnerText in order to avoid Firefox unexpected sorting + * behaviour with untrimmed text elements + * @param {Object} oNode DOM element + * @return {String} DOM element inner text + */ + SortableTable.getInnerText = function (oNode) { + if (!oNode) { + return; + } + if (oNode.getAttribute(adpt.customKey)) { + return oNode.getAttribute(adpt.customKey); + } else { + return _dom2.default.getText(oNode); + } + }; + }; - var ids = tf.getFiltersId(); - for (var idx = 0; idx < ids.length; idx++) { - var header = tf.getHeaderElement(idx); - var img = _dom2.default.tag(header, 'img'); + AdapterSortableTable.prototype.addSortType = function addSortType() { + var args = arguments; + SortableTable.prototype.addSortType(args[0], args[1], args[2], args[3]); + }; - if (img.length === 1) { - header.removeChild(img[0]); + AdapterSortableTable.prototype.setSortTypes = function setSortTypes() { + var _this = this; + + var tf = this.tf, + sortTypes = this.sortTypes, + _sortTypes = []; + + for (var i = 0; i < tf.nbCells; i++) { + var colType = void 0; + + if (sortTypes[i]) { + colType = sortTypes[i].toLowerCase(); + if (colType === 'none') { + colType = 'None'; + } + } else { + // resolve column types + if (tf.hasColNbFormat && tf.colNbFormat[i] !== null) { + colType = tf.colNbFormat[i].toLowerCase(); + } else if (tf.hasColDateType && tf.colDateType[i] !== null) { + colType = tf.colDateType[i].toLowerCase() + 'date'; + } else { + colType = 'String'; } } + _sortTypes.push(colType); } - }]); + + //Public TF method to add sort type + + //Custom sort types + this.addSortType('number', Number); + this.addSortType('caseinsensitivestring', SortableTable.toUpperCase); + this.addSortType('date', SortableTable.toDate); + this.addSortType('string'); + this.addSortType('us', usNumberConverter); + this.addSortType('eu', euNumberConverter); + this.addSortType('dmydate', dmyDateConverter); + this.addSortType('ymddate', ymdDateConverter); + this.addSortType('mdydate', mdyDateConverter); + this.addSortType('ddmmmyyyydate', ddmmmyyyyDateConverter); + this.addSortType('ipaddress', ipAddress, sortIP); + + this.stt = new SortableTable(tf.tbl, _sortTypes); + + /*** external table headers adapter ***/ + if (this.asyncSort && this.triggerIds.length > 0) { + (function () { + var triggers = _this.triggerIds; + for (var j = 0; j < triggers.length; j++) { + if (triggers[j] === null) { + continue; + } + var trigger = _dom2.default.id(triggers[j]); + if (trigger) { + trigger.style.cursor = 'pointer'; + + _event2.default.add(trigger, 'click', function (evt) { + var elm = evt.target; + if (!_this.tf.sort) { + return; + } + _this.stt.asyncSort(triggers.indexOf(elm.id)); + }); + trigger.setAttribute('_sortType', _sortTypes[j]); + } + } + })(); + } + }; + + /** + * Destroy sort + */ + + + AdapterSortableTable.prototype.destroy = function destroy() { + var tf = this.tf; + this.sorted = false; + this.initialized = false; + this.stt.destroy(); + + var ids = tf.getFiltersId(); + for (var idx = 0; idx < ids.length; idx++) { + var header = tf.getHeaderElement(idx); + var img = _dom2.default.tag(header, 'img'); + + if (img.length === 1) { + header.removeChild(img[0]); + } + } + }; return AdapterSortableTable; }(); diff --git a/src/modules/feature.js b/src/modules/feature.js index b8c9f6fa..9c7fa464 100644 --- a/src/modules/feature.js +++ b/src/modules/feature.js @@ -5,7 +5,7 @@ export class Feature { constructor(tf, feature) { this.tf = tf; this.feature = feature; - this.enabled = tf[feature]; + this.enabled = Boolean(tf[feature]); this.config = tf.config(); this.emitter = tf.emitter; this.initialized = false; diff --git a/src/modules/state.js b/src/modules/state.js index 7bde5671..3a24a785 100644 --- a/src/modules/state.js +++ b/src/modules/state.js @@ -3,6 +3,15 @@ import {Hash} from './hash'; import Str from '../string'; import Types from '../types'; + +/** + * Reflects the state of features to be persisted via hash, localStorage or + * cookie + * + * @export + * @class State + * @extends {Feature} + */ export class State extends Feature { /** @@ -30,6 +39,9 @@ export class State extends Feature { this.pageLengthKey = 'page_length'; } + /** + * Initialize features state + */ init() { if (this.initialized) { return; @@ -48,6 +60,10 @@ export class State extends Feature { this.initialized = true; } + + /** + * Update state field based on current features state + */ update() { if(!this.isEnabled()){ return; @@ -60,7 +76,7 @@ export class State extends Feature { filterValues.forEach((val, idx) => { let key = `${this.prfxCol}${idx}`; - if (Str.isEmpty(val)) { + if (Types.isString(val) && Str.isEmpty(val)) { if (this.state.hasOwnProperty(key)) { this.state[key] = undefined; } @@ -91,23 +107,40 @@ export class State extends Feature { this.emitter.emit('state-changed', tf, this.state); } + /** + * Refresh page number field on page number change + * + * @param pageNb Current page number + */ updatePage(pageNb){ this.pageNb = pageNb; this.update(); } + /** + * Refresh page length field on page length change + * + * @param pageLength Current page length value + */ updatePageLength(pageLength){ this.pageLength = pageLength; this.update(); } + /** + * Override state field + * + * @param state State object + */ override(state){ this.state = state; } + /** + * Apply current features state + */ sync() { let state = this.state; - console.log('sync', state); let tf = this.tf; if (this.persistFilters) { @@ -124,7 +157,6 @@ export class State extends Feature { if (this.persistPageNumber) { let pageNumber = state[this.pageNbKey]; - console.log('pageNumber',pageNumber); this.emitter.emit('change-page', this.tf, pageNumber); } @@ -132,15 +164,18 @@ export class State extends Feature { let pageLength = state[this.pageLengthKey]; this.emitter.emit('change-page-results', this.tf, pageLength); } - - this.emitter.emit('state-synced', tf, this.state); } + /** + * Destroy State instance + */ destroy() { if (!this.initialized) { return; } + this.state = {}; + this.emitter.off(['after-filtering'], () => this.update()); this.emitter.off(['after-page-change'], (tf, pageNb) => this.updatePage(pageNb)); diff --git a/src/tablefilter.js b/src/tablefilter.js index aed506ad..039f63b2 100644 --- a/src/tablefilter.js +++ b/src/tablefilter.js @@ -337,7 +337,7 @@ export class TableFilter { Boolean(f.no_results_message); // stateful - this.hasState = Types.isObj(f.state) || Boolean(f.state); + this.state = Types.isObj(f.state) || Boolean(f.state); /*** data types ***/ //defines default date type (european DMY) @@ -492,7 +492,9 @@ export class TableFilter { this.import(this.stylesheetId, this.stylesheet, null, 'link'); //loads theme - if(this.hasThemes){ this.loadThemes(); } + if(this.hasThemes){ + this.loadThemes(); + } // Instantiate help feature and initialise only if set true if(!Mod.help){ @@ -502,7 +504,7 @@ export class TableFilter { Mod.help.init(); } - if(this.hasState){ + if(this.state){ if(!Mod.state){ Mod.state = new State(this); } diff --git a/src/types.js b/src/types.js index 504241f0..ee17ff46 100644 --- a/src/types.js +++ b/src/types.js @@ -42,6 +42,15 @@ export default { return (obj && obj.constructor == Array); }, + /** + * Check argument is a string + * @param {String} val Value + * @returns {Boolean} + */ + isString(val){ + return Object.prototype.toString.call(val) === '[object String]'; + }, + /** * Determine if argument is undefined * @param {Any} o diff --git a/static/templates/grouped-headers.html b/static/templates/grouped-headers.html index 8e482570..43c1866f 100644 --- a/static/templates/grouped-headers.html +++ b/static/templates/grouped-headers.html @@ -47,7 +47,13 @@ var tfConfig = { ], filters_row_index: 3, headers_row_index: 2, - remember_grid_values: true, + // remember_grid_values: true, + state: { + type: ['hash'], + filters: true, + page_number: true, + page_length: true + }, highlight_keywords: true, alternate_rows: true, rows_counter: true,