1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-18 14:26:40 +02:00

Implemented Feature base class for popupFilters

This commit is contained in:
Max Guglielmi 2015-11-21 14:41:40 +11:00
parent f2c5bf33f5
commit 310247bd48
21 changed files with 375 additions and 141 deletions

View file

@ -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);

View file

@ -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}

View file

@ -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}

View file

@ -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}

View file

@ -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}

View file

@ -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}

View file

@ -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}

View file

@ -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;

View file

@ -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() {

View file

@ -294,7 +294,7 @@ export class GridLayout extends Feature{
}
};
if(tf.popUpFilters){
if(tf.popupFilters){
filtersRow.style.display = 'none';
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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<tf.nbCells; i++){
if(tf.getFilterType(i) === tf.fltTypeNone){
@ -95,6 +100,17 @@ export class PopupFilter{
this.popUpFltSpans[i] = popUpSpan;
this.popUpFltImgs[i] = popUpSpan.firstChild;
}
this.initialized = true;
}
/**
* Reset previously destroyed feature
*/
reset(){
this.enable();
this.init();
this.buildAll();
}
/**
@ -203,6 +219,10 @@ export class PopupFilter{
* Remove pop-up filters
*/
destroy(){
if(!this.initialized){
return;
}
this.popUpFltElmCache = [];
for(var i=0; i<this.popUpFltElms.length; i++){
var popUpFltElm = this.popUpFltElms[i],
@ -225,6 +245,9 @@ export class PopupFilter{
this.popUpFltElms = [];
this.popUpFltSpans = [];
this.popUpFltImgs = [];
this.disable();
this.initialized = false;
}
}

View file

@ -38,8 +38,6 @@ export class RowsCounter extends Feature{
//callback raised after counter is refreshed
this.onAfterRefreshCounter = Types.isFn(f.on_after_refresh_counter) ?
f.on_after_refresh_counter : null;
this.tf = tf;
}
init(){

View file

@ -230,10 +230,10 @@ export class TableFilter{
//id of toolbar container element
this.toolBarTgtId = f.toolbar_target_id || null;
//enables/disables help div
this.helpInstructions = Types.isUndef(f.help_instructions) ?
this.help = Types.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
@ -539,7 +539,7 @@ export class TableFilter{
let elm = Event.target(_ev);
this.activeFilterId = elm.getAttribute('id');
this.activeFlt = Dom.id(this.activeFilterId);
if(this.popUpFilters){
if(this.popupFilters){
Event.cancel(_ev);
Event.stop(_ev);
}
@ -567,7 +567,7 @@ export class TableFilter{
let ct = elm.getAttribute('ct');
this.Mod.dropdown._build(ct);
}
if(this.popUpFilters){
if(this.popupFilters){
Event.cancel(_ev);
Event.stop(_ev);
}
@ -576,7 +576,7 @@ export class TableFilter{
onSlcChange(e) {
if(!this.activeFlt){ return; }
let _ev = e || global.event;
if(this.popUpFilters){ Event.stop(_ev); }
if(this.popupFilters){ Event.stop(_ev); }
if(this.onSlcChange){ this.filter(); }
},
// fill checklist filter on click if required
@ -612,7 +612,7 @@ export class TableFilter{
if(this.gridLayout){
this.refRow = this.startRow===null ? 0 : this.startRow;
}
if(this.popUpFilters &&
if(this.popupFilters &&
((this.filtersRowIndex === 0 && this.headersRow === 1) ||
this.gridLayout)){
this.headersRow = 0;
@ -641,6 +641,7 @@ export class TableFilter{
if(this.loader){
if(!Mod.loader){
Mod.loader = new Loader(this);
Mod.loader.init();
}
}
@ -648,7 +649,7 @@ export class TableFilter{
Mod.highlightKeyword = new HighlightKeyword(this);
}
if(this.popUpFilters){
if(this.popupFilters){
if(!Mod.popupFilter){
Mod.popupFilter = new PopupFilter(this);
}
@ -677,16 +678,16 @@ export class TableFilter{
if(this.headersRow > 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<n; i++){// this loop adds filters
if(this.popUpFilters){
if(this.popupFilters){
Mod.popupFilter.build(i);
}
@ -895,7 +896,7 @@ export class TableFilter{
Mod.clearButton = new ClearButton(this);
Mod.clearButton.init();
}
if(this.helpInstructions){
if(this.help){
if(!Mod.help){
Mod.help = new Help(this);
}
@ -1176,7 +1177,7 @@ export class TableFilter{
let rows = this.tbl.rows,
Mod = this.Mod;
if(this.isExternalFlt && !this.popUpFilters){
if(this.isExternalFlt && !this.popupFilters){
this.removeExternalFlts();
}
if(this.infDiv){
@ -1278,12 +1279,12 @@ export class TableFilter{
// Enable help instructions by default if topbar is generated and not
// explicitely set to false
if(Types.isUndef(this.helpInstructions)){
if(Types.isUndef(this.help)){
if(!this.Mod.help){
this.Mod.help = new Help(this);
}
this.Mod.help.init();
this.helpInstructions = true;
this.help = true;
}
}
@ -1504,7 +1505,7 @@ export class TableFilter{
Mod.highlightKeyword.unhighlightAll();
}
//removes popup filters active icons
if(this.popUpFilters){
if(this.popupFilters){
Mod.popupFilter.buildIcons();
}
//removes active column header class
@ -1797,7 +1798,7 @@ export class TableFilter{
if(this.singleSearchFlt && occurence[j]){
singleFltRowValid = true;
}
if(this.popUpFilters){
if(this.popupFilters){
Mod.popupFilter.buildIcon(j, true);
}
if(this.markActiveColumns){
@ -1891,7 +1892,7 @@ export class TableFilter{
Mod.rowsCounter.refresh(this.nbVisibleRows);
}
if(this.popUpFilters){
if(this.popupFilters){
Mod.popupFilter.closeAll();
}
}
@ -2503,9 +2504,9 @@ export class TableFilter{
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){

View file

@ -52,7 +52,8 @@
'70px', '70px', '70px',
'70px', '60px', '60px'
],
extensions:[{ name: 'sort' }]
extensions:[{ name: 'sort' }],
popup_filters: true
};
var tf = new TableFilter('demo', filtersConfig);

View file

@ -12,6 +12,47 @@ test('Clear button component', function() {
notEqual(help.btn, null, 'btn property');
});
module('Feature interface');
test('Properties', function() {
deepEqual(help.tf instanceof TableFilter, true, 'TableFilter instance');
deepEqual(help.feature, 'help', 'Feature name');
deepEqual(help.enabled, true, 'Feature enabled');
deepEqual(help.initialized, true, 'Feature enabled');
deepEqual(typeof help.config, 'object', 'TF configuration object');
deepEqual(typeof help.init, 'function', 'Feature init method');
deepEqual(typeof help.destroy, 'function', 'Feature destroy method');
deepEqual(typeof help.reset, 'function', 'Feature reset method');
deepEqual(typeof help.enable, 'function', 'Feature enable method');
deepEqual(typeof help.disable, 'function', 'Feature enable method');
deepEqual(typeof help.isEnabled, 'function', 'Feature enable method');
});
test('Can destroy', function() {
help.destroy();
deepEqual(help.enabled, false, 'disabled');
});
test('Can reset', function() {
help.reset();
deepEqual(help.enabled, true, 'enabled');
});
test('Can disable', function() {
help.disable();
deepEqual(help.enabled, false, 'disabled');
});
test('Can enable', function() {
help.enable();
deepEqual(help.enabled, true, 'enabled');
});
test('Can init', function() {
help.destroy();
help.enable();
help.init();
deepEqual(help.enabled, true, 'enabled');
});
test('Can check is enabled', function() {
help.isEnabled();
deepEqual(help.enabled, true, 'enabled');
});
module('UI elements');
test('Help UI elements', function() {
var container = help.cont,
@ -45,3 +86,9 @@ test('Re-set UI', function() {
);
notEqual(helpBtn.innerHTML.indexOf('→Help←'), -1, 'Help button text');
});
module('Tear-down');
test('can destroy TableFilter DOM elements', function() {
tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed');
});

View file

@ -9,16 +9,29 @@ var highlightKeyword = tf.feature('highlightKeyword');
module('Sanity checks');
test('HighlightKeyword component', function() {
deepEqual(typeof highlightKeyword, 'object', 'Instanciated');
deepEqual(highlightKeyword.highlightedNodes instanceof Array, true, 'Property check');
deepEqual(highlightKeyword.highlightedNodes instanceof Array,
true, 'Property check');
});
test('Highlighted keywords', function() {
tf.setFilterValue(1, 'Perth');
tf.setFilterValue(3, '3.1');
tf._filter();
deepEqual(highlightKeyword.highlightedNodes.length, 2, 'Number of highlighted words');
deepEqual(highlightKeyword.highlightedNodes.length,
2, 'Number of highlighted words');
tf._clearFilters();
tf._filter();
deepEqual(highlightKeyword.highlightedNodes.length, 0, 'Number of highlighted words');
deepEqual(highlightKeyword.highlightedNodes.length,
0, 'Number of highlighted words');
});
module('Tear-down');
test('can destroy TableFilter DOM elements', function() {
tf.setFilterValue(1, 'Perth');
tf._filter();
tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed');
deepEqual(highlightKeyword.highlightedNodes.length,
0, 'Number of highlighted words');
});

View file

@ -5,9 +5,10 @@ var tf = new TableFilter('demo', {
});
tf.init();
var loader = tf.feature('loader');
module('Sanity checks');
test('Loader component', function() {
var loader = tf.feature('loader');
notEqual(loader, null, 'Loader instanciated');
notEqual(
document.getElementById(loader.prfxLoader+tf.id),
@ -15,3 +16,60 @@ test('Loader component', function() {
'Loader DOM container'
);
});
module('Feature interface');
test('Properties', function() {
deepEqual(loader.tf instanceof TableFilter, true, 'TableFilter instance');
deepEqual(loader.feature, 'loader', 'Feature name');
deepEqual(loader.enabled, true, 'Feature enabled');
deepEqual(loader.initialized, true, 'Feature enabled');
deepEqual(typeof loader.config, 'object', 'TF configuration object');
deepEqual(typeof loader.init, 'function', 'Feature init method');
deepEqual(typeof loader.destroy, 'function', 'Feature destroy method');
deepEqual(typeof loader.reset, 'function', 'Feature reset method');
deepEqual(typeof loader.enable, 'function', 'Feature enable method');
deepEqual(typeof loader.disable, 'function', 'Feature enable method');
deepEqual(typeof loader.isEnabled, 'function', 'Feature enable method');
});
test('Can destroy', function() {
loader.destroy();
deepEqual(loader.enabled, false, 'disabled');
});
test('Can reset', function() {
loader.reset();
deepEqual(loader.enabled, true, 'enabled');
});
test('Can disable', function() {
loader.disable();
deepEqual(loader.enabled, false, 'disabled');
});
test('Can enable', function() {
loader.enable();
deepEqual(loader.enabled, true, 'enabled');
});
test('Can init', function() {
loader.destroy();
loader.enable();
loader.init();
deepEqual(loader.enabled, true, 'enabled');
});
test('Can check is enabled', function() {
loader.isEnabled();
deepEqual(loader.enabled, true, 'enabled');
});
module('Behaviour');
test('Can show loader', function() {
loader.show('');
deepEqual(loader.loaderDiv.style.display, '', 'Loader is displayed');
});
test('Can show loader', function() {
loader.show('');
deepEqual(loader.loaderDiv.style.display, '', 'Loader is displayed');
});
module('Tear-down');
test('can destroy TableFilter DOM elements', function() {
tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed');
});

View file

@ -83,9 +83,30 @@ test('Pop-up filter UI elements with grid-layout', function() {
deepEqual(fltIcn3, undefined, 'Filter icon does not exist for column 4');
});
module('Feature interface');
test('Properties', function() {
var popupFilter = tf.feature('popupFilter');
deepEqual(popupFilter.tf instanceof TableFilter,
true, 'TableFilter instance');
deepEqual(popupFilter.feature, 'popupFilters', 'Feature name');
deepEqual(popupFilter.enabled, true, 'Feature enabled');
deepEqual(popupFilter.initialized, true, 'Feature enabled');
deepEqual(typeof popupFilter.config, 'object', 'TF configuration object');
deepEqual(typeof popupFilter.init, 'function', 'Feature init method');
deepEqual(typeof popupFilter.destroy, 'function', 'Feature destroy method');
deepEqual(typeof popupFilter.reset, 'function', 'Feature reset method');
deepEqual(typeof popupFilter.enable, 'function', 'Feature enable method');
deepEqual(typeof popupFilter.disable, 'function', 'Feature enable method');
deepEqual(typeof popupFilter.isEnabled,
'function', 'Feature enable method');
});
module('Tear-down');
test('TableFilter removed', function() {
tf.destroy();
var fltIcn1 = popupFilter.popUpFltImgs[3];
deepEqual(fltIcn1, undefined, 'Filter icon is removed');
deepEqual(id(tf.fltIds[3]), null, 'Filter is removed');
deepEqual(tf.hasGrid(), false, 'Filters removed');
});