From 2c8352c442f1d4e86acd2ba58e4aad7eccf72bea Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sun, 9 Jun 2013 19:24:21 +0100 Subject: [PATCH] Update the popup manager to allow popup state to be forced, rather than toggled We'll be needing this shortly --- core/modules/utils/dom/popup.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/modules/utils/dom/popup.js b/core/modules/utils/dom/popup.js index 9fc010656..cd2c92277 100644 --- a/core/modules/utils/dom/popup.js +++ b/core/modules/utils/dom/popup.js @@ -48,21 +48,26 @@ Trigger a popup open or closed. Parameters are in a hashmap: title: title of the tiddler where the popup details are stored domNode: dom node to which the popup will be positioned wiki: wiki + force: if specified, forces the popup state to true or false */ Popup.prototype.triggerPopup = function(options) { // Get the current popup state tiddler var value = options.wiki.getTextReference(options.title,""); // Check if the popup is open by checking whether it matches "(,)" - var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/; - if(popupLocationRegExp.test(value)) { - this.cancel(); - } else { + var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/, + state = !popupLocationRegExp.test(value); + if("force" in options) { + state = options.force; + } + if(state) { // Set the position if we're opening it this.cancel(); options.wiki.setTextReference(options.title, "(" + options.domNode.offsetLeft + "," + options.domNode.offsetTop + "," + options.domNode.offsetWidth + "," + options.domNode.offsetHeight + ")"); this.show(options); + } else { + this.cancel(); } };