Skip to content

Instantly share code, notes, and snippets.

@christianvuerings
Created November 3, 2012 20:45
Show Gist options
  • Save christianvuerings/4008670 to your computer and use it in GitHub Desktop.
Save christianvuerings/4008670 to your computer and use it in GitHub Desktop.
Webplatform.org - show prototype of live code
// Use on webplatform.org to show prototype of how live code could work.
var el = document.querySelector('a[href="http://docs.webplatform.org/wiki/html"]');
el.href="http://denbuzze.com/code/webplatform_codepen/";
el.rel="lightbox";
el.target="_blank";
el.innerText="live example"
// Reload the lightbox
(function(){
var lightbox = document.getElementById('lightbox'),
iframe = lightbox.querySelector('iframe'),
close = lightbox.querySelector('a');
var links = document.querySelectorAll('[rel="lightbox"]');
for(var i=0, link; link = links[i++];) {
link.onclick = function () {
lightbox.className = 'open';
var me = this;
setTimeout(function () {
iframe.src = me.href;
}, 1500)
return false;
};
}
close.onclick = function () {
lightbox.className = 'closed';
iframe.src = 'about:blank';
return false;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment