refactor(view) addEvent: last in first out

This commit is contained in:
coderaiser 2017-11-14 12:54:41 +02:00
parent b676c67b96
commit 31889030f1

View file

@ -17,8 +17,11 @@ const Events = require('../dom/events');
const load = require('../dom/load');
const Images = require('../dom/images');
const getRegExp = (ext) => RegExp(`\\.${ext}$`, 'i');
const testRegExp = currify((name, reg) => reg.test(name));
const lifo = currify((fn, el, cb, name) => fn(name, el, cb));
const addEvent = lifo(Events.add);
const getRegExp = (ext) => RegExp(`\\.${ext}$`, 'i');
CloudCmd.View = ViewProto;
@ -94,9 +97,12 @@ function ViewProto(callback) {
className : 'fancybox-overlay fancybox-overlay-fixed'
});
['click', 'contextmenu'].forEach((name) => {
Events.add(name, Overlay, onOverLayClick);
});
const events = [
'click',
'contextmenu',
];
events.forEach(addEvent(Overlay, onOverLayClick));
return module.exports;
}