Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "eventi", | ||
"version": "1.0.2", | ||
"homepage": "https://github.com/nbubna/Eventi", | ||
"bugs": "https://github.com/nbubna/nbubna/issues", | ||
"version": "1.1.0", | ||
"homepage": "https://github.com/esha/Eventi", | ||
"bugs": "https://github.com/esha/Eventi/issues", | ||
"authors": [ | ||
@@ -11,3 +11,3 @@ "ESHA Research <nathan@esha.com>" | ||
"type": "git", | ||
"url": "https://github.com:nbubna/Eventi.git" | ||
"url": "https://github.com:esha/Eventi.git" | ||
}, | ||
@@ -14,0 +14,0 @@ "main": "dist/eventi.min.js", |
{ | ||
"name": "eventi", | ||
"repo": "nbubna/Eventi", | ||
"version": "1.0.2", | ||
"repo": "esha/Eventi", | ||
"version": "1.1.0", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "event", |
@@ -1,4 +0,4 @@ | ||
/*! Eventi - v1.0.2 - 2014-04-09 | ||
* https://github.com/nbubna/Eventi | ||
/*! Eventi - v1.1.0 - 2014-04-17 | ||
* https://github.com/esha/Eventi | ||
* Copyright (c) 2014 ESHA Research; Licensed MIT */ | ||
!function(){var a=Eventi._,b=console.log.bind(console);a.debug=function(c,d,e,f){var g=c[a._key],h=[];if(g)for(var i=0,j=d.length;j>i;i++){var k={};if(d[i])a.parse(k.text=d[i],k.event={},k.handler={}),"function"!=typeof e&&(f=e,e=void 0),k.data=f,k.handlers=a.debug.handlers(k.event.type,k,g);else{k=[];var l={event:{},handler:{}};for(var m in g.s)k.push.apply(k,a.debug.handlers(m,l,g))}h.push(k)}return e||(e=b),h.forEach(function(b){b.text?e(a.debug.target(c),b.text,b.event,b.handler,b.handlers):b.forEach(function(b){e(a.debug.target(b.target),b.text,b)})}),h.length>1?h:h[0]},a.debug.target=function(a){return a===window?"":a},a.debug.handlers=function(b,c,d){var e=d.s[b],f=[];if(e)for(var g=0,h=e.length;h>g;g++)a.debug.match(e[g],c)&&f.push(e[g]);return f},a.debug.match=function(b,c){return a.matches(b.event,c.event)&&a.matches(b,c.handler)&&(!b.important||c.handler.important&&a.matches(c.event,b.event))&&(!c.fn||c.fn===b.fn)},Eventi.debug=a.wrap("debug",3),b("Eventi, version "+a.version),Eventi.debug()}(); | ||
!function(){var a=Eventi._,b=console.log.bind(console);a.debug=function(c,d,e,f){var g=c[a._key],h=[];if(g)for(var i=0,j=d.length;j>i;i++){var k={};if(d[i])a.parse(k.text=d[i],k.event={},k.handler={}),"function"!=typeof e&&(f=e,e=void 0),k.data=f,k.handlers=a.debug.handlers(k.event.type,k,g);else{k=[];var l={event:{},handler:{}};for(var m in g.s)k.push.apply(k,a.debug.handlers(m,l,g))}h.push(k)}return e||(e=b),h.forEach(function(b){b.text?e(a.debug.target(c),b.text,b.event,b.handler,b.handlers):b.forEach(function(b){e(a.debug.target(b.target),b.text,b)})}),h.length>1?h:h[0]},a.debug.target=function(a){return a===window?"":a},a.debug.handlers=function(b,c,d){var e=d.s[b],f=[];if(e)for(var g=0,h=e.length;h>g;g++)a.debug.match(e[g],c)&&f.push(e[g]);return f},a.debug.match=function(b,c){return a.matches(b.event,c.event)&&a.matches(b,c.handler)&&(!b.important||c.handler.important&&a.matches(c.event,b.event))&&(!c.fn||c.fn===b.fn)},a.fn("debug",3),b("Eventi, version "+a.version),Eventi.debug()}(); |
@@ -1,3 +0,3 @@ | ||
/*! Eventi - v1.0.2 - 2014-04-09 | ||
* https://github.com/nbubna/Eventi | ||
/*! Eventi - v1.1.0 - 2014-04-17 | ||
* https://github.com/esha/Eventi | ||
* Copyright (c) 2014 ESHA Research; Licensed MIT */ | ||
@@ -66,7 +66,7 @@ | ||
parse: function(type, event, handler) { | ||
_.parsers.forEach(function(property) { | ||
type = type.replace(property[0], function() { | ||
_.parsers.forEach(function(parser) { | ||
type = type.replace(parser[0], function() { | ||
var args = _.slice(arguments, 1); | ||
args.unshift(event, handler); | ||
return property[1].apply(event, args) || ''; | ||
return parser[1].apply(event, args) || ''; | ||
}); | ||
@@ -97,4 +97,4 @@ }); | ||
wrap: function(name, dataIndex) { | ||
return function wrapper(target) { | ||
fn: function(name, dataIndex) { | ||
Eventi[name] = _.fns[name] = function wrapper(target) { | ||
var args = _.slice(arguments); | ||
@@ -122,2 +122,3 @@ if (!target || typeof target === "string" || target instanceof global.Event) {// ensure target | ||
}, | ||
fns: {}, | ||
split: { | ||
@@ -164,13 +165,10 @@ guard: { '(':')' }, | ||
}; | ||
(Eventi.toString = function(){ return 'Eventi'; }).utility = true; | ||
Eventi.toString = function(){ return 'Eventi, v'+_.version; }; | ||
Eventi._ = _; | ||
(Eventi.fy = function fy(o) { | ||
for (var p in Eventi) { | ||
var fn = Eventi[p]; | ||
if (typeof fn === "function" && !fn.utility) { | ||
Object.defineProperty(o, p, {value:fn, writable:true, configurable:true}); | ||
} | ||
Eventi.fy = function fy(o) { | ||
for (var p in _.fns) { | ||
Object.defineProperty(o, p, {value:Eventi[p], writable:true, configurable:true}); | ||
} | ||
return o; | ||
}).utility = true; | ||
}; | ||
@@ -208,3 +206,3 @@ _.parsers.unshift([/^(\W*)\//, function(event, handler, other) { | ||
}; | ||
Eventi.fire = _.wrap('fire', 2); | ||
_.fn('fire', 2); | ||
_.parsers.unshift([/^(\W*)\!/, function(e, handler, other) {// | ||
@@ -215,2 +213,5 @@ handler.important = true; | ||
_.on = function(target, events, fn, data) { | ||
if (target !== _.global && events.length === 1 && events[0] === '') { | ||
events = target; target = _.global; | ||
} | ||
if (!Array.isArray(events)) { | ||
@@ -313,5 +314,36 @@ if (fn !== undefined) { | ||
}; | ||
_.fn('on', 3); | ||
Eventi.on = _.wrap('on', 3); | ||
_.parsers.unshift([/=>(\w+)$/, function(event, handler, alias) { | ||
handler.alias = alias; | ||
if (handler !== event) { | ||
handler.data = handler.data || []; | ||
handler.data.push(alias); | ||
} | ||
}]); | ||
_.alias = function(alias, text, context) { | ||
return function aliased(target) { | ||
var args = _.slice(arguments), | ||
index = (typeof target !== "object" || !(target.dispatchEvent || target[_key])) ? 0 : 1; | ||
args.splice(index, 0, text); | ||
return this.apply(context, args); | ||
}; | ||
}; | ||
Eventi.alias = function(context) { | ||
var texts = _.slice(arguments, 1), | ||
props; | ||
if (typeof context === "string") { | ||
texts.unshift(context); | ||
context = Eventi; | ||
} | ||
for (var prop in _.fns) { | ||
for (var i=0,m=texts.length; i<m; i++) { | ||
props = {}; | ||
_.parse(texts[i], props, props); | ||
props.alias = props.alias || props.type; | ||
context[prop][props.alias] = _.alias(props.alias, texts[i], context); | ||
} | ||
} | ||
return props; | ||
}; | ||
_.split.guard['<'] = '>'; | ||
@@ -344,9 +376,2 @@ _.parsers.unshift([/<(.+)>/, function(event, handler, selector) { | ||
_.parsers.unshift([/=>(\w+)$/, function(event, handler, alias) { | ||
handler.alias = alias; | ||
if (handler !== event) { | ||
handler.data = handler.data || []; | ||
handler.data.push(alias); | ||
} | ||
}]); | ||
if (document) { | ||
@@ -451,54 +476,2 @@ _.init = function init() { | ||
// add singleton to _.parse's supported event properties | ||
_.parsers.unshift([/^(\W*)\^/, function(event, handler, other) { | ||
handler.singleton = true; | ||
if (event !== handler) { | ||
_.filter(handler, _.before); | ||
} | ||
return other; | ||
}]); | ||
// _.fire's _.dispatch will call this when appropriate | ||
_.singleton = function(target, event) { | ||
_.remember(target, event); | ||
if (event.bubbles && !event.propagationStopped && target !== _.global) { | ||
_.singleton(target.parentNode || target.parentObject || _.global, event); | ||
} | ||
}; | ||
var _skey = _._skey = '^'+_key; | ||
_.remember = function remember(target, event) { | ||
var saved = target[_skey] || []; | ||
if (!saved.length) { | ||
Object.defineProperty(target, _skey, {value:saved,configurable:true}); | ||
} | ||
event[_skey] = true; | ||
saved.push(event); | ||
}; | ||
_.before = function singleton(event, handler) { | ||
_.unhandle(handler); | ||
handler.fn = _.noop;// tell _.handler not to keep this | ||
if (!event[_skey]) {// remember this non-singleton as singleton for handler's sake | ||
_.remember(this.target, event); | ||
} | ||
}; | ||
Eventi.on(_, 'on:handler', function singleton(e, handler) { | ||
if (handler.singleton) { | ||
// search target's saved singletons, execute handler upon match | ||
var saved = handler.target[_skey]||[]; | ||
for (var i=0,m=saved.length; i<m; i++) { | ||
var event = saved[i]; | ||
if (_.matches(event, handler.event)) { | ||
_.execute(event, handler); | ||
break; | ||
} | ||
} | ||
} | ||
}); | ||
if (document) { | ||
Eventi.on('DOMContentLoaded', function ready(e) { | ||
Eventi.fire(document.documentElement, '^ready', e); | ||
}); | ||
} | ||
_.split.guard['['] = ']'; | ||
@@ -677,3 +650,55 @@ _.parsers.push([/\[([^ ]+)\]/, function(event, handler, key) {//' | ||
}; | ||
Eventi.off = _.wrap('off', 3); | ||
_.fn('off', 3); | ||
// add singleton to _.parse's supported event properties | ||
_.parsers.unshift([/^(\W*)\^/, function(event, handler, other) { | ||
handler.singleton = true; | ||
if (event !== handler) { | ||
_.filter(handler, _.before); | ||
} | ||
return other; | ||
}]); | ||
// _.fire's _.dispatch will call this when appropriate | ||
_.singleton = function(target, event) { | ||
_.remember(target, event); | ||
if (event.bubbles && !event.propagationStopped && target !== _.global) { | ||
_.singleton(target.parentNode || target.parentObject || _.global, event); | ||
} | ||
}; | ||
var _skey = _._skey = '^'+_key; | ||
_.remember = function remember(target, event) { | ||
var saved = target[_skey] || []; | ||
if (!saved.length) { | ||
Object.defineProperty(target, _skey, {value:saved,configurable:true}); | ||
} | ||
event[_skey] = true; | ||
saved.push(event); | ||
}; | ||
_.before = function singleton(event, handler) { | ||
_.unhandle(handler); | ||
handler.fn = _.noop;// tell _.handler not to keep this | ||
if (!event[_skey]) {// remember this non-singleton as singleton for handler's sake | ||
_.remember(this.target, event); | ||
} | ||
}; | ||
Eventi.on(_, 'on:handler', function singleton(e, handler) { | ||
if (handler.singleton) { | ||
// search target's saved singletons, execute handler upon match | ||
var saved = handler.target[_skey]||[]; | ||
for (var i=0,m=saved.length; i<m; i++) { | ||
var event = saved[i]; | ||
if (_.matches(event, handler.event)) { | ||
_.execute(event, handler); | ||
break; | ||
} | ||
} | ||
} | ||
}); | ||
if (document) { | ||
Eventi.on('DOMContentLoaded', function ready(e) { | ||
Eventi.fire(document.documentElement, '^ready', e); | ||
}); | ||
} | ||
_.parsers.unshift([/\$(\!?\w+(\.\w+)*)/, function(event, handler, condition) { | ||
@@ -737,2 +762,22 @@ handler.endtest = condition; | ||
_.combo = { | ||
convert: function(handler, text, texts) { | ||
handler.event = _.combo.event(text); | ||
if (handler.data && typeof handler.data[0] === "number") { | ||
handler.timeout = handler.data.shift(); | ||
} | ||
delete handler.singleton; | ||
delete handler.selector; | ||
delete handler.location; | ||
delete handler.filters; | ||
delete handler.endtest; | ||
delete handler.end; | ||
// set up combo event handlers | ||
handler.texts = texts; | ||
handler.ordered = texts.ordered; | ||
handler.reset = _.combo.reset.bind(handler); | ||
handler.handlers = texts.map(function(text, index) { | ||
return _.handler(handler.target, text, _.combo.eventFn.bind(handler, index)); | ||
}); | ||
handler.reset(); | ||
}, | ||
event: function(text) { | ||
@@ -783,20 +828,3 @@ return _.combo[text] || (_.combo[text] = { | ||
if (texts.length > 1) { | ||
handler.event = _.combo.event(text); | ||
if (handler.data && typeof handler.data[0] === "number") { | ||
handler.timeout = handler.data.shift(); | ||
} | ||
delete handler.singleton; | ||
delete handler.selector; | ||
delete handler.location; | ||
delete handler.filters; | ||
delete handler.endtest; | ||
delete handler.end; | ||
// set up combo event handlers | ||
handler.texts = texts; | ||
handler.ordered = texts.ordered; | ||
handler.reset = _.combo.reset.bind(handler); | ||
handler.handlers = texts.map(function(text, index) { | ||
return _.handler(handler.target, text, _.combo.eventFn.bind(handler, index)); | ||
}); | ||
handler.reset(); | ||
_.combo.convert(handler, text, texts); | ||
} | ||
@@ -812,35 +840,3 @@ }).on(_, 'off:filter', function comboFilter(e, filter) { | ||
}); | ||
_.alias = function(alias, text, context) { | ||
return function aliased(target) { | ||
var args = _.slice(arguments), | ||
index = (typeof target !== "object" || !(target.dispatchEvent || target[_key])) ? 0 : 1; | ||
args.splice(index, 0, text); | ||
return this.apply(context, args); | ||
}; | ||
}; | ||
(Eventi.alias = function(context) { | ||
var texts = _.slice(arguments, 1), | ||
props; | ||
if (typeof context === "string") { | ||
texts.unshift(context); | ||
context = Eventi; | ||
} | ||
for (var prop in Eventi) { | ||
var fn = context[prop]; | ||
if (typeof fn === "function" && !fn.utility) { | ||
if (context !== Eventi && fn === Eventi[prop]) { | ||
// prevent shared aliases for different Eventi-fied objects | ||
fn = context[prop] = fn.bind(context); | ||
} | ||
for (var i=0,m=texts.length; i<m; i++) { | ||
props = {}; | ||
_.parse(texts[i], props, props); | ||
props.alias = props.alias || props.type; | ||
fn[props.alias] = _.alias(props.alias, texts[i], context); | ||
} | ||
} | ||
} | ||
return props; | ||
}).utility = true; | ||
_.version = "1.0.2"; | ||
_.version = "1.1.0"; | ||
@@ -847,0 +843,0 @@ var sP = (global.Event && Event.prototype.stopPropagation) || _.noop, |
@@ -1,4 +0,4 @@ | ||
/*! Eventi - v1.0.2 - 2014-04-09 | ||
* https://github.com/nbubna/Eventi | ||
/*! Eventi - v1.1.0 - 2014-04-17 | ||
* https://github.com/esha/Eventi | ||
* Copyright (c) 2014 ESHA Research; Licensed MIT */ | ||
!function(global,document){"use strict";function Eventi(){return _.create.apply(this,arguments)}try{new global.CustomEvent("test")}catch(err){global.CustomEvent=document?function(a,b){b=b||{};var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,!!b.bubbles,!!b.cancelable,b.detail),c}:function(a,b){b=b||{},this.type=a,this.bubbles=!!b.bubbles,this.detail=b.detail,this.timestamp=Date.now()},global.Event||(global.Event=global.CustomEvent)}var _={global:new Function("return this")(),noop:function(){},slice:function(a,b){return Array.prototype.slice.call(a,b)},copy:function(a,b,c){if("object"==typeof a)for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c])},async:global.setImmediate&&setImmediate.bind(global)||function(a){return setTimeout(a,0)},resolveRE:/^([\w\$]+)?((\.[\w\$]+)|\[(\d+|'(\\'|[^'])+'|"(\\"|[^"])+")\])*$/,resolve:function(reference,context,tested){if(tested||_.resolveRE.test(reference)){context=context||global;try{return eval("context"+("["!==reference.charAt(0)?"."+reference:reference))}catch(e){}}},create:function(a,b){var c={text:a+""};a=_.parse(c.text,c,c),_.copy(b,c),"bubbles"in c||(c.bubbles=!0);var d=new CustomEvent(a,c);for(var e in c)_.skip.indexOf(e)<0&&(d[_.prop(e)]=c[e]);return d},skip:"bubbles cancelable detail type".split(" "),prop:function(a){return a},parse:function(a,b,c){return _.parsers.forEach(function(d){a=a.replace(d[0],function(){var a=_.slice(arguments,1);return a.unshift(b,c),d[1].apply(b,a)||""})}),a?b.type=a:a},parsers:[[/^(\W*)_/,function(a,b,c){return a.bubbles=!1,c}],[/\((.*)\)/,function(a,b,c){try{a.detail=_.resolve(c)||JSON.parse(c)}catch(d){a.detail=c}}],[/#(\w+)/g,function(a,b,c){(a.tags||(a.tags=[])).push(c),a[c]=!0}],[/^(\w+):/,function(a,b,c){a.category=c}]],wrap:function(a,b){return function(c){var d=_.slice(arguments);(!c||"string"==typeof c||c instanceof global.Event)&&d.unshift(c=this&&this!==Eventi?this:_.global),d.length>b&&(d[b]=d.slice(b),d=d.slice(0,b+1)),d[1]&&"string"!=typeof d[1]||(d[1]=_.split.ter(d[1]));var e,f=_[a];if("length"in c&&c!==_.global)for(var g=0,h=c.length;h>g;g++)e=f.apply(d[0]=c[g],d);else e=f.apply(c,d);return void 0===e?this:e}},split:{guard:{"(":")"},ter:function(a,b){var c,d=[],e="";if(a){b=_.slice(arguments,1),b.unshift(" ");for(var f=0,g=a.length;g>f;f++){var h=a.charAt(f);!c&&b.indexOf(h)>=0?(e&&d.push(e),e=""):(e+=h,c?c===h&&("\\"===e.charAt(e.length-2)?e=e.replace("\\"+h,h):c=null):c=_.split.guard[h])}e&&d.push(e)}else d.push("");return d}}};(Eventi.toString=function(){return"Eventi"}).utility=!0,Eventi._=_,(Eventi.fy=function(a){for(var b in Eventi){var c=Eventi[b];"function"!=typeof c||c.utility||Object.defineProperty(a,b,{value:c,writable:!0,configurable:!0})}return a}).utility=!0,_.parsers.unshift([/^(\W*)\//,function(a,b,c){return b.global=!0,c}]),_.fire=function(a,b,c){return b instanceof Event?(b.data=c,_.dispatch(a,b),b):_.fireAll(a,b,{data:c})},_.fireAll=function(a,b,c){for(var d,e=0;e<b.length;e++)d=_.create(b[e],c),_.dispatch(a,d);return d},_.dispatch=function(a,b,c){b.global&&(a=_.global),(a.dispatchEvent||a[_key]||_.noop).call(a,b),a.parentObject&&b.bubbles&&!b.propagationStopped&&_.dispatch(a.parentObject,b,!0),!c&&b.singleton&&_.singleton(a,b)},Eventi.fire=_.wrap("fire",2),_.parsers.unshift([/^(\W*)\!/,function(a,b,c){return b.important=!0,c}]),_.on=function(a,b,c,d){if(Array.isArray(b))for(var e=0,f=b.length;f>e;e++)_.handler(a,b[e],c,d);else{void 0!==c&&(d=d?d.unshift(c)&&d:[c]);for(var g in b)_.handler(a,g,b[g],d)}},_.handler=function(a,b,c,d){var e={target:a,fn:c,data:d,text:b,event:{}};return _.parse(b,e.event,e),delete e.event.tags,a!==_&&Eventi.fire(_,"on:handler",e),e.fn!==_.noop&&(a=e.global===!0?_.global:e.target,_.handlers(a,e.event.type).push(e)),e},_.handlers=function(a,b){var c=_.listener(a),d=c.s[b];return d||(d=c.s[b]=[],a.addEventListener&&a.addEventListener(b,c)),d};var _key=_._key="_eventi"+Date.now();if(_.listener=function(a){var b=a[_key];return b||(b=function(a){var c=b.s[a.type];c&&_.handle(a,c)},b.s={},Object.defineProperty(a,_key,{value:b,writeable:!1,configurable:!0})),b},_.handle=function(a,b){for(var c,d=0;d<b.length&&(!_.matches(a,(c=b[d]).event)||(_.execute(a,c),!a.immediatePropagationStopped));d++);},_.execute=function(a,b){var c=[a],d=b.fn,e={target:b.target,args:c};if(a.data&&c.push.apply(c,a.data),b.data&&c.push.apply(c,b.data),b.filters)for(var f=0,g=b.filters.length;g>f&&e.target;f++)b.filters[f].call(e,a,b);if(e.target){try{d.apply(e.target,e.args)}catch(h){_.async(function(){throw h})}b.end&&b.end.apply(e.target,e.args)&&_.unhandle(b)}},_.filter=function(a,b){a.filters=a.filters||[],a.filters.push(b)},_.unhandle=function(a){a.fn=_.noop},_.matches=function(a,b){for(var c in b)if(b[c]!==a[c])return!1;return!0},Eventi.on=_.wrap("on",3),_.split.guard["<"]=">",_.parsers.unshift([/<(.+)>/,function(a,b,c){b.selector=c,_.delegate&&a!==b&&_.filter(b,_.delegate)}]),global.Element){_.delegate=function(a,b){this.target=_.closest(a.target,b.selector)},_.closest=function(a,b){for(;a&&a.matches;){if(a.matches(b))return a;a=a.parentNode}};var Ep=Element.prototype,aS="atchesSelector";Ep.matches||Object.defineProperty(Ep,"matches",{value:Ep["webkitM"+aS]||Ep["mozM"+aS]||Ep["msM"+aS]})}_.parsers.unshift([/=>(\w+)$/,function(a,b,c){b.alias=c,b!==a&&(b.data=b.data||[],b.data.push(c))}]),document&&(_.init=function(){for(var a=document.querySelectorAll("[data-eventi]"),b=0,c=a.length;c>b;b++){var d=a[b],e=d.getAttribute("data-eventi");e!==d.eventi&&(_.off&&d.eventi&&Eventi.off(d,d.eventi,_.declared),d.eventi=e,_.declare(d,e))}(a.length||document.querySelectorAll("[click]").length)&&Eventi.on("click keyup",_.check)},_.declare=function(a,b){for(var c=_.split.ter(b),d=0,e=c.length;e>d;d++)Eventi.on(a,c[d],_.declared)},_.declared=function(a,b){b="string"==typeof b?b:a.type;for(var c=_.declarers(this,b,a.target),d=0,e=c.length;e>d;d++)_.respond(c[d],b,a)},_.declarers=function(a,b,c){for(var d="["+b+"]",e=[],f=!1;c&&c.matches;){if(c.matches(d)&&e.push(c),c===a){f=!0;break}c=c.parentNode}return f?e:a.querySelectorAll(d)},_.respond=function(a,b,c){var d=a.getAttribute(b);if(d){var e=_.resolve(d,a)||_.resolve(d);"function"==typeof e?e.call(a,c):Eventi.fire(a,d,c)}},_.check=function(a){var b=a.target.getAttribute&&("click"===a.type&&_.click(a.target)||13===a.keyCode&&_.click(a.target,!0));b&&(_.declared.call(document.documentElement,a,"click"),"noDefault"!==b||_.allowDefault(a.target)||a.preventDefault())},_.allowDefault=function(a){return"radio"===a.type||"checkbox"===a.type},_.click=function(a,b){var c=a.getAttribute("click");if(c&&"false"!==c)return"noDefault";if(!a.isContentEditable){var d=a.nodeName.toLowerCase();return"textarea"!==d&&("select"!==d||b)&&(b?!("a"===d&&a.getAttribute("href")||"button"===d||"input"===d&&_.buttonRE.test(a.type)):"input"!==d||_.buttonRE.test(a.type))}},_.buttonRE=/^(submit|button|reset)$/,Eventi.on("DOMContentLoaded",_.init)),_.parsers.unshift([/^(\W*)\^/,function(a,b,c){return b.singleton=!0,a!==b&&_.filter(b,_.before),c}]),_.singleton=function(a,b){_.remember(a,b),b.bubbles&&!b.propagationStopped&&a!==_.global&&_.singleton(a.parentNode||a.parentObject||_.global,b)};var _skey=_._skey="^"+_key;_.remember=function(a,b){var c=a[_skey]||[];c.length||Object.defineProperty(a,_skey,{value:c,configurable:!0}),b[_skey]=!0,c.push(b)},_.before=function(a,b){_.unhandle(b),b.fn=_.noop,a[_skey]||_.remember(this.target,a)},Eventi.on(_,"on:handler",function(a,b){if(b.singleton)for(var c=b.target[_skey]||[],d=0,e=c.length;e>d;d++){var f=c[d];if(_.matches(f,b.event)){_.execute(f,b);break}}}),document&&Eventi.on("DOMContentLoaded",function(a){Eventi.fire(document.documentElement,"^ready",a)}),_.split.guard["["]="]",_.parsers.push([/\[([^ ]+)\]/,function(a,b,c){for(var d;(d=c.indexOf("-"))>0;)a[c.substring(0,d)+"Key"]=!0,c=c.substring(d+1);c&&(a.keyCode=_.codes[c]||parseInt(c,10)||c)}]),_.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,capsLock:20,escape:27,start:91,command:224,pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,"delete":46,multiply:106,plus:107,minus:109,point:110,divide:111,numLock:144,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222,space:32};for(var n=0;10>n;n++)_.codes["num"+n]=96+n;for(var f=1;13>f;f++)_.codes["f"+f]=111+f;if("abcdefghijklmnopqrstuvwxyz 0123456789".split("").forEach(function(a){_.codes[a]=a.toUpperCase().charCodeAt(0)}),_.split.guard["@"]="@",_.parsers.unshift([/@([^@]+)(@|$)/,function(a,b,c){b.location=c,_.location&&a!==b&&_.locationHandler(c,b)}]),global.history&&global.location){var current;_.pushState=history.pushState,history.pushState=function(){var a=_.pushState.apply(this,arguments);return _.dispatch(_.global,new CustomEvent("pushstate")),a},_.location=function(a,b){return b=b||decodeURI(location.pathname+location.search+location.hash),b!==current&&_.dispatch(_.global,new Eventi("location",{oldLocation:current,location:current=b,srcEvent:a})),current},_.setLocation=function(a,b,c){if("string"!=typeof b&&(c=b,b=a.location),b){var d=_.keys(b);d&&(b=d.reduce(function(a,b){return a.replace(new RegExp("\\{"+b+"\\}","g"),c[b]||location[b]||"")},b)),b!==current&&history.pushState(null,null,encodeURI(b))}},_.keys=function(a){var b=a.match(/\{\w+\}/g);return b&&b.map(function(a){return a.substring(1,a.length-1)})},_.locationHandler=function(a,b){var c=a;"`"===a.charAt(0)?c=c.substring(1,c.length-1):(c=c.replace(/([.*+?^=!:$(|\[\/\\])/g,"\\$1"),(b.keys=_.keys(c))?c=c.replace(/\{\w+\}/g,"([^/?#]+)"):c.replace(/\{/g,"\\{")),b.uriRE=new RegExp(c),_.filter(b,_.locationFilter)},_.locationFilter=function(a,b){var c=(a.location||current).match(b.uriRE);c?(this.args.splice.apply(this.args,[1,0].concat(c)),b.keys&&(this.args[1]=b.keys.reduce(function(a,b){return a[b]=c.shift(),a},{match:c.shift()}))):this.target=void 0},Eventi.on("!popstate !hashchange !pushstate",_.location).on("!location",_.setLocation).on(_,"on:handler",function(a,b){"location"===b.event.type&&(b.global=!0,current||_.location(),_.execute(new Eventi("location",{location:current,srcEvent:a}),b))})}_.off=function(a,b,c){var d=a[_key];if(d){for(var e=0,f=b.length;f>e;e++){var g={event:{},handler:{},fn:c,text:b[e]};if(_.parse(b[e],g.event,g.handler),delete g.event.tags,delete g.handler.filters,delete g.handler.end,a!==_&&Eventi.fire(_,"off:filter",g),g.event.type)_.clean(g.event.type,g,d,a);else for(var h in d.s)_.clean(h,g,d,a)}_.empty(d.s)&&delete a[_key]}},_.unhandle=function(a){_.off(a.target,[a.text],a.fn)},_.empty=function(a){for(var b in a)return!b;return!0},_.clean=function(a,b,c,d){var e=c.s[a];if(e){for(var f=0,g=e.length;g>f;f++)if(_.cleans(e[f],b)){var h=e.splice(f--,1)[0];d!==_&&Eventi.fire(_,"off:cleaned",h),g--}e.length||(d.removeEventListener&&d.removeEventListener(a,c),delete c.s[a])}},_.cleans=function(a,b){return _.matches(a.event,b.event)&&_.matches(a,b.handler)&&(!a.important||b.handler.important&&_.matches(b.event,a.event))&&(!b.fn||b.fn===a.fn)},Eventi.off=_.wrap("off",3),_.parsers.unshift([/\$(\!?\w+(\.\w+)*)/,function(a,b,c){b.endtest=c,b.end=_.endTest(c)}]),_.endTest=function(a){var b=parseInt(a,10);if(b)return function(){return!--b};var c="!"===a.charAt(0);return c&&(a=a.substring(1)),a&&_.resolveRE.test(a)?function(){var b=_.resolve(a,this,!0);return void 0===b&&(b=_.resolve(a,!0)),"function"==typeof b&&(b=b.apply(this,arguments)),c?!b:b}:void 0},_.fireAll=function(a,b,c,d){for(var e,f,g=0;g<b.length;g++){f=c.sequence=_.split.ter(b[g],"+",",");for(var h=d||0;h<f.length&&(!e||!e.isSequencePaused());h++)f[h]?(c.index=h,e=c.previousEvent=_.create(f[h],c),_.sequence(e,c,a),_.dispatch(a,e)):f.splice(h--,1)}return e},_.sequence=function(a,b,c,d){a.resumeSequence=function(a){d&&(d=!1,_.fireAll(c,[b.sequence.join(",")],b,a||b.index+1))},a.pauseSequence=function(a){return d!==!1?(d=!0,a&&a.then(this.resumeSequence)):void 0},a.isSequencePaused=function(){return!!d}},_.combo={event:function(a){return _.combo[a]||(_.combo[a]={category:"combo",type:"_"+ ++_.combo.count})},split:function(a){var b=_.split.ter(a,"+");return b.length>1?b.ordered=!1:(b=_.split.ter(a,","),b.length>1&&(b.ordered=!0)),b},count:0,reset:function(){this.clear&&clearTimeout(this.clear),this.unfired=this.texts.slice(),this.events=[]},eventFn:function(a,b){if(this.timeout&&!this.clear&&(this.clear=setTimeout(this.reset,this.timeout)),!(this.ordered&&a-1!==this.unfired.lastIndexOf("")||(this.unfired[a]="",this.events.push(b),this.unfired.join("")))){var c=new Eventi("combo:"+this.event.type);c.events=this.events,c.text=this.text,_.dispatch(this.target,c),this.reset()}}},Eventi.on(_,"on:handler",function(a,b){var c=b.text,d=_.combo.split(c);d.length>1&&(b.event=_.combo.event(c),b.data&&"number"==typeof b.data[0]&&(b.timeout=b.data.shift()),delete b.singleton,delete b.selector,delete b.location,delete b.filters,delete b.endtest,delete b.end,b.texts=d,b.ordered=d.ordered,b.reset=_.combo.reset.bind(b),b.handlers=d.map(function(a,c){return _.handler(b.target,a,_.combo.eventFn.bind(b,c))}),b.reset())}).on(_,"off:filter",function(a,b){_.combo.split(b.text).length>1&&(b.event=_.combo.event(b.text))}).on(_,"off:cleaned",function(a,b){b.handlers&&b.handlers.forEach(_.unhandle)}),_.alias=function(a,b,c){return function(a){var d=_.slice(arguments),e="object"!=typeof a||!a.dispatchEvent&&!a[_key]?0:1;return d.splice(e,0,b),this.apply(c,d)}},(Eventi.alias=function(a){var b,c=_.slice(arguments,1);"string"==typeof a&&(c.unshift(a),a=Eventi);for(var d in Eventi){var e=a[d];if("function"==typeof e&&!e.utility){a!==Eventi&&e===Eventi[d]&&(e=a[d]=e.bind(a));for(var f=0,g=c.length;g>f;f++)b={},_.parse(c[f],b,b),b.alias=b.alias||b.type,e[b.alias]=_.alias(b.alias,c[f],a)}}return b}).utility=!0,_.version="1.0.2";var sP=global.Event&&Event.prototype.stopPropagation||_.noop,sIP=global.Event&&Event.prototype.stopImmediatePropagation||_.noop;CustomEvent.prototype.stopPropagation=function(){this.propagationStopped=!0,sP.call(this)},CustomEvent.prototype.stopImmediatePropagation=function(){this.immediatePropagationStopped=!0,sIP.call(this)};var define=global.define||_.noop;define((global.exports||global).Eventi=Eventi)}(this,this.document); | ||
!function(global,document){"use strict";function Eventi(){return _.create.apply(this,arguments)}try{new global.CustomEvent("test")}catch(err){global.CustomEvent=document?function(a,b){b=b||{};var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,!!b.bubbles,!!b.cancelable,b.detail),c}:function(a,b){b=b||{},this.type=a,this.bubbles=!!b.bubbles,this.detail=b.detail,this.timestamp=Date.now()},global.Event||(global.Event=global.CustomEvent)}var _={global:new Function("return this")(),noop:function(){},slice:function(a,b){return Array.prototype.slice.call(a,b)},copy:function(a,b,c){if("object"==typeof a)for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c])},async:global.setImmediate&&setImmediate.bind(global)||function(a){return setTimeout(a,0)},resolveRE:/^([\w\$]+)?((\.[\w\$]+)|\[(\d+|'(\\'|[^'])+'|"(\\"|[^"])+")\])*$/,resolve:function(reference,context,tested){if(tested||_.resolveRE.test(reference)){context=context||global;try{return eval("context"+("["!==reference.charAt(0)?"."+reference:reference))}catch(e){}}},create:function(a,b){var c={text:a+""};a=_.parse(c.text,c,c),_.copy(b,c),"bubbles"in c||(c.bubbles=!0);var d=new CustomEvent(a,c);for(var e in c)_.skip.indexOf(e)<0&&(d[_.prop(e)]=c[e]);return d},skip:"bubbles cancelable detail type".split(" "),prop:function(a){return a},parse:function(a,b,c){return _.parsers.forEach(function(d){a=a.replace(d[0],function(){var a=_.slice(arguments,1);return a.unshift(b,c),d[1].apply(b,a)||""})}),a?b.type=a:a},parsers:[[/^(\W*)_/,function(a,b,c){return a.bubbles=!1,c}],[/\((.*)\)/,function(a,b,c){try{a.detail=_.resolve(c)||JSON.parse(c)}catch(d){a.detail=c}}],[/#(\w+)/g,function(a,b,c){(a.tags||(a.tags=[])).push(c),a[c]=!0}],[/^(\w+):/,function(a,b,c){a.category=c}]],fn:function(a,b){Eventi[a]=_.fns[a]=function(c){var d=_.slice(arguments);(!c||"string"==typeof c||c instanceof global.Event)&&d.unshift(c=this&&this!==Eventi?this:_.global),d.length>b&&(d[b]=d.slice(b),d=d.slice(0,b+1)),d[1]&&"string"!=typeof d[1]||(d[1]=_.split.ter(d[1]));var e,f=_[a];if("length"in c&&c!==_.global)for(var g=0,h=c.length;h>g;g++)e=f.apply(d[0]=c[g],d);else e=f.apply(c,d);return void 0===e?this:e}},fns:{},split:{guard:{"(":")"},ter:function(a,b){var c,d=[],e="";if(a){b=_.slice(arguments,1),b.unshift(" ");for(var f=0,g=a.length;g>f;f++){var h=a.charAt(f);!c&&b.indexOf(h)>=0?(e&&d.push(e),e=""):(e+=h,c?c===h&&("\\"===e.charAt(e.length-2)?e=e.replace("\\"+h,h):c=null):c=_.split.guard[h])}e&&d.push(e)}else d.push("");return d}}};Eventi.toString=function(){return"Eventi, v"+_.version},Eventi._=_,Eventi.fy=function(a){for(var b in _.fns)Object.defineProperty(a,b,{value:Eventi[b],writable:!0,configurable:!0});return a},_.parsers.unshift([/^(\W*)\//,function(a,b,c){return b.global=!0,c}]),_.fire=function(a,b,c){return b instanceof Event?(b.data=c,_.dispatch(a,b),b):_.fireAll(a,b,{data:c})},_.fireAll=function(a,b,c){for(var d,e=0;e<b.length;e++)d=_.create(b[e],c),_.dispatch(a,d);return d},_.dispatch=function(a,b,c){b.global&&(a=_.global),(a.dispatchEvent||a[_key]||_.noop).call(a,b),a.parentObject&&b.bubbles&&!b.propagationStopped&&_.dispatch(a.parentObject,b,!0),!c&&b.singleton&&_.singleton(a,b)},_.fn("fire",2),_.parsers.unshift([/^(\W*)\!/,function(a,b,c){return b.important=!0,c}]),_.on=function(a,b,c,d){if(a!==_.global&&1===b.length&&""===b[0]&&(b=a,a=_.global),Array.isArray(b))for(var e=0,f=b.length;f>e;e++)_.handler(a,b[e],c,d);else{void 0!==c&&(d=d?d.unshift(c)&&d:[c]);for(var g in b)_.handler(a,g,b[g],d)}},_.handler=function(a,b,c,d){var e={target:a,fn:c,data:d,text:b,event:{}};return _.parse(b,e.event,e),delete e.event.tags,a!==_&&Eventi.fire(_,"on:handler",e),e.fn!==_.noop&&(a=e.global===!0?_.global:e.target,_.handlers(a,e.event.type).push(e)),e},_.handlers=function(a,b){var c=_.listener(a),d=c.s[b];return d||(d=c.s[b]=[],a.addEventListener&&a.addEventListener(b,c)),d};var _key=_._key="_eventi"+Date.now();if(_.listener=function(a){var b=a[_key];return b||(b=function(a){var c=b.s[a.type];c&&_.handle(a,c)},b.s={},Object.defineProperty(a,_key,{value:b,writeable:!1,configurable:!0})),b},_.handle=function(a,b){for(var c,d=0;d<b.length&&(!_.matches(a,(c=b[d]).event)||(_.execute(a,c),!a.immediatePropagationStopped));d++);},_.execute=function(a,b){var c=[a],d=b.fn,e={target:b.target,args:c};if(a.data&&c.push.apply(c,a.data),b.data&&c.push.apply(c,b.data),b.filters)for(var f=0,g=b.filters.length;g>f&&e.target;f++)b.filters[f].call(e,a,b);if(e.target){try{d.apply(e.target,e.args)}catch(h){_.async(function(){throw h})}b.end&&b.end.apply(e.target,e.args)&&_.unhandle(b)}},_.filter=function(a,b){a.filters=a.filters||[],a.filters.push(b)},_.unhandle=function(a){a.fn=_.noop},_.matches=function(a,b){for(var c in b)if(b[c]!==a[c])return!1;return!0},_.fn("on",3),_.parsers.unshift([/=>(\w+)$/,function(a,b,c){b.alias=c,b!==a&&(b.data=b.data||[],b.data.push(c))}]),_.alias=function(a,b,c){return function(a){var d=_.slice(arguments),e="object"!=typeof a||!a.dispatchEvent&&!a[_key]?0:1;return d.splice(e,0,b),this.apply(c,d)}},Eventi.alias=function(a){var b,c=_.slice(arguments,1);"string"==typeof a&&(c.unshift(a),a=Eventi);for(var d in _.fns)for(var e=0,f=c.length;f>e;e++)b={},_.parse(c[e],b,b),b.alias=b.alias||b.type,a[d][b.alias]=_.alias(b.alias,c[e],a);return b},_.split.guard["<"]=">",_.parsers.unshift([/<(.+)>/,function(a,b,c){b.selector=c,_.delegate&&a!==b&&_.filter(b,_.delegate)}]),global.Element){_.delegate=function(a,b){this.target=_.closest(a.target,b.selector)},_.closest=function(a,b){for(;a&&a.matches;){if(a.matches(b))return a;a=a.parentNode}};var Ep=Element.prototype,aS="atchesSelector";Ep.matches||Object.defineProperty(Ep,"matches",{value:Ep["webkitM"+aS]||Ep["mozM"+aS]||Ep["msM"+aS]})}document&&(_.init=function(){for(var a=document.querySelectorAll("[data-eventi]"),b=0,c=a.length;c>b;b++){var d=a[b],e=d.getAttribute("data-eventi");e!==d.eventi&&(_.off&&d.eventi&&Eventi.off(d,d.eventi,_.declared),d.eventi=e,_.declare(d,e))}(a.length||document.querySelectorAll("[click]").length)&&Eventi.on("click keyup",_.check)},_.declare=function(a,b){for(var c=_.split.ter(b),d=0,e=c.length;e>d;d++)Eventi.on(a,c[d],_.declared)},_.declared=function(a,b){b="string"==typeof b?b:a.type;for(var c=_.declarers(this,b,a.target),d=0,e=c.length;e>d;d++)_.respond(c[d],b,a)},_.declarers=function(a,b,c){for(var d="["+b+"]",e=[],f=!1;c&&c.matches;){if(c.matches(d)&&e.push(c),c===a){f=!0;break}c=c.parentNode}return f?e:a.querySelectorAll(d)},_.respond=function(a,b,c){var d=a.getAttribute(b);if(d){var e=_.resolve(d,a)||_.resolve(d);"function"==typeof e?e.call(a,c):Eventi.fire(a,d,c)}},_.check=function(a){var b=a.target.getAttribute&&("click"===a.type&&_.click(a.target)||13===a.keyCode&&_.click(a.target,!0));b&&(_.declared.call(document.documentElement,a,"click"),"noDefault"!==b||_.allowDefault(a.target)||a.preventDefault())},_.allowDefault=function(a){return"radio"===a.type||"checkbox"===a.type},_.click=function(a,b){var c=a.getAttribute("click");if(c&&"false"!==c)return"noDefault";if(!a.isContentEditable){var d=a.nodeName.toLowerCase();return"textarea"!==d&&("select"!==d||b)&&(b?!("a"===d&&a.getAttribute("href")||"button"===d||"input"===d&&_.buttonRE.test(a.type)):"input"!==d||_.buttonRE.test(a.type))}},_.buttonRE=/^(submit|button|reset)$/,Eventi.on("DOMContentLoaded",_.init)),_.split.guard["["]="]",_.parsers.push([/\[([^ ]+)\]/,function(a,b,c){for(var d;(d=c.indexOf("-"))>0;)a[c.substring(0,d)+"Key"]=!0,c=c.substring(d+1);c&&(a.keyCode=_.codes[c]||parseInt(c,10)||c)}]),_.codes={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,capsLock:20,escape:27,start:91,command:224,pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,"delete":46,multiply:106,plus:107,minus:109,point:110,divide:111,numLock:144,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222,space:32};for(var n=0;10>n;n++)_.codes["num"+n]=96+n;for(var f=1;13>f;f++)_.codes["f"+f]=111+f;if("abcdefghijklmnopqrstuvwxyz 0123456789".split("").forEach(function(a){_.codes[a]=a.toUpperCase().charCodeAt(0)}),_.split.guard["@"]="@",_.parsers.unshift([/@([^@]+)(@|$)/,function(a,b,c){b.location=c,_.location&&a!==b&&_.locationHandler(c,b)}]),global.history&&global.location){var current;_.pushState=history.pushState,history.pushState=function(){var a=_.pushState.apply(this,arguments);return _.dispatch(_.global,new CustomEvent("pushstate")),a},_.location=function(a,b){return b=b||decodeURI(location.pathname+location.search+location.hash),b!==current&&_.dispatch(_.global,new Eventi("location",{oldLocation:current,location:current=b,srcEvent:a})),current},_.setLocation=function(a,b,c){if("string"!=typeof b&&(c=b,b=a.location),b){var d=_.keys(b);d&&(b=d.reduce(function(a,b){return a.replace(new RegExp("\\{"+b+"\\}","g"),c[b]||location[b]||"")},b)),b!==current&&history.pushState(null,null,encodeURI(b))}},_.keys=function(a){var b=a.match(/\{\w+\}/g);return b&&b.map(function(a){return a.substring(1,a.length-1)})},_.locationHandler=function(a,b){var c=a;"`"===a.charAt(0)?c=c.substring(1,c.length-1):(c=c.replace(/([.*+?^=!:$(|\[\/\\])/g,"\\$1"),(b.keys=_.keys(c))?c=c.replace(/\{\w+\}/g,"([^/?#]+)"):c.replace(/\{/g,"\\{")),b.uriRE=new RegExp(c),_.filter(b,_.locationFilter)},_.locationFilter=function(a,b){var c=(a.location||current).match(b.uriRE);c?(this.args.splice.apply(this.args,[1,0].concat(c)),b.keys&&(this.args[1]=b.keys.reduce(function(a,b){return a[b]=c.shift(),a},{match:c.shift()}))):this.target=void 0},Eventi.on("!popstate !hashchange !pushstate",_.location).on("!location",_.setLocation).on(_,"on:handler",function(a,b){"location"===b.event.type&&(b.global=!0,current||_.location(),_.execute(new Eventi("location",{location:current,srcEvent:a}),b))})}_.off=function(a,b,c){var d=a[_key];if(d){for(var e=0,f=b.length;f>e;e++){var g={event:{},handler:{},fn:c,text:b[e]};if(_.parse(b[e],g.event,g.handler),delete g.event.tags,delete g.handler.filters,delete g.handler.end,a!==_&&Eventi.fire(_,"off:filter",g),g.event.type)_.clean(g.event.type,g,d,a);else for(var h in d.s)_.clean(h,g,d,a)}_.empty(d.s)&&delete a[_key]}},_.unhandle=function(a){_.off(a.target,[a.text],a.fn)},_.empty=function(a){for(var b in a)return!b;return!0},_.clean=function(a,b,c,d){var e=c.s[a];if(e){for(var f=0,g=e.length;g>f;f++)if(_.cleans(e[f],b)){var h=e.splice(f--,1)[0];d!==_&&Eventi.fire(_,"off:cleaned",h),g--}e.length||(d.removeEventListener&&d.removeEventListener(a,c),delete c.s[a])}},_.cleans=function(a,b){return _.matches(a.event,b.event)&&_.matches(a,b.handler)&&(!a.important||b.handler.important&&_.matches(b.event,a.event))&&(!b.fn||b.fn===a.fn)},_.fn("off",3),_.parsers.unshift([/^(\W*)\^/,function(a,b,c){return b.singleton=!0,a!==b&&_.filter(b,_.before),c}]),_.singleton=function(a,b){_.remember(a,b),b.bubbles&&!b.propagationStopped&&a!==_.global&&_.singleton(a.parentNode||a.parentObject||_.global,b)};var _skey=_._skey="^"+_key;_.remember=function(a,b){var c=a[_skey]||[];c.length||Object.defineProperty(a,_skey,{value:c,configurable:!0}),b[_skey]=!0,c.push(b)},_.before=function(a,b){_.unhandle(b),b.fn=_.noop,a[_skey]||_.remember(this.target,a)},Eventi.on(_,"on:handler",function(a,b){if(b.singleton)for(var c=b.target[_skey]||[],d=0,e=c.length;e>d;d++){var f=c[d];if(_.matches(f,b.event)){_.execute(f,b);break}}}),document&&Eventi.on("DOMContentLoaded",function(a){Eventi.fire(document.documentElement,"^ready",a)}),_.parsers.unshift([/\$(\!?\w+(\.\w+)*)/,function(a,b,c){b.endtest=c,b.end=_.endTest(c)}]),_.endTest=function(a){var b=parseInt(a,10);if(b)return function(){return!--b};var c="!"===a.charAt(0);return c&&(a=a.substring(1)),a&&_.resolveRE.test(a)?function(){var b=_.resolve(a,this,!0);return void 0===b&&(b=_.resolve(a,!0)),"function"==typeof b&&(b=b.apply(this,arguments)),c?!b:b}:void 0},_.fireAll=function(a,b,c,d){for(var e,f,g=0;g<b.length;g++){f=c.sequence=_.split.ter(b[g],"+",",");for(var h=d||0;h<f.length&&(!e||!e.isSequencePaused());h++)f[h]?(c.index=h,e=c.previousEvent=_.create(f[h],c),_.sequence(e,c,a),_.dispatch(a,e)):f.splice(h--,1)}return e},_.sequence=function(a,b,c,d){a.resumeSequence=function(a){d&&(d=!1,_.fireAll(c,[b.sequence.join(",")],b,a||b.index+1))},a.pauseSequence=function(a){return d!==!1?(d=!0,a&&a.then(this.resumeSequence)):void 0},a.isSequencePaused=function(){return!!d}},_.combo={convert:function(a,b,c){a.event=_.combo.event(b),a.data&&"number"==typeof a.data[0]&&(a.timeout=a.data.shift()),delete a.singleton,delete a.selector,delete a.location,delete a.filters,delete a.endtest,delete a.end,a.texts=c,a.ordered=c.ordered,a.reset=_.combo.reset.bind(a),a.handlers=c.map(function(b,c){return _.handler(a.target,b,_.combo.eventFn.bind(a,c))}),a.reset()},event:function(a){return _.combo[a]||(_.combo[a]={category:"combo",type:"_"+ ++_.combo.count})},split:function(a){var b=_.split.ter(a,"+");return b.length>1?b.ordered=!1:(b=_.split.ter(a,","),b.length>1&&(b.ordered=!0)),b},count:0,reset:function(){this.clear&&clearTimeout(this.clear),this.unfired=this.texts.slice(),this.events=[]},eventFn:function(a,b){if(this.timeout&&!this.clear&&(this.clear=setTimeout(this.reset,this.timeout)),!(this.ordered&&a-1!==this.unfired.lastIndexOf("")||(this.unfired[a]="",this.events.push(b),this.unfired.join("")))){var c=new Eventi("combo:"+this.event.type);c.events=this.events,c.text=this.text,_.dispatch(this.target,c),this.reset()}}},Eventi.on(_,"on:handler",function(a,b){var c=b.text,d=_.combo.split(c);d.length>1&&_.combo.convert(b,c,d)}).on(_,"off:filter",function(a,b){_.combo.split(b.text).length>1&&(b.event=_.combo.event(b.text))}).on(_,"off:cleaned",function(a,b){b.handlers&&b.handlers.forEach(_.unhandle)}),_.version="1.1.0";var sP=global.Event&&Event.prototype.stopPropagation||_.noop,sIP=global.Event&&Event.prototype.stopImmediatePropagation||_.noop;CustomEvent.prototype.stopPropagation=function(){this.propagationStopped=!0,sP.call(this)},CustomEvent.prototype.stopImmediatePropagation=function(){this.immediatePropagationStopped=!0,sIP.call(this)};var define=global.define||_.noop;define((global.exports||global).Eventi=Eventi)}(this,this.document); |
@@ -23,15 +23,11 @@ module.exports = function(grunt) { | ||
dest: 'dist/<%= pkg.name %>.js', | ||
src: ['src/core.js','src/fire.js','src/on.js', | ||
'src/delegate.js', 'src/declare.js', 'src/singleton.js', 'src/key.js', 'src/location.js', | ||
'src/off.js', 'src/end.js', 'src/sequence.js', 'src/combo.js', 'src/alias.js'] | ||
src: ['src/core.js','src/fire.js','src/on.js', 'src/alias.js', | ||
'src/delegate.js', 'src/declare.js', 'src/key.js', 'src/location.js', | ||
'src/off.js', 'src/singleton.js', 'src/end.js', 'src/sequence.js', 'src/combo.js'] | ||
}, | ||
tall: { | ||
dest: 'dist/<%= pkg.name %>.tall.js', | ||
src: ['src/core.js','src/fire.js','src/on.js'] | ||
server: { | ||
dest: 'dist/<%= pkg.name %>.server.js', | ||
src: ['src/core.js','src/fire.js','src/on.js', 'src/alias.js', | ||
'src/off.js', 'src/singleton.js', 'src/end.js', 'src/sequence.js', 'src/combo.js'] | ||
}, | ||
grande: { | ||
dest: 'dist/<%= pkg.name %>.grande.js', | ||
src: ['src/core.js','src/fire.js','src/on.js', | ||
'src/delegate.js', 'src/declare.js', 'src/singleton.js','src/key.js', 'src/location.js'] | ||
}, | ||
}, | ||
@@ -46,10 +42,6 @@ uglify: { | ||
}, | ||
tall: { | ||
src: 'dist/<%= pkg.name %>.tall.js', | ||
dest: 'dist/<%= pkg.name %>.tall.min.js' | ||
server: { | ||
src: 'dist/<%= pkg.name %>.server.js', | ||
dest: 'dist/<%= pkg.name %>.server.min.js' | ||
}, | ||
grande: { | ||
src: 'dist/<%= pkg.name %>.grande.js', | ||
dest: 'dist/<%= pkg.name %>.grande.min.js' | ||
}, | ||
debug: { | ||
@@ -68,10 +60,6 @@ src: 'src/debug.js', | ||
}, | ||
tall: { | ||
src: ['dist/<%= pkg.name %>.tall.min.js'], | ||
dest: 'dist/<%= pkg.name %>.tall.min.js' | ||
server: { | ||
src: ['dist/<%= pkg.name %>.server.min.js'], | ||
dest: 'dist/<%= pkg.name %>.server.min.js' | ||
}, | ||
grande: { | ||
src: ['dist/<%= pkg.name %>.grande.min.js'], | ||
dest: 'dist/<%= pkg.name %>.grande.min.js' | ||
}, | ||
}, | ||
@@ -78,0 +66,0 @@ qunit: { |
{ | ||
"name": "eventi", | ||
"title": "Eventi", | ||
"version": "1.0.2", | ||
"homepage": "https://github.com/nbubna/Eventi", | ||
"version": "1.1.0", | ||
"homepage": "https://github.com/esha/Eventi", | ||
"author": { | ||
@@ -12,6 +12,6 @@ "name": "ESHA Research", | ||
"type": "git", | ||
"url": "git://github.com/nbubna/Eventi.git" | ||
"url": "git://github.com/esha/Eventi.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/nbubna/Eventi/issues" | ||
"url": "https://github.com/esha/Eventi/issues" | ||
}, | ||
@@ -21,3 +21,3 @@ "licenses": [ | ||
"type": "MIT", | ||
"url": "https://github.com/nbubna/Eventi/blob/master/LICENSE-MIT" | ||
"url": "https://github.com/esha/Eventi/blob/master/LICENSE-MIT" | ||
} | ||
@@ -24,0 +24,0 @@ ], |
@@ -11,5 +11,5 @@ # Eventi | ||
[min]: https://raw.github.com/nbubna/Eventi/master/dist/Eventi.min.js | ||
[max]: https://raw.github.com/nbubna/Eventi/master/dist/Eventi.js | ||
[npm]: https://npmjs.org/package/Eventi | ||
[min]: https://raw.github.com/esha/Eventi/master/dist/Eventi.min.js | ||
[max]: https://raw.github.com/esha/Eventi/master/dist/Eventi.js | ||
[npm]: https://npmjs.org/package/eventi | ||
[bower]: http://bower.io/ | ||
@@ -20,4 +20,3 @@ [component]: http://component.io/ | ||
* JavaScript development is ultimately event-based development. | ||
* Application events (aka custom events) are usually under-used or poorly-used in webapps. | ||
* Application events (aka custom events) are usually under-used or poorly-used in applications. | ||
* Events are the best way to decouple modules and components without isolating them entirely. | ||
@@ -35,9 +34,6 @@ * DOM event bubbling, in particular, has much potential for meaningful event based interfaces. | ||
* Robust, error tolerant listener execution | ||
* Support for best-practices like "signals" (aka pre-defined types) and declarative event mapping | ||
* Support for best-practices like "signals" (aka aliases for complex types) and declarative event mapping | ||
* Lots of solid, maintainable test code | ||
* Impressive, interactive demo (ideas, anyone?) | ||
* Three versions (tall, grande, venti): tall is frame/core/fire/on, grande adds declare/singleton/key/location, venti adds off/until/combo/types | ||
* Venti is the default version to encourage much event-based awesomeness for everyone. | ||
* Grande includes basic webapp tools. | ||
* Tall could be enough for light server-side work. | ||
* Two versions (server and browser): server is frame/core/fire/on/alias/off/singleton/end/sequence/combo, browser adds delegate/declare/key/location | ||
@@ -152,5 +148,5 @@ ## Code Plans | ||
[v0.5.0]: https://github.com/nbubna/Eventi/tree/0.5.0 | ||
[v1.0.0]: https://github.com/nbubna/Eventi/tree/1.0.0 | ||
[v1.0.1]: https://github.com/nbubna/Eventi/tree/1.0.1 | ||
[v1.0.2]: https://github.com/nbubna/Eventi/tree/1.0.2 | ||
[v0.5.0]: https://github.com/esha/Eventi/tree/0.5.0 | ||
[v1.0.0]: https://github.com/esha/Eventi/tree/1.0.0 | ||
[v1.0.1]: https://github.com/esha/Eventi/tree/1.0.1 | ||
[v1.0.2]: https://github.com/esha/Eventi/tree/1.0.2 |
@@ -0,1 +1,8 @@ | ||
_.parsers.unshift([/=>(\w+)$/, function(event, handler, alias) { | ||
handler.alias = alias; | ||
if (handler !== event) { | ||
handler.data = handler.data || []; | ||
handler.data.push(alias); | ||
} | ||
}]); | ||
_.alias = function(alias, text, context) { | ||
@@ -9,3 +16,3 @@ return function aliased(target) { | ||
}; | ||
(Eventi.alias = function(context) { | ||
Eventi.alias = function(context) { | ||
var texts = _.slice(arguments, 1), | ||
@@ -17,18 +24,11 @@ props; | ||
} | ||
for (var prop in Eventi) { | ||
var fn = context[prop]; | ||
if (typeof fn === "function" && !fn.utility) { | ||
if (context !== Eventi && fn === Eventi[prop]) { | ||
// prevent shared aliases for different Eventi-fied objects | ||
fn = context[prop] = fn.bind(context); | ||
} | ||
for (var i=0,m=texts.length; i<m; i++) { | ||
props = {}; | ||
_.parse(texts[i], props, props); | ||
props.alias = props.alias || props.type; | ||
fn[props.alias] = _.alias(props.alias, texts[i], context); | ||
} | ||
for (var prop in _.fns) { | ||
for (var i=0,m=texts.length; i<m; i++) { | ||
props = {}; | ||
_.parse(texts[i], props, props); | ||
props.alias = props.alias || props.type; | ||
context[prop][props.alias] = _.alias(props.alias, texts[i], context); | ||
} | ||
} | ||
return props; | ||
}).utility = true; | ||
}; |
_.combo = { | ||
convert: function(handler, text, texts) { | ||
handler.event = _.combo.event(text); | ||
if (handler.data && typeof handler.data[0] === "number") { | ||
handler.timeout = handler.data.shift(); | ||
} | ||
delete handler.singleton; | ||
delete handler.selector; | ||
delete handler.location; | ||
delete handler.filters; | ||
delete handler.endtest; | ||
delete handler.end; | ||
// set up combo event handlers | ||
handler.texts = texts; | ||
handler.ordered = texts.ordered; | ||
handler.reset = _.combo.reset.bind(handler); | ||
handler.handlers = texts.map(function(text, index) { | ||
return _.handler(handler.target, text, _.combo.eventFn.bind(handler, index)); | ||
}); | ||
handler.reset(); | ||
}, | ||
event: function(text) { | ||
@@ -47,20 +67,3 @@ return _.combo[text] || (_.combo[text] = { | ||
if (texts.length > 1) { | ||
handler.event = _.combo.event(text); | ||
if (handler.data && typeof handler.data[0] === "number") { | ||
handler.timeout = handler.data.shift(); | ||
} | ||
delete handler.singleton; | ||
delete handler.selector; | ||
delete handler.location; | ||
delete handler.filters; | ||
delete handler.endtest; | ||
delete handler.end; | ||
// set up combo event handlers | ||
handler.texts = texts; | ||
handler.ordered = texts.ordered; | ||
handler.reset = _.combo.reset.bind(handler); | ||
handler.handlers = texts.map(function(text, index) { | ||
return _.handler(handler.target, text, _.combo.eventFn.bind(handler, index)); | ||
}); | ||
handler.reset(); | ||
_.combo.convert(handler, text, texts); | ||
} | ||
@@ -67,0 +70,0 @@ }).on(_, 'off:filter', function comboFilter(e, filter) { |
@@ -40,7 +40,7 @@ function Eventi(){ return _.create.apply(this, arguments); } | ||
parse: function(type, event, handler) { | ||
_.parsers.forEach(function(property) { | ||
type = type.replace(property[0], function() { | ||
_.parsers.forEach(function(parser) { | ||
type = type.replace(parser[0], function() { | ||
var args = _.slice(arguments, 1); | ||
args.unshift(event, handler); | ||
return property[1].apply(event, args) || ''; | ||
return parser[1].apply(event, args) || ''; | ||
}); | ||
@@ -71,4 +71,4 @@ }); | ||
wrap: function(name, dataIndex) { | ||
return function wrapper(target) { | ||
fn: function(name, dataIndex) { | ||
Eventi[name] = _.fns[name] = function wrapper(target) { | ||
var args = _.slice(arguments); | ||
@@ -96,2 +96,3 @@ if (!target || typeof target === "string" || target instanceof global.Event) {// ensure target | ||
}, | ||
fns: {}, | ||
split: { | ||
@@ -138,12 +139,9 @@ guard: { '(':')' }, | ||
}; | ||
(Eventi.toString = function(){ return 'Eventi'; }).utility = true; | ||
Eventi.toString = function(){ return 'Eventi, v'+_.version; }; | ||
Eventi._ = _; | ||
(Eventi.fy = function fy(o) { | ||
for (var p in Eventi) { | ||
var fn = Eventi[p]; | ||
if (typeof fn === "function" && !fn.utility) { | ||
Object.defineProperty(o, p, {value:fn, writable:true, configurable:true}); | ||
} | ||
Eventi.fy = function fy(o) { | ||
for (var p in _.fns) { | ||
Object.defineProperty(o, p, {value:Eventi[p], writable:true, configurable:true}); | ||
} | ||
return o; | ||
}).utility = true; | ||
}; |
@@ -65,5 +65,5 @@ (function() { | ||
}; | ||
Eventi.debug = _.wrap('debug', 3); | ||
_.fn('debug', 3); | ||
out('Eventi, version '+_.version); | ||
Eventi.debug();// show global handlers automatically | ||
})(); |
@@ -1,8 +0,1 @@ | ||
_.parsers.unshift([/=>(\w+)$/, function(event, handler, alias) { | ||
handler.alias = alias; | ||
if (handler !== event) { | ||
handler.data = handler.data || []; | ||
handler.data.push(alias); | ||
} | ||
}]); | ||
if (document) { | ||
@@ -9,0 +2,0 @@ _.init = function init() { |
@@ -32,2 +32,2 @@ _.parsers.unshift([/^(\W*)\//, function(event, handler, other) { | ||
}; | ||
Eventi.fire = _.wrap('fire', 2); | ||
_.fn('fire', 2); |
@@ -58,2 +58,2 @@ _.off = function(target, events, fn) { | ||
}; | ||
Eventi.off = _.wrap('off', 3); | ||
_.fn('off', 3); |
@@ -6,2 +6,5 @@ _.parsers.unshift([/^(\W*)\!/, function(e, handler, other) {// | ||
_.on = function(target, events, fn, data) { | ||
if (target !== _.global && events.length === 1 && events[0] === '') { | ||
events = target; target = _.global; | ||
} | ||
if (!Array.isArray(events)) { | ||
@@ -104,3 +107,2 @@ if (fn !== undefined) { | ||
}; | ||
Eventi.on = _.wrap('on', 3); | ||
_.fn('on', 3); |
@@ -36,10 +36,4 @@ (function() { | ||
Eventi.alias('type'); | ||
for (var p in Eventi) { | ||
if (typeof Eventi[p] === "function") { | ||
if (Eventi[p].utility) { | ||
equal(Eventi[p].type, undefined, "utilities should not get alias"); | ||
} else { | ||
equal(typeof Eventi[p].type, "function", "Eventi."+p+".type is a function"); | ||
} | ||
} | ||
for (var p in _.fns) { | ||
equal(typeof Eventi[p].type, "function", "Eventi."+p+".type is a function"); | ||
} | ||
@@ -49,12 +43,9 @@ }); | ||
test('Eventi.alias(Eventi.fy({}), "local", "signal") API additions', function() { | ||
expect(10); | ||
expect(7); | ||
var o = Eventi.fy({}); | ||
equal(o.fire.signal, undefined, 'should not have signal yet'); | ||
Eventi.alias(o, 'local', '/test:signal=>alias'); | ||
for (var p in Eventi) { | ||
if (typeof Eventi[p] === "function" && !Eventi[p].utility) { | ||
notEqual(o[p], Eventi[p], "should have bound Eventi function, not primary"); | ||
equal(typeof o[p].alias, "function", "should have alias alias"); | ||
ok(o[p].local, "should have local alias"); | ||
} | ||
for (var p in _.fns) { | ||
equal(typeof o[p].alias, "function", "should have alias alias"); | ||
ok(o[p].local, "should have local alias"); | ||
} | ||
@@ -61,0 +52,0 @@ }); |
@@ -77,2 +77,6 @@ (function() { | ||
test('Eventi.toString()', function() { | ||
equal(Eventi+'', "Eventi, v"+_.version); | ||
}); | ||
test('internal api presence', function() { | ||
@@ -91,3 +95,6 @@ ok(typeof _ === "object", "Eventi._ should be present"); | ||
ok(_.parsers, "_.parsers"); | ||
ok(_.wrap, "_.wrap"); | ||
ok(_.fn, "_.fn"); | ||
equal(typeof _.version, "string", "_.version"); | ||
notEqual(_.version, "<%= pkg.version %>"); | ||
equal(typeof _.fns, "object", "_.fns"); | ||
equal(typeof _.split, "object", "_.split"); | ||
@@ -148,5 +155,5 @@ equal(typeof _.split.guard, "object", "_.split.guard"); | ||
test('_.wrap', function() { | ||
expect(14); | ||
_.fn = function(target, strings, data) { | ||
test('_.fn', function() { | ||
expect(16); | ||
_.test1 = function(target, strings, data) { | ||
ok(Array.isArray(strings), 'strings should be array (of strings)'); | ||
@@ -164,28 +171,38 @@ equal(typeof strings[0], 'string', 'strings should always have at least one string'); | ||
}; | ||
var api = _.wrap('fn', 2); | ||
notEqual(api, _.fn, 'should not return same fn'); | ||
api('global', 'data'); | ||
api([_.fn, api], 'multiple'); | ||
delete _.fn; | ||
_.fn('test1', 2); | ||
equal(typeof Eventi.test1, "function", "Eventi.test1 defined"); | ||
equal(Eventi.test1, _.fns.test1, 'should have reference in _.fns'); | ||
notEqual(Eventi.test1, _.test1, 'should not return same fn'); | ||
Eventi.test1('global', 'data'); | ||
Eventi.test1([_.fn, Eventi.test1], 'multiple'); | ||
delete _.test1; | ||
delete Eventi.test1; | ||
delete _.fns.test1; | ||
}); | ||
// ensure ordered iteration over targets | ||
test('_.wrap multiple target order', function() { | ||
test('_.fn multiple target order', function() { | ||
expect(2); | ||
var targets = ['a','b']; | ||
_.fn = function(target) { | ||
_.test2 = function(target) { | ||
equal(target, targets.shift(), 'should receive targets in correct order'); | ||
}; | ||
_.wrap('fn', 2)(targets.slice(0), 'orderTest'); | ||
delete _.fn; | ||
_.fn('test2', 2); | ||
Eventi.test2(targets.slice(0), 'orderTest'); | ||
delete _.test2; | ||
delete Eventi.test2; | ||
delete _.fns.test2; | ||
}); | ||
test('_.wrap falsey event text', function() { | ||
test('_.fn falsey event text', function() { | ||
expect(2); | ||
_.fn = function(target, strings) { | ||
_.test3 = function(target, strings) { | ||
equal(target, _.global, 'target should be _.global'); | ||
equal(strings[0], '', 'text should be ""'); | ||
}; | ||
_.wrap('fn', 2)(null); | ||
delete _.fn; | ||
_.fn('test3', 2); | ||
Eventi.test3(null); | ||
delete _.test3; | ||
delete _.fns.test3; | ||
delete Eventi.test3; | ||
}); | ||
@@ -192,0 +209,0 @@ |
@@ -60,2 +60,16 @@ (function() { | ||
test('Eventi.on({type:fn,other:fn1})', function() { | ||
expect(2); | ||
Eventi.on({ | ||
type: function(e) { | ||
equal(e.type, 'type'); | ||
}, | ||
'other$1': function(e) { | ||
equal(e.type, 'other'); | ||
} | ||
}); | ||
Eventi.fire('type other other'); | ||
Eventi.off('type'); | ||
}); | ||
test('Eventi.on(target, {type:fn,other:fn2})', function() { | ||
@@ -62,0 +76,0 @@ expect(3); |
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
2
294980
66
6701
149