diff --git a/bean.js b/bean.js index a929315..6fc8e00 100644 --- a/bean.js +++ b/bean.js @@ -27,6 +27,7 @@ , W3C_MODEL = root[addEvent] , eventSupport = W3C_MODEL ? addEvent : attachEvent , slice = Array.prototype.slice + , mouseTypeRegex = /click|mouse|menu|drag|drop/i , ONE = { one: 1 } // singleton for quick matching making add() do one() , nativeEvents = (function (hash, events, i) { @@ -137,7 +138,7 @@ if (type.indexOf('key') !== -1) { props = keyProps result.keyCode = event.which || event.keyCode - } else if ((/click|mouse|menu|drag|drop/i).test(type)) { + } else if (mouseTypeRegex.test(type)) { props = mouseProps result.rightClick = event.which === 3 || event.button === 2 result.pos = { x: 0, y: 0 } @@ -217,7 +218,7 @@ if (!type || type === '*') { // search the whole registry for (var t in map) { - if (t[0] === '$') + if (t.charAt(0) === '$') forAll(element, t.substr(1), original, handler, fn) } } else { @@ -269,7 +270,7 @@ , entries = function () { var t, entries = [] for (t in map) { - if (t[0] === '$') + if (t.charAt(0) === '$') entries = entries.concat(map[t]) } return entries diff --git a/bean.min.js b/bean.min.js index e20f91c..f25c7d9 100644 --- a/bean.min.js +++ b/bean.min.js @@ -7,4 +7,4 @@ * dperini: https://github.com/dperini/nwevents * the entire mootools team: github.com/mootools/mootools-core *//*global module:true, define:true*/ -!function(a,b,c){typeof module!="undefined"?module.exports=c(a,b):typeof define=="function"&&typeof define.amd=="object"?define(c):b[a]=c(a,b)}("bean",this,function(a,b){var c=window,d=b[a],e=/over|out/,f=/[^\.]*(?=\..*)\.|.*/,g=/\..*/,h="addEventListener",i="attachEvent",j="removeEventListener",k="detachEvent",l=document||{},m=l.documentElement||{},n=m[h],o=n?h:i,p=Array.prototype.slice,q={one:1},r=function(a,b,c){for(c=0;c0){b=b.split(" ");for(j=b.length;j--;)E(a,b[j],c);return a}h=l&&b.replace(g,""),h&&s[h]&&(h=s[h].type);if(!b||l){if(i=l&&b.replace(f,""))i=i.split(".");k(a,h,c,i)}else if(typeof b=="function")k(a,null,b);else for(d in b)b.hasOwnProperty(d)&&E(a,d,b[d]);return a},F=function(a,b,c,d,e){var f,g,h,i,j=c,k=c&&typeof c=="string";if(b&&!c&&typeof b=="object")for(f in b)b.hasOwnProperty(f)&&F.apply(this,[a,f,b[f]]);else{i=arguments.length>3?p.call(arguments,3):[],g=(k?c:b).split(" "),k&&(c=D(b,j=d,e))&&(i=p.call(i,1)),this===q&&(c=A(E,a,b,c,j));for(h=g.length;h--;)C(a,g[h],c,j,i)}return a},G=function(){return F.apply(q,arguments)},H=n?function(a,b,d){var e=l.createEvent(a?"HTMLEvents":"UIEvents");e[a?"initEvent":"initUIEvent"](b,!0,!0,c,1),d.dispatchEvent(e)}:function(a,b,c){c=u(c,a),a?c.fireEvent("on"+b,l.createEventObject()):c["_on"+b]++},I=function(a,b,c){var d,e,h,i,j,k=b.split(" ");for(d=k.length;d--;){b=k[d].replace(g,"");if(i=k[d].replace(f,""))i=i.split(".");if(!i&&!c&&a[o])H(r[b],b,a);else{j=w.get(a,b),c=[!1].concat(c);for(e=0,h=j.length;e0){b=b.split(" ");for(j=b.length;j--;)F(a,b[j],c);return a}h=l&&b.replace(g,""),h&&t[h]&&(h=t[h].type);if(!b||l){if(i=l&&b.replace(f,""))i=i.split(".");k(a,h,c,i)}else if(typeof b=="function")k(a,null,b);else for(d in b)b.hasOwnProperty(d)&&F(a,d,b[d]);return a},G=function(a,b,c,d,e){var f,g,h,i,j=c,k=c&&typeof c=="string";if(b&&!c&&typeof b=="object")for(f in b)b.hasOwnProperty(f)&&G.apply(this,[a,f,b[f]]);else{i=arguments.length>3?p.call(arguments,3):[],g=(k?c:b).split(" "),k&&(c=E(b,j=d,e))&&(i=p.call(i,1)),this===r&&(c=B(F,a,b,c,j));for(h=g.length;h--;)D(a,g[h],c,j,i)}return a},H=function(){return G.apply(r,arguments)},I=n?function(a,b,d){var e=l.createEvent(a?"HTMLEvents":"UIEvents");e[a?"initEvent":"initUIEvent"](b,!0,!0,c,1),d.dispatchEvent(e)}:function(a,b,c){c=v(c,a),a?c.fireEvent("on"+b,l.createEventObject()):c["_on"+b]++},J=function(a,b,c){var d,e,h,i,j,k=b.split(" ");for(d=k.length;d--;){b=k[d].replace(g,"");if(i=k[d].replace(f,""))i=i.split(".");if(!i&&!c&&a[o])I(s[b],b,a);else{j=x.get(a,b),c=[!1].concat(c);for(e=0,h=j.length;e", "Dustin Diaz <@ded>", "Rod Vagg <@rvagg>"], "repository": { diff --git a/src/bean.js b/src/bean.js index 49a7be3..8d38241 100644 --- a/src/bean.js +++ b/src/bean.js @@ -18,6 +18,7 @@ , W3C_MODEL = root[addEvent] , eventSupport = W3C_MODEL ? addEvent : attachEvent , slice = Array.prototype.slice + , mouseTypeRegex = /click|mouse|menu|drag|drop/i , ONE = { one: 1 } // singleton for quick matching making add() do one() , nativeEvents = (function (hash, events, i) { @@ -128,7 +129,7 @@ if (type.indexOf('key') !== -1) { props = keyProps result.keyCode = event.which || event.keyCode - } else if ((/click|mouse|menu|drag|drop/i).test(type)) { + } else if (mouseTypeRegex.test(type)) { props = mouseProps result.rightClick = event.which === 3 || event.button === 2 result.pos = { x: 0, y: 0 } @@ -208,7 +209,7 @@ if (!type || type === '*') { // search the whole registry for (var t in map) { - if (t[0] === '$') + if (t.charAt(0) === '$') forAll(element, t.substr(1), original, handler, fn) } } else { @@ -260,7 +261,7 @@ , entries = function () { var t, entries = [] for (t in map) { - if (t[0] === '$') + if (t.charAt(0) === '$') entries = entries.concat(map[t]) } return entries