Fix for Code

  1. jQuery(document).ready(function() {
  2.  
  3.         // image loader
  4.        
  5.                 //set variables
  6.                 if(jQuery("#slider_img").length){var $index=true; var $load='a.load_slider_img'; var $delay_time=0;}
  7.  
  8.                
  9.                 jQuery(this).delay($delay_time,function() {
  10.        
  11.                         // id of the div containers
  12.                         var $imgContainerId = "div[class^='image_loader']";
  13.        
  14.                         // grab the images
  15.                         var $images = jQuery($imgContainerId+' span img');
  16.        
  17.                         // image length
  18.                         var $max = $images.length;
  19.        
  20.                         // remove them from DOM to prevent normal load
  21.                         jQuery('.rm_img').remove();
  22.  
  23.  
  24.                         // start loading
  25.                         if($max>0) {
  26.                                 LoadImage(0,$max);
  27.                         }
  28.  
  29.                 // loading function handler
  30.                 function LoadImage(index,$max) {
  31.  
  32.                         if(index<$max) {
  33.  
  34.                                 // add list to div
  35.                                 jQuery('<span id="img'+(index+1)+'"></span>').each(function() {
  36.                                    jQuery(this).appendTo(jQuery('.image_loader '+$load).eq(index));
  37.                                 });
  38.                                
  39.                                 if($max>1) {
  40.                                         jQuery('<img style="margin-right:4px;" src="images/transparent.png" alt="" width="14" height="14" class="slider_preview_img" />').each(function() {
  41.                                            jQuery(this).appendTo('#slider_preview_img');
  42.                                         });
  43.                                 }// end
  44.  
  45.                                 // new image object
  46.                                 var $img = new Image();
  47.                
  48.                                 // current image
  49.                                 var $curr = jQuery("#img"+(index+1));
  50.                
  51.                                 // load current image
  52.                                 jQuery($img).load(function () {
  53.                        
  54.                                         // hide it first + .hide() failed in safari
  55.                                         jQuery(this).css('display','none');
  56.                        
  57.                                         //add alt attr
  58.                                         jQuery(this).attr({alt: ""});
  59.                                        
  60.                                         // add hover class
  61.                                         if(!$index) {
  62.                                                 jQuery(this).addClass('hover_fade');
  63.                                         }
  64.                  
  65.                                         // insert the image into div
  66.                                         jQuery($curr).append(this);
  67.                        
  68.                                        
  69.                                        
  70.                                        
  71.                                         // fade it in
  72.                                         jQuery(this).fadeIn(250,function() {
  73.                                                
  74.                                                 // remove loading div
  75.                                                 if(!$index) {
  76.                                                         jQuery('.img_pre_'+index).remove();
  77.                                                 }
  78.  
  79.                                                 if(index == ($max-1)) {
  80.                                                                 // remove loading div after all images loaded then start slider
  81.                                                                 if($index) { cycleStart(); }
  82.                                                                                                                                
  83.                                                                 if($max==1){
  84.                                                                         if($index){
  85.                                                                                 jQuery(".slider_content").css({display:'block'});
  86.                                                                                 jQuery(".slider_content").css({marginTop:"22px"});
  87.                                                                        
  88.                                                                                 if(jQuery('.image_loader').hasClass('slider_cropped')){
  89.                                                                                         jQuery("#home_feature").addClass('staged');
  90.                                                                                         jQuery(".slider_img_cropped").css({marginTop:"20px"});
  91.                                                                                 }
  92.                                                                         }
  93.                                                                 }// end if($max==1)
  94.                                                
  95.                                                         }else{
  96.                                                           // loading next item
  97.                                                           LoadImage(index+1,$max);
  98.                                                         }
  99.                                         });//end fadeIn fonction
  100.                                        
  101.                                        
  102.                                        
  103.  
  104.                                 }).error(function () {
  105.                                         // if loading error remove div
  106.                                         jQuery($curr).remove();
  107.                                         // try to load next item
  108.                                         LoadImage(index+1,$max);
  109.                                 }).attr('src', jQuery($images[index]).attr('src'));
  110.                                
  111.                                
  112.                           } // if(index<$max)
  113.                         } // end LoadImage
  114.                 });// end jQuery(this).delay
  115.  
  116.        
  117.        
  118.         });//end document ready

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.