diff --git a/app/helpers/lightbox_helper.rb b/app/helpers/lightbox_helper.rb index 4567c3c..ffb8d35 100644 --- a/app/helpers/lightbox_helper.rb +++ b/app/helpers/lightbox_helper.rb @@ -22,10 +22,7 @@ module LightboxHelper def lightbox_options(options, lightbox_type = 'lbOn') the_class = lightbox_type the_class << " #{options[:class]}" if options.has_key?(:class) - options.merge( - :class => the_class, - :onclick => 'alert("%s"); return false' % _('Please, try again when the page loading completes.') - ) + options.merge(:class => the_class) end def lightbox? diff --git a/public/javascripts/lightbox.js b/public/javascripts/lightbox.js index 9e5f07b..80ed851 100644 --- a/public/javascripts/lightbox.js +++ b/public/javascripts/lightbox.js @@ -51,7 +51,6 @@ function checkIt(string) { /*-----------------------------------------------------------------------------------------------*/ -Event.observe(window, 'load', initialize, false); Event.observe(window, 'load', getBrowserInfo, false); var lightbox = Class.create(); @@ -68,6 +67,7 @@ lightbox.prototype = { } Event.observe(ctrl, 'click', this.activate.bindAsEventListener(this), false); ctrl.onclick = function(){return false;}; + ctrl.lightbox = this; }, // Turn everything on - mainly the IE fixes @@ -80,7 +80,6 @@ lightbox.prototype = { } this.hideObjectsAndEmbeds('hidden'); this.displayLightbox("block"); - window.location.href= "#"; }, // Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox @@ -169,15 +168,15 @@ lightbox.prototype = { }, // Example of creating your own functionality once lightbox is initiated - insert: function(e){ - link = Event.element(e).parentNode; - Element.remove($('lbContent')); - - var myAjax = new Ajax.Request( - link.href, - {method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)} - ); - + insert: function(e){ + link = Event.element(e).parentNode; + Element.remove($('lbContent')); + + var myAjax = new Ajax.Request( + link.href, + {method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)} + ); + }, // Example of creating your own functionality once lightbox is initiated @@ -196,14 +195,21 @@ lightbox.prototype = { /*-----------------------------------------------------------------------------------------------*/ -// Onload, make all links that need to trigger a lightbox active -function initialize(){ - addLightboxMarkup(); - lbox = document.getElementsByClassName('lbOn'); - for(i = 0; i < lbox.length; i++) { - valid = new lightbox(lbox[i]); - } -} +jQuery('.lbOn').live('click', function(event) { + if (jQuery('#lbLoadMessage').length == 0) + addLightboxMarkup(); + if (this.lightbox == undefined) + valid = new lightbox(this); + else { + removeLightboxMarkup(); + addLightboxMarkup(); + } + + this.lightbox.activate(); + + event.preventDefault(); + return false; +}); // Add in markup necessary to make this work. Basically two divs: // Overlay holds the shadow @@ -221,3 +227,7 @@ function addLightboxMarkup() { bod.appendChild(overlay); bod.appendChild(lb); } +function removeLightboxMarkup() { + Element.remove($('overlay')); + Element.remove($('lightbox')); +} -- libgit2 0.21.2