From 4f1c84989e6cf77eab8fe8588a18c77108811cfa Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 24 Sep 2010 11:46:41 -0600 Subject: [PATCH] Move flag context item creation into javascript Allows for dynamic addition of flags in the future. Also allows storage of IMAP flag name in metadata rather than hackish parameter storage. --- imp/js/dimpbase.js | 33 ++++++++++++++++++++++++++--- imp/templates/dimp/index.inc | 16 ++------------ imp/templates/dimp/javascript_defs_dimp.php | 6 +++++- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/imp/js/dimpbase.js b/imp/js/dimpbase.js index c088abb07..8efbaa907 100644 --- a/imp/js/dimpbase.js +++ b/imp/js/dimpbase.js @@ -643,7 +643,7 @@ var DimpBase = { $('ctx_message_setflag', 'oa_setflag').invoke('up').invoke(flags.size() ? 'show' : 'hide'); if (flags.size()) { $('ctx_flag').childElements().each(function(c) { - [ c ].invoke(flags.include(c.readAttribute('flag')) ? 'show' : 'hide'); + [ c ].invoke(flags.include(c.retrieve('flag')) ? 'show' : 'hide'); }); } }.bindAsEventListener(this)); @@ -896,11 +896,11 @@ var DimpBase = { default: if (menu.endsWith('_setflag') || menu.endsWith('_unsetflag')) { - flag = elt.readAttribute('flag'); + flag = elt.retrieve('flag'); this.flag(flag, this.convertFlag(flag, menu.endsWith('_setflag'))); } else if (menu.endsWith('_filter') || menu.endsWith('_filternot')) { this.search = { - flag: elt.readAttribute('flag'), + flag: elt.retrieve('flag'), label: this.viewport.getMetaData('label'), mbox: this.folder, not: menu.endsWith('_filternot') @@ -1010,6 +1010,26 @@ var DimpBase = { } }, + contextAddFlag: function(flag, f) + { + var a = new Element('A'), + style = {}; + + if (f.p) { + style.backgroundColor = f.b.escapeHTML(); + } + + $('ctx_flag').insert( + a.insert( + new Element('SPAN', { className: 'contextImg' }).addClassName(f.c.escapeHTML()).setStyle(style) + ).insert( + f.l.escapeHTML() + ) + ); + + a.store('flag', flag); + }, + // nodefer - (boolean) If true, don't defer updating if folder element // does not exist. updateTitle: function(nodefer) @@ -3057,6 +3077,13 @@ var DimpBase = { }); DM.addSubMenu('ctx_folder_setflag', 'ctx_folder_flag'); + /* Create flag entries. */ + DIMP.conf.flags_o.each(function(f) { + if (DIMP.conf.flags[f].s) { + this.contextAddFlag(f, DIMP.conf.flags[f]); + } + }, this); + if (DIMP.conf.disable_compose) { $('button_reply', 'button_forward').compact().invoke('up', 'SPAN').concat($('button_compose', 'composelink', 'ctx_contacts_new')).compact().invoke('remove'); } else { diff --git a/imp/templates/dimp/index.inc b/imp/templates/dimp/index.inc index ae5fb588c..fb0b5a452 100644 --- a/imp/templates/dimp/index.inc +++ b/imp/templates/dimp/index.inc @@ -17,9 +17,6 @@ $has_whitelist = $registry->hasMethod('mail/whitelistFrom'); // Quota information $show_quota = (isset($_SESSION['imp']['imap']['quota']) && is_array($_SESSION['imp']['imap']['quota'])); -// Get the list of available IMAP flags -$flag_list = $injector->getInstance('IMP_Imap_Flags')->getList(array('imap' => true)); - // Get application folders list. $application_folders = array(); foreach (IMP_Dimp::menuList() as $app) { @@ -397,13 +394,11 @@ function _simpleButton($id, $text, $image, $nodisplay = false) - -
+ -
@@ -448,13 +443,11 @@ function _simpleButton($id, $text, $image, $nodisplay = false) - -
+ -
@@ -478,13 +471,8 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
- -