// // iWeb - Slideshow.js // Copyright (c) 2007-2008 Apple Inc. All rights reserved. // var DidStartLoadingImagesNotification="DidStartLoadingImages";var SlideshowGlue=Class.create(Widget,{widgetIdentifier:"com-apple-iweb-widget-slideshow",initialize:function($super,instanceID,widgetPath,sharedPath,sitePath,preferences,runningInApp) {if(instanceID) {$super(instanceID,widgetPath,sharedPath,sitePath,preferences,runningInApp);this.mInstanceID=instanceID;this.updateFromPreferences();}},onload:function() {},onunload:function() {},loadFromStream:function(mediaStream) {if(this.p_enabled()) {if(this.runningInApp) {var slideshowDiv=this.getElementById("slideshow_placeholder");slideshowDiv.onmouseover=function() {mediaStream.load(this.p_baseURL(),this.onStreamLoad.bind(this));}.bind(this);} else {mediaStream.load(this.p_baseURL(),this.onStreamLoad.bind(this));}} else {}},onStreamLoad:function(imageStream) {var slideshowDiv=this.getElementById("slideshow_placeholder");if(this.mSlideshow!=null) {this.mSlideshow.pause();slideshowDiv.innerHTML="";} var skipStride=0;var nextToSkip=999999999;var transitionIndex=this.p_transitionIndex();var scrub=(transitionIndex==255);if(scrub) {var numberToSkip=imageStream.length-50;if(numberToSkip>0) {skipStride=imageStream.length/numberToSkip;nextToSkip=0;}} var photos=[];var imageType=this.p_imageType();for(var i=0;inextToSkip) {nextToSkip+=skipStride;} else {photos.push(imageStream[i].slideshowValue(imageType));}} var options={backgroundColor:this.p_backgroundColor(),scaleMode:this.p_scaleMode(),movieMode:this.p_movieMode(),shouldTighten:false};this.mSlideshow=new Slideshow(slideshowDiv,photos,function(){},options);if(scrub) {this.mSlideshow.setTransitionIndex(1,0);} else {this.mSlideshow.setTransitionIndex(transitionIndex,0);} this.mSlideshow.pause();this.mSlideshow.photoDuration=this.p_photoDuration();var startIndex=this.p_startIndex();if(startIndex>=imageStream.length) {startIndex=0;} this.mSlideshow.showPhotoNumber(startIndex);if(this.runningInApp) {window.onresize=function() {this.p_onResize();}.bind(this)} if(scrub) {var heightPct="100%";for(var i=0;i0) {mediaStream=eval(mediaStreamCode);}}} return mediaStream;},p_backgroundColor:function() {var backgroundColor=null;if(this.preferences) {backgroundColor=this.preferenceForKey("color");} if(backgroundColor===undefined) {backgroundColor="black";} return backgroundColor;},p_baseURL:function() {return this.preferenceForKey("baseURL");},p_enabled:function() {var enabled=null;if(this.preferences) {enabled=this.preferenceForKey("slideshowEnabled");} if(enabled===undefined) {enabled=false;} return enabled;},p_fadeIn:function() {var fadeIn=null;if(this.preferences) {fadeIn=this.preferenceForKey("fadeIn");} if(fadeIn===undefined) {fadeIn=false;} return fadeIn;},p_showOnMouseOver:function() {var showOnMouseOver=null;if(this.preferences) {showOnMouseOver=this.preferenceForKey("showOnMouseOver");} if(showOnMouseOver===null||showOnMouseOver==undefined) {showOnMouseOver=false;} return showOnMouseOver;},p_photoDuration:function() {var photoDuration=null;if(this.preferences) {photoDuration=this.preferenceForKey("photoDuration")*1000;} if(photoDuration===null) {photoDuration=5000;} return photoDuration;},p_startIndex:function() {var startIndex=null;if(this.preferences) {startIndex=this.preferenceForKey("startIndex");} if(startIndex===undefined) {startIndex=0;} return startIndex;},p_scaleMode:function() {var scaleMode=null;if(this.preferences) {scaleMode=this.preferenceForKey("scaleMode");} if(scaleMode===undefined) {scaleMode="fit";} return scaleMode;},p_transitionIndex:function() {var transitionIndex=null;if(this.preferences) {transitionIndex=this.preferenceForKey("transitionIndex");} if(transitionIndex===undefined) {transitionIndex=0;} return transitionIndex;},p_imageType:function() {var imageType=null;if(this.preferences) {imageType=this.preferenceForKey("imageType");} if(imageType===null||imageType==undefined) {imageType="image";} return imageType;},p_movieMode:function() {var movieMode=null;if(this.preferences) {movieMode=this.preferenceForKey("movieMode");} if(movieMode===null||movieMode==undefined) {movieMode=kShowMovie;} return movieMode;},p_startSlideshow:function(slideshowDiv) {if(this.mSlideshow&&this.p_enabled()) {if(this.p_fadeIn()) {var self=this;var startOpacity=slideshowDiv.getStyle("opacity");if(this.mFadeAnimation) {this.mFadeAnimation.stop();} this.mFadeAnimation=new SimpleAnimation(function() {delete self.mFadeAnimation;self.mSlideshow.resume();});this.mFadeAnimation.pre=function() {IWSetDivOpacity(slideshowDiv,startOpacity);} this.mFadeAnimation.post=function() {IWSetDivOpacity(slideshowDiv,1.0);} this.mFadeAnimation.update=function(now) {IWSetDivOpacity(slideshowDiv,startOpacity+now*(1.0-startOpacity));} this.mFadeAnimation.start();} else {this.mSlideshow.resume();}}},p_pauseSlideshow:function(slideshowDiv) {if(this.mSlideshow) {this.mSlideshow.pause();if(this.p_fadeIn()) {var startOpacity=slideshowDiv.getStyle("opacity");if(this.mFadeAnimation) {this.mFadeAnimation.stop();} var self=this;this.mFadeAnimation=new SimpleAnimation(function() {delete self.mFadeAnimation;var startIndex=self.p_startIndex();if(self.mSlideshow.currentPhotoNumber==startIndex-1&&startIndex