From 0deaab7c1acc0df31c8985130d98aa38bf12e01d Mon Sep 17 00:00:00 2001 From: str4d Date: Thu, 12 Jul 2012 13:07:48 +0000 Subject: [PATCH] Improvements to resizing JS in iframed app container pages --- apps/routerconsole/jsp/i2ptunnelmgr.jsp | 16 ++++++++++------ apps/routerconsole/jsp/torrents.jsp | 13 ++++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/apps/routerconsole/jsp/i2ptunnelmgr.jsp b/apps/routerconsole/jsp/i2ptunnelmgr.jsp index dc388f28c..5db19465f 100644 --- a/apps/routerconsole/jsp/i2ptunnelmgr.jsp +++ b/apps/routerconsole/jsp/i2ptunnelmgr.jsp @@ -21,16 +21,20 @@ var failMessage = "
<%=intl._("Router is down")%><\/b>"; function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); } function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); } - function resizeFrame(f) { - var body = f.contentWindow.document.body, - html = f.contentWindow.document.documentElement; - f.style.height = body.scrollHeight + "px"; + function injectClass(f) { + f.className += ' iframed'; + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + doc.body.className += ' iframed'; + doc.getElementsByClassName('panel')[0].className += ' iframed'; + } + function resizeFrame(f) { + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + f.style.height = doc.body.offsetHeight + "px"; } - function injectClass(f) { f.contentWindow.document.body.setAttribute('class', 'iframed'); } function setupFrame() { f = document.getElementById("i2ptunnelframe"); - resizeFrame(f); injectClass(f); + resizeFrame(f); } diff --git a/apps/routerconsole/jsp/torrents.jsp b/apps/routerconsole/jsp/torrents.jsp index 690be49a5..ed052ace0 100644 --- a/apps/routerconsole/jsp/torrents.jsp +++ b/apps/routerconsole/jsp/torrents.jsp @@ -21,12 +21,19 @@ var failMessage = "
<%=intl._("Router is down")%><\/b>"; function requestAjax1() { ajax("/xhr1.jsp?requestURI=<%=request.getRequestURI()%>", "xhr", <%=intl.getRefresh()%>000); } function initAjax() { setTimeout(requestAjax1, <%=intl.getRefresh()%>000); } - function resizeFrame(f) { f.style.height = f.contentWindow.document.body.scrollHeight + "px"; } - function injectClass(f) { f.contentWindow.document.body.setAttribute('class', 'iframed'); } + function injectClass(f) { + f.className += ' iframed'; + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + doc.body.className += ' iframed'; + } + function resizeFrame(f) { + var doc = 'contentDocument' in f? f.contentDocument : f.contentWindow.document; + f.style.height = doc.body.offsetHeight + "px"; + } function setupFrame() { f = document.getElementById("i2psnarkframe"); - resizeFrame(f); injectClass(f); + resizeFrame(f); }