More improvements to HTML IFRAME viewing
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 7 Oct 2009 09:04:26 +0000 (03:04 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 7 Oct 2009 18:30:35 +0000 (12:30 -0600)
imp/js/imp.js
imp/lib/Mime/Viewer/Html.php
imp/themes/screen.css

index b503d52..1f0cc27 100644 (file)
@@ -28,10 +28,11 @@ document.observe('dom:loaded', function() {
      */
     IMP.unblockImages = function(e)
     {
-        var callback, imgs,
+        var callback,
             elt = e.element().up('TABLE.mimeStatusMessage'),
-            iframe = elt.up().next('.htmlMsgData').down('IFRAME'),
+            iframe = elt.up().next('.htmlMsgData'),
             iframeid = iframe.readAttribute('id'),
+            imgload = false,
             s = new Selector('[htmlimgblocked]');
 
         e.stop();
@@ -51,14 +52,14 @@ document.observe('dom:loaded', function() {
         }
 
         callback = this.imgOnload.bind(this, iframeid);
-        imgs = s.findElements(iframe.contentWindow.document);
-        IMP.imgs[iframeid] = imgs.size();
 
-        imgs.each(function(img) {
-            img.onload = callback;
+        s.findElements(iframe.contentWindow.document).each(function(img) {
             var src = decodeURIComponent(img.getAttribute('htmlimgblocked'));
             if (img.getAttribute('src')) {
+                img.onload = callback;
+                ++IMP.imgs[iframeid];
                 img.setAttribute('src', src);
+                imgload = true;
             } else if (img.getAttribute('background')) {
                 img.setAttribute('background', src);
             } else if (img.style.backgroundImage) {
@@ -70,6 +71,10 @@ document.observe('dom:loaded', function() {
         // on the page uses the same expression, it will break the next time
         // it is used.
         delete Selector._cache['[htmlimgblocked]'];
+
+        if (!imgload) {
+            this.iframeResize(iframeid);
+        }
     };
 
     IMP.imgOnload = function(id)
@@ -97,7 +102,7 @@ document.observe('dom:loaded', function() {
         if (!defer && Prototype.Browser.IE) {
             this.iframeResize.bind(this, id, true).defer();
         } else {
-            id.up().setStyle({ height: Math.max(id.contentWindow.document.body.scrollHeight, id.contentWindow.document.lastChild.scrollHeight) + 'px' });
+            id.setStyle({ height: Math.max(id.contentWindow.document.body.offsetHeight, id.contentWindow.document.lastChild.offsetHeight) + 'px' });
         }
     };
 
index de27806..23a9a7f 100644 (file)
@@ -118,7 +118,7 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
         $uid = 'htmldata_' . uniqid(mt_rand());
 
         $data['js'] = array('IMP.iframeInject("' . $uid . '", ' . Horde_Serialize::serialize($data['data'], Horde_Serialize::JSON, $this->_mimepart->getCharset()) . ')');
-        $data['data'] = '<DIV class="htmlMsgData"><IFRAME id="' . $uid . '" src="javascript:false" frameborder="0"></IFRAME></DIV>' .
+        $data['data'] = '<IFRAME class="htmlMsgData" id="' . $uid . '" src="javascript:false" frameborder="0"></IFRAME>' .
             Horde_Util::bufferOutput(array('Horde', 'addScriptFile'), 'imp.js', 'imp');
         $data['type'] = 'text/html; charset=UTF-8';
 
index f0a681e..1fce8e7 100644 (file)
@@ -226,14 +226,8 @@ span.trashImg {
 
 /* Style for HTML data iframe. */
 .htmlMsgData {
-    margin: 5px 0;
-    border: 0;
+    margin: 2px 0;
     width: 100%;
-    overflow: hidden;
-}
-.htmlMsgData IFRAME {
-    width: 100%;
-    height: 100%;
 }
 
 /* Compose view */