1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-08 17:02:30 +02:00

Started refactoring Dom module

This commit is contained in:
Max Guglielmi 2016-05-24 18:42:11 +10:00
parent 35f23d46eb
commit 9fec6eb6ef
29 changed files with 11079 additions and 635 deletions

View file

@ -1,6 +1,6 @@
/** /**
* tablefilter v0.2.30 by Max Guglielmi * tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z * build date: 2016-05-24T08:24:39.404Z
* 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.30 by Max Guglielmi * tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z * build date: 2016-05-24T08:24:39.404Z
* 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.30 by Max Guglielmi * tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z * build date: 2016-05-24T08:24:39.404Z
* 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.30 by Max Guglielmi * tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z * build date: 2016-05-24T08:24:39.404Z
* 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.30 by Max Guglielmi * tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z * build date: 2016-05-24T08:24:39.404Z
* 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.30 by Max Guglielmi * tablefilter v0.2.31 by Max Guglielmi
* build date: 2016-05-21T01:26:55.419Z * build date: 2016-05-24T08:24:39.404Z
* 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

2351
dist/tablefilter/tf-1.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "tablefilter", "name": "tablefilter",
"version": "0.2.30", "version": "0.2.31",
"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

@ -5,162 +5,155 @@ import {trim} from './string';
* DOM utilities * DOM utilities
*/ */
export default { // export default {
/** /**
* Returns text + text of children of given node * Returns text + text of children of given node
* @param {NodeElement} node * @param {NodeElement} node
* @return {String} * @return {String}
*/ */
getText(node) { export const getText = node => {
if (isUndef(node.textContent)) { if (isUndef(node.textContent)) {
return trim(node.innerText); return trim(node.innerText);
}
return trim(node.textContent);
},
/**
* Returns the first text node contained in the supplied node
* @param {NodeElement} node node
* @return {String}
*/
getFirstTextNode(node) {
for (let i = 0; i < node.childNodes.length; i++) {
let n = node.childNodes[i];
if (n.nodeType === 3) {
return n.data;
}
}
},
/**
* Creates an html element with given collection of attributes
* @param {String} tag a string of the html tag to create
* @param {Array} an undetermined number of arrays containing the with 2
* items, the attribute name and its value ['id','myId']
* @return {Object} created element
*/
create(tag) {
if (!tag || tag === '') {
return;
}
let el = document.createElement(tag),
args = arguments;
if (args.length > 1) {
for (let i = 0; i < args.length; i++) {
let argtype = typeof args[i];
if (argtype === 'object' && args[i].length === 2) {
el.setAttribute(args[i][0], args[i][1]);
}
}
}
return el;
},
/**
* Removes passed node from DOM
* @param {DOMElement} node
* @return {DOMElement} old node reference
*/
remove(node) {
return node.parentNode.removeChild(node);
},
/**
* Returns a text node with given text
* @param {String} txt
* @return {Object}
*/
text(txt) {
return document.createTextNode(txt);
},
hasClass(ele, cls) {
if (!ele) { return false; }
if (supportsClassList()) {
return ele.classList.contains(cls);
}
return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
},
addClass(ele, cls) {
if (!ele) { return; }
if (supportsClassList()) {
ele.classList.add(cls);
return;
}
if (ele.className === '') {
ele.className = cls;
}
else if (!this.hasClass(ele, cls)) {
ele.className += ' ' + cls;
}
},
removeClass(ele, cls) {
if (!ele) { return; }
if (supportsClassList()) {
ele.classList.remove(cls);
return;
}
let reg = new RegExp('(\\s|^)' + cls + '(\\s|$)', 'g');
ele.className = ele.className.replace(reg, '');
},
/**
* Creates and returns an option element
* @param {String} text option text
* @param {String} value option value
* @param {Boolean} isSel whether option is selected
* @return {Object} option element
*/
createOpt(text, value, isSel) {
let isSelected = isSel ? true : false,
opt = isSelected ?
this.create('option', ['value', value], ['selected', 'true']) :
this.create('option', ['value', value]);
opt.appendChild(this.text(text));
return opt;
},
/**
* Creates and returns a checklist item
* @param {Number} chkIndex index of check item
* @param {String} chkValue check item value
* @param {String} labelText check item label text
* @return {Object} li DOM element
*/
createCheckItem(chkIndex, chkValue, labelText) {
let li = this.create('li'),
label = this.create('label', ['for', chkIndex]),
check = this.create('input',
['id', chkIndex],
['name', chkIndex],
['type', 'checkbox'],
['value', chkValue]
);
label.appendChild(check);
label.appendChild(this.text(labelText));
li.appendChild(label);
li.label = label;
li.check = check;
return li;
},
id(key) {
return document.getElementById(key);
},
tag(o, tagname) {
return o.getElementsByTagName(tagname);
} }
}; return trim(node.textContent);
}
/**
* Returns the first text node contained in the supplied node
* @param {NodeElement} node node
* @return {String}
*/
export const getFirstTextNode = node => {
for (let i = 0; i < node.childNodes.length; i++) {
let n = node.childNodes[i];
if (n.nodeType === 3) {
return n.data;
}
}
}
/**
* Creates an html element with given collection of attributes
* @param {String} tag a string of the html tag to create
* @param {Array} an undetermined number of arrays containing the with 2
* items, the attribute name and its value ['id','myId']
* @return {Object} created element
*/
export const createElm = tag => {
if (isUndef(tag)) {
return;
}
let el = document.createElement(tag),
args = arguments;
if (args.length > 1) {
for (let i = 0; i < args.length; i++) {
let argtype = typeof args[i];
if (argtype === 'object' && args[i].length === 2) {
el.setAttribute(args[i][0], args[i][1]);
}
}
}
return el;
}
/**
* Removes passed node from DOM
* @param {DOMElement} node
* @return {DOMElement} old node reference
*/
export const removeElm = node => node.parentNode.removeChild(node);
/**
* Returns a text node with given text
* @param {String} txt
* @return {Object}
*/
export const createText = txt => document.createTextNode(txt);
export const hasClass = (ele, cls) => {
if (!ele) { return false; }
if (supportsClassList()) {
return ele.classList.contains(cls);
}
return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
}
export const addClass = (ele, cls) => {
if (!ele) { return; }
if (supportsClassList()) {
ele.classList.add(cls);
return;
}
if (ele.className === '') {
ele.className = cls;
}
else if (!hasClass(ele, cls)) {
ele.className += ' ' + cls;
}
}
export const removeClass = (ele, cls) => {
if (!ele) { return; }
if (supportsClassList()) {
ele.classList.remove(cls);
return;
}
let reg = new RegExp('(\\s|^)' + cls + '(\\s|$)', 'g');
ele.className = ele.className.replace(reg, '');
}
/**
* Creates and returns an option element
* @param {String} text option text
* @param {String} value option value
* @param {Boolean} isSel whether option is selected
* @return {Object} option element
*/
export const createOpt = (text, value, isSel) => {
let isSelected = isSel ? true : false,
opt = isSelected ?
createElm('option', ['value', value], ['selected', 'true']) :
createElm('option', ['value', value]);
opt.appendChild(createText(text));
return opt;
}
/**
* Creates and returns a checklist item
* @param {Number} chkIndex index of check item
* @param {String} chkValue check item value
* @param {String} labelText check item label text
* @return {Object} li DOM element
*/
export const createCheckItem = (chkIndex, chkValue, labelText) => {
let li = createElm('li');
let label = createElm('label', ['for', chkIndex]);
let check = createElm('input',
['id', chkIndex],
['name', chkIndex],
['type', 'checkbox'],
['value', chkValue]
);
label.appendChild(check);
label.appendChild(createText(labelText));
li.appendChild(label);
li.label = label;
li.check = check;
return li;
}
export const byId = key => document.getElementById(key);
export const tag = (o, tagname) => o.getElementsByTagName(tagname);
// };
// HTML5 classList API // HTML5 classList API
function supportsClassList() { function supportsClassList() {

View file

@ -1,5 +1,5 @@
import {Feature} from '../../feature'; import {Feature} from '../../feature';
import Dom from '../../dom'; import {tag} from '../../dom';
import {INPUT} from '../../const'; import {INPUT} from '../../const';
import {root} from '../../root'; import {root} from '../../root';
@ -71,7 +71,7 @@ export default class AdapterEzEditTable extends Feature {
//start row for EditTable constructor needs to be calculated //start row for EditTable constructor needs to be calculated
var startRow, var startRow,
cfg = this.cfg, cfg = this.cfg,
thead = Dom.tag(tf.tbl, 'thead'); thead = tag(tf.tbl, 'thead');
//if thead exists and startRow not specified, startRow is calculated //if thead exists and startRow not specified, startRow is calculated
//automatically by EditTable //automatically by EditTable

View file

@ -1,5 +1,5 @@
import {Feature} from '../../feature'; import {Feature} from '../../feature';
import Dom from '../../dom'; import {createText, byId} from '../../dom';
import {isArray, isFn, isUndef} from '../../types'; import {isArray, isFn, isUndef} from '../../types';
export default class ColOps extends Feature { export default class ColOps extends Feature {
@ -268,25 +268,24 @@ export default class ColOps extends Feature {
if (oTypeThisCol && result) { if (oTypeThisCol && result) {
result = result.toFixed(precision); result = result.toFixed(precision);
if (Dom.id(labThisCol[i])) { if (byId(labThisCol[i])) {
switch (oTypeThisCol.toLowerCase()) { switch (oTypeThisCol.toLowerCase()) {
case 'innerhtml': case 'innerhtml':
if (isNaN(result) || !isFinite(result) || if (isNaN(result) || !isFinite(result) ||
nbvalues === 0) { nbvalues === 0) {
Dom.id(labThisCol[i]).innerHTML = '.'; byId(labThisCol[i]).innerHTML = '.';
} else { } else {
Dom.id(labThisCol[i]).innerHTML = byId(labThisCol[i]).innerHTML = result;
result;
} }
break; break;
case 'setvalue': case 'setvalue':
Dom.id(labThisCol[i]).value = result; byId(labThisCol[i]).value = result;
break; break;
case 'createtextnode': case 'createtextnode':
var oldnode = Dom.id(labThisCol[i]) var oldnode =
.firstChild; byId(labThisCol[i]).firstChild;
var txtnode = Dom.text(result); var txtnode = createText(result);
Dom.id(labThisCol[i]) byId(labThisCol[i])
.replaceChild(txtnode, oldnode); .replaceChild(txtnode, oldnode);
break; break;
}//switch }//switch
@ -295,9 +294,9 @@ export default class ColOps extends Feature {
try { try {
if (isNaN(result) || !isFinite(result) || if (isNaN(result) || !isFinite(result) ||
nbvalues === 0) { nbvalues === 0) {
Dom.id(labThisCol[i]).innerHTML = '.'; byId(labThisCol[i]).innerHTML = '.';
} else { } else {
Dom.id(labThisCol[i]).innerHTML = byId(labThisCol[i]).innerHTML =
result.toFixed(precision); result.toFixed(precision);
} }
} catch (e) { }//catch } catch (e) { }//catch

View file

@ -1,5 +1,6 @@
import {Feature} from '../../feature'; import {Feature} from '../../feature';
import Dom from '../../dom'; import {addClass, removeClass, createElm, byId, removeElm, getText, tag}
from '../../dom';
import {isFn} from '../../types'; import {isFn} from '../../types';
import Event from '../../event'; import Event from '../../event';
@ -80,7 +81,7 @@ export default class ColsVisibility extends Feature {
//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 = tag(tf.tbl, 'col').length > 0;
//callback invoked just after cols manager is loaded //callback invoked just after cols manager is loaded
this.onLoaded = isFn(f.on_loaded) ? f.on_loaded : null; this.onLoaded = isFn(f.on_loaded) ? f.on_loaded : null;
@ -155,9 +156,9 @@ export default class ColsVisibility extends Feature {
let 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); addClass(li, this.listSlcItemCssClass);
} else { } else {
Dom.removeClass(li, this.listSlcItemCssClass); removeClass(li, this.listSlcItemCssClass);
} }
let hide = false; let hide = false;
@ -194,14 +195,14 @@ export default class ColsVisibility extends Feature {
return; return;
} }
let tf = this.tf; let tf = this.tf;
let span = Dom.create('span', ['id', this.prfx + tf.id]); let span = createElm('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();
} }
let targetEl = !this.btnTgtId ? tf.rDiv : Dom.id(this.btnTgtId); let targetEl = !this.btnTgtId ? tf.rDiv : byId(this.btnTgtId);
if (!this.btnTgtId) { if (!this.btnTgtId) {
let firstChild = targetEl.firstChild; let firstChild = targetEl.firstChild;
@ -211,7 +212,7 @@ export default class ColsVisibility extends Feature {
} }
if (!this.btnHtml) { if (!this.btnHtml) {
let btn = Dom.create('a', ['href', 'javascript:;']); let btn = createElm('a', ['href', 'javascript:;']);
btn.className = this.btnCssClass; btn.className = this.btnCssClass;
btn.title = this.desc; btn.title = this.desc;
@ -247,17 +248,17 @@ export default class ColsVisibility extends Feature {
let tf = this.tf; let tf = this.tf;
let container = !this.contElTgtId ? let container = !this.contElTgtId ?
Dom.create('div', ['id', this.prfxCont + tf.id]) : createElm('div', ['id', this.prfxCont + tf.id]) :
Dom.id(this.contElTgtId); byId(this.contElTgtId);
container.className = this.contCssClass; container.className = this.contCssClass;
//Extension description //Extension description
let extNameLabel = Dom.create('p'); let extNameLabel = createElm('p');
extNameLabel.innerHTML = this.text; extNameLabel.innerHTML = this.text;
container.appendChild(extNameLabel); container.appendChild(extNameLabel);
//Headers list //Headers list
let ul = Dom.create('ul', ['id', 'ul' + this.name + '_' + tf.id]); let ul = createElm('ul', ['id', 'ul' + this.name + '_' + tf.id]);
ul.className = this.listCssClass; ul.className = this.listCssClass;
let tbl = this.headersTbl ? this.headersTbl : tf.tbl; let tbl = this.headersTbl ? this.headersTbl : tf.tbl;
@ -267,15 +268,15 @@ export default class ColsVisibility extends Feature {
//Tick all option //Tick all option
if (this.enableTickAll) { if (this.enableTickAll) {
let li = Dom.createCheckItem( let li = createCheckItem('col__' + tf.id, this.tickAllText,
'col__' + tf.id, this.tickAllText, this.tickAllText); this.tickAllText);
Dom.addClass(li, this.listItemCssClass); 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 (let h = 0; h < headerRow.cells.length; h++) { for (let h = 0; h < headerRow.cells.length; h++) {
let itm = Dom.id('col_' + h + '_' + tf.id); let itm = byId('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;
@ -288,11 +289,11 @@ export default class ColsVisibility extends Feature {
let cell = headerRow.cells[i]; let cell = headerRow.cells[i];
let 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);
let liElm = Dom.createCheckItem( let liElm = createCheckItem('col_' + i + '_' + tf.id, cellText,
'col_' + i + '_' + tf.id, cellText, cellText); cellText);
Dom.addClass(liElm, this.listItemCssClass); addClass(liElm, this.listItemCssClass);
if (!this.tickToHide) { if (!this.tickToHide) {
Dom.addClass(liElm, this.listSlcItemCssClass); addClass(liElm, this.listSlcItemCssClass);
} }
ul.appendChild(liElm); ul.appendChild(liElm);
if (!this.tickToHide) { if (!this.tickToHide) {
@ -307,11 +308,11 @@ export default class ColsVisibility extends Feature {
} }
//separator //separator
let p = Dom.create('p', ['align', 'center']); let p = createElm('p', ['align', 'center']);
let btn; let btn;
//Close link //Close link
if (!this.btnCloseHtml) { if (!this.btnCloseHtml) {
btn = Dom.create('a', ['href', 'javascript:;']); btn = createElm('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));
@ -419,7 +420,7 @@ export default class ColsVisibility extends Feature {
return; return;
} }
if (this.manager && this.contEl) { if (this.manager && this.contEl) {
let itm = Dom.id('col_' + colIndex + '_' + this.tf.id); let itm = byId('col_' + colIndex + '_' + this.tf.id);
if (itm) { if (itm) {
itm.click(); itm.click();
} }
@ -437,7 +438,7 @@ export default class ColsVisibility extends Feature {
return; return;
} }
if (this.manager && this.contEl) { if (this.manager && this.contEl) {
let itm = Dom.id('col_' + colIndex + '_' + this.tf.id); let itm = byId('col_' + colIndex + '_' + this.tf.id);
if (itm) { if (itm) {
itm.click(); itm.click();
} }
@ -484,15 +485,15 @@ export default class ColsVisibility extends Feature {
if (!this.initialized) { if (!this.initialized) {
return; return;
} }
if (Dom.id(this.contElTgtId)) { if (byId(this.contElTgtId)) {
Dom.id(this.contElTgtId).innerHTML = ''; byId(this.contElTgtId).innerHTML = '';
} else { } else {
this.contEl.innerHTML = ''; this.contEl.innerHTML = '';
Dom.remove(this.contEl); removeElm(this.contEl);
this.contEl = null; this.contEl = null;
} }
this.btnEl.innerHTML = ''; this.btnEl.innerHTML = '';
Dom.remove(this.btnEl); removeElm(this.btnEl);
this.btnEl = null; this.btnEl = null;
this.emitter.off(['hide-column'], this.emitter.off(['hide-column'],
@ -514,7 +515,7 @@ export default class ColsVisibility extends Feature {
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 getText(n);
} }
} }
continue; continue;

View file

@ -1,5 +1,5 @@
import {Feature} from '../../feature'; import {Feature} from '../../feature';
import Dom from '../../dom'; import {createElm, removeElm, byId} from '../../dom';
import {isFn, isUndef} from '../../types'; import {isFn, isUndef} from '../../types';
import Event from '../../event'; import Event from '../../event';
@ -96,14 +96,14 @@ export default class FiltersVisibility extends Feature {
*/ */
buildUI() { buildUI() {
let tf = this.tf; let tf = this.tf;
let span = Dom.create('span', ['id', this.prfx + tf.id]); let span = createElm('span', ['id', this.prfx + tf.id]);
span.className = this.contCssClass; span.className = this.contCssClass;
//Container element (rdiv or custom element) //Container element (rdiv or custom element)
if (!this.targetId) { if (!this.targetId) {
tf.setToolbar(); tf.setToolbar();
} }
let targetEl = !this.targetId ? tf.rDiv : Dom.id(this.targetId); let targetEl = !this.targetId ? tf.rDiv : byId(this.targetId);
if (!this.targetId) { if (!this.targetId) {
let firstChild = targetEl.firstChild; let firstChild = targetEl.firstChild;
@ -114,7 +114,7 @@ export default class FiltersVisibility extends Feature {
let btn; let btn;
if (!this.btnHtml) { if (!this.btnHtml) {
btn = Dom.create('a', ['href', 'javascript:void(0);']); btn = createElm('a', ['href', 'javascript:void(0);']);
btn.className = this.btnCssClass; btn.className = this.btnCssClass;
btn.title = this.btnText || this.defaultText; btn.title = this.btnText || this.defaultText;
btn.innerHTML = this.collapseBtnHtml; btn.innerHTML = this.collapseBtnHtml;
@ -190,11 +190,11 @@ export default class FiltersVisibility extends Feature {
this.emitter.off(['show-filters'], (tf, visible) => this.show(visible)); this.emitter.off(['show-filters'], (tf, visible) => this.show(visible));
this.btnEl.innerHTML = ''; this.btnEl.innerHTML = '';
Dom.remove(this.btnEl); removeElm(this.btnEl);
this.btnEl = null; this.btnEl = null;
this.contEl.innerHTML = ''; this.contEl.innerHTML = '';
Dom.remove(this.contEl); removeElm(this.contEl);
this.contEl = null; this.contEl = null;
this.initialized = false; this.initialized = false;
} }

View file

@ -1,6 +1,6 @@
import {Feature} from '../../feature'; import {Feature} from '../../feature';
import {isArray, isFn, isUndef} from '../../types'; import {isArray, isFn, isUndef} from '../../types';
import Dom from '../../dom'; import {createElm, byId, getText, tag} from '../../dom';
import Event from '../../event'; import Event from '../../event';
import {formatDate} from '../../date'; import {formatDate} from '../../date';
import {removeNbFormat} from '../../helpers'; import {removeNbFormat} from '../../helpers';
@ -186,7 +186,7 @@ export default class AdapterSortableTable extends Feature {
c = cells[i]; c = cells[i];
if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None') { if (stt.sortTypes[i] !== null && stt.sortTypes[i] !== 'None') {
c.style.cursor = 'pointer'; c.style.cursor = 'pointer';
img = Dom.create('img', img = createElm('img',
['src', adpt.imgPath + adpt.imgBlank]); ['src', adpt.imgPath + adpt.imgBlank]);
c.appendChild(img); c.appendChild(img);
if (stt.sortTypes[i] !== null) { if (stt.sortTypes[i] !== null) {
@ -214,7 +214,7 @@ export default class AdapterSortableTable extends Feature {
cells = []; cells = [];
l = triggers.length; l = triggers.length;
for (let j = 0; j < triggers.length; j++) { for (let j = 0; j < triggers.length; j++) {
cells.push(Dom.id(triggers[j])); cells.push(byId(triggers[j]));
} }
} else { } else {
if (!this.tHead) { if (!this.tHead) {
@ -228,7 +228,7 @@ export default class AdapterSortableTable extends Feature {
if (cellAttr !== null && cellAttr !== 'None') { if (cellAttr !== null && cellAttr !== 'None') {
img = cells[i].lastChild || cells[i]; img = cells[i].lastChild || cells[i];
if (img.nodeName.toLowerCase() !== 'img') { if (img.nodeName.toLowerCase() !== 'img') {
img = Dom.create('img', img = createElm('img',
['src', adpt.imgPath + adpt.imgBlank]); ['src', adpt.imgPath + adpt.imgBlank]);
cells[i].appendChild(img); cells[i].appendChild(img);
} }
@ -276,7 +276,7 @@ export default class AdapterSortableTable extends Feature {
if (oNode.getAttribute(adpt.customKey)) { if (oNode.getAttribute(adpt.customKey)) {
return oNode.getAttribute(adpt.customKey); return oNode.getAttribute(adpt.customKey);
} else { } else {
return Dom.getText(oNode); return getText(oNode);
} }
}; };
} }
@ -335,7 +335,7 @@ export default class AdapterSortableTable extends Feature {
if (triggers[j] === null) { if (triggers[j] === null) {
continue; continue;
} }
let trigger = Dom.id(triggers[j]); let trigger = byId(triggers[j]);
if (trigger) { if (trigger) {
trigger.style.cursor = 'pointer'; trigger.style.cursor = 'pointer';
@ -369,7 +369,7 @@ export default class AdapterSortableTable extends Feature {
let ids = tf.getFiltersId(); let ids = tf.getFiltersId();
for (let idx = 0; idx < ids.length; idx++) { for (let idx = 0; idx < ids.length; idx++) {
let header = tf.getHeaderElement(idx); let header = tf.getHeaderElement(idx);
let img = Dom.tag(header, 'img'); let img = tag(header, 'img');
if (img.length === 1) { if (img.length === 1) {
header.removeChild(img[0]); header.removeChild(img[0]);

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {addClass, removeClass} from '../dom';
export class AlternateRows extends Feature { export class AlternateRows extends Feature {
@ -21,7 +21,7 @@ export class AlternateRows extends Feature {
* Sets alternating rows color * Sets alternating rows color
*/ */
init() { init() {
if(this.initialized){ if (this.initialized) {
return; return;
} }
@ -29,15 +29,15 @@ export class AlternateRows extends Feature {
// Subscribe to events // Subscribe to events
this.emitter.on(['row-processed', 'row-paged'], this.emitter.on(['row-processed', 'row-paged'],
(tf, rowIndex, arrIndex, isValid)=> (tf, rowIndex, arrIndex, isValid) =>
this.processRow(rowIndex, arrIndex, isValid)); this.processRow(rowIndex, arrIndex, isValid));
this.emitter.on(['column-sorted'], ()=> this.processAll()); this.emitter.on(['column-sorted'], () => this.processAll());
this.initialized = true; this.initialized = true;
} }
processAll() { processAll() {
if(!this.isEnabled()){ if (!this.isEnabled()) {
return; return;
} }
var tf = this.tf; var tf = this.tf;
@ -47,12 +47,12 @@ export class AlternateRows extends Feature {
var beginIndex = noValidRowsIndex ? tf.refRow : 0; var beginIndex = noValidRowsIndex ? tf.refRow : 0;
// nb indexes // nb indexes
var indexLen = noValidRowsIndex ? var indexLen = noValidRowsIndex ?
tf.nbFilterableRows+beginIndex : tf.nbFilterableRows + beginIndex :
validRowsIndex.length; validRowsIndex.length;
var idx = 0; var idx = 0;
//alternates bg color //alternates bg color
for(var j=beginIndex; j<indexLen; j++){ for (var j = beginIndex; j < indexLen; j++) {
var rowIdx = noValidRowsIndex ? j : validRowsIndex[j]; var rowIdx = noValidRowsIndex ? j : validRowsIndex[j];
this.setRowBg(rowIdx, idx); this.setRowBg(rowIdx, idx);
idx++; idx++;
@ -66,7 +66,7 @@ export class AlternateRows extends Feature {
* @param {Boolean} isValid Valid row flag * @param {Boolean} isValid Valid row flag
*/ */
processRow(rowIdx, arrIdx, isValid) { processRow(rowIdx, arrIdx, isValid) {
if(isValid){ if (isValid) {
this.setRowBg(rowIdx, arrIdx); this.setRowBg(rowIdx, arrIdx);
} else { } else {
this.removeRowBg(rowIdx); this.removeRowBg(rowIdx);
@ -80,17 +80,14 @@ export class AlternateRows extends Feature {
* color * color
*/ */
setRowBg(rowIdx, idx) { setRowBg(rowIdx, idx) {
if(!this.isEnabled() || isNaN(rowIdx)){ if (!this.isEnabled() || isNaN(rowIdx)) {
return; return;
} }
var rows = this.tf.tbl.rows; var rows = this.tf.tbl.rows;
var i = isNaN(idx) ? rowIdx : idx; var i = isNaN(idx) ? rowIdx : idx;
this.removeRowBg(rowIdx); this.removeRowBg(rowIdx);
Dom.addClass( addClass(rows[rowIdx], (i % 2) ? this.evenCss : this.oddCss);
rows[rowIdx],
(i%2) ? this.evenCss : this.oddCss
);
} }
/** /**
@ -98,31 +95,31 @@ export class AlternateRows extends Feature {
* @param {Number} idx Row index * @param {Number} idx Row index
*/ */
removeRowBg(idx) { removeRowBg(idx) {
if(isNaN(idx)){ if (isNaN(idx)) {
return; return;
} }
var rows = this.tf.tbl.rows; var rows = this.tf.tbl.rows;
Dom.removeClass(rows[idx], this.oddCss); removeClass(rows[idx], this.oddCss);
Dom.removeClass(rows[idx], this.evenCss); removeClass(rows[idx], this.evenCss);
} }
/** /**
* Removes all alternating backgrounds * Removes all alternating backgrounds
*/ */
destroy() { destroy() {
if(!this.initialized){ if (!this.initialized) {
return; return;
} }
let nbRows = this.tf.getRowsNb(true); let nbRows = this.tf.getRowsNb(true);
for(var i=0; i<nbRows; i++){ for (var i = 0; i < nbRows; i++) {
this.removeRowBg(i); this.removeRowBg(i);
} }
// Unsubscribe to events // Unsubscribe to events
this.emitter.off(['row-processed', 'row-paged'], this.emitter.off(['row-processed', 'row-paged'],
(tf, rowIndex, arrIndex, isValid)=> (tf, rowIndex, arrIndex, isValid) =>
this.processRow(rowIndex, arrIndex, isValid)); this.processRow(rowIndex, arrIndex, isValid));
this.emitter.off(['column-sorted'], ()=> this.processAll()); this.emitter.off(['column-sorted'], () => this.processAll());
this.initialized = false; this.initialized = false;
} }

View file

@ -1,5 +1,7 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {
addClass, createCheckItem, createText, createElm, byId, removeClass, tag
} from '../dom';
import {has} from '../array'; import {has} from '../array';
import {matchCase, trim, rgxEsc} from '../string'; import {matchCase, trim, rgxEsc} from '../string';
import {ignoreCase, numSortAsc, numSortDesc} from '../sort'; import {ignoreCase, numSortAsc, numSortDesc} from '../sort';
@ -85,14 +87,14 @@ export class CheckList extends Feature {
let externalFltTgtId = isExternal ? let externalFltTgtId = isExternal ?
tf.externalFltTgtIds[colIndex] : null; tf.externalFltTgtIds[colIndex] : null;
let divCont = Dom.create('div', let divCont = createElm('div',
['id', this.prfxCheckListDiv + colIndex + '_' + tf.id], ['id', this.prfxCheckListDiv + colIndex + '_' + tf.id],
['ct', colIndex], ['filled', '0']); ['ct', colIndex], ['filled', '0']);
divCont.className = this.checkListDivCssClass; divCont.className = this.checkListDivCssClass;
//filter is appended in desired element //filter is appended in desired element
if (externalFltTgtId) { if (externalFltTgtId) {
Dom.id(externalFltTgtId).appendChild(divCont); byId(externalFltTgtId).appendChild(divCont);
tf.externalFltEls.push(divCont); tf.externalFltEls.push(divCont);
} else { } else {
container.appendChild(divCont); container.appendChild(divCont);
@ -105,7 +107,7 @@ export class CheckList extends Feature {
this.build(colIndex); this.build(colIndex);
} else { } else {
Event.add(divCont, 'click', (evt) => this.onCheckListClick(evt)); Event.add(divCont, 'click', (evt) => this.onCheckListClick(evt));
divCont.appendChild(Dom.text(this.activateCheckListTxt)); divCont.appendChild(createText(this.activateCheckListTxt));
} }
this.emitter.on( this.emitter.on(
@ -135,8 +137,8 @@ export class CheckList extends Feature {
this.optsTxt = []; this.optsTxt = [];
let flt = this.checkListDiv[colIndex]; let flt = this.checkListDiv[colIndex];
let ul = Dom.create( let ul = createElm('ul', ['id', tf.fltIds[colIndex]],
'ul', ['id', tf.fltIds[colIndex]], ['colIndex', colIndex]); ['colIndex', colIndex]);
ul.className = this.checkListCssClass; ul.className = this.checkListCssClass;
Event.add(ul, 'change', (evt) => this.onChange(evt)); Event.add(ul, 'change', (evt) => this.onChange(evt));
@ -279,14 +281,14 @@ export class CheckList extends Feature {
for (let y = 0; y < this.opts.length; y++) { for (let y = 0; y < this.opts.length; y++) {
let val = this.opts[y]; //item value let val = this.opts[y]; //item value
let lbl = this.isCustom ? this.optsTxt[y] : val; //item text let lbl = this.isCustom ? this.optsTxt[y] : val; //item text
let li = Dom.createCheckItem( let li = createCheckItem(tf.fltIds[colIndex] + '_' + (y + chkCt),
tf.fltIds[colIndex] + '_' + (y + chkCt), val, lbl); val, lbl);
li.className = this.checkListItemCssClass; li.className = this.checkListItemCssClass;
if (tf.linkedFilters && tf.disableExcludedOptions && if (tf.linkedFilters && tf.disableExcludedOptions &&
has(this.excludedOpts, matchCase(val, tf.matchCase), has(this.excludedOpts, matchCase(val, tf.matchCase),
tf.matchCase)) { tf.matchCase)) {
Dom.addClass(li, this.checkListItemDisabledCssClass); addClass(li, this.checkListItemDisabledCssClass);
li.check.disabled = true; li.check.disabled = true;
li.disabled = true; li.disabled = true;
} else { } else {
@ -309,8 +311,8 @@ export class CheckList extends Feature {
addTChecks(colIndex, ul) { addTChecks(colIndex, ul) {
let tf = this.tf; let tf = this.tf;
let chkCt = 1; let chkCt = 1;
let li0 = Dom.createCheckItem( let li0 = createCheckItem(tf.fltIds[colIndex] + '_0', '',
tf.fltIds[colIndex] + '_0', '', tf.displayAllText); tf.displayAllText);
li0.className = this.checkListItemCssClass; li0.className = this.checkListItemCssClass;
ul.appendChild(li0); ul.appendChild(li0);
@ -321,8 +323,8 @@ export class CheckList extends Feature {
} }
if (tf.enableEmptyOption) { if (tf.enableEmptyOption) {
let li1 = Dom.createCheckItem( let li1 = createCheckItem(tf.fltIds[colIndex] + '_1',
tf.fltIds[colIndex] + '_1', tf.emOperator, tf.emptyText); tf.emOperator, tf.emptyText);
li1.className = this.checkListItemCssClass; li1.className = this.checkListItemCssClass;
ul.appendChild(li1); ul.appendChild(li1);
Event.add(li1.check, 'click', (evt) => this.optionClick(evt)); Event.add(li1.check, 'click', (evt) => this.optionClick(evt));
@ -330,11 +332,8 @@ export class CheckList extends Feature {
} }
if (tf.enableNonEmptyOption) { if (tf.enableNonEmptyOption) {
let li2 = Dom.createCheckItem( let li2 = createCheckItem(tf.fltIds[colIndex] + '_2', tf.nmOperator,
tf.fltIds[colIndex] + '_2', tf.nonEmptyText);
tf.nmOperator,
tf.nonEmptyText
);
li2.className = this.checkListItemCssClass; li2.className = this.checkListItemCssClass;
ul.appendChild(li2); ul.appendChild(li2);
Event.add(li2.check, 'click', (evt) => this.optionClick(evt)); Event.add(li2.check, 'click', (evt) => this.optionClick(evt));
@ -374,14 +373,12 @@ export class CheckList extends Feature {
//checked items loop //checked items loop
for (let u = 0; u < indSplit.length; u++) { for (let u = 0; u < indSplit.length; u++) {
//checked item //checked item
let cChk = Dom.id(tf.fltIds[colIndex] + '_' + let cChk = byId(tf.fltIds[colIndex] + '_' +
indSplit[u]); indSplit[u]);
if (cChk) { if (cChk) {
cChk.checked = false; cChk.checked = false;
Dom.removeClass( removeClass(n.childNodes[indSplit[u]],
n.childNodes[indSplit[u]], this.checkListSlcItemCssClass);
this.checkListSlcItemCssClass
);
} }
} }
} }
@ -396,15 +393,14 @@ export class CheckList extends Feature {
n.setAttribute('value', chkValue); n.setAttribute('value', chkValue);
n.setAttribute('indexes', chkIndex); n.setAttribute('indexes', chkIndex);
//1st option unchecked //1st option unchecked
if (Dom.id(tf.fltIds[colIndex] + '_0')) { if (byId(tf.fltIds[colIndex] + '_0')) {
Dom.id(tf.fltIds[colIndex] + '_0').checked = false; byId(tf.fltIds[colIndex] + '_0').checked = false;
} }
} }
if (li.nodeName === itemTag) { if (li.nodeName === itemTag) {
Dom.removeClass( removeClass(n.childNodes[0], this.checkListSlcItemCssClass);
n.childNodes[0], this.checkListSlcItemCssClass); addClass(li, this.checkListSlcItemCssClass);
Dom.addClass(li, this.checkListSlcItemCssClass);
} }
} else { //removes values and indexes } else { //removes values and indexes
if (chkValue !== '') { if (chkValue !== '') {
@ -419,7 +415,7 @@ export class CheckList extends Feature {
n.setAttribute('indexes', fltIndexes); n.setAttribute('indexes', fltIndexes);
} }
if (li.nodeName === itemTag) { if (li.nodeName === itemTag) {
Dom.removeClass(li, this.checkListSlcItemCssClass); removeClass(li, this.checkListSlcItemCssClass);
} }
} }
} }
@ -436,16 +432,16 @@ export class CheckList extends Feature {
return; return;
} }
let lisNb = Dom.tag(flt, 'li').length; let lisNb = tag(flt, 'li').length;
flt.setAttribute('value', ''); flt.setAttribute('value', '');
flt.setAttribute('indexes', ''); flt.setAttribute('indexes', '');
for (let k = 0; k < lisNb; k++) { for (let k = 0; k < lisNb; k++) {
let li = Dom.tag(flt, 'li')[k], let li = tag(flt, 'li')[k],
lbl = Dom.tag(li, 'label')[0], lbl = tag(li, 'label')[0],
chk = Dom.tag(li, 'input')[0], chk = tag(li, 'input')[0],
lblTxt = matchCase(Dom.getText(lbl), tf.caseSensitive); lblTxt = matchCase(getText(lbl), tf.caseSensitive);
if (lblTxt !== '' && has(values, lblTxt, tf.caseSensitive)) { if (lblTxt !== '' && has(values, lblTxt, tf.caseSensitive)) {
chk.checked = true; chk.checked = true;
this.setCheckListValues(chk); this.setCheckListValues(chk);

View file

@ -1,18 +1,18 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {createElm, createText, id, removeElm} from '../dom';
import Event from '../event'; import Event from '../event';
export class ClearButton extends Feature{ export class ClearButton extends Feature {
/** /**
* Clear button component * Clear button component
* @param {Object} tf TableFilter instance * @param {Object} tf TableFilter instance
*/ */
constructor(tf){ constructor(tf) {
super(tf, 'btnReset'); super(tf, 'btnReset');
// Configuration object // Configuration object
var f = this.config; let f = this.config;
//id of container element //id of container element
this.btnResetTgtId = f.btn_reset_target_id || null; this.btnResetTgtId = f.btn_reset_target_id || null;
@ -25,14 +25,14 @@ export class ClearButton extends Feature{
//defines reset button innerHtml //defines reset button innerHtml
this.btnResetHtml = f.btn_reset_html || this.btnResetHtml = f.btn_reset_html ||
(!tf.enableIcons ? null : (!tf.enableIcons ? null :
'<input type="button" value="" class="'+tf.btnResetCssClass+'" ' + '<input type="button" value="" class="' + tf.btnResetCssClass +
'title="'+this.btnResetTooltip+'" />'); '" ' + 'title="' + this.btnResetTooltip + '" />');
//span containing reset button //span containing reset button
this.prfxResetSpan = 'resetspan_'; this.prfxResetSpan = 'resetspan_';
} }
onClick(){ onClick() {
if(!this.isEnabled()){ if (!this.isEnabled()) {
return; return;
} }
this.tf.clearFilters(); this.tf.clearFilters();
@ -41,33 +41,32 @@ export class ClearButton extends Feature{
/** /**
* Build DOM elements * Build DOM elements
*/ */
init(){ init() {
var tf = this.tf; let tf = this.tf;
if(this.initialized){ if (this.initialized) {
return; return;
} }
var resetspan = Dom.create('span', ['id', this.prfxResetSpan+tf.id]); let resetspan = createElm('span', ['id', this.prfxResetSpan + tf.id]);
// reset button is added to defined element // reset button is added to defined element
if(!this.btnResetTgtId){ if (!this.btnResetTgtId) {
tf.setToolbar(); tf.setToolbar();
} }
var targetEl = !this.btnResetTgtId ? let targetEl = !this.btnResetTgtId ? tf.rDiv : id(this.btnResetTgtId);
tf.rDiv : Dom.id(this.btnResetTgtId);
targetEl.appendChild(resetspan); targetEl.appendChild(resetspan);
if(!this.btnResetHtml){ if (!this.btnResetHtml) {
var fltreset = Dom.create('a', ['href', 'javascript:void(0);']); let fltreset = createElm('a', ['href', 'javascript:void(0);']);
fltreset.className = tf.btnResetCssClass; fltreset.className = tf.btnResetCssClass;
fltreset.appendChild(Dom.text(this.btnResetText)); fltreset.appendChild(createText(this.btnResetText));
resetspan.appendChild(fltreset); resetspan.appendChild(fltreset);
Event.add(fltreset, 'click', ()=> { this.onClick(); }); Event.add(fltreset, 'click', () => { this.onClick(); });
} else { } else {
resetspan.innerHTML = this.btnResetHtml; resetspan.innerHTML = this.btnResetHtml;
var resetEl = resetspan.firstChild; let resetEl = resetspan.firstChild;
Event.add(resetEl, 'click', ()=> { this.onClick(); }); Event.add(resetEl, 'click', () => { this.onClick(); });
} }
this.btnResetEl = resetspan.firstChild; this.btnResetEl = resetspan.firstChild;
@ -77,16 +76,16 @@ export class ClearButton extends Feature{
/** /**
* Remove clear button UI * Remove clear button UI
*/ */
destroy(){ destroy() {
var tf = this.tf; let tf = this.tf;
if(!this.initialized){ if (!this.initialized) {
return; return;
} }
var resetspan = Dom.id(this.prfxResetSpan+tf.id); let resetspan = id(this.prfxResetSpan + tf.id);
if(resetspan){ if (resetspan) {
Dom.remove(resetspan); removeElm(resetspan);
} }
this.btnResetEl = null; this.btnResetEl = null;
this.initialized = false; this.initialized = false;

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {createElm, createOpt, id} from '../dom';
import {has} from '../array'; import {has} from '../array';
import {matchCase} from '../string'; import {matchCase} from '../string';
import {ignoreCase, numSortAsc, numSortDesc} from '../sort'; import {ignoreCase, numSortAsc, numSortDesc} from '../sort';
@ -67,7 +67,7 @@ export class Dropdown extends Feature {
let externalFltTgtId = isExternal ? let externalFltTgtId = isExternal ?
tf.externalFltTgtIds[colIndex] : null; tf.externalFltTgtIds[colIndex] : null;
let slc = Dom.create(SELECT, let slc = createElm(SELECT,
['id', tf.prfxFlt + colIndex + '_' + tf.id], ['id', tf.prfxFlt + colIndex + '_' + tf.id],
['ct', colIndex], ['filled', '0'] ['ct', colIndex], ['filled', '0']
); );
@ -81,7 +81,7 @@ export class Dropdown extends Feature {
//filter is appended in container element //filter is appended in container element
if (externalFltTgtId) { if (externalFltTgtId) {
Dom.id(externalFltTgtId).appendChild(slc); id(externalFltTgtId).appendChild(slc);
tf.externalFltEls.push(slc); tf.externalFltEls.push(slc);
} else { } else {
container.appendChild(slc); container.appendChild(slc);
@ -93,7 +93,7 @@ export class Dropdown extends Feature {
this.build(colIndex); this.build(colIndex);
} else { } else {
//1st option is created here since build isn't invoked //1st option is created here since build isn't invoked
let opt0 = Dom.createOpt(tf.displayAllText, ''); let opt0 = createOpt(tf.displayAllText, '');
slc.appendChild(opt0); slc.appendChild(opt0);
} }
@ -129,9 +129,9 @@ export class Dropdown extends Feature {
this.slcInnerHtml = ''; this.slcInnerHtml = '';
let slcId = tf.fltIds[colIndex]; let slcId = tf.fltIds[colIndex];
let slc = Dom.id(slcId), let slc = id(slcId);
rows = tf.tbl.rows, let rows = tf.tbl.rows;
nbRows = tf.getRowsNb(true); let nbRows = tf.getRowsNb(true);
//custom select test //custom select test
this.isCustom = tf.isCustomOptions(colIndex); this.isCustom = tf.isCustomOptions(colIndex);
@ -290,9 +290,9 @@ export class Dropdown extends Feature {
//fill select on demand //fill select on demand
if (tf.loadFltOnDemand && slcValue === this.opts[y] && if (tf.loadFltOnDemand && slcValue === this.opts[y] &&
tf.getFilterType(colIndex) === SELECT) { tf.getFilterType(colIndex) === SELECT) {
opt = Dom.createOpt(lbl, val, true); opt = createOpt(lbl, val, true);
} else { } else {
opt = Dom.createOpt(lbl, val, false); opt = createOpt(lbl, val, false);
} }
if (isDisabled) { if (isDisabled) {
opt.disabled = true; opt.disabled = true;
@ -310,18 +310,18 @@ export class Dropdown extends Feature {
addFirstOption(slc) { addFirstOption(slc) {
let tf = this.tf; let tf = this.tf;
let opt0 = Dom.createOpt( let opt0 = createOpt(
(!this.enableSlcResetFilter ? '' : tf.displayAllText), ''); (!this.enableSlcResetFilter ? '' : tf.displayAllText), '');
if (!this.enableSlcResetFilter) { if (!this.enableSlcResetFilter) {
opt0.style.display = NONE; opt0.style.display = NONE;
} }
slc.appendChild(opt0); slc.appendChild(opt0);
if (tf.enableEmptyOption) { if (tf.enableEmptyOption) {
let opt1 = Dom.createOpt(tf.emptyText, tf.emOperator); let opt1 = createOpt(tf.emptyText, tf.emOperator);
slc.appendChild(opt1); slc.appendChild(opt1);
} }
if (tf.enableNonEmptyOption) { if (tf.enableNonEmptyOption) {
let opt2 = Dom.createOpt(tf.nonEmptyText, tf.nmOperator); let opt2 = createOpt(tf.nonEmptyText, tf.nmOperator);
slc.appendChild(opt2); slc.appendChild(opt2);
} }
return slc; return slc;

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {createElm, removeElm, id, tag} from '../dom';
import {isFn, isNull, isUndef} from '../types'; import {isFn, isNull, isUndef} from '../types';
import Event from '../event'; import Event from '../event';
import {contains} from '../string'; import {contains} from '../string';
@ -110,7 +110,7 @@ export class GridLayout extends Feature {
} }
//Main container: it will contain all the elements //Main container: it will contain all the elements
this.tblMainCont = Dom.create('div', this.tblMainCont = createElm('div',
['id', this.prfxMainTblCont + tf.id]); ['id', this.prfxMainTblCont + tf.id]);
this.tblMainCont.className = this.gridMainContCssClass; this.tblMainCont.className = this.gridMainContCssClass;
if (this.gridWidth) { if (this.gridWidth) {
@ -119,7 +119,7 @@ export class GridLayout extends Feature {
tbl.parentNode.insertBefore(this.tblMainCont, tbl); tbl.parentNode.insertBefore(this.tblMainCont, tbl);
//Table container: div wrapping content table //Table container: div wrapping content table
this.tblCont = Dom.create('div', ['id', this.prfxTblCont + tf.id]); this.tblCont = createElm('div', ['id', this.prfxTblCont + tf.id]);
this.tblCont.className = this.gridContCssClass; this.tblCont.className = this.gridContCssClass;
if (this.gridWidth) { if (this.gridWidth) {
if (this.gridWidth.indexOf('%') !== -1) { if (this.gridWidth.indexOf('%') !== -1) {
@ -132,7 +132,7 @@ export class GridLayout extends Feature {
this.tblCont.style.height = this.gridHeight; this.tblCont.style.height = this.gridHeight;
} }
tbl.parentNode.insertBefore(this.tblCont, tbl); tbl.parentNode.insertBefore(this.tblCont, tbl);
let t = Dom.remove(tbl); let t = removeElm(tbl);
this.tblCont.appendChild(t); this.tblCont.appendChild(t);
//In case table width is expressed in % //In case table width is expressed in %
@ -141,11 +141,11 @@ export class GridLayout extends Feature {
tbl.clientWidth : tblW) + 'px'; tbl.clientWidth : tblW) + 'px';
} }
let d = Dom.remove(this.tblCont); let d = removeElm(this.tblCont);
this.tblMainCont.appendChild(d); this.tblMainCont.appendChild(d);
//Headers table container: div wrapping headers table //Headers table container: div wrapping headers table
this.headTblCont = Dom.create( this.headTblCont = createElm(
'div', ['id', this.prfxHeadTblCont + tf.id]); 'div', ['id', this.prfxHeadTblCont + tf.id]);
this.headTblCont.className = this.gridHeadContCssClass; this.headTblCont.className = this.gridHeadContCssClass;
if (this.gridWidth) { if (this.gridWidth) {
@ -157,8 +157,8 @@ export class GridLayout extends Feature {
} }
//Headers table //Headers table
this.headTbl = Dom.create('table', ['id', this.prfxHeadTbl + tf.id]); this.headTbl = createElm('table', ['id', this.prfxHeadTbl + tf.id]);
let tH = Dom.create('tHead'); let tH = createElm('tHead');
//1st row should be headers row, ids are added if not set //1st row should be headers row, ids are added if not set
//Those ids are used by the sort feature //Those ids are used by the sort feature
@ -175,12 +175,12 @@ export class GridLayout extends Feature {
} }
//Filters row is created //Filters row is created
let filtersRow = Dom.create('tr'); let filtersRow = createElm('tr');
if (this.gridEnableFilters && tf.fltGrid) { if (this.gridEnableFilters && tf.fltGrid) {
tf.externalFltTgtIds = []; tf.externalFltTgtIds = [];
for (let j = 0; j < tf.nbCells; j++) { for (let j = 0; j < tf.nbCells; j++) {
let fltTdId = tf.prfxFlt + j + this.prfxGridFltTd + tf.id; let fltTdId = tf.prfxFlt + j + this.prfxGridFltTd + tf.id;
let cl = Dom.create(tf.fltCellTag, ['id', fltTdId]); let cl = createElm(tf.fltCellTag, ['id', fltTdId]);
filtersRow.appendChild(cl); filtersRow.appendChild(cl);
tf.externalFltTgtIds[j] = fltTdId; tf.externalFltTgtIds[j] = fltTdId;
} }
@ -195,7 +195,7 @@ export class GridLayout extends Feature {
} else { } else {
// Handle table with no headers, assuming here headers do not // Handle table with no headers, assuming here headers do not
// exist // exist
tH.appendChild(Dom.create('tr')); tH.appendChild(createElm('tr'));
} }
this.headTbl.appendChild(tH); this.headTbl.appendChild(tH);
@ -209,7 +209,7 @@ export class GridLayout extends Feature {
this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont); this.tblCont.parentNode.insertBefore(this.headTblCont, this.tblCont);
//THead needs to be removed in content table for sort feature //THead needs to be removed in content table for sort feature
let thead = Dom.tag(tbl, 'thead'); let thead = tag(tbl, 'thead');
if (thead.length > 0) { if (thead.length > 0) {
tbl.removeChild(thead[0]); tbl.removeChild(thead[0]);
} }
@ -264,13 +264,13 @@ export class GridLayout extends Feature {
} }
//Cols generation for all browsers excepted IE<=7 //Cols generation for all browsers excepted IE<=7
this.tblHasColTag = Dom.tag(tbl, 'col').length > 0 ? true : false; this.tblHasColTag = tag(tbl, 'col').length > 0 ? true : false;
//Col elements are enough to keep column widths after sorting and //Col elements are enough to keep column widths after sorting and
//filtering //filtering
let createColTags = function () { let createColTags = function () {
for (let k = (tf.nbCells - 1); k >= 0; k--) { for (let k = (tf.nbCells - 1); k >= 0; k--) {
let col = Dom.create('col', ['id', tf.id + '_col_' + k]); let col = createElm('col', ['id', tf.id + '_col_' + k]);
tbl.insertBefore(col, tbl.firstChild); tbl.insertBefore(col, tbl.firstChild);
col.style.width = tf.colWidths[k]; col.style.width = tf.colWidths[k];
this.gridColElms[k] = col; this.gridColElms[k] = col;
@ -281,7 +281,7 @@ export class GridLayout extends Feature {
if (!this.tblHasColTag) { if (!this.tblHasColTag) {
createColTags.call(this); createColTags.call(this);
} else { } else {
let cols = Dom.tag(tbl, 'col'); let cols = tag(tbl, 'col');
for (let ii = 0; ii < tf.nbCells; ii++) { for (let ii = 0; ii < tf.nbCells; ii++) {
cols[ii].setAttribute('id', tf.id + '_col_' + ii); cols[ii].setAttribute('id', tf.id + '_col_' + ii);
cols[ii].style.width = tf.colWidths[ii]; cols[ii].style.width = tf.colWidths[ii];
@ -332,9 +332,9 @@ export class GridLayout extends Feature {
if (!this.initialized) { if (!this.initialized) {
return; return;
} }
let t = Dom.remove(tbl); let t = removeElm(tbl);
this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont); this.tblMainCont.parentNode.insertBefore(t, this.tblMainCont);
Dom.remove(this.tblMainCont); removeElm(this.tblMainCont);
this.tblMainCont = null; this.tblMainCont = null;
this.headTblCont = null; this.headTblCont = null;
@ -343,7 +343,7 @@ export class GridLayout extends Feature {
tbl.outerHTML = this.sourceTblHtml; tbl.outerHTML = this.sourceTblHtml;
//needed to keep reference of table element for future usage //needed to keep reference of table element for future usage
this.tf.tbl = Dom.id(tf.id); this.tf.tbl = id(tf.id);
this.initialized = false; this.initialized = false;
} }

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {createElm, createText, id, removeElm} from '../dom';
import Event from '../event'; import Event from '../event';
import {NONE} from '../const'; import {NONE} from '../const';
@ -70,36 +70,36 @@ export class Help extends Feature{
var tf = this.tf; var tf = this.tf;
var helpspan = Dom.create('span', ['id', this.prfxHelpSpan+tf.id]); var helpspan = createElm('span', ['id', this.prfxHelpSpan+tf.id]);
var helpdiv = Dom.create('div', ['id', this.prfxHelpDiv+tf.id]); var helpdiv = createElm('div', ['id', this.prfxHelpDiv+tf.id]);
//help button is added to defined element //help button is added to defined element
if(!this.tgtId){ if(!this.tgtId){
tf.setToolbar(); tf.setToolbar();
} }
var targetEl = !this.tgtId ? tf.rDiv : Dom.id(this.tgtId); var targetEl = !this.tgtId ? tf.rDiv : id(this.tgtId);
targetEl.appendChild(helpspan); targetEl.appendChild(helpspan);
var divContainer = !this.contTgtId ? helpspan : Dom.id(this.contTgtId); var divContainer = !this.contTgtId ? helpspan : id(this.contTgtId);
if(!this.btnHtml){ if(!this.btnHtml){
divContainer.appendChild(helpdiv); divContainer.appendChild(helpdiv);
var helplink = Dom.create('a', ['href', 'javascript:void(0);']); var helplink = createElm('a', ['href', 'javascript:void(0);']);
helplink.className = this.btnCssClass; helplink.className = this.btnCssClass;
helplink.appendChild(Dom.text(this.btnText)); helplink.appendChild(createText(this.btnText));
helpspan.appendChild(helplink); helpspan.appendChild(helplink);
Event.add(helplink, 'click', () => { this.toggle(); }); Event.add(helplink, 'click', () => this.toggle());
} else { } else {
helpspan.innerHTML = this.btnHtml; helpspan.innerHTML = this.btnHtml;
var helpEl = helpspan.firstChild; var helpEl = helpspan.firstChild;
Event.add(helpEl, 'click', () => { this.toggle(); }); Event.add(helpEl, 'click', () => this.toggle());
divContainer.appendChild(helpdiv); divContainer.appendChild(helpdiv);
} }
if(!this.instrHtml){ if(!this.instrHtml){
helpdiv.innerHTML = this.instrText; helpdiv.innerHTML = this.instrText;
helpdiv.className = this.contCssClass; helpdiv.className = this.contCssClass;
Event.add(helpdiv, 'dblclick', () => { this.toggle(); }); Event.add(helpdiv, 'dblclick', () => this.toggle());
} else { } else {
if(this.contTgtId){ if(this.contTgtId){
divContainer.appendChild(helpdiv); divContainer.appendChild(helpdiv);
@ -107,11 +107,11 @@ export class Help extends Feature{
helpdiv.innerHTML = this.instrHtml; helpdiv.innerHTML = this.instrHtml;
if(!this.contTgtId){ if(!this.contTgtId){
helpdiv.className = this.contCssClass; helpdiv.className = this.contCssClass;
Event.add(helpdiv, 'dblclick', () => { this.toggle(); }); Event.add(helpdiv, 'dblclick', () => this.toggle());
} }
} }
helpdiv.innerHTML += this.defaultHtml; helpdiv.innerHTML += this.defaultHtml;
Event.add(helpdiv, 'click', () => { this.toggle(); }); Event.add(helpdiv, 'click', () => this.toggle());
this.cont = helpdiv; this.cont = helpdiv;
this.btn = helpspan; this.btn = helpspan;
@ -142,12 +142,12 @@ export class Help extends Feature{
if(!this.initialized){ if(!this.initialized){
return; return;
} }
Dom.remove(this.btn); removeElm(this.btn);
this.btn = null; this.btn = null;
if(!this.cont){ if(!this.cont){
return; return;
} }
Dom.remove(this.cont); removeElm(this.cont);
this.cont = null; this.cont = null;
this.initialized = false; this.initialized = false;
} }

View file

@ -1,4 +1,4 @@
import Dom from '../dom'; import {createText, createElm, getText} from '../dom';
import {isArray} from '../types'; import {isArray} from '../types';
export class HighlightKeyword { export class HighlightKeyword {
@ -55,11 +55,11 @@ export class HighlightKeyword {
let nv = node.nodeValue, let nv = node.nodeValue,
ni = tempNodeVal.indexOf(tempWordVal), ni = tempNodeVal.indexOf(tempWordVal),
// Create a load of replacement nodes // Create a load of replacement nodes
before = Dom.text(nv.substr(0, ni)), before = createText(nv.substr(0, ni)),
docWordVal = nv.substr(ni, word.length), docWordVal = nv.substr(ni, word.length),
after = Dom.text(nv.substr(ni + word.length)), after = createText(nv.substr(ni + word.length)),
hiwordtext = Dom.text(docWordVal), hiwordtext = createText(docWordVal),
hiword = Dom.create('span'); hiword = createElm('span');
hiword.className = cssClass; hiword.className = cssClass;
hiword.appendChild(hiwordtext); hiword.appendChild(hiwordtext);
pn.insertBefore(before, node); pn.insertBefore(before, node);
@ -80,12 +80,12 @@ export class HighlightKeyword {
let highlightedNodes = this.tf.tbl.querySelectorAll(`.${cssClass}`); let highlightedNodes = this.tf.tbl.querySelectorAll(`.${cssClass}`);
for (let i = 0; i < highlightedNodes.length; i++) { for (let i = 0; i < highlightedNodes.length; i++) {
let n = highlightedNodes[i]; let n = highlightedNodes[i];
let nodeVal = Dom.getText(n), let nodeVal = getText(n),
tempNodeVal = nodeVal.toLowerCase(), tempNodeVal = nodeVal.toLowerCase(),
tempWordVal = word.toLowerCase(); tempWordVal = word.toLowerCase();
if (tempNodeVal.indexOf(tempWordVal) !== -1) { if (tempNodeVal.indexOf(tempWordVal) !== -1) {
n.parentNode.replaceChild(Dom.text(nodeVal), n); n.parentNode.replaceChild(createText(nodeVal), n);
} }
} }
} }

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {createElm, createText, id, removeElm} from '../dom';
import {isFn} from '../types'; import {isFn} from '../types';
import {root} from '../root'; import {root} from '../root';
import {NONE} from '../const'; import {NONE} from '../const';
@ -44,11 +44,11 @@ export class Loader extends Feature {
let tf = this.tf; let tf = this.tf;
let emitter = this.emitter; let emitter = this.emitter;
let containerDiv = Dom.create('div', ['id', this.prfxLoader + tf.id]); let containerDiv = createElm('div', ['id', this.prfxLoader + tf.id]);
containerDiv.className = this.loaderCssClass; containerDiv.className = this.loaderCssClass;
let targetEl = !this.loaderTgtId ? let targetEl = !this.loaderTgtId ?
tf.tbl.parentNode : Dom.id(this.loaderTgtId); tf.tbl.parentNode : id(this.loaderTgtId);
if (!this.loaderTgtId) { if (!this.loaderTgtId) {
targetEl.insertBefore(containerDiv, tf.tbl); targetEl.insertBefore(containerDiv, tf.tbl);
} else { } else {
@ -56,7 +56,7 @@ export class Loader extends Feature {
} }
this.loaderDiv = containerDiv; this.loaderDiv = containerDiv;
if (!this.loaderHtml) { if (!this.loaderHtml) {
this.loaderDiv.appendChild(Dom.text(this.loaderText)); this.loaderDiv.appendChild(createText(this.loaderText));
} else { } else {
this.loaderDiv.innerHTML = this.loaderHtml; this.loaderDiv.innerHTML = this.loaderHtml;
} }
@ -121,7 +121,7 @@ export class Loader extends Feature {
let emitter = this.emitter; let emitter = this.emitter;
Dom.remove(this.loaderDiv); removeElm(this.loaderDiv);
this.loaderDiv = null; this.loaderDiv = null;
// Unsubscribe to events // Unsubscribe to events

View file

@ -1,15 +1,15 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {createElm, id, removeElm} from '../dom';
import {isEmpty, isFn} from '../types'; import {isEmpty, isFn} from '../types';
import {NONE} from '../const'; import {NONE} from '../const';
export class NoResults extends Feature{ export class NoResults extends Feature {
/** /**
* No results message UI component * No results message UI component
* @param {Object} tf TableFilter instance * @param {Object} tf TableFilter instance
*/ */
constructor(tf){ constructor(tf) {
super(tf, 'noResults'); super(tf, 'noResults');
//configuration object //configuration object
@ -40,20 +40,20 @@ export class NoResults extends Feature{
this.prfxNoResults = 'nores_'; this.prfxNoResults = 'nores_';
} }
init(){ init() {
if(this.initialized){ if (this.initialized) {
return; return;
} }
let tf = this.tf; let tf = this.tf;
let target = this.customContainer || Dom.id(this.customContainerId) || let target = this.customContainer || id(this.customContainerId) ||
tf.tbl; tf.tbl;
//container //container
let cont = Dom.create('div', ['id', this.prfxNoResults+tf.id]); let cont = createElm('div', ['id', this.prfxNoResults + tf.id]);
cont.className = this.cssClass; cont.className = this.cssClass;
cont.innerHTML = this.content; cont.innerHTML = this.content;
if(this.isExternal){ if (this.isExternal) {
target.appendChild(cont); target.appendChild(cont);
} else { } else {
target.parentNode.insertBefore(cont, target.nextSibling); target.parentNode.insertBefore(cont, target.nextSibling);
@ -62,58 +62,58 @@ export class NoResults extends Feature{
this.cont = cont; this.cont = cont;
// subscribe to after-filtering event // subscribe to after-filtering event
this.emitter.on(['after-filtering'], ()=> this.toggle()); this.emitter.on(['after-filtering'], () => this.toggle());
this.initialized = true; this.initialized = true;
this.hide(); this.hide();
} }
toggle(){ toggle() {
if(this.tf.nbVisibleRows > 0){ if (this.tf.nbVisibleRows > 0) {
this.hide(); this.hide();
} else { } else {
this.show(); this.show();
} }
} }
show(){ show() {
if(!this.initialized || !this.isEnabled()){ if (!this.initialized || !this.isEnabled()) {
return; return;
} }
if(this.onBeforeShowMsg){ if (this.onBeforeShowMsg) {
this.onBeforeShowMsg.call(null, this.tf, this); this.onBeforeShowMsg.call(null, this.tf, this);
} }
this.setWidth(); this.setWidth();
this.cont.style.display = 'block'; this.cont.style.display = 'block';
if(this.onAfterShowMsg){ if (this.onAfterShowMsg) {
this.onAfterShowMsg.call(null, this.tf, this); this.onAfterShowMsg.call(null, this.tf, this);
} }
} }
hide(){ hide() {
if(!this.initialized || !this.isEnabled()){ if (!this.initialized || !this.isEnabled()) {
return; return;
} }
if(this.onBeforeHideMsg){ if (this.onBeforeHideMsg) {
this.onBeforeHideMsg.call(null, this.tf, this); this.onBeforeHideMsg.call(null, this.tf, this);
} }
this.cont.style.display = NONE; this.cont.style.display = NONE;
if(this.onBeforeHideMsg){ if (this.onBeforeHideMsg) {
this.onBeforeHideMsg.call(null, this.tf, this); this.onBeforeHideMsg.call(null, this.tf, this);
} }
} }
setWidth(){ setWidth() {
if(!this.initialized || this.isExternal || !this.isEnabled()){ if (!this.initialized || this.isExternal || !this.isEnabled()) {
return; return;
} }
if(this.tf.gridLayout){ if (this.tf.gridLayout) {
let gridLayout = this.tf.feature('gridLayout'); let gridLayout = this.tf.feature('gridLayout');
this.cont.style.width = gridLayout.tblCont.clientWidth + 'px'; this.cont.style.width = gridLayout.tblCont.clientWidth + 'px';
} else { } else {
@ -122,14 +122,14 @@ export class NoResults extends Feature{
} }
destroy(){ destroy() {
if(!this.initialized){ if (!this.initialized) {
return; return;
} }
Dom.remove(this.cont); removeElm(this.cont);
this.cont = null; this.cont = null;
// unsubscribe to after-filtering event // unsubscribe to after-filtering event
this.emitter.off(['after-filtering'], ()=> this.toggle()); this.emitter.off(['after-filtering'], () => this.toggle());
this.initialized = false; this.initialized = false;
} }

View file

@ -1,5 +1,5 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {createElm, createOpt, createText, id, removeElm} from '../dom';
import {isArray, isFn, isNull} from '../types'; import {isArray, isFn, isNull} from '../types';
import Event from '../event'; import Event from '../event';
import {INPUT, SELECT, NONE, ENTER_KEY} from '../const'; import {INPUT, SELECT, NONE, ENTER_KEY} from '../const';
@ -205,14 +205,14 @@ export class Paging extends Feature {
// Paging drop-down list selector // Paging drop-down list selector
if (this.pageSelectorType === SELECT) { if (this.pageSelectorType === SELECT) {
slcPages = Dom.create(SELECT, ['id', this.prfxSlcPages + tf.id]); slcPages = createElm(SELECT, ['id', this.prfxSlcPages + tf.id]);
slcPages.className = this.pgSlcCssClass; slcPages.className = this.pgSlcCssClass;
Event.add(slcPages, 'change', evt.slcPagesChange); Event.add(slcPages, 'change', evt.slcPagesChange);
} }
// Paging input selector // Paging input selector
if (this.pageSelectorType === INPUT) { if (this.pageSelectorType === INPUT) {
slcPages = Dom.create(INPUT, slcPages = createElm(INPUT,
['id', this.prfxSlcPages + tf.id], ['id', this.prfxSlcPages + tf.id],
['value', this.currentPageNb] ['value', this.currentPageNb]
); );
@ -221,19 +221,19 @@ export class Paging extends Feature {
} }
// btns containers // btns containers
var btnNextSpan = Dom.create( var btnNextSpan = createElm(
'span', ['id', this.prfxBtnNextSpan + tf.id]); 'span', ['id', this.prfxBtnNextSpan + tf.id]);
var btnPrevSpan = Dom.create( var btnPrevSpan = createElm(
'span', ['id', this.prfxBtnPrevSpan + tf.id]); 'span', ['id', this.prfxBtnPrevSpan + tf.id]);
var btnLastSpan = Dom.create( var btnLastSpan = createElm(
'span', ['id', this.prfxBtnLastSpan + tf.id]); 'span', ['id', this.prfxBtnLastSpan + tf.id]);
var btnFirstSpan = Dom.create( var btnFirstSpan = createElm(
'span', ['id', this.prfxBtnFirstSpan + tf.id]); 'span', ['id', this.prfxBtnFirstSpan + tf.id]);
if (this.hasPagingBtns) { if (this.hasPagingBtns) {
// Next button // Next button
if (!this.btnNextPageHtml) { if (!this.btnNextPageHtml) {
var btn_next = Dom.create(INPUT, var btn_next = createElm(INPUT,
['id', this.prfxBtnNext + tf.id], ['id', this.prfxBtnNext + tf.id],
['type', 'button'], ['type', 'button'],
['value', this.btnNextPageText], ['value', this.btnNextPageText],
@ -248,7 +248,7 @@ export class Paging extends Feature {
} }
// Previous button // Previous button
if (!this.btnPrevPageHtml) { if (!this.btnPrevPageHtml) {
var btn_prev = Dom.create(INPUT, var btn_prev = createElm(INPUT,
['id', this.prfxBtnPrev + tf.id], ['id', this.prfxBtnPrev + tf.id],
['type', 'button'], ['type', 'button'],
['value', this.btnPrevPageText], ['value', this.btnPrevPageText],
@ -263,7 +263,7 @@ export class Paging extends Feature {
} }
// Last button // Last button
if (!this.btnLastPageHtml) { if (!this.btnLastPageHtml) {
var btn_last = Dom.create(INPUT, var btn_last = createElm(INPUT,
['id', this.prfxBtnLast + tf.id], ['id', this.prfxBtnLast + tf.id],
['type', 'button'], ['type', 'button'],
['value', this.btnLastPageText], ['value', this.btnLastPageText],
@ -278,7 +278,7 @@ export class Paging extends Feature {
} }
// First button // First button
if (!this.btnFirstPageHtml) { if (!this.btnFirstPageHtml) {
var btn_first = Dom.create(INPUT, var btn_first = createElm(INPUT,
['id', this.prfxBtnFirst + tf.id], ['id', this.prfxBtnFirst + tf.id],
['type', 'button'], ['type', 'button'],
['value', this.btnFirstPageText], ['value', this.btnFirstPageText],
@ -297,28 +297,28 @@ export class Paging extends Feature {
if (!this.pagingTgtId) { if (!this.pagingTgtId) {
tf.setToolbar(); tf.setToolbar();
} }
var targetEl = !this.pagingTgtId ? tf.mDiv : Dom.id(this.pagingTgtId); var targetEl = !this.pagingTgtId ? tf.mDiv : id(this.pagingTgtId);
targetEl.appendChild(btnFirstSpan); targetEl.appendChild(btnFirstSpan);
targetEl.appendChild(btnPrevSpan); targetEl.appendChild(btnPrevSpan);
var pgBeforeSpan = Dom.create( var pgBeforeSpan = createElm(
'span', ['id', this.prfxPgBeforeSpan + tf.id]); 'span', ['id', this.prfxPgBeforeSpan + tf.id]);
pgBeforeSpan.appendChild(Dom.text(this.pageText)); pgBeforeSpan.appendChild(createText(this.pageText));
pgBeforeSpan.className = this.nbPgSpanCssClass; pgBeforeSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgBeforeSpan); targetEl.appendChild(pgBeforeSpan);
targetEl.appendChild(slcPages); targetEl.appendChild(slcPages);
var pgAfterSpan = Dom.create( var pgAfterSpan = createElm(
'span', ['id', this.prfxPgAfterSpan + tf.id]); 'span', ['id', this.prfxPgAfterSpan + tf.id]);
pgAfterSpan.appendChild(Dom.text(this.ofText)); pgAfterSpan.appendChild(createText(this.ofText));
pgAfterSpan.className = this.nbPgSpanCssClass; pgAfterSpan.className = this.nbPgSpanCssClass;
targetEl.appendChild(pgAfterSpan); targetEl.appendChild(pgAfterSpan);
var pgspan = Dom.create('span', ['id', this.prfxPgSpan + tf.id]); var pgspan = createElm('span', ['id', this.prfxPgSpan + tf.id]);
pgspan.className = this.nbPgSpanCssClass; pgspan.className = this.nbPgSpanCssClass;
pgspan.appendChild(Dom.text(' ' + this.nbPages + ' ')); pgspan.appendChild(createText(' ' + this.nbPages + ' '));
targetEl.appendChild(pgspan); targetEl.appendChild(pgspan);
targetEl.appendChild(btnNextSpan); targetEl.appendChild(btnNextSpan);
targetEl.appendChild(btnLastSpan); targetEl.appendChild(btnLastSpan);
this.pagingSlc = Dom.id(this.prfxSlcPages + tf.id); this.pagingSlc = id(this.prfxSlcPages + tf.id);
this.setPagingInfo(); this.setPagingInfo();
@ -369,8 +369,8 @@ export class Paging extends Feature {
*/ */
setPagingInfo(validRows) { setPagingInfo(validRows) {
var tf = this.tf; var tf = this.tf;
var mdiv = !this.pagingTgtId ? tf.mDiv : Dom.id(this.pagingTgtId); var mdiv = !this.pagingTgtId ? tf.mDiv : id(this.pagingTgtId);
var pgspan = Dom.id(this.prfxPgSpan + tf.id); var pgspan = id(this.prfxPgSpan + tf.id);
//store valid rows indexes //store valid rows indexes
tf.validRowsIndex = validRows || tf.getValidRows(true); tf.validRowsIndex = validRows || tf.getValidRows(true);
@ -388,8 +388,7 @@ export class Paging extends Feature {
mdiv.style.visibility = 'visible'; mdiv.style.visibility = 'visible';
if (this.pageSelectorType === SELECT) { if (this.pageSelectorType === SELECT) {
for (var z = 0; z < this.nbPages; z++) { for (var z = 0; z < this.nbPages; z++) {
var opt = Dom.createOpt(z + 1, z * this.pagingLength, var opt = createOpt(z + 1, z * this.pagingLength, false);
false);
this.pagingSlc.options[z] = opt; this.pagingSlc.options[z] = opt;
} }
} else { } else {
@ -503,11 +502,11 @@ export class Paging extends Feature {
ev.target.blur(); ev.target.blur();
}; };
var slcR = Dom.create(SELECT, ['id', this.prfxSlcResults + tf.id]); var slcR = createElm(SELECT, ['id', this.prfxSlcResults + tf.id]);
slcR.className = this.resultsSlcCssClass; slcR.className = this.resultsSlcCssClass;
var slcRText = this.resultsPerPage[0], var slcRText = this.resultsPerPage[0],
slcROpts = this.resultsPerPage[1]; slcROpts = this.resultsPerPage[1];
var slcRSpan = Dom.create( var slcRSpan = createElm(
'span', ['id', this.prfxSlcResultsTxt + tf.id]); 'span', ['id', this.prfxSlcResultsTxt + tf.id]);
slcRSpan.className = this.resultsSpanCssClass; slcRSpan.className = this.resultsSpanCssClass;
@ -516,8 +515,8 @@ export class Paging extends Feature {
tf.setToolbar(); tf.setToolbar();
} }
var targetEl = !this.resultsPerPageTgtId ? var targetEl = !this.resultsPerPageTgtId ?
tf.rDiv : Dom.id(this.resultsPerPageTgtId); tf.rDiv : id(this.resultsPerPageTgtId);
slcRSpan.appendChild(Dom.text(slcRText)); slcRSpan.appendChild(createText(slcRText));
var help = tf.feature('help'); var help = tf.feature('help');
if (help && help.btn) { if (help && help.btn) {
@ -545,12 +544,12 @@ export class Paging extends Feature {
return; return;
} }
var slcR = this.resultsPerPageSlc, var slcR = this.resultsPerPageSlc,
slcRSpan = Dom.id(this.prfxSlcResultsTxt + tf.id); slcRSpan = id(this.prfxSlcResultsTxt + tf.id);
if (slcR) { if (slcR) {
Dom.remove(slcR); removeElm(slcR);
} }
if (slcRSpan) { if (slcRSpan) {
Dom.remove(slcRSpan); removeElm(slcRSpan);
} }
this.resultsPerPageSlc = null; this.resultsPerPageSlc = null;
} }
@ -686,16 +685,16 @@ export class Paging extends Feature {
return; return;
} }
// btns containers // btns containers
var btnNextSpan = Dom.id(this.prfxBtnNextSpan + tf.id); var btnNextSpan = id(this.prfxBtnNextSpan + tf.id);
var btnPrevSpan = Dom.id(this.prfxBtnPrevSpan + tf.id); var btnPrevSpan = id(this.prfxBtnPrevSpan + tf.id);
var btnLastSpan = Dom.id(this.prfxBtnLastSpan + tf.id); var btnLastSpan = id(this.prfxBtnLastSpan + tf.id);
var btnFirstSpan = Dom.id(this.prfxBtnFirstSpan + tf.id); var btnFirstSpan = id(this.prfxBtnFirstSpan + tf.id);
//span containing 'Page' text //span containing 'Page' text
var pgBeforeSpan = Dom.id(this.prfxPgBeforeSpan + tf.id); var pgBeforeSpan = id(this.prfxPgBeforeSpan + tf.id);
//span containing 'of' text //span containing 'of' text
var pgAfterSpan = Dom.id(this.prfxPgAfterSpan + tf.id); var pgAfterSpan = id(this.prfxPgAfterSpan + tf.id);
//span containing nb of pages //span containing nb of pages
var pgspan = Dom.id(this.prfxPgSpan + tf.id); var pgspan = id(this.prfxPgSpan + tf.id);
var evt = this.evt; var evt = this.evt;
@ -706,39 +705,39 @@ export class Paging extends Feature {
else if (this.pageSelectorType === INPUT) { else if (this.pageSelectorType === INPUT) {
Event.remove(this.pagingSlc, 'keypress', evt._detectKey); Event.remove(this.pagingSlc, 'keypress', evt._detectKey);
} }
Dom.remove(this.pagingSlc); removeElm(this.pagingSlc);
} }
if (btnNextSpan) { if (btnNextSpan) {
Event.remove(btnNextSpan, 'click', evt.next); Event.remove(btnNextSpan, 'click', evt.next);
Dom.remove(btnNextSpan); removeElm(btnNextSpan);
} }
if (btnPrevSpan) { if (btnPrevSpan) {
Event.remove(btnPrevSpan, 'click', evt.prev); Event.remove(btnPrevSpan, 'click', evt.prev);
Dom.remove(btnPrevSpan); removeElm(btnPrevSpan);
} }
if (btnLastSpan) { if (btnLastSpan) {
Event.remove(btnLastSpan, 'click', evt.last); Event.remove(btnLastSpan, 'click', evt.last);
Dom.remove(btnLastSpan); removeElm(btnLastSpan);
} }
if (btnFirstSpan) { if (btnFirstSpan) {
Event.remove(btnFirstSpan, 'click', evt.first); Event.remove(btnFirstSpan, 'click', evt.first);
Dom.remove(btnFirstSpan); removeElm(btnFirstSpan);
} }
if (pgBeforeSpan) { if (pgBeforeSpan) {
Dom.remove(pgBeforeSpan); removeElm(pgBeforeSpan);
} }
if (pgAfterSpan) { if (pgAfterSpan) {
Dom.remove(pgAfterSpan); removeElm(pgAfterSpan);
} }
if (pgspan) { if (pgspan) {
Dom.remove(pgspan); removeElm(pgspan);
} }
if (this.hasResultsPerPage) { if (this.hasResultsPerPage) {

View file

@ -1,20 +1,20 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import {isFn} from '../types'; import {isFn} from '../types';
import Dom from '../dom'; import {createElm, removeElm} from '../dom';
import Event from '../event'; import Event from '../event';
import {INPUT, NONE} from '../const'; import {INPUT, NONE} from '../const';
export class PopupFilter extends Feature{ export class PopupFilter extends Feature {
/** /**
* Pop-up filter component * Pop-up filter component
* @param {Object} tf TableFilter instance * @param {Object} tf TableFilter instance
*/ */
constructor(tf){ constructor(tf) {
super(tf, 'popupFilters'); super(tf, 'popupFilters');
// Configuration object // Configuration object
var f = this.config; let f = this.config;
// Enable external filters // Enable external filters
tf.isExternalFlt = true; tf.isExternalFlt = true;
@ -22,12 +22,12 @@ export class PopupFilter extends Feature{
//filter icon path //filter icon path
this.popUpImgFlt = f.popup_filters_image || this.popUpImgFlt = f.popup_filters_image ||
tf.themesPath+'icn_filter.gif'; tf.themesPath + 'icn_filter.gif';
//active filter icon path //active filter icon path
this.popUpImgFltActive = f.popup_filters_image_active || this.popUpImgFltActive = f.popup_filters_image_active ||
tf.themesPath+'icn_filterActive.gif'; tf.themesPath + 'icn_filterActive.gif';
this.popUpImgFltHtml = f.popup_filters_image_html || this.popUpImgFltHtml = f.popup_filters_image_html ||
'<img src="'+ this.popUpImgFlt +'" alt="Column filter" />'; '<img src="' + this.popUpImgFlt + '" alt="Column filter" />';
//defines css class for popup div containing filter //defines css class for popup div containing filter
this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter'; this.popUpDivCssClass = f.popup_div_css_class || 'popUpFilter';
//callback function before popup filtes is opened //callback function before popup filtes is opened
@ -57,15 +57,15 @@ export class PopupFilter extends Feature{
this.prfxPopUpDiv = 'popUpDiv_'; this.prfxPopUpDiv = 'popUpDiv_';
} }
onClick(evt){ onClick(evt) {
var elm = Event.target(evt).parentNode, let elm = Event.target(evt).parentNode,
colIndex = parseInt(elm.getAttribute('ci'), 10); colIndex = parseInt(elm.getAttribute('ci'), 10);
this.closeAll(colIndex); this.closeAll(colIndex);
this.toggle(colIndex); this.toggle(colIndex);
if(this.popUpFltAdjustToContainer){ if (this.popUpFltAdjustToContainer) {
var popUpDiv = this.popUpFltElms[colIndex], let popUpDiv = this.popUpFltElms[colIndex],
header = this.tf.getHeaderElement(colIndex), header = this.tf.getHeaderElement(colIndex),
headerWidth = header.clientWidth * 0.95; headerWidth = header.clientWidth * 0.95;
popUpDiv.style.width = parseInt(headerWidth, 10) + 'px'; popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';
@ -77,29 +77,29 @@ export class PopupFilter extends Feature{
/** /**
* Initialize DOM elements * Initialize DOM elements
*/ */
init(){ init() {
if(this.initialized){ if (this.initialized) {
return; return;
} }
var tf = this.tf; let tf = this.tf;
// Override headers row index if no grouped headers // Override headers row index if no grouped headers
if(tf.headersRow <= 1){ if (tf.headersRow <= 1) {
tf.headersRow = 0; tf.headersRow = 0;
} }
for(var i=0; i<tf.nbCells; i++){ for (let i = 0; i < tf.nbCells; i++) {
if(tf.getFilterType(i) === NONE){ if (tf.getFilterType(i) === NONE) {
continue; continue;
} }
var popUpSpan = Dom.create( let popUpSpan = createElm(
'span', 'span',
['id', this.prfxPopUpSpan+tf.id+'_'+i], ['id', this.prfxPopUpSpan + tf.id + '_' + i],
['ci', i] ['ci', i]
); );
popUpSpan.innerHTML = this.popUpImgFltHtml; popUpSpan.innerHTML = this.popUpImgFltHtml;
var header = tf.getHeaderElement(i); let header = tf.getHeaderElement(i);
header.appendChild(popUpSpan); header.appendChild(popUpSpan);
Event.add(popUpSpan, 'click', (evt) => { this.onClick(evt); }); Event.add(popUpSpan, 'click', (evt) => { this.onClick(evt); });
this.popUpFltSpans[i] = popUpSpan; this.popUpFltSpans[i] = popUpSpan;
@ -107,13 +107,13 @@ export class PopupFilter extends Feature{
} }
// subscribe to events // subscribe to events
this.emitter.on(['before-filtering'], ()=> this.buildIcons()); this.emitter.on(['before-filtering'], () => this.buildIcons());
this.emitter.on(['after-filtering'], ()=> this.closeAll()); this.emitter.on(['after-filtering'], () => this.closeAll());
this.emitter.on(['cell-processed'], this.emitter.on(['cell-processed'],
(tf, cellIndex)=> this.buildIcon(cellIndex, true)); (tf, cellIndex) => this.buildIcon(cellIndex, true));
this.emitter.on(['filters-row-inserted'], ()=> this.tf.headersRow++); this.emitter.on(['filters-row-inserted'], () => this.tf.headersRow++);
this.emitter.on(['before-filter-init'], this.emitter.on(['before-filter-init'],
(tf, colIndex)=> this.build(colIndex)); (tf, colIndex) => this.build(colIndex));
this.initialized = true; this.initialized = true;
} }
@ -121,7 +121,7 @@ export class PopupFilter extends Feature{
/** /**
* Reset previously destroyed feature * Reset previously destroyed feature
*/ */
reset(){ reset() {
this.enable(); this.enable();
this.init(); this.init();
this.buildAll(); this.buildAll();
@ -130,8 +130,8 @@ export class PopupFilter extends Feature{
/** /**
* Build all pop-up filters elements * Build all pop-up filters elements
*/ */
buildAll(){ buildAll() {
for(var i=0; i<this.popUpFltElmCache.length; i++){ for (let i = 0; i < this.popUpFltElmCache.length; i++) {
this.build(i, this.popUpFltElmCache[i]); this.build(i, this.popUpFltElmCache[i]);
} }
} }
@ -141,14 +141,15 @@ export class PopupFilter extends Feature{
* @param {Number} colIndex Column index * @param {Number} colIndex Column index
* @param {Object} div Optional container DOM element * @param {Object} div Optional container DOM element
*/ */
build(colIndex, div){ build(colIndex, div) {
var tf = this.tf; let tf = this.tf;
var popUpDiv = !div ? let popUpDiv = !div ?
Dom.create('div', ['id', this.prfxPopUpDiv+tf.id+'_'+colIndex]) : createElm('div',
['id', this.prfxPopUpDiv + tf.id + '_' + colIndex]) :
div; div;
popUpDiv.className = this.popUpDivCssClass; popUpDiv.className = this.popUpDivCssClass;
tf.externalFltTgtIds.push(popUpDiv.id); tf.externalFltTgtIds.push(popUpDiv.id);
var header = tf.getHeaderElement(colIndex); let header = tf.getHeaderElement(colIndex);
header.insertBefore(popUpDiv, header.firstChild); header.insertBefore(popUpDiv, header.firstChild);
Event.add(popUpDiv, 'click', (evt) => Event.stop(evt)); Event.add(popUpDiv, 'click', (evt) => Event.stop(evt));
this.popUpFltElms[colIndex] = popUpDiv; this.popUpFltElms[colIndex] = popUpDiv;
@ -158,34 +159,34 @@ export class PopupFilter extends Feature{
* Toogle visibility of specified filter * Toogle visibility of specified filter
* @param {Number} colIndex Column index * @param {Number} colIndex Column index
*/ */
toggle(colIndex){ toggle(colIndex) {
var tf = this.tf, let tf = this.tf,
popUpFltElm = this.popUpFltElms[colIndex]; popUpFltElm = this.popUpFltElms[colIndex];
if(popUpFltElm.style.display === NONE || if (popUpFltElm.style.display === NONE ||
popUpFltElm.style.display === ''){ popUpFltElm.style.display === '') {
if(this.onBeforePopUpOpen){ if (this.onBeforePopUpOpen) {
this.onBeforePopUpOpen.call( this.onBeforePopUpOpen.call(
null, this, this.popUpFltElms[colIndex], colIndex); null, this, this.popUpFltElms[colIndex], colIndex);
} }
popUpFltElm.style.display = 'block'; popUpFltElm.style.display = 'block';
if(tf.getFilterType(colIndex) === INPUT){ if (tf.getFilterType(colIndex) === INPUT) {
var flt = tf.getFilterElement(colIndex); let flt = tf.getFilterElement(colIndex);
if(flt){ if (flt) {
flt.focus(); flt.focus();
} }
} }
if(this.onAfterPopUpOpen){ if (this.onAfterPopUpOpen) {
this.onAfterPopUpOpen.call( this.onAfterPopUpOpen.call(
null, this, this.popUpFltElms[colIndex], colIndex); null, this, this.popUpFltElms[colIndex], colIndex);
} }
} else { } else {
if(this.onBeforePopUpClose){ if (this.onBeforePopUpClose) {
this.onBeforePopUpClose.call( this.onBeforePopUpClose.call(
null, this, this.popUpFltElms[colIndex], colIndex); null, this, this.popUpFltElms[colIndex], colIndex);
} }
popUpFltElm.style.display = NONE; popUpFltElm.style.display = NONE;
if(this.onAfterPopUpClose){ if (this.onAfterPopUpClose) {
this.onAfterPopUpClose.call( this.onAfterPopUpClose.call(
null, this, this.popUpFltElms[colIndex], colIndex); null, this, this.popUpFltElms[colIndex], colIndex);
} }
@ -196,13 +197,13 @@ export class PopupFilter extends Feature{
* Close all filters excepted for the specified one if any * Close all filters excepted for the specified one if any
* @param {Number} exceptIdx Column index of the filter to not close * @param {Number} exceptIdx Column index of the filter to not close
*/ */
closeAll(exceptIdx){ closeAll(exceptIdx) {
for(var i=0; i<this.popUpFltElms.length; i++){ for (let i = 0; i < this.popUpFltElms.length; i++) {
if(i === exceptIdx){ if (i === exceptIdx) {
continue; continue;
} }
var popUpFltElm = this.popUpFltElms[i]; let popUpFltElm = this.popUpFltElms[i];
if(popUpFltElm){ if (popUpFltElm) {
popUpFltElm.style.display = NONE; popUpFltElm.style.display = NONE;
} }
} }
@ -211,8 +212,8 @@ export class PopupFilter extends Feature{
/** /**
* Build all the icons representing the pop-up filters * Build all the icons representing the pop-up filters
*/ */
buildIcons(){ buildIcons() {
for(var i=0; i<this.popUpFltImgs.length; i++){ for (let i = 0; i < this.popUpFltImgs.length; i++) {
this.buildIcon(i, false); this.buildIcon(i, false);
} }
} }
@ -222,8 +223,8 @@ export class PopupFilter extends Feature{
* @param {Number} colIndex Column index * @param {Number} colIndex Column index
* @param {Boolean} active Apply active state * @param {Boolean} active Apply active state
*/ */
buildIcon(colIndex, active){ buildIcon(colIndex, active) {
if(this.popUpFltImgs[colIndex]){ if (this.popUpFltImgs[colIndex]) {
this.popUpFltImgs[colIndex].src = active ? this.popUpFltImgs[colIndex].src = active ?
this.popUpImgFltActive : this.popUpImgFlt; this.popUpImgFltActive : this.popUpImgFlt;
} }
@ -232,27 +233,27 @@ export class PopupFilter extends Feature{
/** /**
* Remove pop-up filters * Remove pop-up filters
*/ */
destroy(){ destroy() {
if(!this.initialized){ if (!this.initialized) {
return; return;
} }
this.popUpFltElmCache = []; this.popUpFltElmCache = [];
for(var i=0; i<this.popUpFltElms.length; i++){ for (let i = 0; i < this.popUpFltElms.length; i++) {
var popUpFltElm = this.popUpFltElms[i], let popUpFltElm = this.popUpFltElms[i],
popUpFltSpan = this.popUpFltSpans[i], popUpFltSpan = this.popUpFltSpans[i],
popUpFltImg = this.popUpFltImgs[i]; popUpFltImg = this.popUpFltImgs[i];
if(popUpFltElm){ if (popUpFltElm) {
Dom.remove(popUpFltElm); removeElm(popUpFltElm);
this.popUpFltElmCache[i] = popUpFltElm; this.popUpFltElmCache[i] = popUpFltElm;
} }
popUpFltElm = null; popUpFltElm = null;
if(popUpFltSpan){ if (popUpFltSpan) {
Dom.remove(popUpFltSpan); removeElm(popUpFltSpan);
} }
popUpFltSpan = null; popUpFltSpan = null;
if(popUpFltImg){ if (popUpFltImg) {
Dom.remove(popUpFltImg); removeElm(popUpFltImg);
} }
popUpFltImg = null; popUpFltImg = null;
} }
@ -261,13 +262,13 @@ export class PopupFilter extends Feature{
this.popUpFltImgs = []; this.popUpFltImgs = [];
// unsubscribe to events // unsubscribe to events
this.emitter.off(['before-filtering'], ()=> this.buildIcons()); this.emitter.off(['before-filtering'], () => this.buildIcons());
this.emitter.off(['after-filtering'], ()=> this.closeAll()); this.emitter.off(['after-filtering'], () => this.closeAll());
this.emitter.off(['cell-processed'], this.emitter.off(['cell-processed'],
(tf, cellIndex)=> this.buildIcon(cellIndex, true)); (tf, cellIndex) => this.buildIcon(cellIndex, true));
this.emitter.off(['filters-row-inserted'], ()=> this.tf.headersRow++); this.emitter.off(['filters-row-inserted'], () => this.tf.headersRow++);
this.emitter.off(['before-filter-init'], this.emitter.off(['before-filter-init'],
(tf, colIndex)=> this.build(colIndex)); (tf, colIndex) => this.build(colIndex));
this.initialized = false; this.initialized = false;
} }

View file

@ -1,14 +1,14 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import Dom from '../dom'; import {createElm, createText, id, removeElm} from '../dom';
import {isFn} from '../types'; import {isFn} from '../types';
export class RowsCounter extends Feature{ export class RowsCounter extends Feature {
/** /**
* Rows counter * Rows counter
* @param {Object} tf TableFilter instance * @param {Object} tf TableFilter instance
*/ */
constructor(tf){ constructor(tf) {
super(tf, 'rowsCounter'); super(tf, 'rowsCounter');
// TableFilter configuration // TableFilter configuration
@ -40,35 +40,35 @@ export class RowsCounter extends Feature{
f.on_after_refresh_counter : null; f.on_after_refresh_counter : null;
} }
init(){ init() {
if(this.initialized){ if (this.initialized) {
return; return;
} }
var tf = this.tf; var tf = this.tf;
//rows counter container //rows counter container
var countDiv = Dom.create('div', ['id', this.prfxCounter+tf.id]); var countDiv = createElm('div', ['id', this.prfxCounter + tf.id]);
countDiv.className = this.totRowsCssClass; countDiv.className = this.totRowsCssClass;
//rows counter label //rows counter label
var countSpan = Dom.create('span', ['id', this.prfxTotRows+tf.id]); var countSpan = createElm('span', ['id', this.prfxTotRows + tf.id]);
var countText = Dom.create('span', ['id', this.prfxTotRowsTxt+tf.id]); var countText = createElm('span', ['id', this.prfxTotRowsTxt + tf.id]);
countText.appendChild(Dom.text(this.rowsCounterText)); countText.appendChild(createText(this.rowsCounterText));
// counter is added to defined element // counter is added to defined element
if(!this.rowsCounterTgtId){ if (!this.rowsCounterTgtId) {
tf.setToolbar(); tf.setToolbar();
} }
var targetEl = !this.rowsCounterTgtId ? var targetEl = !this.rowsCounterTgtId ?
tf.lDiv : Dom.id( this.rowsCounterTgtId ); tf.lDiv : id(this.rowsCounterTgtId);
//default container: 'lDiv' //default container: 'lDiv'
if(!this.rowsCounterTgtId){ if (!this.rowsCounterTgtId) {
countDiv.appendChild(countText); countDiv.appendChild(countText);
countDiv.appendChild(countSpan); countDiv.appendChild(countSpan);
targetEl.appendChild(countDiv); targetEl.appendChild(countDiv);
} }
else{ else {
//custom container, no need to append statusDiv //custom container, no need to append statusDiv
targetEl.appendChild(countText); targetEl.appendChild(countText);
targetEl.appendChild(countSpan); targetEl.appendChild(countSpan);
@ -78,40 +78,41 @@ export class RowsCounter extends Feature{
// subscribe to events // subscribe to events
this.emitter.on(['after-filtering', 'grouped-by-page'], this.emitter.on(['after-filtering', 'grouped-by-page'],
()=> this.refresh(tf.nbVisibleRows)); () => this.refresh(tf.nbVisibleRows));
this.emitter.on(['rows-changed'], ()=> this.refresh()); this.emitter.on(['rows-changed'], () => this.refresh());
this.initialized = true; this.initialized = true;
this.refresh(); this.refresh();
} }
refresh(p){ refresh(p) {
if(!this.initialized || !this.isEnabled()){ if (!this.initialized || !this.isEnabled()) {
return; return;
} }
var tf = this.tf; var tf = this.tf;
if(this.onBeforeRefreshCounter){ if (this.onBeforeRefreshCounter) {
this.onBeforeRefreshCounter.call(null, tf, this.rowsCounterSpan); this.onBeforeRefreshCounter.call(null, tf, this.rowsCounterSpan);
} }
var totTxt; var totTxt;
if(!tf.paging){ if (!tf.paging) {
if(p && p !== ''){ if (p && p !== '') {
totTxt = p; totTxt = p;
} else{ } else {
totTxt = tf.nbFilterableRows - tf.nbHiddenRows; totTxt = tf.nbFilterableRows - tf.nbHiddenRows;
} }
} else { } else {
var paging = tf.feature('paging'); var paging = tf.feature('paging');
if(paging){ if (paging) {
//paging start row //paging start row
var paging_start_row = parseInt(paging.startPagingRow, 10) + var paging_start_row = parseInt(paging.startPagingRow, 10) +
((tf.nbVisibleRows>0) ? 1 : 0); ((tf.nbVisibleRows > 0) ? 1 : 0);
var paging_end_row = (paging_start_row+paging.pagingLength)-1 <= var paging_end_row =
tf.nbVisibleRows ? (paging_start_row + paging.pagingLength) - 1 <=
paging_start_row+paging.pagingLength-1 : tf.nbVisibleRows ?
paging_start_row + paging.pagingLength - 1 :
tf.nbVisibleRows; tf.nbVisibleRows;
totTxt = paging_start_row + this.fromToTextSeparator + totTxt = paging_start_row + this.fromToTextSeparator +
paging_end_row + this.overText + tf.nbVisibleRows; paging_end_row + this.overText + tf.nbVisibleRows;
@ -119,29 +120,29 @@ export class RowsCounter extends Feature{
} }
this.rowsCounterSpan.innerHTML = totTxt; this.rowsCounterSpan.innerHTML = totTxt;
if(this.onAfterRefreshCounter){ if (this.onAfterRefreshCounter) {
this.onAfterRefreshCounter.call( this.onAfterRefreshCounter.call(
null, tf, this.rowsCounterSpan, totTxt); null, tf, this.rowsCounterSpan, totTxt);
} }
} }
destroy(){ destroy() {
if(!this.initialized){ if (!this.initialized) {
return; return;
} }
if(!this.rowsCounterTgtId && this.rowsCounterDiv){ if (!this.rowsCounterTgtId && this.rowsCounterDiv) {
Dom.remove(this.rowsCounterDiv); removeElm(this.rowsCounterDiv);
} else { } else {
Dom.id(this.rowsCounterTgtId).innerHTML = ''; id(this.rowsCounterTgtId).innerHTML = '';
} }
this.rowsCounterSpan = null; this.rowsCounterSpan = null;
this.rowsCounterDiv = null; this.rowsCounterDiv = null;
// unsubscribe to events // unsubscribe to events
this.emitter.off(['after-filtering', 'grouped-by-page'], this.emitter.off(['after-filtering', 'grouped-by-page'],
()=> this.refresh(tf.nbVisibleRows)); () => this.refresh(tf.nbVisibleRows));
this.emitter.off(['rows-changed'], ()=> this.refresh()); this.emitter.off(['rows-changed'], () => this.refresh());
this.initialized = false; this.initialized = false;
} }

View file

@ -1,15 +1,15 @@
import {Feature} from '../feature'; import {Feature} from '../feature';
import {root} from '../root'; import {root} from '../root';
import Dom from '../dom'; import {createElm, createText, id, removeElm} from '../dom';
import {isFn} from '../types'; import {isFn} from '../types';
export class StatusBar extends Feature{ export class StatusBar extends Feature {
/** /**
* Status bar UI component * Status bar UI component
* @param {Object} tf TableFilter instance * @param {Object} tf TableFilter instance
*/ */
constructor(tf){ constructor(tf) {
super(tf, 'statusBar'); super(tf, 'statusBar');
// Configuration object // Configuration object
@ -72,8 +72,8 @@ export class StatusBar extends Feature{
this.prfxStatusTxt = 'statusText_'; this.prfxStatusTxt = 'statusText_';
} }
init(){ init() {
if(this.initialized){ if (this.initialized) {
return; return;
} }
@ -81,25 +81,25 @@ export class StatusBar extends Feature{
let emitter = this.emitter; let emitter = this.emitter;
//status bar container //status bar container
let statusDiv = Dom.create('div', ['id', this.prfxStatus+tf.id]); let statusDiv = createElm('div', ['id', this.prfxStatus + tf.id]);
statusDiv.className = this.statusBarCssClass; statusDiv.className = this.statusBarCssClass;
//status bar label //status bar label
let statusSpan = Dom.create('span', ['id', this.prfxStatusSpan+tf.id]); let statusSpan = createElm('span', ['id', this.prfxStatusSpan + tf.id]);
//preceding text //preceding text
let statusSpanText = Dom.create('span', let statusSpanText = createElm('span',
['id', this.prfxStatusTxt+tf.id]); ['id', this.prfxStatusTxt + tf.id]);
statusSpanText.appendChild(Dom.text(this.statusBarText)); statusSpanText.appendChild(createText(this.statusBarText));
// target element container // target element container
if(!this.statusBarTgtId){ if (!this.statusBarTgtId) {
tf.setToolbar(); tf.setToolbar();
} }
let targetEl = (!this.statusBarTgtId) ? let targetEl = (!this.statusBarTgtId) ?
tf.lDiv : Dom.id(this.statusBarTgtId); tf.lDiv : id(this.statusBarTgtId);
//default container: 'lDiv' //default container: 'lDiv'
if(!this.statusBarTgtId){ if (!this.statusBarTgtId) {
statusDiv.appendChild(statusSpanText); statusDiv.appendChild(statusSpanText);
statusDiv.appendChild(statusSpan); statusDiv.appendChild(statusSpan);
targetEl.appendChild(statusDiv); targetEl.appendChild(statusDiv);
@ -114,22 +114,23 @@ export class StatusBar extends Feature{
this.statusBarSpanText = statusSpanText; this.statusBarSpanText = statusSpanText;
// Subscribe to events // Subscribe to events
emitter.on(['before-filtering'], ()=> this.message(this.msgFilter)); emitter.on(['before-filtering'], () => this.message(this.msgFilter));
emitter.on(['before-populating-filter'], emitter.on(['before-populating-filter'],
()=> this.message(this.msgPopulate)); () => this.message(this.msgPopulate));
emitter.on(['before-page-change'], emitter.on(['before-page-change'],
()=> this.message(this.msgChangePage)); () => this.message(this.msgChangePage));
emitter.on(['before-clearing-filters'], ()=> emitter.on(['before-clearing-filters'], () =>
this.message(this.msgClear)); this.message(this.msgClear));
emitter.on(['before-page-length-change'], emitter.on(['before-page-length-change'],
()=> this.message(this.msgChangeResults)); () => this.message(this.msgChangeResults));
emitter.on(['before-reset-page'], ()=> this.message(this.msgResetPage)); emitter.on(['before-reset-page'],
() => this.message(this.msgResetPage));
emitter.on(['before-reset-page-length'], emitter.on(['before-reset-page-length'],
()=> this.message(this.msgResetPageLength)); () => this.message(this.msgResetPageLength));
emitter.on(['before-loading-extensions'], emitter.on(['before-loading-extensions'],
()=> this.message(this.msgLoadExtensions)); () => this.message(this.msgLoadExtensions));
emitter.on(['before-loading-themes'], emitter.on(['before-loading-themes'],
()=> this.message(this.msgLoadThemes)); () => this.message(this.msgLoadThemes));
emitter.on([ emitter.on([
'after-filtering', 'after-filtering',
@ -141,66 +142,66 @@ export class StatusBar extends Feature{
'after-reset-page-length', 'after-reset-page-length',
'after-loading-extensions', 'after-loading-extensions',
'after-loading-themes'], 'after-loading-themes'],
()=> this.message('') () => this.message('')
); );
this.initialized = true; this.initialized = true;
} }
message(t=''){ message(t = '') {
if(!this.isEnabled()){ if (!this.isEnabled()) {
return; return;
} }
if(this.onBeforeShowMsg){ if (this.onBeforeShowMsg) {
this.onBeforeShowMsg.call(null, this.tf, t); this.onBeforeShowMsg.call(null, this.tf, t);
} }
let d = t==='' ? this.statusBarCloseDelay : 1; let d = t === '' ? this.statusBarCloseDelay : 1;
root.setTimeout(() => { root.setTimeout(() => {
if(!this.initialized){ if (!this.initialized) {
return; return;
} }
this.statusBarSpan.innerHTML = t; this.statusBarSpan.innerHTML = t;
if(this.onAfterShowMsg){ if (this.onAfterShowMsg) {
this.onAfterShowMsg.call(null, this.tf, t); this.onAfterShowMsg.call(null, this.tf, t);
} }
}, d); }, d);
} }
destroy(){ destroy() {
if(!this.initialized){ if (!this.initialized) {
return; return;
} }
let emitter = this.emitter; let emitter = this.emitter;
this.statusBarDiv.innerHTML = ''; this.statusBarDiv.innerHTML = '';
if(!this.statusBarTgtId){ if (!this.statusBarTgtId) {
Dom.remove(this.statusBarDiv); removeElm(this.statusBarDiv);
} }
this.statusBarSpan = null; this.statusBarSpan = null;
this.statusBarSpanText = null; this.statusBarSpanText = null;
this.statusBarDiv = null; this.statusBarDiv = null;
// Unsubscribe to events // Unsubscribe to events
emitter.off(['before-filtering'], ()=> this.message(this.msgFilter)); emitter.off(['before-filtering'], () => this.message(this.msgFilter));
emitter.off(['before-populating-filter'], emitter.off(['before-populating-filter'],
()=> this.message(this.msgPopulate)); () => this.message(this.msgPopulate));
emitter.off(['before-page-change'], emitter.off(['before-page-change'],
()=> this.message(this.msgChangePage)); () => this.message(this.msgChangePage));
emitter.off(['before-clearing-filters'], emitter.off(['before-clearing-filters'],
()=> this.message(this.msgClear)); () => this.message(this.msgClear));
emitter.off(['before-page-length-change'], emitter.off(['before-page-length-change'],
()=> this.message(this.msgChangeResults)); () => this.message(this.msgChangeResults));
emitter.off(['before-reset-page'], ()=> emitter.off(['before-reset-page'], () =>
this.message(this.msgResetPage)); this.message(this.msgResetPage));
emitter.off(['before-reset-page-length'], emitter.off(['before-reset-page-length'],
()=> this.message(this.msgResetPageLength)); () => this.message(this.msgResetPageLength));
emitter.off(['before-loading-extensions'], emitter.off(['before-loading-extensions'],
()=> this.message(this.msgLoadExtensions)); () => this.message(this.msgLoadExtensions));
emitter.off(['before-loading-themes'], emitter.off(['before-loading-themes'],
()=> this.message(this.msgLoadThemes)); () => this.message(this.msgLoadThemes));
emitter.off([ emitter.off([
'after-filtering', 'after-filtering',
@ -212,7 +213,7 @@ export class StatusBar extends Feature{
'after-reset-page-length', 'after-reset-page-length',
'after-loading-extensions', 'after-loading-extensions',
'after-loading-themes'], 'after-loading-themes'],
()=> this.message('') () => this.message('')
); );
this.initialized = false; this.initialized = false;

View file

@ -1,5 +1,8 @@
import Event from './event'; import Event from './event';
import Dom from './dom'; import {
addClass, createElm, createOpt, getText, getFirstTextNode, byId, tag,
removeClass, removeElm
} from './dom';
import {contains, matchCase, rgxEsc, trim} from './string'; import {contains, matchCase, rgxEsc, trim} from './string';
import {isEmpty as isEmptyString} from './string'; import {isEmpty as isEmptyString} from './string';
import {isArray, isEmpty, isFn, isNumber, isObj, isString, isUndef} import {isArray, isEmpty, isFn, isNumber, isObj, isString, isUndef}
@ -62,7 +65,7 @@ export class TableFilter {
this.id = arg.id || `tf_${new Date().getTime()}_`; this.id = arg.id || `tf_${new Date().getTime()}_`;
} else if (isString(arg)) { } else if (isString(arg)) {
this.id = arg; this.id = arg;
this.tbl = Dom.id(arg); this.tbl = byId(arg);
} else if (isNumber(arg)) { } else if (isNumber(arg)) {
this.startRow = arg; this.startRow = arg;
} else if (isObj(arg)) { } else if (isObj(arg)) {
@ -457,7 +460,7 @@ export class TableFilter {
for (let i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
this.emitter.emit('before-filter-init', this, i); this.emitter.emit('before-filter-init', this, i);
let fltcell = Dom.create(this.fltCellTag), let fltcell = createElm(this.fltCellTag),
col = this.getFilterType(i); col = this.getFilterType(i);
if (this.singleSearchFlt) { if (this.singleSearchFlt) {
@ -550,9 +553,9 @@ export class TableFilter {
//TF css class is added to table //TF css class is added to table
if (!this.gridLayout) { if (!this.gridLayout) {
Dom.addClass(this.tbl, this.prfxTf); addClass(this.tbl, this.prfxTf);
if (this.responsive) { if (this.responsive) {
Dom.addClass(this.tbl, this.prfxResponsive); addClass(this.tbl, this.prfxResponsive);
} }
} }
@ -673,7 +676,7 @@ export class TableFilter {
} }
let fltrow; let fltrow;
let thead = Dom.tag(this.tbl, 'thead'); let thead = tag(this.tbl, 'thead');
if (thead.length > 0) { if (thead.length > 0) {
fltrow = thead[0].insertRow(this.filtersRowIndex); fltrow = thead[0].insertRow(this.filtersRowIndex);
} else { } else {
@ -713,7 +716,7 @@ export class TableFilter {
let externalFltTgtId = this.isExternalFlt ? let externalFltTgtId = this.isExternalFlt ?
this.externalFltTgtIds[colIndex] : null; this.externalFltTgtIds[colIndex] : null;
let inptype = col === INPUT ? 'text' : 'hidden'; let inptype = col === INPUT ? 'text' : 'hidden';
let inp = Dom.create(INPUT, let inp = createElm(INPUT,
['id', this.prfxFlt + colIndex + '_' + this.id], ['id', this.prfxFlt + colIndex + '_' + this.id],
['type', inptype], ['ct', colIndex]); ['type', inptype], ['ct', colIndex]);
@ -728,7 +731,7 @@ export class TableFilter {
//filter is appended in custom element //filter is appended in custom element
if (externalFltTgtId) { if (externalFltTgtId) {
Dom.id(externalFltTgtId).appendChild(inp); byId(externalFltTgtId).appendChild(inp);
this.externalFltEls.push(inp); this.externalFltEls.push(inp);
} else { } else {
container.appendChild(inp); container.appendChild(inp);
@ -750,14 +753,14 @@ export class TableFilter {
_buildSubmitButton(colIndex, container) { _buildSubmitButton(colIndex, container) {
let externalFltTgtId = this.isExternalFlt ? let externalFltTgtId = this.isExternalFlt ?
this.externalFltTgtIds[colIndex] : null; this.externalFltTgtIds[colIndex] : null;
let btn = Dom.create(INPUT, let btn = createElm(INPUT,
['id', this.prfxValButton + colIndex + '_' + this.id], ['id', this.prfxValButton + colIndex + '_' + this.id],
['type', 'button'], ['value', this.btnText]); ['type', 'button'], ['value', this.btnText]);
btn.className = this.btnCssClass; btn.className = this.btnCssClass;
//filter is appended in custom element //filter is appended in custom element
if (externalFltTgtId) { if (externalFltTgtId) {
Dom.id(externalFltTgtId).appendChild(btn); byId(externalFltTgtId).appendChild(btn);
} else { } else {
container.appendChild(btn); container.appendChild(btn);
} }
@ -916,7 +919,7 @@ export class TableFilter {
* @return {DOMElement} stylesheet element * @return {DOMElement} stylesheet element
*/ */
getStylesheet(name = 'default') { getStylesheet(name = 'default') {
return Dom.id(this.prfxTf + name); return byId(this.prfxTf + name);
} }
/** /**
@ -975,8 +978,8 @@ export class TableFilter {
this.emitter.off(['filter-focus'], this.emitter.off(['filter-focus'],
(tf, filter) => this.setActiveFilterId(filter.id)); (tf, filter) => this.setActiveFilterId(filter.id));
Dom.removeClass(this.tbl, this.prfxTf); removeClass(this.tbl, this.prfxTf);
Dom.removeClass(this.tbl, this.prfxResponsive); removeClass(this.tbl, this.prfxResponsive);
this.nbHiddenRows = 0; this.nbHiddenRows = 0;
this.validRowsIndex = []; this.validRowsIndex = [];
@ -994,12 +997,12 @@ export class TableFilter {
} }
/*** container div ***/ /*** container div ***/
let infdiv = Dom.create('div', ['id', this.prfxInfDiv + this.id]); let infdiv = createElm('div', ['id', this.prfxInfDiv + this.id]);
infdiv.className = this.infDivCssClass; infdiv.className = this.infDivCssClass;
//custom container //custom container
if (this.toolBarTgtId) { if (this.toolBarTgtId) {
Dom.id(this.toolBarTgtId).appendChild(infdiv); byId(this.toolBarTgtId).appendChild(infdiv);
} }
//grid-layout //grid-layout
else if (this.gridLayout) { else if (this.gridLayout) {
@ -1009,30 +1012,30 @@ export class TableFilter {
} }
//default location: just above the table //default location: just above the table
else { else {
let cont = Dom.create('caption'); let cont = createElm('caption');
cont.appendChild(infdiv); cont.appendChild(infdiv);
this.tbl.insertBefore(cont, this.tbl.firstChild); this.tbl.insertBefore(cont, this.tbl.firstChild);
} }
this.infDiv = Dom.id(this.prfxInfDiv + this.id); this.infDiv = byId(this.prfxInfDiv + this.id);
/*** left div containing rows # displayer ***/ /*** left div containing rows # displayer ***/
let ldiv = Dom.create('div', ['id', this.prfxLDiv + this.id]); let ldiv = createElm('div', ['id', this.prfxLDiv + this.id]);
ldiv.className = this.lDivCssClass; ldiv.className = this.lDivCssClass;
infdiv.appendChild(ldiv); infdiv.appendChild(ldiv);
this.lDiv = Dom.id(this.prfxLDiv + this.id); this.lDiv = byId(this.prfxLDiv + this.id);
/*** right div containing reset button /*** right div containing reset button
+ nb results per page select ***/ + nb results per page select ***/
let rdiv = Dom.create('div', ['id', this.prfxRDiv + this.id]); let rdiv = createElm('div', ['id', this.prfxRDiv + this.id]);
rdiv.className = this.rDivCssClass; rdiv.className = this.rDivCssClass;
infdiv.appendChild(rdiv); infdiv.appendChild(rdiv);
this.rDiv = Dom.id(this.prfxRDiv + this.id); this.rDiv = byId(this.prfxRDiv + this.id);
/*** mid div containing paging elements ***/ /*** mid div containing paging elements ***/
let mdiv = Dom.create('div', ['id', this.prfxMDiv + this.id]); let mdiv = createElm('div', ['id', this.prfxMDiv + this.id]);
mdiv.className = this.mDivCssClass; mdiv.className = this.mDivCssClass;
infdiv.appendChild(mdiv); infdiv.appendChild(mdiv);
this.mDiv = Dom.id(this.prfxMDiv + this.id); this.mDiv = byId(this.prfxMDiv + this.id);
// emit help initialisation only if undefined // emit help initialisation only if undefined
if (isUndef(this.help)) { if (isUndef(this.help)) {
@ -1050,11 +1053,11 @@ export class TableFilter {
if (!this.infDiv) { if (!this.infDiv) {
return; return;
} }
Dom.remove(this.infDiv); removeElm(this.infDiv);
this.infDiv = null; this.infDiv = null;
let tbl = this.tbl; let tbl = this.tbl;
let captions = Dom.tag(tbl, 'caption'); let captions = tag(tbl, 'caption');
if (captions.length > 0) { if (captions.length > 0) {
[].forEach.call(captions, (elm) => tbl.removeChild(elm)); [].forEach.call(captions, (elm) => tbl.removeChild(elm));
} }
@ -1071,7 +1074,7 @@ export class TableFilter {
len = ids.length; len = ids.length;
for (let ct = 0; ct < len; ct++) { for (let ct = 0; ct < len; ct++) {
let externalFltTgtId = ids[ct], let externalFltTgtId = ids[ct],
externalFlt = Dom.id(externalFltTgtId); externalFlt = byId(externalFltTgtId);
if (externalFlt) { if (externalFlt) {
externalFlt.innerHTML = ''; externalFlt.innerHTML = '';
} }
@ -1173,7 +1176,7 @@ export class TableFilter {
let w = str; let w = str;
if (re_le.test(str) || re_ge.test(str) || re_l.test(str) || if (re_le.test(str) || re_ge.test(str) || re_l.test(str) ||
re_g.test(str) || re_d.test(str)) { re_g.test(str) || re_d.test(str)) {
w = Dom.getText(cell); w = getText(cell);
} }
if (w !== '') { if (w !== '') {
this.emitter.emit('highlight-keyword', this, cell, w); this.emitter.emit('highlight-keyword', this, cell, w);
@ -1628,7 +1631,7 @@ export class TableFilter {
*/ */
getFilterElement(index) { getFilterElement(index) {
let fltId = this.fltIds[index]; let fltId = this.fltIds[index];
return Dom.id(fltId); return byId(fltId);
} }
/** /**
@ -1668,7 +1671,7 @@ export class TableFilter {
this.customCellDataCols.indexOf(idx) !== -1) { this.customCellDataCols.indexOf(idx) !== -1) {
return this.customCellData.call(null, this, cell, idx); return this.customCellData.call(null, this, cell, idx);
} else { } else {
return Dom.getText(cell); return getText(cell);
} }
} }
@ -1901,7 +1904,7 @@ export class TableFilter {
function setWidths() { function setWidths() {
let nbCols = this.nbCells; let nbCols = this.nbCells;
let colWidths = this.colWidths; let colWidths = this.colWidths;
let colTags = Dom.tag(tbl, 'col'); let colTags = tag(tbl, 'col');
let tblHasColTag = colTags.length > 0; let tblHasColTag = colTags.length > 0;
let frag = !tblHasColTag ? doc.createDocumentFragment() : null; let frag = !tblHasColTag ? doc.createDocumentFragment() : null;
for (let k = 0; k < nbCols; k++) { for (let k = 0; k < nbCols; k++) {
@ -1909,7 +1912,7 @@ export class TableFilter {
if (tblHasColTag) { if (tblHasColTag) {
col = colTags[k]; col = colTags[k];
} else { } else {
col = Dom.create('col', ['id', this.id + '_col_' + k]); col = createElm('col', ['id', this.id + '_col_' + k]);
frag.appendChild(col); frag.appendChild(col);
} }
col.style.width = colWidths[k]; col.style.width = colWidths[k];
@ -1967,8 +1970,7 @@ export class TableFilter {
*/ */
clearActiveColumns() { clearActiveColumns() {
for (let i = 0, len = this.getCellsNb(this.headersRow); i < len; i++) { for (let i = 0, len = this.getCellsNb(this.headersRow); i < len; i++) {
Dom.removeClass( removeClass(this.getHeaderElement(i), this.activeColumnsCssClass);
this.getHeaderElement(i), this.activeColumnsCssClass);
} }
} }
@ -1978,13 +1980,13 @@ export class TableFilter {
*/ */
markActiveColumn(colIndex) { markActiveColumn(colIndex) {
let header = this.getHeaderElement(colIndex); let header = this.getHeaderElement(colIndex);
if (Dom.hasClass(header, this.activeColumnsCssClass)) { if (hasClass(header, this.activeColumnsCssClass)) {
return; return;
} }
if (this.onBeforeActiveColumn) { if (this.onBeforeActiveColumn) {
this.onBeforeActiveColumn.call(null, this, colIndex); this.onBeforeActiveColumn.call(null, this, colIndex);
} }
Dom.addClass(header, this.activeColumnsCssClass); addClass(header, this.activeColumnsCssClass);
if (this.onAfterActiveColumn) { if (this.onAfterActiveColumn) {
this.onAfterActiveColumn.call(null, this, colIndex); this.onAfterActiveColumn.call(null, this, colIndex);
} }
@ -2045,7 +2047,7 @@ export class TableFilter {
let activeIdx = this.getColumnIndexFromFilterId(this.activeFilterId); let activeIdx = this.getColumnIndexFromFilterId(this.activeFilterId);
for (let i = 0, len = slcIndex.length; i < len; i++) { for (let i = 0, len = slcIndex.length; i < len; i++) {
let curSlc = Dom.id(this.fltIds[slcIndex[i]]); let curSlc = byId(this.fltIds[slcIndex[i]]);
let slcSelectedValue = this.getFilterValue(slcIndex[i]); let slcSelectedValue = this.getFilterValue(slcIndex[i]);
// Welcome to cyclomatic complexity hell :) // Welcome to cyclomatic complexity hell :)
@ -2059,7 +2061,7 @@ export class TableFilter {
//1st option needs to be inserted //1st option needs to be inserted
if (this.loadFltOnDemand) { if (this.loadFltOnDemand) {
let opt0 = Dom.createOpt(this.displayAllText, ''); let opt0 = createOpt(this.displayAllText, '');
curSlc.innerHTML = ''; curSlc.innerHTML = '';
curSlc.appendChild(opt0); curSlc.appendChild(opt0);
} }
@ -2098,7 +2100,7 @@ export class TableFilter {
let imported = false, let imported = false,
importType = !type ? 'script' : type, importType = !type ? 'script' : type,
attr = importType === 'script' ? 'src' : 'href', attr = importType === 'script' ? 'src' : 'href',
files = Dom.tag(doc, importType); files = tag(doc, importType);
for (let i = 0, len = files.length; i < len; i++) { for (let i = 0, len = files.length; i < len; i++) {
if (files[i][attr] === undefined) { if (files[i][attr] === undefined) {
continue; continue;
@ -2127,15 +2129,15 @@ export class TableFilter {
let o = this, let o = this,
isLoaded = false, isLoaded = false,
file, file,
head = Dom.tag(doc, 'head')[0]; head = tag(doc, 'head')[0];
if (ftype.toLowerCase() === 'link') { if (ftype.toLowerCase() === 'link') {
file = Dom.create('link', file = createElm('link',
['id', fileId], ['type', 'text/css'], ['id', fileId], ['type', 'text/css'],
['rel', 'stylesheet'], ['href', filePath] ['rel', 'stylesheet'], ['href', filePath]
); );
} else { } else {
file = Dom.create('script', file = createElm('script',
['id', fileId], ['id', fileId],
['type', 'text/javascript'], ['src', filePath] ['type', 'text/javascript'], ['src', filePath]
); );
@ -2243,7 +2245,7 @@ export class TableFilter {
*/ */
getHeaderElement(colIndex) { getHeaderElement(colIndex) {
let table = this.gridLayout ? this.Mod.gridLayout.headTbl : this.tbl; let table = this.gridLayout ? this.Mod.gridLayout.headTbl : this.tbl;
let tHead = Dom.tag(table, 'thead'); let tHead = tag(table, 'thead');
let headersRow = this.headersRow; let headersRow = this.headersRow;
let header; let header;
for (let i = 0; i < this.nbCells; i++) { for (let i = 0; i < this.nbCells; i++) {
@ -2275,7 +2277,7 @@ export class TableFilter {
} }
} }
let header = this.getHeaderElement(j); let header = this.getHeaderElement(j);
let headerText = Dom.getFirstTextNode(header); let headerText = getFirstTextNode(header);
headers.push(headerText); headers.push(headerText);
} }
return headers; return headers;