git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bumping the version up to 1.3.2pre.
[jquery.git]
/
src
/
event.js
diff --git
a/src/event.js
b/src/event.js
index
5097302
..
e707015
100644
(file)
--- a/
src/event.js
+++ b/
src/event.js
@@
-26,10
+26,7
@@
jQuery.event = {
var fn = handler;
// Create unique handler function, wrapped around original handler
var fn = handler;
// Create unique handler function, wrapped around original handler
- handler = this.proxy( fn, function() {
- // Pass arguments and context to original handler
- return fn.apply(this, arguments);
- });
+ handler = this.proxy( fn );
// Store data in unique handler
handler.data = data;
// Store data in unique handler
handler.data = data;
@@
-128,10
+125,10
@@
jQuery.event = {
// remove all handlers for the given type
else
// remove all handlers for the given type
else
- for ( handler in events[type] )
+ for ( var handle in events[type] )
// Handle the removal of namespaced events
// Handle the removal of namespaced events
- if ( namespace.test(events[type][handler].type) )
- delete events[type][handler];
+ if ( namespace.test(events[type][handle].type) )
+ delete events[type][handle];
if ( jQuery.event.specialAll[type] )
jQuery.event.specialAll[type].teardown.call(elem, namespaces);
if ( jQuery.event.specialAll[type] )
jQuery.event.specialAll[type].teardown.call(elem, namespaces);
@@
-229,13
+226,13
@@
jQuery.event = {
} catch (e) {}
}
} catch (e) {}
}
+ this.triggered = false;
+
if ( !event.isPropagationStopped() ) {
var parent = elem.parentNode || elem.ownerDocument;
if ( parent )
jQuery.event.trigger(event, data, parent, true);
}
if ( !event.isPropagationStopped() ) {
var parent = elem.parentNode || elem.ownerDocument;
if ( parent )
jQuery.event.trigger(event, data, parent, true);
}
-
- this.triggered = false;
},
handle: function(event) {
},
handle: function(event) {
@@
-334,6
+331,7
@@
jQuery.event = {
},
proxy: function( fn, proxy ){
},
proxy: function( fn, proxy ){
+ proxy = proxy || function(){ return fn.apply(this, arguments); };
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
// So proxy can be declared as an argument
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
// So proxy can be declared as an argument
@@
-362,7
+360,7
@@
jQuery.event = {
remove++;
});
remove++;
});
- if ( remove <= 1 )
+ if ( remove < 1 )
jQuery.event.remove( this, namespaces[0], liveHandler );
}
}
jQuery.event.remove( this, namespaces[0], liveHandler );
}
}
@@
-379,13
+377,13
@@
jQuery.Event = function( src ){
if( src && src.type ){
this.originalEvent = src;
this.type = src.type;
if( src && src.type ){
this.originalEvent = src;
this.type = src.type;
- this.timeStamp = src.timeStamp;
// Event type
}else
this.type = src;
// Event type
}else
this.type = src;
- if( !this.timeStamp )
- this.timeStamp = now();
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = now();
// Mark it as fixed
this[expando] = true;
// Mark it as fixed
this[expando] = true;
@@
-546,27
+544,42
@@
jQuery.fn.extend({
},
live: function( type, fn ){
},
live: function( type, fn ){
- jQuery(document).bind( liveConvert(type, this.selector), this.selector, fn );
+ var proxy = jQuery.event.proxy( fn );
+ proxy.guid += this.selector + type;
+
+ jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy );
+
return this;
},
die: function( type, fn ){
return this;
},
die: function( type, fn ){
- jQuery(document).unbind( liveConvert(type, this.selector), fn );
+ jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
return this;
}
});
function liveHandler( event ){
var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"),
return this;
}
});
function liveHandler( event ){
var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"),
- stop = true;
+ stop = true,
+ elems = [];
jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){
jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){
- if ( !event.isImmediatePropagationStopped() && check.test(fn.type) ) {
+ if ( check.test(fn.type) ) {
var elem = jQuery(event.target).closest(fn.data)[0];
var elem = jQuery(event.target).closest(fn.data)[0];
- if ( elem && fn.call(elem, event, fn.data) === false )
- stop = false;
+ if ( elem )
+ elems.push({ elem: elem, fn: fn });
}
});
}
});
+
+ elems.sort(function(a,b) {
+ return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest");
+ });
+
+ jQuery.each(elems, function(){
+ if ( this.fn.call(this.elem, event, this.fn.data) === false )
+ return (stop = false);
+ });
+
return stop;
}
return stop;
}
@@
-628,7
+641,7
@@
function bindReady(){
// If IE and not an iframe
// continually check to see if the document is ready
// If IE and not an iframe
// continually check to see if the document is ready
- if ( document.documentElement.doScroll && !window.frameElement ) (function(){
+ if ( document.documentElement.doScroll && window == window.top ) (function(){
if ( jQuery.isReady ) return;
try {
if ( jQuery.isReady ) return;
try {