You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2013/02/06 09:52:00 UTC

[14/38] git commit: Add possibility to stop event completely, i.e. it wont be handled by other listeners on the same HTML element.

Add possibility to stop event completely, i.e. it wont be handled by other listeners on the same HTML element.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/f884894e
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/f884894e
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/f884894e

Branch: refs/heads/reference-guide
Commit: f884894e2af9ce57f31c63548157a1517488a8bd
Parents: 67f4e86
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon Jan 28 16:11:23 2013 +0100
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon Jan 28 16:11:23 2013 +0100

----------------------------------------------------------------------
 .../wicket/ajax/res/js/wicket-event-jquery.js      |   11 +++++++++--
 wicket-core/src/test/js/event.js                   |    8 +++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/f884894e/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js
index 8dc66bd..48fcf7f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js
@@ -110,10 +110,17 @@
 
 			/**
 			 * Prevent event from bubbling up in the element hierarchy.
+			 * @param evt {Event} - the event to stop
+			 * @param immediate {Boolean} - true if the event should not be handled by other listeners registered
+			 *      on the same HTML element. Optional
 			 */
-			stop: function (evt) {
+			stop: function (evt, immediate) {
 				evt = Wicket.Event.fix(evt);
-				evt.stopPropagation();
+				if (immediate) {
+					evt.stopImmediatePropagation();
+				} else {
+					evt.stopPropagation();
+				}
 				return evt;
 			},
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/f884894e/wicket-core/src/test/js/event.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/js/event.js b/wicket-core/src/test/js/event.js
index 5bcc794..31847c7 100644
--- a/wicket-core/src/test/js/event.js
+++ b/wicket-core/src/test/js/event.js
@@ -61,10 +61,17 @@ jQuery(document).ready(function() {
 		var evt = jQuery.Event("keydown", { keyCode: 123 });
 
 		equal(evt.isPropagationStopped(), false);
+		equal(evt.isImmediatePropagationStopped(), false);
 
 		Wicket.Event.stop(evt);
 
 		equal(evt.isPropagationStopped(), true);
+		equal(evt.isImmediatePropagationStopped(), false);
+
+		Wicket.Event.stop(evt, true);
+
+		equal(evt.isPropagationStopped(), true);
+		equal(evt.isImmediatePropagationStopped(), true);
 	});
 
 
@@ -207,7 +214,6 @@ jQuery(document).ready(function() {
 		Wicket.Event.publish('topicName');
 	});
 
-	
 	test('all topics', function() {
 		expect(8);