1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-10 18:36:43 +02:00

Removed element IDs from paging

This commit is contained in:
Max Guglielmi 2016-11-05 22:08:32 +11:00
parent 3ff52002e4
commit e8a2ada208
12 changed files with 137 additions and 198 deletions

4
dist/starter.html vendored
View file

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

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.7 by Max Guglielmi
* build date: 2016-11-03T11:02:32.318Z
* tablefilter v0.4.8 by Max Guglielmi
* build date: 2016-11-05T11:03:38.397Z
* 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.4.7 by Max Guglielmi
* build date: 2016-11-03T11:02:32.318Z
* tablefilter v0.4.8 by Max Guglielmi
* build date: 2016-11-05T11:03:38.397Z
* 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.4.7 by Max Guglielmi
* build date: 2016-11-03T11:02:32.318Z
* tablefilter v0.4.8 by Max Guglielmi
* build date: 2016-11-05T11:03:38.397Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.7 by Max Guglielmi
* build date: 2016-11-03T11:02:32.318Z
* tablefilter v0.4.8 by Max Guglielmi
* build date: 2016-11-05T11:03:38.397Z
* 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.4.7 by Max Guglielmi
* build date: 2016-11-03T11:02:32.318Z
* tablefilter v0.4.8 by Max Guglielmi
* build date: 2016-11-05T11:03:38.397Z
* 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.4.7 by Max Guglielmi
* build date: 2016-11-03T11:02:32.318Z
* tablefilter v0.4.8 by Max Guglielmi
* build date: 2016-11-05T11:03:38.397Z
* 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}

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.4.7 by Max Guglielmi
* build date: 2016-11-03T11:02:32.299Z
* tablefilter v0.4.8 by Max Guglielmi
* build date: 2016-11-05T11:03:38.311Z
* MIT License
*/

View file

@ -1,6 +1,6 @@
{
"name": "tablefilter",
"version": "0.4.7",
"version": "0.4.8",
"description": "A Javascript library making HTML tables filterable and a bit more",
"license": "MIT",
"author": {
@ -22,7 +22,14 @@
"pagination"
],
"scripts": {
"test": "grunt test"
"dev": "grunt dev",
"build": "grunt build",
"build-demos": "grunt build-demos",
"server": "grunt server",
"eslint": "grunt eslint",
"test": "grunt test",
"esdoc": "grunt esdoc",
"all": "grunt"
},
"publishConfig": {
"tag": "next"
@ -33,7 +40,7 @@
"babel-loader": "^6.2.6",
"babel-plugin-transform-es2015-classes": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"clean-webpack-plugin": "^0.1.13",
"clean-webpack-plugin": "^0.1.14",
"diacritics": "1.2.3",
"grunt": "^1.0.1",
"grunt-babel": "^6.0.0",
@ -50,7 +57,7 @@
"grunt-webpack": "^1.0.18",
"script-loader": "^0.7.0",
"string-replace-webpack-plugin": "^0.0.4",
"sugar-date": "2.0.0",
"sugar-date": "2.0.2",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2"
},

View file

@ -220,93 +220,54 @@ export class Paging extends Feature {
this.onAfterChangePage = isFn(f.on_after_change_page) ?
f.on_after_change_page : null;
/**
* Element IDs prefixes
*/
/**
* Page select
* @type {String}
* @private
*/
this.prfxSlcPages = 'slcPages_';
/**
* Results per page select
* @type {String}
* @private
*/
this.prfxSlcResults = 'slcResults_';
/**
* Label preciding results per page select
* @type {String}
* @type {DOMElement}
* @private
*/
this.prfxSlcResultsTxt = 'slcResultsTxt_';
this.slcResultsTxt = null;
/**
* Span containing next page button
* @type {String}
* @type {DOMElement}
* @private
*/
this.prfxBtnNextSpan = 'btnNextSpan_';
this.btnNextCont = null;
/**
* Span containing previous page button
* @type {String}
* @type {DOMElement}
* @private
*/
this.prfxBtnPrevSpan = 'btnPrevSpan_';
this.btnPrevCont = null;
/**
* Span containing last page button
* @type {String}
* @type {DOMElement}
* @private
*/
this.prfxBtnLastSpan = 'btnLastSpan_';
this.btnLastCont = null;
/**
* Span containing first page button
* @type {String}
* @type {DOMElement}
* @private
*/
this.prfxBtnFirstSpan = 'btnFirstSpan_';
/**
* Next button
* @type {String}
* @private
*/
this.prfxBtnNext = 'btnNext_';
/**
* Previous button
* @type {String}
* @private
*/
this.prfxBtnPrev = 'btnPrev_';
/**
* Last button
* @type {String}
* @private
*/
this.prfxBtnLast = 'btnLast_';
/**
* First button
* @type {String}
* @private
*/
this.prfxBtnFirst = 'btnFirst_';
this.btnFirstCont = null;
/**
* Span for tot nb pages
* @type {String}
* @type {DOMElement}
* @private
*/
this.prfxPgSpan = 'pgspan_';
this.pgCont = null;
/**
* Span preceding pages select (contains 'Page')
* @type {String}
* @type {DOMElement}
* @private
*/
this.prfxPgBeforeSpan = 'pgbeforespan_';
this.pgBefore = null;
/**
* Span following pages select (contains ' of ')
* @type {String}
* @type {DOMElement}
* @private
*/
this.prfxPgAfterSpan = 'pgafterspan_';
this.pgAfter = null;
var start_row = tf.refRow;
var nrows = tf.getRowsNb(true);
@ -396,88 +357,77 @@ export class Paging extends Feature {
// Paging drop-down list selector
if (this.pageSelectorType === SELECT) {
slcPages = createElm(SELECT, ['id', this.prfxSlcPages + tf.id]);
slcPages = createElm(SELECT);
slcPages.className = this.pgSlcCssClass;
addEvt(slcPages, 'change', evt.slcPagesChange);
}
// Paging input selector
if (this.pageSelectorType === INPUT) {
slcPages = createElm(INPUT,
['id', this.prfxSlcPages + tf.id],
['value', this.currentPageNb]
);
slcPages = createElm(INPUT, ['value', this.currentPageNb]);
slcPages.className = this.pgInpCssClass;
addEvt(slcPages, 'keypress', evt._detectKey);
}
// btns containers
var btnNextSpan = createElm(
'span', ['id', this.prfxBtnNextSpan + tf.id]);
var btnPrevSpan = createElm(
'span', ['id', this.prfxBtnPrevSpan + tf.id]);
var btnLastSpan = createElm(
'span', ['id', this.prfxBtnLastSpan + tf.id]);
var btnFirstSpan = createElm(
'span', ['id', this.prfxBtnFirstSpan + tf.id]);
var btnNextSpan = createElm('span');
var btnPrevSpan = createElm('span');
var btnLastSpan = createElm('span');
var btnFirstSpan = createElm('span');
if (this.hasPagingBtns) {
// Next button
if (!this.btnNextPageHtml) {
var btn_next = createElm(INPUT,
['id', this.prfxBtnNext + tf.id],
var btnNext = createElm(INPUT,
['type', 'button'],
['value', this.btnNextPageText],
['title', 'Next']
);
btn_next.className = this.btnPageCssClass;
addEvt(btn_next, 'click', evt.next);
btnNextSpan.appendChild(btn_next);
btnNext.className = this.btnPageCssClass;
addEvt(btnNext, 'click', evt.next);
btnNextSpan.appendChild(btnNext);
} else {
btnNextSpan.innerHTML = this.btnNextPageHtml;
addEvt(btnNextSpan, 'click', evt.next);
}
// Previous button
if (!this.btnPrevPageHtml) {
var btn_prev = createElm(INPUT,
['id', this.prfxBtnPrev + tf.id],
var btnPrev = createElm(INPUT,
['type', 'button'],
['value', this.btnPrevPageText],
['title', 'Previous']
);
btn_prev.className = this.btnPageCssClass;
addEvt(btn_prev, 'click', evt.prev);
btnPrevSpan.appendChild(btn_prev);
btnPrev.className = this.btnPageCssClass;
addEvt(btnPrev, 'click', evt.prev);
btnPrevSpan.appendChild(btnPrev);
} else {
btnPrevSpan.innerHTML = this.btnPrevPageHtml;
addEvt(btnPrevSpan, 'click', evt.prev);
}
// Last button
if (!this.btnLastPageHtml) {
var btn_last = createElm(INPUT,
['id', this.prfxBtnLast + tf.id],
var btnLast = createElm(INPUT,
['type', 'button'],
['value', this.btnLastPageText],
['title', 'Last']
);
btn_last.className = this.btnPageCssClass;
addEvt(btn_last, 'click', evt.last);
btnLastSpan.appendChild(btn_last);
btnLast.className = this.btnPageCssClass;
addEvt(btnLast, 'click', evt.last);
btnLastSpan.appendChild(btnLast);
} else {
btnLastSpan.innerHTML = this.btnLastPageHtml;
addEvt(btnLastSpan, 'click', evt.last);
}
// First button
if (!this.btnFirstPageHtml) {
var btn_first = createElm(INPUT,
['id', this.prfxBtnFirst + tf.id],
var btnFirst = createElm(INPUT,
['type', 'button'],
['value', this.btnFirstPageText],
['title', 'First']
);
btn_first.className = this.btnPageCssClass;
addEvt(btn_first, 'click', evt.first);
btnFirstSpan.appendChild(btn_first);
btnFirst.className = this.btnPageCssClass;
addEvt(btnFirst, 'click', evt.first);
btnFirstSpan.appendChild(btnFirst);
} else {
btnFirstSpan.innerHTML = this.btnFirstPageHtml;
addEvt(btnFirstSpan, 'click', evt.first);
@ -492,24 +442,30 @@ export class Paging extends Feature {
targetEl.appendChild(btnFirstSpan);
targetEl.appendChild(btnPrevSpan);
var pgBeforeSpan = createElm(
'span', ['id', this.prfxPgBeforeSpan + tf.id]);
var pgBeforeSpan = createElm('span');
pgBeforeSpan.appendChild(createText(this.pageText));
pgBeforeSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgBeforeSpan);
targetEl.appendChild(slcPages);
var pgAfterSpan = createElm(
'span', ['id', this.prfxPgAfterSpan + tf.id]);
var pgAfterSpan = createElm('span');
pgAfterSpan.appendChild(createText(this.ofText));
pgAfterSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgAfterSpan);
var pgspan = createElm('span', ['id', this.prfxPgSpan + tf.id]);
pgspan.className = this.nbPgSpanCssClass;
pgspan.appendChild(createText(' ' + this.nbPages + ' '));
targetEl.appendChild(pgspan);
var pgSpan = createElm('span');
pgSpan.className = this.nbPgSpanCssClass;
pgSpan.appendChild(createText(' ' + this.nbPages + ' '));
targetEl.appendChild(pgSpan);
targetEl.appendChild(btnNextSpan);
targetEl.appendChild(btnLastSpan);
this.pagingSlc = elm(this.prfxSlcPages + tf.id);
this.btnNextCont = btnNextSpan;
this.btnPrevCont = btnPrevSpan;
this.btnLastCont = btnLastSpan;
this.btnFirstCont = btnFirstSpan;
this.pgCont = pgSpan;
this.pgBefore = pgBeforeSpan;
this.pgAfter = pgAfterSpan;
this.pagingSlc = slcPages;
this.setPagingInfo();
@ -524,9 +480,7 @@ export class Paging extends Feature {
this.emitter.on(['change-page-results'],
(tf, pageLength) => this.changeResultsPerPage(pageLength));
/**
* @inherited
*/
/** @inherited */
this.initialized = true;
}
@ -564,7 +518,6 @@ export class Paging extends Feature {
setPagingInfo(validRows) {
var tf = this.tf;
var mdiv = !this.pagingTgtId ? tf.mDiv : elm(this.pagingTgtId);
var pgspan = elm(this.prfxPgSpan + tf.id);
//store valid rows indexes
tf.validRowsIndex = validRows || tf.getValidRows(true);
@ -572,7 +525,7 @@ export class Paging extends Feature {
//calculate nb of pages
this.nbPages = Math.ceil(tf.validRowsIndex.length / this.pagingLength);
//refresh page nb span
pgspan.innerHTML = this.nbPages;
this.pgCont.innerHTML = this.nbPages;
//select clearing shortcut
if (this.pageSelectorType === SELECT) {
this.pagingSlc.innerHTML = '';
@ -694,12 +647,11 @@ export class Paging extends Feature {
ev.target.blur();
};
var slcR = createElm(SELECT, ['id', this.prfxSlcResults + tf.id]);
var slcR = createElm(SELECT);
slcR.className = this.resultsSlcCssClass;
var slcRText = this.resultsPerPage[0],
slcROpts = this.resultsPerPage[1];
var slcRSpan = createElm(
'span', ['id', this.prfxSlcResultsTxt + tf.id]);
var slcRSpan = createElm('span');
slcRSpan.className = this.resultsSpanCssClass;
// results per page select is added to external element
@ -724,6 +676,7 @@ export class Paging extends Feature {
slcR.options[r] = currOpt;
}
addEvt(slcR, 'change', evt.slcResultsChange);
this.slcResultsTxt = slcRSpan;
this.resultsPerPageSlc = slcR;
}
@ -736,15 +689,14 @@ export class Paging extends Feature {
!this.resultsPerPage) {
return;
}
var slcR = this.resultsPerPageSlc,
slcRSpan = elm(this.prfxSlcResultsTxt + tf.id);
if (slcR) {
removeElm(slcR);
if (this.resultsPerPageSlc) {
removeElm(this.resultsPerPageSlc);
}
if (slcRSpan) {
removeElm(slcRSpan);
if (this.slcResultsTxt) {
removeElm(this.slcResultsTxt);
}
this.resultsPerPageSlc = null;
this.slcResultsTxt = null;
}
/**
@ -876,22 +828,9 @@ export class Paging extends Feature {
* Remove paging feature
*/
destroy() {
var tf = this.tf;
if (!this.initialized) {
return;
}
// btns containers
var btnNextSpan = elm(this.prfxBtnNextSpan + tf.id);
var btnPrevSpan = elm(this.prfxBtnPrevSpan + tf.id);
var btnLastSpan = elm(this.prfxBtnLastSpan + tf.id);
var btnFirstSpan = elm(this.prfxBtnFirstSpan + tf.id);
//span containing 'Page' text
var pgBeforeSpan = elm(this.prfxPgBeforeSpan + tf.id);
//span containing 'of' text
var pgAfterSpan = elm(this.prfxPgAfterSpan + tf.id);
//span containing nb of pages
var pgspan = elm(this.prfxPgSpan + tf.id);
var evt = this.evt;
@ -905,36 +844,43 @@ export class Paging extends Feature {
removeElm(this.pagingSlc);
}
if (btnNextSpan) {
removeEvt(btnNextSpan, 'click', evt.next);
removeElm(btnNextSpan);
if (this.btnNextCont) {
removeEvt(this.btnNextCont, 'click', evt.next);
removeElm(this.btnNextCont);
this.btnNextCont = null;
}
if (btnPrevSpan) {
removeEvt(btnPrevSpan, 'click', evt.prev);
removeElm(btnPrevSpan);
if (this.btnPrevCont) {
removeEvt(this.btnPrevCont, 'click', evt.prev);
removeElm(this.btnPrevCont);
this.btnPrevCont = null;
}
if (btnLastSpan) {
removeEvt(btnLastSpan, 'click', evt.last);
removeElm(btnLastSpan);
if (this.btnLastCont) {
removeEvt(this.btnLastCont, 'click', evt.last);
removeElm(this.btnLastCont);
this.btnLastCont = null;
}
if (btnFirstSpan) {
removeEvt(btnFirstSpan, 'click', evt.first);
removeElm(btnFirstSpan);
if (this.btnFirstCont) {
removeEvt(this.btnFirstCont, 'click', evt.first);
removeElm(this.btnFirstCont);
this.btnFirstCont = null;
}
if (pgBeforeSpan) {
removeElm(pgBeforeSpan);
if (this.pgBefore) {
removeElm(this.pgBefore);
this.pgBefore = null;
}
if (pgAfterSpan) {
removeElm(pgAfterSpan);
if (this.pgAfter) {
removeElm(this.pgAfter);
this.pgAfter = null;
}
if (pgspan) {
removeElm(pgspan);
if (this.pgCont) {
removeElm(this.pgCont);
this.pgCont = null;
}
if (this.hasResultsPerPage) {

View file

@ -1,11 +1,9 @@
var id = function (id){ return document.getElementById(id); };
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
paging: true,
paging_length: 2,
results_per_page: ['Results per page ', [2,4,6]]
results_per_page: ['Results per page ', [2, 4, 6]]
});
tf.init();
@ -65,28 +63,20 @@ test('Paging UI elements', function() {
notEqual(paging.pagingSlc, null, 'Paging drop-down element');
notEqual(paging.resultsPerPageSlc, null,
'Number of results per page drop-down element');
notEqual(id(paging.prfxBtnNextSpan+tf.id), null,
'Next button container element');
notEqual(id(paging.prfxBtnPrevSpan+tf.id), null,
'Previous button container element');
notEqual(id(paging.prfxBtnLastSpan+tf.id), null,
'Last button container element');
notEqual(id(paging.prfxBtnFirstSpan+tf.id), null,
'First button container element');
notEqual(paging.btnNextCont, null, 'Next button container element');
notEqual(paging.btnPrevCont, null, 'Previous button container element');
notEqual(paging.btnLastCont, null, 'Last button container element');
notEqual(paging.btnFirstCont, null, 'First button container element');
});
test('Destroy Paging component', function() {
paging.destroy();
deepEqual(paging.pagingSlc, null, 'Paging drop-down element');
deepEqual(paging.resultsPerPageSlc, null, 'Paging drop-down element');
deepEqual(id(paging.prfxBtnNextSpan+tf.id), null,
'Next button container element');
deepEqual(id(paging.prfxBtnPrevSpan+tf.id), null,
'Previous button container element');
deepEqual(id(paging.prfxBtnLastSpan+tf.id), null,
'Last button container element');
deepEqual(id(paging.prfxBtnFirstSpan+tf.id), null,
'First button container 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');
deepEqual(paging.btnFirstCont, null, 'First button container element');
deepEqual(paging.nbPages, 0, 'Number of pages');
});
@ -156,14 +146,10 @@ test('Grid layout with paging', function() {
notEqual(paging.pagingSlc, null, 'Paging drop-down element');
notEqual(paging.resultsPerPageSlc, null,
'Number of results per page drop-down element');
notEqual(id(paging.prfxBtnNextSpan+tf.id), null,
'Next button container element');
notEqual(id(paging.prfxBtnPrevSpan+tf.id), null,
'Previous button container element');
notEqual(id(paging.prfxBtnLastSpan+tf.id), null,
'Last button container element');
notEqual(id(paging.prfxBtnFirstSpan+tf.id), null,
'First button container element');
notEqual(paging.btnNextCont, null, 'Next button container element');
notEqual(paging.btnPrevCont, null, 'Previous button container element');
notEqual(paging.btnLastCont, null, 'Last button container element');
notEqual(paging.btnFirstCont, null, 'First button container element');
});
module('Behaviour');