Refactored the trigger code a little bit.
This commit is contained in:
parent
23220321d1
commit
d2f9022a8e
1 changed files with 19 additions and 18 deletions
|
@ -80,29 +80,30 @@ jQuery.event = {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Handle triggering a single element
|
// Handle triggering a single element
|
||||||
else if ( element["on" + type] ) {
|
else {
|
||||||
// Pass along a fake event
|
var handler = element["on" + type ], val,
|
||||||
data.unshift( this.fix({ type: type, target: element }) );
|
fn = jQuery.isFunction( element[ type ] );
|
||||||
|
|
||||||
// Trigger the event
|
|
||||||
var val = element["on" + type].apply( element, data );
|
|
||||||
|
|
||||||
if ( val !== false && jQuery.isFunction( element[ type ] ) ) {
|
if ( handler ) {
|
||||||
this.triggered = true;
|
// Pass along a fake event
|
||||||
element[ type ]();
|
data.unshift( this.fix({ type: type, target: element }) );
|
||||||
|
|
||||||
|
// Trigger the event
|
||||||
|
if ( (val = handler.apply( element, data )) !== false )
|
||||||
|
this.triggered = true;
|
||||||
}
|
}
|
||||||
} else if ( jQuery.isFunction( element[ type ] ) )
|
|
||||||
element[ type ]();
|
if ( fn && val !== false )
|
||||||
|
element[ type ]();
|
||||||
|
|
||||||
|
this.triggered = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handle: function(event) {
|
handle: function(event) {
|
||||||
if ( typeof jQuery == "undefined" ) return;
|
// Handle the second event of a trigger and when
|
||||||
|
// an event is called after a page has unloaded
|
||||||
// Handle the second event of a trigger
|
if ( typeof jQuery == "undefined" || jQuery.event.triggered ) return;
|
||||||
if ( jQuery.event.triggered ) {
|
|
||||||
jQuery.event.triggered = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Empty object is for triggered events with no data
|
// Empty object is for triggered events with no data
|
||||||
event = jQuery.event.fix( event || window.event || {} );
|
event = jQuery.event.fix( event || window.event || {} );
|
||||||
|
|
Loading…
Reference in a new issue