From 310247bd48f547d0da7b1bc38b156e3010496335 Mon Sep 17 00:00:00 2001 From: Max Guglielmi Date: Sat, 21 Nov 2015 14:41:40 +1100 Subject: [PATCH] Implemented Feature base class for popupFilters --- demos/demo.html | 3 +- dist/tablefilter/style/colsVisibility.css | 2 +- dist/tablefilter/style/filtersVisibility.css | 2 +- dist/tablefilter/style/tablefilter.css | 2 +- .../style/themes/default/default.css | 2 +- .../style/themes/mytheme/mytheme.css | 2 +- .../style/themes/skyblue/skyblue.css | 2 +- dist/tablefilter/tablefilter.js | 200 +++++++++++------- src/modules/feature.js | 2 - src/modules/gridLayout.js | 2 +- src/modules/help.js | 26 ++- src/modules/loader.js | 41 ++-- src/modules/paging.js | 6 +- src/modules/popupFilter.js | 31 ++- src/modules/rowsCounter.js | 2 - src/tablefilter.js | 41 ++-- static/templates/demo.html | 3 +- test/test-help.js | 47 ++++ test/test-highlight-keywords.js | 19 +- test/test-loader.js | 60 +++++- test/test-popup-filter.js | 21 ++ 21 files changed, 375 insertions(+), 141 deletions(-) diff --git a/demos/demo.html b/demos/demo.html index 2fa24001..8fa5823a 100644 --- a/demos/demo.html +++ b/demos/demo.html @@ -13029,7 +13029,8 @@ '70px', '70px', '70px', '70px', '60px', '60px' ], - extensions:[{ name: 'sort' }] + extensions:[{ name: 'sort' }], + popup_filters: true }; var tf = new TableFilter('demo', filtersConfig); diff --git a/dist/tablefilter/style/colsVisibility.css b/dist/tablefilter/style/colsVisibility.css index 626314a1..373d7828 100644 --- a/dist/tablefilter/style/colsVisibility.css +++ b/dist/tablefilter/style/colsVisibility.css @@ -1,6 +1,6 @@ /** * tablefilter v0.0.11 by Max Guglielmi - * build date: 2015-11-16T10:31:33.931Z + * build date: 2015-11-21T00:51:06.757Z * 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 6426904b..22fb6c71 100644 --- a/dist/tablefilter/style/filtersVisibility.css +++ b/dist/tablefilter/style/filtersVisibility.css @@ -1,6 +1,6 @@ /** * tablefilter v0.0.11 by Max Guglielmi - * build date: 2015-11-16T10:31:33.931Z + * build date: 2015-11-21T00:51:06.757Z * 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 7ac24de6..81264e7d 100644 --- a/dist/tablefilter/style/tablefilter.css +++ b/dist/tablefilter/style/tablefilter.css @@ -1,6 +1,6 @@ /** * tablefilter v0.0.11 by Max Guglielmi - * build date: 2015-11-16T10:31:33.931Z + * build date: 2015-11-21T00:51:06.757Z * 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 4da88a3f..866db16b 100644 --- a/dist/tablefilter/style/themes/default/default.css +++ b/dist/tablefilter/style/themes/default/default.css @@ -1,6 +1,6 @@ /** * tablefilter v0.0.11 by Max Guglielmi - * build date: 2015-11-16T10:31:33.931Z + * build date: 2015-11-21T00:51:06.757Z * MIT License */ table.TF{border-left:1px solid #ccc !important;border-top:none !important;border-right:none !important;border-bottom:none !important;}table.TF th{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;color:#333 !important}table.TF td{border-bottom:1px dotted #999 !important;padding:5px !important}.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} \ 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 07f4da2f..3823f44a 100644 --- a/dist/tablefilter/style/themes/mytheme/mytheme.css +++ b/dist/tablefilter/style/themes/mytheme/mytheme.css @@ -1,6 +1,6 @@ /** * tablefilter v0.0.11 by Max Guglielmi - * build date: 2015-11-16T10:31:33.931Z + * build date: 2015-11-21T00:51:06.757Z * MIT License */ table.TF{border-left:1px dotted #81963b !important;border-top:none !important;border-right:0 !important;border-bottom:none !important;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;color:#fff !important}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px !important}.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} \ 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 d5b10e13..3c6fee2a 100644 --- a/dist/tablefilter/style/themes/skyblue/skyblue.css +++ b/dist/tablefilter/style/themes/skyblue/skyblue.css @@ -1,6 +1,6 @@ /** * tablefilter v0.0.11 by Max Guglielmi - * build date: 2015-11-16T10:31:33.931Z + * build date: 2015-11-21T00:51:06.757Z * 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 289f0f7f..2ce7fb09 100644 --- a/dist/tablefilter/tablefilter.js +++ b/dist/tablefilter/tablefilter.js @@ -388,9 +388,9 @@ return /******/ (function(modules) { // webpackBootstrap //id of toolbar container element this.toolBarTgtId = f.toolbar_target_id || null; //enables/disables help div - this.helpInstructions = _types2['default'].isUndef(f.help_instructions) ? undefined : Boolean(f.help_instructions); + this.help = _types2['default'].isUndef(f.help_instructions) ? undefined : Boolean(f.help_instructions); //popup filters - this.popUpFilters = Boolean(f.popup_filters); + this.popupFilters = Boolean(f.popup_filters); //active columns color this.markActiveColumns = Boolean(f.mark_active_columns); //defines css class for active column header @@ -687,7 +687,7 @@ return /******/ (function(modules) { // webpackBootstrap var elm = _event2['default'].target(_ev); this.activeFilterId = elm.getAttribute('id'); this.activeFlt = _dom2['default'].id(this.activeFilterId); - if (this.popUpFilters) { + if (this.popupFilters) { _event2['default'].cancel(_ev); _event2['default'].stop(_ev); } @@ -715,7 +715,7 @@ return /******/ (function(modules) { // webpackBootstrap var ct = elm.getAttribute('ct'); this.Mod.dropdown._build(ct); } - if (this.popUpFilters) { + if (this.popupFilters) { _event2['default'].cancel(_ev); _event2['default'].stop(_ev); } @@ -726,7 +726,7 @@ return /******/ (function(modules) { // webpackBootstrap return; } var _ev = e || global.event; - if (this.popUpFilters) { + if (this.popupFilters) { _event2['default'].stop(_ev); } if (this.onSlcChange) { @@ -769,7 +769,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.gridLayout) { this.refRow = this.startRow === null ? 0 : this.startRow; } - if (this.popUpFilters && (this.filtersRowIndex === 0 && this.headersRow === 1 || this.gridLayout)) { + if (this.popupFilters && (this.filtersRowIndex === 0 && this.headersRow === 1 || this.gridLayout)) { this.headersRow = 0; } @@ -797,6 +797,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.loader) { if (!Mod.loader) { Mod.loader = new _modulesLoader.Loader(this); + Mod.loader.init(); } } @@ -804,7 +805,7 @@ return /******/ (function(modules) { // webpackBootstrap Mod.highlightKeyword = new _modulesHighlightKeywords.HighlightKeyword(this); } - if (this.popUpFilters) { + if (this.popupFilters) { if (!Mod.popupFilter) { Mod.popupFilter = new _modulesPopupFilter.PopupFilter(this); } @@ -831,16 +832,16 @@ return /******/ (function(modules) { // webpackBootstrap fltrow = this.tbl.insertRow(this.filtersRowIndex); } - if (this.headersRow > 1 && this.filtersRowIndex <= this.headersRow && !this.popUpFilters) { + if (this.headersRow > 1 && this.filtersRowIndex <= this.headersRow && !this.popupFilters) { this.headersRow++; } - if (this.popUpFilters) { + if (this.popupFilters) { this.headersRow++; } fltrow.className = this.fltsRowCssClass; - if (this.isExternalFlt || this.popUpFilters) { + if (this.isExternalFlt || this.popupFilters) { fltrow.style.display = 'none'; } } @@ -852,7 +853,7 @@ return /******/ (function(modules) { // webpackBootstrap for (var i = 0; i < n; i++) { // this loop adds filters - if (this.popUpFilters) { + if (this.popupFilters) { Mod.popupFilter.build(i); } @@ -1021,7 +1022,7 @@ return /******/ (function(modules) { // webpackBootstrap Mod.clearButton = new _modulesClearButton.ClearButton(this); Mod.clearButton.init(); } - if (this.helpInstructions) { + if (this.help) { if (!Mod.help) { Mod.help = new _modulesHelp.Help(this); } @@ -1320,7 +1321,7 @@ return /******/ (function(modules) { // webpackBootstrap var rows = this.tbl.rows, Mod = this.Mod; - if (this.isExternalFlt && !this.popUpFilters) { + if (this.isExternalFlt && !this.popupFilters) { this.removeExternalFlts(); } if (this.infDiv) { @@ -1423,12 +1424,12 @@ return /******/ (function(modules) { // webpackBootstrap // Enable help instructions by default if topbar is generated and not // explicitely set to false - if (_types2['default'].isUndef(this.helpInstructions)) { + if (_types2['default'].isUndef(this.help)) { if (!this.Mod.help) { this.Mod.help = new _modulesHelp.Help(this); } this.Mod.help.init(); - this.helpInstructions = true; + this.help = true; } } @@ -1662,7 +1663,7 @@ return /******/ (function(modules) { // webpackBootstrap Mod.highlightKeyword.unhighlightAll(); } //removes popup filters active icons - if (this.popUpFilters) { + if (this.popupFilters) { Mod.popupFilter.buildIcons(); } //removes active column header class @@ -1940,7 +1941,7 @@ return /******/ (function(modules) { // webpackBootstrap if (this.singleSearchFlt && occurence[j]) { singleFltRowValid = true; } - if (this.popUpFilters) { + if (this.popupFilters) { Mod.popupFilter.buildIcon(j, true); } if (this.markActiveColumns) { @@ -2034,7 +2035,7 @@ return /******/ (function(modules) { // webpackBootstrap Mod.rowsCounter.refresh(this.nbVisibleRows); } - if (this.popUpFilters) { + if (this.popupFilters) { Mod.popupFilter.closeAll(); } } @@ -2692,9 +2693,9 @@ return /******/ (function(modules) { // webpackBootstrap this.nbVisibleRows = this.nbFilterableRows; this.nbRows = rows.length; - if (this.popUpFilters) { + if (this.popupFilters) { this.headersRow++; - Mod.popupFilter.buildAll(); + Mod.popupFilter.reset(); } if (!this.gridLayout) { @@ -4095,7 +4096,7 @@ return /******/ (function(modules) { // webpackBootstrap } }; - if (tf.popUpFilters) { + if (tf.popupFilters) { filtersRow.style.display = 'none'; } @@ -4190,13 +4191,11 @@ return /******/ (function(modules) { // webpackBootstrap key: 'enable', value: function enable() { this.enabled = true; - // this.tf[this.feature] = this.enabled; } }, { key: 'disable', value: function disable() { this.enabled = false; - // this.tf[this.feature] = this.enabled; } }, { key: 'isEnabled', @@ -4222,10 +4221,16 @@ return /******/ (function(modules) { // webpackBootstrap 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 _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + 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; } + + var _feature = __webpack_require__(11); + var _dom = __webpack_require__(2); var _dom2 = _interopRequireDefault(_dom); @@ -4236,7 +4241,8 @@ return /******/ (function(modules) { // webpackBootstrap var global = window; - var Loader = (function () { + var Loader = (function (_Feature) { + _inherits(Loader, _Feature); /** * Loading message/spinner @@ -4246,8 +4252,11 @@ return /******/ (function(modules) { // webpackBootstrap function Loader(tf) { _classCallCheck(this, Loader); + _get(Object.getPrototypeOf(Loader.prototype), 'constructor', this).call(this, tf, 'loader'); + // TableFilter configuration - var f = tf.config(); + var f = this.config; + //id of container element this.loaderTgtId = f.loader_target_id || null; //div containing loader @@ -4266,32 +4275,42 @@ return /******/ (function(modules) { // webpackBootstrap this.onHideLoader = _types2['default'].isFn(f.on_hide_loader) ? f.on_hide_loader : null; //loader div this.prfxLoader = 'load_'; - - this.tf = tf; - - 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 = _dom2['default'].id(this.prfxLoader + tf.id); - if (!this.loaderHtml) { - this.loaderDiv.appendChild(_dom2['default'].text(this.loaderText)); - } else { - this.loaderDiv.innerHTML = this.loaderHtml; - } } _createClass(Loader, [{ + key: 'init', + value: function init() { + if (this.initialized) { + return; + } + + var tf = this.tf; + + 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'); + this.initialized = true; + } + }, { key: 'show', value: function show(p) { var _this = this; - if (!this.tf.loader || !this.loaderDiv || this.loaderDiv.style.display === p) { + if (!this.isEnabled() || this.loaderDiv.style.display === p) { return; } @@ -4314,22 +4333,20 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'destroy', value: function destroy() { - if (!this.loaderDiv) { + if (!this.initialized) { return; } - // var tf = this.tf, - // targetEl = !this.loaderTgtId ? - // (tf.gridLayout ? - // tf.feature('gridLayout').tblCont : tf.tbl.parentNode) : - // Dom.id(this.loaderTgtId); - // targetEl.removeChild(this.loaderDiv); + this.loaderDiv.parentNode.removeChild(this.loaderDiv); this.loaderDiv = null; + + this.disable(); + this.initialized = false; } }]); return Loader; - })(); + })(_feature.Feature); exports.Loader = Loader; @@ -4491,10 +4508,16 @@ return /******/ (function(modules) { // webpackBootstrap 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 _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + 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; } + + var _feature = __webpack_require__(11); + var _types = __webpack_require__(5); var _types2 = _interopRequireDefault(_types); @@ -4507,7 +4530,8 @@ return /******/ (function(modules) { // webpackBootstrap var _event2 = _interopRequireDefault(_event); - var PopupFilter = (function () { + var PopupFilter = (function (_Feature) { + _inherits(PopupFilter, _Feature); /** * Pop-up filter component @@ -4517,8 +4541,10 @@ return /******/ (function(modules) { // webpackBootstrap function PopupFilter(tf) { _classCallCheck(this, PopupFilter); + _get(Object.getPrototypeOf(PopupFilter.prototype), 'constructor', this).call(this, tf, 'popupFilters'); + // Configuration object - var f = tf.config(); + var f = this.config; // Enable external filters behaviour tf.isExternalFlt = true; @@ -4552,8 +4578,6 @@ return /******/ (function(modules) { // webpackBootstrap this.prfxPopUpSpan = 'popUpSpan_'; //id prefix for pop-up div containing filter this.prfxPopUpDiv = 'popUpDiv_'; - - this.tf = tf; } _createClass(PopupFilter, [{ @@ -4584,6 +4608,10 @@ return /******/ (function(modules) { // webpackBootstrap value: function init() { var _this = this; + if (this.initialized) { + return; + } + var tf = this.tf; for (var i = 0; i < tf.nbCells; i++) { if (tf.getFilterType(i) === tf.fltTypeNone) { @@ -4599,6 +4627,19 @@ return /******/ (function(modules) { // webpackBootstrap this.popUpFltSpans[i] = popUpSpan; this.popUpFltImgs[i] = popUpSpan.firstChild; } + + this.initialized = true; + } + + /** + * Reset previously destroyed feature + */ + }, { + key: 'reset', + value: function reset() { + this.enable(); + this.init(); + this.buildAll(); } /** @@ -4715,6 +4756,10 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'destroy', value: function destroy() { + if (!this.initialized) { + return; + } + this.popUpFltElmCache = []; for (var i = 0; i < this.popUpFltElms.length; i++) { var popUpFltElm = this.popUpFltElms[i], @@ -4737,11 +4782,14 @@ return /******/ (function(modules) { // webpackBootstrap this.popUpFltElms = []; this.popUpFltSpans = []; this.popUpFltImgs = []; + + this.disable(); + this.initialized = false; } }]); return PopupFilter; - })(); + })(_feature.Feature); exports.PopupFilter = PopupFilter; /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) @@ -5630,8 +5678,6 @@ return /******/ (function(modules) { // webpackBootstrap this.onBeforeRefreshCounter = _types2['default'].isFn(f.on_before_refresh_counter) ? f.on_before_refresh_counter : null; //callback raised after counter is refreshed this.onAfterRefreshCounter = _types2['default'].isFn(f.on_after_refresh_counter) ? f.on_after_refresh_counter : null; - - this.tf = tf; } _createClass(RowsCounter, [{ @@ -6419,9 +6465,9 @@ return /******/ (function(modules) { // webpackBootstrap slcRSpan.appendChild(_dom2['default'].text(slcRText)); var help = tf.feature('help'); - if (help && help.cont) { - help.cont.parentNode.insertBefore(slcRSpan, help.cont); - help.cont.parentNode.insertBefore(slcR, help.cont); + 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); @@ -6837,10 +6883,16 @@ return /******/ (function(modules) { // webpackBootstrap 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 _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } + 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; } + + var _feature = __webpack_require__(11); + var _dom = __webpack_require__(2); var _dom2 = _interopRequireDefault(_dom); @@ -6852,7 +6904,8 @@ return /******/ (function(modules) { // webpackBootstrap var WIKI_URL = 'https://github.com/koalyptus/TableFilter/wiki/' + '4.-Filter-operators'; var WEBSITE_URL = 'http://koalyptus.github.io/TableFilter/'; - var Help = (function () { + var Help = (function (_Feature) { + _inherits(Help, _Feature); /** * Help UI component @@ -6862,8 +6915,9 @@ return /******/ (function(modules) { // webpackBootstrap function Help(tf) { _classCallCheck(this, Help); - // Configuration object - var f = tf.config(); + _get(Object.getPrototypeOf(Help.prototype), 'constructor', this).call(this, tf, 'help'); + + var f = this.config; //id of custom container element for instructions this.tgtId = f.help_instructions_target_id || null; @@ -6891,8 +6945,6 @@ return /******/ (function(modules) { // webpackBootstrap this.prfxHelpSpan = 'helpSpan_'; //id prefix for help elements this.prfxHelpDiv = 'helpDiv_'; - - this.tf = tf; } _createClass(Help, [{ @@ -6900,7 +6952,7 @@ return /******/ (function(modules) { // webpackBootstrap value: function init() { var _this = this; - if (this.btn) { + if (this.initialized) { return; } @@ -6961,6 +7013,7 @@ return /******/ (function(modules) { // webpackBootstrap this.cont = helpdiv; this.btn = helpspan; + this.initialized = true; } /** @@ -6969,7 +7022,9 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'toggle', value: function toggle() { - if (!this.cont) { + // 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; @@ -6986,7 +7041,7 @@ return /******/ (function(modules) { // webpackBootstrap }, { key: 'destroy', value: function destroy() { - if (!this.btn) { + if (!this.initialized) { return; } this.btn.parentNode.removeChild(this.btn); @@ -6996,11 +7051,14 @@ return /******/ (function(modules) { // webpackBootstrap } this.cont.parentNode.removeChild(this.cont); this.cont = null; + + this.disable(); + this.initialized = false; } }]); return Help; - })(); + })(_feature.Feature); exports.Help = Help; diff --git a/src/modules/feature.js b/src/modules/feature.js index 016e9090..eda73c75 100644 --- a/src/modules/feature.js +++ b/src/modules/feature.js @@ -28,12 +28,10 @@ export class Feature { enable() { this.enabled = true; - // this.tf[this.feature] = this.enabled; } disable() { this.enabled = false; - // this.tf[this.feature] = this.enabled; } isEnabled() { diff --git a/src/modules/gridLayout.js b/src/modules/gridLayout.js index da079b4c..959d674a 100644 --- a/src/modules/gridLayout.js +++ b/src/modules/gridLayout.js @@ -294,7 +294,7 @@ export class GridLayout extends Feature{ } }; - if(tf.popUpFilters){ + if(tf.popupFilters){ filtersRow.style.display = 'none'; } diff --git a/src/modules/help.js b/src/modules/help.js index 3488177b..7f0ae77f 100644 --- a/src/modules/help.js +++ b/src/modules/help.js @@ -1,3 +1,4 @@ +import {Feature} from './feature'; import Dom from '../dom'; import Event from '../event'; @@ -6,15 +7,16 @@ const WIKI_URL = 'https://github.com/koalyptus/TableFilter/wiki/' + '4.-Filter-operators'; const WEBSITE_URL = 'http://koalyptus.github.io/TableFilter/'; -export class Help{ +export class Help extends Feature{ /** * Help UI component * @param {Object} tf TableFilter instance */ constructor(tf){ - // Configuration object - var f = tf.config(); + super(tf, 'help'); + + var f = this.config; //id of custom container element for instructions this.tgtId = f.help_instructions_target_id || null; @@ -57,19 +59,17 @@ export class Help{ this.prfxHelpSpan = 'helpSpan_'; //id prefix for help elements this.prfxHelpDiv = 'helpDiv_'; - - this.tf = tf; } init(){ - if(this.btn){ + if(this.initialized){ return; } var tf = this.tf; - var helpspan = Dom.create('span',['id', this.prfxHelpSpan+tf.id]); - var helpdiv = Dom.create('div',['id', this.prfxHelpDiv+tf.id]); + var helpspan = Dom.create('span', ['id', this.prfxHelpSpan+tf.id]); + var helpdiv = Dom.create('div', ['id', this.prfxHelpDiv+tf.id]); //help button is added to defined element if(!this.tgtId){ @@ -113,13 +113,16 @@ export class Help{ this.cont = helpdiv; this.btn = helpspan; + this.initialized = true; } /** * Toggle help pop-up */ toggle(){ - if(!this.cont){ + // 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; @@ -134,7 +137,7 @@ export class Help{ * Remove help UI */ destroy(){ - if(!this.btn){ + if(!this.initialized){ return; } this.btn.parentNode.removeChild(this.btn); @@ -144,6 +147,9 @@ export class Help{ } this.cont.parentNode.removeChild(this.cont); this.cont = null; + + this.disable(); + this.initialized = false; } } diff --git a/src/modules/loader.js b/src/modules/loader.js index 90e2fe40..fb7a583f 100644 --- a/src/modules/loader.js +++ b/src/modules/loader.js @@ -1,18 +1,21 @@ +import {Feature} from './feature'; import Dom from '../dom'; import Types from '../types'; var global = window; -export class Loader{ +export class Loader extends Feature{ /** * Loading message/spinner * @param {Object} tf TableFilter instance */ constructor(tf){ + super(tf, 'loader'); // TableFilter configuration - var f = tf.config(); + var f = this.config; + //id of container element this.loaderTgtId = f.loader_target_id || null; //div containing loader @@ -33,8 +36,14 @@ export class Loader{ f.on_hide_loader : null; //loader div this.prfxLoader = 'load_'; + } - this.tf = tf; + init() { + if(this.initialized){ + return; + } + + var tf = this.tf; var containerDiv = Dom.create('div', ['id', this.prfxLoader+tf.id]); containerDiv.className = this.loaderCssClass; @@ -46,17 +55,19 @@ export class Loader{ } else { targetEl.appendChild(containerDiv); } - this.loaderDiv = Dom.id(this.prfxLoader+tf.id); + this.loaderDiv = containerDiv; if(!this.loaderHtml){ this.loaderDiv.appendChild(Dom.text(this.loaderText)); } else { this.loaderDiv.innerHTML = this.loaderHtml; } + + this.show('none'); + this.initialized = true; } show(p) { - if(!this.tf.loader || !this.loaderDiv || - this.loaderDiv.style.display===p){ + if(!this.isEnabled() || this.loaderDiv.style.display === p){ return; } @@ -64,30 +75,28 @@ export class Loader{ if(!this.loaderDiv){ return; } - if(this.onShowLoader && p!=='none'){ + if(this.onShowLoader && p !== 'none'){ this.onShowLoader.call(null, this); } this.loaderDiv.style.display = p; - if(this.onHideLoader && p==='none'){ + if(this.onHideLoader && p === 'none'){ this.onHideLoader.call(null, this); } }; - var t = p==='none' ? this.loaderCloseDelay : 1; + var t = p === 'none' ? this.loaderCloseDelay : 1; global.setTimeout(displayLoader, t); } destroy(){ - if(!this.loaderDiv){ + if(!this.initialized){ return; } - // var tf = this.tf, - // targetEl = !this.loaderTgtId ? - // (tf.gridLayout ? - // tf.feature('gridLayout').tblCont : tf.tbl.parentNode) : - // Dom.id(this.loaderTgtId); - // targetEl.removeChild(this.loaderDiv); + this.loaderDiv.parentNode.removeChild(this.loaderDiv); this.loaderDiv = null; + + this.disable(); + this.initialized = false; } } diff --git a/src/modules/paging.js b/src/modules/paging.js index b7c07f05..a5473c8b 100644 --- a/src/modules/paging.js +++ b/src/modules/paging.js @@ -534,9 +534,9 @@ export class Paging extends Feature{ slcRSpan.appendChild(Dom.text(slcRText)); var help = tf.feature('help'); - if(help && help.cont){ - help.cont.parentNode.insertBefore(slcRSpan, help.cont); - help.cont.parentNode.insertBefore(slcR, help.cont); + 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); diff --git a/src/modules/popupFilter.js b/src/modules/popupFilter.js index f4348c96..f2de5b22 100644 --- a/src/modules/popupFilter.js +++ b/src/modules/popupFilter.js @@ -1,16 +1,19 @@ +import {Feature} from './feature'; import Types from '../types'; import Dom from '../dom'; import Event from '../event'; -export class PopupFilter{ +export class PopupFilter extends Feature{ /** * Pop-up filter component * @param {Object} tf TableFilter instance */ constructor(tf){ + super(tf, 'popupFilters'); + // Configuration object - var f = tf.config(); + var f = this.config; // Enable external filters behaviour tf.isExternalFlt = true; @@ -52,8 +55,6 @@ export class PopupFilter{ this.prfxPopUpSpan = 'popUpSpan_'; //id prefix for pop-up div containing filter this.prfxPopUpDiv = 'popUpDiv_'; - - this.tf = tf; } onClick(e){ @@ -78,6 +79,10 @@ export class PopupFilter{ * Initialize DOM elements */ init(){ + if(this.initialized){ + return; + } + var tf = this.tf; for(var i=0; i 1 && this.filtersRowIndex <= this.headersRow && - !this.popUpFilters){ + !this.popupFilters){ this.headersRow++; } - if(this.popUpFilters){ + if(this.popupFilters){ this.headersRow++; } fltrow.className = this.fltsRowCssClass; - if(this.isExternalFlt || this.popUpFilters){ + if(this.isExternalFlt || this.popupFilters){ fltrow.style.display = 'none'; } } @@ -697,7 +698,7 @@ export class TableFilter{ for(let i=0; i