diff --git a/allure-commandline/custom-iframe-resize.js b/allure-commandline/custom-iframe-resize.js new file mode 100644 index 000000000..bfdf60df8 --- /dev/null +++ b/allure-commandline/custom-iframe-resize.js @@ -0,0 +1,76 @@ +;(function () { + 'use strict'; + // Iframe resizer + function measureIframe(iframe) { + try { + var doc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document); + if (!doc) return; + var body = doc.body, html = doc.documentElement; + var h = Math.max( + (body && body.scrollHeight) || 0, + (html && html.scrollHeight) || 0, + (body && body.offsetHeight) || 0, + (html && html.offsetHeight) || 0 + ); + iframe.style.width = '100%'; + var fh = Math.max(h || 0, 20); + if (iframe.style.height !== fh + 'px') iframe.style.height = fh + 'px'; + } catch (e) { + // ignore cross-origin access errors + } + } + + function measureAll() { + try { + var all = document.querySelectorAll('.attachment__iframe'); + for (var i = 0; i < all.length; i++) { + measureIframe(all[i]); + } + } catch (e) {} + } + + function attachListeners() { + try { + var iframes = document.querySelectorAll('.attachment__iframe'); + for (var i = 0; i < iframes.length; i++) { + var f = iframes[i]; + if (f.dataset._resizerAttached) continue; + f.dataset._resizerAttached = '1'; + try { + f.addEventListener('load', function (ev) { + measureIframe(ev.currentTarget); + // transient polling in case the iframe applies late layout + var tries = 0, max = 6; + var iv = setInterval(function () { try { measureIframe(ev.currentTarget); } catch (e) {} tries++; if (tries >= max) clearInterval(iv); }, 400); + }); + } catch (e) {} + } + } catch (e) {} + } + + function observeDom() { + try { + if (document.body) { + var mo = new MutationObserver(function (entries) { + entries.forEach(function (en) { + try { + if (en.addedNodes && en.addedNodes.length) { + attachListeners(); + measureAll(); + } + } catch (e) {} + }); + }); + mo.observe(document.body, { childList: true, subtree: true }); + } + } catch (e) {} + } + + // initial wiring + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', function () { attachListeners(); observeDom(); measureAll(); }); + } else { + attachListeners(); observeDom(); measureAll(); + } + +})(); diff --git a/allure-commandline/custom-styles.css b/allure-commandline/custom-styles.css new file mode 100644 index 000000000..0c738a41d --- /dev/null +++ b/allure-commandline/custom-styles.css @@ -0,0 +1,68 @@ +.attachment__iframe { + /* Allow JS to set an explicit pixel height based on the attachment HTML content.*/ + width: 100% !important; + border: none !important; + height: auto; /* inline height set by JS will apply */ +} + +.attachment__iframe_fullscreen { + height: 85vh !important; +} + +.attachment__iframe-container { + overflow: visible !important; + padding: 0 !important; + margin: 0 !important; +} + +/* Make the attachment panel use full available width and remove inner gutters */ +.test-result__content, .testcase__content, .details-content { + padding: 0 !important; +} + +/* Presentation mode: only when body.presentation-mode is present */ +body.presentation-mode .side-nav, +body.presentation-mode .app__header, +body.presentation-mode .app__nav, +body.presentation-mode .side-nav__head, +body.presentation-mode .side-nav__menu { + display: none !important; + visibility: hidden !important; + width: 0 !important; + height: 0 !important; + padding: 0 !important; + margin: 0 !important; +} + +body.presentation-mode .app { display: block !important; } +body.presentation-mode .app__content { margin-left: 0 !important; width: 100% !important; } + +/* Make the attachment iframe expand to fill the right-hand content panel (not fullscreen). + The JS will set an explicit height based on the attachment's HTML content*/ +body.presentation-mode .attachment__iframe { + position: relative !important; + display: block !important; + width: 100% !important; + height: auto !important; /* explicit px height will be applied by JS */ + max-height: calc(100vh - 120px) !important; /* leave space for header/toolbars */ + z-index: 999 !important; + border: none !important; + background: #fff !important; +} + +/* Hide other panels that might overlay the iframe */ +body.presentation-mode .popup, body.presentation-mode #popup, body.presentation-mode .modal__background, body.presentation-mode .modal__window { display: none !important; } + +/* Small injected button to manually expand/collapse HTML attachments in the panel */ +.copilot-expand-btn { + margin-left: 6px; + padding: 4px 8px; + font-size: 12px; + border-radius: 3px; + background: #2b6cb0; + color: #fff; + border: none; + cursor: pointer; +} +.copilot-expand-btn:hover { background: #2c5282; } +