diff --git a/src/index.html b/src/index.html
index d44fe4a8..31769f78 100644
--- a/src/index.html
+++ b/src/index.html
@@ -1,7 +1,7 @@
-
+ HTML Table Filter Generator
@@ -68,8 +68,9 @@
diff --git a/src/tablefilter_all.js b/src/tablefilter_all.js
index c7de9078..d370a6aa 100644
--- a/src/tablefilter_all.js
+++ b/src/tablefilter_all.js
@@ -1,8 +1,8 @@
-/*------------------------------------------------------------------------
+/* ------------------------------------------------------------------------
- HTML Table Filter Generator v2.5
- By Max Guglielmi (tablefilter.free.fr)
- Licensed under the MIT License
---------------------------------------------------------------------------
+---------------------------------------------------------------------------
Copyright (c) 2009-2014 Max Guglielmi
Permission is hereby granted, free of charge, to any person obtaining
@@ -23,13 +23,13 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------------------------------------------
+---------------------------------------------------------------------------
- Special credit to:
Cedric Wartel, cnx.claude@free.fr, Florent Hirchy, Váry Péter,
Anthony Maes, Nuovella Williams, Fuggerbit, Venkata Seshagiri Rao
Raya, Piepiax, Manuel Kern, Baladhandayutham for active contribution
and/or inspiration
-------------------------------------------------------------------------*/
+------------------------------------------------------------------------ */
/**
* TF object constructor
@@ -2259,25 +2259,30 @@ TF.prototype = {
var o = this;
this.Evt._Paging = {// paging buttons events
slcIndex: function(){
- return (o.pageSelectorType==o.fltTypeSlc) ?
+ return (o.pageSelectorType===o.fltTypeSlc) ?
o.pagingSlc.options.selectedIndex :
parseInt(o.pagingSlc.value,10)-1;
},
nbOpts: function(){
- return (o.pageSelectorType==o.fltTypeSlc)
- ? parseInt(o.pagingSlc.options.length)-1
- : (o.nbPages-1);
+ return (o.pageSelectorType===o.fltTypeSlc) ?
+ parseInt(o.pagingSlc.options.length,10)-1 :
+ (o.nbPages-1);
},
next: function(){
- if(o.Evt._Paging.nextEvt) o.Evt._Paging.nextEvt();
- var nextIndex = (o.Evt._Paging.slcIndex()0
- ? o.Evt._Paging.slcIndex()-1 : o.Evt._Paging.nbOpts();
+ if(o.Evt._Paging.prevEvt){
+ o.Evt._Paging.prevEvt();
+ }
+ var prevIndex = o.Evt._Paging.slcIndex()>0 ?
+ o.Evt._Paging.slcIndex()-1 : o.Evt._Paging.nbOpts();
o.ChangePage(prevIndex);
},
last: function(){
@@ -2285,22 +2290,25 @@ TF.prototype = {
o.ChangePage(o.Evt._Paging.nbOpts());
},
first: function(){
- if(o.Evt._Paging.firstEvt) o.Evt._Paging.firstEvt();
+ if(o.Evt._Paging.firstEvt){
+ o.Evt._Paging.firstEvt();
+ }
o.ChangePage(0);
},
- _detectKey: function(e)
- {
- var evt=(e)?e:(window.event)?window.event:null;
- if(evt)
- {
- var key=(evt.charCode)?evt.charCode:
- ((evt.keyCode)?evt.keyCode:((evt.which)?evt.which:0));
- if(key=='13'){
- if(o.sorted){ o.Filter(); o.ChangePage(o.Evt._Paging.slcIndex()); }
- else o.ChangePage();
+ _detectKey: function(e){
+ var evt = e || window.event;
+ if(evt){
+ var key = o.Evt.getKeyCode(e);
+ if(key===13){
+ if(o.sorted){
+ o.Filter();
+ o.ChangePage(o.Evt._Paging.slcIndex());
+ } else{
+ o.ChangePage();
+ }
this.blur();
}
- }//if evt
+ }
},
nextEvt: null,
prevEvt: null,
@@ -2309,34 +2317,36 @@ TF.prototype = {
};
}
- if(!this.Evt._OnSlcPagesChange)
- {
- this.Evt._OnSlcPagesChange = function()
- /*====================================================
- - onchange event for paging select
- =====================================================*/
- {
- if(o.Evt._Paging._OnSlcPagesChangeEvt)
+ /*====================================================
+ - onchange event for paging select
+ =====================================================*/
+ if(!this.Evt._OnSlcPagesChange){
+ this.Evt._OnSlcPagesChange = function(){
+ if(o.Evt._Paging._OnSlcPagesChangeEvt){
o.Evt._Paging._OnSlcPagesChangeEvt();
+ }
o.ChangePage();
this.blur();
//ie only: blur is not enough...
- if(this.parentNode && tf_isIE)
+ if(this.parentNode && tf_isIE){
this.parentNode.focus();
- }
+ }
+ };
}
+ var slcPages;
+
// Paging drop-down list selector
- if(this.pageSelectorType == this.fltTypeSlc)
- {
- var slcPages = tf_CreateElm( this.fltTypeSlc, ['id',this.prfxSlcPages+this.id] );
+ if(this.pageSelectorType === this.fltTypeSlc){
+ slcPages = tf_CreateElm(
+ this.fltTypeSlc, ['id',this.prfxSlcPages+this.id]);
slcPages.className = this.pgSlcCssClass;
slcPages.onchange = this.Evt._OnSlcPagesChange;
}
+
// Paging input selector
- if(this.pageSelectorType == this.fltTypeInp)
- {
- var slcPages = tf_CreateElm(
+ if(this.pageSelectorType === this.fltTypeInp){
+ slcPages = tf_CreateElm(
this.fltTypeInp,
['id',this.prfxSlcPages+this.id],
['value',this.currentPageNb]
@@ -2345,18 +2355,25 @@ TF.prototype = {
slcPages.onkeypress = this.Evt._Paging._detectKey;
}
- var btnNextSpan, btnPrevSpan, btnLastSpan, btnFirstSpan;// btns containers
- btnNextSpan = tf_CreateElm('span',['id',this.prfxBtnNextSpan+this.id]);
- btnPrevSpan = tf_CreateElm('span',['id',this.prfxBtnPrevSpan+this.id]);
- btnLastSpan = tf_CreateElm('span',['id',this.prfxBtnLastSpan+this.id]);
- btnFirstSpan = tf_CreateElm('span',['id',this.prfxBtnFirstSpan+this.id]);
+ // btns containers
+ var btnNextSpan = tf_CreateElm(
+ 'span',['id',this.prfxBtnNextSpan+this.id]);
+ var btnPrevSpan = tf_CreateElm(
+ 'span',['id',this.prfxBtnPrevSpan+this.id]);
+ var btnLastSpan = tf_CreateElm(
+ 'span',['id',this.prfxBtnLastSpan+this.id]);
+ var btnFirstSpan = tf_CreateElm(
+ 'span',['id',this.prfxBtnFirstSpan+this.id]);
- if(this.hasPagingBtns)
- {
- if(this.btnNextPageHtml==null)
- {// Next button
- var btn_next = tf_CreateElm( this.fltTypeInp,['id',this.prfxBtnNext+this.id],
- ['type','button'],['value',this.btnNextPageText],['title','Next'] );
+ if(this.hasPagingBtns){
+ // Next button
+ if(!this.btnNextPageHtml){
+ var btn_next = tf_CreateElm(
+ this.fltTypeInp,['id',this.prfxBtnNext+this.id],
+ ['type','button'],
+ ['value',this.btnNextPageText],
+ ['title','Next']
+ );
btn_next.className = this.btnPageCssClass;
btn_next.onclick = this.Evt._Paging.next;
btnNextSpan.appendChild(btn_next);
@@ -2364,11 +2381,15 @@ TF.prototype = {
btnNextSpan.innerHTML = this.btnNextPageHtml;
btnNextSpan.onclick = this.Evt._Paging.next;
}
-
- if(this.btnPrevPageHtml==null)
- {// Previous button
- var btn_prev = tf_CreateElm( this.fltTypeInp,['id',this.prfxBtnPrev+this.id],
- ['type','button'],['value',this.btnPrevPageText],['title','Previous'] );
+ // Previous button
+ if(!this.btnPrevPageHtml){
+ var btn_prev = tf_CreateElm(
+ this.fltTypeInp,
+ ['id',this.prfxBtnPrev+this.id],
+ ['type','button'],
+ ['value',this.btnPrevPageText],
+ ['title','Previous']
+ );
btn_prev.className = this.btnPageCssClass;
btn_prev.onclick = this.Evt._Paging.prev;
btnPrevSpan.appendChild(btn_prev);
@@ -2376,11 +2397,15 @@ TF.prototype = {
btnPrevSpan.innerHTML = this.btnPrevPageHtml;
btnPrevSpan.onclick = this.Evt._Paging.prev;
}
-
- if(this.btnLastPageHtml==null)
- {// Last button
- var btn_last = tf_CreateElm( this.fltTypeInp,['id',this.prfxBtnLast+this.id],
- ['type','button'],['value',this.btnLastPageText],['title','Last'] );
+ // Last button
+ if(!this.btnLastPageHtml){
+ var btn_last = tf_CreateElm(
+ this.fltTypeInp,
+ ['id',this.prfxBtnLast+this.id],
+ ['type','button'],
+ ['value',this.btnLastPageText],
+ ['title','Last']
+ );
btn_last.className = this.btnPageCssClass;
btn_last.onclick = this.Evt._Paging.last;
btnLastSpan.appendChild(btn_last);
@@ -2388,11 +2413,15 @@ TF.prototype = {
btnLastSpan.innerHTML = this.btnLastPageHtml;
btnLastSpan.onclick = this.Evt._Paging.last;
}
-
- if(this.btnFirstPageHtml==null)
- {// First button
- var btn_first = tf_CreateElm( this.fltTypeInp,['id',this.prfxBtnFirst+this.id],
- ['type','button'],['value',this.btnFirstPageText],['title','First'] );
+ // First button
+ if(!this.btnFirstPageHtml){
+ var btn_first = tf_CreateElm(
+ this.fltTypeInp,
+ ['id',this.prfxBtnFirst+this.id],
+ ['type','button'],
+ ['value',this.btnFirstPageText],
+ ['title','First']
+ );
btn_first.className = this.btnPageCssClass;
btn_first.onclick = this.Evt._Paging.first;
btnFirstSpan.appendChild(btn_first);
@@ -2400,27 +2429,35 @@ TF.prototype = {
btnFirstSpan.innerHTML = this.btnFirstPageHtml;
btnFirstSpan.onclick = this.Evt._Paging.first;
}
- }//if this.hasPagingBtns
+ }
// paging elements (buttons+drop-down list) are added to defined element
- if(this.pagingTgtId==null) this.SetTopDiv();
- var targetEl = ( this.pagingTgtId==null ) ? this.mDiv : tf_Id( this.pagingTgtId );
+ if(!this.pagingTgtId){
+ this.SetTopDiv();
+ }
+ var targetEl = !this.pagingTgtId ? this.mDiv : tf_Id(this.pagingTgtId);
- /*** if paging previously removed this prevents IE memory leak with removeChild
- used in RemovePaging method. For more info refer to
- http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2840253&SiteID=1 ***/
- if ( targetEl.innerHTML!='' ) targetEl.innerHTML = '';
+ /***
+ if paging previously removed this prevents IE memory leak with
+ removeChild used in RemovePaging method. For more info refer to
+ http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2840253&SiteID=1
+ ***/
+ if (targetEl.innerHTML!==''){
+ targetEl.innerHTML = '';
+ }
/*** ***/
targetEl.appendChild(btnFirstSpan);
targetEl.appendChild(btnPrevSpan);
- var pgBeforeSpan = tf_CreateElm( 'span',['id',this.prfxPgBeforeSpan+this.id] );
+ var pgBeforeSpan = tf_CreateElm(
+ 'span',['id',this.prfxPgBeforeSpan+this.id] );
pgBeforeSpan.appendChild( tf_CreateText(this.pageText) );
pgBeforeSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgBeforeSpan);
targetEl.appendChild(slcPages);
- var pgAfterSpan = tf_CreateElm( 'span',['id',this.prfxPgAfterSpan+this.id] );
+ var pgAfterSpan = tf_CreateElm(
+ 'span',['id',this.prfxPgAfterSpan+this.id]);
pgAfterSpan.appendChild( tf_CreateText(this.ofText) );
pgAfterSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgAfterSpan)
@@ -2430,14 +2467,14 @@ TF.prototype = {
targetEl.appendChild(pgspan);
targetEl.appendChild(btnNextSpan);
targetEl.appendChild(btnLastSpan);
- this.pagingSlc = tf_Id(this.prfxSlcPages+this.id); //to be easily re-used
+ this.pagingSlc = tf_Id(this.prfxSlcPages+this.id);
// if this.rememberGridValues==true this.SetPagingInfo() is called
// in ResetGridValues() method
- if( !this.rememberGridValues || this.isPagingRemoved )
+ if(!this.rememberGridValues || this.isPagingRemoved){
this.SetPagingInfo();
- if( !this.fltGrid )
- {
+ }
+ if(!this.fltGrid){
this.ValidateAllRows();
this.SetPagingInfo(this.validRowsIndex);
}
@@ -2446,196 +2483,239 @@ TF.prototype = {
this.isPagingRemoved = false;
},
- RemovePaging: function()
/*====================================================
- Removes paging elements
=====================================================*/
- {
- if(!this.hasGrid) return;
- if( this.pagingSlc==null ) return;
- var btnNextSpan, btnPrevSpan, btnLastSpan, btnFirstSpan;// btns containers
+ RemovePaging: function(){
+ if(!this.hasGrid || !this.pagingSlc){
+ return;
+ }
+
+ // btns containers
+ var btnNextSpan, btnPrevSpan, btnLastSpan, btnFirstSpan;
var pgBeforeSpan, pgAfterSpan, pgspan;
btnNextSpan = tf_Id(this.prfxBtnNextSpan+this.id);
btnPrevSpan = tf_Id(this.prfxBtnPrevSpan+this.id);
btnLastSpan = tf_Id(this.prfxBtnLastSpan+this.id);
btnFirstSpan = tf_Id(this.prfxBtnFirstSpan+this.id);
- pgBeforeSpan = tf_Id(this.prfxPgBeforeSpan+this.id);//span containing 'Page' text
- pgAfterSpan = tf_Id(this.prfxPgAfterSpan+this.id);//span containing 'of' text
- pgspan = tf_Id(this.prfxPgSpan+this.id);//span containing nb of pages
+ //span containing 'Page' text
+ pgBeforeSpan = tf_Id(this.prfxPgBeforeSpan+this.id);
+ //span containing 'of' text
+ pgAfterSpan = tf_Id(this.prfxPgAfterSpan+this.id);
+ //span containing nb of pages
+ pgspan = tf_Id(this.prfxPgSpan+this.id);
this.pagingSlc.parentNode.removeChild(this.pagingSlc);
- if( btnNextSpan!=null )
+ if(btnNextSpan){
btnNextSpan.parentNode.removeChild( btnNextSpan );
+ }
- if( btnPrevSpan!=null )
+ if(btnPrevSpan){
btnPrevSpan.parentNode.removeChild( btnPrevSpan );
+ }
- if( btnLastSpan!=null )
+ if(btnLastSpan){
btnLastSpan.parentNode.removeChild( btnLastSpan );
+ }
- if( btnFirstSpan!=null )
+ if(btnFirstSpan){
btnFirstSpan.parentNode.removeChild( btnFirstSpan );
+ }
- if( pgBeforeSpan!=null )
+ if(pgBeforeSpan){
pgBeforeSpan.parentNode.removeChild( pgBeforeSpan );
+ }
- if( pgAfterSpan!=null )
+ if(pgAfterSpan){
pgAfterSpan.parentNode.removeChild( pgAfterSpan );
+ }
- if( pgspan!=null )
+ if(pgspan){
pgspan.parentNode.removeChild( pgspan );
+ }
this.pagingBtnEvents = null;
this.pagingSlc = null;
this.isPagingRemoved = true;
},
- SetPagingInfo: function( validRows )
/*====================================================
- calculates page # according to valid rows
- refreshes paging select according to page #
- Calls GroupByPage method
=====================================================*/
- {
- var row = this.tbl.rows;
- var mdiv = ( this.pagingTgtId==null ) ? this.mDiv : tf_Id( this.pagingTgtId );
+ SetPagingInfo: function(validRows){
+ var rows = this.tbl.rows;
+ var mdiv = !this.pagingTgtId ? this.mDiv : tf_Id(this.pagingTgtId);
var pgspan = tf_Id(this.prfxPgSpan+this.id);
+ //stores valid rows indexes
+ if(validRows && validRows.length>0){
+ this.validRowsIndex = validRows;
+ } else {
+ //re-sets valid rows indexes array
+ this.validRowsIndex = [];
- if( validRows!=undefined ) this.validRowsIndex = validRows;//stores valid rows index
- else
- {
- this.validRowsIndex = [];//re-sets valid rows index
-
- for(var j=this.refRow; j0 )
- {
+ if(this.nbPages>0){
mdiv.style.visibility = 'visible';
- if(this.pageSelectorType==this.fltTypeSlc)
- for(var z=0; z=this.startPagingRow && h=this.startPagingRow && h' +
- '<, <=, >, >=, =, *, !, {, }, ||, ' +
- '&&, [empty], [nonempty], rgx:
These operators are described here:
' +
- 'http://tablefilter.free.fr/#operators
';
- this.helpInstrHtml = f.help_instructions_html!=undefined
- ? f.help_instructions_html : null; //defines help innerHtml
- this.helpInstrBtnText = f.help_instructions_btn_text!=undefined
- ? f.help_instructions_btn_text : '?'; //defines reset button text
- this.helpInstrBtnHtml = f.help_instructions_btn_html!=undefined
- ? f.help_instructions_btn_html : null; //defines reset button innerHtml
- this.helpInstrBtnCssClass = f.help_instructions_btn_css_class!=undefined //defines css class for help button
- ? f.help_instructions_btn_css_class : 'helpBtn';
- this.helpInstrContCssClass = f.help_instructions_container_css_class!=undefined //defines css class for help container
- ? f.help_instructions_container_css_class : 'helpCont';
- this.helpInstrBtnEl = null; //help button element
- this.helpInstrContEl = null; //help content div
- this.helpInstrDefaultHtml = '';
+ //id of custom container element for instructions
+ this.helpInstrTgtId = f.help_instructions_target_id || null;
+ //id of custom container element for instructions
+ this.helpInstrContTgtId = f.help_instructions_container_target_id ||
+ null;
+ //defines help text
+ this.helpInstrText = f.help_instructions_text ?
+ f.help_instructions_text :
+ 'Use the filters above each column to filter and limit table ' +
+ 'data. Avanced searches can be performed by using the following ' +
+ 'operators:
<, <=, >, ' +
+ '>=, =, *, !, {, }, ' +
+ '||,&&, [empty], [nonempty], ' +
+ 'rgx:
These operators are described here:
' +
+ 'http://tablefilter.free.fr/#operators
';
+ //defines help innerHtml
+ this.helpInstrHtml = f.help_instructions_html || null;
+ //defines reset button text
+ this.helpInstrBtnText = f.help_instructions_btn_text || '?';
+ //defines reset button innerHtml
+ this.helpInstrBtnHtml = f.help_instructions_btn_html || null;
+ //defines css class for help button
+ this.helpInstrBtnCssClass = f.help_instructions_btn_css_class ||
+ 'helpBtn';
+ //defines css class for help container
+ this.helpInstrContCssClass = f.help_instructions_container_css_class ||
+ 'helpCont';
+ //help button element
+ this.helpInstrBtnEl = null;
+ //help content div
+ this.helpInstrContEl = null;
+ this.helpInstrDefaultHtml = '';
var helpspan = tf_CreateElm('span',['id',this.prfxHelpSpan+this.id]);
var helpdiv = tf_CreateElm('div',['id',this.prfxHelpDiv+this.id]);
//help button is added to defined element
- if(this.helpInstrTgtId==null) this.SetTopDiv();
- var targetEl = ( this.helpInstrTgtId==null ) ? this.rDiv : tf_Id( this.helpInstrTgtId );
+ if(!this.helpInstrTgtId){
+ this.SetTopDiv();
+ }
+ var targetEl = !this.helpInstrTgtId ?
+ this.rDiv : tf_Id(this.helpInstrTgtId);
targetEl.appendChild(helpspan);
- var divContainer = ( this.helpInstrContTgtId==null ) ? helpspan : tf_Id( this.helpInstrContTgtId );
+ var divContainer = !this.helpInstrContTgtId ?
+ helpspan : tf_Id( this.helpInstrContTgtId );
- if(this.helpInstrBtnHtml == null)
- {
+ if(!this.helpInstrBtnHtml){
divContainer.appendChild(helpdiv);
- var helplink = tf_CreateElm( 'a', ['href','javascript:void(0);'] );
+ var helplink = tf_CreateElm( 'a', ['href','javascript:void(0);']);
helplink.className = this.helpInstrBtnCssClass;
helplink.appendChild(tf_CreateText(this.helpInstrBtnText));
helpspan.appendChild(helplink);
@@ -2727,9 +2826,7 @@ TF.prototype = {
divContainer.appendChild(helpdiv);
}
- if(this.helpInstrHtml == null)
- {
- //helpdiv.appendChild(tf_CreateText(this.helpInstrText));
+ if(!this.helpInstrHtml){
helpdiv.innerHTML = this.helpInstrText;
helpdiv.className = this.helpInstrContCssClass;
helpdiv.ondblclick = this.Evt._OnHelpBtnClick;
@@ -2746,139 +2843,154 @@ TF.prototype = {
this.helpInstrBtnEl = helpspan;
},
- RemoveHelpInstructions: function()
/*====================================================
- Removes help instructions
=====================================================*/
- {
- if(this.helpInstrBtnEl==null) return;
+ RemoveHelpInstructions: function() {
+ if(!this.helpInstrBtnEl){
+ return;
+ }
this.helpInstrBtnEl.parentNode.removeChild(this.helpInstrBtnEl);
this.helpInstrBtnEl = null;
- if(this.helpInstrContEl==null) return;
+ if(!this.helpInstrContEl){
+ return;
+ }
this.helpInstrContEl.parentNode.removeChild(this.helpInstrContEl);
this.helpInstrContEl = null;
},
- _ToggleHelp: function()
/*====================================================
- Toggles help div
=====================================================*/
- {
- if(!this.helpInstrContEl) return;
- var divDisplay = this.helpInstrContEl.style.display;
- if(divDisplay == '' || divDisplay == 'none'){
- this.helpInstrContEl.style.display = 'block';
- var btnLeft = tf_ObjPosition(this.helpInstrBtnEl, [this.helpInstrBtnEl.nodeName])[0];
- if(!this.helpInstrContTgtId)
- this.helpInstrContEl.style.left = (btnLeft - this.helpInstrContEl.clientWidth + 25) + 'px';
+ _ToggleHelp: function(){
+ if(!this.helpInstrContEl){
+ return;
+ }
+ var divDisplay = this.helpInstrContEl.style.display;
+ if(divDisplay==='' || divDisplay==='none'){
+ this.helpInstrContEl.style.display = 'block';
+ var btnLeft = tf_ObjPosition(
+ this.helpInstrBtnEl, [this.helpInstrBtnEl.nodeName])[0];
+ if(!this.helpInstrContTgtId){
+ this.helpInstrContEl.style.left =
+ (btnLeft - this.helpInstrContEl.clientWidth + 25) + 'px';
+ }
+ } else {
+ this.helpInstrContEl.style.display = 'none';
}
- else this.helpInstrContEl.style.display = 'none';
},
- ChangePage: function( index )
- {
+ ChangePage: function(index){
this.EvtManager(this.Evt.name.changepage,{ pgIndex:index });
},
- _ChangePage: function( index )
/*====================================================
- Changes page
- Param:
- index: option index of paging select
(numeric value)
=====================================================*/
- {
- if( !this.paging ) return;
- if( index==undefined )
- index = (this.pageSelectorType==this.fltTypeSlc) ?
+ _ChangePage: function(index){
+ if(!this.paging){
+ return;
+ }
+ if(!index){
+ index = this.pageSelectorType===this.fltTypeSlc ?
this.pagingSlc.options.selectedIndex : (this.pagingSlc.value-1);
- if( index>=0 && index<=(this.nbPages-1) )
- {
- if(this.onBeforeChangePage) this.onBeforeChangePage.call(null, this, index);
+ }
+ if( index>=0 && index<=(this.nbPages-1) ){
+ if(this.onBeforeChangePage){
+ this.onBeforeChangePage.call(null, this, index);
+ }
this.currentPageNb = parseInt(index)+1;
- if(this.pageSelectorType==this.fltTypeSlc)
+ if(this.pageSelectorType===this.fltTypeSlc){
this.pagingSlc.options[index].selected = true;
- else
+ } else {
this.pagingSlc.value = this.currentPageNb;
+ }
- if( this.rememberPageNb ) this.RememberPageNb( this.pgNbCookie );
- this.startPagingRow = (this.pageSelectorType==this.fltTypeSlc)
- ? this.pagingSlc.value : (index*this.pagingLength);
+ if(this.rememberPageNb){
+ this.RememberPageNb(this.pgNbCookie);
+ }
+ this.startPagingRow = (this.pageSelectorType===this.fltTypeSlc) ?
+ this.pagingSlc.value : (index*this.pagingLength);
this.GroupByPage();
- if(this.onAfterChangePage) this.onAfterChangePage.call(null, this, index);
+ if(this.onAfterChangePage){
+ this.onAfterChangePage.call(null, this, index);
+ }
}
},
- ChangeResultsPerPage: function()
- {
+ ChangeResultsPerPage: function(){
this.EvtManager(this.Evt.name.changeresultsperpage);
},
- _ChangeResultsPerPage: function()
/*====================================================
- calculates rows to be displayed in a page
- method called by nb results per page select
=====================================================*/
- {
- if( !this.paging ) return;
+ _ChangeResultsPerPage: function(){
+ if(!this.paging){
+ return;
+ }
var slcR = this.resultsPerPageSlc;
- var slcPagesSelIndex = (this.pageSelectorType==this.fltTypeSlc)
- ? this.pagingSlc.selectedIndex : parseInt(this.pagingSlc.value-1);
- this.pagingLength = parseInt(slcR.options[slcR.selectedIndex].value);
+ var slcPagesSelIndex = (this.pageSelectorType==this.fltTypeSlc) ?
+ this.pagingSlc.selectedIndex :
+ parseInt(this.pagingSlc.value-1,10);
+ this.pagingLength = parseInt(slcR.options[slcR.selectedIndex].value,10);
this.startPagingRow = this.pagingLength*slcPagesSelIndex;
- if( !isNaN(this.pagingLength) )
- {
- if( this.startPagingRow>=this.nbFilterableRows )
+ if(!isNaN(this.pagingLength)){
+ if(this.startPagingRow>=this.nbFilterableRows){
this.startPagingRow = (this.nbFilterableRows-this.pagingLength);
+ }
this.SetPagingInfo();
- if(this.pageSelectorType==this.fltTypeSlc)
- {
- var slcIndex = (this.pagingSlc.options.length-1<=slcPagesSelIndex )
- ? (this.pagingSlc.options.length-1) : slcPagesSelIndex;
+ if(this.pageSelectorType===this.fltTypeSlc){
+ var slcIndex =
+ (this.pagingSlc.options.length-1<=slcPagesSelIndex ) ?
+ (this.pagingSlc.options.length-1) : slcPagesSelIndex;
this.pagingSlc.options[slcIndex].selected = true;
}
- if( this.rememberPageLen ) this.RememberPageLength( this.pgLenCookie );
- }//if isNaN
+ if(this.rememberPageLen){
+ this.RememberPageLength( this.pgLenCookie );
+ }
+ }
},
- ResetPage: function( name )
- {
+ ResetPage: function(name){
this.EvtManager(this.Evt.name.resetpage);
},
- _ResetPage: function( name )
/*==============================================
- re-sets page nb at page re-load
- Params:
- name: cookie name (string)
===============================================*/
- {
- var pgnb = tf_ReadCookie(name); //reads the cookie
- if( pgnb!='' )
+ _ResetPage: function(name){
+ var pgnb = tf_ReadCookie(name);
+ if(pgnb!==''){
this.ChangePage((pgnb-1));
+ }
},
- ResetPageLength: function( name )
- {
+ ResetPageLength: function(name){
this.EvtManager(this.Evt.name.resetpagelength);
},
- _ResetPageLength: function( name )
/*==============================================
- re-sets page length at page re-load
- Params:
- name: cookie name (string)
===============================================*/
- {
- if(!this.paging) return;
- var pglenIndex = tf_ReadCookie(name); //reads the cookie
+ _ResetPageLength: function(name){
+ if(!this.paging){
+ return;
+ }
+ var pglenIndex = tf_ReadCookie(name);
- if( pglenIndex!='' )
- {
+ if(pglenIndex!==''){
this.resultsPerPageSlc.options[pglenIndex].selected = true;
this.ChangeResultsPerPage();
}
},
- AddPaging: function(filterTable)
/*====================================================
- Adds paging feature if filter grid bar is
already set
@@ -2886,40 +2998,50 @@ TF.prototype = {
- execFilter: if true table is filtered
(boolean)
=====================================================*/
- {
- if( !this.hasGrid || this.paging ) return;
+ AddPaging: function(filterTable){
+ if(!this.hasGrid || this.paging){
+ return;
+ }
this.paging = true;
this.isPagingRemoved = true;
this.SetPaging();
this.ResetValues();
- if(filterTable) this.Filter();
+ if(filterTable){
+ this.Filter();
+ }
},
- PopulateSelect: function(colIndex,isExternal,extSlcId)
- {
+ PopulateSelect: function(colIndex,isExternal,extSlcId){
this.EvtManager(
this.Evt.name.populateselect,
{ slcIndex:colIndex, slcExternal:isExternal, slcId:extSlcId }
);
},
- _PopulateSelect: function(colIndex,isRefreshed,isExternal,extSlcId)
/*====================================================
- populates drop-down filters
=====================================================*/
- {
- isExternal = (isExternal==undefined) ? false : isExternal;
+ _PopulateSelect: function(colIndex,isRefreshed,isExternal,extSlcId) {
+ isExternal = isExternal===undefined ? false : isExternal;
var slcId = this.fltIds[colIndex];
- if( tf_Id(slcId)==null && !isExternal ) return;
- if( tf_Id(extSlcId)==null && isExternal ) return;
- var slc = (!isExternal) ? tf_Id(slcId) : tf_Id(extSlcId);
- var o = this, row = this.tbl.rows;
- var fillMethod = this.slcFillingMethod.tf_LCase();
- var optArray = [], slcInnerHtml = '', opt0;
- var isCustomSlc = (this.hasCustomSlcOptions //custom select test
- && this.customSlcOptions.cols.tf_Has(colIndex));
- var optTxt = []; //custom selects text
- var activeFlt;
+ if((!tf_Id(slcId) && !isExternal) ||
+ (!tf_Id(extSlcId) && isExternal)){
+ return;
+ }
+ var slc = !isExternal ? tf_Id(slcId) : tf_Id(extSlcId),
+ o = this,
+ row = this.tbl.rows,
+ matchCase = this.matchCase,
+ fillMethod = this.slcFillingMethod.tf_LCase(),
+ optArray = [],
+ slcInnerHtml = '',
+ opt0,
+ //custom select test
+ isCustomSlc = (this.hasCustomSlcOptions &&
+ this.customSlcOptions.cols.tf_Has(colIndex));
+ //custom selects text
+ var optTxt = [],
+ activeFlt;
if(isRefreshed && this.activeFilterId){
activeFlt = this.activeFilterId.split('_')[0];
activeFlt = activeFlt.split(this.prfxFlt)[1];
@@ -2927,46 +3049,70 @@ TF.prototype = {
/*** remember grid values ***/
var flts_values = [], fltArr = [];
- if(this.rememberGridValues)
- {
- flts_values = tf_CookieValueArray(this.fltsValuesCookie, this.separator);
- if(flts_values != undefined && flts_values.toString().tf_Trim() != ''){
- if(this.hasCustomSlcOptions && this.customSlcOptions.cols.tf_Has(colIndex)){
+ if(this.rememberGridValues){
+ flts_values = tf_CookieValueArray(
+ this.fltsValuesCookie, this.separator);
+ if(flts_values && flts_values.toString().tf_Trim()!==''){
+ if(isCustomSlc){
fltArr.push(flts_values[colIndex]);
- } else { fltArr = flts_values[colIndex].split(' '+o.orOperator+' '); }
+ } else {
+ fltArr = flts_values[colIndex].split(' '+o.orOperator+' ');
+ }
}
}
- var excludedOpts = null, filteredDataCol = null;
- if(isRefreshed && this.disableExcludedOptions){ excludedOpts = []; filteredDataCol = []; }
+ var excludedOpts = null,
+ filteredDataCol = null;
+ if(isRefreshed && this.disableExcludedOptions){
+ excludedOpts = [];
+ filteredDataCol = [];
+ }
- for(var k=this.refRow; k'+o.displayAllText+'';
+ // adds 1st option
+ function AddOpt0(){
+ if(fillMethod === 'innerhtml'){
+ slcInnerHtml +='';
+ }
else {
- var opt0 = tf_CreateOpt((!o.enableSlcResetFilter ? '' : o.displayAllText),'');
- if(!o.enableSlcResetFilter) opt0.style.display = 'none';
+ var opt0 = tf_CreateOpt(
+ (!o.enableSlcResetFilter ? '' : o.displayAllText),'');
+ if(!o.enableSlcResetFilter){
+ opt0.style.display = 'none';
+ }
slc.appendChild(opt0);
if(o.enableEmptyOption){
var opt1 = tf_CreateOpt(o.emptyText,o.emOperator);
@@ -3032,58 +3200,73 @@ TF.prototype = {
}
}
- function AddOpts()
- {// populates select
+ // populates select
+ function AddOpts(){
var slcValue = slc.value;
slc.innerHTML = '';
AddOpt0();
- for(var y=0; y'+lbl+'';
+ }
+ slcInnerHtml += '';
} else {
var opt;
//fill select on demand
- if(o.fillSlcOnDemand && slcValue==optArray[y] && o['col'+colIndex]==o.fltTypeSlc)
- opt = tf_CreateOpt( lbl, val, true );
- else{
- if( o['col'+colIndex]!=o.fltTypeMulti )
- opt = tf_CreateOpt( lbl, val,
- (flts_values[colIndex]!=' ' && val==flts_values[colIndex])
- ? true : false );
- else
- {
- opt = tf_CreateOpt( lbl, val,
- (fltArr.tf_Has(optArray[y].tf_MatchCase(o.matchCase),o.matchCase)
- || fltArr.toString().indexOf(val)!= -1)
- ? true : false );
+ if(o.fillSlcOnDemand && slcValue==optArray[y] &&
+ o['col'+colIndex]===o.fltTypeSlc){
+ opt = tf_CreateOpt(lbl, val, true);
+ } else {
+ if(o['col'+colIndex]!=o.fltTypeMulti){
+ opt = tf_CreateOpt(
+ lbl,
+ val,
+ (flts_values[colIndex]!==' ' &&
+ val==flts_values[colIndex]) ? true : false
+ );
+ } else {
+ opt = tf_CreateOpt(
+ lbl,
+ val,
+ (fltArr.tf_Has(
+ optArray[y].tf_MatchCase(
+ o.matchCase),o.matchCase) ||
+ fltArr.toString().indexOf(val)!== -1) ?
+ true : false
+ );
}
}
- if(isDisabled) opt.disabled = true;
+ if(isDisabled){
+ opt.disabled = true;
+ }
slc.appendChild(opt);
}
}// for y
- if( fillMethod == 'innerhtml' ) slc.innerHTML += slcInnerHtml;
+ if(fillMethod === 'innerhtml'){
+ slc.innerHTML += slcInnerHtml;
+ }
slc.setAttribute('filled','1');
}// fn AddOpt
},
- __deferMultipleSelection: function(slc,index,filter)
/*====================================================
- IE bug: it seems there is no way to make
multiple selections programatically, only last
@@ -3092,29 +3275,27 @@ TF.prototype = {
- Work-around: defer selection with a setTimeout
If you find a more elegant solution to
this let me know ;-)
- - For the moment only this solution seems
- to work!
+ - For the moment only this solution seems to work!
- Params:
- slc = select object (select obj)
- index to be selected (integer)
- execute filtering (boolean)
=====================================================*/
- {
- if(slc.nodeName.tf_LCase() != 'select') return;
- var doFilter = (filter==undefined) ? false : filter;
+ __deferMultipleSelection: function(slc,index,filter){
+ if(slc.nodeName.tf_LCase() !== 'select'){
+ return;
+ }
+ var doFilter = filter===undefined ? false : filter;
var o = this;
- window.setTimeout(
- function(){
- slc.options[0].selected = false;
+ window.setTimeout(function(){
+ slc.options[0].selected = false;
- if(slc.options[index].value=='')
- slc.options[index].selected = false;
- else
- slc.options[index].selected = true;
- if(doFilter) o.Filter();
- },
- .1
- );
+ if(slc.options[index].value=='')
+ slc.options[index].selected = false;
+ else
+ slc.options[index].selected = true;
+ if(doFilter) o.Filter();
+ }, 0.1);
},
__getCustomValues: function(colIndex)