From 83351301326cd46f44fc5fede3a7102d12027de1 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 16 Dec 2009 12:38:27 -0700 Subject: [PATCH] ContextSensitive events now fired on base element, not document --- imp/js/ContextSensitive.js | 15 ++++++++------- imp/js/DimpBase.js | 6 +++--- imp/js/DimpCore.js | 16 +++++++++------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/imp/js/ContextSensitive.js b/imp/js/ContextSensitive.js index b2373cd88..ade17838a 100644 --- a/imp/js/ContextSensitive.js +++ b/imp/js/ContextSensitive.js @@ -16,16 +16,17 @@ * * Custom Events: * -------------- - * Custom events are triggered on the document element. The parameters given + * Custom events are triggered on the base element. The parameters given * below are available through the 'memo' property of the Event object. * * ContextSensitive:click - * Fired on TODO - * params: (object) TODO [base, elt, trigger] + * Fired when a contextmenu element is clicked on. + * params: (object) elt - (Element) The menu element clicked on. + * trigger - (string) The parent menu. * * ContextSensitive:show - * Fired on TODO - * params: (object) TODO [base, id] + * Fired before a contextmenu is displayed. + * params: (string) The DOM ID of the context menu. * * * Original code by Havard Eide (http://eide.org/) released under the MIT @@ -191,7 +192,7 @@ var ContextSensitive = Class.create({ base = this.baseelt; trigger = this.triggers.last(); this.close(); - document.fire('ContextSensitive:click', { base: base, elt: elt, trigger: trigger }); + base.fire('ContextSensitive:click', { elt: elt, trigger: trigger }); } return; } @@ -294,7 +295,7 @@ var ContextSensitive = Class.create({ : (v.width - size.width - 10); } - document.fire('ContextSensitive:show', { base: this.baseelt, id: id }); + this.baseelt.fire('ContextSensitive:show', id); elt.setStyle({ left: x + 'px', top: y + 'px' }) diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index ee7f76154..0daeb1d7b 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -681,7 +681,7 @@ var DimpBase = { contextOnClick: function(parentfunc, e) { var flag, tmp, - baseelt = e.memo.base, + baseelt = e.element(), elt = e.memo.elt, id = elt.readAttribute('id'), menu = e.memo.trigger; @@ -858,8 +858,8 @@ var DimpBase = { contextOnShow: function(parentfunc, e) { var elts, ob, sel, tmp, - baseelt = e.memo.base, - ctx_id = e.memo.id; + baseelt = e.element(), + ctx_id = e.memo; switch (ctx_id) { case 'ctx_folder': diff --git a/imp/js/DimpCore.js b/imp/js/DimpCore.js index 97c915238..7c2656163 100644 --- a/imp/js/DimpCore.js +++ b/imp/js/DimpCore.js @@ -446,9 +446,9 @@ var DimpCore = { { var tmp; - switch (e.memo.id) { + switch (e.memo) { case 'ctx_contacts': - tmp = $(e.memo.id).down('DIV.contactAddr'); + tmp = $(e.memo).down('DIV.contactAddr'); if (tmp) { tmp.next().remove(); tmp.remove(); @@ -456,10 +456,10 @@ var DimpCore = { // Add e-mail info to context menu if personal name is shown on // page. - if (e.memo.base.retrieve('personal')) { - $(e.memo.id) + if (e.element().retrieve('personal')) { + $(e.memo) .insert({ top: new Element('DIV', { className: 'sep' }) }) - .insert({ top: new Element('DIV', { className: 'contactAddr' }).insert(e.memo.base.retrieve('email').escapeHTML()) }); + .insert({ top: new Element('DIV', { className: 'contactAddr' }).insert(e.element().retrieve('email').escapeHTML()) }); } break; } @@ -467,13 +467,15 @@ var DimpCore = { contextOnClick: function(e) { + var baseelt = e.element(); + switch (e.memo.elt.readAttribute('id')) { case 'ctx_contacts_new': - this.compose('new', { to: e.memo.baseelt.retrieve('address') }); + this.compose('new', { to: baseelt.retrieve('address') }); break; case 'ctx_contacts_add': - this.doAction('AddContact', { name: e.memo.baseelt.retrieve('personal'), email: e.memo.baseelt.retrieve('email') }, {}, true); + this.doAction('AddContact', { name: baseelt.retrieve('personal'), email: baseelt.retrieve('email') }, {}, true); break; } }, -- 2.11.0