|
@@ -357,6 +357,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ <nav class="toc" aria-labelledby="toc-heading">
|
|
|
|
+ <h2 id="toc-heading">Table of contents</h2>
|
|
|
|
+ <ol>
|
|
|
|
+
|
|
|
|
+ <li>
|
|
|
|
+ <a href="#launch-in-a-separate-window">
|
|
|
|
+ Launch in a separate window
|
|
|
|
+ </a>
|
|
|
|
+ </li>
|
|
|
|
+
|
|
|
|
+ <li>
|
|
|
|
+ <a href="#captioned-demos">
|
|
|
|
+ Captioned demos
|
|
|
|
+ </a>
|
|
|
|
+ </li>
|
|
|
|
+
|
|
|
|
+ </ol>
|
|
|
|
+ </nav>
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -406,7 +425,7 @@ toggle.addEventListener('click', (e) => {
|
|
|
|
|
|
<div class="demo-container">
|
|
<div class="demo-container">
|
|
|
|
|
|
- <div class="demo" id="demo-414e06a48e755bf9e43e5e2596f9ea7a"></div>
|
|
|
|
|
|
+ <div class="demo" id="js-demo-414e06a48e755bf9e43e5e2596f9ea7a"></div>
|
|
|
|
|
|
|
|
|
|
<template id="template-414e06a48e755bf9e43e5e2596f9ea7a">
|
|
<template id="template-414e06a48e755bf9e43e5e2596f9ea7a">
|
|
@@ -440,25 +459,48 @@ toggle.addEventListener('click', (e) => {
|
|
</script>
|
|
</script>
|
|
|
|
|
|
</template>
|
|
</template>
|
|
|
|
+ <button data-launch="js-demo-414e06a48e755bf9e43e5e2596f9ea7a">Launch in separate window</button>
|
|
<script>
|
|
<script>
|
|
(function() {
|
|
(function() {
|
|
- var root = document.getElementById('demo-414e06a48e755bf9e43e5e2596f9ea7a');
|
|
|
|
|
|
+ var root = document.getElementById('js-demo-414e06a48e755bf9e43e5e2596f9ea7a');
|
|
|
|
+ var template = document.getElementById('template-414e06a48e755bf9e43e5e2596f9ea7a');
|
|
|
|
+ var script = template.content.querySelector('script');
|
|
|
|
+
|
|
|
|
+ if (script) {
|
|
|
|
+ var standaloneScript = '(function() { document.getElementsByTagName(\'html\')[0].setAttribute(\'lang\', \'en\'); var demo = document; ' + script.textContent + ' })()';
|
|
|
|
+ var wrappedScript = '(function() { var demo = document.getElementById(\'js-demo-414e06a48e755bf9e43e5e2596f9ea7a\').shadowRoot;' + script.textContent + '})()';
|
|
|
|
+ script.textContent = wrappedScript;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (document.head.attachShadow) {
|
|
if (document.head.attachShadow) {
|
|
root.attachShadow({mode: 'open'});
|
|
root.attachShadow({mode: 'open'});
|
|
- var template = document.getElementById('template-414e06a48e755bf9e43e5e2596f9ea7a');
|
|
|
|
- var script = template.content.querySelector('script');
|
|
|
|
- if (script) {
|
|
|
|
- script.textContent = `(function() { var demo = document.getElementById(\'demo-414e06a48e755bf9e43e5e2596f9ea7a\').shadowRoot; ${script.textContent} })()`
|
|
|
|
- }
|
|
|
|
root.shadowRoot.appendChild(document.importNode(template.content, true));
|
|
root.shadowRoot.appendChild(document.importNode(template.content, true));
|
|
} else {
|
|
} else {
|
|
- root.innerHTML = '<p class="site-error"><strong style="font-weight:bold">Site error:</strong> A browser supporting Shadow DOM is needed to run encapsulated demos. The browser does not have an issue with the demo code itself.</p>';
|
|
|
|
|
|
+ root.innerHTML = '<p class="site-error"><strong style="font-weight:bold">Site error:</strong> A browser supporting Shadow DOM is needed to run encapsulated demos. You can launch the demo in a separate window ↓</p>';
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ var launchButton = document.querySelector('[data-launch="js-demo-414e06a48e755bf9e43e5e2596f9ea7a"]');
|
|
|
|
+ launchButton.addEventListener('click', function () {
|
|
|
|
+ var demoContent = template.content;
|
|
|
|
+ var standalone = window.open();
|
|
|
|
+ script.textContent = standaloneScript;
|
|
|
|
+ standalone.document.body.appendChild(document.importNode(template.content, true));
|
|
|
|
+ standalone.document.title = 'demo ' + "414e06a48e755bf9e43e5e2596f9ea7a"
|
|
|
|
+ });
|
|
})();
|
|
})();
|
|
</script>
|
|
</script>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
+<h2 id="launch-in-a-separate-window">Launch in a separate window</h2>
|
|
|
|
+
|
|
|
|
+<p>The “Launch in separate window” takes the demo code and pushes it to a new browser window. This serves two purposes:</p>
|
|
|
|
+
|
|
|
|
+<ul>
|
|
|
|
+<li>It provides a fallback for browsers that do not support Shadow DOM encapsulation (a warning message will replace the inline demo).</li>
|
|
|
|
+<li>It creates an isolated test case for the demo, allowing you to run browser extensions and bookmarklets on the the demo code and <em>just</em> the demo code.</li>
|
|
|
|
+</ul>
|
|
|
|
+
|
|
<h2 id="captioned-demos">Captioned demos</h2>
|
|
<h2 id="captioned-demos">Captioned demos</h2>
|
|
|
|
|
|
<p>It’s possible to give your demo a caption using an accessible <code><figure></code> and <code><figcaption></code> structure. All <em>you</em> need to do is supply a <code>caption</code> attribute. For example:</p>
|
|
<p>It’s possible to give your demo a caption using an accessible <code><figure></code> and <code><figcaption></code> structure. All <em>you</em> need to do is supply a <code>caption</code> attribute. For example:</p>
|