Fix image hiding/showing in HTML messages.
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 20 Feb 2009 23:47:35 +0000 (16:47 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 20 Feb 2009 23:47:35 +0000 (16:47 -0700)
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
imp/js/src/imp.js
imp/js/src/message.js
imp/lib/Mime/Viewer/html.php
imp/themes/ie6_or_less-dimp.css
imp/themes/ie6_or_less.css
imp/themes/ie7-dimp.css
imp/themes/ie7.css
imp/themes/rtl.css
imp/themes/screen.css

index d6309ef..c1ae197 100644 (file)
@@ -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')) {
index 660d6df..e9f7674 100644 (file)
@@ -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() {
index 661ecff..e0304c8 100644 (file)
@@ -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 } });
index bf01cd2..a3c8522 100644 (file)
@@ -198,7 +198,7 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html
 
         if ($inline) {
             /* Put div around message. */
-            $data = '<div id="html-message">' . $data . '</div>';
+            $data = '<div class="htmlMessage">' . $data . '</div>';
         }
 
         /* 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) . '</a>'
+                        Horde::link(Util::addParameter($url, 'view_html_images', 1), '', 'unblockImageLink') . String::convertCharset(_("Show Images?"), $charset, $msg_charset) . '</a>'
                     )
                 );
 
index 461198f..b986a3d 100644 (file)
@@ -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;
 }
index bbcf555..4f6a2eb 100644 (file)
@@ -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;
 }
index d8b7061..0ce5452 100644 (file)
@@ -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;
 }
index 5fb6b91..22efa61 100644 (file)
@@ -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;
 }
index cb7ff0e..81f0c5e 100644 (file)
@@ -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;
 }
index 5e8f1ee..fb8cfd3 100644 (file)
@@ -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;