Mercurial > libervia-templates
diff sat_templates/templates/default/static/common.js @ 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 | 178f55b825b7 |
children | 0e69b5843c2f |
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'; +}