﻿Type.registerNamespace('b.Interactive.AjaxControls');b.Interactive.AjaxControls.SlideShowBehavior = function(element) {
b.Interactive.AjaxControls.SlideShowBehavior.initializeBase(this, [element]);this._nextButtonID = null;this._previousButtonID = null;this._toFirstButtonID = null;this._toLastButtonID = null;this._imageDescriptionLabelID = null;this._imageAttributionLabelID = null;this._slideNofMLabelID = null;this._playButtonID = null;this._playButtonValue = '>';this._stopButtonValue = '||';this._playButtonImageClass = null;this._stopButtonImageClass = null;this._slides = null;this._jsonSlides = null;this._slideShowServicePath = null;this._slideShowServiceMethod = null;this._contextKey = null;this._imageHandling = null;this._useParms = false;this._loopInterval = 0;this._playInterval = 3000;this._tickHandler = null;this._loop = false;this._autoPlay = false;this._preLoad = false;this._inPlayMode = false;this._elementImage = null;this._bNext = null;this._bPrevious = null;this._bToFirst = null;this._bToLast = null;this._currentIndex = -1;this._currentValue = null;this._imageDescriptionLabel = null;this._imageAttributionLabel = null;this._slideNofMLabel = null;this._bPlay = null;this._timer = null;this._currentImageElement = null;this._images = null;this._clickNextHandler = null;this._clickPreviousHandler = null;this._clickToFirstHandler = null;this._clickToLastHandler = null;this._clickPlayHandler = null;this._tickHandler = null;this._imageLoadedHandler = null;}
b.Interactive.AjaxControls.SlideShowBehavior.prototype = {
initialize: function() {
b.Interactive.AjaxControls.SlideShowBehavior.callBaseMethod(this, 'initialize');var e = this.get_element();this._elementImage = e;var _divContent = document.createElement('DIV');e.parentNode.insertBefore(_divContent, e);e.parentNode.removeChild(e);_divContent.appendChild(e);this._currentImageElement = document.createElement('IMG');this._currentImageElement.style.display = 'none';_divContent.appendChild(this._currentImageElement);this.controlsSetup();if (this._bNext) {
this._clickNextHandler = Function.createDelegate(this, this._onClickNext);$(this._bNext).bind('click', this._clickNextHandler);}
if (this._bPrevious) {
this._clickPreviousHandler = Function.createDelegate(this, this._onClickPrevious);$(this._bPrevious).bind('click', this._clickPreviousHandler);}
if (this._bToFirst) {
this._clickToFirstHandler = Function.createDelegate(this, this._onClickToFirst);$(this._bToFirst).bind('click', this._clickToFirstHandler);}
if (this._bToLast) {
this._clickToLastHandler = Function.createDelegate(this, this._onClickToLast);$(this._bToLast).bind('click', this._clickToLastHandler);}
if (this._bPlay) {
this._clickPlayHandler = Function.createDelegate(this, this._onClickPlay);$(this._bPlay).bind('click', this._clickPlayHandler);}
this._imageLoadedHandler = Function.createDelegate(this, this._onImageLoaded);$(this._currentImageElement).bind('load', this._imageLoadedHandler);this._slideShowInit();},
dispose: function() {
if (this._clickNextHandler) {
$(this._bNext).unbind('click', this._clickNextHandler);this._clickNextHandler = null;}
if (this._clickPreviousHandler) {
$(this._bPrevious).unbind('click', this._clickPreviousHandler);this._clickPreviousHandler = null;}
if (this._clickToFirstHandler) {
$(this._bToFirst).unbind('click', this._clickToFirstHandler);this._clickToFirstHandler = null;}
if (this._clickToLastHandler) {
$(this._bToLast).unbind('click', this._clickToLastHandler);this._clickToLastHandler = null;}
if (this._clickPlayHandler) {
$(this._bPlay).unbind('click', this._clickPlayHandler);this._clickPlayHandler = null;}
if (this._imageLoadedHandler) {
$(this._currentImageElement).unbind('load', this._imageLoadedHandler);this._imageLoadedHandler = null;}
if (this._timer) {
this._timer.dispose();this._timer = null;}
b.Interactive.AjaxControls.SlideShowBehavior.callBaseMethod(this, 'dispose');},
add_slideChanged: function(handler) {
this.get_events().addHandler('slideChanged', handler);},
remove_slideChanged: function(handler) {
this.get_events().removeHandler('slideChanged', handler);},
raiseSlideChanged: function(eventArgs) {
var handler = this.get_events().getHandler('slideChanged');if (handler) {
if (!eventArgs) {
eventArgs = Sys.EventArgs.Empty;}
handler(this, eventArgs);}
},
add_slideChanging: function(handler) {
this.get_events().addHandler('slideChanging', handler);},
remove_slideChanging: function(handler) {
this.get_events().removeHandler('slideChanging', handler);},
raiseSlideChanging: function(previousSlide, newSlide) {
var handler = this.get_events().getHandler('slideChanging');if (handler) {
var eventArgs = new b.Interactive.AjaxControls.SlideShowEventArgs(previousSlide, newSlide, this._currentIndex);handler(this, eventArgs);return eventArgs.get_cancel();}
return false;},
get_contextKey: function() {
return this._contextKey;},
set_contextKey: function(value) {
if (this._contextKey != value) {
this._contextKey = value;this.set_useParms(true);if (this._elementImage) {
this._slideShowInit();}
this.raisePropertyChanged('contextKey');}
},
get_imageHandling: function() {
return this._imageHandling;},
set_imageHandling: function(value) {
if (this._imageHandling != value) {
this._imageHandling = value;this.set_useParms(true);if (this._elementImage) {
this._slideShowInit();}
this.raisePropertyChanged('imageHandling');}
},
get_useParms: function() {
return this._useParms;},
set_useParms: function(value) {
if (this._useParms != value) {
this._useParms = value;this.raisePropertyChanged('useParms');}
},
controlsSetup: function() {
if (this._nextButtonID) {
this._bNext = $get(this._nextButtonID);}
if (this._previousButtonID) {
this._bPrevious = $get(this._previousButtonID);}
if (this._toFirstButtonID) {
this._bToFirst = $get(this._toFirstButtonID);}
if (this._toLastButtonID) {
this._bToLast = $get(this._toLastButtonID);}
if (this._playButtonID) {
this._bPlay = $get(this._playButtonID);if (this._playButtonImageClass && this._stopButtonImageClass) {
with ($(this._bPlay)) {
removeClass(this._stopButtonImageClass);addClass(this._playButtonImageClass);}
}
else {
this._bPlay.value = this._playButtonValue;}
}
if (this._imageDescriptionLabelID) {
this._imageDescriptionLabel = $get(this._imageDescriptionLabelID);}
if (this._imageAttributionLabelID) {
this._imageAttributionLabel = $get(this._imageAttributionLabelID);}
if (this._slideNofMLabelID) {
this._slideNofMLabel = $get(this._slideNofMLabelID);}
},
resetButtons: function() {
if (!this._loop) {
if (this._slides.length <= this._currentIndex + 1) {
if (this._bToLast) this._bToLast.disabled = true;if (this._bNext) this._bNext.disabled = true;if (this._bPlay) this._bPlay.disabled = true;if (this._bToFirst) this._bToFirst.disabled = false;if (this._bPrevious) this._bPrevious.disabled = false;this._inPlayMode = false;if (this._timer) {
this._timer.set_enabled(false);}
if (this._bPlay) {
if (this._playButtonImageClass && this._stopButtonImageClass) {
with ($(this._bPlay)) {
removeClass(this._stopButtonImageClass);addClass(this._playButtonImageClass);}
}
} else {
this._bPlay.value = this._playButtonValue;}
} else {
if (this._bToLast) this._bToLast.disabled = false;if (this._bNext) this._bNext.disabled = false;if (this._bPlay) this._bPlay.disabled = false;}
if (this._currentIndex <= 0) {
if (this._bToFirst) this._bToFirst.disabled = true;if (this._bPrevious) this._bPrevious.disabled = true;} else {
if (this._bToFirst) this._bToFirst.disabled = false;if (this._bPrevious) this._bPrevious.disabled = false;}
}
else {
if (this._slides.length == 0) {
if (this._bToFirst) this._bToFirst.disabled = true;if (this._bPrevious) this._bPrevious.disabled = true;if (this._bToLast) this._bToLast.disabled = true;if (this._bNext) this._bNext.disabled = true;if (this._bPlay) this._bPlay.disabled = true;}
}
if (this._inPlayMode) {
this._timer.set_enabled(false);this._timer.set_enabled(true);}
},
resetSlideShowButtonState: function() {
if (this._inPlayMode) {
if (this._bPlay) {
if (this._playButtonImageClass && this._stopButtonImageClass) {
with ($(this._bPlay)) {
removeClass(this._playButtonImageClass);addClass(this._stopButtonImageClass);}
} else {
this._bPlay.value = this._stopButtonValue;}
}
}
else {
this.resetButtons();if (this._bPlay) {
if (this._playButtonImageClass && this._stopButtonImageClass) {
with ($(this._bPlay)) {
removeClass(this._stopButtonImageClass);addClass(this._playButtonImageClass);}
} else {
this._bPlay.value = this._playButtonValue;}
}
}
},
setCurrentImage: function() {
if (this._slides[this._currentIndex]) {
if (this._inPlayMode) {
this._timer.set_enabled(false);}
this._updateImage(this._currentImageElement, this._slides[this._currentIndex]);} else {
this._currentImageElement.src = '';}
if (Sys.Browser.agent == Sys.Browser.Opera) {
this._onImageLoaded(true);}
},
updateImage: function(value) {
if (value) {
if (this.raiseSlideChanging(this._currentValue, value)) {
return;}
this._currentValue = value;this._updateImage(this._elementImage, value);this._elementImage.alt = "Slideshow";this._elementImage.title = value.imageTitle ? value.imageTitle : value.Description ? value.Description : "";if (this._imageDescriptionLabel) {
this._imageDescriptionLabel.innerHTML = value.Description ? value.Description : "";}
if (this._imageAttributionLabel) {
this._imageAttributionLabel.innerHTML = value.Attribution ? value.Attribution : "";}
if (this._slideNofMLabel) {
this._slideNofMLabel.innerHTML = String(this._currentIndex + 1) + " of " + String(this._slides.length);}
this.raiseSlideChanged(value);this.resetButtons();if (this._inPlayMode) {
this._timer.set_enabled(true);}
}
},
_updateImage: function(element, slide) {
if (slide.ImagePath.indexOf('?') == -1) {
var imageWidth = $(element).parent().width() - 2;var imageHeight = Math.round(imageWidth / 1.333);if (slide.ImageWidth < imageWidth && slide.ImageWidth > 0) imageWidth = slide.ImageWidth;if (slide.ImageHeight < imageHeight && slide.ImageHeight > 0) imageHeight = slide.ImageHeight;if (imageHeight > 0 && slide.ImageHeight > 0) {
if ((imageWidth / imageHeight) > (slide.ImageWidth / slide.ImageHeight)) {
imageWidth = 0;} else {
imageHeight = 0;}
}
if (imageHeight > 0 && !(imageWidth > 0)) {
imageWidth = slide.ImageWidth * imageHeight / slide.ImageHeight;} else if (!(imageHeight > 0) && imageWidth > 0) {
imageHeight = slide.ImageHeight * imageWidth / slide.ImageWidth;}
if (imageHeight > 0 && imageWidth > 0) {
$(element).css('image-rendering', 'optimizeQuality');$(element).css('-ms-interpolation-mode', 'bicubic');$(element).width(Math.round(imageWidth));$(element).height(Math.round(imageHeight));}
}
$(element).attr("src", slide.ImagePath);},
get_imageDescriptionLabelID: function() {
return this._imageDescriptionLabelID;},
set_imageDescriptionLabelID: function(value) {
if (this._imageDescriptionLabelID != value) {
this._imageDescriptionLabelID = value;this.raisePropertyChanged('imageDescriptionLabelID');}
},
get_imageAttributionLabelID: function() {
return this._imageAttributionLabelID;},
set_imageAttributionLabelID: function(value) {
if (this._imageAttributionLabelID != value) {
this._imageAttributionLabelID = value;this.raisePropertyChanged('imageAttributionLabelID');}
},
get_nextButtonID: function() {
return this._nextButtonID;},
set_nextButtonID: function(value) {
if (this._nextButtonID != value) {
this._nextButtonID = value;this.raisePropertyChanged('nextButtonID');}
},
get_playButtonID: function() {
return this._playButtonID;},
set_playButtonID: function(value) {
if (this._playButtonID != value) {
this._playButtonID = value;this.raisePropertyChanged('playButtonID');}
},
get_playButtonText: function() {
return this._playButtonValue;},
set_playButtonText: function(value) {
if (this._playButtonValue != value) {
this._playButtonValue = value;this.raisePropertyChanged('playButtonText');}
},
get_playButtonImageClass: function() {
return this._playButtonImageClass;},
set_playButtonImageClass: function(value) {
if (this._playButtonImageClass != value) {
this._playButtonImageClass = value;this.raisePropertyChanged('playButtonImageClass');}
},
get_stopButtonText: function() {
return this._stopButtonValue;},
set_stopButtonText: function(value) {
if (this._stopButtonValue != value) {
this._stopButtonValue = value;this.raisePropertyChanged('stopButtonText');}
},
get_stopButtonImageClass: function() {
return this._stopButtonImageClass;},
set_stopButtonImageClass: function(value) {
if (this._stopButtonImageClass != value) {
this._stopButtonImageClass = value;this.raisePropertyChanged('stopButtonImageClass');}
},
get_playInterval: function() {
return this._playInterval;},
set_playInterval: function(value) {
if (this._playInterval != value) {
this._playInterval = value;this.raisePropertyChanged('playInterval');}
},
get_loopInterval: function() {
return this._loopInterval;},
set_loopInterval: function(value) {
if (this._loopInterval != value) {
this._loopInterval = value;this.raisePropertyChanged('loopInterval');}
},
get_previousButtonID: function() {
return this._previousButtonID;},
set_previousButtonID: function(value) {
if (this._previousButtonID != value) {
this._previousButtonID = value;this.raisePropertyChanged('previousButtonID');}
},
get_toFirstButtonID: function() {
return this._toFirstButtonID;},
set_toFirstButtonID: function(value) {
if (this._toFirstButtonID != value) {
this._toFirstButtonID = value;this.raisePropertyChanged('toFirstButtonID');}
},
get_toLastButtonID: function() {
return this._toLastButtonID;},
set_toLastButtonID: function(value) {
if (this._toLastButtonID != value) {
this._toLastButtonID = value;this.raisePropertyChanged('toLastButtonID');}
},
get_slideNofMLabelID: function() {
return this._slideNofMLabelID;},
set_slideNofMLabelID: function(value) {
if (this._slideNofMLabelID != value) {
this._slideNofMLabelID = value;this.raisePropertyChanged('slideNofMLabelID');}
},
get_slides: function() {
return this._jsonSlides;},
set_slides: function(value) {
if (this._jsonSlides != value) {
this._slides = eval(this._jsonSlides = value);this.raisePropertyChanged('slides');}
},
get_slideShowServicePath: function() {
return this._slideShowServicePath;},
set_slideShowServicePath: function(value) {
if (this._slideShowServicePath != value) {
this._slideShowServicePath = value;this.raisePropertyChanged('slideShowServicePath');}
},
get_slideShowServiceMethod: function() {
return this._slideShowServiceMethod;},
set_slideShowServiceMethod: function(value) {
if (this._slideShowServiceMethod != value) {
this._slideShowServiceMethod = value;this.raisePropertyChanged('slideShowServiceMethod');}
},
get_loop: function() {
return this._loop;},
set_loop: function(value) {
if (this._loop != value) {
this._loop = value;this.raisePropertyChanged('loop');}
},
get_autoPlay: function() {
return this._autoPlay;},
set_autoPlay: function(value) {
if (this._autoPlay != value) {
this._autoPlay = value;this.raisePropertyChanged('autoPlay');}
},
get_preLoad: function() {
return this._preLoad;},
set_preLoad: function(value) {
if (this._preLoad != value) {
this._preLoad = value;this.raisePropertyChanged('preLoad');}
},
_onImageLoaded: function(e) {
this.updateImage(this._slides[this._currentIndex]);this.resetButtons();this._cacheImage(this._currentIndex + 1);},
_onClickToFirst: function(e) {
e.preventDefault();e.stopPropagation();this._clickToFirst();},
_clickToFirst: function() {
if (this._slides) {
if (this._inPlayMode) {
this._inPlayMode = false;this._timer.set_enabled(false);this.resetSlideShowButtonState();}
this._currentIndex = 0;this.setCurrentImage();return true;}
return false;},
_onClickToLast: function(e) {
e.preventDefault();e.stopPropagation();this._clickToLast();},
_clickToLast: function() {
if (this._slides) {
if (this._inPlayMode) {
this._inPlayMode = false;this._timer.set_enabled(false);this.resetSlideShowButtonState();}
this._currentIndex = this._slides.length - 1;this.setCurrentImage();return true;}
return false;},
_onClickNext: function(e) {
e.preventDefault();e.stopPropagation();this._clickNext();},
_clickNext: function() {
if (this._slides) {
if ((this._currentIndex + 1) < this._slides.length) {
++this._currentIndex;} else if (this._loop) {
this._currentIndex = 0;} else {
return false;}
this.setCurrentImage();return true;}
return false;},
_onClickPrevious: function(e) {
e.preventDefault();e.stopPropagation();this._clickPrevious();},
_clickPrevious: function() {
if (this._slides) {
if ((this._currentIndex - 1) >= 0) {
--this._currentIndex;}
else if (this._loop) {
this._currentIndex = this._slides.length - 1;} else {
return false;}
this.setCurrentImage();return true;}
return false;},
_onClickPlay: function(e) {
e.preventDefault();e.stopPropagation();if (!this._inPlayMode) this._clickNext();this._play();},
_play: function() {
if (this._slides) {
if (this._inPlayMode) {
this._inPlayMode = false;this._timer.set_enabled(false);this.resetSlideShowButtonState();} else {
this._inPlayMode = true;if (!this._timer) {
this._timer = new Sys.Timer();this._timer.set_interval(this._playInterval);this._tickHandler = Function.createDelegate(this, this._onPlay);this._timer.add_tick(this._tickHandler);}
this.resetSlideShowButtonState();this._timer.set_enabled(true);}
}
},
_onPlay: function(e) {
if (this._slides && this._inPlayMode) {
if ((this._currentIndex + 1) < this._slides.length) {
++this._currentIndex;this.setCurrentImage();if (this._currentIndex == (this._slides.length - 1) && this._loop && this._loopInterval) {
this._timer.set_interval(this._playInterval + this._loopInterval);}
return true;} else if (this._loop) {
if (this._loopInterval) {
this._timer.set_interval(this._playInterval);}
this._currentIndex = 0;this.setCurrentImage();return true;} else {
this._inPlayMode = false;this.resetSlideShowButtonState();}
}
return false;},
_slideShowInit: function() {
this._currentIndex = -1;this._inPlayMode = false;this._currentValue = null;this._images = null;if (this._slides) {
this._initShow();} else {
var params = null;if (this._useParms) {
params = { contextKey: this._contextKey, imageHandling: this._imageHandling };}
Sys.Net.WebServiceProxy.invoke(
this._slideShowServicePath,
this._slideShowServiceMethod,
true,
params,
Function.createDelegate(this, this._initSlides),
null,
null);}
},
_initSlides: function(sender, eventArgs) {
this._slides = sender;this._jsonSlides = "[{}]";this.raisePropertyChanged('slides');this._initShow();},
_initShow: function() {
if (this._slides && this._slides.length > 0) {
this._images = new Array();if (this._preLoad) {
for (var i = 0;i < this._slides.length;i++) {
this._cacheImage(i);}
} else {
this._cacheImage(0);}
this._clickNext();if (this._autoPlay) {
this._play();}
} else {
this.set_slides(null);}
},
_cacheImage: function(i) {
if (this._images.length < this._slides.length) {
if (i <= this._images.length) {
if (this._slides[i]) {
this._images[i] = new Image();this._images[i].src = this._slides[i].ImagePath;}
}
}
}
}
b.Interactive.AjaxControls.SlideShowBehavior.registerClass('b.Interactive.AjaxControls.SlideShowBehavior', b.Interactive.AjaxControls.BehaviorBase);b.Interactive.AjaxControls.SlideShowEventArgs = function(previousSlide, nextSlide, slideIndex, beginningSlide) {
b.Interactive.AjaxControls.SlideShowEventArgs.initializeBase(this);this._beginningSlide = beginningSlide;this._previousSlide = previousSlide;this._nextSlide = nextSlide;this._slideIndex = slideIndex;}
b.Interactive.AjaxControls.SlideShowEventArgs.prototype = {
get_beginningSlide : function() {
return this._beginningSlide;},
get_previousSlide : function() {
return this._previousSlide;},
get_nextSlide : function() {
return this._nextSlide;},
get_slideIndex : function () {
return this._slideIndex;}
}
b.Interactive.AjaxControls.SlideShowEventArgs.registerClass('b.Interactive.AjaxControls.SlideShowEventArgs', Sys.CancelEventArgs);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();