From 52f59a4eb46a51a9fb0a65fea337b4938a3838a0 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 14 Jun 2012 17:15:38 +0100 Subject: [PATCH] Medium-sized refactoring of macro architecture Now event handlers are attached to element nodes, not to macro nodes. --- core/modules/macros/button.js | 14 ++-- core/modules/macros/chooser.js | 8 ++- core/modules/macros/download.js | 8 ++- core/modules/macros/edit/edit.js | 8 --- .../macros/edit/editors/bitmapeditor.js | 66 +++++++++---------- .../modules/macros/edit/editors/texteditor.js | 10 ++- core/modules/macros/link.js | 5 +- core/modules/macros/reveal.js | 10 +-- core/modules/macros/slider.js | 8 ++- core/modules/macros/story/story.js | 8 ++- core/modules/macros/zoomer.js | 8 ++- core/modules/treenodes/element.js | 23 ++++++- core/modules/treenodes/macro.js | 37 ++--------- 13 files changed, 104 insertions(+), 109 deletions(-) diff --git a/core/modules/macros/button.js b/core/modules/macros/button.js index ab0e6b103..2d8b7cfad 100644 --- a/core/modules/macros/button.js +++ b/core/modules/macros/button.js @@ -19,8 +19,7 @@ exports.info = { popup: {byName: true, type: "tiddler"}, qualifyTiddlerTitles: {byName: true, type: "text"}, "class": {byName: true, type: "text"} - }, - events: ["click", "tw-cancel-popup"] + } }; exports.dispatchMessage = function(event) { @@ -44,12 +43,12 @@ exports.triggerPopup = function(event,cancel) { value = ""; } else { // 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]+)\)$/; + var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/; if(popupLocationRegExp.test(value)) { value = ""; } else { // Set the position if we're opening it - value = "(" + this.domNode.offsetLeft + "," + this.domNode.offsetTop + "," + this.domNode.offsetWidth + "," + this.domNode.offsetHeight + ")"; + value = "(" + this.child.domNode.offsetLeft + "," + this.child.domNode.offsetTop + "," + this.child.domNode.offsetWidth + "," + this.child.domNode.offsetHeight + ")"; } } // Update the state tiddler @@ -68,7 +67,7 @@ exports.handleEvent = function(event) { event.preventDefault(); return false; case "tw-cancel-popup": - if(this.hasParameter("popup") && this.domNode !== event.targetOfCancel && !$tw.utils.domContains(this.domNode,event.targetOfCancel)) { + if(this.hasParameter("popup") && this.child.domNode !== event.targetOfCancel && !$tw.utils.domContains(this.child.domNode,event.targetOfCancel)) { this.triggerPopup(event,true); } break; @@ -87,7 +86,10 @@ exports.executeMacro = function() { for(var t=0; t