From ae24183bc93ff2539ca483924bbaff4af999ceb8 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 7 Oct 2009 03:04:26 -0600 Subject: [PATCH] More improvements to HTML IFRAME viewing --- imp/js/imp.js | 19 ++++++++++++------- imp/lib/Mime/Viewer/Html.php | 2 +- imp/themes/screen.css | 8 +------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/imp/js/imp.js b/imp/js/imp.js index b503d5255..1f0cc27f6 100644 --- a/imp/js/imp.js +++ b/imp/js/imp.js @@ -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' }); } }; diff --git a/imp/lib/Mime/Viewer/Html.php b/imp/lib/Mime/Viewer/Html.php index de2780680..23a9a7f16 100644 --- a/imp/lib/Mime/Viewer/Html.php +++ b/imp/lib/Mime/Viewer/Html.php @@ -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'] = '
' . + $data['data'] = '' . Horde_Util::bufferOutput(array('Horde', 'addScriptFile'), 'imp.js', 'imp'); $data['type'] = 'text/html; charset=UTF-8'; diff --git a/imp/themes/screen.css b/imp/themes/screen.css index f0a681e73..1fce8e7f1 100644 --- a/imp/themes/screen.css +++ b/imp/themes/screen.css @@ -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 */ -- 2.11.0