From: Michael M Slusarz Date: Tue, 18 Aug 2009 08:29:50 +0000 (-0600) Subject: Move more javascript out of templates to static files X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b7fe6bddf4cf2646259b045ff39a4f78b6ebd283;p=horde.git Move more javascript out of templates to static files --- diff --git a/imp/js/foldermanagement.js b/imp/js/foldermanagement.js new file mode 100644 index 000000000..0c59a8654 --- /dev/null +++ b/imp/js/foldermanagement.js @@ -0,0 +1,49 @@ +/** + * Provides the javascript for managing folders. + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + */ + +var ImpFoldermanagement = { + // Variables defined by other code: folders + + newFolderName: function(f, fn, p1, p2) + { + f = $(f); + fn = $(fn); + + if (f[f.selectedIndex].value == '') { + var folder = window.prompt(p1, fn.value ? fn.value : ''); + if (folder != '') { + fn.value = folder; + f[1].text = p2 + ' [' + fn.value + ']'; + } + } + } + +}; + +document.observe('dom:loaded', function() { + var fm = ImpFoldermanagement; + fm.folders.each(function(f) { + $(f[0]).observe('change', fm.newFolderName.bind(fm, f[0], f[1], f[2], f[3])); + }); +}); + +// Called by Horde identity pref code. +function newChoice_sent_mail_folder(val) +{ + var field = $('sent_mail_folder'); + if (val == "") { + field.selectedIndex = 0; + return; + } + + for (var i = 0, l = field.options.length; i < l; i++) { + if (field.options[i].value == val) { + field.selectedIndex = i; + break; + } + } +} diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 2be58dc02..3491d38ea 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -438,6 +438,39 @@ class IMP_Application extends Horde_Registry_Application 'ImpFlagmanagement.confirm_delete = ' . Horde_Serialize::serialize(_("Are you sure you want to delete this flag?"), Horde_Serialize::JSON, Horde_Nls::getCharset()) )); break; + + case 'identities': + if (!$GLOBALS['prefs']->isLocked('sent_mail_folder')) { + Horde::addScriptFile('foldermanagement.js', 'imp', true); + Horde::addInlineScript(array( + 'ImpFoldermanagement.folders = ' . Horde_Serialize::serialize(array('sent_mail_folder', 'sent_mail_new', _("Enter the name for your new sent-mail folder"), _("Create a new sent-mail folder")), Horde_Serialize::JSON, Horde_Nls::getCharset()) + )); + } + break; + + case 'server': + $code = array(); + + if (!$GLOBALS['prefs']->isLocked('drafts_folder')) { + $code[] = array('drafts', 'drafts_new', _("Enter the name for your new drafts folder"), _("Create a new drafts folder")); + } + + if (!$GLOBALS['prefs']->isLocked('spam_folder')) { + $code[] = array('spam', 'spam_new', _("Enter the name for your new spam folder"), _("Create a new spam folder")); + } + + if (!$GLOBALS['prefs']->isLocked('trash_folder') && + !$GLOBALS['prefs']->isLocked('use_vtrash')) { + $code[] = array('trash', 'trash_new', _("Enter the name for your new trash folder"), _("Create a new trash folder")); + } + + if (!empty($code)) { + Horde::addScriptFile('foldermanagement.js', 'imp', true); + Horde::addInlineScript(array( + 'ImpFoldermanagement.folders = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, Horde_Nls::getCharset()) + )); + } + break; } } diff --git a/imp/templates/prefs/draftsselect.inc b/imp/templates/prefs/draftsselect.inc index 0afc1b4e5..2acabeef8 100644 --- a/imp/templates/prefs/draftsselect.inc +++ b/imp/templates/prefs/draftsselect.inc @@ -1,25 +1,7 @@ isLocked('drafts_folder')): ?> - -
- - + diff --git a/imp/templates/prefs/sentmailselect.inc b/imp/templates/prefs/sentmailselect.inc index 0ffa2c9a5..6f863cb32 100644 --- a/imp/templates/prefs/sentmailselect.inc +++ b/imp/templates/prefs/sentmailselect.inc @@ -1,44 +1,10 @@ isLocked('sent_mail_folder')): ?> - -
-
- + + +
diff --git a/imp/templates/prefs/spamselect.inc b/imp/templates/prefs/spamselect.inc index 44e16ac38..cf2dfd910 100644 --- a/imp/templates/prefs/spamselect.inc +++ b/imp/templates/prefs/spamselect.inc @@ -1,23 +1,8 @@ isLocked('spam_folder')): ?> - -
- - + + diff --git a/imp/templates/prefs/trashselect.inc b/imp/templates/prefs/trashselect.inc index 9f6d074b7..2f3b35bad 100644 --- a/imp/templates/prefs/trashselect.inc +++ b/imp/templates/prefs/trashselect.inc @@ -1,23 +1,7 @@ isLocked('trash_folder') && !$prefs->isLocked('use_vtrash')): ?> - -
- - +