1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2026-03-17 08:05:44 +01:00

Continued pub-sub refactoring

This commit is contained in:
Max Guglielmi 2016-01-12 17:46:27 +11:00
commit 4e2ae18aff
13 changed files with 567 additions and 10038 deletions

View file

@ -50,9 +50,11 @@ export class CheckList extends Feature{
// TODO: move event here
onChange(evt){
let elm = evt.target;
this.tf.activeFilterId = elm.getAttribute('id');
this.tf.activeFlt = Dom.id(this.tf.activeFilterId);
this.tf.Evt.onSlcChange.call(this.tf, evt);
let tf = this.tf;
tf.activeFilterId = elm.getAttribute('id');
tf.activeFlt = Dom.id(tf.activeFilterId);
tf.filter();
// this.tf.Evt.onSlcChange.call(this.tf, evt);
}
optionClick(evt){
@ -132,7 +134,7 @@ export class CheckList extends Feature{
let ul = Dom.create(
'ul', ['id', tf.fltIds[colIndex]], ['colIndex', colIndex]);
ul.className = this.checkListCssClass;
Event.add(ul, 'change', (evt) => this.onChange(evt));
Event.add(ul, 'change', (evt)=> this.onChange(evt));
let rows = tf.tbl.rows;
this.isCustom = tf.isCustomOptions(colIndex);
@ -289,7 +291,7 @@ export class CheckList extends Feature{
li.check.disabled = true;
li.disabled = true;
} else {
Event.add(li.check, 'click', (evt) => this.optionClick(evt));
Event.add(li.check, 'click', (evt)=> this.optionClick(evt));
}
ul.appendChild(li);
@ -313,9 +315,7 @@ export class CheckList extends Feature{
li0.className = this.checkListItemCssClass;
ul.appendChild(li0);
Event.add(li0.check, 'click', (evt) => {
this.optionClick(evt);
});
Event.add(li0.check, 'click', (evt)=> this.optionClick(evt));
if(!this.enableCheckListResetFilter){
li0.style.display = 'none';
@ -326,7 +326,7 @@ export class CheckList extends Feature{
tf.fltIds[colIndex]+'_1', tf.emOperator, tf.emptyText);
li1.className = this.checkListItemCssClass;
ul.appendChild(li1);
Event.add(li1.check, 'click', (evt) => this.optionClick(evt));
Event.add(li1.check, 'click', (evt)=> this.optionClick(evt));
chkCt++;
}
@ -338,7 +338,7 @@ export class CheckList extends Feature{
);
li2.className = this.checkListItemCssClass;
ul.appendChild(li2);
Event.add(li2.check, 'click', (evt) => this.optionClick(evt));
Event.add(li2.check, 'click', (evt)=> this.optionClick(evt));
chkCt++;
}
return chkCt;

View file

@ -53,6 +53,14 @@ export class Dropdown extends Feature{
this.emitter.emit('filter-focus', tf, this);
}
onSlcChange() {
// if(!this.activeFlt){ return; }
// if(this.popupFilters){ Event.stop(e); }
if(this.tf.onSlcChange){
this.tf.filter();
}
}
/**
* Initialize drop-down filter
* @param {Number} colIndex Column index
@ -95,8 +103,9 @@ export class Dropdown extends Feature{
slc.appendChild(opt0);
}
Event.add(slc, 'keypress', tf.Evt.detectKey.bind(tf));
Event.add(slc, 'change', tf.Evt.onSlcChange.bind(tf));
//Event.add(slc, 'keypress', tf.Evt.detectKey.bind(tf));
Event.add(slc, 'change', ()=> this.onSlcChange());
// Event.add(slc, 'change', tf.Evt.onSlcChange.bind(tf));
Event.add(slc, 'focus', (e)=> this.onSlcFocus(e));
this.initialized = true;