mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-23 16:52:26 +02:00
Init formatting
This commit is contained in:
parent
620b22d228
commit
e41d3a631c
|
@ -30,7 +30,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
Raya, Piepiax, Manuel Kern, Baladhandayutham for active contribution
|
Raya, Piepiax, Manuel Kern, Baladhandayutham for active contribution
|
||||||
and/or inspiration
|
and/or inspiration
|
||||||
------------------------------------------------------------------------*/
|
------------------------------------------------------------------------*/
|
||||||
var TF = (function() {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TF object constructor
|
* TF object constructor
|
||||||
|
@ -44,7 +43,7 @@ var TF = (function() {
|
||||||
this.version = '2.5';
|
this.version = '2.5';
|
||||||
this.year = new Date().getFullYear();
|
this.year = new Date().getFullYear();
|
||||||
this.tbl = tf_Id(id);
|
this.tbl = tf_Id(id);
|
||||||
this.startRow = undefined;
|
this.startRow = null;
|
||||||
this.refRow = null;
|
this.refRow = null;
|
||||||
this.headersRow = null;
|
this.headersRow = null;
|
||||||
this.fObj = null;
|
this.fObj = null;
|
||||||
|
@ -75,10 +74,11 @@ var TF = (function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var f = !this.fObj ? {} : this.fObj;
|
// configuration object
|
||||||
|
var f = this.fObj || {};
|
||||||
|
|
||||||
//Start row et cols nb
|
//Start row et cols nb
|
||||||
this.refRow = this.startRow===undefined ? 2 : (this.startRow+1);
|
this.refRow = this.startRow===null ? 2 : (this.startRow+1);
|
||||||
try{ this.nbCells = this.GetCellsNb(this.refRow); }
|
try{ this.nbCells = this.GetCellsNb(this.refRow); }
|
||||||
catch(e){ this.nbCells = this.GetCellsNb(0); }
|
catch(e){ this.nbCells = this.GetCellsNb(0); }
|
||||||
|
|
||||||
|
@ -706,18 +706,19 @@ var TF = (function() {
|
||||||
loadextensions: 'LoadExtensions',
|
loadextensions: 'LoadExtensions',
|
||||||
loadthemes: 'LoadThemes'
|
loadthemes: 'LoadThemes'
|
||||||
},
|
},
|
||||||
|
getKeyCode: function(e){
|
||||||
|
return e.charCode ? evt.charCode :
|
||||||
|
(evt.keyCode ? evt.keyCode: (evt.which ? evt.which : 0));
|
||||||
|
},
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- Detects <enter> key for a given element
|
- Detects <enter> key for a given element
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
_DetectKey: function(e) {
|
_DetectKey: function(e) {
|
||||||
if(!o.enterKey) return;
|
if(!o.enterKey){ return; }
|
||||||
var evt = e || window.event;
|
var evt = e || window.event;
|
||||||
if(evt)
|
if(evt){
|
||||||
{
|
var key = o.Evt.getKeyCode(evt);
|
||||||
var key=(evt.charCode)?evt.charCode:
|
if(key===13){
|
||||||
((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
|
|
||||||
if(key=='13')
|
|
||||||
{
|
|
||||||
o._Filter();
|
o._Filter();
|
||||||
tf_CancelEvent(evt);
|
tf_CancelEvent(evt);
|
||||||
tf_StopEvent(evt);
|
tf_StopEvent(evt);
|
||||||
|
@ -734,11 +735,9 @@ var TF = (function() {
|
||||||
_OnKeyUp: function(e) {
|
_OnKeyUp: function(e) {
|
||||||
if(!o.onKeyUp) return;
|
if(!o.onKeyUp) return;
|
||||||
var evt = e || window.event;
|
var evt = e || window.event;
|
||||||
var key=(evt.charCode)?evt.charCode:
|
var key = o.Evt.getKeyCode(evt);
|
||||||
((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
|
|
||||||
o.isUserTyping = false;
|
o.isUserTyping = false;
|
||||||
|
|
||||||
if(key!=13 && key!=9 && key!=27 && key!=38 && key!=40) {
|
|
||||||
function filter() {
|
function filter() {
|
||||||
window.clearInterval(o.onKeyUpTimer);
|
window.clearInterval(o.onKeyUpTimer);
|
||||||
o.onKeyUpTimer = undefined;
|
o.onKeyUpTimer = undefined;
|
||||||
|
@ -748,8 +747,11 @@ var TF = (function() {
|
||||||
o.isUserTyping = null;
|
o.isUserTyping = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(o.onKeyUpTimer===undefined)
|
|
||||||
|
if(key!==13 && key!==9 && key!==27 && key!==38 && key!==40) {
|
||||||
|
if(o.onKeyUpTimer===undefined){
|
||||||
o.onKeyUpTimer = window.setInterval(filter, o.onKeyUpDelay);
|
o.onKeyUpTimer = window.setInterval(filter, o.onKeyUpDelay);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
window.clearInterval(o.onKeyUpTimer);
|
window.clearInterval(o.onKeyUpTimer);
|
||||||
o.onKeyUpTimer = undefined;
|
o.onKeyUpTimer = undefined;
|
||||||
|
@ -915,80 +917,103 @@ var TF = (function() {
|
||||||
|
|
||||||
TF.prototype = {
|
TF.prototype = {
|
||||||
|
|
||||||
AddGrid: function()
|
AddGrid: function(){ this._AddGrid();},
|
||||||
{
|
Init: function(){ this.AddGrid(); },
|
||||||
this._AddGrid();
|
Initialize: function(){ this.AddGrid(); },
|
||||||
}, Init : function(){ this.AddGrid(); }, Initialize : function(){ this.AddGrid(); },
|
init: function(){ this.AddGrid(); },
|
||||||
init : function(){ this.AddGrid(); }, initialize : function(){ this.AddGrid(); },
|
initialize: function(){ this.AddGrid(); },
|
||||||
|
|
||||||
_AddGrid: function()
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- adds row with filtering grid bar and sets grid
|
- adds row with filtering grid bar and sets grid
|
||||||
behaviours and layout
|
behaviours and layout
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
_AddGrid: function(){
|
||||||
if(this.hasGrid) return;
|
if(this.hasGrid) return;
|
||||||
if(this.gridLayout) this.refRow = this.startRow==undefined ? 0 : this.startRow;
|
if(this.gridLayout){
|
||||||
if(this.popUpFilters && ((this.filtersRowIndex==0 && this.headersRow == 1) || this.gridLayout)) this.headersRow = 0;
|
this.refRow = this.startRow===null ? 0 : this.startRow;
|
||||||
var f = !this.fObj ? {} : this.fObj;
|
}
|
||||||
var n = (this.singleSearchFlt) ? 1 : this.nbCells, inpclass;
|
if(this.popUpFilters &&
|
||||||
if(window['tf_'+this.id] == undefined) window['tf_'+this.id] = this;
|
((this.filtersRowIndex === 0 && this.headersRow === 1) ||
|
||||||
|
this.gridLayout)){
|
||||||
|
this.headersRow = 0;
|
||||||
|
}
|
||||||
|
var f = this.fObj || {},
|
||||||
|
n = this.singleSearchFlt ? 1 : this.nbCells,
|
||||||
|
inpclass;
|
||||||
|
|
||||||
|
if(window['tf_'+this.id] === undefined){
|
||||||
|
window['tf_'+this.id] = this;
|
||||||
|
}
|
||||||
|
|
||||||
//loads stylesheet if not imported
|
//loads stylesheet if not imported
|
||||||
//Issues with browsers != IE, IE rules in this case
|
//Issues with browsers != IE, IE rules in this case
|
||||||
this.IncludeFile(this.stylesheetId, this.stylesheet, null, 'link');
|
this.IncludeFile(this.stylesheetId, this.stylesheet, null, 'link');
|
||||||
|
|
||||||
//loads theme
|
//loads theme
|
||||||
if(this.hasThemes) this._LoadThemes();
|
if(this.hasThemes){ this._LoadThemes(); }
|
||||||
|
|
||||||
if(this.gridLayout)
|
if(this.gridLayout){
|
||||||
{
|
|
||||||
this.isExternalFlt = true;
|
this.isExternalFlt = true;
|
||||||
this.SetGridLayout();
|
this.SetGridLayout();
|
||||||
//Once grid generated 1st filterable row is 0 again
|
//Once grid generated 1st filterable row is 0 again
|
||||||
this.refRow = (tf_isIE || tf_isIE7) ? (this.refRow+1) : 0;
|
this.refRow = (tf_isIE || tf_isIE7) ? (this.refRow+1) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.loader) this.SetLoader();
|
if(this.loader){ this.SetLoader(); }
|
||||||
|
|
||||||
if(this.popUpFilters){ if(!this.isFirstLoad && !this.gridLayout){ this.headersRow--; } this.SetPopupFilterIcons(); }
|
if(this.popUpFilters){
|
||||||
|
if(!this.isFirstLoad && !this.gridLayout){
|
||||||
if(this.hasResultsPerPage)
|
this.headersRow--;
|
||||||
{
|
}
|
||||||
this.resultsPerPage = f['results_per_page']!=undefined
|
this.SetPopupFilterIcons();
|
||||||
? f['results_per_page'] : this.resultsPerPage;
|
|
||||||
if(this.resultsPerPage.length<2)
|
|
||||||
this.hasResultsPerPage = false;
|
|
||||||
else
|
|
||||||
this.pagingLength = this.resultsPerPage[1][0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.fltGrid)
|
if(this.hasResultsPerPage){
|
||||||
{//filters grid is not genetared
|
this.resultsPerPage = f['results_per_page'] || this.resultsPerPage;
|
||||||
this.refRow = (this.refRow-1);
|
if(this.resultsPerPage.length<2){
|
||||||
if(this.gridLayout) this.refRow = 0;
|
this.hasResultsPerPage = false;
|
||||||
|
} else {
|
||||||
|
this.pagingLength = this.resultsPerPage[1][0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//filters grid is not generated
|
||||||
|
if(!this.fltGrid){
|
||||||
|
this.refRow = this.refRow-1;
|
||||||
|
if(this.gridLayout){
|
||||||
|
this.refRow = 0;
|
||||||
|
}
|
||||||
this.nbFilterableRows = this.GetRowsNb();
|
this.nbFilterableRows = this.GetRowsNb();
|
||||||
this.nbVisibleRows = this.nbFilterableRows;
|
this.nbVisibleRows = this.nbFilterableRows;
|
||||||
this.nbRows = this.nbFilterableRows + this.refRow;
|
this.nbRows = this.nbFilterableRows + this.refRow;
|
||||||
} else {
|
} else {
|
||||||
if(this.isFirstLoad)
|
if(this.isFirstLoad){
|
||||||
{
|
|
||||||
if(!this.gridLayout){
|
|
||||||
var fltrow;
|
var fltrow;
|
||||||
|
if(!this.gridLayout){
|
||||||
var thead = tf_Tag(this.tbl,'thead');
|
var thead = tf_Tag(this.tbl,'thead');
|
||||||
if(thead.length>0)
|
if(thead.length > 0){
|
||||||
fltrow = thead[0].insertRow(this.filtersRowIndex);
|
fltrow = thead[0].insertRow(this.filtersRowIndex);
|
||||||
else
|
} else {
|
||||||
fltrow = this.tbl.insertRow(this.filtersRowIndex);
|
fltrow = this.tbl.insertRow(this.filtersRowIndex);
|
||||||
|
}
|
||||||
|
|
||||||
if(this.headersRow>1 && this.filtersRowIndex <= this.headersRow && !this.popUpFilters) this.headersRow++;
|
if(this.headersRow > 1 &&
|
||||||
if(this.popUpFilters) this.headersRow++;
|
this.filtersRowIndex <= this.headersRow &&
|
||||||
|
!this.popUpFilters){
|
||||||
if(this.fixedHeaders) this.SetFixedHeaders();
|
this.headersRow++;
|
||||||
|
}
|
||||||
|
if(this.popUpFilters){
|
||||||
|
this.headersRow++;
|
||||||
|
}
|
||||||
|
if(this.fixedHeaders){
|
||||||
|
this.SetFixedHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
fltrow.className = this.fltsRowCssClass;
|
fltrow.className = this.fltsRowCssClass;
|
||||||
//Disable for grid_layout
|
//Disable for grid_layout
|
||||||
if(this.isExternalFlt && (!this.gridLayout || this.popUpFilters)) fltrow.style.display = 'none';
|
if(this.isExternalFlt &&
|
||||||
|
(!this.gridLayout || this.popUpFilters)){
|
||||||
|
fltrow.style.display = 'none';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.nbFilterableRows = this.GetRowsNb();
|
this.nbFilterableRows = this.GetRowsNb();
|
||||||
|
@ -996,39 +1021,53 @@ var TF = (function() {
|
||||||
this.nbRows = this.tbl.rows.length;
|
this.nbRows = this.tbl.rows.length;
|
||||||
|
|
||||||
for(var i=0; i<n; i++){// this loop adds filters
|
for(var i=0; i<n; i++){// this loop adds filters
|
||||||
var fltcell = tf_CreateElm(this.fltCellTag);
|
var fltcell = tf_CreateElm(this.fltCellTag),
|
||||||
if(this.singleSearchFlt) fltcell.colSpan = this.nbCells;
|
col = this['col'+i],
|
||||||
if(!this.gridLayout) fltrow.appendChild(fltcell);
|
externalFltTgtId =
|
||||||
inpclass = (i==n-1 && this.displayBtn) ? this.fltSmallCssClass : this.fltCssClass;
|
this.isExternalFlt && this.externalFltTgtIds ?
|
||||||
|
this.externalFltTgtIds[i] : null;
|
||||||
|
|
||||||
if(this.popUpFilters) this.SetPopupFilter(i);
|
if(this.singleSearchFlt){
|
||||||
|
fltcell.colSpan = this.nbCells;
|
||||||
|
}
|
||||||
|
if(!this.gridLayout){
|
||||||
|
fltrow.appendChild(fltcell);
|
||||||
|
}
|
||||||
|
inpclass = (i==n-1 && this.displayBtn) ?
|
||||||
|
this.fltSmallCssClass : this.fltCssClass;
|
||||||
|
|
||||||
if(this['col'+i]==undefined)
|
if(this.popUpFilters){
|
||||||
this['col'+i] = (f['col_'+i]==undefined)
|
this.SetPopupFilter(i);
|
||||||
? this.fltTypeInp : f['col_'+i].tf_LCase();
|
}
|
||||||
|
|
||||||
if(this.singleSearchFlt)
|
if(col===undefined){
|
||||||
{//only 1 input for single search
|
col = f['col_'+i]===undefined ?
|
||||||
this['col'+i] = this.fltTypeInp;
|
this.fltTypeInp : f['col_'+i].tf_LCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
//only 1 input for single search
|
||||||
|
if(this.singleSearchFlt){
|
||||||
|
col = this.fltTypeInp;
|
||||||
inpclass = this.singleFltCssClass;
|
inpclass = this.singleFltCssClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this['col'+i]==this.fltTypeSlc || this['col'+i]==this.fltTypeMulti)
|
//selects
|
||||||
{//selects
|
if(col===this.fltTypeSlc ||
|
||||||
|
col===this.fltTypeMulti){
|
||||||
var slc = tf_CreateElm(this.fltTypeSlc,
|
var slc = tf_CreateElm(this.fltTypeSlc,
|
||||||
['id',this.prfxFlt+i+'_'+this.id],
|
['id',this.prfxFlt+i+'_'+this.id],
|
||||||
['ct',i], ['filled','0']);
|
['ct',i], ['filled','0']);
|
||||||
if(this['col'+i]==this.fltTypeMulti)
|
|
||||||
{
|
if(col===this.fltTypeMulti){
|
||||||
slc.multiple = this.fltTypeMulti;
|
slc.multiple = this.fltTypeMulti;
|
||||||
slc.title = this.multipleSlcTooltip;
|
slc.title = this.multipleSlcTooltip;
|
||||||
}
|
}
|
||||||
slc.className = (this['col'+i].tf_LCase()==this.fltTypeSlc)
|
slc.className = (col.tf_LCase()===this.fltTypeSlc) ?
|
||||||
? inpclass : this.fltMultiCssClass;// for ie<=6
|
inpclass : this.fltMultiCssClass;// for ie<=6
|
||||||
|
|
||||||
if(this.isExternalFlt && this.externalFltTgtIds && tf_Id(this.externalFltTgtIds[i]))
|
//filter is appended in desired element
|
||||||
{//filter is appended in desired element
|
if(externalFltTgtId){
|
||||||
tf_Id(this.externalFltTgtIds[i]).appendChild(slc);
|
tf_Id(externalFltTgtId).appendChild(slc);
|
||||||
this.externalFltEls.push(slc);
|
this.externalFltEls.push(slc);
|
||||||
} else {
|
} else {
|
||||||
fltcell.appendChild(slc);
|
fltcell.appendChild(slc);
|
||||||
|
@ -1036,15 +1075,18 @@ var TF = (function() {
|
||||||
|
|
||||||
this.fltIds.push(this.prfxFlt+i+'_'+this.id);
|
this.fltIds.push(this.prfxFlt+i+'_'+this.id);
|
||||||
|
|
||||||
if(!this.fillSlcOnDemand) this._PopulateSelect(i);
|
if(!this.fillSlcOnDemand){
|
||||||
|
this._PopulateSelect(i);
|
||||||
|
}
|
||||||
|
|
||||||
slc.onkeypress = this.Evt._DetectKey;
|
slc.onkeypress = this.Evt._DetectKey;
|
||||||
slc.onchange = this.Evt._OnSlcChange;
|
slc.onchange = this.Evt._OnSlcChange;
|
||||||
slc.onfocus = this.Evt._OnSlcFocus;
|
slc.onfocus = this.Evt._OnSlcFocus;
|
||||||
slc.onblur = this.Evt._OnSlcBlur;
|
slc.onblur = this.Evt._OnSlcBlur;
|
||||||
|
|
||||||
if(this.fillSlcOnDemand)
|
//1st option is created here since PopulateSelect isn't
|
||||||
{//1st option is created here since PopulateSelect isn't invoked
|
//invoked
|
||||||
|
if(this.fillSlcOnDemand){
|
||||||
var opt0 = tf_CreateOpt(this.displayAllText,'');
|
var opt0 = tf_CreateOpt(this.displayAllText,'');
|
||||||
slc.appendChild(opt0);
|
slc.appendChild(opt0);
|
||||||
}
|
}
|
||||||
|
@ -1056,27 +1098,25 @@ var TF = (function() {
|
||||||
select is disabled and by clicking on element
|
select is disabled and by clicking on element
|
||||||
(parent td), users enable drop-down and select is
|
(parent td), users enable drop-down and select is
|
||||||
populated at same time. */
|
populated at same time. */
|
||||||
if(this.fillSlcOnDemand && tf_isIE)
|
if(this.fillSlcOnDemand && tf_isIE){
|
||||||
{
|
|
||||||
slc.disabled = true;
|
slc.disabled = true;
|
||||||
slc.title = this.activateSlcTooltip;
|
slc.title = this.activateSlcTooltip;
|
||||||
slc.parentNode.onclick = this.Evt._EnableSlc;
|
slc.parentNode.onclick = this.Evt._EnableSlc;
|
||||||
if(this['col'+i]==this.fltTypeMulti)
|
if(col===this.fltTypeMulti){
|
||||||
this.__deferMultipleSelection(slc,0);
|
this.__deferMultipleSelection(slc,0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(this['col'+i]==this.fltTypeCheckList)
|
// checklist
|
||||||
{// checklist
|
else if(col===this.fltTypeCheckList){
|
||||||
var divCont = tf_CreateElm('div',
|
var divCont = tf_CreateElm('div',
|
||||||
['id',this.prfxCheckListDiv+i+'_'+this.id],
|
['id',this.prfxCheckListDiv+i+'_'+this.id],
|
||||||
['ct',i],['filled','0']);
|
['ct',i],['filled','0']);
|
||||||
divCont.className = this.checkListDivCssClass;
|
divCont.className = this.checkListDivCssClass;
|
||||||
|
|
||||||
if(this.isExternalFlt && this.externalFltTgtIds
|
//filter is appended in desired element
|
||||||
&& tf_Id(this.externalFltTgtIds[i]))
|
if(externalFltTgtId){
|
||||||
{//filter is appended in desired element
|
tf_Id(externalFltTgtId).appendChild(divCont);
|
||||||
tf_Id(this.externalFltTgtIds[i]).appendChild(divCont);
|
|
||||||
this.externalFltEls.push(divCont);
|
this.externalFltEls.push(divCont);
|
||||||
} else {
|
} else {
|
||||||
fltcell.appendChild(divCont);
|
fltcell.appendChild(divCont);
|
||||||
|
@ -1084,31 +1124,39 @@ var TF = (function() {
|
||||||
|
|
||||||
this.checkListDiv[i] = divCont;
|
this.checkListDiv[i] = divCont;
|
||||||
this.fltIds.push(this.prfxFlt+i+'_'+this.id);
|
this.fltIds.push(this.prfxFlt+i+'_'+this.id);
|
||||||
if(!this.fillSlcOnDemand) this._PopulateCheckList(i);
|
if(!this.fillSlcOnDemand){
|
||||||
|
this._PopulateCheckList(i);
|
||||||
|
}
|
||||||
|
|
||||||
divCont.onclick = this.Evt._OnCheckListFocus;
|
divCont.onclick = this.Evt._OnCheckListFocus;
|
||||||
|
|
||||||
if(this.fillSlcOnDemand)
|
if(this.fillSlcOnDemand){
|
||||||
{
|
|
||||||
divCont.onclick = this.Evt._OnCheckListClick;
|
divCont.onclick = this.Evt._OnCheckListClick;
|
||||||
divCont.appendChild(tf_CreateText(this.activateCheckListTxt));
|
divCont.appendChild(
|
||||||
|
tf_CreateText(this.activateCheckListTxt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else{
|
||||||
{
|
//show/hide input
|
||||||
var inptype;
|
var inptype = col===this.fltTypeInp ? 'text' : 'hidden';
|
||||||
(this['col'+i]==this.fltTypeInp) ? inptype='text' : inptype='hidden';//show/hide input
|
var inp = tf_CreateElm(this.fltTypeInp,
|
||||||
var inp = tf_CreateElm(this.fltTypeInp,['id',this.prfxFlt+i+'_'+this.id],['type',inptype],['ct',i]);
|
['id',this.prfxFlt+i+'_'+this.id],
|
||||||
if(inptype!='hidden')
|
['type',inptype],['ct',i]);
|
||||||
inp.value = (this.isInpWatermarkArray) ? this.inpWatermark[i] : this.inpWatermark;
|
if(inptype!='hidden'){
|
||||||
|
inp.value = (this.isInpWatermarkArray) ?
|
||||||
|
this.inpWatermark[i] : this.inpWatermark;
|
||||||
|
}
|
||||||
inp.className = inpclass;// for ie<=6
|
inp.className = inpclass;// for ie<=6
|
||||||
if(this.inpWatermark!='') tf_AddClass(inp, this.inpWatermarkCssClass); //watermark css class
|
if(this.inpWatermark!==''){
|
||||||
|
//watermark css class
|
||||||
|
tf_AddClass(inp, this.inpWatermarkCssClass);
|
||||||
|
}
|
||||||
inp.onfocus = this.Evt._OnInpFocus;
|
inp.onfocus = this.Evt._OnInpFocus;
|
||||||
|
|
||||||
if(this.isExternalFlt && this.externalFltTgtIds && tf_Id(this.externalFltTgtIds[i]))
|
//filter is appended in desired element
|
||||||
{//filter is appended in desired element
|
if(externalFltTgtId){
|
||||||
tf_Id(this.externalFltTgtIds[i]).appendChild(inp);
|
tf_Id(externalFltTgtId).appendChild(inp);
|
||||||
this.externalFltEls.push(inp);
|
this.externalFltEls.push(inp);
|
||||||
} else {
|
} else {
|
||||||
fltcell.appendChild(inp);
|
fltcell.appendChild(inp);
|
||||||
|
@ -1121,27 +1169,30 @@ var TF = (function() {
|
||||||
inp.onkeyup = this.Evt._OnKeyUp;
|
inp.onkeyup = this.Evt._OnKeyUp;
|
||||||
inp.onblur = this.Evt._OnInpBlur;
|
inp.onblur = this.Evt._OnInpBlur;
|
||||||
|
|
||||||
if(this.rememberGridValues)
|
if(this.rememberGridValues){
|
||||||
{
|
//reads the cookie
|
||||||
var flts = tf_ReadCookie(this.fltsValuesCookie); //reads the cookie
|
var flts = tf_ReadCookie(this.fltsValuesCookie);
|
||||||
var reg = new RegExp(this.separator,'g');
|
var reg = new RegExp(this.separator,'g');
|
||||||
var flts_values = flts.split(reg); //creates an array with filters' values
|
//creates an array with filters' values
|
||||||
if(flts_values[i]!=' ')
|
var flts_values = flts.split(reg);
|
||||||
|
if(flts_values[i]!=' '){
|
||||||
this.SetFilterValue(i,flts_values[i],false);
|
this.SetFilterValue(i,flts_values[i],false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(i==n-1 && this.displayBtn)// this adds validation button
|
// this adds submit button
|
||||||
{
|
if(i==n-1 && this.displayBtn){
|
||||||
var btn = tf_CreateElm(this.fltTypeInp,['id',this.prfxValButton+i+'_'+this.id],
|
var btn = tf_CreateElm(this.fltTypeInp,
|
||||||
|
['id',this.prfxValButton+i+'_'+this.id],
|
||||||
['type','button'], ['value',this.btnText]);
|
['type','button'], ['value',this.btnText]);
|
||||||
btn.className = this.btnCssClass;
|
btn.className = this.btnCssClass;
|
||||||
|
|
||||||
if(this.isExternalFlt && this.externalFltTgtIds && tf_Id(this.externalFltTgtIds[i]))
|
|
||||||
//filter is appended in desired element
|
//filter is appended in desired element
|
||||||
tf_Id(this.externalFltTgtIds[i]).appendChild(btn);
|
if(externalFltTgtId){
|
||||||
else
|
tf_Id(externalFltTgtId).appendChild(btn);
|
||||||
|
} else{
|
||||||
fltcell.appendChild(btn);
|
fltcell.appendChild(btn);
|
||||||
|
}
|
||||||
|
|
||||||
btn.onclick = this.Evt._OnBtnClick;
|
btn.onclick = this.Evt._OnBtnClick;
|
||||||
}//if
|
}//if
|
||||||
|
@ -1151,40 +1202,57 @@ var TF = (function() {
|
||||||
} else {
|
} else {
|
||||||
this.__resetGrid();
|
this.__resetGrid();
|
||||||
}//if isFirstLoad
|
}//if isFirstLoad
|
||||||
|
|
||||||
}//if this.fltGrid
|
}//if this.fltGrid
|
||||||
|
|
||||||
/* Filter behaviours */
|
/* Filter behaviours */
|
||||||
if(this.rowsCounter) this.SetRowsCounter();
|
if(this.rowsCounter){
|
||||||
if(this.statusBar) this.SetStatusBar();
|
this.SetRowsCounter();
|
||||||
if(this.fixedHeaders && !this.isFirstLoad) this.SetFixedHeaders();
|
}
|
||||||
if(this.paging) this.SetPaging();
|
if(this.statusBar){
|
||||||
if(this.hasResultsPerPage && this.paging) this.SetResultsPerPage();
|
this.SetStatusBar();
|
||||||
if(this.btnReset) this.SetResetBtn();
|
}
|
||||||
if(this.helpInstructions) this.SetHelpInstructions();
|
if(this.fixedHeaders && !this.isFirstLoad){
|
||||||
|
this.SetFixedHeaders();
|
||||||
if(this.hasColWidth && !this.gridLayout) this.SetColWidths();
|
}
|
||||||
|
if(this.paging){
|
||||||
if(this.alternateBgs && this.isStartBgAlternate)
|
this.SetPaging();
|
||||||
this.SetAlternateRows(); //1st time only if no paging and rememberGridValues
|
}
|
||||||
|
if(this.hasResultsPerPage && this.paging){
|
||||||
if(this.hasColOperation && this.fltGrid)
|
this.SetResultsPerPage();
|
||||||
{
|
}
|
||||||
|
if(this.btnReset){
|
||||||
|
this.SetResetBtn();
|
||||||
|
}
|
||||||
|
if(this.helpInstructions){
|
||||||
|
this.SetHelpInstructions();
|
||||||
|
}
|
||||||
|
if(this.hasColWidth && !this.gridLayout){
|
||||||
|
this.SetColWidths();
|
||||||
|
}
|
||||||
|
if(this.alternateBgs && this.isStartBgAlternate){
|
||||||
|
//1st time only if no paging and rememberGridValues
|
||||||
|
this.SetAlternateRows();
|
||||||
|
}
|
||||||
|
if(this.hasColOperation && this.fltGrid){
|
||||||
this.colOperation = f.col_operation;
|
this.colOperation = f.col_operation;
|
||||||
this.SetColOperation();
|
this.SetColOperation();
|
||||||
}
|
}
|
||||||
|
if(this.sort || this.gridLayout){
|
||||||
if(this.sort || this.gridLayout) this.SetSort();
|
this.SetSort();
|
||||||
if(this.selectable || this.editable) this.SetEditable();
|
}
|
||||||
|
if(this.selectable || this.editable){
|
||||||
|
this.SetEditable();
|
||||||
|
}
|
||||||
|
|
||||||
/* Deprecated Loads external script */
|
/* Deprecated Loads external script */
|
||||||
if(this.hasBindScript)
|
if(this.hasBindScript) {
|
||||||
{
|
if(this.bindScript['src']!==undefined){
|
||||||
if(this.bindScript['src']!=undefined)
|
|
||||||
{
|
|
||||||
var scriptPath = this.bindScript['src'];
|
var scriptPath = this.bindScript['src'];
|
||||||
var scriptName = (this.bindScript['name']!=undefined)
|
var scriptName = this.bindScript['name']!==undefined ?
|
||||||
? this.bindScript['name'] : '';
|
this.bindScript['name'] : '';
|
||||||
this.IncludeFile(scriptName,scriptPath,this.bindScript['target_fn']);
|
this.IncludeFile(
|
||||||
|
scriptName,scriptPath,this.bindScript['target_fn']);
|
||||||
}
|
}
|
||||||
}//if bindScript
|
}//if bindScript
|
||||||
/* */
|
/* */
|
||||||
|
@ -1192,48 +1260,61 @@ var TF = (function() {
|
||||||
this.isFirstLoad = false;
|
this.isFirstLoad = false;
|
||||||
this.hasGrid = true;
|
this.hasGrid = true;
|
||||||
|
|
||||||
if(this.rememberGridValues || this.rememberPageLen || this.rememberPageNb)
|
if(this.rememberGridValues || this.rememberPageLen ||
|
||||||
|
this.rememberPageNb){
|
||||||
this.ResetValues();
|
this.ResetValues();
|
||||||
|
}
|
||||||
|
|
||||||
//TF css class is added to table
|
//TF css class is added to table
|
||||||
if(!this.gridLayout) tf_AddClass(this.tbl, this.prfxTf);
|
if(!this.gridLayout){
|
||||||
|
tf_AddClass(this.tbl, this.prfxTf);
|
||||||
|
}
|
||||||
|
|
||||||
if(this.loader) this.ShowLoader('none');
|
if(this.loader){
|
||||||
|
this.ShowLoader('none');
|
||||||
|
}
|
||||||
|
|
||||||
/* Loads extensions */
|
/* Loads extensions */
|
||||||
if(this.hasExtensions) this.LoadExtensions();
|
if(this.hasExtensions){
|
||||||
|
this.LoadExtensions();
|
||||||
|
}
|
||||||
|
|
||||||
if(this.onFiltersLoaded)
|
if(this.onFiltersLoaded){
|
||||||
this.onFiltersLoaded.call(null,this);
|
this.onFiltersLoaded.call(null,this);
|
||||||
|
}
|
||||||
|
|
||||||
},// AddGrid
|
},// AddGrid
|
||||||
|
|
||||||
EvtManager: function(evt,s)
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- TF events manager
|
- TF events manager
|
||||||
- Params:
|
- Params:
|
||||||
- event name (string)
|
- event name (string)
|
||||||
- config object (optional literal object)
|
- config object (optional literal object)
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
EvtManager: function(evt, s){
|
||||||
var o = this;
|
var o = this;
|
||||||
var slcIndex = (s!=undefined && s.slcIndex!=undefined) ? s.slcIndex : null;
|
var slcIndex = s && s.slcIndex!==undefined ? s.slcIndex : null;
|
||||||
var slcExternal = (s!=undefined && s.slcExternal!=undefined) ? s.slcExternal : false;
|
var slcExternal = s && s.slcExternal!==undefined ?
|
||||||
var slcId = (s!=undefined && s.slcId!=undefined) ? s.slcId : null;
|
s.slcExternal : false;
|
||||||
var pgIndex = (s!=undefined && s.pgIndex!=undefined) ? s.pgIndex : null;
|
var slcId = s && s.slcId!==undefined ? s.slcId : null;
|
||||||
|
var pgIndex = s && s.pgIndex!==undefined ? s.pgIndex : null;
|
||||||
|
|
||||||
function efx(){
|
function efx(){
|
||||||
if(evt!=undefined)
|
if(!evt){ return; }
|
||||||
switch(evt)
|
switch(evt){
|
||||||
{
|
|
||||||
case o.Evt.name.filter:
|
case o.Evt.name.filter:
|
||||||
(o.isModFilterFn)
|
if(o.isModFilterFn){
|
||||||
? o.modFilterFn.call(null,o)
|
o.modFilterFn.call(null,o);
|
||||||
: o._Filter();
|
} else {
|
||||||
|
o._Filter();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case o.Evt.name.populateselect:
|
case o.Evt.name.populateselect:
|
||||||
(o.refreshFilters)
|
if(o.refreshFilters){
|
||||||
? o._PopulateSelect(slcIndex,true)
|
o._PopulateSelect(slcIndex,true);
|
||||||
: o._PopulateSelect(slcIndex,false,slcExternal,slcId);
|
} else {
|
||||||
|
o._PopulateSelect(slcIndex,false,slcExternal,slcId);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case o.Evt.name.populatechecklist:
|
case o.Evt.name.populatechecklist:
|
||||||
o._PopulateCheckList(slcIndex,slcExternal,slcId);
|
o._PopulateCheckList(slcIndex,slcExternal,slcId);
|
||||||
|
@ -1271,28 +1352,31 @@ var TF = (function() {
|
||||||
o['_'+evt].call(null,o,s);
|
o['_'+evt].call(null,o,s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(o.status || o.statusBar) o.StatusMsg('');
|
if(o.status || o.statusBar){
|
||||||
if(o.loader) o.ShowLoader('none');
|
o.StatusMsg('');
|
||||||
|
}
|
||||||
|
if(o.loader){
|
||||||
|
o.ShowLoader('none');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.loader || this.status || this.statusBar)
|
if(this.loader || this.status || this.statusBar) {
|
||||||
{
|
|
||||||
try{
|
try{
|
||||||
this.ShowLoader('');
|
this.ShowLoader('');
|
||||||
this.StatusMsg(o['msg'+evt]);
|
this.StatusMsg(o['msg'+evt]);
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
window.setTimeout(efx,this.execDelay);
|
window.setTimeout(efx,this.execDelay);
|
||||||
} else efx();
|
} else {
|
||||||
|
efx();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
ImportModule: function(module)
|
ImportModule: function(module){
|
||||||
{
|
|
||||||
if(!module.path || !module.name) return;
|
if(!module.path || !module.name) return;
|
||||||
this.IncludeFile(module.name, module.path, module.init);
|
this.IncludeFile(module.name, module.path, module.init);
|
||||||
},
|
},
|
||||||
|
|
||||||
LoadExtensions : function()
|
LoadExtensions : function(){
|
||||||
{
|
|
||||||
if(!this.Ext){
|
if(!this.Ext){
|
||||||
/*** TF extensions ***/
|
/*** TF extensions ***/
|
||||||
var o = this;
|
var o = this;
|
||||||
|
@ -4143,11 +4227,10 @@ var TF = (function() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
RemoveFixedHeaders: function()
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- Removes fixed headers
|
- Removes fixed headers
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
RemoveFixedHeaders: function(){
|
||||||
if(!this.hasGrid || !this.fixedHeaders ) return;
|
if(!this.hasGrid || !this.fixedHeaders ) return;
|
||||||
if( this.contDiv )//IE additional div
|
if( this.contDiv )//IE additional div
|
||||||
{
|
{
|
||||||
|
@ -5522,9 +5605,6 @@ var TF = (function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return TF;
|
|
||||||
})();
|
|
||||||
|
|
||||||
/* --- */
|
/* --- */
|
||||||
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
|
@ -6113,7 +6193,6 @@ function tf_SetOuterHtml(){
|
||||||
}
|
}
|
||||||
/* --- */
|
/* --- */
|
||||||
|
|
||||||
function setFilterGrid(id)
|
|
||||||
/*====================================================
|
/*====================================================
|
||||||
- Sets filters grid bar
|
- Sets filters grid bar
|
||||||
- Calls TF Constructor and generates grid bar
|
- Calls TF Constructor and generates grid bar
|
||||||
|
@ -6124,7 +6203,7 @@ function setFilterGrid(id)
|
||||||
object (literal object)
|
object (literal object)
|
||||||
- Returns TF object
|
- Returns TF object
|
||||||
=====================================================*/
|
=====================================================*/
|
||||||
{
|
function setFilterGrid(id){
|
||||||
if(arguments.length === 0){ return; }
|
if(arguments.length === 0){ return; }
|
||||||
window['tf_'+id] = new TF(arguments[0], arguments[1], arguments[2]);
|
window['tf_'+id] = new TF(arguments[0], arguments[1], arguments[2]);
|
||||||
window['tf_'+id].AddGrid();
|
window['tf_'+id].AddGrid();
|
||||||
|
|
Loading…
Reference in a new issue