From 758ba5edc2cb8bf06a60013d9ebeaaa5a3912b78 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 25 Mar 2015 22:13:22 +0000 Subject: [PATCH] Allow widgets to choose not to propagate actions Allow widgets to choose not to propagate actions. This is important for widgets that themselves trigger actions. Note that this change will cause problems with any existing 5.1.8-prerelease plugins that call `invokeActions()`. --- core/modules/widgets/button.js | 9 ++++++++- core/modules/widgets/widget.js | 27 ++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/core/modules/widgets/button.js b/core/modules/widgets/button.js index ff4d116e4..de839977a 100644 --- a/core/modules/widgets/button.js +++ b/core/modules/widgets/button.js @@ -63,7 +63,7 @@ ButtonWidget.prototype.render = function(parent,nextSibling) { // Add a click event handler domNode.addEventListener("click",function (event) { var handled = false; - if(self.invokeActions(event)) { + if(self.invokeActions(this,event)) { handled = true; } if(self.to) { @@ -94,6 +94,13 @@ ButtonWidget.prototype.render = function(parent,nextSibling) { this.domNodes.push(domNode); }; +/* +We don't allow actions to propagate because we trigger actions ourselves +*/ +ButtonWidget.prototype.allowActionPropagation = function() { + return false; +}; + ButtonWidget.prototype.getBoundingClientRect = function() { return this.domNodes[0].getBoundingClientRect(); } diff --git a/core/modules/widgets/widget.js b/core/modules/widgets/widget.js index 26c3bece0..bbcf5b025 100755 --- a/core/modules/widgets/widget.js +++ b/core/modules/widgets/widget.js @@ -476,29 +476,30 @@ Widget.prototype.removeChildDomNodes = function() { }; /* -Invoke any action widgets that are descendants of this widget. +Invoke the action widgets that are descendents of the current widget. */ -Widget.prototype.invokeActions = function(event) { - return this.invokeActionCall(this,event); -}; - -/* -Recursively search through descendants, invoking all actions encountered. -*/ -Widget.prototype.invokeActionCall = function(here,event) { +Widget.prototype.invokeActions = function(triggeringWidget,event) { var handled = false; - for(var t=0; t