Hi there theremotedr,
I noticed that you now want to display videos.
Unfortunately, I haven't as yet been able to make them work in the modal.
This means that at present I am having to let them be displayed in a new window.
Here though is the corrected javascript for you to test...
Code:
/****************** modal window ******************/
var col = document.querySelectorAll('.column'),
cnt = document.querySelectorAll('.content'),
cls = document.querySelector('#closure'),
h,k,ext;
for ( k = 0; k < cnt.length; k ++ ) {
cnt[k].firstElementChild.addEventListener( 'click', modal(k), false );
}
function modal(k){
cnt[k].firstElementChild.onclick = function( event){
for ( h = 0; h < cnt.length; h ++ ) {
col[h].classList.add( 'hide' );
}
ext = cnt[k].firstElementChild.href;
if( ext.substring(ext.lastIndexOf(".")+1,ext.length) ==='jpg') {
event.preventDefault();
document.querySelector('#modal').classList.remove('hide');
document.querySelector('#modal-image').src = ext;
}
else{
for ( h = 0; h < cnt.length; h ++ ) {
col[h].classList.remove( 'hide' );
}
}
}
}
cls.addEventListener( 'click',
function(){
document.querySelector('#modal').classList.add('hide');
document.querySelector('#modal-image').src='';
for ( h = 0; h < cnt.length; h ++ ) {
col[h].classList.remove('hide');
}
},false);
/**************************************************/
coothead
Bookmarks