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

Refactored Event module

This commit is contained in:
Max Guglielmi 2016-06-02 14:13:56 +10:00
parent f5848c7b8e
commit 2e2515586e
21 changed files with 189 additions and 186 deletions

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.35 by Max Guglielmi
* build date: 2016-06-02T03:28:29.388Z
* build date: 2016-06-02T04:09:12.677Z
* 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.2.35 by Max Guglielmi
* build date: 2016-06-02T03:28:29.388Z
* build date: 2016-06-02T04:09:12.677Z
* 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.2.35 by Max Guglielmi
* build date: 2016-06-02T03:28:29.388Z
* build date: 2016-06-02T04:09:12.677Z
* MIT License
*/
.activeHeader{background-color:#66afe9 !important;color:#fff !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.35 by Max Guglielmi
* build date: 2016-06-02T03:28:29.388Z
* build date: 2016-06-02T04:09:12.677Z
* MIT License
*/
table.TF{border-left:1px solid #ccc;border-top:none;border-right:none;border-bottom:none;}table.TF th{background:#ebecee url("images/bg_th.jpg") left top repeat-x;border-bottom:1px solid #d0d0d0;border-right:1px solid #d0d0d0;border-left:1px solid #fff;border-top:1px solid #fff;color:#333}table.TF td{border-bottom:1px dotted #999;padding:5px}.fltrow{background-color:#ebecee !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #666 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #999 !important}input.flt{width:99% !important}.inf{height:$min-height;background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important}input.reset{background:transparent url("images/btn_eraser.gif") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important;}.nextPage:hover{background:transparent url("images/btn_over_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important;}.previousPage:hover{background:transparent url("images/btn_over_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important;}.firstPage:hover{background:transparent url("images/btn_over_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important;}.lastPage:hover{background:transparent url("images/btn_over_last_page.gif") center center no-repeat !important}div.grd_Cont{background-color:#ebecee !important;border:1px solid #ccc !important;padding:0 !important;}div.grd_Cont .even{background-color:#fff}div.grd_Cont .odd{background-color:#d5d5d5}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important;}div.grd_headTblCont table{border-right:none !important}div.grd_tblCont table th,div.grd_headTblCont table th,div.grd_headTblCont table td{background:#ebecee url("images/bg_th.jpg") left top repeat-x !important;border-bottom:1px solid #d0d0d0 !important;border-right:1px solid #d0d0d0 !important;border-left:1px solid #fff !important;border-top:1px solid #fff !important}div.grd_tblCont table td{border-bottom:1px solid #999 !important}.grd_inf{background:#d7d7d7 url("images/bg_infDiv.jpg") 0 0 repeat-x !important;border-top:1px solid #d0d0d0 !important}.loader{border:1px solid #999}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#fff}.odd{background-color:#d5d5d5}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#999 !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.35 by Max Guglielmi
* build date: 2016-06-02T03:28:29.388Z
* build date: 2016-06-02T04:09:12.677Z
* MIT License
*/
table.TF{border-left:1px dotted #81963b;border-top:none;border-right:0;border-bottom:none;}table.TF th{background:#39424b url("images/bg_headers.jpg") left top repeat-x;border-bottom:0;border-right:1px dotted #d0d0d0;border-left:0;border-top:0;color:#fff}table.TF td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b;padding:5px}.fltrow{background-color:#81963b !important;}.fltrow th,.fltrow td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;padding:1px 3px 1px 3px !important}.flt,select.flt,select.flt_multi,.flt_s,.single_flt,.div_checklist{border:1px solid #687830 !important}input.flt{width:99% !important}.inf{background:#d8d8d8;height:$min-height}input.reset{width:53px;background:transparent url("images/btn_filter.png") center center no-repeat !important}.helpBtn:hover{background-color:transparent}.nextPage{background:transparent url("images/btn_next_page.gif") center center no-repeat !important}.previousPage{background:transparent url("images/btn_previous_page.gif") center center no-repeat !important}.firstPage{background:transparent url("images/btn_first_page.gif") center center no-repeat !important}.lastPage{background:transparent url("images/btn_last_page.gif") center center no-repeat !important}div.grd_Cont{background:#81963b url("images/bg_headers.jpg") left top repeat-x !important;border:1px solid #ccc !important;padding:0 1px 1px 1px !important;}div.grd_Cont .even{background-color:#bccd83}div.grd_Cont .odd{background-color:#fff}div.grd_headTblCont{background-color:#ebecee !important;border-bottom:none !important}div.grd_tblCont table{border-right:none !important;}div.grd_tblCont table td{border-bottom:1px dotted #81963b;border-right:1px dotted #81963b}div.grd_tblCont table th,div.grd_headTblCont table th{background:transparent url("images/bg_headers.jpg") 0 0 repeat-x !important;border-bottom:0 !important;border-right:1px dotted #d0d0d0 !important;border-left:0 !important;border-top:0 !important;padding:0 4px 0 4px !important;color:#fff !important;height:35px !important}div.grd_headTblCont table td{border-bottom:1px dotted #39424b !important;border-right:1px dotted #fff !important;border-left:0 !important;border-top:0 !important;background-color:#81963b !important;padding:1px 3px 1px 3px !important}.grd_inf{background-color:#d8d8d8;border-top:1px solid #d0d0d0 !important}.loader{border:0 !important;background:#81963b !important}.defaultLoader{width:32px;height:32px;background:transparent url("images/img_loading.gif") 0 0 no-repeat !important}.even{background-color:#bccd83}.odd{background-color:#fff}span.expClpFlt a.btnExpClpFlt:hover{background-color:transparent !important}.activeHeader{background:#81963b !important}

View file

@ -1,6 +1,6 @@
/**
* tablefilter v0.2.35 by Max Guglielmi
* build date: 2016-06-02T03:28:29.388Z
* build date: 2016-06-02T04:09:12.677Z
* 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

@ -4,96 +4,99 @@ import {root} from './root';
* DOM event utilities
*/
export default {
/**
* Add event handler for specified event on passed element
*
* @param {DOMElement} obj Element
* @param {String} type Event type
* @param {Function} Handler
* @param {Boolean} capture Specifiy whether the event should be executed in
* the capturing or in the bubbling phase
*/
add(obj, type, func, capture) {
if (obj.addEventListener) {
obj.addEventListener(type, func, capture);
}
else if (obj.attachEvent) {
obj.attachEvent('on' + type, func);
} else {
obj['on' + type] = func;
}
},
/**
* Remove event handler for specified event on passed element
*
* @param {DOMElement} obj Element
* @param {String} type Event type
* @param {Function} Handler
* @param {Boolean} capture Specifiy whether the event should be executed in
* the capturing or in the bubbling phase
*/
remove(obj, type, func, capture) {
if (obj.detachEvent) {
obj.detachEvent('on' + type, func);
}
else if (obj.removeEventListener) {
obj.removeEventListener(type, func, capture);
} else {
obj['on' + type] = null;
}
},
/**
* Prevents further propagation of the current event in the bubbling phase
*
* @param {Event} evt Event on the DOM
*/
stop(evt) {
if (!evt) {
evt = root.event;
}
if (evt.stopPropagation) {
evt.stopPropagation();
} else {
evt.cancelBubble = true;
}
},
/**
* Cancels the event if it is cancelable, without stopping further
* propagation of the event.
*
* @param {Event} evt Event on the DOM
*/
cancel(evt) {
if (!evt) {
evt = root.event;
}
if (evt.preventDefault) {
evt.preventDefault();
} else {
evt.returnValue = false;
}
},
/**
* Reference to the object that dispatched the event
*
* @param {Event} evt Event on the DOM
* @returns {DOMElement}
*/
target(evt) {
if (!evt) {
evt = root.event;
}
return evt.target || evt.srcElement;
},
/**
* Returns the Unicode value of pressed key
*
* @param {Event} evt Event on the DOM
* @returns {Number}
*/
keyCode(evt) {
return evt.charCode ? evt.charCode :
(evt.keyCode ? evt.keyCode : (evt.which ? evt.which : 0));
/**
* Add event handler for specified event on passed element
*
* @param {DOMElement} obj Element
* @param {String} type Event type
* @param {Function} Handler
* @param {Boolean} capture Specifiy whether the event should be executed in
* the capturing or in the bubbling phase
*/
export const addEvt = (obj, type, func, capture) => {
if (obj.addEventListener) {
obj.addEventListener(type, func, capture);
}
else if (obj.attachEvent) {
obj.attachEvent('on' + type, func);
} else {
obj['on' + type] = func;
}
};
/**
* Remove event handler for specified event on passed element
*
* @param {DOMElement} obj Element
* @param {String} type Event type
* @param {Function} Handler
* @param {Boolean} capture Specifiy whether the event should be executed in
* the capturing or in the bubbling phase
*/
export const removeEvt = (obj, type, func, capture) =>{
if (obj.detachEvent) {
obj.detachEvent('on' + type, func);
}
else if (obj.removeEventListener) {
obj.removeEventListener(type, func, capture);
} else {
obj['on' + type] = null;
}
};
/**
* Prevents further propagation of the current event in the bubbling phase
*
* @param {Event} evt Event on the DOM
*/
export const stopEvt = evt =>{
if (!evt) {
evt = root.event;
}
if (evt.stopPropagation) {
evt.stopPropagation();
} else {
evt.cancelBubble = true;
}
};
/**
* Cancels the event if it is cancelable, without stopping further
* propagation of the event.
*
* @param {Event} evt Event on the DOM
*/
export const cancelEvt = evt => {
if (!evt) {
evt = root.event;
}
if (evt.preventDefault) {
evt.preventDefault();
} else {
evt.returnValue = false;
}
};
/**
* Reference to the object that dispatched the event
*
* @param {Event} evt Event on the DOM
* @returns {DOMElement}
*/
export const targetEvt = evt => {
if (!evt) {
evt = root.event;
}
return evt.target || evt.srcElement;
};
/**
* Returns the Unicode value of pressed key
*
* @param {Event} evt Event on the DOM
* @returns {Number}
*/
export const keyCode = evt => {
return evt.charCode ? evt.charCode :
(evt.keyCode ? evt.keyCode : (evt.which ? evt.which : 0));
};

View file

@ -4,7 +4,7 @@ import {
getText, tag
} from '../../dom';
import {isFn} from '../../types';
import Event from '../../event';
import {addEvt, targetEvt} from '../../event';
export default class ColsVisibility extends Feature {
@ -221,17 +221,17 @@ export default class ColsVisibility extends Feature {
btn.innerHTML = this.btnText;
span.appendChild(btn);
if (!this.enableHover) {
Event.add(btn, 'click', (evt) => this.toggle(evt));
addEvt(btn, 'click', (evt) => this.toggle(evt));
} else {
Event.add(btn, 'mouseover', (evt) => this.toggle(evt));
addEvt(btn, 'mouseover', (evt) => this.toggle(evt));
}
} else { //Custom html
span.innerHTML = this.btnHtml;
let colVisEl = span.firstChild;
if (!this.enableHover) {
Event.add(colVisEl, 'click', (evt) => this.toggle(evt));
addEvt(colVisEl, 'click', (evt) => this.toggle(evt));
} else {
Event.add(colVisEl, 'mouseover', (evt) => this.toggle(evt));
addEvt(colVisEl, 'mouseover', (evt) => this.toggle(evt));
}
}
@ -276,7 +276,7 @@ export default class ColsVisibility extends Feature {
ul.appendChild(li);
li.check.checked = !this.tickToHide;
Event.add(li.check, 'click', () => {
addEvt(li.check, 'click', () => {
for (let h = 0; h < headerRow.cells.length; h++) {
let itm = elm('col_' + h + '_' + tf.id);
if (itm && li.check.checked !== itm.checked) {
@ -302,8 +302,8 @@ export default class ColsVisibility extends Feature {
liElm.check.checked = true;
}
Event.add(liElm.check, 'click', (evt) => {
let elm = Event.target(evt);
addEvt(liElm.check, 'click', (evt) => {
let elm = targetEvt(evt);
let lbl = elm.parentNode;
this.checkItem(lbl);
});
@ -317,12 +317,12 @@ export default class ColsVisibility extends Feature {
btn = createElm('a', ['href', 'javascript:;']);
btn.className = this.btnCloseCssClass;
btn.innerHTML = this.btnCloseText;
Event.add(btn, 'click', (evt) => this.toggle(evt));
addEvt(btn, 'click', (evt) => this.toggle(evt));
p.appendChild(btn);
} else {
p.innerHTML = this.btnCloseHtml;
btn = p.firstChild;
Event.add(btn, 'click', (evt) => this.toggle(evt));
addEvt(btn, 'click', (evt) => this.toggle(evt));
}
container.appendChild(ul);

View file

@ -1,7 +1,7 @@
import {Feature} from '../../feature';
import {createElm, removeElm, elm} from '../../dom';
import {isFn, isUndef} from '../../types';
import Event from '../../event';
import {addEvt} from '../../event';
export default class FiltersVisibility extends Feature {
@ -124,7 +124,7 @@ export default class FiltersVisibility extends Feature {
btn = span.firstChild;
}
Event.add(btn, 'click', () => this.toggle());
addEvt(btn, 'click', () => this.toggle());
this.contEl = span;
this.btnEl = btn;

View file

@ -1,7 +1,7 @@
import {Feature} from '../../feature';
import {isArray, isFn, isUndef} from '../../types';
import {createElm, elm, getText, tag} from '../../dom';
import Event from '../../event';
import {addEvt} from '../../event';
import {formatDate} from '../../date';
import {removeNbFormat} from '../../helpers';
import {NONE, CELL_TAG, HEADER_TAG} from '../../const';
@ -192,7 +192,7 @@ export default class AdapterSortableTable extends Feature {
if (stt.sortTypes[i] !== null) {
c.setAttribute('_sortType', stt.sortTypes[i]);
}
Event.add(c, 'click', stt._headerOnclick);
addEvt(c, 'click', stt._headerOnclick);
} else {
c.setAttribute('_sortType', oSortTypes[i]);
c._sortType = 'None';
@ -339,7 +339,7 @@ export default class AdapterSortableTable extends Feature {
if (trigger) {
trigger.style.cursor = 'pointer';
Event.add(trigger, 'click', (evt) => {
addEvt(trigger, 'click', (evt) => {
let elm = evt.target;
if (!this.tf.sort) {
return;

View file

@ -6,7 +6,7 @@ import {
import {has} from '../array';
import {matchCase, trim, rgxEsc} from '../string';
import {ignoreCase, numSortAsc, numSortDesc} from '../sort';
import Event from '../event';
import {addEvt, removeEvt, targetEvt} from '../event';
import {isEmpty} from '../types';
import {CHECKLIST, NONE} from '../const';
@ -56,7 +56,7 @@ export class CheckList extends Feature {
}
onChange(evt) {
let elm = Event.target(evt);
let elm = targetEvt(evt);
let tf = this.tf;
this.emitter.emit('filter-focus', tf, elm);
tf.filter();
@ -68,12 +68,12 @@ export class CheckList extends Feature {
}
onCheckListClick(evt) {
let elm = Event.target(evt);
let elm = targetEvt(evt);
if (this.tf.loadFltOnDemand && elm.getAttribute('filled') === '0') {
let ct = elm.getAttribute('ct');
let div = this.checkListDiv[ct];
this.build(ct);
Event.remove(div, 'click', (evt) => this.onCheckListClick(evt));
removeEvt(div, 'click', (evt) => this.onCheckListClick(evt));
}
}
@ -107,7 +107,7 @@ export class CheckList extends Feature {
if (!tf.loadFltOnDemand) {
this.build(colIndex);
} else {
Event.add(divCont, 'click', (evt) => this.onCheckListClick(evt));
addEvt(divCont, 'click', (evt) => this.onCheckListClick(evt));
divCont.appendChild(createText(this.activateCheckListTxt));
}
@ -141,7 +141,7 @@ export class CheckList extends Feature {
let ul = createElm('ul', ['id', tf.fltIds[colIndex]],
['colIndex', colIndex]);
ul.className = this.checkListCssClass;
Event.add(ul, 'change', (evt) => this.onChange(evt));
addEvt(ul, 'change', (evt) => this.onChange(evt));
let rows = tf.tbl.rows;
let nbRows = tf.getRowsNb(true);
@ -295,7 +295,7 @@ export class CheckList extends Feature {
li.check.disabled = true;
li.disabled = true;
} else {
Event.add(li.check, 'click', (evt) => this.optionClick(evt));
addEvt(li.check, 'click', (evt) => this.optionClick(evt));
}
ul.appendChild(li);
@ -319,7 +319,7 @@ export class CheckList extends Feature {
li0.className = this.checkListItemCssClass;
ul.appendChild(li0);
Event.add(li0.check, 'click', (evt) => this.optionClick(evt));
addEvt(li0.check, 'click', (evt) => this.optionClick(evt));
if (!this.enableCheckListResetFilter) {
li0.style.display = NONE;
@ -330,7 +330,7 @@ export class CheckList extends Feature {
tf.emOperator, tf.emptyText);
li1.className = this.checkListItemCssClass;
ul.appendChild(li1);
Event.add(li1.check, 'click', (evt) => this.optionClick(evt));
addEvt(li1.check, 'click', (evt) => this.optionClick(evt));
chkCt++;
}
@ -339,7 +339,7 @@ export class CheckList extends Feature {
tf.nonEmptyText);
li2.className = this.checkListItemCssClass;
ul.appendChild(li2);
Event.add(li2.check, 'click', (evt) => this.optionClick(evt));
addEvt(li2.check, 'click', (evt) => this.optionClick(evt));
chkCt++;
}
return chkCt;

View file

@ -1,6 +1,6 @@
import {Feature} from '../feature';
import {createElm, createText, elm, removeElm} from '../dom';
import Event from '../event';
import {addEvt} from '../event';
export class ClearButton extends Feature {
@ -62,11 +62,11 @@ export class ClearButton extends Feature {
fltreset.className = tf.btnResetCssClass;
fltreset.appendChild(createText(this.btnResetText));
resetspan.appendChild(fltreset);
Event.add(fltreset, 'click', () => { this.onClick(); });
addEvt(fltreset, 'click', () => this.onClick());
} else {
resetspan.innerHTML = this.btnResetHtml;
let resetEl = resetspan.firstChild;
Event.add(resetEl, 'click', () => { this.onClick(); });
addEvt(resetEl, 'click', () => this.onClick());
}
this.btnResetEl = resetspan.firstChild;

View file

@ -3,7 +3,7 @@ import {createElm, createOpt, elm} from '../dom';
import {has} from '../array';
import {matchCase} from '../string';
import {ignoreCase, numSortAsc, numSortDesc} from '../sort';
import Event from '../event';
import {addEvt, targetEvt} from '../event';
import {SELECT, MULTIPLE, NONE} from '../const';
const SORT_ERROR = 'Filter options for column {0} cannot be sorted in ' +
@ -39,7 +39,7 @@ export class Dropdown extends Feature {
}
onSlcFocus(e) {
let elm = Event.target(e);
let elm = targetEvt(e);
let tf = this.tf;
// select is populated when element has focus
if (tf.loadFltOnDemand && elm.getAttribute('filled') === '0') {
@ -97,8 +97,8 @@ export class Dropdown extends Feature {
slc.appendChild(opt0);
}
Event.add(slc, 'change', () => this.onSlcChange());
Event.add(slc, 'focus', (e) => this.onSlcFocus(e));
addEvt(slc, 'change', () => this.onSlcChange());
addEvt(slc, 'focus', (e) => this.onSlcFocus(e));
this.emitter.on(
['build-select-filter'],

View file

@ -1,7 +1,7 @@
import {Feature} from '../feature';
import {createElm, removeElm, elm, tag} from '../dom';
import {isFn, isNull, isUndef} from '../types';
import Event from '../event';
import {addEvt, targetEvt} from '../event';
import {contains} from '../string';
import {NONE} from '../const';
@ -233,8 +233,8 @@ export class GridLayout extends Feature {
//
//scroll synchronisation
Event.add(this.tblCont, 'scroll', (evt) => {
let elm = Event.target(evt);
addEvt(this.tblCont, 'scroll', (evt) => {
let elm = targetEvt(evt);
let scrollLeft = elm.scrollLeft;
this.headTblCont.scrollLeft = scrollLeft;
//New pointerX calc taking into account scrollLeft

View file

@ -1,4 +1,4 @@
import Event from '../event';
import {addEvt, removeEvt} from '../event';
import {root} from '../root';
const JSON = root.JSON;
@ -41,7 +41,7 @@ export class Hash {
this.emitter.on(['state-changed'], (tf, state) => this.update(state));
this.emitter.on(['initialized'], () => this.sync());
Event.add(root, 'hashchange', () => this.sync());
addEvt(root, 'hashchange', () => this.sync());
}
/**
@ -91,7 +91,7 @@ export class Hash {
destroy() {
this.emitter.off(['state-changed'], (tf, state) => this.update(state));
this.emitter.off(['initialized'], () => this.sync());
Event.remove(root, 'hashchange', () => this.sync());
removeEvt(root, 'hashchange', () => this.sync());
this.state = null;
this.lastHash = null;

View file

@ -1,6 +1,6 @@
import {Feature} from '../feature';
import {createElm, createText, elm, removeElm} from '../dom';
import Event from '../event';
import {addEvt} from '../event';
import {NONE} from '../const';
const WIKI_URL = 'https://github.com/koalyptus/TableFilter/wiki/' +
@ -93,18 +93,18 @@ export class Help extends Feature {
helplink.className = this.btnCssClass;
helplink.appendChild(createText(this.btnText));
helpspan.appendChild(helplink);
Event.add(helplink, 'click', () => this.toggle());
addEvt(helplink, 'click', () => this.toggle());
} else {
helpspan.innerHTML = this.btnHtml;
var helpEl = helpspan.firstChild;
Event.add(helpEl, 'click', () => this.toggle());
addEvt(helpEl, 'click', () => this.toggle());
divContainer.appendChild(helpdiv);
}
if (!this.instrHtml) {
helpdiv.innerHTML = this.instrText;
helpdiv.className = this.contCssClass;
Event.add(helpdiv, 'dblclick', () => this.toggle());
addEvt(helpdiv, 'dblclick', () => this.toggle());
} else {
if (this.contTgtId) {
divContainer.appendChild(helpdiv);
@ -112,11 +112,11 @@ export class Help extends Feature {
helpdiv.innerHTML = this.instrHtml;
if (!this.contTgtId) {
helpdiv.className = this.contCssClass;
Event.add(helpdiv, 'dblclick', () => this.toggle());
addEvt(helpdiv, 'dblclick', () => this.toggle());
}
}
helpdiv.innerHTML += this.defaultHtml;
Event.add(helpdiv, 'click', () => this.toggle());
addEvt(helpdiv, 'click', () => this.toggle());
this.cont = helpdiv;
this.btn = helpspan;

View file

@ -1,7 +1,7 @@
import {Feature} from '../feature';
import {createElm, createOpt, createText, elm, removeElm} from '../dom';
import {isArray, isFn, isNull} from '../types';
import Event from '../event';
import {addEvt, keyCode, removeEvt} from '../event';
import {INPUT, SELECT, NONE, ENTER_KEY} from '../const';
export class Paging extends Feature {
@ -156,7 +156,7 @@ export class Paging extends Feature {
o.changePage(0);
},
_detectKey(e) {
var key = Event.keyCode(e);
var key = keyCode(e);
if (key === ENTER_KEY) {
if (tf.sorted) {
tf.filter();
@ -207,7 +207,7 @@ export class Paging extends Feature {
if (this.pageSelectorType === SELECT) {
slcPages = createElm(SELECT, ['id', this.prfxSlcPages + tf.id]);
slcPages.className = this.pgSlcCssClass;
Event.add(slcPages, 'change', evt.slcPagesChange);
addEvt(slcPages, 'change', evt.slcPagesChange);
}
// Paging input selector
@ -217,7 +217,7 @@ export class Paging extends Feature {
['value', this.currentPageNb]
);
slcPages.className = this.pgInpCssClass;
Event.add(slcPages, 'keypress', evt._detectKey);
addEvt(slcPages, 'keypress', evt._detectKey);
}
// btns containers
@ -240,11 +240,11 @@ export class Paging extends Feature {
['title', 'Next']
);
btn_next.className = this.btnPageCssClass;
Event.add(btn_next, 'click', evt.next);
addEvt(btn_next, 'click', evt.next);
btnNextSpan.appendChild(btn_next);
} else {
btnNextSpan.innerHTML = this.btnNextPageHtml;
Event.add(btnNextSpan, 'click', evt.next);
addEvt(btnNextSpan, 'click', evt.next);
}
// Previous button
if (!this.btnPrevPageHtml) {
@ -255,11 +255,11 @@ export class Paging extends Feature {
['title', 'Previous']
);
btn_prev.className = this.btnPageCssClass;
Event.add(btn_prev, 'click', evt.prev);
addEvt(btn_prev, 'click', evt.prev);
btnPrevSpan.appendChild(btn_prev);
} else {
btnPrevSpan.innerHTML = this.btnPrevPageHtml;
Event.add(btnPrevSpan, 'click', evt.prev);
addEvt(btnPrevSpan, 'click', evt.prev);
}
// Last button
if (!this.btnLastPageHtml) {
@ -270,11 +270,11 @@ export class Paging extends Feature {
['title', 'Last']
);
btn_last.className = this.btnPageCssClass;
Event.add(btn_last, 'click', evt.last);
addEvt(btn_last, 'click', evt.last);
btnLastSpan.appendChild(btn_last);
} else {
btnLastSpan.innerHTML = this.btnLastPageHtml;
Event.add(btnLastSpan, 'click', evt.last);
addEvt(btnLastSpan, 'click', evt.last);
}
// First button
if (!this.btnFirstPageHtml) {
@ -285,11 +285,11 @@ export class Paging extends Feature {
['title', 'First']
);
btn_first.className = this.btnPageCssClass;
Event.add(btn_first, 'click', evt.first);
addEvt(btn_first, 'click', evt.first);
btnFirstSpan.appendChild(btn_first);
} else {
btnFirstSpan.innerHTML = this.btnFirstPageHtml;
Event.add(btnFirstSpan, 'click', evt.first);
addEvt(btnFirstSpan, 'click', evt.first);
}
}
@ -529,7 +529,7 @@ export class Paging extends Feature {
var currOpt = new Option(slcROpts[r], slcROpts[r], false, false);
slcR.options[r] = currOpt;
}
Event.add(slcR, 'change', evt.slcResultsChange);
addEvt(slcR, 'change', evt.slcResultsChange);
this.resultsPerPageSlc = slcR;
}
@ -699,31 +699,31 @@ export class Paging extends Feature {
if (this.pagingSlc) {
if (this.pageSelectorType === SELECT) {
Event.remove(this.pagingSlc, 'change', evt.slcPagesChange);
removeEvt(this.pagingSlc, 'change', evt.slcPagesChange);
}
else if (this.pageSelectorType === INPUT) {
Event.remove(this.pagingSlc, 'keypress', evt._detectKey);
removeEvt(this.pagingSlc, 'keypress', evt._detectKey);
}
removeElm(this.pagingSlc);
}
if (btnNextSpan) {
Event.remove(btnNextSpan, 'click', evt.next);
removeEvt(btnNextSpan, 'click', evt.next);
removeElm(btnNextSpan);
}
if (btnPrevSpan) {
Event.remove(btnPrevSpan, 'click', evt.prev);
removeEvt(btnPrevSpan, 'click', evt.prev);
removeElm(btnPrevSpan);
}
if (btnLastSpan) {
Event.remove(btnLastSpan, 'click', evt.last);
removeEvt(btnLastSpan, 'click', evt.last);
removeElm(btnLastSpan);
}
if (btnFirstSpan) {
Event.remove(btnFirstSpan, 'click', evt.first);
removeEvt(btnFirstSpan, 'click', evt.first);
removeElm(btnFirstSpan);
}

View file

@ -1,7 +1,7 @@
import {Feature} from '../feature';
import {isFn} from '../types';
import {createElm, removeElm} from '../dom';
import Event from '../event';
import {addEvt, cancelEvt, stopEvt, targetEvt} from '../event';
import {INPUT, NONE} from '../const';
export class PopupFilter extends Feature {
@ -58,7 +58,7 @@ export class PopupFilter extends Feature {
}
onClick(evt) {
let elm = Event.target(evt).parentNode,
let elm = targetEvt(evt).parentNode,
colIndex = parseInt(elm.getAttribute('ci'), 10);
this.closeAll(colIndex);
@ -70,8 +70,8 @@ export class PopupFilter extends Feature {
headerWidth = header.clientWidth * 0.95;
popUpDiv.style.width = parseInt(headerWidth, 10) + 'px';
}
Event.cancel(evt);
Event.stop(evt);
cancelEvt(evt);
stopEvt(evt);
}
/**
@ -101,7 +101,7 @@ export class PopupFilter extends Feature {
popUpSpan.innerHTML = this.popUpImgFltHtml;
let header = tf.getHeaderElement(i);
header.appendChild(popUpSpan);
Event.add(popUpSpan, 'click', (evt) => { this.onClick(evt); });
addEvt(popUpSpan, 'click', (evt) => this.onClick(evt));
this.popUpFltSpans[i] = popUpSpan;
this.popUpFltImgs[i] = popUpSpan.firstChild;
}
@ -151,7 +151,7 @@ export class PopupFilter extends Feature {
tf.externalFltTgtIds.push(popUpDiv.id);
let header = tf.getHeaderElement(colIndex);
header.insertBefore(popUpDiv, header.firstChild);
Event.add(popUpDiv, 'click', (evt) => Event.stop(evt));
addEvt(popUpDiv, 'click', (evt) => stopEvt(evt));
this.popUpFltElms[colIndex] = popUpDiv;
}

View file

@ -1,4 +1,4 @@
import Event from './event';
import {addEvt, cancelEvt, stopEvt, targetEvt, keyCode} from './event';
import {
addClass, createElm, createOpt, elm, getText, getFirstTextNode, hasClass,
removeClass, removeElm, tag
@ -580,11 +580,11 @@ export class TableFilter {
return;
}
if (evt) {
let key = Event.keyCode(evt);
let key = keyCode(evt);
if (key === ENTER_KEY) {
this.filter();
Event.cancel(evt);
Event.stop(evt);
cancelEvt(evt);
stopEvt(evt);
} else {
this.isUserTyping = true;
root.clearInterval(this.autoFilterTimer);
@ -602,7 +602,7 @@ export class TableFilter {
if (!this.autoFilter) {
return;
}
let key = Event.keyCode(evt);
let key = keyCode(evt);
this.isUserTyping = false;
function filter() {
@ -640,7 +640,7 @@ export class TableFilter {
* @param {Event} evt
*/
onInpFocus(evt) {
let elm = Event.target(evt);
let elm = targetEvt(evt);
this.emitter.emit('filter-focus', this, elm);
}
@ -714,7 +714,7 @@ export class TableFilter {
);
}
inp.className = cssClass || this.fltCssClass;
Event.add(inp, 'focus', (evt) => this.onInpFocus(evt));
addEvt(inp, 'focus', (evt) => this.onInpFocus(evt));
//filter is appended in custom element
if (externalFltTgtId) {
@ -726,10 +726,10 @@ export class TableFilter {
this.fltIds.push(inp.id);
Event.add(inp, 'keypress', (evt) => this.detectKey(evt));
Event.add(inp, 'keydown', () => this.onKeyDown());
Event.add(inp, 'keyup', (evt) => this.onKeyUp(evt));
Event.add(inp, 'blur', () => this.onInpBlur());
addEvt(inp, 'keypress', (evt) => this.detectKey(evt));
addEvt(inp, 'keydown', () => this.onKeyDown());
addEvt(inp, 'keyup', (evt) => this.onKeyUp(evt));
addEvt(inp, 'blur', () => this.onInpBlur());
}
/**
@ -752,7 +752,7 @@ export class TableFilter {
container.appendChild(btn);
}
Event.add(btn, 'click', () => this.filter());
addEvt(btn, 'click', () => this.filter());
}
/**