From: Michael M Slusarz Date: Thu, 22 Apr 2010 20:57:12 +0000 (-0600) Subject: Improve clarity of popdown generation code X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=befcebe74422f7fcf319745bc897ab3eb169b5f1;p=horde.git Improve clarity of popdown generation code --- diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index dcd8bd03a..2861ae55a 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -672,15 +672,26 @@ var DimpBase = { }); }, - _addMouseEvents: function(p, popdown) + _addPopdown: function(p, t) { - if (popdown) { - popdown.insert({ after: new Element('SPAN', { className: 'iconImg popdownImg popdown', id: p.id + '_img' }) }); - p.id += '_img'; - p.offset = popdown.up(); - p.left = true; - } + var elt = new Element('SPAN', { className: 'iconImg popdownImg popdown' }); + $(p).insert({ after: elt }); + this._addPopdownContextMenu(elt, t); + return elt; + }, + _addPopdownContextMenu: function(elt, t) + { + this._addMouseEvents({ + id: elt.identify(), + left: true, + offset: elt.up(), + type: t + }); + }, + + _addMouseEvents: function(p) + { DimpCore.DMenu.addElement(p.id, 'ctx_' + p.type, p); }, @@ -1994,10 +2005,6 @@ var DimpBase = { e.stop(); return; - case 'folderopts': - DimpCore.DMenu.trigger($('folderopts_img'), true); - return; - case 'button_forward': case 'button_reply': this.composeMailbox(id == 'button_reply' ? 'reply_auto' : 'forward_auto'); @@ -2014,11 +2021,6 @@ var DimpBase = { e.stop(); return; - case 'button_other': - DimpCore.DMenu.trigger(e.findElement('A').next(), true); - e.stop(); - return; - case 'msglistHeader': this.sort(e.element().retrieve('sortby')); e.stop(); @@ -2969,8 +2971,10 @@ var DimpBase = { this._setQsearchText(true); /* Add popdown menus. Check for disabled compose at the same time. */ - this._addMouseEvents({ id: 'button_other', type: 'otheractions' }, $('button_other')); - this._addMouseEvents({ id: 'folderopts', type: 'folderopts' }, $('folderopts').down(1)); + this._addPopdown('button_other', 'otheractions'); + this._addPopdownContextMenu($('button_other'), 'otheractions'); + this._addPopdown('folderopts_link', 'folderopts'); + this._addPopdownContextMenu($('folderopts_link'), 'folderopts'); DM.addSubMenu('ctx_message_reply', 'ctx_reply'); DM.addSubMenu('ctx_message_forward', 'ctx_forward'); @@ -2985,11 +2989,8 @@ var DimpBase = { if (DIMP.conf.disable_compose) { $('button_reply', 'button_forward').compact().invoke('up', 'SPAN').concat($('button_compose', 'composelink', 'ctx_contacts_new')).compact().invoke('remove'); } else { - this._addMouseEvents({ id: 'button_reply', type: 'reply' }, $('button_reply')); - DM.disable('button_reply_img', true, true); - - this._addMouseEvents({ id: 'button_forward', type: 'forward' }, $('button_forward')); - DM.disable('button_forward_img', true, true); + DM.disable(this._addPopdown('button_reply', 'reply').identify(), true, true); + DM.disable(this._addPopdown('button_forward', 'forward').identify(), true, true); } this._addMouseEvents({ id: 'msglistHeader', type: 'mboxsort' }); diff --git a/imp/templates/dimp/index.inc b/imp/templates/dimp/index.inc index 3ff828bc1..cc94b8f6d 100644 --- a/imp/templates/dimp/index.inc +++ b/imp/templates/dimp/index.inc @@ -104,7 +104,7 @@ function _simpleButton($id, $text, $image, $nodisplay = false)