]> source.dussan.org Git - jquery.git/commitdiff
Modified onexxx handlers to unbind themselve when executed; Reintroduced event fixes...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Fri, 27 Oct 2006 08:10:00 +0000 (08:10 +0000)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Fri, 27 Oct 2006 08:10:00 +0000 (08:10 +0000)
src/event/event.js
src/jquery/jquery.js

index a60c4616aff29c624e66f61b69a65a84002bbeed..7a61773da5b95a483a8e7909cd60a0de5110e703 100644 (file)
@@ -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);
                };
                        
        };
index 9561ea9de4337e07cd775bf5d484ee56eb18977f..287cd641328c0b9338ebef4d4f45c5059c58e2d6 100644 (file)
@@ -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;
                }