09.27.06

Posted in JavaScript at 11:22 pm by jasonb

Hate Flash? You’re not alone. I just finished ripping out Flash support from LightboxEx, so it is no longer required. You will not need to load swfobject.js or Sound.js. The script is smaller with the applied patch, but still includes all the other nice features, like proper resizing for large images and slideshows.

Enjoy!

--- /tmp/lightboxEx.js  2006-09-24 23:27:43.000000000 -0400
+++ public/javascripts/lightboxEx.js  2006-09-24 23:39:27.000000000 -0400
@@ -10,6 +10,7 @@
 /*
 Updates:
 8/16/2006 - Fixed issue with PNG support in IE when play and close button graphics where not visible.
+9/24/2006 - Removed dependency on SoundBridge.swf.
	
 */
	
@@ -51,8 +52,7 @@
 var navigationBarWidth      = -1;   // -1 - size navigation bar based on width of each image
 var slideshow           = 0;     // 1 slideshow auto start. Set 0 if you want to disable starting slideshow  automaticaly
 var foreverLoop         = 0;  // Set 0 if want to stop on the last image or Set it to 1 for Infinite loop feature
-var loopInterval         = 4000;  // image swap interval in miliseconds
-var loopMusic          = true; //loops music if it is shorter then slideshow
+var loopInterval        = 4000; // image swap interval in miliseconds
	
 // ------- Images path ---------------------------------------------------------------–
 var homeURL           = "/"; //URL to your installation directory
@@ -70,31 +70,8 @@
	
 var resize             = 1;  // Set 0 to disable auto-resizing
	
-//var SoundBridgeSWF         = homeURL + "js/SoundBridge.swf";
-
 // ------- End of Configuration Parameters ------------------------------------------------------------------–
	
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 //
 //  Global Variables
 //
@@ -272,198 +249,8 @@
     this.shift();
   }
 }
-//    Sound.trace = function(value, isJavascript) {
-        // tracing disabled
-//    } 
     
 // ---------------------------------------------------------------------------------–
-
-// Music Player Class
-/*   function Player () {
-      this.paused = true;
-      this.stoped = true;
-
-      this.options = new Object();
-      this.options.swfLocation = SoundBridgeSWF;
-      this.sound = new Sound(this.options);
-    
-      this.position = 0;
-      this.frequency = 1000;
-      this.isLoaded = false;
-      this.duration = 0;
-      this.bytesTotal = 0;
-      this.callback = this.registerCallback();
-   }
-    
-    
-   Player.prototype.onTimerEvent = function() {
-    var isDurationOk = false
-      if(!this.paused) {
-
-          var position = this.sound.getPosition();
-          if(!position) position = 0;
-          if(position != this.position && position != 0) {
-             this.onPlaying();
-          } else {
-             this.onBuffering();
-          }
-          this.position = position;          
-          
-          var duration = 0;                   
-          duration = this.sound.getDuration();
-          
-          if(!duration) duration = 0;
-          if(duration == this.duration && duration != 0) {
-             isDurationOk = true;             
-          }
-          
-          this.duration = duration;
-          var progress = position/duration;
-          if(isDurationOk) {
-              this.setProgressBar(progress);
-          }
-          
-          var isBytesTotalOk = false;
-          
-          var bytesTotal = this.sound.getBytesTotal();
-          if(bytesTotal == this.bytesTotal) {
-              isBytesTotalOk = true;    
-          }
-          this.bytesTotal = bytesTotal;
-          
-          if(isBytesTotalOk) {
-              var loaded =  this.sound.getBytesLoaded()/bytesTotal;
-              this.setLoadedBar(loaded);
-          }
-          
-          if (progress == 1 && duration != 0 && position != 0) {
-            this.onSoundComplete();
-          }
-          
-      }
-   }
-      
-   Player.prototype.registerCallback = function() {
-      return setInterval(this.onTimerEvent.bind(this), this.frequency);
-   }
-      
-   Player.prototype.clearCallback = function() {
-       clearInterval(this.callback);
-       this.callback = null;
-  }
-  
-   Player.prototype.setProgressBar = function(progress) {
-        if(!progress) progress = 0;        
-   }
-  
-   Player.prototype.setLoadedBar = function(loaded) {
-         if(!loaded) loaded = 0;
-   }   
-      
-   Player.prototype.onPlaying = function() {   
-       //Element.show('caption');
-       //Element.setInnerHTML( 'caption', this.sound.getId3());
-   }
-   
-   Player.prototype.onPause = function() {
-   }   
-   
-   Player.prototype.onBuffering = function() {      
-   }   
-
-   Player.prototype.onSoundComplete = function() {
-      if(!this.paused) {
-        if (loopMusic) {
-          this.onForward();
-        }
-      }
-   }
-
-   Player.prototype.onForward = function() {
-         this.position = 0;
-         this.duration = 0;
-         this.sound.start(this.duration/1000, 1);
-         this.sound.stop();
-         this.loadTrack(this.track);
-         this.stoped = true;
-         this.setProgressBar(0);
-         this.setLoadedBar(0);
-         if(!this.paused) {            
-            this.paused = true;
-            this.play();
-         }
-   }   
-
-   Player.prototype.fadeOut = function() {
-         for (var i=this.sound.getVolume()-1; i>=0; i--) {         
-           this.sound.setVolume(i);
-           //pause(1);
-        }              
-   }   
-   
-   Player.prototype.fadeIn = function() {
-         for (var i=1; i <= 100; i++) {         
-           this.sound.setVolume(i);
-           //pause(1);
-        }              
-   }
-   
-   Player.prototype.toggleVolume = function() {
-       if (this.paused) return;
-       var volume = this.sound.getVolume();
-       if (volume == 0) {
-         this.fadeIn();
-         //this.sound.setVolume(100);         
-         objSpeakerImage.setAttribute('src', MusicOnImage);
-       }
-       if (volume == 100) {
-         this.fadeOut();
-         //this.sound.setVolume(0);
-         objSpeakerImage.setAttribute('src', MusicOffImage);
-       }
-   }
-   
-   Player.prototype.play = function() {   
-      if(this.paused) {
-         this.paused = false;
-         if(this.stoped) {
-             this.sound.loadSound(this.track, true);
-         }
-         this.sound.start(this.position/1000, 1);         
-         this.stoped = false;
-      } else {
-         this.position = this.sound.getPosition();
-         this.sound.stop();         
-         this.paused = true;
-         this.onPause();
-      }
-   }
-
-   Player.prototype.stop = function() {
-       if (! this.paused) {
-       //fade out
-       for (var i=this.sound.getVolume()-1; i>=0; i--) {         
-             this.sound.setVolume(i);
-             pause(1);
-       }                       
-       }
-       this.paused = true;
-       this.stoped = true;
-       this.position = 0;
-       this.duration = 0;
-              
-       this.sound.start(this.duration/1000, 1);       
-       this.sound.stop();         
-   }   
-   
-  
-   Player.prototype.loadTrack = function(track) {
-      this.track = track;
-   }        
-
-var player;
-*/
-// ---------------------------------------------------------------------------------–
 //
 //  Lightbox Class Declaration
 //  - initialize()
@@ -724,28 +511,6 @@
     objSlideShowLink.appendChild(objSlideShowImage);
     //objSlideShowImage.setAttribute('src', SlideShowStartImage);
	
-    //Speaker link
-//    var objSpeakerLink = document.createElement("a");
-//    objSpeakerLink.setAttribute('id','speakerLink');
-//    objSpeakerLink.setAttribute('href','#');
-//    objSpeakerLink.setAttribute('onFocus', 'if (this.blur) this.blur()');
-//    objSpeakerLink.onclick = function() { player.toggleVolume(); return false; }
-//    objBottomNav.appendChild(objSpeakerLink);
-      
-    //Speaker Image
-//    objSpeakerImage = document.createElement("img");
-//    objSpeakerImage.setAttribute('id', 'speaker');    
-//    objSpeakerImage.setAttribute('alt', "Music On/Off");      
-//    objSpeakerImage.setAttribute('src', MusicOffImage);  
-//    objSpeakerImage.onpropertychange = function() { propertyChanged(); return false; };
-//    objSpeakerLink.appendChild(objSpeakerImage);    
-      
-    //Music player
-//    var objFlashPlayer = document.createElement("div");
-//    objFlashPlayer.setAttribute('id','__sound_flash__');
-//    objOverlay.appendChild(objFlashPlayer);
-      
-
   },
   
   lightUpNavigationBar: function() {
@@ -783,7 +548,6 @@
   //  Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
   //
   start: function(imageLink) {  
-//    player = new Player();
     
     slideshowMusic = null;
     firstTime = 1;
@@ -795,7 +559,6 @@
     saveSlideShowWidth = slideShowWidth;
     saveSlideShowHeight = slideShowHeight;
     
-    saveLoopMusic = loopMusic;
     saveNavigationBarWidth = navigationBarWidth;
	
     hideSelectBoxes();
@@ -830,7 +593,7 @@
               //Element.hide('speakerLink');
             } else { 
               //Element.show('speakerLink');              
-//              player.loadTrack(slideshowMusic);                              
+        
             }
	
             var startSlideshow = anchor.getAttribute('startslideshow');
@@ -842,14 +605,7 @@
             if (forever != null) {
             if (forever == "true") foreverLoop = 1; else foreverLoop = 0;
             }          
-            
-//            var foreverMusic = anchor.getAttribute('loopMusic');
-//            if (foreverMusic != null) {
-//            if (foreverMusic == "true") loopMusic = true; else loopMusic = false;
-//            }          
-            
-//            if (foreverLoop == 1) { loopMusic = true;  }
-            
+                        
             var slideDuration = anchor.getAttribute('slideDuration');
             if (slideDuration != null) {
             loopInterval = slideDuration * 1000;
@@ -921,7 +677,6 @@
         Element.hide('imageDataContainer');      
       Element.hide('bottomNav');
       Element.hide('numberDisplay');
-//      Element.hide('speakerLink');
       Element.hide('slideshowLink');    
     }
       
@@ -1063,7 +818,6 @@
     Element.show('bottomNav');
     
     if (firstTime == 1) {
-//      objSpeakerImage.setAttribute('src', MusicOffImage);
       objSlideShowImage.setAttribute('src', SlideShowStartImage);
       objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
     }
@@ -1097,10 +851,8 @@
	

       if (imageArray.length > 1) {                           
-         //Element.show('speakerLink');
          Element.show('slideshowLink');
       }else {
-         //Element.hide('speakerLink');
          Element.hide('slideshowLink');
       }
	
@@ -1140,9 +892,6 @@
	
     if (firstTime == 1) {
       firstTime = 0;
-      //if (imageArray.length > 1 && slideshow == 1) 
-//      this.showSpeaker();
-//      if (slideshow == 1) this.playMusic(); 
     }
   },
	
@@ -1208,35 +957,6 @@
   
   },
	
-  //showSpeaker
-//  showSpeaker: function() {
-//     if (slideshowMusic != null) {
-//        Element.show('speakerLink');        
-//     } else {
-//      Element.hide('speakerLink');
-//    }
-//  },
-  
-  //playMusic
-/*  playMusic: function() {
-     if (slideshowMusic != null) {
-        objSpeakerImage.setAttribute('src', MusicOnImage);
-        player.play();
-     }
-  },
-
-  //stopMusic
-  stopMusic: function() {
-    if (slideshowMusic != null) {
-        objSpeakerImage.setAttribute('src', MusicOffImage);
-        if (player.paused) {
-           player.stop();
-        } else {
-           player.play();
-        }
-      }
-  }, */
-
   //  Slideshow Functions
   //
   //  toggleSlideShow()
@@ -1247,7 +967,6 @@
   toggleSlideShow: function() {
     if(slideshow == 1) this.stopSlideShow();
     else {
-//       this.playMusic();       
        if(activeImage == (imageArray.length-1)) {
       slideshow = 1;
       this.changeImage(0);      
@@ -1298,17 +1017,11 @@
           
           Element.setInnerHTML( 'numberDisplay', '');
           
-/*          this.fadeoutTimer = setInterval(function() {
-            player.sound.setVolume(player.sound.getVolume()-1);
-          }.bind(this), 30); */
-          
           new Effect.Appear('lightboxImage', { duration: 3, from: 1, to: 0, 
                     afterFinish: function(){                       
                       new Effect.Appear('replay', { duration: 0.2, from: 0, to: 1}); 
                       objSlideShowImage.setAttribute('src', SlideShowStartImage);
                       clearInterval(myLightbox.fadeoutTimer);
-//                      player.paused = true; //this will cause music to stop
-//                      myLightbox.stopMusic();
                       
                       }}  );
         }
@@ -1321,7 +1034,6 @@
     slideshow = 0;
     objSlideShowImage.setAttribute('src', SlideShowStartImage);
      
-//    this.stopMusic();    
     if(this.slideShowTimer) {
       clearTimeout(this.slideShowTimer);
       this.slideShowTimer = null;      
@@ -1332,11 +1044,9 @@
   //  end()
   //
   end: function() {    
-//    player.paused = true; //this will cause music to stop
     
     this.stopSlideShow();
     
-//    player.clearCallback();
     clearInterval(myLightbox.fadeoutTimer);
     
     this.disableKeyboardNav();
@@ -1354,8 +1064,7 @@
     slideShowWidth = saveSlideShowWidth;
     slideShowHeight = saveSlideShowHeight;
     navigationBarWidth = saveNavigationBarWidth;
-    
-    loopMusic = saveLoopMusic;
+
   }
 }
	

Leave a Comment

What's a blog without spam: the intense and intense Wordpress Anti-Spam Plugin!