Comparing version 0.1.0 to 0.1.1
28
bean.js
@@ -79,3 +79,3 @@ /*! | ||
} | ||
var isNative = W3C_MODEL || nativeEvents.indexOf(type) > -1; | ||
var isNative = W3C_MODEL || ~nativeEvents.indexOf('|' + type + '|'); | ||
fn = isNative ? nativeHandler(element, fn, args) : customHandler(element, fn, type, false, args); | ||
@@ -107,3 +107,3 @@ if (type == 'unload') { | ||
type = customEvents[type] ? customEvents[type].base : type; | ||
var isNative = element[addEvent] || nativeEvents.indexOf(type) > -1; | ||
var isNative = W3C_MODEL || ~nativeEvents.indexOf('|' + type + '|'); | ||
listener(element, isNative ? type : 'propertychange', handler, false, !isNative && type); | ||
@@ -178,3 +178,3 @@ } | ||
type = types[i].replace(stripName, ''); | ||
var isNative = nativeEvents.indexOf(type) > -1, | ||
var isNative = ~nativeEvents.indexOf('|' + type + '|'), | ||
isNamespace = types[i].replace(namespace, ''), | ||
@@ -224,3 +224,3 @@ handlers = retrieveEvents(element)[type]; | ||
result.target = target && target.nodeType == 3 ? target.parentNode : target; | ||
if (type.indexOf('key') != -1) { | ||
if (~type.indexOf('key')) { | ||
result.keyCode = e.which || e.keyCode; | ||
@@ -268,12 +268,12 @@ } else if ((/click|mouse|menu/i).test(type)) { | ||
var nativeEvents = 'click,dblclick,mouseup,mousedown,contextmenu,' + //mouse buttons | ||
'mousewheel,DOMMouseScroll,' + //mouse wheel | ||
'mouseover,mouseout,mousemove,selectstart,selectend,' + //mouse movement | ||
'keydown,keypress,keyup,' + //keyboard | ||
'orientationchange,' + // mobile | ||
'touchstart,touchmove,touchend,touchcancel,' + // touch | ||
'gesturestart,gesturechange,gestureend,' + // gesture | ||
'focus,blur,change,reset,select,submit,' + //form elements | ||
'load,unload,beforeunload,resize,move,DOMContentLoaded,readystatechange,' + //window | ||
'error,abort,scroll'.split(','); //misc | ||
var nativeEvents = '|click|dblclick|mouseup|mousedown|contextmenu|' + //mouse buttons | ||
'mousewheel|DOMMouseScroll|' + //mouse wheel | ||
'mouseover|mouseout|mousemove|selectstart|selectend|' + //mouse movement | ||
'keydown|keypress|keyup|' + //keyboard | ||
'orientationchange|' + // mobile | ||
'touchstart|touchmove|touchend|touchcancel|' + // touch | ||
'gesturestart|gesturechange|gestureend|' + // gesture | ||
'focus|blur|change|reset|select|submit|' + //form elements | ||
'load|unload|beforeunload|resize|move|DOMContentLoaded|readystatechange|' + //window | ||
'error|abort|scroll|'; //misc | ||
@@ -280,0 +280,0 @@ function check(event) { |
@@ -11,2 +11,2 @@ /*! | ||
*/ | ||
!function(a){function F(a){var b=a.relatedTarget;if(!b)return b==null;return b!=this&&b.prefix!="xul"&&!/document/.test(this.toString())&&!p(this,b)}var b=1,c={},d={},e=/over|out/,f=/[^\.]*(?=\..*)\.|.*/,g=/\..*/,h="addEventListener",i="attachEvent",j="removeEventListener",k="detachEvent",l=a.document||{},m=l.documentElement||{},n=m[h],o=n?h:i,p=function(a,b){var c=b.parentNode;while(c!=null){if(c==a)return!0;c=c.parentNode}},q=function(a,c){return a.__uid=c||a.__uid||b++},r=function(a){var b=q(a);return c[b]=c[b]||{}},s=n?function(a,b,c,d){a[d?h:j](b,c,!1)}:function(a,b,c,d,e){e&&d&&(a["_on"+e]=a["_on"+e]||0),a[d?i:k]("on"+b,c)},t=function(b,c,d){return function(e){e=D(e||((this.ownerDocument||this.document||this).parentWindow||a).event);return c.apply(b,[e].concat(d))}},u=function(a,b,c,d,e){return function(f){(d?d.call(this,f):f&&f.propertyName=="_on"+c||!f)&&b.apply(a,[f].concat(e))}},v=function(a,b,c,e){var h=b.replace(g,""),i=r(a),j=i[h]||(i[h]={}),k=q(c,b.replace(f,""));if(j[k])return a;var l=G[h];l&&(c=l.condition?u(a,c,h,l.condition):c,h=l.base||h);var m=n||E.indexOf(h)>-1;c=m?t(a,c,e):u(a,c,h,!1,e);if(h=="unload"){var p=c;c=function(){w(a,h,c)&&p()}}a[o]&&s(a,m?h:"propertychange",c,!0,!m&&h),j[k]=c,c.__uid=k;return h=="unload"?a:d[q(a)]=a},w=function(a,b,c){var d,e,i,j,k=r(a),l=b.replace(g,"");if(!k||!k[l])return a;e=b.replace(f,""),i=e?e.split("."):[c.__uid];for(j=i.length;j--;){d=i[j],c=k[l][d],delete k[l][d];if(a[o]){l=G[l]?G[l].base:l;var m=a[h]||E.indexOf(l)>-1;s(a,m?l:"propertychange",c,!1,!m&&l)}}return a},x=function(a,b,c){return function(d){var e=typeof a=="string"?c(a,this):a;for(var f=d.target;f&&f!=this;f=f.parentNode)for(var g=e.length;g--;)if(e[g]==f)return b.apply(f,arguments)}},y=function(a,b,c,d,e){if(typeof b=="object"&&!c)for(var f in b)b.hasOwnProperty(f)&&y(a,f,b[f]);else{var g=typeof c=="string",h=(g?c:b).split(" ");c=g?x(b,d,e):c;for(var i=h.length;i--;)v(a,h[i],c,Array.prototype.slice.call(arguments,g?4:3))}return a},z=function(a,b,c){var d,e,h,i=typeof b=="string",j=i&&b.replace(f,""),k=w,l=r(a);if(i&&/\s/.test(b)){b=b.split(" ");var m=b.length-1;while(z(a,b[m])&&m--);return a}h=i?b.replace(g,""):b;if(!l||i&&!l[h])return a;if(typeof c=="function")k(a,h,c);else if(j)k(a,b);else{k=h?k:z,e=i&&h,h=h?c||l[h]||h:l;for(d in h)h.hasOwnProperty(d)&&k(a,e||d,h[d])}return a},A=function(a,b){var c,d,e,h=b.split(" ");for(e=h.length;e--;){b=h[e].replace(g,"");var i=E.indexOf(b)>-1,j=h[e].replace(f,""),k=r(a)[b];if(j){j=j.split(".");for(d=j.length;d--;)k[j[d]]&&k[j[d]]()}else if(a[o])B(i,b,a);else for(d in k)k.hasOwnProperty(d)&&k[d]()}return a},B=n?function(b,c,d){evt=document.createEvent(b?"HTMLEvents":"UIEvents"),evt[b?"initEvent":"initUIEvent"](c,!0,!0,a,1),d.dispatchEvent(evt)}:function(a,b,c){a?c.fireEvent("on"+b,document.createEventObject()):c["_on"+b]++},C=function(a,b,c){var d=r(b),e,f;e=c?d[c]:d;for(f in e)e.hasOwnProperty(f)&&(c?y:C)(a,c||b,c?e[f]:f);return a},D=function(a){var b={};if(!a)return b;var c=a.type,d=a.target||a.srcElement;b.preventDefault=D.preventDefault(a),b.stopPropagation=D.stopPropagation(a),b.target=d&&d.nodeType==3?d.parentNode:d;if(c.indexOf("key")!=-1)b.keyCode=a.which||a.keyCode;else if(/click|mouse|menu/i.test(c)){b.rightClick=a.which==3||a.button==2,b.pos={x:0,y:0};if(a.pageX||a.pageY)b.clientX=a.pageX,b.clientY=a.pageY;else if(a.clientX||a.clientY)b.clientX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,b.clientY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop;e.test(c)&&(b.relatedTarget=a.relatedTarget||a[(c=="mouseover"?"from":"to")+"Element"])}for(var f in a)f in b||(b[f]=a[f]);return b};D.preventDefault=function(a){return function(){a.preventDefault?a.preventDefault():a.returnValue=!1}},D.stopPropagation=function(a){return function(){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}};var E="click,dblclick,mouseup,mousedown,contextmenu,mousewheel,DOMMouseScroll,mouseover,mouseout,mousemove,selectstart,selectend,keydown,keypress,keyup,orientationchange,touchstart,touchmove,touchend,touchcancel,gesturestart,gesturechange,gestureend,focus,blur,change,reset,select,submit,load,unload,beforeunload,resize,move,DOMContentLoaded,readystatechange,"+"error,abort,scroll".split(","),G={mouseenter:{base:"mouseover",condition:F},mouseleave:{base:"mouseout",condition:F},mousewheel:{base:/Firefox/.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel"}},H={add:y,remove:z,clone:C,fire:A},I=function(a){var b=z(a).__uid;b&&(delete d[b],delete c[b])};a[i]&&y(a,"unload",function(){for(var b in d)d.hasOwnProperty(b)&&I(d[b]);a.CollectGarbage&&CollectGarbage()});var J=a.bean;H.noConflict=function(){a.bean=J;return this},typeof module!="undefined"&&module.exports?module.exports=H:a.bean=H}(this) | ||
!function(a){function F(a){var b=a.relatedTarget;if(!b)return b==null;return b!=this&&b.prefix!="xul"&&!/document/.test(this.toString())&&!p(this,b)}var b=1,c={},d={},e=/over|out/,f=/[^\.]*(?=\..*)\.|.*/,g=/\..*/,h="addEventListener",i="attachEvent",j="removeEventListener",k="detachEvent",l=a.document||{},m=l.documentElement||{},n=m[h],o=n?h:i,p=function(a,b){var c=b.parentNode;while(c!=null){if(c==a)return!0;c=c.parentNode}},q=function(a,c){return a.__uid=c||a.__uid||b++},r=function(a){var b=q(a);return c[b]=c[b]||{}},s=n?function(a,b,c,d){a[d?h:j](b,c,!1)}:function(a,b,c,d,e){e&&d&&(a["_on"+e]=a["_on"+e]||0),a[d?i:k]("on"+b,c)},t=function(b,c,d){return function(e){e=D(e||((this.ownerDocument||this.document||this).parentWindow||a).event);return c.apply(b,[e].concat(d))}},u=function(a,b,c,d,e){return function(f){(d?d.call(this,f):f&&f.propertyName=="_on"+c||!f)&&b.apply(a,[f].concat(e))}},v=function(a,b,c,e){var h=b.replace(g,""),i=r(a),j=i[h]||(i[h]={}),k=q(c,b.replace(f,""));if(j[k])return a;var l=G[h];l&&(c=l.condition?u(a,c,h,l.condition):c,h=l.base||h);var m=n||~E.indexOf("|"+h+"|");c=m?t(a,c,e):u(a,c,h,!1,e);if(h=="unload"){var p=c;c=function(){w(a,h,c)&&p()}}a[o]&&s(a,m?h:"propertychange",c,!0,!m&&h),j[k]=c,c.__uid=k;return h=="unload"?a:d[q(a)]=a},w=function(a,b,c){var d,e,h,i,j=r(a),k=b.replace(g,"");if(!j||!j[k])return a;e=b.replace(f,""),h=e?e.split("."):[c.__uid];for(i=h.length;i--;){d=h[i],c=j[k][d],delete j[k][d];if(a[o]){k=G[k]?G[k].base:k;var l=n||~E.indexOf("|"+k+"|");s(a,l?k:"propertychange",c,!1,!l&&k)}}return a},x=function(a,b,c){return function(d){var e=typeof a=="string"?c(a,this):a;for(var f=d.target;f&&f!=this;f=f.parentNode)for(var g=e.length;g--;)if(e[g]==f)return b.apply(f,arguments)}},y=function(a,b,c,d,e){if(typeof b=="object"&&!c)for(var f in b)b.hasOwnProperty(f)&&y(a,f,b[f]);else{var g=typeof c=="string",h=(g?c:b).split(" ");c=g?x(b,d,e):c;for(var i=h.length;i--;)v(a,h[i],c,Array.prototype.slice.call(arguments,g?4:3))}return a},z=function(a,b,c){var d,e,h,i=typeof b=="string",j=i&&b.replace(f,""),k=w,l=r(a);if(i&&/\s/.test(b)){b=b.split(" ");var m=b.length-1;while(z(a,b[m])&&m--);return a}h=i?b.replace(g,""):b;if(!l||i&&!l[h])return a;if(typeof c=="function")k(a,h,c);else if(j)k(a,b);else{k=h?k:z,e=i&&h,h=h?c||l[h]||h:l;for(d in h)h.hasOwnProperty(d)&&k(a,e||d,h[d])}return a},A=function(a,b){var c,d,e,h=b.split(" ");for(e=h.length;e--;){b=h[e].replace(g,"");var i=~E.indexOf("|"+b+"|"),j=h[e].replace(f,""),k=r(a)[b];if(j){j=j.split(".");for(d=j.length;d--;)k[j[d]]&&k[j[d]]()}else if(a[o])B(i,b,a);else for(d in k)k.hasOwnProperty(d)&&k[d]()}return a},B=n?function(b,c,d){evt=document.createEvent(b?"HTMLEvents":"UIEvents"),evt[b?"initEvent":"initUIEvent"](c,!0,!0,a,1),d.dispatchEvent(evt)}:function(a,b,c){a?c.fireEvent("on"+b,document.createEventObject()):c["_on"+b]++},C=function(a,b,c){var d=r(b),e,f;e=c?d[c]:d;for(f in e)e.hasOwnProperty(f)&&(c?y:C)(a,c||b,c?e[f]:f);return a},D=function(a){var b={};if(!a)return b;var c=a.type,d=a.target||a.srcElement;b.preventDefault=D.preventDefault(a),b.stopPropagation=D.stopPropagation(a),b.target=d&&d.nodeType==3?d.parentNode:d;if(~c.indexOf("key"))b.keyCode=a.which||a.keyCode;else if(/click|mouse|menu/i.test(c)){b.rightClick=a.which==3||a.button==2,b.pos={x:0,y:0};if(a.pageX||a.pageY)b.clientX=a.pageX,b.clientY=a.pageY;else if(a.clientX||a.clientY)b.clientX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,b.clientY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop;e.test(c)&&(b.relatedTarget=a.relatedTarget||a[(c=="mouseover"?"from":"to")+"Element"])}for(var f in a)f in b||(b[f]=a[f]);return b};D.preventDefault=function(a){return function(){a.preventDefault?a.preventDefault():a.returnValue=!1}},D.stopPropagation=function(a){return function(){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}};var E="|click|dblclick|mouseup|mousedown|contextmenu|mousewheel|DOMMouseScroll|mouseover|mouseout|mousemove|selectstart|selectend|keydown|keypress|keyup|orientationchange|touchstart|touchmove|touchend|touchcancel|gesturestart|gesturechange|gestureend|focus|blur|change|reset|select|submit|load|unload|beforeunload|resize|move|DOMContentLoaded|readystatechange|error|abort|scroll|",G={mouseenter:{base:"mouseover",condition:F},mouseleave:{base:"mouseout",condition:F},mousewheel:{base:/Firefox/.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel"}},H={add:y,remove:z,clone:C,fire:A},I=function(a){var b=z(a).__uid;b&&(delete d[b],delete c[b])};a[i]&&y(a,"unload",function(){for(var b in d)d.hasOwnProperty(b)&&I(d[b]);a.CollectGarbage&&CollectGarbage()});var J=a.bean;H.noConflict=function(){a.bean=J;return this},typeof module!="undefined"&&module.exports?module.exports=H:a.bean=H}(this) |
{ | ||
"name": "bean", | ||
"description": "an events api for javascript", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/fat/bean", | ||
@@ -6,0 +6,0 @@ "authors": ["Jacob Thornton <@fat>"], |
@@ -69,3 +69,3 @@ !function (context) { | ||
} | ||
var isNative = W3C_MODEL || nativeEvents.indexOf(type) > -1; | ||
var isNative = W3C_MODEL || ~nativeEvents.indexOf('|' + type + '|'); | ||
fn = isNative ? nativeHandler(element, fn, args) : customHandler(element, fn, type, false, args); | ||
@@ -97,3 +97,3 @@ if (type == 'unload') { | ||
type = customEvents[type] ? customEvents[type].base : type; | ||
var isNative = element[addEvent] || nativeEvents.indexOf(type) > -1; | ||
var isNative = W3C_MODEL || ~nativeEvents.indexOf('|' + type + '|'); | ||
listener(element, isNative ? type : 'propertychange', handler, false, !isNative && type); | ||
@@ -168,3 +168,3 @@ } | ||
type = types[i].replace(stripName, ''); | ||
var isNative = nativeEvents.indexOf(type) > -1, | ||
var isNative = ~nativeEvents.indexOf('|' + type + '|'), | ||
isNamespace = types[i].replace(namespace, ''), | ||
@@ -214,3 +214,3 @@ handlers = retrieveEvents(element)[type]; | ||
result.target = target && target.nodeType == 3 ? target.parentNode : target; | ||
if (type.indexOf('key') != -1) { | ||
if (~type.indexOf('key')) { | ||
result.keyCode = e.which || e.keyCode; | ||
@@ -258,12 +258,12 @@ } else if ((/click|mouse|menu/i).test(type)) { | ||
var nativeEvents = 'click,dblclick,mouseup,mousedown,contextmenu,' + //mouse buttons | ||
'mousewheel,DOMMouseScroll,' + //mouse wheel | ||
'mouseover,mouseout,mousemove,selectstart,selectend,' + //mouse movement | ||
'keydown,keypress,keyup,' + //keyboard | ||
'orientationchange,' + // mobile | ||
'touchstart,touchmove,touchend,touchcancel,' + // touch | ||
'gesturestart,gesturechange,gestureend,' + // gesture | ||
'focus,blur,change,reset,select,submit,' + //form elements | ||
'load,unload,beforeunload,resize,move,DOMContentLoaded,readystatechange,' + //window | ||
'error,abort,scroll'.split(','); //misc | ||
var nativeEvents = '|click|dblclick|mouseup|mousedown|contextmenu|' + //mouse buttons | ||
'mousewheel|DOMMouseScroll|' + //mouse wheel | ||
'mouseover|mouseout|mousemove|selectstart|selectend|' + //mouse movement | ||
'keydown|keypress|keyup|' + //keyboard | ||
'orientationchange|' + // mobile | ||
'touchstart|touchmove|touchend|touchcancel|' + // touch | ||
'gesturestart|gesturechange|gestureend|' + // gesture | ||
'focus|blur|change|reset|select|submit|' + //form elements | ||
'load|unload|beforeunload|resize|move|DOMContentLoaded|readystatechange|' + //window | ||
'error|abort|scroll|'; //misc | ||
@@ -270,0 +270,0 @@ function check(event) { |
644892