changeset 171:cede18c118c9

js (common): added fitHeightToContent to fit <iframe> to its content + <iframe> CSS
author Goffi <goffi@goffi.org>
date Fri, 25 Jan 2019 11:28:41 +0100
parents 6c251da9a4f3
children 4a03d0a6839b
files sat_templates/templates/default/static/common.js sat_templates/templates/default/static/styles.css
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat_templates/templates/default/static/common.js	Sat Jan 19 11:49:18 2019 +0100
+++ b/sat_templates/templates/default/static/common.js	Fri Jan 25 11:28:41 2019 +0100
@@ -7,7 +7,7 @@
      * @param type(string): "session" or "storage"
      * @return (boolean): true if requested storage is available
      */
-    console.assert(type == 'session' || type == 'storage', "bad storage type (%s)", type);
+    console.assert(type === 'session' || type === 'storage', "bad storage type (%s)", type);
     const var_name = '__' + type + '_storage_available';
     var available = window[var_name];
     if (available === undefined) {
@@ -167,3 +167,9 @@
     new_element = template.content.firstChild;
     return new_element;
     }
+
+
+function fitHeightToContent(elt) {
+    /* adapt height to content, specially useful for iframe */
+    elt.style.height = elt.contentWindow.document.body.scrollHeight + 80 + 'px';
+}
--- a/sat_templates/templates/default/static/styles.css	Sat Jan 19 11:49:18 2019 +0100
+++ b/sat_templates/templates/default/static/styles.css	Fri Jan 25 11:28:41 2019 +0100
@@ -52,6 +52,13 @@
 	padding: 0.2em;
 }
 
+iframe {
+    border: 0;
+    width: 100%;
+    /* this value is used when js is not enabled */
+    height: 100%;
+}
+
 #main_area {
     flex: 1;
     display: flex;