types = types.type;
}
- // Handle multiple events seperated by a space
+ // Handle multiple events separated by a space
// jQuery(...).unbind("mouseover mouseout", fn);
types = types.split(/\s+/);
var i = 0;
var namespaces = type.split(".");
type = namespaces.shift();
var all = !namespaces.length,
- cleaned = jQuery.map( namespaces.slice(0).sort() , function(nm){ return nm.replace(/[^\w\s\.\|`]/g, function(ch){return "\\"+ch }) }),
+ cleaned = jQuery.map( namespaces.slice(0).sort() , function(nm){ return nm.replace(/[^\w\s\.\|`]/g, function(ch){return "\\"+ch; }); }),
namespace = new RegExp("(^|\\.)" + cleaned.join("\\.(?:.*\\.)?") + "(\\.|$)"),
special = this.special[ type ] || {};
}
}
+
+ return event.result;
},
props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
}
},
special: {}
+ },
+ beforeunload: {
+ setup: function( data, namespaces, fn ) {
+ // We only want to do this special case on windows
+ if ( this.setInterval ) {
+ this.onbeforeunload = fn;
+ }
+
+ return false;
+ },
+ teardown: function( namespaces, fn ) {
+ if ( this.onbeforeunload === fn ) {
+ this.onbeforeunload = null;
+ }
+ }
}
}
};
// Create mouseenter and mouseleave events
jQuery.each({
- mouseover: "mouseenter",
- mouseout: "mouseleave"
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
}, function( orig, fix ) {
- jQuery.event.special[ fix ] = {
+ jQuery.event.special[ orig ] = {
setup: function(data){
- jQuery.event.add( this, orig, data && data.selector ? delegate : withinElement, fix );
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
},
teardown: function(data){
- jQuery.event.remove( this, orig, data && data.selector ? delegate : withinElement );
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
}
};
});
}
// Create "bubbling" focus and blur events
-jQuery.each({
- focus: "focusin",
- blur: "focusout"
-}, function( orig, fix ){
- var event = jQuery.event,
- handle = event.handle;
-
- function ieHandler() {
- arguments[0].type = orig;
- return handle.apply(this, arguments);
- }
+if ( !jQuery.support.focusBubbles ) {
- event.special[orig] = {
- setup:function() {
- if ( this.addEventListener ) {
- this.addEventListener( orig, handle, true );
- } else {
- event.add( this, fix, ieHandler );
- }
+jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ){
+ event.special[ orig ] = {
+ setup: function() {
+ jQuery.event.add( this, fix, ieHandler );
},
- teardown:function() {
- if ( this.removeEventListener ) {
- this.removeEventListener( orig, handle, true );
- } else {
- event.remove( this, fix, ieHandler );
- }
+ teardown: function() {
+ jQuery.event.remove( this, fix, ieHandler );
}
};
+
+ function ieHandler() {
+ arguments[0].type = orig;
+ return jQuery.event.handle.apply(this, arguments);
+ }
});
+}
+
jQuery.fn.extend({
// TODO: make bind(), unbind() and one() DRY!
bind: function( type, data, fn, thisObject ) {