jquery event: closes #3355. Added stopImmediatePropagation() to events.
authorAriel Flesler <aflesler@gmail.com>
Sat, 18 Oct 2008 22:46:04 +0000 (22:46 +0000)
committerAriel Flesler <aflesler@gmail.com>
Sat, 18 Oct 2008 22:46:04 +0000 (22:46 +0000)
src/event.js

index 324024f..e9e1bee 100644 (file)
@@ -190,6 +190,7 @@ jQuery.event = {
                                        target: elem,
                                        preventDefault: function(){},
                                        stopPropagation: function(){},
                                        target: elem,
                                        preventDefault: function(){},
                                        stopPropagation: function(){},
+                                       stopImmediatePropagation:stopImmediatePropagation,
                                        timeStamp: now()
                                });
                                data[0][expando] = true; // no need to fix fake event
                                        timeStamp: now()
                                });
                                data[0][expando] = true; // no need to fix fake event
@@ -271,6 +272,10 @@ jQuery.event = {
                                        event.preventDefault();
                                        event.stopPropagation();
                                }
                                        event.preventDefault();
                                        event.stopPropagation();
                                }
+
+                               if( event._sip )
+                                       break;
+
                        }
                }
 
                        }
                }
 
@@ -280,7 +285,7 @@ jQuery.event = {
        props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" "),
 
        fix: function(event) {
        props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target timeStamp toElement type view wheelDelta which".split(" "),
 
        fix: function(event) {
-               if ( event[expando] == true )
+               if ( event[expando] )
                        return event;
 
                // store a copy of the original event object
                        return event;
 
                // store a copy of the original event object
@@ -313,6 +318,8 @@ jQuery.event = {
                        originalEvent.cancelBubble = true;
                };
 
                        originalEvent.cancelBubble = true;
                };
 
+               event.stopImmediatePropagation = stopImmediatePropagation;
+
                // Fix timeStamp
                event.timeStamp = event.timeStamp || now();
 
                // Fix timeStamp
                event.timeStamp = event.timeStamp || now();
 
@@ -367,6 +374,11 @@ jQuery.event = {
        }
 };
 
        }
 };
 
+function stopImmediatePropagation(){
+       this._sip = 1;
+       this.stopPropagation();
+}
+
 if ( !jQuery.browser.msie ){   
        // Checks if an event happened on an element within another element
        // Used in jQuery.event.special.mouseenter and mouseleave handlers
 if ( !jQuery.browser.msie ){   
        // Checks if an event happened on an element within another element
        // Used in jQuery.event.special.mouseenter and mouseleave handlers