Hi All,

I have a pretty resource heavy website, and It's imperative that I can make Shadowbox work before the page is completely loaded. But before the page is loaded the links click through like normal links... taking you to a full windowed video in my case.

I've played around with the order that scripts are loaded. I'm using Jquery as my "adaptor" for shadowbox, and using the shadowbox module to load it in. It works fine once the page is loaded loaded.

This is an old post with the same problem, but on drupal 5. http://drupal.org/node/345864

Maybe I should update to the latest version... since I´m a little behind. I'll update here when I do, but I suspect it will be the same.

This is where I call the init:

(function ($) {
 
 // take link from link and make the image linked
 //views_slideshow_cycle_div_slides-block_0 and 1
 $(document).ready(function(){

function myOpen( cacheElem ){ 
    $('#quotes').cycle('pause');
    $('.views-slideshow-cycle-main-frame').cycle('pause');
    //$('.views_slideshow_cycle_teaser_section_slides-block').cycle('pause');
    //$('.views_slideshow_cycle_teaser_section').cycle('pause');

 };


function myClose( cacheElem ){ 
    $('#quotes').cycle('resume');
     $('.views-slideshow-cycle-main-frame').cycle('resume');
    //alert('resume');
 };

 
 Shadowbox.init( { onOpen : myOpen, onClose : myClose } );
 
 
 });
 
  })(jQuery); 

in my head tag

<script type="text/javascript" src="http://www.kuteblackson.com/beta/misc/jquery.js?v=1.4.4"></script>
<script type="text/javascript" src="http://www.kuteblackson.com/beta/misc/jquery.once.js?v=1.2"></script>
<script type="text/javascript" src="http://www.kuteblackson.com/beta/misc/drupal.js?lzgmb0"></script>
<script type="text/javascript" src="http://www.kuteblackson.com/beta/sites/all/libraries/mediaelement/build/mediaelement-and-player.min.js?v=2.1.6"></script>
<script type="text/javascript" src="http://www.kuteblackson.com/beta/sites/all/libraries/shadowbox/shadowbox.js?v=3.0.3"></script>
<script type="text/javascript" src="http://www.kuteblackson.com/beta/themes/marinelli/shadowbox/shadow-box-custom-init.js?lzgmb0"></script>

Comments

manfer’s picture

There is nothing special to do for shadowbox to work properly. And there is no way to make it work before the DOM is ready because it needs to know about the DOM to work.

And that is enough soon to start working no matter if the webpage is "pretty resource heavy" as it is not waiting for the media to be ready, only the DOM -which is ready pretty fast-

What I suggest is that you review your code because you are trying to load the shadowbox library from two places. And besides your code has javascript errors. So those are the first things to resolve.

The second place where you are trying to load shadowbox just doesn't work because the files are not there anymore but anyway the website is requesting them:

<script src="http://www.kuteblackson.com/beta/themes/marinelli/shadowbox/shadowbofx.js?lzgmb0" type="text/javascript"></script>
<script src="http://www.kuteblackson.com/beta/themes/marinelli/shadowbox/inift.js?lzgmb0" type="text/javascript"></script>

And an init with errors at the end:

<script type="text/javascript">
<!--//--><![CDATA[//><!--

          Shadowbox.path = "/beta/sites/all/libraries/shadowbox/";
	      Shadowbox.init(options : { onOpen : function(){ 
                                              
                                        }  });
	    
//--><!]]>
</script>
manfer’s picture

Status: Active » Closed (fixed)