Created
November 3, 2012 20:45
-
-
Save christianvuerings/4008670 to your computer and use it in GitHub Desktop.
Webplatform.org - show prototype of live code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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