Skip to content
Permalink
Browse files

Modified onexxx handlers to unbind themselve when executed; Reintrodu…

…ced event fixes (and added some more comments)
  • Loading branch information
jzaefferer committed Oct 27, 2006
1 parent 440d512 commit 4e5b46f7f624b119633390385560e09ab3d38fa8
Showing with 21 additions and 17 deletions.
  1. +9 −14 src/event/event.js
  2. +12 −3 src/jquery/jquery.js
@@ -1592,20 +1592,15 @@ new function(){

// Finally, handle events that only fire once
jQuery.fn["one"+o] = function(f){
// Attach the event listener
return this.each(function(){

var count = 0;

// Add the event
jQuery.event.add( this, o, function(e){
// If this function has already been executed, stop
if ( count++ ) return true;

// And execute the bound function
return f.apply(this, [e]);
});
});
// save cloned reference to this
var element = jQuery(this);
var handler = function() {
// unbind itself when executed
element.unbind(o, handler);
// apply original handler with the same arguments
f.apply(this, arguments);
};
return this.bind(o, handler);
};

};
@@ -2295,16 +2295,25 @@ jQuery.extend({
},

fix: function(event) {
if ( event ) {
// check IE
if(jQuery.browser.msie) {
// get real event from window.event
event = window.event;
event.preventDefault = function() {
this.returnValue = false;
};

event.stopPropagation = function() {
this.cancelBubble = true;
};
// fix target property
event.target = event.srcElement;
// check safari and if target is a textnode
} else if(jQuery.browser.safari && event.target.nodeType == 3) {
// target is readonly, clone the event object
event = jQuery.extend({}, event);
// get parentnode from textnode
event.target = event.target.parentNode;
}

return event;
}

0 comments on commit 4e5b46f

Please sign in to comment.
You can’t perform that action at this time.