1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-29 10:50:51 +02:00

Merge pull request #185 from koalyptus/issue-177-extend-persistence

Issue 177 extend persistence
This commit is contained in:
koalyptus 2016-04-20 17:06:48 +02:00
commit 40cdf1c64e
16 changed files with 928 additions and 831 deletions

4
dist/starter.html vendored
View file

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

View file

@ -1,6 +1,6 @@
/** /**
* tablefilter v0.2.11 by Max Guglielmi * tablefilter v0.2.12 by Max Guglielmi
* build date: 2016-04-14T08:05:52.776Z * build date: 2016-04-20T14:24:50.288Z
* MIT License * 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} 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.2.11 by Max Guglielmi * tablefilter v0.2.12 by Max Guglielmi
* build date: 2016-04-14T08:05:52.776Z * build date: 2016-04-20T14:24:50.288Z
* MIT License * 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} 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.2.11 by Max Guglielmi * tablefilter v0.2.12 by Max Guglielmi
* build date: 2016-04-14T08:05:52.776Z * build date: 2016-04-20T14:24:50.288Z
* MIT License * MIT License
*/ */
.activeHeader{background-color:#66afe9 !important;color:#fff !important} .activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/** /**
* tablefilter v0.2.11 by Max Guglielmi * tablefilter v0.2.12 by Max Guglielmi
* build date: 2016-04-14T08:05:52.776Z * build date: 2016-04-20T14:24:50.288Z
* MIT License * 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} 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.2.11 by Max Guglielmi * tablefilter v0.2.12 by Max Guglielmi
* build date: 2016-04-14T08:05:52.776Z * build date: 2016-04-20T14:24:50.288Z
* MIT License * 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} 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.2.11 by Max Guglielmi * tablefilter v0.2.12 by Max Guglielmi
* build date: 2016-04-14T08:05:52.776Z * build date: 2016-04-20T14:24:50.288Z
* MIT License * 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} 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

File diff suppressed because one or more lines are too long

View file

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

View file

@ -2,17 +2,17 @@ import Dom from '../../dom';
import Types from '../../types'; import Types from '../../types';
import Event from '../../event'; import Event from '../../event';
export default class ColsVisibility{ export default class ColsVisibility {
/** /**
* Columns Visibility extension * Columns Visibility extension
* @param {Object} tf TableFilter instance * @param {Object} tf TableFilter instance
* @param {Object} f Config * @param {Object} f Extension's configuration
*/ */
constructor(tf, f){ constructor(tf, f) {
// Configuration object // Configuration object
var cfg = tf.config(); let cfg = tf.config();
this.initialized = false; this.initialized = false;
this.name = f.name; this.name = f.name;
@ -26,9 +26,9 @@ export default class ColsVisibility{
this.contEl = null; this.contEl = null;
//tick to hide or show column //tick to hide or show column
this.tickToHide = f.tick_to_hide===false ? false : true; this.tickToHide = f.tick_to_hide === false ? false : true;
//enables/disables cols manager generation //enables/disables cols manager generation
this.manager = f.manager===false ? false : true; this.manager = f.manager === false ? false : true;
//only if external headers //only if external headers
this.headersTbl = f.headers_table || false; this.headersTbl = f.headers_table || false;
//only if external headers //only if external headers
@ -60,7 +60,7 @@ export default class ColsVisibility{
//defines css class div containing show/hide cols //defines css class div containing show/hide cols
this.contCssClass = f.cont_css_class || 'colVisCont'; this.contCssClass = f.cont_css_class || 'colVisCont';
//defines css class for cols list (ul) //defines css class for cols list (ul)
this.listCssClass = cfg.list_css_class ||'cols_checklist'; this.listCssClass = cfg.list_css_class || 'cols_checklist';
//defines css class for list item (li) //defines css class for list item (li)
this.listItemCssClass = cfg.checklist_item_css_class || this.listItemCssClass = cfg.checklist_item_css_class ||
'cols_checklist_item'; 'cols_checklist_item';
@ -78,7 +78,7 @@ export default class ColsVisibility{
//array containing hidden columns indexes //array containing hidden columns indexes
this.hiddenCols = []; this.hiddenCols = [];
this.tblHasColTag = (Dom.tag(tf.tbl,'col').length > 0); this.tblHasColTag = (Dom.tag(tf.tbl, 'col').length > 0);
//callback invoked just after cols manager is loaded //callback invoked just after cols manager is loaded
this.onLoaded = Types.isFn(f.on_loaded) ? f.on_loaded : null; this.onLoaded = Types.isFn(f.on_loaded) ? f.on_loaded : null;
@ -108,125 +108,136 @@ export default class ColsVisibility{
f.on_after_col_displayed : null; f.on_after_col_displayed : null;
//Grid layout compatibility //Grid layout compatibility
if(tf.gridLayout){ if (tf.gridLayout) {
this.headersTbl = tf.feature('gridLayout').headTbl; //headers table this.headersTbl = tf.feature('gridLayout').headTbl; //headers table
this.headersIndex = 0; //headers index this.headersIndex = 0; //headers index
this.onAfterColDisplayed = function(){}; this.onAfterColDisplayed = function () { };
this.onAfterColHidden = function(){}; this.onAfterColHidden = function () { };
} }
//Loads extension stylesheet //Loads extension stylesheet
tf.import(f.name+'Style', tf.stylePath + this.stylesheet, null, 'link'); tf.import(f.name + 'Style', tf.stylePath + this.stylesheet, null,
'link');
this.tf = tf; this.tf = tf;
this.emitter = tf.emitter;
} }
toggle(){ toggle() {
var contDisplay = this.contEl.style.display; let contDisplay = this.contEl.style.display;
var onBeforeOpen = this.onBeforeOpen; let onBeforeOpen = this.onBeforeOpen;
var onBeforeClose = this.onBeforeClose; let onBeforeClose = this.onBeforeClose;
var onAfterOpen = this.onAfterOpen; let onAfterOpen = this.onAfterOpen;
var onAfterClose = this.onAfterClose; let onAfterClose = this.onAfterClose;
if(onBeforeOpen && contDisplay !== 'inline'){ if (onBeforeOpen && contDisplay !== 'inline') {
onBeforeOpen.call(null, this); onBeforeOpen.call(null, this);
} }
if(onBeforeClose && contDisplay === 'inline'){ if (onBeforeClose && contDisplay === 'inline') {
onBeforeClose.call(null, this); onBeforeClose.call(null, this);
} }
this.contEl.style.display = contDisplay === 'inline' ? this.contEl.style.display = contDisplay === 'inline' ?
'none' : 'inline'; 'none' : 'inline';
if(onAfterOpen && contDisplay !== 'inline'){ if (onAfterOpen && contDisplay !== 'inline') {
onAfterOpen.call(null, this); onAfterOpen.call(null, this);
} }
if(onAfterClose && contDisplay === 'inline'){ if (onAfterClose && contDisplay === 'inline') {
onAfterClose.call(null, this); onAfterClose.call(null, this);
} }
} }
checkItem(lbl){ checkItem(lbl) {
var li = lbl.parentNode; let li = lbl.parentNode;
if(!li || !lbl){ if (!li || !lbl) {
return; return;
} }
var isChecked = lbl.firstChild.checked; let isChecked = lbl.firstChild.checked;
var colIndex = lbl.firstChild.getAttribute('id').split('_')[1]; let colIndex = lbl.firstChild.getAttribute('id').split('_')[1];
colIndex = parseInt(colIndex, 10); colIndex = parseInt(colIndex, 10);
if(isChecked){ if (isChecked) {
Dom.addClass(li, this.listSlcItemCssClass); Dom.addClass(li, this.listSlcItemCssClass);
} else { } else {
Dom.removeClass(li, this.listSlcItemCssClass); Dom.removeClass(li, this.listSlcItemCssClass);
} }
var hide = false; let hide = false;
if((this.tickToHide && isChecked) || (!this.tickToHide && !isChecked)){ if ((this.tickToHide && isChecked) ||
(!this.tickToHide && !isChecked)) {
hide = true; hide = true;
} }
this.setHidden(colIndex, hide); this.setHidden(colIndex, hide);
} }
init(){ init() {
if(!this.manager){ if (!this.manager) {
return; return;
} }
this.emitter.on(['hide-column'],
(tf, colIndex) => this.hideCol(colIndex));
this.buildBtn(); this.buildBtn();
this.buildManager(); this.buildManager();
this.initialized = true; this.initialized = true;
this.emitter.emit('columns-visibility-initialized', tf, this);
// Hide columns at start at very end of initialization
this._hideAtStart();
} }
/** /**
* Build main button UI * Build main button UI
*/ */
buildBtn(){ buildBtn() {
if(this.btnEl){ if (this.btnEl) {
return; return;
} }
var tf = this.tf; let tf = this.tf;
var span = Dom.create('span', ['id', this.prfx+tf.id]); let span = Dom.create('span', ['id', this.prfx + tf.id]);
span.className = this.spanCssClass; span.className = this.spanCssClass;
//Container element (rdiv or custom element) //Container element (rdiv or custom element)
if(!this.btnTgtId){ if (!this.btnTgtId) {
tf.setToolbar(); tf.setToolbar();
} }
var targetEl = !this.btnTgtId ? tf.rDiv : Dom.id(this.btnTgtId); let targetEl = !this.btnTgtId ? tf.rDiv : Dom.id(this.btnTgtId);
if(!this.btnTgtId){ if (!this.btnTgtId) {
var firstChild = targetEl.firstChild; let firstChild = targetEl.firstChild;
firstChild.parentNode.insertBefore(span, firstChild); firstChild.parentNode.insertBefore(span, firstChild);
} else { } else {
targetEl.appendChild(span); targetEl.appendChild(span);
} }
if(!this.btnHtml){ if (!this.btnHtml) {
var btn = Dom.create('a', ['href','javascript:;']); let btn = Dom.create('a', ['href', 'javascript:;']);
btn.className = this.btnCssClass; btn.className = this.btnCssClass;
btn.title = this.desc; btn.title = this.desc;
btn.innerHTML = this.btnText; btn.innerHTML = this.btnText;
span.appendChild(btn); span.appendChild(btn);
if(!this.enableHover){ if (!this.enableHover) {
Event.add(btn, 'click', (evt)=> { this.toggle(evt); }); Event.add(btn, 'click', (evt) => this.toggle(evt));
} else { } else {
Event.add(btn, 'mouseover', (evt)=> { this.toggle(evt); }); Event.add(btn, 'mouseover', (evt) => this.toggle(evt));
} }
} else { //Custom html } else { //Custom html
span.innerHTML = this.btnHtml; span.innerHTML = this.btnHtml;
var colVisEl = span.firstChild; let colVisEl = span.firstChild;
if(!this.enableHover){ if (!this.enableHover) {
Event.add(colVisEl, 'click', (evt)=> { this.toggle(evt); }); Event.add(colVisEl, 'click', (evt) => this.toggle(evt));
} else { } else {
Event.add(colVisEl, 'mouseover', (evt)=> { this.toggle(evt); }); Event.add(colVisEl, 'mouseover', (evt) => this.toggle(evt));
} }
} }
this.spanEl = span; this.spanEl = span;
this.btnEl = this.spanEl.firstChild; this.btnEl = this.spanEl.firstChild;
if(this.onLoaded){ if (this.onLoaded) {
this.onLoaded.call(null, this); this.onLoaded.call(null, this);
} }
} }
@ -234,40 +245,40 @@ export default class ColsVisibility{
/** /**
* Build columns manager UI * Build columns manager UI
*/ */
buildManager(){ buildManager() {
var tf = this.tf; let tf = this.tf;
var container = !this.contElTgtId ? let container = !this.contElTgtId ?
Dom.create('div', ['id', this.prfxCont+tf.id]) : Dom.create('div', ['id', this.prfxCont + tf.id]) :
Dom.id(this.contElTgtId); Dom.id(this.contElTgtId);
container.className = this.contCssClass; container.className = this.contCssClass;
//Extension description //Extension description
var extNameLabel = Dom.create('p'); let extNameLabel = Dom.create('p');
extNameLabel.innerHTML = this.text; extNameLabel.innerHTML = this.text;
container.appendChild(extNameLabel); container.appendChild(extNameLabel);
//Headers list //Headers list
var ul = Dom.create('ul' ,['id', 'ul'+this.name+'_'+tf.id]); let ul = Dom.create('ul', ['id', 'ul' + this.name + '_' + tf.id]);
ul.className = this.listCssClass; ul.className = this.listCssClass;
var tbl = this.headersTbl ? this.headersTbl : tf.tbl; let tbl = this.headersTbl ? this.headersTbl : tf.tbl;
var headerIndex = this.headersTbl ? let headerIndex = this.headersTbl ?
this.headersIndex : tf.getHeadersRowIndex(); this.headersIndex : tf.getHeadersRowIndex();
var headerRow = tbl.rows[headerIndex]; let headerRow = tbl.rows[headerIndex];
//Tick all option //Tick all option
if(this.enableTickAll){ if (this.enableTickAll) {
var li = Dom.createCheckItem( let li = Dom.createCheckItem(
'col__'+tf.id, this.tickAllText, this.tickAllText); 'col__' + tf.id, this.tickAllText, this.tickAllText);
Dom.addClass(li, this.listItemCssClass); Dom.addClass(li, this.listItemCssClass);
ul.appendChild(li); ul.appendChild(li);
li.check.checked = !this.tickToHide; li.check.checked = !this.tickToHide;
Event.add(li.check, 'click', ()=> { Event.add(li.check, 'click', () => {
for(var h = 0; h < headerRow.cells.length; h++){ for (let h = 0; h < headerRow.cells.length; h++) {
var itm = Dom.id('col_'+h+'_'+tf.id); let itm = Dom.id('col_' + h + '_' + tf.id);
if(itm && li.check.checked !== itm.checked){ if (itm && li.check.checked !== itm.checked) {
itm.click(); itm.click();
itm.checked = li.check.checked; itm.checked = li.check.checked;
} }
@ -275,42 +286,42 @@ export default class ColsVisibility{
}); });
} }
for(var i = 0; i < headerRow.cells.length; i++){ for (let i = 0; i < headerRow.cells.length; i++) {
var cell = headerRow.cells[i]; let cell = headerRow.cells[i];
var cellText = this.headersText && this.headersText[i] ? let cellText = this.headersText && this.headersText[i] ?
this.headersText[i] : this._getHeaderText(cell); this.headersText[i] : this._getHeaderText(cell);
var liElm = Dom.createCheckItem( let liElm = Dom.createCheckItem(
'col_'+i+'_'+tf.id, cellText, cellText); 'col_' + i + '_' + tf.id, cellText, cellText);
Dom.addClass(liElm, this.listItemCssClass); Dom.addClass(liElm, this.listItemCssClass);
if(!this.tickToHide){ if (!this.tickToHide) {
Dom.addClass(liElm, this.listSlcItemCssClass); Dom.addClass(liElm, this.listSlcItemCssClass);
} }
ul.appendChild(liElm); ul.appendChild(liElm);
if(!this.tickToHide){ if (!this.tickToHide) {
liElm.check.checked = true; liElm.check.checked = true;
} }
Event.add(liElm.check, 'click', (evt)=> { Event.add(liElm.check, 'click', (evt) => {
var elm = Event.target(evt); let elm = Event.target(evt);
var lbl = elm.parentNode; let lbl = elm.parentNode;
this.checkItem(lbl); this.checkItem(lbl);
}); });
} }
//separator //separator
var p = Dom.create('p', ['align','center']); let p = Dom.create('p', ['align', 'center']);
var btn; let btn;
//Close link //Close link
if(!this.btnCloseHtml){ if (!this.btnCloseHtml) {
btn = Dom.create('a', ['href','javascript:;']); btn = Dom.create('a', ['href', 'javascript:;']);
btn.className = this.btnCloseCssClass; btn.className = this.btnCloseCssClass;
btn.innerHTML = this.btnCloseText; btn.innerHTML = this.btnCloseText;
Event.add(btn, 'click', (evt)=> { this.toggle(evt); }); Event.add(btn, 'click', (evt) => this.toggle(evt));
p.appendChild(btn); p.appendChild(btn);
} else { } else {
p.innerHTML = this.btnCloseHtml; p.innerHTML = this.btnCloseHtml;
btn = p.firstChild; btn = p.firstChild;
Event.add(btn, 'click', (evt)=> { this.toggle(evt); }); Event.add(btn, 'click', (evt) => this.toggle(evt));
} }
container.appendChild(ul); container.appendChild(ul);
@ -318,102 +329,102 @@ export default class ColsVisibility{
this.btnEl.parentNode.insertBefore(container, this.btnEl); this.btnEl.parentNode.insertBefore(container, this.btnEl);
this.contEl = container; this.contEl = container;
if(this.atStart){
var a = this.atStart;
for(var k=0; k<a.length; k++){
var itm = Dom.id('col_'+a[k]+'_'+tf.id);
if(itm){
itm.click();
}
}
}
} }
/** /**
* Hide or show specified columns * Hide or show specified columns
* @param {Numner} colIndex Column index * @param {Numner} colIndex Column index
* @param {Boolean} hide hide column if true or show if false * @param {Boolean} hide Hide column if true or show if false
*/ */
setHidden(colIndex, hide){ setHidden(colIndex, hide) {
var tf = this.tf; let tf = this.tf;
var tbl = tf.tbl; let tbl = tf.tbl;
if(this.onBeforeColHidden && hide){ if (this.onBeforeColHidden && hide) {
this.onBeforeColHidden.call(null, this, colIndex); this.onBeforeColHidden.call(null, this, colIndex);
} }
if(this.onBeforeColDisplayed && !hide){ if (this.onBeforeColDisplayed && !hide) {
this.onBeforeColDisplayed.call(null, this, colIndex); this.onBeforeColDisplayed.call(null, this, colIndex);
} }
this._hideCells(tbl, colIndex, hide); this._hideCells(tbl, colIndex, hide);
if(this.headersTbl){ if (this.headersTbl) {
this._hideCells(this.headersTbl, colIndex, hide); this._hideCells(this.headersTbl, colIndex, hide);
} }
var hiddenCols = this.hiddenCols; let hiddenCols = this.hiddenCols;
var itemIndex = hiddenCols.indexOf(colIndex); let itemIndex = hiddenCols.indexOf(colIndex);
if(hide){ if (hide) {
if(itemIndex === -1){ if (itemIndex === -1) {
this.hiddenCols.push(colIndex); this.hiddenCols.push(colIndex);
} }
} else { } else {
if(itemIndex !== -1){ if (itemIndex !== -1) {
this.hiddenCols.splice(itemIndex, 1); this.hiddenCols.splice(itemIndex, 1);
} }
} }
var gridLayout; let gridLayout;
var headTbl; let headTbl;
var gridColElms; let gridColElms;
if(this.onAfterColHidden && hide){ if (hide) {
//This event is fired just after a column is displayed for //This event is fired just after a column is displayed for
//grid_layout support //grid_layout support
//TODO: grid layout module should be responsible for those //TODO: grid layout module should be responsible for those
//calculations //calculations
if(tf.gridLayout){ if (tf.gridLayout) {
gridLayout = tf.feature('gridLayout'); gridLayout = tf.feature('gridLayout');
headTbl = gridLayout.headTbl; headTbl = gridLayout.headTbl;
gridColElms = gridLayout.gridColElms; gridColElms = gridLayout.gridColElms;
var hiddenWidth = parseInt( let hiddenWidth = parseInt(
gridColElms[colIndex].style.width, 10); gridColElms[colIndex].style.width, 10);
var headTblW = parseInt(headTbl.style.width, 10); let headTblW = parseInt(headTbl.style.width, 10);
headTbl.style.width = headTblW - hiddenWidth + 'px'; headTbl.style.width = headTblW - hiddenWidth + 'px';
tbl.style.width = headTbl.style.width; tbl.style.width = headTbl.style.width;
} }
if (this.onAfterColHidden) {
this.onAfterColHidden.call(null, this, colIndex); this.onAfterColHidden.call(null, this, colIndex);
} }
this.emitter.emit('column-hidden', tf, this, colIndex,
this.hiddenCols);
}
if(this.onAfterColDisplayed && !hide){ if (!hide) {
//This event is fired just after a column is displayed for //This event is fired just after a column is displayed for
//grid_layout support //grid_layout support
//TODO: grid layout module should be responsible for those //TODO: grid layout module should be responsible for those
//calculations //calculations
if(tf.gridLayout){ if (tf.gridLayout) {
gridLayout = tf.feature('gridLayout'); gridLayout = tf.feature('gridLayout');
headTbl = gridLayout.headTbl; headTbl = gridLayout.headTbl;
gridColElms = gridLayout.gridColElms; gridColElms = gridLayout.gridColElms;
var width = parseInt(gridColElms[colIndex].style.width, 10); let width = parseInt(gridColElms[colIndex].style.width, 10);
headTbl.style.width = headTbl.style.width =
(parseInt(headTbl.style.width, 10) + width) + 'px'; (parseInt(headTbl.style.width, 10) + width) + 'px';
tf.tbl.style.width = headTbl.style.width; tf.tbl.style.width = headTbl.style.width;
} }
if (this.onAfterColDisplayed) {
this.onAfterColDisplayed.call(null, this, colIndex); this.onAfterColDisplayed.call(null, this, colIndex);
} }
this.emitter.emit('column-shown', tf, this, colIndex,
this.hiddenCols);
}
} }
/** /**
* Show specified column * Show specified column
* @param {Number} colIndex Column index * @param {Number} colIndex Column index
*/ */
showCol(colIndex){ showCol(colIndex) {
if(colIndex === undefined || !this.isColHidden(colIndex)){ if (colIndex === undefined || !this.isColHidden(colIndex)) {
return; return;
} }
if(this.manager && this.contEl){ if (this.manager && this.contEl) {
var itm = Dom.id('col_'+colIndex+'_'+this.tf.id); let itm = Dom.id('col_' + colIndex + '_' + this.tf.id);
if(itm){ itm.click(); } if (itm) {
itm.click();
}
} else { } else {
this.setHidden(colIndex, false); this.setHidden(colIndex, false);
} }
@ -423,13 +434,15 @@ export default class ColsVisibility{
* Hide specified column * Hide specified column
* @param {Number} colIndex Column index * @param {Number} colIndex Column index
*/ */
hideCol(colIndex){ hideCol(colIndex) {
if(colIndex === undefined || this.isColHidden(colIndex)){ if (colIndex === undefined || this.isColHidden(colIndex)) {
return; return;
} }
if(this.manager && this.contEl){ if (this.manager && this.contEl) {
var itm = Dom.id('col_'+colIndex+'_'+this.tf.id); let itm = Dom.id('col_' + colIndex + '_' + this.tf.id);
if(itm){ itm.click(); } if (itm) {
itm.click();
}
} else { } else {
this.setHidden(colIndex, true); this.setHidden(colIndex, true);
} }
@ -439,8 +452,8 @@ export default class ColsVisibility{
* Determine if specified column is hidden * Determine if specified column is hidden
* @param {Number} colIndex Column index * @param {Number} colIndex Column index
*/ */
isColHidden(colIndex){ isColHidden(colIndex) {
if(this.hiddenCols.indexOf(colIndex) !== -1){ if (this.hiddenCols.indexOf(colIndex) !== -1) {
return true; return true;
} }
return false; return false;
@ -450,8 +463,8 @@ export default class ColsVisibility{
* Toggle visibility of specified column * Toggle visibility of specified column
* @param {Number} colIndex Column index * @param {Number} colIndex Column index
*/ */
toggleCol(colIndex){ toggleCol(colIndex) {
if(colIndex === undefined || this.isColHidden(colIndex)){ if (colIndex === undefined || this.isColHidden(colIndex)) {
this.showCol(colIndex); this.showCol(colIndex);
} else { } else {
this.hideCol(colIndex); this.hideCol(colIndex);
@ -459,21 +472,21 @@ export default class ColsVisibility{
} }
/** /**
* Returns the indexes of the columns currently hidden * Return the indexes of the columns currently hidden
* @return {Array} column indexes * @return {Array} column indexes
*/ */
getHiddenCols(){ getHiddenCols() {
return this.hiddenCols; return this.hiddenCols;
} }
/** /**
* Remove the columns manager * Remove the columns manager
*/ */
destroy(){ destroy() {
if(!this.btnEl && !this.contEl){ if (!this.btnEl && !this.contEl) {
return; return;
} }
if(Dom.id(this.contElTgtId)){ if (Dom.id(this.contElTgtId)) {
Dom.id(this.contElTgtId).innerHTML = ''; Dom.id(this.contElTgtId).innerHTML = '';
} else { } else {
this.contEl.innerHTML = ''; this.contEl.innerHTML = '';
@ -483,20 +496,24 @@ export default class ColsVisibility{
this.btnEl.innerHTML = ''; this.btnEl.innerHTML = '';
Dom.remove(this.btnEl); Dom.remove(this.btnEl);
this.btnEl = null; this.btnEl = null;
this.emitter.off(['hide-column'],
(tf, colIndex) => this.hideCol(colIndex));
this.initialized = false; this.initialized = false;
} }
_getHeaderText(cell){ _getHeaderText(cell) {
if(!cell.hasChildNodes){ if (!cell.hasChildNodes) {
return ''; return '';
} }
for(var i=0; i<cell.childNodes.length; i++){ for (let i = 0; i < cell.childNodes.length; i++) {
var n = cell.childNodes[i]; let n = cell.childNodes[i];
if(n.nodeType === 3){ if (n.nodeType === 3) {
return n.nodeValue; return n.nodeValue;
} else if(n.nodeType === 1){ } else if (n.nodeType === 1) {
if(n.id && n.id.indexOf('popUp') !== -1){ if (n.id && n.id.indexOf('popUp') !== -1) {
continue; continue;
} else { } else {
return Dom.getText(n); return Dom.getText(n);
@ -507,14 +524,22 @@ export default class ColsVisibility{
return ''; return '';
} }
_hideCells(tbl, colIndex, hide){ _hideCells(tbl, colIndex, hide) {
for(var i=0; i<tbl.rows.length; i++){ for (let i = 0; i < tbl.rows.length; i++) {
var row = tbl.rows[i]; let row = tbl.rows[i];
var cell = row.cells[colIndex]; let cell = row.cells[colIndex];
if(cell){ if (cell) {
cell.style.display = hide ? 'none' : ''; cell.style.display = hide ? 'none' : '';
} }
} }
} }
_hideAtStart() {
if (!this.atStart) {
return;
}
this.atStart.forEach((colIdx) => {
this.hideCol(colIdx);
});
}
} }

View file

@ -34,6 +34,7 @@ export class State extends Feature {
this.persistPageNumber = Boolean(cfg.page_number); this.persistPageNumber = Boolean(cfg.page_number);
this.persistPageLength = Boolean(cfg.page_length); this.persistPageLength = Boolean(cfg.page_length);
this.persistSort = Boolean(cfg.sort); this.persistSort = Boolean(cfg.sort);
this.persistColsVisibility = Boolean(cfg.columns_visibility);
this.cookieDuration = !isNaN(cfg.cookie_duration) ? this.cookieDuration = !isNaN(cfg.cookie_duration) ?
parseInt(cfg.cookie_duration, 10) : 87600; parseInt(cfg.cookie_duration, 10) : 87600;
@ -42,6 +43,7 @@ export class State extends Feature {
this.pageNb = null; this.pageNb = null;
this.pageLength = null; this.pageLength = null;
this.sort = null; this.sort = null;
this.hiddenCols = null;
this.state = {}; this.state = {};
this.prfxCol = 'col_'; this.prfxCol = 'col_';
@ -65,6 +67,10 @@ export class State extends Feature {
this.emitter.on(['column-sorted'], this.emitter.on(['column-sorted'],
(tf, index, descending) => this.updateSort(index, descending)); (tf, index, descending) => this.updateSort(index, descending));
this.emitter.on(['sort-initialized'], () => this._syncSort()); this.emitter.on(['sort-initialized'], () => this._syncSort());
this.emitter.on(['columns-visibility-initialized'],
() => this._syncColsVisibility());
this.emitter.on(['column-shown', 'column-hidden'], (tf, feature,
colIndex, hiddenCols) => this.updateColsVisibility(hiddenCols));
if (this.enableHash) { if (this.enableHash) {
this.hash = new Hash(this); this.hash = new Hash(this);
@ -79,7 +85,7 @@ export class State extends Feature {
/** /**
* Update state field based on current features state * Update state object based on current features state
*/ */
update() { update() {
if (!this.isEnabled()) { if (!this.isEnabled()) {
@ -96,7 +102,7 @@ export class State extends Feature {
if (Types.isString(val) && Str.isEmpty(val)) { if (Types.isString(val) && Str.isEmpty(val)) {
if (state.hasOwnProperty(key)) { if (state.hasOwnProperty(key)) {
state[key] = undefined; state[key].flt = undefined;
} }
} else { } else {
state[key] = state[key] || {}; state[key] = state[key] || {};
@ -136,11 +142,28 @@ export class State extends Feature {
} }
} }
if (this.persistColsVisibility) {
if (!Types.isNull(this.hiddenCols)) {
// Clear previuosly hidden columns
Object.keys(state).forEach((key) => {
if (key.indexOf(this.prfxCol) !== -1 && state[key]) {
state[key].hidden = undefined;
}
});
this.hiddenCols.forEach((colIdx) => {
let key = `${this.prfxCol}${colIdx}`;
state[key] = state[key] || {};
state[key].hidden = true;
});
}
}
this.emitter.emit('state-changed', tf, state); this.emitter.emit('state-changed', tf, state);
} }
/** /**
* Refresh page number field on page number change * Refresh page number field on page number changes
* *
* @param pageNb Current page number * @param pageNb Current page number
*/ */
@ -150,7 +173,7 @@ export class State extends Feature {
} }
/** /**
* Refresh page length field on page length change * Refresh page length field on page length changes
* *
* @param pageLength Current page length value * @param pageLength Current page length value
*/ */
@ -160,7 +183,7 @@ export class State extends Feature {
} }
/** /**
* Refresh column sorting information on sort change * Refresh column sorting information on sort changes
* *
* @param index {Number} Column index * @param index {Number} Column index
* @param descending {Boolean} Descending manner * @param descending {Boolean} Descending manner
@ -173,6 +196,16 @@ export class State extends Feature {
this.update(); this.update();
} }
/**
* Refresh hidden columns information on columns visibility changes
*
* @param hiddenCols {Array} Columns indexes
*/
updateColsVisibility(hiddenCols) {
this.hiddenCols = hiddenCols;
this.update();
}
/** /**
* Override state field * Override state field
* *
@ -202,6 +235,7 @@ export class State extends Feature {
} }
this._syncSort(); this._syncSort();
this._syncColsVisibility();
} }
/** /**
@ -267,6 +301,33 @@ export class State extends Feature {
}); });
} }
/**
* Sync hidden columns with stored information
*
* @private
*/
_syncColsVisibility() {
if (!this.persistColsVisibility) {
return;
}
let state = this.state;
let tf = this.tf;
let hiddenCols = [];
Object.keys(state).forEach((key) => {
if (key.indexOf(this.prfxCol) !== -1) {
let colIdx = parseInt(key.replace(this.prfxCol, ''), 10);
if (!Types.isUndef(state[key].hidden)) {
hiddenCols.push(colIdx);
}
}
});
hiddenCols.forEach((colIdx) => {
this.emitter.emit('hide-column', tf, colIdx);
});
}
/** /**
* Destroy State instance * Destroy State instance
*/ */
@ -285,6 +346,10 @@ export class State extends Feature {
this.emitter.off(['column-sorted'], this.emitter.off(['column-sorted'],
(tf, index, descending) => this.updateSort(index, descending)); (tf, index, descending) => this.updateSort(index, descending));
this.emitter.off(['sort-initialized'], () => this._syncSort()); this.emitter.off(['sort-initialized'], () => this._syncSort());
this.emitter.off(['columns-visibility-initialized'],
() => this._syncColsVisibility());
this.emitter.off(['column-shown', 'column-hidden'], (tf, feature,
colIndex, hiddenCols) => this.updateColsVisibility(hiddenCols));
if (this.enableHash) { if (this.enableHash) {
this.hash.destroy(); this.hash.destroy();

View file

@ -30,7 +30,8 @@ var tfConfig = {
paging: true, paging: true,
state: { state: {
types: ['cookie'], types: ['cookie'],
filters: true filters: true,
columns_visibility: true
}, },
alternate_rows: true, alternate_rows: true,
rows_counter: true, rows_counter: true,

View file

@ -1,22 +1,21 @@
(function(win, TableFilter) {
var tf = new TableFilter('demo', { var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/' base_path: '../dist/tablefilter/'
}); });
tf.init(); tf.init();
var tf1 = new TableFilter('demo1', { var tf1 = new TableFilter('demo1', {
base_path: '../dist/tablefilter/', base_path: '../dist/tablefilter/',
extensions: [{ extensions: [{
name: 'colsVisibility', name: 'colsVisibility',
at_start: [1, 2], at_start: [1, 2],
on_loaded: colsVisibilityTests on_loaded: colsVisibilityTests
}] }]
}); });
tf1.init(); tf1.init();
module('Sanity checks'); module('Sanity checks');
test('TableFilter object', function() { test('TableFilter object', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated'); deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.id, 'demo', 'id check'); deepEqual(tf.id, 'demo', 'id check');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index'); deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
@ -37,48 +36,48 @@
'Destination', 'Destination',
'Column header text' 'Column header text'
); );
}); });
module('Public methods'); module('Public methods');
test('Filters DOM elements', function() { test('Filters DOM elements', function() {
deepEqual(tf.getFilterElement(1).nodeName, 'INPUT', deepEqual(tf.getFilterElement(1).nodeName, 'INPUT',
'Filter\'s DOM element'); 'Filter\'s DOM element');
deepEqual(tf.getHeaderElement(2).nodeName, 'TH', deepEqual(tf.getHeaderElement(2).nodeName, 'TH',
'Header\'s DOM element'); 'Header\'s DOM element');
}); });
test('Get filters values', function() { test('Get filters values', function() {
equal(tf.getFilterValue(0), '', 'Column 0 filter value'); equal(tf.getFilterValue(0), '', 'Column 0 filter value');
tf.setFilterValue(0, 'Syd'); tf.setFilterValue(0, 'Syd');
tf.setFilterValue(1, 'Ade'); tf.setFilterValue(1, 'Ade');
deepEqual(tf.getFilterValue(0), 'Syd', 'Column 0 filter value'); deepEqual(tf.getFilterValue(0), 'Syd', 'Column 0 filter value');
deepEqual(tf.getFiltersValue(), ['Syd', 'Ade', '', '', '']); deepEqual(tf.getFiltersValue(), ['Syd', 'Ade', '', '', '']);
}); });
test('Filter table', function() { test('Filter table', function() {
tf.clearFilters(); tf.clearFilters();
deepEqual(tf.getFilterValue(0), '', deepEqual(tf.getFilterValue(0), '',
'Column 0 filter value after clearing filters'); 'Column 0 filter value after clearing filters');
tf.setFilterValue(0, 'Syd'); tf.setFilterValue(0, 'Syd');
tf.filter(); tf.filter();
deepEqual(tf.getValidRows().length, 4, 'Filtered rows number'); deepEqual(tf.getValidRows().length, 4, 'Filtered rows number');
}); });
test('Filter table with range', function() { test('Filter table with range', function() {
tf.clearFilters(); tf.clearFilters();
tf.setFilterValue(2, '>1500 && <=2871'); tf.setFilterValue(2, '>1500 && <=2871');
tf.filter(); tf.filter();
deepEqual(tf.getValidRows().length, 3, 'Filtered rows number'); deepEqual(tf.getValidRows().length, 3, 'Filtered rows number');
}); });
test('Filter table with operator', function() { test('Filter table with operator', function() {
tf.clearFilters(); tf.clearFilters();
tf.setFilterValue(1, '{Bri'); tf.setFilterValue(1, '{Bri');
tf.filter(); tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows number'); deepEqual(tf.getValidRows().length, 2, 'Filtered rows number');
}); });
test('Get active filter ID', function() { test('Get active filter ID', function() {
//setup //setup
tf.getFilterElement(0).focus(); tf.getFilterElement(0).focus();
@ -87,17 +86,17 @@
//assert //assert
deepEqual(id, 'flt0_demo', 'Active filter ID'); deepEqual(id, 'flt0_demo', 'Active filter ID');
}); });
test('Set active filter ID', function() { test('Set active filter ID', function() {
//act //act
tf.setActiveFilterId('hello'); tf.setActiveFilterId('hello');
//assert //assert
deepEqual(tf.getActiveFilterId(), 'hello', 'Active filter ID'); deepEqual(tf.getActiveFilterId(), 'hello', 'Active filter ID');
}); });
test('Get column index from filter ID', function() { test('Get column index from filter ID', function() {
//set //set
var filterId = 'flt3_demo'; var filterId = 'flt3_demo';
@ -106,9 +105,9 @@
//assert //assert
deepEqual(colIndex, 3, 'Column index'); deepEqual(colIndex, 3, 'Column index');
}); });
test('Activate filter for a specified column', function() { test('Activate filter for a specified column', function() {
//set //set
var filterId = 'flt3_demo'; var filterId = 'flt3_demo';
@ -117,15 +116,15 @@
//assert //assert
deepEqual(tf.getActiveFilterId(), filterId, 'Filter active'); deepEqual(tf.getActiveFilterId(), filterId, 'Filter active');
}); });
test('Clear filters', function() { test('Clear filters', function() {
tf.clearFilters(); tf.clearFilters();
deepEqual(tf.nbVisibleRows, 7, 'Filtered rows number'); deepEqual(tf.nbVisibleRows, 7, 'Filtered rows number');
deepEqual(tf.getFiltersValue(), ['', '', '', '', '']); deepEqual(tf.getFiltersValue(), ['', '', '', '', '']);
}); });
test('Get table data', function() { test('Get table data', function() {
deepEqual(tf.getColValues(0), deepEqual(tf.getColValues(0),
[ [
'Sydney','Sydney','Sydney', 'Sydney','Sydney','Sydney',
@ -202,16 +201,16 @@
); );
tf.clearFilters(); tf.clearFilters();
tf.filter(); tf.filter();
}); });
test('Destroy', function() { test('Destroy', function() {
tf.destroy(); tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed'); deepEqual(tf.hasGrid(), false, 'Filters removed');
tf = null; tf = null;
}); });
module('TableFilter instance with different filter types'); module('TableFilter instance with different filter types');
test('Test filter types', function() { test('Test filter types', function() {
tf = null; tf = null;
tf = new TableFilter('demo', { tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/', base_path: '../dist/tablefilter/',
@ -233,70 +232,70 @@
'Get checklist filter(s)'); 'Get checklist filter(s)');
deepEqual(tf.getFiltersByType('input'), ['flt3_demo','flt4_demo'], deepEqual(tf.getFiltersByType('input'), ['flt3_demo','flt4_demo'],
'Get input filter(s)'); 'Get input filter(s)');
}); });
test('Get filters values', function() { test('Get filters values', function() {
tf.setFilterValue(0, 'Sydney'); tf.setFilterValue(0, 'Sydney');
tf.setFilterValue(1, 'Adelaide'); tf.setFilterValue(1, 'Adelaide');
deepEqual(tf.getFilterValue(0), 'Sydney', 'Column 0 filter value'); deepEqual(tf.getFilterValue(0), 'Sydney', 'Column 0 filter value');
deepEqual(tf.getFiltersValue(), deepEqual(tf.getFiltersValue(),
['Sydney', ['Adelaide'], '', '', '']); ['Sydney', ['Adelaide'], '', '', '']);
}); });
test('Filter table', function() { test('Filter table', function() {
tf.clearFilters(); tf.clearFilters();
tf.setFilterValue(1, 'Alice Springs'); tf.setFilterValue(1, 'Alice Springs');
tf.filter(); tf.filter();
deepEqual(tf.getValidRows().length, 1, 'Filtered rows number'); deepEqual(tf.getValidRows().length, 1, 'Filtered rows number');
}); });
test('Can filter table with multiple filter', function() { test('Can filter table with multiple filter', function() {
tf.clearFilters(); tf.clearFilters();
tf.setFilterValue(1, ['Alice Springs', 'Canberra']); tf.setFilterValue(1, ['Alice Springs', 'Canberra']);
tf.filter(); tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows number'); deepEqual(tf.getValidRows().length, 2, 'Filtered rows number');
}); });
test('Can filter table with checklist filter', function() { test('Can filter table with checklist filter', function() {
tf.clearFilters(); tf.clearFilters();
tf.setFilterValue(2, ['2045', '2781']); tf.setFilterValue(2, ['2045', '2781']);
tf.filter(); tf.filter();
deepEqual(tf.getValidRows().length, 2, 'Filtered rows number'); deepEqual(tf.getValidRows().length, 2, 'Filtered rows number');
}); });
test('Can select dropdown options with or operator', function() { test('Can select dropdown options with or operator', function() {
tf.setFilterValue(1, ''); tf.setFilterValue(1, '');
tf.setFilterValue(1, 'Brisbane || Melbourne'); tf.setFilterValue(1, 'Brisbane || Melbourne');
deepEqual(tf.getFilterValue(1), ['Brisbane', 'Melbourne'], deepEqual(tf.getFilterValue(1), ['Brisbane', 'Melbourne'],
'Column 2 filter values'); 'Column 2 filter values');
}); });
test('Can select dropdown options with array', function() { test('Can select dropdown options with array', function() {
tf.setFilterValue(1, ''); tf.setFilterValue(1, '');
tf.setFilterValue(1, ['Canberra', 'Perth']); tf.setFilterValue(1, ['Canberra', 'Perth']);
deepEqual(tf.getFilterValue(1), ['Canberra', 'Perth'], deepEqual(tf.getFilterValue(1), ['Canberra', 'Perth'],
'Column 2 filter values'); 'Column 2 filter values');
}); });
test('Can select checklist options', function() { test('Can select checklist options', function() {
tf.setFilterValue(2, '2045 || 2781'); tf.setFilterValue(2, '2045 || 2781');
deepEqual(tf.getFilterValue(2), ['2045', '2781'], deepEqual(tf.getFilterValue(2), ['2045', '2781'],
'Column 2 filter values'); 'Column 2 filter values');
}); });
test('Can select checklist options with array', function() { test('Can select checklist options with array', function() {
tf.setFilterValue(2, ''); tf.setFilterValue(2, '');
tf.setFilterValue(2, ['1412', '982']); tf.setFilterValue(2, ['1412', '982']);
deepEqual(tf.getFilterValue(2), ['1412', '982'], deepEqual(tf.getFilterValue(2), ['1412', '982'],
'Column 2 filter values'); 'Column 2 filter values');
}); });
module('TableFilter with pop-up filters'); module('TableFilter with pop-up filters');
test('Sanity checks', function() { test('Sanity checks', function() {
tf.destroy(); tf.destroy();
tf = null; tf = null;
tf = new TableFilter('demo', { tf = new TableFilter('demo', {
@ -311,17 +310,17 @@
'Filter\'s DOM element'); 'Filter\'s DOM element');
deepEqual(tf.getHeaderElement(2).nodeName, 'TH', deepEqual(tf.getHeaderElement(2).nodeName, 'TH',
'Header\'s DOM element'); 'Header\'s DOM element');
}); });
test('Get filters values', function() { test('Get filters values', function() {
tf.setFilterValue(0, 'Sydney'); tf.setFilterValue(0, 'Sydney');
tf.setFilterValue(1, 'Adelaide'); tf.setFilterValue(1, 'Adelaide');
deepEqual(tf.getFilterValue(0), 'Sydney', 'Column 0 filter value'); deepEqual(tf.getFilterValue(0), 'Sydney', 'Column 0 filter value');
deepEqual(tf.getFiltersValue(), ['Sydney', 'Adelaide', '', '', '']); deepEqual(tf.getFiltersValue(), ['Sydney', 'Adelaide', '', '', '']);
}); });
// Test case for issue 165 // Test case for issue 165
test('Test getCellData with white spaces', function() { test('Test getCellData with white spaces', function() {
// setup // setup
var cell = document.createElement('td'); var cell = document.createElement('td');
cell.textContent ='\t\thello world\t\t\t'; cell.textContent ='\t\thello world\t\t\t';
@ -331,17 +330,17 @@
//assert //assert
deepEqual(result, 'hello world', 'Expected text with no white spaces'); deepEqual(result, 'hello world', 'Expected text with no white spaces');
}); });
test('Filter table', function() { test('Filter table', function() {
tf.clearFilters(); tf.clearFilters();
tf.setFilterValue(1, 'Adelaide'); tf.setFilterValue(1, 'Adelaide');
tf.filter(); tf.filter();
deepEqual(tf.getValidRows().length, 1, 'Filtered rows number'); deepEqual(tf.getValidRows().length, 1, 'Filtered rows number');
}); });
module('TableFilter with grid-layout'); module('TableFilter with grid-layout');
test('Sanity checks', function() { test('Sanity checks', function() {
tf.destroy(); tf.destroy();
tf = null; tf = null;
tf = new TableFilter('demo', { tf = new TableFilter('demo', {
@ -372,29 +371,29 @@
'Filter\'s DOM element'); 'Filter\'s DOM element');
deepEqual(tf.getHeaderElement(2).nodeName, 'TH', deepEqual(tf.getHeaderElement(2).nodeName, 'TH',
'Header\'s DOM element'); 'Header\'s DOM element');
}); });
test('Get filters values', function() { test('Get filters values', function() {
tf.setFilterValue(0, 'Sydney'); tf.setFilterValue(0, 'Sydney');
tf.setFilterValue(1, 'Adelaide'); tf.setFilterValue(1, 'Adelaide');
deepEqual(tf.getFilterValue(0), 'Sydney', 'Column 0 filter value'); deepEqual(tf.getFilterValue(0), 'Sydney', 'Column 0 filter value');
deepEqual(tf.getFiltersValue(), ['Sydney', ['Adelaide'], '', '', '']); deepEqual(tf.getFiltersValue(), ['Sydney', ['Adelaide'], '', '', '']);
}); });
test('Filter table', function() { test('Filter table', function() {
tf.clearFilters(); tf.clearFilters();
tf.setFilterValue(1, 'Adelaide'); tf.setFilterValue(1, 'Adelaide');
tf.filter(); tf.filter();
deepEqual(tf.getValidRows().length, 1, 'Filtered rows number'); deepEqual(tf.getValidRows().length, 1, 'Filtered rows number');
}); });
test('Clear filters', function() { test('Clear filters', function() {
tf.clearFilters(); tf.clearFilters();
deepEqual(tf.nbVisibleRows, 7, 'Filtered rows number'); deepEqual(tf.nbVisibleRows, 7, 'Filtered rows number');
deepEqual(tf.getFiltersValue(), ['', '', '', '', '']); deepEqual(tf.getFiltersValue(), ['', '', '', '', '']);
}); });
test('Get table data', function() { test('Get table data', function() {
deepEqual(tf.getColValues(0), deepEqual(tf.getColValues(0),
[ [
'Sydney','Sydney','Sydney', 'Sydney','Sydney','Sydney',
@ -457,15 +456,15 @@
); );
tf.clearFilters(); tf.clearFilters();
tf.filter(); tf.filter();
}); });
test('Destroy', function() { test('Destroy', function() {
tf.destroy(); tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed'); deepEqual(tf.hasGrid(), false, 'Filters removed');
tf = null; tf = null;
}); });
function colsVisibilityTests() { // issue 94 function colsVisibilityTests() { // issue 94
module('Public methods with columns visibility extension'); module('Public methods with columns visibility extension');
test('Sanity checks', function() { test('Sanity checks', function() {
@ -542,7 +541,4 @@
deepEqual(tf1.hasGrid(), false, 'Filters removed'); deepEqual(tf1.hasGrid(), false, 'Filters removed');
tf1 = null; tf1 = null;
}); });
} }
})(window, TableFilter);

View file

@ -1,25 +1,23 @@
(function(win, TableFilter){ var tf = new TableFilter('demo', {
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/', base_path: '../dist/tablefilter/',
extensions:[{ name: 'colsVisibility' }] extensions:[{ name: 'colsVisibility' }]
}); });
tf.init(); tf.init();
var ext; var ext;
module('Sanity checks'); module('Sanity checks');
test('Extension initialization', function() { test('Extension initialization', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated'); deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
notEqual(ext, null, 'Extension instanciated'); notEqual(ext, null, 'Extension instanciated');
deepEqual(ext.initialized, true, 'Extension initialized'); deepEqual(ext.initialized, true, 'Extension initialized');
deepEqual(ext.text, 'Hide: ', 'Text setting'); deepEqual(ext.text, 'Hide: ', 'Text setting');
deepEqual(ext.btnText, 'Columns&#9660;', 'Button text setting'); deepEqual(ext.btnText, 'Columns&#9660;', 'Button text setting');
}); });
module('UI checks'); module('UI checks');
test('UI elements', function() { test('UI elements', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
var span = ext.spanEl; var span = ext.spanEl;
var cont = ext.contEl; var cont = ext.contEl;
@ -30,54 +28,54 @@
'Hide: ', 'Expected text'); 'Hide: ', 'Expected text');
deepEqual(btn.nodeName, 'A', 'Button element'); deepEqual(btn.nodeName, 'A', 'Button element');
deepEqual(btn.innerHTML, 'Columns▼'); deepEqual(btn.innerHTML, 'Columns▼');
}); });
module('Behaviour'); module('Behaviour');
test('Toggle columns list container', function() { test('Toggle columns list container', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.toggle(); ext.toggle();
deepEqual(ext.contEl.style.display, 'inline', 'columns list visible'); deepEqual(ext.contEl.style.display, 'inline', 'columns list visible');
ext.toggle(); ext.toggle();
deepEqual(ext.contEl.style.display, 'none', 'columns list visible'); deepEqual(ext.contEl.style.display, 'none', 'columns list visible');
}); });
test('Hide columns', function() { test('Hide columns', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.hideCol(2); ext.hideCol(2);
ext.hideCol(3); ext.hideCol(3);
deepEqual(ext.isColHidden(2), true, 'Expected column is hidden'); deepEqual(ext.isColHidden(2), true, 'Expected column is hidden');
deepEqual(ext.isColHidden(3), true, 'Expected column is hidden'); deepEqual(ext.isColHidden(3), true, 'Expected column is hidden');
}); });
test('Show columns', function() { test('Show columns', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.showCol(2); ext.showCol(2);
ext.showCol(3); ext.showCol(3);
deepEqual(ext.isColHidden(2), false, 'Expected column is displayed'); deepEqual(ext.isColHidden(2), false, 'Expected column is displayed');
deepEqual(ext.isColHidden(3), false, 'Expected column is displayed'); deepEqual(ext.isColHidden(3), false, 'Expected column is displayed');
}); });
test('Toggle column', function() { test('Toggle column', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.toggleCol(2); ext.toggleCol(2);
deepEqual(ext.isColHidden(2), true, 'Expected column is hidden'); deepEqual(ext.isColHidden(2), true, 'Expected column is hidden');
ext.toggleCol(2); ext.toggleCol(2);
deepEqual(ext.isColHidden(2), false, 'Expected column is displayed'); deepEqual(ext.isColHidden(2), false, 'Expected column is displayed');
}); });
test('Destroy extension', function() { test('Destroy extension', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.destroy(); ext.destroy();
deepEqual(ext.initialized, false, 'Extension no longer initialized'); deepEqual(ext.initialized, false, 'Extension no longer initialized');
deepEqual(ext.contEl, null, 'Columns list container removed'); deepEqual(ext.contEl, null, 'Columns list container removed');
deepEqual(ext.btnEl, null, 'Button removed'); deepEqual(ext.btnEl, null, 'Button removed');
}); });
test('Re-initialize extension', function() { test('Re-initialize extension', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.init(); ext.init();
deepEqual(ext.initialized, true, 'Extension initialized'); deepEqual(ext.initialized, true, 'Extension initialized');
tf.destroy(); tf.destroy();
}); });
module('Behaviour with grid layout'); module('Behaviour with grid layout');
test('Re-initialize tablefilter with grid layout on', function() { test('Re-initialize tablefilter with grid layout on', function() {
tf = null; tf = null;
tf = new TableFilter('demo', { tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/', base_path: '../dist/tablefilter/',
@ -88,38 +86,38 @@
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
deepEqual(ext.initialized, true, 'Extension initialized'); deepEqual(ext.initialized, true, 'Extension initialized');
}); });
test('Toggle columns list container', function() { test('Toggle columns list container', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.toggle(); ext.toggle();
deepEqual(ext.contEl.style.display, 'inline', 'columns list visible'); deepEqual(ext.contEl.style.display, 'inline', 'columns list visible');
ext.toggle(); ext.toggle();
deepEqual(ext.contEl.style.display, 'none', 'columns list visible'); deepEqual(ext.contEl.style.display, 'none', 'columns list visible');
}); });
test('Hide columns', function() { test('Hide columns', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.hideCol(2); ext.hideCol(2);
ext.hideCol(3); ext.hideCol(3);
deepEqual(ext.isColHidden(2), true, 'Expected column is hidden'); deepEqual(ext.isColHidden(2), true, 'Expected column is hidden');
deepEqual(ext.isColHidden(3), true, 'Expected column is hidden'); deepEqual(ext.isColHidden(3), true, 'Expected column is hidden');
}); });
test('Show columns', function() { test('Show columns', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.showCol(2); ext.showCol(2);
ext.showCol(3); ext.showCol(3);
deepEqual(ext.isColHidden(2), false, 'Expected column is displayed'); deepEqual(ext.isColHidden(2), false, 'Expected column is displayed');
deepEqual(ext.isColHidden(3), false, 'Expected column is displayed'); deepEqual(ext.isColHidden(3), false, 'Expected column is displayed');
}); });
test('Toggle column', function() { test('Toggle column', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.toggleCol(2); ext.toggleCol(2);
deepEqual(ext.isColHidden(2), true, 'Expected column is hidden'); deepEqual(ext.isColHidden(2), true, 'Expected column is hidden');
ext.toggleCol(2); ext.toggleCol(2);
deepEqual(ext.isColHidden(2), false, 'Expected column is displayed'); deepEqual(ext.isColHidden(2), false, 'Expected column is displayed');
}); });
test('Destroy extension and tablefilter', function() { test('Destroy extension and tablefilter', function() {
ext = tf.extension('colsVisibility'); ext = tf.extension('colsVisibility');
ext.destroy(); ext.destroy();
deepEqual(ext.initialized, false, 'Extension no longer initialized'); deepEqual(ext.initialized, false, 'Extension no longer initialized');
@ -127,6 +125,4 @@
deepEqual(ext.btnEl, null, 'Button removed'); deepEqual(ext.btnEl, null, 'Button removed');
tf.destroy(); tf.destroy();
}); });
})(window, TableFilter);

View file

@ -119,6 +119,20 @@ test('Can update sort', function() {
{ 'sort': { 'descending': true } }, 'Sort updated'); { 'sort': { 'descending': true } }, 'Sort updated');
}); });
test('Can update columns visibility', function() {
// setup
state.persistColsVisibility = true;
state.state = {};
// act
state.updateColsVisibility([0, 2]);
state.persistColsVisibility = false;
// assert
deepEqual(state.state.col_0.hidden, true, 'Column 0 visibility updated');
deepEqual(state.state.col_2.hidden, true, 'Column 2 visibility updated');
});
module('Tear-down'); module('Tear-down');
test('Can destroy TF', function() { test('Can destroy TF', function() {
// setup // setup