From 260bbc99a744ab7b23e1cb6a663b121ac6e673c4 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 9 Feb 2009 16:58:00 -0700 Subject: [PATCH] Move folder switch code to static JS file --- imp/js/imp.js | 1 + imp/js/src/imp.js | 26 ++++++++++++++++++++++++++ imp/lib/IMP.php | 5 +++-- imp/templates/menu.html | 19 ++----------------- 4 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 imp/js/imp.js create mode 100644 imp/js/src/imp.js diff --git a/imp/js/imp.js b/imp/js/imp.js new file mode 100644 index 000000000..2568d7fd4 --- /dev/null +++ b/imp/js/imp.js @@ -0,0 +1 @@ +if(!IMP){var IMP={}}IMP.menuFolderSubmit=function(a){var b=$("menuform");if((!this.menufolder_load||a)&&$F(b.down('SELECT[name="mailbox"]'))){this.menufolder_load=true;b.submit()}};document.observe("dom:loaded",function(){$("menuform").observe("change",IMP.menuFolderSubmit.bind(IMP));$("openfoldericon").down().observe("click",IMP.menuFolderSubmit.bind(IMP,true))}); \ No newline at end of file diff --git a/imp/js/src/imp.js b/imp/js/src/imp.js new file mode 100644 index 000000000..7f2b6d37a --- /dev/null +++ b/imp/js/src/imp.js @@ -0,0 +1,26 @@ +/** + * Provides basic IMP javascript. + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + */ + +if (!IMP) { + var IMP = {}; +} + +IMP.menuFolderSubmit = function(clear) +{ + var mf = $('menuform'); + + if ((!this.menufolder_load || clear) && + $F(mf.down('SELECT[name="mailbox"]'))) { + this.menufolder_load = true; + mf.submit(); + } +}; + +document.observe('dom:loaded', function() { + $('menuform').observe('change', IMP.menuFolderSubmit.bind(IMP)); + $('openfoldericon').down().observe('click', IMP.menuFolderSubmit.bind(IMP, true)); +}); diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index fe3dc972d..4f4fc108b 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -694,9 +694,10 @@ class IMP $t->set('accesskey', $GLOBALS['prefs']->getValue('widget_accesskey') ? Horde::getAccessKey(_("Open Fo_lder")) : '', true); $t->set('flist', self::flistSelect(array('selected' => $GLOBALS['imp_mbox']['mailbox'], 'inc_vfolder' => true))); + Horde::addScriptFile('imp.js', 'imp', true); + $menu_view = $GLOBALS['prefs']->getValue('menu_view'); - $link = Horde::link('#', '', '', '', 'folderSubmit(true); return false;'); - $t->set('flink', sprintf('', $link, ($menu_view != 'text') ? Horde::img('folders/folder_open.png', _("Open Folder"), ($menu_view == 'icon') ? array('title' => _("Open Folder")) : array()) : '', ($menu_view != 'icon') ? Horde::highlightAccessKey(_("Open Fo_lder"), $t->get('accesskey')) : '')); + $t->set('flink', sprintf('', Horde::link('#'), ($menu_view != 'text') ? Horde::img('folders/folder_open.png', _("Open Folder"), ($menu_view == 'icon') ? array('title' => _("Open Folder")) : array()) : '', ($menu_view != 'icon') ? Horde::highlightAccessKey(_("Open Fo_lder"), $t->get('accesskey')) : '')); } $t->set('menu_string', self::getMenu('string')); diff --git a/imp/templates/menu.html b/imp/templates/menu.html index 998c89b1f..62aa20c68 100644 --- a/imp/templates/menu.html +++ b/imp/templates/menu.html @@ -1,11 +1,11 @@ -
+