1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-20 23:36:39 +02:00

Merge pull request #464 from koalyptus/refactor-paging-options

Refactor paging options
This commit is contained in:
koalyptus 2017-06-15 13:43:50 +10:00 committed by GitHub
commit ab9ff96684
32 changed files with 213 additions and 200 deletions

View file

@ -13,7 +13,7 @@
"keyword-spacing": ["error", { "after": true, "before": true }],
"max-depth": [2, 7],
"max-statements": [2, 143],
"complexity": [2, 82],
"complexity": [2, 83],
"no-unused-vars": 2,
"no-eval": 2,
"no-underscore-dangle": 0,

4
dist/starter.html vendored
View file

@ -1,10 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>tablefilter v0.5.20 - Starter</title>
<title>tablefilter v0.5.21 - Starter</title>
</head>
<body>
<h1>tablefilter v0.5.20</h1>
<h1>tablefilter v0.5.21</h1>

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.20 by Max Guglielmi
* build date: 2017-06-04T08:16:15.416Z
* tablefilter v0.5.21 by Max Guglielmi
* build date: 2017-06-14T12:10:10.152Z
* MIT License
*/
span.colVisSpan{text-align:left;}span.colVisSpan a.colVis{display:inline-block;padding:7px 5px 0;font-size:inherit;font-weight:inherit;vertical-align:top}div.colVisCont{position:relative;background:#fff;-webkit-box-shadow:3px 3px 2px #888;-moz-box-shadow:3px 3px 2px #888;box-shadow:3px 3px 2px #888;position:absolute;display:none;border:1px solid #ccc;height:auto;width:250px;background-color:#fff;margin:35px 0 0 -100px;z-index:10000;padding:10px 10px 10px 10px;text-align:left;font-size:12px;}div.colVisCont:after,div.colVisCont:before{bottom:100%;left:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.colVisCont:after{border-color:rgba(255,255,255,0);border-bottom-color:#fff;border-width:10px;margin-left:-10px}div.colVisCont:before{border-color:rgba(255,255,255,0);border-bottom-color:#ccc;border-width:12px;margin-left:-12px}div.colVisCont p{margin:6px auto 6px auto}div.colVisCont a.colVis{display:initial;font-weight:inherit}ul.cols_checklist{padding:0;margin:0;list-style:none;}ul.cols_checklist label{display:block}ul.cols_checklist input{vertical-align:middle;margin:2px 5px 2px 1px}li.cols_checklist_item{padding:4px;margin:0;}li.cols_checklist_item:hover{background-color:#335ea8;color:#fff}.cols_checklist_slc_item{background-color:#335ea8;color:#fff}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.20 by Max Guglielmi
* build date: 2017-06-04T08:16:15.416Z
* tablefilter v0.5.21 by Max Guglielmi
* build date: 2017-06-14T12:10:10.152Z
* MIT License
*/
span.expClpFlt a.btnExpClpFlt{width:35px;height:35px;display:inline-block;}span.expClpFlt a.btnExpClpFlt:hover{background-color:#f4f4f4}span.expClpFlt img{padding:8px 11px 11px 11px}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.20 by Max Guglielmi
* build date: 2017-06-04T08:16:15.416Z
* tablefilter v0.5.21 by Max Guglielmi
* build date: 2017-06-14T12:10:10.152Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.20 by Max Guglielmi
* build date: 2017-06-04T08:16:15.416Z
* tablefilter v0.5.21 by Max Guglielmi
* build date: 2017-06-14T12:10:10.152Z
* MIT License
*/
table.TF{border-left:1px solid #ccc;border-top:none;border-right:none;border-bottom:none;}table.TF th{background:#ebecee url("images/bg_th.jpg") left top repeat-x;border-bottom:1px solid #d0d0d0;border-right:1px solid #d0d0d0;border-left:1px solid #fff;border-top:1px solid #fff;color:#333}table.TF td{border-bottom:1px dotted #999;padding:5px}.fltrow{background-color:#ebecee !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #666 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #999 !important}input.flt{width:99% !important}.inf{height:$min-height;background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important}input.reset{background:transparent url("images/btn_eraser.gif") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;}.nextPage:hover{background:transparent url("images/btn_over_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important;}.previousPage:hover{background:transparent url("images/btn_over_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;}.firstPage:hover{background:transparent url("images/btn_over_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;}.lastPage:hover{background:transparent url("images/btn_over_last_page.gif") center center no-repeat !important}div.grd_Cont{background-color:#ebecee !important;border:1px solid #ccc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#d5d5d5}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important;}div.grd_headTblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#ebecee url("images/bg_th.jpg") left top repeat-x !important;border-bottom:1px solid #d0d0d0 !important;border-right:1px solid #d0d0d0 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #999 !important}.grd_inf{background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important;border-top:1px solid #d0d0d0 !important}.loader{border:1px solid #999}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#fff}.odd{background-color:#d5d5d5}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#999 !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.20 by Max Guglielmi
* build date: 2017-06-04T08:16:15.416Z
* tablefilter v0.5.21 by Max Guglielmi
* build date: 2017-06-14T12:10:10.152Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b;border-top:none;border-right:0;border-bottom:none;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x;border-bottom:0;border-right:1px dotted #d0d0d0;border-left:0;border-top:0;color:#fff}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px}.fltrow{background-color:#81963b !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #687830 !important}input.flt{width:99% !important}.inf{background:#d8d8d8;height:$min-height}input.reset{width:53px;background:transparent url("images/btn_filter.png") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important}div.grd_Cont{background:#81963b url("images/bg_headers.jpg") left top repeat-x !important;border:1px solid #ccc !important;padding:0 1px 1px 1px !important;}div.grd_Cont .even{background-color:#bccd83}div.grd_Cont .odd{background-color:#fff}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important;}div.grd_tblCont table td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b}div.grd_tblCont table th,div.grd_headTblCont table th{background:transparent url("images/bg_headers.jpg") 0 0 repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;padding:0 4px 0 4px !important;color:#fff !important;height:35px !important}div.grd_headTblCont table td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;background-color:#81963b !important;padding:1px 3px 1px 3px !important}.grd_inf{background-color:#d8d8d8;border-top:1px solid #d0d0d0 !important}.loader{border:0 !important;background:#81963b !important}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#bccd83}.odd{background-color:#fff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#81963b !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.20 by Max Guglielmi
* build date: 2017-06-04T08:16:15.416Z
* tablefilter v0.5.21 by Max Guglielmi
* build date: 2017-06-14T12:10:10.152Z
* MIT License
*/
table.TF{padding:0;color:#000;border-right:1px solid #a4bed4;border-top:1px solid #a4bed4;border-left:1px solid #a4bed4;border-bottom:0;}table.TF th{margin:0;color:inherit;background:#d1e5fe url("images/bg_skyblue.gif") 0 0 repeat-x;border-color:#fdfdfd #a4bed4 #a4bed4 #fdfdfd;border-width:1px;border-style:solid}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid #a4bed4;border-left:0;border-top:0;border-right:0}.fltrow{background-color:#d1e5fe !important;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4 !important}input.flt{width:99% !important}.inf{background-color:#e3efff !important;border:1px solid #a4bed4;height:$min-height;color:#004a6f}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#ffe4ab url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#ffe4ab url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#ffe4ab url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#ffe4ab url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #ffb552 !important}.activeHeader{background:#ffe4ab !important;border:1px solid #ffb552 !important;color:inherit !important}div.grd_Cont{background-color:#d9eaed !important;border:1px solid #9cc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#e3efff}div.grd_headTblCont{background-color:#d9eaed !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#d9eaed url("images/bg_skyblue.gif") left top repeat-x;border-bottom:1px solid #a4bed4;border-right:1px solid #a4bed4 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #a4bed4 !important;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:#cce2fe;color:#004a6f;border-top:1px solid #9cc !important;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#2d8eef;border:1px solid #cce2fe;border-radius:5px}.even{background-color:#fff}.odd{background-color:#e3efff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ffdc61 !important;color:inherit}.ezSelectedRow{background-color:#ffe4ab !important;color:inherit}.ezActiveCell{background-color:#fff !important;color:#000 !important;font-weight:bold}.ezETSelectedCell{background-color:#fff !important;font-weight:bold;color:#000 !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.5.20 by Max Guglielmi
* build date: 2017-06-04T08:16:15.416Z
* tablefilter v0.5.21 by Max Guglielmi
* build date: 2017-06-14T12:10:10.152Z
* MIT License
*/
table.TF{padding:0;color:inherit;border-right:1px solid transparent;border-top:1px solid transparent;border-left:1px solid transparent;border-bottom:0;}table.TF th{margin:0;color:inherit;background-color:transparent;border-color:transparent;border-width:1px;border-style:solid;}table.TF th:last-child{border-right:1px solid transparent}table.TF td{margin:0;padding:5px;color:inherit;border-bottom:1px solid transparent;border-left:0;border-top:0;border-right:0}.fltrow{background-color:transparent;}.fltrow th,.fltrow td{padding:1px 3px 1px 3px;border-bottom:1px solid transparent !important;}.fltrow th:last-child,.fltrow td:last-child{border-right:1px solid transparent}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #a4bed4}input.flt{width:99% !important}.inf{background-color:transparent;border:1px solid transparent;height:$min-height;color:inherit}div.tot,div.status{border-right:0 !important}.helpBtn:hover{background-color:transparent}input.reset{background:transparent url("images/icn_clear_filters.png") center center no-repeat !important}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.nextPage:hover{background:#f7f7f7 url("images/btn_next_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.previousPage{background:transparent url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.previousPage:hover{background:#f7f7f7 url("images/btn_prev_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.firstPage:hover{background:#f7f7f7 url("images/btn_first_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid transparent !important;}.lastPage:hover{background:#f7f7f7 url("images/btn_last_page.gif") center center no-repeat !important;border:1px solid #f7f7f7 !important}.activeHeader{background:#f7f7f7 !important;border:1px solid transparent;color:inherit !important}div.grd_Cont{-webkit-box-shadow:0 0 0 0 rgba(50,50,50,0.75);-moz-box-shadow:0 0 0 0 rgba(50,50,50,0.75);box-shadow:0 0 0 0 rgba(50,50,50,0.75);background-color:transparent;border:1px solid transparent;padding:0 !important;}div.grd_Cont .even{background-color:transparent}div.grd_Cont .odd{background-color:#f7f7f7}div.grd_headTblCont{background-color:transparent;border-bottom:none !important}div.grd_tblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:transparent;border-bottom:1px solid transparent;border-right:1px solid transparent !important;border-left:1px solid transparent;border-top:1px solid transparent}div.grd_tblCont table td{border-bottom:1px solid transparent;border-right:0 !important;border-left:0 !important;border-top:0 !important}.grd_inf{background-color:transparent;color:inherit;border-top:1px solid transparent;}.grd_inf a{text-decoration:none;font-weight:bold}.loader{background-color:#f7f7f7;border:1px solid #f7f7f7;border-radius:5px;color:#000;text-shadow:none}.even{background-color:transparent}.odd{background-color:#f7f7f7}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.ezActiveRow{background-color:#ccc !important;color:inherit}.ezSelectedRow{background-color:#ccc !important;color:inherit}.ezActiveCell{background-color:transparent;color:inherit;font-weight:bold}.ezETSelectedCell{background-color:transparent;font-weight:bold;color:inherit}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "tablefilter",
"version": "0.5.20",
"version": "0.5.21",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {

View file

@ -208,7 +208,7 @@ export default class AdapterEzEditTable extends Feature {
paging = tf.feature('paging'),
//pgup/pgdown keys
d = keyCode === 34 || keyCode === 33 ?
(paging && paging.pagingLength || et.nbRowsPerPage) :
(paging && paging.pageLength || et.nbRowsPerPage) :
1;
//If next row is not valid, next valid filtered row needs to be
@ -278,11 +278,11 @@ export default class AdapterEzEditTable extends Feature {
if (tf.feature('paging').nbPages > 1) {
let paging = tf.feature('paging');
//page length is re-assigned in case it has changed
et.nbRowsPerPage = paging.pagingLength;
et.nbRowsPerPage = paging.pageLength;
let validIndexes = tf.validRowsIndex,
validIdxLen = validIndexes.length,
pagingEndRow = parseInt(paging.startPagingRow, 10) +
parseInt(paging.pagingLength, 10);
parseInt(paging.pageLength, 10);
let rowIndex = row.rowIndex;
if ((rowIndex === validIndexes[validIdxLen - 1]) &&

View file

@ -20,55 +20,55 @@ export class Paging extends Feature {
super(tf, 'paging');
// Configuration object
var f = this.config;
let f = this.config.paging || {};
/**
* Css class for the paging buttons (previous, next, etc.)
* @type {String}
*/
this.btnPageCssClass = f.paging_btn_css_class || 'pgInp';
this.btnCssClass = f.btn_css_class || 'pgInp';
/**
* Main select DOM element
* @type {DOMElement}
*/
this.pagingSlc = null;
this.pageSlc = null;
/**
* Results per page select DOM element
* @type {DOMElement}
*/
this.resultsPerPageSlc = null;
this.pageLengthSlc = null;
/**
* ID of custom container element
* @type {String}
*/
this.pagingTgtId = f.paging_target_id || null;
this.tgtId = f.target_id || null;
/**
* Number of rows contained in a page
* @type {Number}
*/
this.pagingLength = !isNaN(f.paging_length) ? f.paging_length : 10;
this.pageLength = !isNaN(f.length) ? f.length : 10;
/**
* ID of custom container element for the results per page selector
* @type {String}
*/
this.resultsPerPageTgtId = f.results_per_page_target_id || null;
this.pageLengthTgtId = f.results_per_page_target_id || null;
/**
* Css class for the paging select element
* @type {String}
*/
this.pgSlcCssClass = f.paging_slc_css_class || 'pgSlc';
this.pgSlcCssClass = f.slc_css_class || 'pgSlc';
/**
* Css class for the paging input element
* @type {String}
*/
this.pgInpCssClass = f.paging_inp_css_class || 'pgNbInp';
this.pgInpCssClass = f.inp_css_class || 'pgNbInp';
/**
* Label and values for the results per page select, example of usage:
@ -146,7 +146,7 @@ export class Paging extends Feature {
*/
this.btnNextPageHtml = f.btn_next_page_html ||
(!tf.enableIcons ? null :
'<input type="button" value="" class="' + this.btnPageCssClass +
'<input type="button" value="" class="' + this.btnCssClass +
' nextPage" title="Next page" />');
/**
@ -155,7 +155,7 @@ export class Paging extends Feature {
*/
this.btnPrevPageHtml = f.btn_prev_page_html ||
(!tf.enableIcons ? null :
'<input type="button" value="" class="' + this.btnPageCssClass +
'<input type="button" value="" class="' + this.btnCssClass +
' previousPage" title="Previous page" />');
/**
@ -164,7 +164,7 @@ export class Paging extends Feature {
*/
this.btnFirstPageHtml = f.btn_first_page_html ||
(!tf.enableIcons ? null :
'<input type="button" value="" class="' + this.btnPageCssClass +
'<input type="button" value="" class="' + this.btnCssClass +
' firstPage" title="First page" />');
/**
@ -173,7 +173,7 @@ export class Paging extends Feature {
*/
this.btnLastPageHtml = f.btn_last_page_html ||
(!tf.enableIcons ? null :
'<input type="button" value="" class="' + this.btnPageCssClass +
'<input type="button" value="" class="' + this.btnCssClass +
' lastPage" title="Last page" />');
/**
@ -198,7 +198,7 @@ export class Paging extends Feature {
* Determines if paging buttons are enabled (default: true)
* @type {Boolean}
*/
this.hasPagingBtns = f.paging_btns === false ? false : true;
this.hasBtns = f.btns === false ? false : true;
/**
* Defines page selector type, two possible values: 'select', 'input'
@ -269,12 +269,12 @@ export class Paging extends Feature {
*/
this.pgAfter = null;
var start_row = tf.refRow;
var nrows = tf.getRowsNb(true);
let startRow = tf.refRow;
let nrows = tf.getRowsNb(true);
//calculates page nb
this.nbPages = Math.ceil((nrows - start_row) / this.pagingLength);
this.nbPages = Math.ceil((nrows - startRow) / this.pageLength);
var o = this;
let o = this;
/**
* Paging DOM events handlers
* @type {String}
@ -283,21 +283,21 @@ export class Paging extends Feature {
this.evt = {
slcIndex() {
return (o.pageSelectorType === SELECT) ?
o.pagingSlc.options.selectedIndex :
parseInt(o.pagingSlc.value, 10) - 1;
o.pageSlc.options.selectedIndex :
parseInt(o.pageSlc.value, 10) - 1;
},
nbOpts() {
return (o.pageSelectorType === SELECT) ?
parseInt(o.pagingSlc.options.length, 10) - 1 :
parseInt(o.pageSlc.options.length, 10) - 1 :
(o.nbPages - 1);
},
next() {
var nextIndex = o.evt.slcIndex() < o.evt.nbOpts() ?
let nextIndex = o.evt.slcIndex() < o.evt.nbOpts() ?
o.evt.slcIndex() + 1 : 0;
o.changePage(nextIndex);
},
prev() {
var prevIndex = o.evt.slcIndex() > 0 ?
let prevIndex = o.evt.slcIndex() > 0 ?
o.evt.slcIndex() - 1 : o.evt.nbOpts();
o.changePage(prevIndex);
},
@ -308,7 +308,7 @@ export class Paging extends Feature {
o.changePage(0);
},
_detectKey(e) {
var key = keyCode(e);
let key = keyCode(e);
if (key === ENTER_KEY) {
if (tf.sorted) {
tf.filter();
@ -331,9 +331,9 @@ export class Paging extends Feature {
* Initialize DOM elements
*/
init() {
var slcPages;
var tf = this.tf;
var evt = this.evt;
let slcPages;
let tf = this.tf;
let evt = this.evt;
if (this.initialized) {
return;
@ -345,13 +345,13 @@ export class Paging extends Feature {
if (this.resultsPerPage.length < 2) {
this.hasResultsPerPage = false;
} else {
this.pagingLength = this.resultsPerPage[1][0];
this.pageLength = this.resultsPerPage[1][0];
this.setResultsPerPage();
}
}
evt.slcPagesChange = (event) => {
var slc = event.target;
let slc = event.target;
this.changePage(slc.selectedIndex);
};
@ -370,20 +370,20 @@ export class Paging extends Feature {
}
// btns containers
var btnNextSpan = createElm('span');
var btnPrevSpan = createElm('span');
var btnLastSpan = createElm('span');
var btnFirstSpan = createElm('span');
let btnNextSpan = createElm('span');
let btnPrevSpan = createElm('span');
let btnLastSpan = createElm('span');
let btnFirstSpan = createElm('span');
if (this.hasPagingBtns) {
if (this.hasBtns) {
// Next button
if (!this.btnNextPageHtml) {
var btnNext = createElm(INPUT,
let btnNext = createElm(INPUT,
['type', 'button'],
['value', this.btnNextPageText],
['title', 'Next']
);
btnNext.className = this.btnPageCssClass;
btnNext.className = this.btnCssClass;
addEvt(btnNext, 'click', evt.next);
btnNextSpan.appendChild(btnNext);
} else {
@ -392,12 +392,12 @@ export class Paging extends Feature {
}
// Previous button
if (!this.btnPrevPageHtml) {
var btnPrev = createElm(INPUT,
let btnPrev = createElm(INPUT,
['type', 'button'],
['value', this.btnPrevPageText],
['title', 'Previous']
);
btnPrev.className = this.btnPageCssClass;
btnPrev.className = this.btnCssClass;
addEvt(btnPrev, 'click', evt.prev);
btnPrevSpan.appendChild(btnPrev);
} else {
@ -406,12 +406,12 @@ export class Paging extends Feature {
}
// Last button
if (!this.btnLastPageHtml) {
var btnLast = createElm(INPUT,
let btnLast = createElm(INPUT,
['type', 'button'],
['value', this.btnLastPageText],
['title', 'Last']
);
btnLast.className = this.btnPageCssClass;
btnLast.className = this.btnCssClass;
addEvt(btnLast, 'click', evt.last);
btnLastSpan.appendChild(btnLast);
} else {
@ -420,12 +420,12 @@ export class Paging extends Feature {
}
// First button
if (!this.btnFirstPageHtml) {
var btnFirst = createElm(INPUT,
let btnFirst = createElm(INPUT,
['type', 'button'],
['value', this.btnFirstPageText],
['title', 'First']
);
btnFirst.className = this.btnPageCssClass;
btnFirst.className = this.btnCssClass;
addEvt(btnFirst, 'click', evt.first);
btnFirstSpan.appendChild(btnFirst);
} else {
@ -435,23 +435,23 @@ export class Paging extends Feature {
}
// paging elements (buttons+drop-down list) are added to defined element
if (!this.pagingTgtId) {
if (!this.tgtId) {
tf.setToolbar();
}
var targetEl = !this.pagingTgtId ? tf.mDiv : elm(this.pagingTgtId);
let targetEl = !this.tgtId ? tf.mDiv : elm(this.tgtId);
targetEl.appendChild(btnFirstSpan);
targetEl.appendChild(btnPrevSpan);
var pgBeforeSpan = createElm('span');
let pgBeforeSpan = createElm('span');
pgBeforeSpan.appendChild(createText(this.pageText));
pgBeforeSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgBeforeSpan);
targetEl.appendChild(slcPages);
var pgAfterSpan = createElm('span');
let pgAfterSpan = createElm('span');
pgAfterSpan.appendChild(createText(this.ofText));
pgAfterSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgAfterSpan);
var pgSpan = createElm('span');
let pgSpan = createElm('span');
pgSpan.className = this.nbPgSpanCssClass;
pgSpan.appendChild(createText(' ' + this.nbPages + ' '));
targetEl.appendChild(pgSpan);
@ -465,7 +465,7 @@ export class Paging extends Feature {
this.pgCont = pgSpan;
this.pgBefore = pgBeforeSpan;
this.pgAfter = pgAfterSpan;
this.pagingSlc = slcPages;
this.pageSlc = slcPages;
this.setPagingInfo();
@ -512,31 +512,31 @@ export class Paging extends Feature {
* @param {Array} validRows Collection of valid rows
*/
setPagingInfo(validRows) {
var tf = this.tf;
var mdiv = !this.pagingTgtId ? tf.mDiv : elm(this.pagingTgtId);
let tf = this.tf;
let mdiv = !this.tgtId ? tf.mDiv : elm(this.tgtId);
//store valid rows indexes
tf.validRowsIndex = validRows || tf.getValidRows(true);
//calculate nb of pages
this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pagingLength);
this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pageLength);
//refresh page nb span
this.pgCont.innerHTML = this.nbPages;
//select clearing shortcut
if (this.pageSelectorType === SELECT) {
this.pagingSlc.innerHTML = '';
this.pageSlc.innerHTML = '';
}
if (this.nbPages > 0) {
mdiv.style.visibility = 'visible';
if (this.pageSelectorType === SELECT) {
for (var z = 0; z < this.nbPages; z++) {
var opt = createOpt(z + 1, z * this.pagingLength, false);
this.pagingSlc.options[z] = opt;
for (let z = 0; z < this.nbPages; z++) {
let opt = createOpt(z + 1, z * this.pageLength, false);
this.pageSlc.options[z] = opt;
}
} else {
//input type
this.pagingSlc.value = this.currentPageNb;
this.pageSlc.value = this.currentPageNb;
}
} else {
@ -551,10 +551,10 @@ export class Paging extends Feature {
* @param {Array} validRows Collection of valid rows
*/
groupByPage(validRows) {
var tf = this.tf;
var rows = tf.dom().rows;
var startPagingRow = parseInt(this.startPagingRow, 10);
var endPagingRow = startPagingRow + parseInt(this.pagingLength, 10);
let tf = this.tf;
let rows = tf.dom().rows;
let startPagingRow = parseInt(this.startPagingRow, 10);
let endPagingRow = startPagingRow + parseInt(this.pageLength, 10);
//store valid rows indexes
if (validRows) {
@ -562,11 +562,11 @@ export class Paging extends Feature {
}
//this loop shows valid rows of current page
for (var h = 0, len = tf.getValidRowsNb(true); h < len; h++) {
var validRowIdx = tf.validRowsIndex[h];
var r = rows[validRowIdx];
var isRowValid = r.getAttribute('validRow');
var rowDisplayed = false;
for (let h = 0, len = tf.getValidRowsNb(true); h < len; h++) {
let validRowIdx = tf.validRowsIndex[h];
let r = rows[validRowIdx];
let isRowValid = r.getAttribute('validRow');
let rowDisplayed = false;
if (h >= startPagingRow && h < endPagingRow) {
if (isNull(isRowValid) || Boolean(isRowValid === 'true')) {
@ -597,11 +597,11 @@ export class Paging extends Feature {
* 'previous', 'last', 'first' or page number as per param
*/
setPage(cmd) {
var tf = this.tf;
let tf = this.tf;
if (!tf.isInitialized() || !this.isEnabled()) {
return;
}
var btnEvt = this.evt,
let btnEvt = this.evt,
cmdtype = typeof cmd;
if (cmdtype === 'string') {
switch (cmd.toLowerCase()) {
@ -631,10 +631,10 @@ export class Paging extends Feature {
* Generates UI elements for the number of results per page drop-down
*/
setResultsPerPage() {
var tf = this.tf;
var evt = this.evt;
let tf = this.tf;
let evt = this.evt;
if (this.resultsPerPageSlc || !this.resultsPerPage) {
if (this.pageLengthSlc || !this.resultsPerPage) {
return;
}
@ -643,22 +643,22 @@ export class Paging extends Feature {
ev.target.blur();
};
var slcR = createElm(SELECT);
let slcR = createElm(SELECT);
slcR.className = this.resultsSlcCssClass;
var slcRText = this.resultsPerPage[0],
let slcRText = this.resultsPerPage[0],
slcROpts = this.resultsPerPage[1];
var slcRSpan = createElm('span');
let slcRSpan = createElm('span');
slcRSpan.className = this.resultsSpanCssClass;
// results per page select is added to external element
if (!this.resultsPerPageTgtId) {
if (!this.pageLengthTgtId) {
tf.setToolbar();
}
var targetEl = !this.resultsPerPageTgtId ?
tf.rDiv : elm(this.resultsPerPageTgtId);
let targetEl = !this.pageLengthTgtId ?
tf.rDiv : elm(this.pageLengthTgtId);
slcRSpan.appendChild(createText(slcRText));
var help = tf.feature('help');
let help = tf.feature('help');
if (help && help.btn) {
help.btn.parentNode.insertBefore(slcRSpan, help.btn);
help.btn.parentNode.insertBefore(slcR, help.btn);
@ -667,31 +667,31 @@ export class Paging extends Feature {
targetEl.appendChild(slcR);
}
for (var r = 0; r < slcROpts.length; r++) {
var currOpt = new Option(slcROpts[r], slcROpts[r], false, false);
for (let r = 0; r < slcROpts.length; r++) {
let currOpt = new Option(slcROpts[r], slcROpts[r], false, false);
slcR.options[r] = currOpt;
}
addEvt(slcR, 'change', evt.slcResultsChange);
this.slcResultsTxt = slcRSpan;
this.resultsPerPageSlc = slcR;
this.pageLengthSlc = slcR;
}
/**
* Remove number of results per page UI elements
*/
removeResultsPerPage() {
var tf = this.tf;
if (!tf.isInitialized() || !this.resultsPerPageSlc ||
let tf = this.tf;
if (!tf.isInitialized() || !this.pageLengthSlc ||
!this.resultsPerPage) {
return;
}
if (this.resultsPerPageSlc) {
removeElm(this.resultsPerPageSlc);
if (this.pageLengthSlc) {
removeElm(this.pageLengthSlc);
}
if (this.slcResultsTxt) {
removeElm(this.slcResultsTxt);
}
this.resultsPerPageSlc = null;
this.pageLengthSlc = null;
this.slcResultsTxt = null;
}
@ -700,7 +700,7 @@ export class Paging extends Feature {
* @param {Number} index Index of the page (0-n)
*/
changePage(index) {
var tf = this.tf;
let tf = this.tf;
if (!this.isEnabled()) {
return;
@ -710,20 +710,20 @@ export class Paging extends Feature {
if (index === null) {
index = this.pageSelectorType === SELECT ?
this.pagingSlc.options.selectedIndex : this.pagingSlc.value - 1;
this.pageSlc.options.selectedIndex : this.pageSlc.value - 1;
}
if (index >= 0 && index <= (this.nbPages - 1)) {
this.onBeforeChangePage(this, (index + 1));
this.currentPageNb = parseInt(index, 10) + 1;
if (this.pageSelectorType === SELECT) {
this.pagingSlc.options[index].selected = true;
this.pageSlc.options[index].selected = true;
} else {
this.pagingSlc.value = this.currentPageNb;
this.pageSlc.value = this.currentPageNb;
}
this.startPagingRow = (this.pageSelectorType === SELECT) ?
this.pagingSlc.value : (index * this.pagingLength);
this.pageSlc.value : (index * this.pageLength);
this.groupByPage();
@ -742,7 +742,7 @@ export class Paging extends Feature {
return;
}
this.resultsPerPageSlc.value = val;
this.pageLengthSlc.value = val;
this.onChangeResultsPerPage();
}
@ -757,44 +757,44 @@ export class Paging extends Feature {
}
let {
resultsPerPageSlc: slcR, pageSelectorType, pagingSlc, emitter
pageLengthSlc: slcR, pageSelectorType, pageSlc, emitter
} = this;
emitter.emit('before-page-length-change', tf);
let slcIndex = slcR.selectedIndex;
let slcPagesSelIndex = (pageSelectorType === SELECT) ?
pagingSlc.selectedIndex : parseInt(pagingSlc.value - 1, 10);
this.pagingLength = parseInt(slcR.options[slcIndex].value, 10);
this.startPagingRow = this.pagingLength * slcPagesSelIndex;
pageSlc.selectedIndex : parseInt(pageSlc.value - 1, 10);
this.pageLength = parseInt(slcR.options[slcIndex].value, 10);
this.startPagingRow = this.pageLength * slcPagesSelIndex;
if (!isNaN(this.pagingLength)) {
if (!isNaN(this.pageLength)) {
if (this.startPagingRow >= tf.nbFilterableRows) {
this.startPagingRow = (tf.nbFilterableRows - this.pagingLength);
this.startPagingRow = (tf.nbFilterableRows - this.pageLength);
}
this.setPagingInfo();
if (pageSelectorType === SELECT) {
let slcIdx =
(pagingSlc.options.length - 1 <= slcPagesSelIndex) ?
(pagingSlc.options.length - 1) : slcPagesSelIndex;
pagingSlc.options[slcIdx].selected = true;
(pageSlc.options.length - 1 <= slcPagesSelIndex) ?
(pageSlc.options.length - 1) : slcPagesSelIndex;
pageSlc.options[slcIdx].selected = true;
}
}
emitter.emit('after-page-length-change', tf, this.pagingLength);
emitter.emit('after-page-length-change', tf, this.pageLength);
}
/**
* Re-set page nb at page re-load
*/
resetPage() {
var tf = this.tf;
let tf = this.tf;
if (!this.isEnabled()) {
return;
}
this.emitter.emit('before-reset-page', tf);
var pgNb = tf.feature('store').getPageNb();
let pgNb = tf.feature('store').getPageNb();
if (pgNb !== '') {
this.changePage((pgNb - 1));
}
@ -805,15 +805,15 @@ export class Paging extends Feature {
* Re-set page length value at page re-load
*/
resetPageLength() {
var tf = this.tf;
let tf = this.tf;
if (!this.isEnabled()) {
return;
}
this.emitter.emit('before-reset-page-length', tf);
var pglenIndex = tf.feature('store').getPageLength();
let pglenIndex = tf.feature('store').getPageLength();
if (pglenIndex !== '') {
this.resultsPerPageSlc.options[pglenIndex].selected = true;
this.pageLengthSlc.options[pglenIndex].selected = true;
this.changeResultsPerPage();
}
this.emitter.emit('after-reset-page-length', tf, pglenIndex);
@ -827,16 +827,16 @@ export class Paging extends Feature {
return;
}
var evt = this.evt;
let evt = this.evt;
if (this.pagingSlc) {
if (this.pageSlc) {
if (this.pageSelectorType === SELECT) {
removeEvt(this.pagingSlc, 'change', evt.slcPagesChange);
removeEvt(this.pageSlc, 'change', evt.slcPagesChange);
}
else if (this.pageSelectorType === INPUT) {
removeEvt(this.pagingSlc, 'keypress', evt._detectKey);
removeEvt(this.pageSlc, 'keypress', evt._detectKey);
}
removeElm(this.pagingSlc);
removeElm(this.pageSlc);
}
if (this.btnNextCont) {
@ -888,7 +888,7 @@ export class Paging extends Feature {
this.emitter.off(['change-page-results'],
(tf, pageLength) => this.changeResultsPerPage(pageLength));
this.pagingSlc = null;
this.pageSlc = null;
this.nbPages = 0;
this.initialized = false;

View file

@ -157,9 +157,9 @@ export class RowsCounter extends Feature {
let pagingStartRow = parseInt(paging.startPagingRow, 10) +
((nbValidRows > 0) ? 1 : 0);
let pagingEndRow =
(pagingStartRow + paging.pagingLength) - 1 <=
(pagingStartRow + paging.pageLength) - 1 <=
nbValidRows ?
pagingStartRow + paging.pagingLength - 1 :
pagingStartRow + paging.pageLength - 1 :
nbValidRows;
totTxt = pagingStartRow + this.fromToTextSeparator +
pagingEndRow + this.overText + nbValidRows;

View file

@ -765,9 +765,9 @@ export class TableFilter {
/**
* Enable paging component
* @type {Boolean}
* @type {Object|Boolean}
*/
this.paging = Boolean(f.paging);
this.paging = isObj(f.paging) || Boolean(f.paging);
/**
* Number of hidden rows

View file

@ -58,8 +58,9 @@ var tfConfig = {
rows_counter: true,
btn_reset: true,
status_bar: true,
paging: true,
paging_length: 15,
paging: {
length: 15
},
enable_empty_option: true,
enable_non_empty_option: true,
enable_default_theme: true,

View file

@ -30,8 +30,9 @@
<script data-config>
var filtersConfig = {
base_path: '../dist/tablefilter/',
paging: true,
results_per_page: ['Records: ', [10,25,50,100]],
paging: {
results_per_page: ['Records: ', [10, 25, 50, 100]]
},
state: {
types: ['local_storage'],
filters: true,

View file

@ -52,8 +52,9 @@
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
rows_always_visible: [4, 9],
paging: true,
paging_length: 2
paging: {
length: 2
}
});
tf.init();
var paging = tf.feature('paging');

View file

@ -6,8 +6,9 @@ var totRowIndex = table.getElementsByTagName('tr').length;
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
col_types: ['string', 'string', 'number', 'number', 'number'],
paging: true,
paging_length: 4,
paging: {
length: 4
},
rows_always_visible: [
totRowIndex-6,
totRowIndex-5,

View file

@ -10,8 +10,9 @@ var rowToAdd = tf.dom().rows[8];
var tf1 = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
rows_counter: true,
paging: true,
paging_length: 3
paging: {
length: 3
}
});
module('Sanity checks');

View file

@ -28,8 +28,9 @@ test('Sanity checks', function() {
base_path: '../dist/tablefilter/',
filters_row_index: 3,
headers_row_index: 2,
paging: true,
paging_length: 3
paging: {
length: 3
}
});
tf.init();

View file

@ -7,8 +7,9 @@ var tf = new TableFilter('demo', {
page_number: true,
page_length: true
},
paging: true,
results_per_page: ['Records: ', [2, 4, 6]],
paging: {
results_per_page: ['Records: ', [2, 4, 6]]
}
});
tf.init();
var state = tf.feature('state');

View file

@ -1,7 +1,8 @@
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
paging: true,
paging_length: 2,
paging: {
length: 2
},
results_per_page: ['Results per page ', [2,4,6]],
extensions: [{
name: 'sort',
@ -15,7 +16,7 @@ var paging = tf.feature('paging');
module('Sanity checks');
test('Paging component', function() {
notEqual(paging, null, 'Paging instanciated');
deepEqual(paging.pagingLength, 2, 'Paging length');
deepEqual(paging.pageLength, 2, 'Paging length');
deepEqual(paging.nbPages, 4, 'Number of pages');
});
test('Sort extension', function() {
@ -31,14 +32,14 @@ test('It contains options', function() {
var sort = tf.extension('sort');
sort.sortByColumnIndex(0);
deepEqual(paging.pagingSlc.options.length, 4, 'Expected options number');
deepEqual(paging.pageSlc.options.length, 4, 'Expected options number');
});
test('Can select a page', function() {
var sort = tf.extension('sort');
sort.sortByColumnIndex(1);
paging.setPage(3);
deepEqual(paging.pagingSlc.selectedIndex, 2, 'Expected selected option');
deepEqual(paging.pageSlc.selectedIndex, 2, 'Expected selected option');
});
module('Changing pages when column is sorted (issue #70)');

View file

@ -1,9 +1,10 @@
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
paging: true,
paging_length: 2,
results_per_page: ['Results per page ', [2, 4, 6]]
paging: {
length: 2,
results_per_page: ['Results per page ', [2, 4, 6]]
}
});
tf.init();
@ -11,7 +12,7 @@ var paging = tf.feature('paging');
module('Sanity checks');
test('Paging component', function() {
notEqual(paging, null, 'Paging instanciated');
deepEqual(paging.pagingLength, 2, 'Paging length');
deepEqual(paging.pageLength, 2, 'Paging length');
deepEqual(paging.nbPages, 4, 'Number of pages');
});
module('Feature interface');
@ -60,8 +61,8 @@ test('Can check is enabled', function() {
module('UI elements');
test('Paging UI elements', function() {
notEqual(paging.pagingSlc, null, 'Paging drop-down element');
notEqual(paging.resultsPerPageSlc, null,
notEqual(paging.pageSlc, null, 'Paging drop-down element');
notEqual(paging.pageLengthSlc, null,
'Number of results per page drop-down element');
notEqual(paging.btnNextCont, null, 'Next button container element');
notEqual(paging.btnPrevCont, null, 'Previous button container element');
@ -71,8 +72,8 @@ test('Paging UI elements', function() {
test('Destroy Paging component', function() {
paging.destroy();
deepEqual(paging.pagingSlc, null, 'Paging drop-down element');
deepEqual(paging.resultsPerPageSlc, null, 'Paging drop-down element');
deepEqual(paging.pageSlc, null, 'Paging drop-down element');
deepEqual(paging.pageLengthSlc, null, 'Paging drop-down element');
deepEqual(paging.btnNextCont, null, 'Next button container element');
deepEqual(paging.btnPrevCont, null, 'Previous button container element');
deepEqual(paging.btnLastCont, null, 'Last button container element');
@ -83,7 +84,7 @@ test('Destroy Paging component', function() {
test('Reset Paging component', function() {
paging.reset();
paging.setPage(2);
notEqual(paging.pagingSlc, null, 'Paging drop-down element');
notEqual(paging.pageSlc, null, 'Paging drop-down element');
});
module('Behaviour');
@ -92,7 +93,7 @@ test('Set page', function() {
deepEqual(paging.getPage(), 1, 'Expected page number');
paging.setPage(3);
deepEqual(paging.getPage(), 3, 'Expected page number');
deepEqual(paging.pagingSlc.selectedIndex, 2,
deepEqual(paging.pageSlc.selectedIndex, 2,
'Expected page number in paging drop-down selector');
});
@ -121,8 +122,8 @@ test('Can set page with command', function() {
});
test('Set page via drop-down page selector', function() {
paging.pagingSlc.selectedIndex = 3;
paging.changePage(paging.pagingSlc.selectedIndex);
paging.pageSlc.selectedIndex = 3;
paging.changePage(paging.pageSlc.selectedIndex);
deepEqual(paging.getPage(), 4, 'Expected page number');
});
@ -145,10 +146,10 @@ test('Filter with dummy value', function() {
test('Set results per page', function() {
tf.clearFilters();
paging.changeResultsPerPage('4');
deepEqual(paging.pagingLength, 4, 'Expected page length');
deepEqual(paging.pageLength, 4, 'Expected page length');
deepEqual(paging.nbPages, 2, 'Expected number of pages');
paging.changeResultsPerPage('6');
deepEqual(paging.pagingLength, 6, 'Expected page length');
deepEqual(paging.pageLength, 6, 'Expected page length');
deepEqual(paging.nbPages, 2, 'Expected number of pages');
});
@ -159,16 +160,17 @@ test('Grid layout with paging', function() {
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
grid_layout: true,
paging: true,
paging_length: 2,
results_per_page: ['Results per page ', [2,4,6]]
paging: {
length: 2,
results_per_page: ['Results per page ', [2, 4, 6]]
}
});
tf.init();
paging = tf.feature('paging');
notEqual(paging.pagingSlc, null, 'Paging drop-down element');
notEqual(paging.resultsPerPageSlc, null,
notEqual(paging.pageSlc, null, 'Paging drop-down element');
notEqual(paging.pageLengthSlc, null,
'Number of results per page drop-down element');
notEqual(paging.btnNextCont, null, 'Next button container element');
notEqual(paging.btnPrevCont, null, 'Previous button container element');
@ -209,8 +211,8 @@ test('Can set page with command', function() {
});
test('Set page via drop-down page selector', function() {
paging.pagingSlc.selectedIndex = 3;
paging.changePage(paging.pagingSlc.selectedIndex);
paging.pageSlc.selectedIndex = 3;
paging.changePage(paging.pageSlc.selectedIndex);
deepEqual(paging.getPage(), 4, 'Expected page number');
});
@ -233,10 +235,10 @@ test('Filter with dummy value', function() {
test('Set results per page', function() {
tf.clearFilters();
paging.changeResultsPerPage('4');
deepEqual(paging.pagingLength, 4, 'Expected page length');
deepEqual(paging.pageLength, 4, 'Expected page length');
deepEqual(paging.nbPages, 2, 'Expected number of pages');
paging.changeResultsPerPage('6');
deepEqual(paging.pagingLength, 6, 'Expected page length');
deepEqual(paging.pageLength, 6, 'Expected page length');
deepEqual(paging.nbPages, 2, 'Expected number of pages');
});
@ -251,7 +253,7 @@ test('Set results per page when no valid rows', function() {
paging.changeResultsPerPage('4');
// assert
deepEqual(paging.resultsPerPageSlc.value, '4', 'Select page length option');
deepEqual(paging.pageLengthSlc.value, '4', 'Select page length option');
deepEqual(paging.getPage(), 1, 'Expected page number');
});
@ -260,7 +262,7 @@ test('can destroy and init TableFilter', function() {
tf.destroy();
tf.init();
notEqual(paging, null, 'Paging instanciated');
deepEqual(paging.pagingLength, 2, 'Paging length');
deepEqual(paging.pageLength, 2, 'Paging length');
deepEqual(paging.nbPages, 4, 'Number of pages');
});

View file

@ -85,8 +85,9 @@ test('RowsCounter component with paging', function() {
separator: '~',
over_text: ' \\ '
},
paging: true,
paging_length: 3
paging: {
length: 3
}
});
tf.init();
equal(tf.feature('rowsCounter').label.innerHTML,

View file

@ -7,8 +7,9 @@ var tf = new TableFilter('demo', {
page_number: true,
page_length: true
},
paging: true,
results_per_page: ['Records: ', [2, 4, 6]],
paging: {
results_per_page: ['Records: ', [2, 4, 6]]
}
});
tf.init();
var state = tf.feature('state');

View file

@ -7,8 +7,9 @@ var tf = new TableFilter('demo', {
page_number: true,
page_length: true
},
paging: true,
results_per_page: ['Records: ', [2, 4, 6]],
paging: {
results_per_page: ['Records: ', [2, 4, 6]],
}
});
tf.init();
var state = tf.feature('state');