1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-22 00:06:56 +02:00

Improved emitter logic

This commit is contained in:
Max Guglielmi 2016-01-03 13:49:04 +11:00
parent ea478ec500
commit fd8d5c759c
24 changed files with 183 additions and 380 deletions

View file

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

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-02T14:26:21.155Z
* build date: 2016-01-03T02:45:10.758Z
* MIT License
*/
span.expClpFlt a.btnExpClpFlt{width:35px;height:35px;display:inline-block;}span.expClpFlt a.btnExpClpFlt:hover{background-color:#f4f4f4}span.expClpFlt img{padding:8px 11px 11px 11px}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-02T14:26:21.155Z
* build date: 2016-01-03T02:45:10.758Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-02T14:26:21.155Z
* build date: 2016-01-03T02:45:10.758Z
* MIT License
*/
table.TF{border-left:1px solid #ccc !important;border-top:none !important;border-right:none !important;border-bottom:none !important;}table.TF th{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;color:#333 !important}table.TF td{border-bottom:1px dotted #999 !important;padding:5px !important}.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}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.1.4 by Max Guglielmi
* build date: 2016-01-02T14:26:21.155Z
* build date: 2016-01-03T02:45:10.758Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b !important;border-top:none !important;border-right:0 !important;border-bottom:none !important;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;color:#fff !important}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px !important}.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}

View file

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -12,23 +12,27 @@ export class Emitter {
/**
* Subscribe to an event
* @param {String} evt Event name
* @param {Array} evts Collection of event names
* @param {Function} fn Function invoked when event is emitted
*/
on(evt, fn) {
this.events[evt] = this.events[evt] || [];
this.events[evt].push(fn);
on(evts, fn) {
evts.forEach((evt)=> {
this.events[evt] = this.events[evt] || [];
this.events[evt].push(fn);
});
}
/**
* Unsubscribe to an event
* @param {String} evt Event name
* @param {Array} evts Collection of event names
* @param {Function} fn Function invoked when event is emitted
*/
off(evt, fn) {
if(evt in this.events) {
this.events[evt].splice(this.events[evt].indexOf(fn), 1);
}
off(evts, fn) {
evts.forEach((evt)=> {
if(evt in this.events) {
this.events[evt].splice(this.events[evt].indexOf(fn), 1);
}
});
}
/**
@ -37,11 +41,10 @@ export class Emitter {
* the invoked function
*/
emit(evt /*, args...*/) {
if(evt in this.events === false) {
return;
}
for(var i = 0; i < this.events[evt].length; i++) {
this.events[evt][i].apply(this, [].slice.call(arguments, 1));
if(evt in this.events) {
for(let i = 0; i < this.events[evt].length; i++) {
this.events[evt][i].apply(this, [].slice.call(arguments, 1));
}
}
}
}

View file

@ -23,7 +23,7 @@ export default class ColOps{
init(){
// subscribe to events
this.tf.emitter.on('after-filtering', ()=> this.calc());
this.tf.emitter.on(['after-filtering'], ()=> this.calc());
this.calc();
}
@ -315,7 +315,7 @@ export default class ColOps{
destroy(){
// unsubscribe to events
this.tf.emitter.off('after-filtering', ()=> this.calc());
this.tf.emitter.off(['after-filtering'], ()=> this.calc());
}
}

View file

@ -46,7 +46,7 @@ export default class AdapterSortableTable{
opts.on_after_sort : null;
this.tf = tf;
this.emitter = this.tf.emitter;
this.emitter = tf.emitter;
}
init(){

View file

@ -27,11 +27,11 @@ export class AlternateRows extends Feature {
this.processAll();
this.emitter.on('row-processed', (tf, rowIndex, arrIndex, isValid)=>
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.on('row-paged', (tf, rowIndex, arrIndex, isValid)=>
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.on('column-sorted', ()=> this.processAll());
// Subscribe to events
this.emitter.on(['row-processed', 'row-paged'],
(tf, rowIndex, arrIndex, isValid)=>
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.on(['column-sorted'], ()=> this.processAll());
this.initialized = true;
}
@ -116,11 +116,11 @@ export class AlternateRows extends Feature {
this.removeRowBg(i);
}
this.emitter.off('row-processed', (tf, rowIndex, arrIndex, isValid)=>
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.off('row-paged', (tf, rowIndex, arrIndex, isValid)=>
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.off('column-sorted', ()=> this.processAll());
// Unsubscribe to events
this.emitter.off(['row-processed', 'row-paged'],
(tf, rowIndex, arrIndex, isValid)=>
this.processRow(rowIndex, arrIndex, isValid));
this.emitter.off(['column-sorted'], ()=> this.processAll());
this.initialized = false;
}

View file

@ -60,20 +60,6 @@ export class CheckList{
this.onChange(evt);
}
/**
* Build checklist UI asynchronously
* @param {Number} colIndex Column index
* @param {Boolean} isExternal Render in external container
* @param {String} extFltId External container id
*/
// build(colIndex, isExternal, extFltId){
// var tf = this.tf;
// tf.EvtManager(
// tf.Evt.name.checklist,
// { slcIndex:colIndex, slcExternal:isExternal, slcId:extFltId }
// );
// }
/**
* Build checklist UI
* @param {Number} colIndex Column index

View file

@ -35,26 +35,6 @@ export class Dropdown{
this.emitter = tf.emitter;
}
/**
* Build drop-down filter UI asynchronously
* @param {Number} colIndex Column index
* @param {Boolean} isLinked Enable linked refresh behaviour
* @param {Boolean} isExternal Render in external container
* @param {String} extSlcId External container id
*/
// build(colIndex, isLinked, isExternal, extSlcId){
// var tf = this.tf;
// tf.EvtManager(
// tf.Evt.name.dropdown,
// {
// slcIndex: colIndex,
// slcRefreshed: isLinked,
// slcExternal: isExternal,
// slcId: extSlcId
// }
// );
// }
/**
* Build drop-down filter UI
* @param {Number} colIndex Column index

View file

@ -18,7 +18,7 @@ export class HighlightKeyword{
}
init(){
this.emitter.on('before-filtering', ()=> this.unhighlightAll());
this.emitter.on(['before-filtering'], ()=> this.unhighlightAll());
}
/**
@ -112,6 +112,6 @@ export class HighlightKeyword{
}
destroy(){
this.emitter.off('before-filtering', ()=> this.unhighlightAll());
this.emitter.off(['before-filtering'], ()=> this.unhighlightAll());
}
}

View file

@ -66,24 +66,32 @@ export class Loader extends Feature{
this.show('none');
// Subscribe to events
emitter.on('before-filtering', ()=> this.show(''));
emitter.on('after-filtering', ()=> this.show('none'));
emitter.on('before-populating-filter', ()=> this.show(''));
emitter.on('after-populating-filter', ()=> this.show('none'));
emitter.on('before-changing-page', ()=> this.show(''));
emitter.on('after-changing-page', ()=> this.show('none'));
emitter.on('before-clearing-filters', ()=> this.show(''));
emitter.on('after-clearing-filters', ()=> this.show('none'));
emitter.on('before-changing-results-per-page', ()=> this.show(''));
emitter.on('after-changing-results-per-page', ()=> this.show('none'));
emitter.on('before-reset-page', ()=> this.show(''));
emitter.on('after-reset-page', ()=> this.show('none'));
emitter.on('before-reset-page-length', ()=> this.show(''));
emitter.on('after-reset-page-length', ()=> this.show('none'));
emitter.on('before-loading-extensions', ()=> this.show(''));
emitter.on('after-loading-extensions', ()=> this.show('none'));
emitter.on('before-loading-themes', ()=> this.show(''));
emitter.on('after-loading-themes', ()=> this.show('none'));
emitter.on([
'before-filtering',
'before-populating-filter',
'before-changing-page',
'before-clearing-filters',
'before-changing-results-per-page',
'before-reset-page',
'before-reset-page-length',
'before-loading-extensions',
'before-loading-themes'
],
()=> this.show('')
);
emitter.on([
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'
],
()=> this.show('none')
);
this.initialized = true;
}
@ -121,24 +129,32 @@ export class Loader extends Feature{
this.loaderDiv = null;
// Unsubscribe to events
emitter.off('before-filtering', ()=> this.show(''));
emitter.off('after-filtering', ()=> this.show('none'));
emitter.off('before-populating-filter', ()=> this.show(''));
emitter.off('after-populating-filter', ()=> this.show('none'));
emitter.off('before-changing-page', ()=> this.show(''));
emitter.off('after-changing-page', ()=> this.show('none'));
emitter.off('before-clearing-filters', ()=> this.show(''));
emitter.off('after-clearing-filters', ()=> this.show('none'));
emitter.off('before-changing-results-per-page', ()=> this.show(''));
emitter.off('after-changing-results-per-page', ()=> this.show('none'));
emitter.off('before-reset-page', ()=> this.show(''));
emitter.off('after-reset-page', ()=> this.show('none'));
emitter.off('before-reset-page-length', ()=> this.show(''));
emitter.off('after-reset-page-length', ()=> this.show('none'));
emitter.off('before-loading-extensions', ()=> this.show(''));
emitter.off('after-loading-extensions', ()=> this.show('none'));
emitter.off('before-loading-themes', ()=> this.show(''));
emitter.off('after-loading-themes', ()=> this.show('none'));
emitter.off([
'before-filtering',
'before-populating-filter',
'before-changing-page',
'before-clearing-filters',
'before-changing-results-per-page',
'before-reset-page',
'before-reset-page-length',
'before-loading-extensions',
'before-loading-themes'
],
()=> this.show('')
);
emitter.off([
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'
],
()=> this.show('none')
);
this.initialized = false;
}

View file

@ -61,7 +61,7 @@ export class NoResults extends Feature{
this.cont = cont;
// subscribe to after-filtering event
this.emitter.on('after-filtering', ()=> this.toggle());
this.emitter.on(['after-filtering'], ()=> this.toggle());
this.initialized = true;
this.hide();
@ -128,7 +128,8 @@ export class NoResults extends Feature{
Dom.remove(this.cont);
this.cont = null;
// unsubscribe to after-filtering event
this.emitter.off('after-filtering', ()=> this.toggle());
this.emitter.off(['after-filtering'], ()=> this.toggle());
this.initialized = false;
}
}

View file

@ -334,8 +334,8 @@ export class Paging extends Feature{
this.setPagingInfo(tf.validRowsIndex);
}
this.emitter.on('after-filtering', ()=> this.resetPagingInfo());
this.emitter.on('initialized', ()=> this.resetValues());
this.emitter.on(['after-filtering'], ()=> this.resetPagingInfo());
this.emitter.on(['initialized'], ()=> this.resetValues());
this.initialized = true;
}
@ -562,43 +562,6 @@ export class Paging extends Feature{
this.resultsPerPageSlc = null;
}
/**
* Change the page asynchronously according to passed index
* @param {Number} index Index of the page (0-n)
*/
// changePage(index){
// var tf = this.tf;
// var evt = tf.Evt;
// tf.EvtManager(evt.name.changepage, { pgIndex:index });
// }
/**
* Change rows asynchronously according to page results
*/
// changeResultsPerPage(){
// var tf = this.tf;
// var evt = tf.Evt;
// tf.EvtManager(evt.name.changeresultsperpage);
// }
/**
* Re-set asynchronously page nb at page re-load
*/
// resetPage(){
// var tf = this.tf;
// var evt = tf.Evt;
// tf.EvtManager(evt.name.resetpage);
// }
/**
* Re-set asynchronously page length at page re-load
*/
// resetPageLength(){
// var tf = this.tf;
// var evt = tf.Evt;
// tf.EvtManager(evt.name.resetpagelength);
// }
/**
* Change the page according to passed index
* @param {Number} index Index of the page (0-n)
@ -799,8 +762,8 @@ export class Paging extends Feature{
this.removeResultsPerPage();
}
this.emitter.off('after-filtering', ()=> this.resetPagingInfo());
this.emitter.off('initialized', ()=> this.resetValues());
this.emitter.off(['after-filtering'], ()=> this.resetPagingInfo());
this.emitter.off(['initialized'], ()=> this.resetValues());
this.pagingSlc = null;
this.nbPages = 0;

View file

@ -102,9 +102,9 @@ export class PopupFilter extends Feature{
}
// subscribe to events
this.emitter.on('before-filtering', ()=> this.buildIcons());
this.emitter.on('after-filtering', ()=> this.closeAll());
this.emitter.on('cell-processed',
this.emitter.on(['before-filtering'], ()=> this.buildIcons());
this.emitter.on(['after-filtering'], ()=> this.closeAll());
this.emitter.on(['cell-processed'],
(tf, cellIndex)=> this.buildIcon(cellIndex, true));
this.initialized = true;
@ -253,9 +253,9 @@ export class PopupFilter extends Feature{
this.popUpFltImgs = [];
// unsubscribe to events
this.emitter.off('before-filtering', ()=> this.buildIcons());
this.emitter.off('after-filtering', ()=> this.closeAll());
this.emitter.off('cell-processed',
this.emitter.off(['before-filtering'], ()=> this.buildIcons());
this.emitter.off(['after-filtering'], ()=> this.closeAll());
this.emitter.off(['cell-processed'],
(tf, cellIndex)=> this.buildIcon(cellIndex, true));
this.initialized = false;

View file

@ -76,12 +76,10 @@ export class RowsCounter extends Feature{
this.rowsCounterDiv = countDiv;
this.rowsCounterSpan = countSpan;
// subscribe to after-filtering event
this.emitter.on('after-filtering', ()=> this.refresh(tf.nbVisibleRows));
// subscribe to grouped-by-page event
this.emitter.on('grouped-by-page', ()=> this.refresh(tf.nbVisibleRows));
// subscribe to rows-changed event
this.emitter.on('rows-changed', ()=> this.refresh());
// subscribe to events
this.emitter.on(['after-filtering', 'grouped-by-page'],
()=> this.refresh(tf.nbVisibleRows));
this.emitter.on(['rows-changed'], ()=> this.refresh());
this.initialized = true;
this.refresh();
@ -141,15 +139,9 @@ export class RowsCounter extends Feature{
this.rowsCounterDiv = null;
// unsubscribe to events
this.emitter.off(
'after-filtering',
()=> this.refresh(tf.nbVisibleRows)
);
this.emitter.off(
'grouped-by-page',
()=> this.refresh(tf.nbVisibleRows)
);
this.emitter.off('rows-changed', ()=> this.refresh());
this.emitter.off(['after-filtering', 'grouped-by-page'],
()=> this.refresh(tf.nbVisibleRows));
this.emitter.off(['rows-changed'], ()=> this.refresh());
this.initialized = false;
}

View file

@ -52,9 +52,6 @@ export class StatusBar extends Feature{
//changing nb results/page
this.msgChangeResults = f.msg_change_results ||
'Changing results per page...';
//re-setting grid values
// this.msgResetValues = f.msg_reset_grid_values ||
// 'Re-setting filters values...';
//re-setting page
this.msgResetPage = f.msg_reset_page || 'Re-setting page...';
//re-setting page length
@ -118,30 +115,36 @@ export class StatusBar extends Feature{
this.statusBarSpanText = statusSpanText;
// Subscribe to events
emitter.on('before-filtering', ()=> this.message(this.msgFilter));
emitter.on('after-filtering', ()=> this.message(''));
emitter.on('before-populating-filter',
emitter.on(['before-filtering'], ()=> this.message(this.msgFilter));
emitter.on(['before-populating-filter'],
()=> this.message(this.msgPopulate));
emitter.on('after-populating-filter', ()=> this.message(''));
emitter.on('before-changing-page',
emitter.on(['before-changing-page'],
()=> this.message(this.msgChangePage));
emitter.on('after-changing-page', ()=> this.message(''));
emitter.on('before-clearing-filters', ()=> this.message(this.msgClear));
emitter.on('after-clearing-filters', ()=> this.message(''));
emitter.on('before-changing-results-per-page',
emitter.on(['before-clearing-filters'], ()=>
this.message(this.msgClear));
emitter.on(['before-changing-results-per-page'],
()=> this.message(this.msgChangeResults));
emitter.on('after-changing-results-per-page', ()=> this.message(''));
emitter.on('before-reset-page', ()=> this.message(this.msgResetPage));
emitter.on('after-reset-page', ()=> this.message(''));
emitter.on('before-reset-page-length',
emitter.on(['before-reset-page'], ()=> this.message(this.msgResetPage));
emitter.on(['before-reset-page-length'],
()=> this.message(this.msgResetPageLength));
emitter.on('after-reset-page-length', ()=> this.message(''));
emitter.on('before-loading-extensions',
emitter.on(['before-loading-extensions'],
()=> this.message(this.msgLoadExtensions));
emitter.on('after-loading-extensions', ()=> this.message(''));
emitter.on('before-loading-themes',
emitter.on(['before-loading-themes'],
()=> this.message(this.msgLoadThemes));
emitter.on('after-loading-themes', ()=> this.message(''));
emitter.on([
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'
],
()=> this.message('')
);
this.initialized = true;
}
@ -181,31 +184,37 @@ export class StatusBar extends Feature{
this.statusBarDiv = null;
// Unsubscribe to events
emitter.off('before-filtering', ()=> this.message(this.msgFilter));
emitter.off('after-filtering', ()=> this.message(''));
emitter.off('before-populating-filter',
emitter.off(['before-filtering'], ()=> this.message(this.msgFilter));
emitter.off(['before-populating-filter'],
()=> this.message(this.msgPopulate));
emitter.off('after-populating-filter', ()=> this.message(''));
emitter.off('before-changing-page',
emitter.off(['before-changing-page'],
()=> this.message(this.msgChangePage));
emitter.off('after-changing-page', ()=> this.message(''));
emitter.off('before-clearing-filters',
emitter.off(['before-clearing-filters'],
()=> this.message(this.msgClear));
emitter.off('after-clearing-filters', ()=> this.message(''));
emitter.off('before-changing-results-per-page',
emitter.off(['before-changing-results-per-page'],
()=> this.message(this.msgChangeResults));
emitter.off('after-changing-results-per-page', ()=> this.message(''));
emitter.off('before-reset-page', ()=> this.message(this.msgResetPage));
emitter.off('after-reset-page', ()=> this.message(''));
emitter.off('before-reset-page-length',
emitter.off(['before-reset-page'], ()=>
this.message(this.msgResetPage));
emitter.off(['before-reset-page-length'],
()=> this.message(this.msgResetPageLength));
emitter.off('after-reset-page-length', ()=> this.message(''));
emitter.off('before-loading-extensions',
emitter.off(['before-loading-extensions'],
()=> this.message(this.msgLoadExtensions));
emitter.off('after-loading-extensions', ()=> this.message(''));
emitter.off('before-loading-themes',
emitter.off(['before-loading-themes'],
()=> this.message(this.msgLoadThemes));
emitter.off('after-loading-themes', ()=> this.message(''));
emitter.off([
'after-filtering',
'after-populating-filter',
'after-changing-page',
'after-clearing-filters',
'after-changing-results-per-page',
'after-reset-page',
'after-reset-page-length',
'after-loading-extensions',
'after-loading-themes'
],
()=> this.message('')
);
this.initialized = false;
}

View file

@ -19,7 +19,7 @@ export class Store{
}
init(){
this.emitter.on('after-filtering',
this.emitter.on(['after-filtering'],
()=> this.saveFilterValues(this.tf.fltsValuesCookie));
}
@ -104,7 +104,7 @@ export class Store{
}
destroy(){
this.emitter.off('after-filtering',
this.emitter.off(['after-filtering'],
()=> this.saveFilterValues(this.tf.fltsValuesCookie));
}
}

View file

@ -368,37 +368,6 @@ export class TableFilter {
//array containing columns date type
this.colDateType = this.hasColDateType ? f.col_date_type : null;
/*** status messages ***/
//filtering
// this.msgFilter = f.msg_filter || 'Filtering data...';
// //populating drop-downs
// this.msgPopulate = f.msg_populate || 'Populating filter...';
// //populating drop-downs
// this.msgPopulateCheckList = f.msg_populate_checklist ||
// 'Populating list...';
// //changing paging page
//this.msgChangePage = f.msg_change_page || 'Collecting paging data...';
// //clearing filters
// this.msgClear = f.msg_clear || 'Clearing filters...';
// //changing nb results/page
// this.msgChangeResults = f.msg_change_results ||
// 'Changing results per page...';
// //re-setting grid values
// this.msgResetValues = f.msg_reset_grid_values ||
// 'Re-setting filters values...';
// //re-setting page
// this.msgResetPage = f.msg_reset_page || 'Re-setting page...';
// //re-setting page length
// this.msgResetPageLength = f.msg_reset_page_length ||
// 'Re-setting page length...';
// //table sorting
// this.msgSort = f.msg_sort || 'Sorting data...';
// //extensions loading
// this.msgLoadExtensions = f.msg_load_extensions ||
// 'Loading extensions...';
// //themes loading
// this.msgLoadThemes = f.msg_load_themes || 'Loading theme(s)...';
/*** ids prefixes ***/
//css class name added to table
this.prfxTf = 'TF';
@ -457,20 +426,6 @@ export class TableFilter {
/*** TF events ***/
this.Evt = {
// name: {
// //filter: 'Filter',
// //dropdown: 'DropDown',
// // checklist: 'CheckList',
// // changepage: 'ChangePage',
// // clear: 'Clear',
// // changeresultsperpage: 'ChangeResults',
// // resetvalues: 'ResetValues',
// // resetpage: 'ResetPage',
// // resetpagelength: 'ResetPageLength',
// // loadextensions: 'LoadExtensions',
// // loadthemes: 'LoadThemes'
// },
// Detect <enter> key
detectKey(e) {
if(!this.enterKey){ return; }
@ -630,7 +585,7 @@ export class TableFilter {
this.import(this.stylesheetId, this.stylesheet, null, 'link');
//loads theme
if(this.hasThemes){ this._loadThemes(); }
if(this.hasThemes){ this.loadThemes(); }
if(this.rememberGridValues || this.rememberPageNb ||
this.rememberPageLen){
@ -876,7 +831,7 @@ export class TableFilter {
/* Features */
if(this.hasVisibleRows){
this.emitter.on('after-filtering', ()=> this.enforceVisibility());
this.emitter.on(['after-filtering'], ()=> this.enforceVisibility());
this.enforceVisibility();
}
if(this.rowsCounter){
@ -938,12 +893,13 @@ export class TableFilter {
// Subscribe to events
if(this.markActiveColumns){
this.emitter.on('before-filtering', ()=> this.clearActiveColumns());
this.emitter.on('cell-processed',
this.emitter.on(['before-filtering'],
()=> this.clearActiveColumns());
this.emitter.on(['cell-processed'],
(tf, colIndex)=> this.markActiveColumn(colIndex));
}
if(this.linkedFilters){
this.emitter.on('after-filtering', ()=> this.linkFilters());
this.emitter.on(['after-filtering'], ()=> this.linkFilters());
}
if(this.onFiltersLoaded){
@ -953,87 +909,6 @@ export class TableFilter {
this.emitter.emit('initialized', this);
}
/**
* Manages state messages
* @param {String} evt Event name
* @param {Object} cfg Config object
*/
// EvtManager(evt/*,
// cfg={ slcIndex: null, slcExternal: false, slcId: null, pgIndex: null }
// */){
// // let slcIndex = cfg.slcIndex;
// // let slcExternal = cfg.slcExternal;
// // let slcId = cfg.slcId;
// // let pgIndex = cfg.pgIndex;
// let cpt = this.Mod;
// function efx(){
// /*jshint validthis:true */
// // let ev = this.Evt.name;
// // switch(evt){
// // case ev.filter:
// // this._filter();
// // break;
// // case ev.dropdown:
// // if(this.linkedFilters){
// // cpt.dropdown._build(slcIndex, true);
// // } else {
// // cpt.dropdown._build(
// // slcIndex, false, slcExternal, slcId);
// // }
// // break;
// // case ev.checklist:
// // cpt.checkList._build(slcIndex, slcExternal, slcId);
// // break;
// // case ev.changepage:
// // cpt.paging._changePage(pgIndex);
// // break;
// // case ev.clear:
// // this._clearFilters();
// // this.filter();
// // break;
// // case ev.changeresultsperpage:
// // cpt.paging._changeResultsPerPage();
// // break;
// // case ev.resetvalues:
// // this._resetValues();
// // this.filter();
// // break;
// // case ev.resetpage:
// // cpt.paging._resetPage(this.pgNbCookie);
// // break;
// // case ev.resetpagelength:
// // cpt.paging._resetPageLength(this.pgLenCookie);
// // break;
// // case ev.loadextensions:
// // this._loadExtensions();
// // break;
// // case ev.loadthemes:
// // this._loadThemes();
// // break;
// // }
// if(this.statusBar){
// cpt.statusBar.message('');
// }
// if(this.loader){
// cpt.loader.show('none');
// }
// }
// if(!this.loader && !this.statusBar && !this.linkedFilters) {
// efx.call(this);
// } else {
// if(this.loader){
// cpt.loader.show('');
// }
// if(this.statusBar){
// cpt.statusBar.message(this['msg'+evt]);
// }
// global.setTimeout(efx.bind(this), this.execDelay);
// }
// }
/**
* Return a feature instance for a given name
* @param {String} name Name of the feature
@ -1123,10 +998,6 @@ export class TableFilter {
}
}
// loadThemes(){
// this.EvtManager(this.Evt.name.loadthemes);
// }
/**
* Load themes defined in the configuration object
*/
@ -1213,9 +1084,9 @@ export class TableFilter {
}
if(this.markActiveColumns){
this.clearActiveColumns();
this.emitter.off('before-filtering',
this.emitter.off(['before-filtering'],
()=> this.clearActiveColumns());
this.emitter.off('cell-processed',
this.emitter.off(['cell-processed'],
(tf, colIndex)=> this.markActiveColumn(colIndex));
}
if(this.hasExtensions){
@ -1248,10 +1119,11 @@ export class TableFilter {
// unsubscribe to events
if(this.hasVisibleRows){
this.emitter.off('after-filtering', ()=> this.enforceVisibility());
this.emitter.off(['after-filtering'],
()=> this.enforceVisibility());
}
if(this.linkedFilters){
this.emitter.off('after-filtering', ()=> this.linkFilters());
this.emitter.off(['after-filtering'], ()=> this.linkFilters());
}
Dom.removeClass(this.tbl, this.prfxTf);
@ -1403,10 +1275,6 @@ export class TableFilter {
return [optArray, optTxt];
}
// resetValues(){
// this.EvtManager(this.Evt.name.resetvalues);
// }
/**
* Reset persisted filter values
*/
@ -1415,12 +1283,6 @@ export class TableFilter {
if(this.rememberGridValues && this.loadFltOnDemand){
this._resetGridValues(this.fltsValuesCookie);
}
// if(this.rememberPageLen && this.Mod.paging){
// this.Mod.paging.resetPageLength(this.pgLenCookie);
// }
// if(this.rememberPageNb && this.Mod.paging){
// this.Mod.paging.resetPage(this.pgNbCookie);
// }
this.filter();
}
@ -1509,10 +1371,6 @@ export class TableFilter {
}//end if
}
// filter(){
// this.EvtManager(this.Evt.name.filter);
// }
/**
* Filter the table by retrieving the data from each cell in every single
* row and comparing it to the search term for current column. A row is
@ -2331,10 +2189,6 @@ export class TableFilter {
}
}
// clearFilters(){
// // this.EvtManager(this.Evt.name.clear);
// }
/**
* Clear all the filters' values
*/
@ -2510,9 +2364,6 @@ export class TableFilter {
Mod.popupFilter.reset();
}
// if(!this.gridLayout){
// Dom.addClass(this.tbl, this.prfxTf);
// }
this._hasGrid = true;
}

View file

@ -17,7 +17,8 @@ module('Behaviour');
test('Can subscribe', function(){
var emitter = tf.emitter;
var output = null;
emitter.on('before-filtering', function(){ output = 'before-filtering'; });
emitter.on(['before-filtering'],
function(){ output = 'before-filtering'; });
tf.filter();
@ -29,7 +30,8 @@ test('Can subscribe', function(){
test('Can unsubscribe', function(){
var emitter = tf.emitter;
var output = null;
emitter.off('before-filtering', function(){ output = 'before-filtering'; });
emitter.off(['before-filtering'],
function(){ output = 'before-filtering'; });
tf.filter();
@ -41,7 +43,7 @@ test('Can unsubscribe', function(){
test('Can emit', function(){
var emitter = tf.emitter;
var output = null;
emitter.on('hello', function(arg){ output = arg; });
emitter.on(['hello'], function(arg){ output = arg; });
emitter.emit('hello', 'world');