/**************************************** Barebones Lightbox Template by Kyle Schaeffer kyleschaeffer.com * requires $ ****************************************/ // display the lightbox function lightbox(insertContent, ajaxContentUrl){ // add lightbox/shadow
's if not previously added if($('#lightbox').size() == 0){ var theLightbox = $(''); var theShadow = $(''); $(theShadow).click(function(e){ closeLightbox(); }); $('body').append(theShadow); $('body').append(theLightbox); } // remove any previously added content $('#lightbox').empty(); // insert HTML content if(insertContent != null){ $('#lightbox').append(insertContent); } // insert AJAX content if(ajaxContentUrl != null){ // temporarily add a "Loading..." message in the lightbox $('#lightbox').append(''); // request AJAX content $.ajax({ type: 'GET', url: ajaxContentUrl, success:function(data){ // remove "Loading..." message and append AJAX content $('#lightbox').empty(); $('#lightbox').append(data); }, error:function(){ alert('AJAX Failure!'); } }); } // move the lightbox to the current window top + 100px $('#lightbox').css('top', $(window).scrollTop() + 125 + 'px'); // display the lightbox $('#lightbox').show(); $('#lightbox-shadow').show(); } // close the lightbox function closeLightbox(){ // hide lightbox and shadow 's $('#lightbox').hide(); $('#lightbox-shadow').hide(); $('#lightbox2').hide(); $('#lightbox-shadow2').hide(); // remove contents of lightbox in case a video or other content is actively playing $('#lightbox').empty(); $('#lightbox2').empty(); } function lightbox2(insertContent, ajaxContentUrl){ // add lightbox/shadow 's if not previously added if($('#lightbox2').size() == 0){ var theLightbox = $(''); var theShadow = $(''); $(theShadow).click(function(e){ closeLightbox(); }); $('body').append(theShadow); $('body').append(theLightbox); } // remove any previously added content $('#lightbox2').empty(); // insert HTML content if(insertContent != null){ $('#lightbox2').append(insertContent); } // insert AJAX content if(ajaxContentUrl != null){ // temporarily add a "Loading..." message in the lightbox $('#lightbox2').append('Loading...
'); // request AJAX content $.ajax({ type: 'GET', url: ajaxContentUrl, success:function(data){ // remove "Loading..." message and append AJAX content $('#lightbox2').empty(); $('#lightbox2').append(data); }, error:function(){ alert('AJAX Failure!'); } }); } // move the lightbox to the current window top + 100px $('#lightbox2').css('top', $(window).scrollTop() + 125 + 'px'); // display the lightbox $('#lightbox2').show(); $('#lightbox-shadow2').show(); }