From be7aa991d78b0bebccd4c3c1a16cb6054ea31ada Mon Sep 17 00:00:00 2001 From: str4d Date: Mon, 16 Jul 2012 23:39:44 +0000 Subject: [PATCH] Consolidated the common iframing JS into /js/iframed.js --- apps/routerconsole/jsp/dns.jsp | 38 +------------------------ apps/routerconsole/jsp/i2ptunnelmgr.jsp | 38 ++----------------------- apps/routerconsole/jsp/js/iframed.js | 38 +++++++++++++++++++++++++ apps/routerconsole/jsp/torrents.jsp | 38 +------------------------ apps/routerconsole/jsp/webmail.jsp | 38 +------------------------ 5 files changed, 44 insertions(+), 146 deletions(-) create mode 100644 apps/routerconsole/jsp/js/iframed.js diff --git a/apps/routerconsole/jsp/dns.jsp b/apps/routerconsole/jsp/dns.jsp index ab29f4008..63b1f643e 100644 --- a/apps/routerconsole/jsp/dns.jsp +++ b/apps/routerconsole/jsp/dns.jsp @@ -17,47 +17,11 @@ <%@include file="css.jsi" %> <%=intl.title("addressbook")%> + + diff --git a/apps/routerconsole/jsp/js/iframed.js b/apps/routerconsole/jsp/js/iframed.js new file mode 100644 index 000000000..05d14b896 --- /dev/null +++ b/apps/routerconsole/jsp/js/iframed.js @@ -0,0 +1,38 @@ +function injectClass(f) { + f.className += ' iframed'; + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + doc.body.className += ' iframed'; +} +function resizeFrame(f) { + // offsetHeight returns the height of the visible area for an object, in pixels. + // The value contains the height with the padding, scrollBar, and the border, + // but does not include the margin. Therefore, any content within the iframe + // should have no margins at the very top or very bottom to avoid a scrollbar. + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + var totalHeight = doc.body.offsetHeight; + + // Detect if horizontal scrollbar is present, and add its width to height if so. + // This prevents a vertical scrollbar appearing when the min-width is passed. + // FIXME: How to detect horizontal scrollbar in iframe? Always apply for now. + if (true) { + // Create the measurement node + var scrollDiv = document.createElement("div"); + scrollDiv.className = "scrollbar-measure"; + scrollDiv.style.width = "100px"; + scrollDiv.style.height = "100px"; + scrollDiv.style.overflow = "scroll"; + scrollDiv.style.position = "absolute"; + scrollDiv.style.top = "-9999px"; + document.body.appendChild(scrollDiv); + + // Get the scrollbar width + var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; + totalHeight += scrollbarWidth; + + // Delete the div + document.body.removeChild(scrollDiv); + } + + f.style.height = totalHeight + "px"; +} + diff --git a/apps/routerconsole/jsp/torrents.jsp b/apps/routerconsole/jsp/torrents.jsp index 665f03985..a76b0e78b 100644 --- a/apps/routerconsole/jsp/torrents.jsp +++ b/apps/routerconsole/jsp/torrents.jsp @@ -17,47 +17,11 @@ <%@include file="css.jsi" %> <%=intl.title("torrents")%> + +