diff --git a/src/tablefilter_all.js b/src/tablefilter_all.js index ce66a9b3..47f5bcbb 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 @@ -2334,9 +2334,11 @@ TF.prototype = { }; } + var slcPages; + // Paging drop-down list selector if(this.pageSelectorType === this.fltTypeSlc){ - var slcPages = tf_CreateElm( + slcPages = tf_CreateElm( this.fltTypeSlc, ['id',this.prfxSlcPages+this.id]); slcPages.className = this.pgSlcCssClass; slcPages.onchange = this.Evt._OnSlcPagesChange; @@ -2344,7 +2346,7 @@ TF.prototype = { // Paging input selector if(this.pageSelectorType === this.fltTypeInp){ - var slcPages = tf_CreateElm( + slcPages = tf_CreateElm( this.fltTypeInp, ['id',this.prfxSlcPages+this.id], ['value',this.currentPageNb] @@ -2481,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