|
@@ -20,6 +20,8 @@
|
|
(function() {
|
|
(function() {
|
|
var root = document.getElementById('js-demo-{{ $uniq }}');
|
|
var root = document.getElementById('js-demo-{{ $uniq }}');
|
|
var template = document.getElementById('template-{{ $uniq }}');
|
|
var template = document.getElementById('template-{{ $uniq }}');
|
|
|
|
+
|
|
|
|
+ // Save a version for the new window
|
|
var demoDiv = document.createElement('div');
|
|
var demoDiv = document.createElement('div');
|
|
demoDiv.innerHTML = template.innerHTML;
|
|
demoDiv.innerHTML = template.innerHTML;
|
|
var standaloneScript = demoDiv.querySelector('script');
|
|
var standaloneScript = demoDiv.querySelector('script');
|
|
@@ -56,45 +58,5 @@
|
|
standalone.document.title = 'demo ' + {{ $uniq }};
|
|
standalone.document.title = 'demo ' + {{ $uniq }};
|
|
});
|
|
});
|
|
})();
|
|
})();
|
|
- /*(function() {
|
|
|
|
- var root = document.getElementById('js-demo-{{ $uniq }}');
|
|
|
|
- var template = document.getElementById('template-{{ $uniq }}');
|
|
|
|
- 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-{{ $uniq }}\').shadowRoot;' + script.textContent + '})();';
|
|
|
|
- script.textContent = wrappedScript;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (document.head.attachShadow) {
|
|
|
|
- root.attachShadow({mode: 'open'});
|
|
|
|
- root.shadowRoot.appendChild(document.importNode(template.content, true));
|
|
|
|
- } 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. You can launch the demo in a separate window ↓</p>';
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var launchButton = document.querySelector('[data-launch="js-demo-{{ $uniq }}"]');
|
|
|
|
- launchButton.addEventListener('click', function () {
|
|
|
|
- var standalone = window.open();
|
|
|
|
- script.innerHTML = standaloneScript;
|
|
|
|
- var demoDiv = document.createElement('div');
|
|
|
|
- demoDiv.innerHTML = template.innerHTML;
|
|
|
|
- standalone.document.body.appendChild(demoDiv);
|
|
|
|
-
|
|
|
|
- // For activating the script :-(
|
|
|
|
- var newScript = standalone.document.createElement('script');
|
|
|
|
- var oldScript = standalone.document.querySelector('script');
|
|
|
|
- newScript.textContent = oldScript.textContent;
|
|
|
|
- oldScript.parentNode.removeChild(oldScript);
|
|
|
|
- standalone.document.body.appendChild(newScript);
|
|
|
|
-
|
|
|
|
- {{ if .Get "backgroundColor" }}
|
|
|
|
- standalone.document.body.style.backgroundColor = {{ .Get "backgroundColor" | safeCSS }};
|
|
|
|
- {{ end }}
|
|
|
|
-
|
|
|
|
- standalone.document.title = 'demo ' + {{ $uniq }};
|
|
|
|
- });
|
|
|
|
- })();*/
|
|
|
|
</script>
|
|
</script>
|
|
</div>
|
|
</div>
|