From: Michael M Slusarz Date: Tue, 10 Feb 2009 04:36:51 +0000 (-0700) Subject: Move popup/unblockimages into imp.js. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d06f5dbc9d3a8328b25ce2f866ab6b5fedcb66b9;p=horde.git Move popup/unblockimages into imp.js. --- diff --git a/imp/folders.php b/imp/folders.php index 07af5bd74..1edef3fd8 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -510,7 +510,7 @@ if ($open_compose_window === false) { if (!isset($options)) { $options = array(); } - Horde::addScriptFile('popup.js', 'imp', true); + Horde::addScriptFile('imp.js', 'imp', true); IMP::addInlineScript(IMP::popupIMPString('compose.php', array_merge(array('popup' => 1), $options, IMP::getComposeArgs()))); } diff --git a/imp/index-dimp.php b/imp/index-dimp.php index b634bc58a..72522cb7b 100644 --- a/imp/index-dimp.php +++ b/imp/index-dimp.php @@ -23,8 +23,7 @@ $scripts = array( array('redbox.js', 'horde', true), array('mailbox-dimp.js', 'imp', false), array('DimpSlider.js', 'imp', true), - array('unblockImages.js', 'imp', true), - array('popup.js', 'imp', true), + array('imp.js', 'imp', true), array('dialog.js', 'imp', true) ); diff --git a/imp/js/imp.js b/imp/js/imp.js index 2568d7fd4..5ca3bdf19 100644 --- a/imp/js/imp.js +++ b/imp/js/imp.js @@ -1 +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 +var IMP=window.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()}};IMP.popup=function(d,e,a,c){var f,g,h=$H(),b=new Date().getTime();a=Math.min(screen.height-75,a||500);e=Math.min(screen.width-75,e||600);f=d.indexOf("?");if(f!=-1){h=$H(d.toQueryParams());d=d.substring(0,f)}if(c){$H(c.toQueryParams()).each(function(i){h.set(i.key,unescape(i.value))})}h.set("uniq",b);g=window.open(d+"?"+h.toQueryString(),b,"toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width="+e+",height="+a+",left=0,top=0");if(!g){alert(IMP.text.popup_block)}else{if(Object.isUndefined(g.name)){g.name=b}if(Object.isUndefined(g.opener)){g.opener=self}g.focus()}};IMP.unblockImages=function(c,b){var a;if(!c){return true}$(c).select("[blocked]").each(function(d){var e=decodeURIComponent(d.readAttribute("blocked"));if(d.hasAttribute("src")){d.writeAttribute("src",e)}else{if(d.hasAttribute("background")){d.writeAttribute("background",e)}else{if(d.style.backgroundImage){d.setStyle({backgroundImage:"url("+e+")"})}}}});b=$(b);if(b){a=b.up();b.remove();if(!a.childElements().size()){a=a.up("TABLE.mimeStatusMessage");if(a){a.remove()}}}return false};document.observe("dom:loaded",function(){var a=$("menuform");if(a){a.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/popup.js b/imp/js/popup.js deleted file mode 100644 index 2949d5bc2..000000000 --- a/imp/js/popup.js +++ /dev/null @@ -1 +0,0 @@ -function popup_imp(d,e,a,c){var f,g,h=$H(),b=new Date().getTime();a=Math.min(screen.height-75,a||500);e=Math.min(screen.width-75,e||600);f=d.indexOf("?");if(f!=-1){h=$H(d.toQueryParams());d=d.substring(0,f)}if(c){$H(c.toQueryParams()).each(function(i){h.set(i.key,unescape(i.value))})}h.set("uniq",b);g=window.open(d+"?"+h.toQueryString(),b,"toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width="+e+",height="+a+",left=0,top=0");if(!g){alert(IMP.text.popup_block)}else{if(Object.isUndefined(g.name)){g.name=b}if(Object.isUndefined(g.opener)){g.opener=self}g.focus()}}; \ No newline at end of file diff --git a/imp/js/src/imp.js b/imp/js/src/imp.js index 7f2b6d37a..660d6df33 100644 --- a/imp/js/src/imp.js +++ b/imp/js/src/imp.js @@ -1,13 +1,11 @@ /** - * Provides basic IMP javascript. + * Provides basic IMP javascript functions. * * 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 = {}; -} +var IMP = window.IMP || {}; IMP.menuFolderSubmit = function(clear) { @@ -20,7 +18,94 @@ IMP.menuFolderSubmit = function(clear) } }; +/** + * Open a popup window. + * + * @param string $url The URL to open in the popup window. + * @param integer $width The width of the popup window. (Default: 600 px) + * @param integer $height The height of the popup window. (Default: 500 px) + * @param string $args Any additional args to pass to the script. + * (Default: no args) + */ +IMP.popup = function(url, width, height, args) +{ + var q, win, + params = $H(), + name = new Date().getTime(); + + height = Math.min(screen.height - 75, height || 500); + width = Math.min(screen.width - 75, width || 600); + + q = url.indexOf('?'); + if (q != -1) { + params = $H(url.toQueryParams()); + url = url.substring(0, q); + } + + if (args) { + $H(args.toQueryParams()).each(function(a) { + params.set(a.key, unescape(a.value)); + }); + } + params.set('uniq', name); + + win = window.open(url + '?' + params.toQueryString(), name, 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',left=0,top=0'); + if (!win) { + alert(IMP.text.popup_block); + } else { + if (Object.isUndefined(win.name)) { + win.name = name; + } + if (Object.isUndefined(win.opener)) { + win.opener = self; + } + win.focus(); + } +}; + +/** + * Use DOM manipulation to un-block images that had been redirected. + */ +IMP.unblockImages = function(p, message) +{ + var tmp; + + if (!p) { + return true; + } + + $(p).select('[blocked]').each(function(elt) { + var src = decodeURIComponent(elt.readAttribute('blocked')); + if (elt.hasAttribute('src')) { + elt.writeAttribute('src', src); + } else if (elt.hasAttribute('background')) { + elt.writeAttribute('background', src); + } else if (elt.style.backgroundImage) { + elt.setStyle({ backgroundImage: 'url(' + src + ')' }); + } + }); + + message = $(message); + if (message) { + tmp = message.up(); + message.remove(); + if (!tmp.childElements().size()) { + tmp = tmp.up('TABLE.mimeStatusMessage'); + if (tmp) { + tmp.remove(); + } + } + } + + // On success return false to stop event propagation. + return false; +}; + document.observe('dom:loaded', function() { - $('menuform').observe('change', IMP.menuFolderSubmit.bind(IMP)); - $('openfoldericon').down().observe('click', IMP.menuFolderSubmit.bind(IMP, true)); + // If menu is present, attach event handlers to folder switcher. + var tmp = $('menuform'); + if (tmp) { + tmp.observe('change', IMP.menuFolderSubmit.bind(IMP)); + $('openfoldericon').down().observe('click', IMP.menuFolderSubmit.bind(IMP, true)); + } }); diff --git a/imp/js/src/popup.js b/imp/js/src/popup.js deleted file mode 100644 index f6c37d212..000000000 --- a/imp/js/src/popup.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * IMP Popup JavaScript. - * - * Provides the javascript to open popup windows. - * This file should be included via Horde::addScriptFile(). - * Requires prototypejs 1.6.0.2+ - * - * See the enclosed file COPYING for license information (GPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. - */ - -/** - * Open a popup window. - * - * @param string $url The URL to open in the popup window. - * @param integer $width The width of the popup window. (Default: 600 px) - * @param integer $height The height of the popup window. (Default: 500 px) - * @param string $args Any additional args to pass to the script. - * (Default: no args) - */ -function popup_imp(url, width, height, args) -{ - var q, win, - params = $H(), - name = new Date().getTime(); - - height = Math.min(screen.height - 75, height || 500); - width = Math.min(screen.width - 75, width || 600); - - q = url.indexOf('?'); - if (q != -1) { - params = $H(url.toQueryParams()); - url = url.substring(0, q); - } - - if (args) { - $H(args.toQueryParams()).each(function(a) { - params.set(a.key, unescape(a.value)); - }); - } - params.set('uniq', name); - - win = window.open(url + '?' + params.toQueryString(), name, 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',left=0,top=0'); - if (!win) { - alert(IMP.text.popup_block); - } else { - if (Object.isUndefined(win.name)) { - win.name = name; - } - if (Object.isUndefined(win.opener)) { - win.opener = self; - } - win.focus(); - } -} diff --git a/imp/js/src/unblockImages.js b/imp/js/src/unblockImages.js deleted file mode 100644 index b04fecd92..000000000 --- a/imp/js/src/unblockImages.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Use DOM manipulation to un-block images that had been redirected. - */ - -var IMP = window.IMP || {}; - -IMP.unblockImages = function(parent, message) -{ - var tmp; - - if (!parent) { - return true; - } - - $(parent).select('[blocked]').each(function(elt) { - var src = decodeURIComponent(elt.readAttribute('blocked')); - if (elt.hasAttribute('src')) { - elt.writeAttribute('src', src); - } else if (elt.hasAttribute('background')) { - elt.writeAttribute('background', src); - } else if (elt.style.backgroundImage) { - elt.setStyle({ backgroundImage: 'url(' + src + ')' }); - } - }); - - message = $(message); - if (message) { - tmp = message.up(); - message.remove(); - if (!tmp.childElements().size()) { - tmp = tmp.up('TABLE.mimeStatusMessage'); - if (tmp) { - tmp.remove(); - } - } - } - - // On success return false to stop event propagation. - return false; -}; diff --git a/imp/js/unblockImages.js b/imp/js/unblockImages.js deleted file mode 100644 index a2ef8a548..000000000 --- a/imp/js/unblockImages.js +++ /dev/null @@ -1 +0,0 @@ -var IMP=window.IMP||{};IMP.unblockImages=function(b,c){var a;if(!b){return true}$(b).select("[blocked]").each(function(d){var e=decodeURIComponent(d.readAttribute("blocked"));if(d.hasAttribute("src")){d.writeAttribute("src",e)}else{if(d.hasAttribute("background")){d.writeAttribute("background",e)}else{if(d.style.backgroundImage){d.setStyle({backgroundImage:"url("+e+")"})}}}});c=$(c);if(c){a=c.up();c.remove();if(!a.childElements().size()){a=a.up("TABLE.mimeStatusMessage");if(a){a.remove()}}}return false}; \ No newline at end of file diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index e63829572..4094b71d6 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -419,7 +419,7 @@ class IMP $GLOBALS['prefs']->getValue('compose_popup') && $GLOBALS['browser']->hasFeature('javascript')) { Horde::addScriptFile('prototype.js', 'horde', true); - Horde::addScriptFile('popup.js', 'imp', true); + Horde::addScriptFile('imp.js', 'imp', true); if (isset($args['to'])) { $args['to'] = addcslashes($args['to'], '\\"'); } @@ -1339,7 +1339,7 @@ class IMP } /** - * Output the javascript needed to call the popup_imp JS function. + * Output the javascript needed to call the IMP popup JS function. * * @param string $url The IMP page to load. * @param array $params An array of paramters to pass to the URL. @@ -1351,7 +1351,7 @@ class IMP static public function popupIMPString($url, $params = array(), $width = 700, $height = 650) { - return "popup_imp('" . Horde::applicationUrl($url) . "'," . $width . "," . $height . ",'" . $GLOBALS['browser']->escapeJSCode(str_replace('+', '%20', substr(Util::addParameter('', $params, null, false), 1))) . "');"; + return "IMP.popup('" . Horde::applicationUrl($url) . "'," . $width . "," . $height . ",'" . $GLOBALS['browser']->escapeJSCode(str_replace('+', '%20', substr(Util::addParameter('', $params, null, false), 1))) . "');"; } /** diff --git a/imp/lib/Mime/Viewer/html.php b/imp/lib/Mime/Viewer/html.php index d0f2278ed..bf01cd228 100644 --- a/imp/lib/Mime/Viewer/html.php +++ b/imp/lib/Mime/Viewer/html.php @@ -219,7 +219,7 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html if (!$view_img && !$addr_check) { $data .= Util::bufferOutput(array('Horde', 'addScriptFile'), 'prototype.js', 'horde', true) . - Util::bufferOutput(array('Horde', 'addScriptFile'), 'unblockImages.js', 'imp', true); + Util::bufferOutput(array('Horde', 'addScriptFile'), 'imp.js', 'imp', true); $cleanhtml['status'][] = array( 'icon' => Horde::img('mime/image.png'), diff --git a/imp/lib/Mime/Viewer/smime.php b/imp/lib/Mime/Viewer/smime.php index a20c8599e..df9f7a783 100644 --- a/imp/lib/Mime/Viewer/smime.php +++ b/imp/lib/Mime/Viewer/smime.php @@ -72,7 +72,7 @@ class IMP_Horde_Mime_Viewer_smime extends Horde_Mime_Viewer_Driver /* We need to insert JavaScript code now if S/MIME support is * active. */ Horde::addScriptFile('prototype.js', 'horde', true); - Horde::addScriptFile('popup.js', 'imp', true); + Horde::addScriptFile('imp.js', 'imp', true); } switch ($this->_mimepart->getType()) { diff --git a/imp/mailbox.php b/imp/mailbox.php index 3ed786843..f15d37255 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -413,7 +413,7 @@ if ($open_compose_window === false) { if (!isset($options)) { $options = array(); } - Horde::addScriptFile('popup.js', 'imp', true); + Horde::addScriptFile('imp.js', 'imp', true); $notification->push(IMP::popupIMPString('compose.php', array_merge(array('popup' => 1), $options, IMP::getComposeArgs())), 'javascript'); } diff --git a/imp/message-dimp.php b/imp/message-dimp.php index f027625b5..111ecd19c 100644 --- a/imp/message-dimp.php +++ b/imp/message-dimp.php @@ -71,8 +71,7 @@ $scripts = array( array('ContextSensitive.js', 'imp', true), array('fullmessage-dimp.js', 'imp', true), array('compose-dimp.js', 'imp', true), - array('unblockImages.js', 'imp', true), - array('popup.js', 'imp', true) + array('imp.js', 'imp', true) ); DIMP::header($show_msg_result['subject'], $scripts); diff --git a/imp/message.php b/imp/message.php index e61d17d14..598176261 100644 --- a/imp/message.php +++ b/imp/message.php @@ -725,7 +725,7 @@ $m_template->set('msgtext', $msgtext); /* Output message page now. */ Horde::addScriptFile('prototype.js', 'horde', true); -Horde::addScriptFile('popup.js', 'imp', true); +Horde::addScriptFile('imp.js', 'imp', true); Horde::addScriptFile('message.js', 'imp', true); require IMP_TEMPLATES . '/common-header.inc'; if (IMP::$printMode) { diff --git a/imp/pgp.php b/imp/pgp.php index ce20f9e7c..3076ea553 100644 --- a/imp/pgp.php +++ b/imp/pgp.php @@ -288,7 +288,7 @@ $t = new IMP_Template(); $t->setOption('gettext', true); if ($prefs->getValue('use_pgp')) { Horde::addScriptFile('prototype.js', 'horde', true); - Horde::addScriptFile('popup.js', 'imp', true); + Horde::addScriptFile('imp.js', 'imp', true); $t->set('pgpactive', true); $t->set('overview-help', Help::link('imp', 'pgp-overview')); $t->set('attach_pubkey_notlocked', !$prefs->isLocked('pgp_attach_pubkey')); diff --git a/imp/smime.php b/imp/smime.php index 26f1ec2a0..07ca1083e 100644 --- a/imp/smime.php +++ b/imp/smime.php @@ -232,7 +232,7 @@ $t = new IMP_Template(); $t->setOption('gettext', true); $t->set('use_smime_help', Help::link('imp', 'smime-overview')); if (!is_a($openssl_check, 'PEAR_Error') && $prefs->getValue('use_smime')) { - Horde::addScriptFile('popup.js', 'imp', true); + Horde::addScriptFile('imp.js', 'imp', true); $t->set('smimeactive', true); $t->set('manage_pubkey-help', Help::link('imp', 'smime-manage-pubkey')); diff --git a/imp/templates/javascript_defs.php b/imp/templates/javascript_defs.php index d0cf3dfd0..a9d67e8a1 100644 --- a/imp/templates/javascript_defs.php +++ b/imp/templates/javascript_defs.php @@ -59,7 +59,7 @@ $code = array( /* Strings used in search.js */ 'search_select' => _("Please select at least one folder to search."), - /* Strings used in popup.js */ + /* Strings used in imp.js */ 'popup_block' => _("A popup window could not be opened. Perhaps you have set your browser to block popup windows?"), /* Strings used in login.js */ diff --git a/imp/templates/pgp/pgp.html b/imp/templates/pgp/pgp.html index d0cd06035..acef4c2a3 100644 --- a/imp/templates/pgp/pgp.html +++ b/imp/templates/pgp/pgp.html @@ -52,7 +52,7 @@
Key import is not available. You have no address book defined to add your contacts.
-
+
@@ -128,7 +128,7 @@

- +

diff --git a/imp/templates/smime/smime.html b/imp/templates/smime/smime.html index 4b0317d43..9cc83d64a 100644 --- a/imp/templates/smime/smime.html +++ b/imp/templates/smime/smime.html @@ -44,7 +44,7 @@ Key import is not available. You have no address book defined to add your contacts. -

+

@@ -78,7 +78,7 @@ Certificate import is not available. File upload is not enabled on this server. -

+