From 58ab073916586f1ff41b404d37040f38d6cfd0e7 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 20 Feb 2009 16:47:35 -0700 Subject: [PATCH] Fix image hiding/showing in HTML messages. Image show link should only work for the current MIME part, not all image MIME parts. Removes the potentially duplicate DOM ID 'html-message', which might occur if more than 1 viewable HTML part was in a message. --- imp/js/src/DimpCore.js | 4 +++- imp/js/src/imp.js | 27 ++++++--------------------- imp/js/src/message.js | 2 ++ imp/lib/Mime/Viewer/html.php | 11 ++++------- imp/themes/ie6_or_less-dimp.css | 2 +- imp/themes/ie6_or_less.css | 2 +- imp/themes/ie7-dimp.css | 2 +- imp/themes/ie7.css | 2 +- imp/themes/rtl.css | 2 +- imp/themes/screen.css | 12 ++++++------ 10 files changed, 26 insertions(+), 40 deletions(-) diff --git a/imp/js/src/DimpCore.js b/imp/js/src/DimpCore.js index d6309ef47..c1ae197b6 100644 --- a/imp/js/src/DimpCore.js +++ b/imp/js/src/DimpCore.js @@ -489,7 +489,9 @@ DimpCore = { default: // CSS class based matching - if (elt.match('SPAN.toggleQuoteShow')) { + if (elt.hasClassName('unblockImageLink')) { + IMP.unblockImages(e); + } else if (elt.match('SPAN.toggleQuoteShow')) { [ elt, elt.next() ].invoke('toggle'); Effect.BlindDown(elt.next(1), { duration: 0.2, queue: { position: 'end', scope: 'showquote', limit: 2 } }); } else if (elt.match('SPAN.toggleQuoteHide')) { diff --git a/imp/js/src/imp.js b/imp/js/src/imp.js index 660d6df33..e9f76744b 100644 --- a/imp/js/src/imp.js +++ b/imp/js/src/imp.js @@ -64,17 +64,13 @@ IMP.popup = function(url, width, height, args) }; /** - * Use DOM manipulation to un-block images that had been redirected. + * Use DOM manipulation to un-block images. */ -IMP.unblockImages = function(p, message) +IMP.unblockImages = function(e) { - var tmp; + var elt = e.element().up('TABLE.mimeStatusMessage'); - if (!p) { - return true; - } - - $(p).select('[blocked]').each(function(elt) { + elt.next('.htmlMessage').select('[blocked]').each(function(elt) { var src = decodeURIComponent(elt.readAttribute('blocked')); if (elt.hasAttribute('src')) { elt.writeAttribute('src', src); @@ -85,20 +81,9 @@ IMP.unblockImages = function(p, message) } }); - message = $(message); - if (message) { - tmp = message.up(); - message.remove(); - if (!tmp.childElements().size()) { - tmp = tmp.up('TABLE.mimeStatusMessage'); - if (tmp) { - tmp.remove(); - } - } - } + Effect.Fade(elt, { duration: 0.6, afterFinish: function() { elt.remove(); } }); - // On success return false to stop event propagation. - return false; + e.stop(); }; document.observe('dom:loaded', function() { diff --git a/imp/js/src/message.js b/imp/js/src/message.js index 661ecff3f..e0304c860 100644 --- a/imp/js/src/message.js +++ b/imp/js/src/message.js @@ -179,6 +179,8 @@ var ImpMessage = { } else if (elt.hasClassName('notspamAction')) { this.submit('notspam_report'); } + } else if (elt.hasClassName('unblockImageLink')) { + IMP.unblockImages(e); } else if (elt.match('SPAN.toggleQuoteShow')) { [ elt, elt.next() ].invoke('toggle'); Effect.BlindDown(elt.next(1), { duration: 0.2, queue: { position: 'end', scope: 'showquote', limit: 2 } }); diff --git a/imp/lib/Mime/Viewer/html.php b/imp/lib/Mime/Viewer/html.php index bf01cd228..a3c852200 100644 --- a/imp/lib/Mime/Viewer/html.php +++ b/imp/lib/Mime/Viewer/html.php @@ -198,7 +198,7 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html if ($inline) { /* Put div around message. */ - $data = '
' . $data . '
'; + $data = '
' . $data . '
'; } /* Only display images if specifically allowed by user. */ @@ -208,10 +208,7 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html preg_match($this->_img_regex, $data)) { /* Make sure the URL parameters are correct for the current * message. */ - $url = Util::removeParameter(Horde::selfUrl(true), array('index')); - if ($inline) { - $url = Util::removeParameter($url, array('actionID')); - } + $url = Util::removeParameter(Horde::selfUrl(true), array('actionID', 'index')); $url = Util::addParameter($url, 'index', $this->_params['contents']->getIndex()); $view_img = Util::getFormData('view_html_images'); @@ -221,12 +218,12 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html $data .= Util::bufferOutput(array('Horde', 'addScriptFile'), 'prototype.js', 'horde', true) . Util::bufferOutput(array('Horde', 'addScriptFile'), 'imp.js', 'imp', true); + // Unblock javascript code in js/src/imp.js $cleanhtml['status'][] = array( 'icon' => Horde::img('mime/image.png'), - 'id' => 'impblockimages', 'text' => array( String::convertCharset(_("Images have been blocked to protect your privacy."), $charset, $msg_charset), - Horde::link(Util::addParameter($url, 'view_html_images', 1), '', '', '', 'return IMP.unblockImages(' . (!$inline ? 'document.body' : '$(\'html-message\')') . ', \'impblockimages\');', '', '', $inline ? array() : array('style' => 'color:blue')) . String::convertCharset(_("Show Images?"), $charset, $msg_charset) . '' + Horde::link(Util::addParameter($url, 'view_html_images', 1), '', 'unblockImageLink') . String::convertCharset(_("Show Images?"), $charset, $msg_charset) . '' ) ); diff --git a/imp/themes/ie6_or_less-dimp.css b/imp/themes/ie6_or_less-dimp.css index 461198fed..b986a3dd9 100644 --- a/imp/themes/ie6_or_less-dimp.css +++ b/imp/themes/ie6_or_less-dimp.css @@ -58,6 +58,6 @@ form#compose { } /* Fixes li & ol list numbering issues in HTML messages. */ -#html-message ul li, #html-message ol li { +.htmlMessage ul li, .htmlMessage ol li { margin-left: 2em; } diff --git a/imp/themes/ie6_or_less.css b/imp/themes/ie6_or_less.css index bbcf55593..4f6a2eb08 100644 --- a/imp/themes/ie6_or_less.css +++ b/imp/themes/ie6_or_less.css @@ -3,6 +3,6 @@ */ /* Fixes li & ol list numbering issues in HTML messages. */ -#html-message ul li, #html-message ol li { +.htmlMessage ul li, .htmlMessage ol li { margin-left: 2em; } diff --git a/imp/themes/ie7-dimp.css b/imp/themes/ie7-dimp.css index d8b7061cf..0ce545285 100644 --- a/imp/themes/ie7-dimp.css +++ b/imp/themes/ie7-dimp.css @@ -50,6 +50,6 @@ form#compose { } /* Fixes li & ol list numbering issues in HTML messages. */ -#html-message ul li , #html-message ol li { +.htmlMessage ul li , .htmlMessage ol li { margin-left: 2em; } diff --git a/imp/themes/ie7.css b/imp/themes/ie7.css index 5fb6b911c..22efa618c 100644 --- a/imp/themes/ie7.css +++ b/imp/themes/ie7.css @@ -3,6 +3,6 @@ */ /* Fixes li & ol list numbering issues in HTML messages. */ -#html-message ul li, #html-message ol li { +.htmlMessage ul li, .htmlMessage ol li { margin-left: 2em; } diff --git a/imp/themes/rtl.css b/imp/themes/rtl.css index cb7ff0ed9..81f0c5ebf 100644 --- a/imp/themes/rtl.css +++ b/imp/themes/rtl.css @@ -31,7 +31,7 @@ } /* Based on the Mozilla default defintions */ -#html-message blockquote[type="cite"] { +.htmlMessage blockquote[type="cite"] { padding-left: 0; padding-right: 1em; } diff --git a/imp/themes/screen.css b/imp/themes/screen.css index 5e8f1ee03..fb8cfd3a0 100644 --- a/imp/themes/screen.css +++ b/imp/themes/screen.css @@ -164,29 +164,29 @@ form#search div { } /* Based on the Mozilla default definitions */ -#html-message td { +.htmlMessage td { padding: 0; } -#html-message ul { +.htmlMessage ul { display: block; list-style-type: disc; margin: 1em 0; -moz-padding-start: 40px; } -#html-message ol { +.htmlMessage ol { display: block; list-style-type: decimal; margin: 1em 0; -moz-padding-start: 40px; } -#html-message p { +.htmlMessage p { display: block; margin: 1em 0; } -#html-message blockquote { +.htmlMessage blockquote { margin: 1em 40px; } -#html-message blockquote[type="cite"] { +.htmlMessage blockquote[type="cite"] { margin-left: 0; margin-right: 0; padding-left: 1em; -- 2.11.0