From: Michael M Slusarz Date: Fri, 12 Dec 2008 06:47:51 +0000 (-0700) Subject: Make encrypt.js an all-purpose dialog script. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5b571add72d698859b98620d537d2736871de895;p=horde.git Make encrypt.js an all-purpose dialog script. --- diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 287bd9e5b..08df891ac 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -137,8 +137,7 @@ if (!$is_pop3) { 'column' => _("Message Options"), 'label' => _("Fetch Mail"), 'desc' => _("Customize accounts for fetching mail from other accounts."), - 'members' => array('fetchmail_link', 'fetchmail_popup', - 'fetchmail_menu') + 'members' => array('fetchmail_link', 'fetchmail_menu') ); } @@ -1090,14 +1089,6 @@ $_prefs['fetchmail_link'] = array( 'img' => 'fetchmail.png', 'desc' => _("Edit your preferences for accessing other mail accounts.")); -// Fetch mail on separate window? -$_prefs['fetchmail_popup'] = array( - 'value' => 0, - 'locked' => false, - 'shared' => false, - 'type' => 'checkbox', - 'desc' => _("Fetch Mail in a separate window?")); - // Show the Fetch mail icon on the menubar? $_prefs['fetchmail_menu'] = array( 'value' => 1, diff --git a/imp/index-dimp.php b/imp/index-dimp.php index 28fb0eaee..d9d5e3104 100644 --- a/imp/index-dimp.php +++ b/imp/index-dimp.php @@ -29,7 +29,7 @@ if ((!empty($GLOBALS['conf']['utils']['gnupg']) && $GLOBALS['prefs']->getValue('use_pgp')) || ($GLOBALS['prefs']->getValue('use_smime') && Util::extensionExists('openssl'))) { - $scripts[] = array('encrypt.js', 'imp', true); + $scripts[] = array('dialog.js', 'imp', true); } /* Get site specific menu items. */ diff --git a/imp/js/src/dialog.js b/imp/js/src/dialog.js new file mode 100644 index 000000000..043ef7726 --- /dev/null +++ b/imp/js/src/dialog.js @@ -0,0 +1,73 @@ +/** + * Javascript code used to display a RedBox dialog. + * + * Copyright 2008 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + * + * @author Michael Slusarz + */ + +var IMPDialog = { + + display: function(data) + { + data = decodeURIComponent(data).evalJSON(true); + this.action = data.action; + this.params = data.params; + this.uri = data.uri; + + var n = new Element('FORM', { action: '#', id: 'RB_confirm' }).insert( + new Element('P').insert(data.text) + ).insert( + new Element('INPUT', { type: 'text', size: 15 }) + ).insert( + new Element('INPUT', { type: 'button', className: 'button', value: data.ok_text }).observe('click', this._onClick.bind(this)) + ).insert( + new Element('INPUT', { type: 'button', className: 'button', value: data.cancel_text }).observe('click', this._close.bind(this)) + ).observe('keydown', function(e) { if ((e.keyCode || e.charCode) == Event.KEY_RETURN) { e.stop(); this._onClick(e); } }.bind(this)); + + RedBox.overlay = true; + RedBox.onDisplay = Form.focusFirstElement.curry(n); + RedBox.showHtml(n); + }, + + _close: function() + { + var c = RedBox.getWindowContents(); + [ c, c.descendants()].flatten().compact().invoke('stopObserving'); + RedBox.close(); + }, + + _onClick: function(e) + { + params = this.params || {}; + params.passphrase = $F(e.findElement('form').down('input')); + + new Ajax.Request(this.uri, { parameters: params, onSuccess: this._onSuccess.bind(this), onFailure: this._onFailure.bind(this) }); + }, + + _onSuccess: function(r) + { + try { + r = r.responseText.evalJSON(true); + } catch (e) {} + + if (r.response.success) { + this._close(); + if (this.action) { + this.action(); + } else { + location.reload(); + } + } else if (r.response.error) { + alert(r.response.error); + } + }, + + _onFailure: function(r) + { + } + +}; diff --git a/imp/js/src/encrypt.js b/imp/js/src/encrypt.js deleted file mode 100644 index ab7ce68af..000000000 --- a/imp/js/src/encrypt.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Javascript code used to display a RedBox pasphrase dialog. - * - * Copyright 2008 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (GPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. - * - * @author Michael Slusarz - */ - -var IMPEncrypt = { - - display: function(data) - { - data = decodeURIComponent(data).evalJSON(true); - this.action = data.action; - this.params = data.params; - this.uri = data.uri; - - var n = new Element('FORM', { action: '#', id: 'RB_confirm' }).insert( - new Element('P').insert(data.text) - ).insert( - new Element('INPUT', { type: 'text', size: 15 }) - ).insert( - new Element('INPUT', { type: 'button', className: 'button', value: data.ok_text }).observe('click', this._onClick.bind(this)) - ).insert( - new Element('INPUT', { type: 'button', className: 'button', value: data.cancel_text }).observe('click', this._close.bind(this)) - ).observe('keydown', function(e) { if ((e.keyCode || e.charCode) == Event.KEY_RETURN) { e.stop(); this._onClick(e); } }.bind(this)); - - RedBox.overlay = true; - RedBox.onDisplay = Form.focusFirstElement.curry(n); - RedBox.showHtml(n); - }, - - _close: function() - { - var c = RedBox.getWindowContents(); - [ c, c.descendants()].flatten().compact().invoke('stopObserving'); - RedBox.close(); - }, - - _onClick: function(e) - { - params = this.params || {}; - params.passphrase = $F(e.findElement('form').down('input')); - - new Ajax.Request(this.uri, { parameters: params, onSuccess: this._onSuccess.bind(this), onFailure: this._onFailure.bind(this) }); - }, - - _onSuccess: function(r) - { - try { - r = r.responseText.evalJSON(true); - } catch (e) {} - - if (r.response.success) { - this._close(); - if (this.action) { - this.action(); - } else { - location.reload(); - } - } else if (r.response.error) { - alert(r.response.error); - } - }, - - _onFailure: function(r) - { - } - -}; diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 7fc0a8be1..bcaf801f3 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1952,7 +1952,7 @@ class IMP { Horde::addScriptFile('prototype.js', 'horde', true); Horde::addScriptFile('effects.js', 'horde', true); - Horde::addScriptFile('encrypt.js', 'imp', true); + Horde::addScriptFile('dialog.js', 'imp', true); Horde::addScriptFile('redbox.js', 'imp', true); switch ($type) { @@ -1978,6 +1978,6 @@ class IMP 'cancel_text' => _("Cancel") ); - return 'IMPEncrypt.display(\'' . IMP::escapeJSON($js_params) . '\')'; + return 'IMPDialog.display(\'' . IMP::escapeJSON($js_params) . '\')'; } }