mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-03 15:13:15 +02:00
Added grid layout tests
This commit is contained in:
parent
cd6a57cd3f
commit
8774c670ff
22
Gruntfile.js
22
Gruntfile.js
|
@ -10,7 +10,11 @@ module.exports = function (grunt) {
|
|||
|
||||
// A list of files, which will be syntax-checked by JSHint
|
||||
jshint: {
|
||||
src: ['Gruntfile.js', 'src/*.js'],
|
||||
src: [
|
||||
'Gruntfile.js',
|
||||
'<%= source_folder %>*.js',
|
||||
'!<%= source_folder %>sortabletable.js'
|
||||
],
|
||||
options: {
|
||||
jshintrc: '.jshintrc'
|
||||
}
|
||||
|
@ -19,9 +23,9 @@ module.exports = function (grunt) {
|
|||
watch: {
|
||||
files: [
|
||||
'src-es6/**/*.js',
|
||||
'src/**/*.js',
|
||||
'src/**/*.css',
|
||||
'src/**/*.html'
|
||||
'<%= source_folder %>**/*.js',
|
||||
'<%= source_folder %>**/*.css',
|
||||
'<%= source_folder %>**/*.html'
|
||||
],
|
||||
tasks: ['dev']
|
||||
},
|
||||
|
@ -33,15 +37,20 @@ module.exports = function (grunt) {
|
|||
requirejs: {
|
||||
compile: {
|
||||
options: {
|
||||
baseUrl: 'src/',
|
||||
baseUrl: '<%= source_folder %>',
|
||||
'paths': {
|
||||
'tf': '.'
|
||||
},
|
||||
include: ['../libs/almond/almond', 'core'],
|
||||
out: 'dist/tablefilter.js',
|
||||
out: '<%= dist_folder %>tablefilter.js',
|
||||
wrap: {
|
||||
startFile: "src/start.frag",
|
||||
endFile: "src/end.frag"
|
||||
},
|
||||
shim: {
|
||||
'SortableTable': {
|
||||
exports: 'SortableTable'
|
||||
}
|
||||
}/*,
|
||||
optimize: 'uglify2',
|
||||
preserveLicenseComments: false,
|
||||
|
@ -101,6 +110,7 @@ module.exports = function (grunt) {
|
|||
copy: {
|
||||
main: {
|
||||
files: [
|
||||
{ src: 'libs/sortabletable.js', dest: '<%= source_folder %>/sortabletable.js' },
|
||||
{ src: ['**'], cwd: '<%= source_folder %>TF_Modules/', dest: '<%= dist_folder %>TF_Modules/', expand: true },
|
||||
{ src: ['**'], cwd: '<%= source_folder %>TF_Themes/', dest: '<%= dist_folder %>TF_Themes/', expand: true }
|
||||
]
|
||||
|
|
2
dist/filtergrid.css
vendored
2
dist/filtergrid.css
vendored
|
@ -1,6 +1,6 @@
|
|||
/*------------------------------------------------------------------------
|
||||
- TableFilter stylesheet by Max Guglielmi
|
||||
- (build date: Sun Nov 23 2014 00:56:49)
|
||||
- (build date: Sun Nov 23 2014 14:31:03)
|
||||
- Edit below for your projects' needs
|
||||
------------------------------------------------------------------------*/
|
||||
|
||||
|
|
10
dist/tablefilter.js
vendored
10
dist/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
438
libs/sortabletable.js
Normal file
438
libs/sortabletable.js
Normal file
|
@ -0,0 +1,438 @@
|
|||
/*----------------------------------------------------------------------------\
|
||||
| Sortable Table 1.12 |
|
||||
|-----------------------------------------------------------------------------|
|
||||
| Created by Erik Arvidsson |
|
||||
| (http://webfx.eae.net/contact.html#erik) |
|
||||
| For WebFX (http://webfx.eae.net/) |
|
||||
|-----------------------------------------------------------------------------|
|
||||
| A DOM 1 based script that allows an ordinary HTML table to be sortable. |
|
||||
|-----------------------------------------------------------------------------|
|
||||
| Copyright (c) 1998 - 2006 Erik Arvidsson |
|
||||
|-----------------------------------------------------------------------------|
|
||||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
|
||||
| use this file except in compliance with the License. You may obtain a copy |
|
||||
| of the License at http://www.apache.org/licenses/LICENSE-2.0 |
|
||||
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
||||
| Unless required by applicable law or agreed to in writing, software |
|
||||
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|
||||
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|
||||
| License for the specific language governing permissions and limitations |
|
||||
| under the License. |
|
||||
|-----------------------------------------------------------------------------|
|
||||
| 2003-01-10 | First version |
|
||||
| 2003-01-19 | Minor changes to the date parsing |
|
||||
| 2003-01-28 | JScript 5.0 fixes (no support for 'in' operator) |
|
||||
| 2003-02-01 | Sloppy typo like error fixed in getInnerText |
|
||||
| 2003-07-04 | Added workaround for IE cellIndex bug. |
|
||||
| 2003-11-09 | The bDescending argument to sort was not correctly working |
|
||||
| | Using onclick DOM0 event if no support for addEventListener |
|
||||
| | or attachEvent |
|
||||
| 2004-01-13 | Adding addSortType and removeSortType which makes it a lot |
|
||||
| | easier to add new, custom sort types. |
|
||||
| 2004-01-27 | Switch to use descending = false as the default sort order. |
|
||||
| | Change defaultDescending to suit your needs. |
|
||||
| 2004-03-14 | Improved sort type None look and feel a bit |
|
||||
| 2004-08-26 | Made the handling of tBody and tHead more flexible. Now you |
|
||||
| | can use another tHead or no tHead, and you can chose some |
|
||||
| | other tBody. |
|
||||
| 2006-04-25 | Changed license to Apache Software License 2.0 |
|
||||
|-----------------------------------------------------------------------------|
|
||||
| Created 2003-01-10 | All changes are in the log above. | Updated 2006-04-25 |
|
||||
\----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
function SortableTable(oTable, oSortTypes) {
|
||||
|
||||
this.sortTypes = oSortTypes || [];
|
||||
|
||||
this.sortColumn = null;
|
||||
this.descending = null;
|
||||
|
||||
var oThis = this;
|
||||
this._headerOnclick = function (e) {
|
||||
oThis.headerOnclick(e);
|
||||
};
|
||||
|
||||
if (oTable) {
|
||||
this.setTable( oTable );
|
||||
this.document = oTable.ownerDocument || oTable.document;
|
||||
}
|
||||
else {
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
|
||||
// only IE needs this
|
||||
var win = this.document.defaultView || this.document.parentWindow;
|
||||
this._onunload = function () {
|
||||
oThis.destroy();
|
||||
};
|
||||
if (win && typeof win.attachEvent != "undefined") {
|
||||
win.attachEvent("onunload", this._onunload);
|
||||
}
|
||||
}
|
||||
|
||||
SortableTable.gecko = navigator.product == "Gecko";
|
||||
SortableTable.msie = /msie/i.test(navigator.userAgent);
|
||||
// Mozilla is faster when doing the DOM manipulations on
|
||||
// an orphaned element. MSIE is not
|
||||
SortableTable.removeBeforeSort = SortableTable.gecko;
|
||||
|
||||
SortableTable.prototype.onsort = function () {};
|
||||
|
||||
// default sort order. true -> descending, false -> ascending
|
||||
SortableTable.prototype.defaultDescending = false;
|
||||
|
||||
// shared between all instances. This is intentional to allow external files
|
||||
// to modify the prototype
|
||||
SortableTable.prototype._sortTypeInfo = {};
|
||||
|
||||
SortableTable.prototype.setTable = function (oTable) {
|
||||
if ( this.tHead )
|
||||
this.uninitHeader();
|
||||
this.element = oTable;
|
||||
this.setTHead( oTable.tHead );
|
||||
this.setTBody( oTable.tBodies[0] );
|
||||
};
|
||||
|
||||
SortableTable.prototype.setTHead = function (oTHead) {
|
||||
if (this.tHead && this.tHead != oTHead )
|
||||
this.uninitHeader();
|
||||
this.tHead = oTHead;
|
||||
this.initHeader( this.sortTypes );
|
||||
};
|
||||
|
||||
SortableTable.prototype.setTBody = function (oTBody) {
|
||||
this.tBody = oTBody;
|
||||
};
|
||||
|
||||
SortableTable.prototype.setSortTypes = function ( oSortTypes ) {
|
||||
if ( this.tHead )
|
||||
this.uninitHeader();
|
||||
this.sortTypes = oSortTypes || [];
|
||||
if ( this.tHead )
|
||||
this.initHeader( this.sortTypes );
|
||||
};
|
||||
|
||||
// adds arrow containers and events
|
||||
// also binds sort type to the header cells so that reordering columns does
|
||||
// not break the sort types
|
||||
SortableTable.prototype.initHeader = function (oSortTypes) {
|
||||
if (!this.tHead) return;
|
||||
var cells = this.tHead.rows[0].cells;
|
||||
var doc = this.tHead.ownerDocument || this.tHead.document;
|
||||
this.sortTypes = oSortTypes || [];
|
||||
var l = cells.length;
|
||||
var img, c;
|
||||
for (var i = 0; i < l; i++) {
|
||||
c = cells[i];
|
||||
if (this.sortTypes[i] != null && this.sortTypes[i] != "None") {
|
||||
img = doc.createElement("IMG");
|
||||
img.src = "images/blank.png";
|
||||
c.appendChild(img);
|
||||
if (this.sortTypes[i] != null)
|
||||
c._sortType = this.sortTypes[i];
|
||||
if (typeof c.addEventListener != "undefined")
|
||||
c.addEventListener("click", this._headerOnclick, false);
|
||||
else if (typeof c.attachEvent != "undefined")
|
||||
c.attachEvent("onclick", this._headerOnclick);
|
||||
else
|
||||
c.onclick = this._headerOnclick;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.setAttribute( "_sortType", oSortTypes[i] );
|
||||
c._sortType = "None";
|
||||
}
|
||||
}
|
||||
this.updateHeaderArrows();
|
||||
};
|
||||
|
||||
// remove arrows and events
|
||||
SortableTable.prototype.uninitHeader = function () {
|
||||
if (!this.tHead) return;
|
||||
var cells = this.tHead.rows[0].cells;
|
||||
var l = cells.length;
|
||||
var c;
|
||||
for (var i = 0; i < l; i++) {
|
||||
c = cells[i];
|
||||
if (c._sortType != null && c._sortType != "None") {
|
||||
c.removeChild(c.lastChild);
|
||||
if (typeof c.removeEventListener != "undefined")
|
||||
c.removeEventListener("click", this._headerOnclick, false);
|
||||
else if (typeof c.detachEvent != "undefined")
|
||||
c.detachEvent("onclick", this._headerOnclick);
|
||||
c._sortType = null;
|
||||
c.removeAttribute( "_sortType" );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SortableTable.prototype.updateHeaderArrows = function () {
|
||||
if (!this.tHead) return;
|
||||
var cells = this.tHead.rows[0].cells;
|
||||
var l = cells.length;
|
||||
var img;
|
||||
for (var i = 0; i < l; i++) {
|
||||
if (cells[i]._sortType != null && cells[i]._sortType != "None") {
|
||||
img = cells[i].lastChild;
|
||||
if (i == this.sortColumn)
|
||||
img.className = "sort-arrow " + (this.descending ? "descending" : "ascending");
|
||||
else
|
||||
img.className = "sort-arrow";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SortableTable.prototype.headerOnclick = function (e) {
|
||||
// find TD element
|
||||
var el = e.target || e.srcElement;
|
||||
while (el.tagName != "TD")
|
||||
el = el.parentNode;
|
||||
|
||||
this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex);
|
||||
};
|
||||
|
||||
// IE returns wrong cellIndex when columns are hidden
|
||||
SortableTable.getCellIndex = function (oTd) {
|
||||
var cells = oTd.parentNode.childNodes
|
||||
var l = cells.length;
|
||||
var i;
|
||||
for (i = 0; cells[i] != oTd && i < l; i++)
|
||||
;
|
||||
return i;
|
||||
};
|
||||
|
||||
SortableTable.prototype.getSortType = function (nColumn) {
|
||||
return this.sortTypes[nColumn] || "String";
|
||||
};
|
||||
|
||||
// only nColumn is required
|
||||
// if bDescending is left out the old value is taken into account
|
||||
// if sSortType is left out the sort type is found from the sortTypes array
|
||||
|
||||
SortableTable.prototype.sort = function (nColumn, bDescending, sSortType) {
|
||||
if (!this.tBody) return;
|
||||
if (sSortType == null)
|
||||
sSortType = this.getSortType(nColumn);
|
||||
|
||||
// exit if None
|
||||
if (sSortType == "None")
|
||||
return;
|
||||
|
||||
if (bDescending == null) {
|
||||
if (this.sortColumn != nColumn)
|
||||
this.descending = this.defaultDescending;
|
||||
else
|
||||
this.descending = !this.descending;
|
||||
}
|
||||
else
|
||||
this.descending = bDescending;
|
||||
|
||||
this.sortColumn = nColumn;
|
||||
|
||||
if (typeof this.onbeforesort == "function")
|
||||
this.onbeforesort();
|
||||
|
||||
var f = this.getSortFunction(sSortType, nColumn);
|
||||
var a = this.getCache(sSortType, nColumn);
|
||||
var tBody = this.tBody;
|
||||
|
||||
a.sort(f);
|
||||
|
||||
if (this.descending)
|
||||
a.reverse();
|
||||
|
||||
if (SortableTable.removeBeforeSort) {
|
||||
// remove from doc
|
||||
var nextSibling = tBody.nextSibling;
|
||||
var p = tBody.parentNode;
|
||||
p.removeChild(tBody);
|
||||
}
|
||||
|
||||
// insert in the new order
|
||||
var l = a.length;
|
||||
for (var i = 0; i < l; i++)
|
||||
tBody.appendChild(a[i].element);
|
||||
|
||||
if (SortableTable.removeBeforeSort) {
|
||||
// insert into doc
|
||||
p.insertBefore(tBody, nextSibling);
|
||||
}
|
||||
|
||||
this.updateHeaderArrows();
|
||||
|
||||
this.destroyCache(a);
|
||||
|
||||
if (typeof this.onsort == "function")
|
||||
this.onsort();
|
||||
};
|
||||
|
||||
SortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) {
|
||||
var oThis = this;
|
||||
this._asyncsort = function () {
|
||||
oThis.sort(nColumn, bDescending, sSortType);
|
||||
};
|
||||
window.setTimeout(this._asyncsort, 1);
|
||||
};
|
||||
|
||||
SortableTable.prototype.getCache = function (sType, nColumn) {
|
||||
if (!this.tBody) return [];
|
||||
var rows = this.tBody.rows;
|
||||
var l = rows.length;
|
||||
var a = new Array(l);
|
||||
var r;
|
||||
for (var i = 0; i < l; i++) {
|
||||
r = rows[i];
|
||||
a[i] = {
|
||||
value: this.getRowValue(r, sType, nColumn),
|
||||
element: r
|
||||
};
|
||||
};
|
||||
return a;
|
||||
};
|
||||
|
||||
SortableTable.prototype.destroyCache = function (oArray) {
|
||||
var l = oArray.length;
|
||||
for (var i = 0; i < l; i++) {
|
||||
oArray[i].value = null;
|
||||
oArray[i].element = null;
|
||||
oArray[i] = null;
|
||||
}
|
||||
};
|
||||
|
||||
SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {
|
||||
// if we have defined a custom getRowValue use that
|
||||
if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)
|
||||
return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);
|
||||
|
||||
var s;
|
||||
var c = oRow.cells[nColumn];
|
||||
if (typeof c.innerText != "undefined")
|
||||
s = c.innerText;
|
||||
else
|
||||
s = SortableTable.getInnerText(c);
|
||||
return this.getValueFromString(s, sType);
|
||||
};
|
||||
|
||||
SortableTable.getInnerText = function (oNode) {
|
||||
var s = "";
|
||||
var cs = oNode.childNodes;
|
||||
var l = cs.length;
|
||||
for (var i = 0; i < l; i++) {
|
||||
switch (cs[i].nodeType) {
|
||||
case 1: //ELEMENT_NODE
|
||||
s += SortableTable.getInnerText(cs[i]);
|
||||
break;
|
||||
case 3: //TEXT_NODE
|
||||
s += cs[i].nodeValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
SortableTable.prototype.getValueFromString = function (sText, sType) {
|
||||
if (this._sortTypeInfo[sType])
|
||||
return this._sortTypeInfo[sType].getValueFromString( sText );
|
||||
return sText;
|
||||
/*
|
||||
switch (sType) {
|
||||
case "Number":
|
||||
return Number(sText);
|
||||
case "CaseInsensitiveString":
|
||||
return sText.toUpperCase();
|
||||
case "Date":
|
||||
var parts = sText.split("-");
|
||||
var d = new Date(0);
|
||||
d.setFullYear(parts[0]);
|
||||
d.setDate(parts[2]);
|
||||
d.setMonth(parts[1] - 1);
|
||||
return d.valueOf();
|
||||
}
|
||||
return sText;
|
||||
*/
|
||||
};
|
||||
|
||||
SortableTable.prototype.getSortFunction = function (sType, nColumn) {
|
||||
if (this._sortTypeInfo[sType])
|
||||
return this._sortTypeInfo[sType].compare;
|
||||
return SortableTable.basicCompare;
|
||||
};
|
||||
|
||||
SortableTable.prototype.destroy = function () {
|
||||
this.uninitHeader();
|
||||
var win = this.document.parentWindow;
|
||||
if (win && typeof win.detachEvent != "undefined") { // only IE needs this
|
||||
win.detachEvent("onunload", this._onunload);
|
||||
}
|
||||
this._onunload = null;
|
||||
this.element = null;
|
||||
this.tHead = null;
|
||||
this.tBody = null;
|
||||
this.document = null;
|
||||
this._headerOnclick = null;
|
||||
this.sortTypes = null;
|
||||
this._asyncsort = null;
|
||||
this.onsort = null;
|
||||
};
|
||||
|
||||
// Adds a sort type to all instance of SortableTable
|
||||
// sType : String - the identifier of the sort type
|
||||
// fGetValueFromString : function ( s : string ) : T - A function that takes a
|
||||
// string and casts it to a desired format. If left out the string is just
|
||||
// returned
|
||||
// fCompareFunction : function ( n1 : T, n2 : T ) : Number - A normal JS sort
|
||||
// compare function. Takes two values and compares them. If left out less than,
|
||||
// <, compare is used
|
||||
// fGetRowValue : function( oRow : HTMLTRElement, nColumn : int ) : T - A function
|
||||
// that takes the row and the column index and returns the value used to compare.
|
||||
// If left out then the innerText is first taken for the cell and then the
|
||||
// fGetValueFromString is used to convert that string the desired value and type
|
||||
|
||||
SortableTable.prototype.addSortType = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) {
|
||||
this._sortTypeInfo[sType] = {
|
||||
type: sType,
|
||||
getValueFromString: fGetValueFromString || SortableTable.idFunction,
|
||||
compare: fCompareFunction || SortableTable.basicCompare,
|
||||
getRowValue: fGetRowValue
|
||||
};
|
||||
};
|
||||
|
||||
// this removes the sort type from all instances of SortableTable
|
||||
SortableTable.prototype.removeSortType = function (sType) {
|
||||
delete this._sortTypeInfo[sType];
|
||||
};
|
||||
|
||||
SortableTable.basicCompare = function compare(n1, n2) {
|
||||
if (n1.value < n2.value)
|
||||
return -1;
|
||||
if (n2.value < n1.value)
|
||||
return 1;
|
||||
return 0;
|
||||
};
|
||||
|
||||
SortableTable.idFunction = function (x) {
|
||||
return x;
|
||||
};
|
||||
|
||||
SortableTable.toUpperCase = function (s) {
|
||||
return s.toUpperCase();
|
||||
};
|
||||
|
||||
SortableTable.toDate = function (s) {
|
||||
var parts = s.split("-");
|
||||
var d = new Date(0);
|
||||
d.setFullYear(parts[0]);
|
||||
d.setDate(parts[2]);
|
||||
d.setMonth(parts[1] - 1);
|
||||
return d.valueOf();
|
||||
};
|
||||
|
||||
|
||||
// add sort types
|
||||
SortableTable.prototype.addSortType("Number", Number);
|
||||
SortableTable.prototype.addSortType("CaseInsensitiveString", SortableTable.toUpperCase);
|
||||
SortableTable.prototype.addSortType("Date", SortableTable.toDate);
|
||||
SortableTable.prototype.addSortType("String");
|
||||
// None is a special case
|
|
@ -32,7 +32,7 @@ export class GridLayout{
|
|||
this.gridDefaultColWidth = f.grid_default_col_width || '100px';
|
||||
//enables/disables columns resizer
|
||||
this.gridEnableColResizer = f.grid_enable_cols_resizer!==undefined ?
|
||||
f.grid_enable_cols_resizer : true;
|
||||
f.grid_enable_cols_resizer : false;
|
||||
//defines col resizer script path
|
||||
this.gridColResizerPath = f.grid_cont_col_resizer_path ||
|
||||
this.basePath+'TFExt_ColsResizer/TFExt_ColsResizer.js';
|
||||
|
@ -47,15 +47,15 @@ export class GridLayout{
|
|||
|
||||
tf.isExternalFlt = true;
|
||||
|
||||
// in case column widths are not set default width 100px
|
||||
// default width of 100px if column widths not set
|
||||
if(!tf.hasColWidth){
|
||||
tf.colWidth = [];
|
||||
for(var k=0; k<tf.nbCells; k++){
|
||||
var colW,
|
||||
cell = tbl.rows[this.gridHeadRowIndex].cells[k];
|
||||
if(cell.width!==''){
|
||||
if(cell.width !== ''){
|
||||
colW = cell.width;
|
||||
} else if(cell.style.width!==''){
|
||||
} else if(cell.style.width !== ''){
|
||||
colW = parseInt(cell.style.width, 10);
|
||||
} else {
|
||||
colW = this.gridDefaultColWidth;
|
||||
|
@ -67,10 +67,10 @@ export class GridLayout{
|
|||
tf.SetColWidths(this.gridHeadRowIndex);
|
||||
|
||||
var tblW;//initial table width
|
||||
if(tbl.width!==''){
|
||||
if(tbl.width !== ''){
|
||||
tblW = tbl.width;
|
||||
}
|
||||
else if(tbl.style.width!==''){
|
||||
else if(tbl.style.width !== ''){
|
||||
tblW = parseInt(tbl.style.width, 10);
|
||||
} else {
|
||||
tblW = tbl.clientWidth;
|
||||
|
@ -82,7 +82,7 @@ export class GridLayout{
|
|||
if(this.gridWidth){
|
||||
this.tblMainCont.style.width = this.gridWidth;
|
||||
}
|
||||
tbl.parentNode.insertBefore(this.tblMainCont, tf.tbl);
|
||||
tbl.parentNode.insertBefore(this.tblMainCont, tbl);
|
||||
|
||||
//Table container: div wrapping content table
|
||||
this.tblCont = Dom.create('div',['id', tf.prfxTblCont + tf.id]);
|
||||
|
@ -93,8 +93,8 @@ export class GridLayout{
|
|||
if(this.gridHeight){
|
||||
this.tblCont.style.height = this.gridHeight;
|
||||
}
|
||||
tbl.parentNode.insertBefore(this.tblCont, tf.tbl);
|
||||
var t = tbl.parentNode.removeChild(tf.tbl);
|
||||
tbl.parentNode.insertBefore(this.tblCont, tbl);
|
||||
var t = tbl.parentNode.removeChild(tbl);
|
||||
this.tblCont.appendChild(t);
|
||||
|
||||
//In case table width is expressed in %
|
||||
|
@ -159,7 +159,7 @@ export class GridLayout{
|
|||
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
|
||||
|
||||
//THead needs to be removed in content table for sort feature
|
||||
var thead = Dom.tag(tf.tbl, 'thead');
|
||||
var thead = Dom.tag(tbl, 'thead');
|
||||
if(thead.length>0){
|
||||
tbl.removeChild(thead[0]);
|
||||
}
|
||||
|
@ -186,17 +186,18 @@ export class GridLayout{
|
|||
var o = this; //TF object
|
||||
|
||||
Event.add(this.tblCont, 'scroll', function(){
|
||||
o.headTblCont.scrollLeft = this.scrollLeft;
|
||||
var _o = this; //this = scroll element
|
||||
//this = scroll element
|
||||
var scrollLeft = this.scrollLeft;
|
||||
o.headTblCont.scrollLeft = scrollLeft;
|
||||
//New pointerX calc taking into account scrollLeft
|
||||
if(!o.isPointerXOverwritten){
|
||||
try{
|
||||
o.Evt.pointerX = function(e){
|
||||
e = e || global.event;
|
||||
var scrollLeft = tf_StandardBody().scrollLeft +
|
||||
_o.scrollLeft;
|
||||
return (e.pageX + _o.scrollLeft) ||
|
||||
(e.clientX + scrollLeft);
|
||||
o.Evt.pointerX = function(evt){
|
||||
var e = evt || global.event;
|
||||
var bdScrollLeft = tf_StandardBody().scrollLeft +
|
||||
scrollLeft;
|
||||
return (e.pageX + scrollLeft) ||
|
||||
(e.clientX + bdScrollLeft);
|
||||
};
|
||||
o.isPointerXOverwritten = true;
|
||||
} catch(err) {
|
||||
|
@ -349,6 +350,7 @@ export class GridLayout{
|
|||
tbl.style.width = this.headTbl.clientWidth+'px';
|
||||
}
|
||||
|
||||
// Re-adjust reference row
|
||||
tf.refRow = Helpers.isIE() ? (tf.refRow+1) : 0;
|
||||
}
|
||||
|
||||
|
@ -369,6 +371,7 @@ export class GridLayout{
|
|||
this.tblCont = null;
|
||||
|
||||
tbl.outerHTML = tf.sourceTblHtml;
|
||||
tbl = Dom.id(tf.id); //needed to keep reference
|
||||
//needed to keep reference of table element
|
||||
tbl = Dom.id(tf.id);
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
//default col width
|
||||
this.gridDefaultColWidth = f.grid_default_col_width || "100px";
|
||||
//enables/disables columns resizer
|
||||
this.gridEnableColResizer = f.grid_enable_cols_resizer !== undefined ? f.grid_enable_cols_resizer : true;
|
||||
this.gridEnableColResizer = f.grid_enable_cols_resizer !== undefined ? f.grid_enable_cols_resizer : false;
|
||||
//defines col resizer script path
|
||||
this.gridColResizerPath = f.grid_cont_col_resizer_path || this.basePath + "TFExt_ColsResizer/TFExt_ColsResizer.js";
|
||||
|
||||
|
@ -52,7 +52,7 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
|
||||
tf.isExternalFlt = true;
|
||||
|
||||
// in case column widths are not set default width 100px
|
||||
// default width of 100px if column widths not set
|
||||
if (!tf.hasColWidth) {
|
||||
tf.colWidth = [];
|
||||
for (var k = 0; k < tf.nbCells; k++) {
|
||||
|
@ -85,7 +85,7 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
if (this.gridWidth) {
|
||||
this.tblMainCont.style.width = this.gridWidth;
|
||||
}
|
||||
tbl.parentNode.insertBefore(this.tblMainCont, tf.tbl);
|
||||
tbl.parentNode.insertBefore(this.tblMainCont, tbl);
|
||||
|
||||
//Table container: div wrapping content table
|
||||
this.tblCont = Dom.create("div", ["id", tf.prfxTblCont + tf.id]);
|
||||
|
@ -96,8 +96,8 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
if (this.gridHeight) {
|
||||
this.tblCont.style.height = this.gridHeight;
|
||||
}
|
||||
tbl.parentNode.insertBefore(this.tblCont, tf.tbl);
|
||||
var t = tbl.parentNode.removeChild(tf.tbl);
|
||||
tbl.parentNode.insertBefore(this.tblCont, tbl);
|
||||
var t = tbl.parentNode.removeChild(tbl);
|
||||
this.tblCont.appendChild(t);
|
||||
|
||||
//In case table width is expressed in %
|
||||
|
@ -160,7 +160,7 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
|
||||
|
||||
//THead needs to be removed in content table for sort feature
|
||||
var thead = Dom.tag(tf.tbl, "thead");
|
||||
var thead = Dom.tag(tbl, "thead");
|
||||
if (thead.length > 0) {
|
||||
tbl.removeChild(thead[0]);
|
||||
}
|
||||
|
@ -187,15 +187,16 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
var o = this; //TF object
|
||||
|
||||
Event.add(this.tblCont, "scroll", function () {
|
||||
o.headTblCont.scrollLeft = this.scrollLeft;
|
||||
var _o = this; //this = scroll element
|
||||
//this = scroll element
|
||||
var scrollLeft = this.scrollLeft;
|
||||
o.headTblCont.scrollLeft = scrollLeft;
|
||||
//New pointerX calc taking into account scrollLeft
|
||||
if (!o.isPointerXOverwritten) {
|
||||
try {
|
||||
o.Evt.pointerX = function (e) {
|
||||
e = e || global.event;
|
||||
var scrollLeft = tf_StandardBody().scrollLeft + _o.scrollLeft;
|
||||
return (e.pageX + _o.scrollLeft) || (e.clientX + scrollLeft);
|
||||
o.Evt.pointerX = function (evt) {
|
||||
var e = evt || global.event;
|
||||
var bdScrollLeft = tf_StandardBody().scrollLeft + scrollLeft;
|
||||
return (e.pageX + scrollLeft) || (e.clientX + bdScrollLeft);
|
||||
};
|
||||
o.isPointerXOverwritten = true;
|
||||
} catch (err) {
|
||||
|
@ -344,6 +345,7 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
tbl.style.width = this.headTbl.clientWidth + "px";
|
||||
}
|
||||
|
||||
// Re-adjust reference row
|
||||
tf.refRow = Helpers.isIE() ? (tf.refRow + 1) : 0;
|
||||
}
|
||||
},
|
||||
|
@ -366,7 +368,8 @@ define(["exports", "../dom", "../types", "../helpers", "../event"], function (ex
|
|||
this.tblCont = null;
|
||||
|
||||
tbl.outerHTML = tf.sourceTblHtml;
|
||||
tbl = Dom.id(tf.id); //needed to keep reference
|
||||
//needed to keep reference of table element
|
||||
tbl = Dom.id(tf.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,30 @@
|
|||
requirejs(['test-config', '../src/core'], function(config, TableFilter){
|
||||
|
||||
QUnit.start();
|
||||
|
||||
var GridLayout = require('modules/gridLayout').GridLayout;
|
||||
|
||||
var tf = new TableFilter('demo', {
|
||||
grid_layout: true
|
||||
});
|
||||
tf.init();
|
||||
|
||||
module('Sanity checks');
|
||||
test('GridLayout component', function() {
|
||||
deepEqual(tf.Cpt.gridLayout instanceof GridLayout, true, 'GridLayout type');
|
||||
notEqual(tf.Cpt.gridLayout, null, 'GridLayout instanciated');
|
||||
notEqual(tf.Cpt.gridLayout.tblMainCont, null, 'GridLayout main container element');
|
||||
notEqual(tf.Cpt.gridLayout.tblCont, null, 'GridLayout main HTML table container element');
|
||||
notEqual(tf.Cpt.gridLayout.headTblCont, null, 'GridLayout headers container element');
|
||||
notEqual(tf.Cpt.gridLayout.headTbl, null, 'GridLayout headers HTML table');
|
||||
});
|
||||
|
||||
test('Destroy GridLayout component', function() {
|
||||
tf.Cpt.gridLayout.destroy();
|
||||
deepEqual(tf.Cpt.gridLayout.tblMainCont, null, 'Main container element removed');
|
||||
deepEqual(tf.Cpt.gridLayout.tblCont, null, 'Main HTML table container element removed');
|
||||
deepEqual(tf.Cpt.gridLayout.headTblCont, null, 'Headers container element removed');
|
||||
deepEqual(tf.Cpt.gridLayout.headTbl, null, 'Headers HTML table element removed');
|
||||
});
|
||||
|
||||
});
|
|
@ -2,8 +2,7 @@ requirejs(['test-config', '../src/core'], function(config, TableFilter){
|
|||
|
||||
QUnit.start();
|
||||
|
||||
var dom = require('dom'),
|
||||
RowsCounter = require('modules/rowsCounter').RowsCounter;
|
||||
var RowsCounter = require('modules/rowsCounter').RowsCounter;
|
||||
|
||||
var tf = new TableFilter('demo', {
|
||||
rows_counter: true
|
||||
|
@ -12,7 +11,7 @@ requirejs(['test-config', '../src/core'], function(config, TableFilter){
|
|||
|
||||
module('Sanity checks');
|
||||
test('RowsCounter component', function() {
|
||||
deepEqual(tf.Cpt.rowsCounter instanceof RowsCounter, true, 'RowsCounter constructor');
|
||||
deepEqual(tf.Cpt.rowsCounter instanceof RowsCounter, true, 'RowsCounter type');
|
||||
notEqual(tf.Cpt.rowsCounter, null, 'RowsCounter instanciated');
|
||||
equal(tf.Cpt.rowsCounter.rowsCounterSpan.innerHTML, 7, 'Counter value');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue