mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-18 14:26:40 +02:00
Implemented Feature base class for statusBar
This commit is contained in:
parent
310247bd48
commit
3565c0dad3
|
@ -13029,8 +13029,7 @@
|
|||
'70px', '70px', '70px',
|
||||
'70px', '60px', '60px'
|
||||
],
|
||||
extensions:[{ name: 'sort' }],
|
||||
popup_filters: true
|
||||
extensions:[{ name: 'sort' }]
|
||||
};
|
||||
|
||||
var tf = new TableFilter('demo', filtersConfig);
|
||||
|
|
35
dist/tablefilter/tablefilter.js
vendored
35
dist/tablefilter/tablefilter.js
vendored
|
@ -1366,7 +1366,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
_dom2['default'].removeClass(this.tbl, this.prfxTf);
|
||||
this.activeFlt = null;
|
||||
this.isStartBgAlternate = true;
|
||||
this._hasGrid = false;
|
||||
this.tbl = null;
|
||||
}
|
||||
|
@ -5791,10 +5790,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(_x2, _x3, _x4) { var _again = true; _function: while (_again) { var object = _x2, property = _x3, receiver = _x4; 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 { _x2 = parent; _x3 = property; _x4 = 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);
|
||||
|
@ -5805,7 +5810,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
var global = window;
|
||||
|
||||
var StatusBar = (function () {
|
||||
var StatusBar = (function (_Feature) {
|
||||
_inherits(StatusBar, _Feature);
|
||||
|
||||
/**
|
||||
* Status bar UI component
|
||||
|
@ -5815,8 +5821,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
function StatusBar(tf) {
|
||||
_classCallCheck(this, StatusBar);
|
||||
|
||||
_get(Object.getPrototypeOf(StatusBar.prototype), 'constructor', this).call(this, tf, 'statusBar');
|
||||
|
||||
// Configuration object
|
||||
var f = tf.config();
|
||||
var f = this.config;
|
||||
|
||||
//id of custom container element
|
||||
this.statusBarTgtId = f.status_bar_target_id || null;
|
||||
|
@ -5844,18 +5852,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.prfxStatusSpan = 'statusSpan_';
|
||||
// text preceding status bar label
|
||||
this.prfxStatusTxt = 'statusText_';
|
||||
|
||||
this.tf = tf;
|
||||
}
|
||||
|
||||
_createClass(StatusBar, [{
|
||||
key: 'init',
|
||||
value: function init() {
|
||||
var tf = this.tf;
|
||||
if (!tf.hasGrid() && !tf.isFirstLoad) {
|
||||
if (this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
var tf = this.tf;
|
||||
|
||||
//status bar container
|
||||
var statusDiv = _dom2['default'].create('div', ['id', this.prfxStatus + tf.id]);
|
||||
statusDiv.className = this.statusBarCssClass;
|
||||
|
@ -5886,6 +5893,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.statusBarDiv = statusDiv;
|
||||
this.statusBarSpan = statusSpan;
|
||||
this.statusBarSpanText = statusSpanText;
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
}, {
|
||||
key: 'message',
|
||||
|
@ -5894,10 +5903,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
|
||||
var t = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
|
||||
|
||||
var tf = this.tf;
|
||||
if (!tf.statusBar || !this.statusBarSpan) {
|
||||
if (!this.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.onBeforeShowMsg) {
|
||||
this.onBeforeShowMsg.call(null, this.tf, t);
|
||||
}
|
||||
|
@ -5913,8 +5922,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
}, {
|
||||
key: 'destroy',
|
||||
value: function destroy() {
|
||||
var tf = this.tf;
|
||||
if (!tf.hasGrid() || !this.statusBarDiv) {
|
||||
if (!this.initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5923,11 +5931,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.statusBarSpan = null;
|
||||
this.statusBarSpanText = null;
|
||||
this.statusBarDiv = null;
|
||||
|
||||
this.disable();
|
||||
this.initialized = false;
|
||||
}
|
||||
}]);
|
||||
|
||||
return StatusBar;
|
||||
})();
|
||||
})(_feature.Feature);
|
||||
|
||||
exports.StatusBar = StatusBar;
|
||||
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
import {Feature} from './feature';
|
||||
import Dom from '../dom';
|
||||
import Types from '../types';
|
||||
|
||||
var global = window;
|
||||
|
||||
export class StatusBar{
|
||||
export class StatusBar extends Feature{
|
||||
|
||||
/**
|
||||
* Status bar UI component
|
||||
* @param {Object} tf TableFilter instance
|
||||
*/
|
||||
constructor(tf){
|
||||
super(tf, 'statusBar');
|
||||
|
||||
// Configuration object
|
||||
var f = tf.config();
|
||||
var f = this.config;
|
||||
|
||||
//id of custom container element
|
||||
this.statusBarTgtId = f.status_bar_target_id || null;
|
||||
|
@ -41,16 +44,15 @@ export class StatusBar{
|
|||
this.prfxStatusSpan = 'statusSpan_';
|
||||
// text preceding status bar label
|
||||
this.prfxStatusTxt = 'statusText_';
|
||||
|
||||
this.tf = tf;
|
||||
}
|
||||
|
||||
init(){
|
||||
var tf = this.tf;
|
||||
if(!tf.hasGrid() && !tf.isFirstLoad){
|
||||
if(this.initialized){
|
||||
return;
|
||||
}
|
||||
|
||||
var tf = this.tf;
|
||||
|
||||
//status bar container
|
||||
var statusDiv = Dom.create('div', ['id', this.prfxStatus+tf.id]);
|
||||
statusDiv.className = this.statusBarCssClass;
|
||||
|
@ -84,13 +86,14 @@ export class StatusBar{
|
|||
this.statusBarSpan = statusSpan;
|
||||
this.statusBarSpanText = statusSpanText;
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
message(t=''){
|
||||
var tf = this.tf;
|
||||
if(!tf.statusBar || !this.statusBarSpan){
|
||||
if(!this.isEnabled()){
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.onBeforeShowMsg){
|
||||
this.onBeforeShowMsg.call(null, this.tf, t);
|
||||
}
|
||||
|
@ -105,8 +108,7 @@ export class StatusBar{
|
|||
}
|
||||
|
||||
destroy(){
|
||||
var tf = this.tf;
|
||||
if(!tf.hasGrid() || !this.statusBarDiv){
|
||||
if(!this.initialized){
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -115,6 +117,9 @@ export class StatusBar{
|
|||
this.statusBarSpan = null;
|
||||
this.statusBarSpanText = null;
|
||||
this.statusBarDiv = null;
|
||||
|
||||
this.disable();
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1223,7 +1223,6 @@ export class TableFilter{
|
|||
|
||||
Dom.removeClass(this.tbl, this.prfxTf);
|
||||
this.activeFlt = null;
|
||||
this.isStartBgAlternate = true;
|
||||
this._hasGrid = false;
|
||||
this.tbl = null;
|
||||
}
|
||||
|
|
|
@ -52,8 +52,7 @@
|
|||
'70px', '70px', '70px',
|
||||
'70px', '60px', '60px'
|
||||
],
|
||||
extensions:[{ name: 'sort' }],
|
||||
popup_filters: true
|
||||
extensions:[{ name: 'sort' }]
|
||||
};
|
||||
|
||||
var tf = new TableFilter('demo', filtersConfig);
|
||||
|
|
|
@ -11,6 +11,48 @@ test('Status bar component', function() {
|
|||
notEqual(statusBar.statusBarDiv, null, 'statusBarDiv property');
|
||||
});
|
||||
|
||||
module('Feature interface');
|
||||
test('Properties', function() {
|
||||
deepEqual(statusBar.tf instanceof TableFilter,
|
||||
true, 'TableFilter instance');
|
||||
deepEqual(statusBar.feature, 'statusBar', 'Feature name');
|
||||
deepEqual(statusBar.enabled, true, 'Feature enabled');
|
||||
deepEqual(statusBar.initialized, true, 'Feature enabled');
|
||||
deepEqual(typeof statusBar.config, 'object', 'TF configuration object');
|
||||
deepEqual(typeof statusBar.init, 'function', 'Feature init method');
|
||||
deepEqual(typeof statusBar.destroy, 'function', 'Feature destroy method');
|
||||
deepEqual(typeof statusBar.reset, 'function', 'Feature reset method');
|
||||
deepEqual(typeof statusBar.enable, 'function', 'Feature enable method');
|
||||
deepEqual(typeof statusBar.disable, 'function', 'Feature enable method');
|
||||
deepEqual(typeof statusBar.isEnabled, 'function', 'Feature enable method');
|
||||
});
|
||||
test('Can destroy', function() {
|
||||
statusBar.destroy();
|
||||
deepEqual(statusBar.enabled, false, 'disabled');
|
||||
});
|
||||
test('Can reset', function() {
|
||||
statusBar.reset();
|
||||
deepEqual(statusBar.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can disable', function() {
|
||||
statusBar.disable();
|
||||
deepEqual(statusBar.enabled, false, 'disabled');
|
||||
});
|
||||
test('Can enable', function() {
|
||||
statusBar.enable();
|
||||
deepEqual(statusBar.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can init', function() {
|
||||
statusBar.destroy();
|
||||
statusBar.enable();
|
||||
statusBar.init();
|
||||
deepEqual(statusBar.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can check is enabled', function() {
|
||||
statusBar.isEnabled();
|
||||
deepEqual(statusBar.enabled, true, 'enabled');
|
||||
});
|
||||
|
||||
module('UI elements');
|
||||
test('Status bar UI elements', function() {
|
||||
var container = statusBar.statusBarDiv,
|
||||
|
@ -37,3 +79,8 @@ test('Re-set UI', function() {
|
|||
label.innerHTML.indexOf('→←'), -1, 'Status bar text');
|
||||
});
|
||||
|
||||
module('Tear-down');
|
||||
test('can destroy TableFilter DOM elements', function() {
|
||||
tf.destroy();
|
||||
deepEqual(tf.hasGrid(), false, 'Filters removed');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue