1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2026-03-17 08:05:44 +01:00

Started feature base class for grid layout

This commit is contained in:
Max Guglielmi 2015-11-16 23:21:19 +11:00
commit f2c5bf33f5
19 changed files with 753 additions and 152 deletions

View file

@ -44,7 +44,6 @@ export class ClearButton extends Feature{
init(){
var tf = this.tf;
// if(!tf.hasGrid() && !tf.isFirstLoad && tf.btnResetEl){
if(this.initialized){
return;
}

View file

@ -28,12 +28,12 @@ export class Feature {
enable() {
this.enabled = true;
this.tf[this.feature] = this.enabled;
// this.tf[this.feature] = this.enabled;
}
disable() {
this.enabled = false;
this.tf[this.feature] = this.enabled;
// this.tf[this.feature] = this.enabled;
}
isEnabled() {

View file

@ -1,15 +1,18 @@
import {Feature} from './feature';
import Dom from '../dom';
import Types from '../types';
import Event from '../event';
export class GridLayout{
export class GridLayout extends Feature{
/**
* Grid layout, table with fixed headers
* @param {Object} tf TableFilter instance
*/
constructor(tf) {
var f = tf.config();
constructor(tf){
super(tf, 'gridLayout');
var f = this.config;
//defines grid width
this.gridWidth = f.grid_width || null;
@ -50,8 +53,6 @@ export class GridLayout{
this.prfxGridTh = 'tblHeadTh_';
this.sourceTblHtml = tf.tbl.outerHTML;
this.tf = tf;
}
/**
@ -59,10 +60,10 @@ export class GridLayout{
*/
init(){
var tf = this.tf;
var f = tf.config();
var f = this.config;
var tbl = tf.tbl;
if(!tf.gridLayout){
if(this.initialized){
return;
}
@ -148,7 +149,7 @@ export class GridLayout{
//Headers table
this.headTbl = Dom.create('table', ['id', this.prfxHeadTbl + tf.id]);
var tH = Dom.create('tHead'); //IE<7 needs it
var tH = Dom.create('tHead');
//1st row should be headers row, ids are added if not set
//Those ids are used by the sort feature
@ -300,6 +301,8 @@ export class GridLayout{
if(tbl.clientWidth !== this.headTbl.clientWidth){
tbl.style.width = this.headTbl.clientWidth+'px';
}
this.initialized = true;
}
/**
@ -309,7 +312,7 @@ export class GridLayout{
var tf = this.tf;
var tbl = tf.tbl;
if(!tf.gridLayout){
if(!this.initialized){
return;
}
var t = tbl.parentNode.removeChild(tbl);
@ -323,6 +326,8 @@ export class GridLayout{
tbl.outerHTML = this.sourceTblHtml;
//needed to keep reference of table element
tbl = Dom.id(tf.id);
this.tf.tbl = Dom.id(tf.id); // ???
this.initialized = false;
}
}
}

View file

@ -81,12 +81,13 @@ export class Loader{
if(!this.loaderDiv){
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);
// 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;
}
}