25 lines
12 KiB
JavaScript
25 lines
12 KiB
JavaScript
(function(b,d){b.ObjectRegistry=b.ObjectRegistry||{};b.ObjectRegistry.Slideshow=b.ObjectRegistry.Slideshow||{};b.ObjectRegistry.Slideshow.Register=function(a,e){b.ObjectRegistry.Slideshow.hasOwnProperty(a)&&g("WARNING \x3e Slideshow object is already registered. Rebinding new slideshow "+a+". Old one will fade into darkness.");return b.ObjectRegistry.Slideshow[a]=e};b.Slideshow=function(){this.slideCount=0;this.transitionType;this.slider=null;this.slideViewTime=this.transitionTime=1E3;this.currentSlideIndex=
|
|
0;this.uniqueID=this.autoTransition=null;this.liveEditEnabled=!1;return this};b.Slideshow.prototype.DIAGNOSTIC_MODE=!1;var g=function(a){b.Slideshow.prototype.DIAGNOSTIC_MODE&&console.log("Slideshow diagnostic[SlideshowGenerator.js] "+a)};b.Slideshow.prototype.initSlides=function(a){d("img[data-delay-load]",a).each(function(){var a=d(this),b=attrOrProps(a,"data-delay-load");attrOrProps(a,"src",b)})};b.Slideshow.prototype.initSlidePlusAndMinusOneIndex=function(a,e,b){if(0<d("img[data-delay-load]",
|
|
e).length){e=d("img[data-delayed-image]",e);var c=e.length,g=function(a,c){var b=d(a),e=attrOrProps(b,"dataset"),e=void 0==e?b.attr("data-delay-load"):e.delayLoad,h=attrOrProps(b,"src");"undefined"!==typeof c&&0!==c?b.css("height",c+"px"):b.css("height","auto");e!==h&&(void 0!==e&&""!==e&&null!==e)&&(attrOrProps(b,"src",e),b.removeAttr("data-delay-load"))};g(e[a],b);a+1>=c?g(e[0],b):g(e[a+1],b);0>a-1?g(e[c-1],b):g(e[a-1],b)}else a=d("img",e),0!==b?a.css("height",b+"px"):a.css("height","auto")};b.Slideshow.prototype.generate=
|
|
function(a,e,h,c,m,k){g("Generating Slideshow for "+a);b.ObjectRegistry.Slideshow.Register(a,this);var f=this.mapUi(a);this.slider=this.createSlider(f);this.slider.$slider.removeClass("slide");this.initSlidePlusAndMinusOneIndex(0,f.$slider,k);null===e?(this.transitionTime=1E3*f.values.transitionTiming,this.slideViewTime=1E3*f.values.slideTiming):(this.transitionTime=1E3*e,this.slideViewTime=1E3*h);this.transitionType=f.transitionType;this.slideCount=f.$slides.length;this.currentSlideIndex=this.transitionType===
|
|
this.TransitionType.Slide?1:0;this.uniqueID=a;this.liveEditEnabled=c;a=100/this.slideCount;1<this.slideCount&&f.$slides.first().addClass("showing");if(this.transitionType===this.TransitionType.Slide)this.slider.createOverlapImagesForFirstAndLastSlides(),this.slideCount=f.$slides.length,a=100/this.slideCount,f.$slides.removeClass("hidden"),f.$slider.css("left","-100%");else if(this.transitionType===this.TransitionType.Fade)for(f.$slides.slice(1).animate({opacity:0},0),f.$slides.removeClass("hidden"),
|
|
e=0;e<this.slideCount;e++){h=a*e;if(/(?:\b(MS)?IE\s+|\bTrident\/7\.0;.*\s+rv:)(\d+)/.test(navigator.userAgent)||-1<navigator.userAgent.indexOf("Edge"))h=(Math.floor(100*a)/100).toFixed(2)*e;d(f.$slides[e]).css("left","-"+h+"%")}f.$slider.css("width",this.slideCount+"00%");f.$slides.css("width",a+"%");f.$pages.first().addClass("active");f.$slides.addClass("slideshowOptions nonEmpty");this.autoTransition=function(){var a=this;this.isDisposed()||f.$slider.animate({delay:1},this.slideViewTime,function(){g("Begin Slide Transition Cycle ( Slide View Time: "+
|
|
a.slideViewTime+" ms, Transition Time: "+a.transitionTime+" ms )");a.next(a.autoTransition)})};m||this.autoTransition();this.bindUx()};b.Slideshow.prototype.isDisposed=function(){return this!==b.ObjectRegistry.Slideshow[this.uniqueID]};b.Slideshow.prototype.pause=function(){this.slider.$slider.stop(!0);this.slider.$slides.stop(!0);this.autoTransition=null};b.Slideshow.prototype.transitionToSlide=function(a,b,h){g("Transition to "+a);var c=this,m=function(){if(!c.isDisposed()){g("Fade Animation Complete for slide "+
|
|
c.currentSlideIndex+" to "+a+" - Update Indexes and Classes. Invoke Next Transition");c.slider.$slider.find(".showing").removeClass("showing");c.slider.$pager.find(".active").removeClass("active");d(c.slider.$pages[a]).addClass("active");d(c.slider.$slides[a]).addClass("showing");c.currentSlideIndex=a;for(var b=0,b=0;b<c.slider.$slides.length;b++)b!=a&&d(c.slider.$slides[b]).stop(!0).animate({opacity:0},0);"function"===typeof h&&h.call(c)}},k=function(){if(!c.isDisposed()){var b=d(c.slider.$slides[a]);
|
|
g("Dot Update Invoked for "+a+" corresponding to id "+attrOrProps(b,"id")+".");d("#dot"+attrOrProps(b,"id")).parent("ol").children("li").removeClass("active");d("#dot"+attrOrProps(b,"id")).addClass("active")}};if(this.transitionType===this.TransitionType.Slide){a>this.slideCount-2?a=1:1>a&&(a=this.slideCount-2);g("(Slide) Current Slide: "+this.currentSlideIndex+"; Target Slide: "+a);b=this.GetSlideDirectionTransitionType(a,b);k();var f=0,l=0;switch(b){case this.SlideTransitionDirectionType.FirstToLast:f=
|
|
0;g("First Slide to Last Slide Transition");this.slider.$slider.animate({left:"0%"},this.transitionTime,function(){var a=c.slider.$slides.length-2;/(?:\b(MS)?IE\s+|\bTrident\/7\.0;.*\s+rv:)(\d+)/.test(navigator.userAgent)&&(f=100/c.slider.$slides.length%c.slider.$slides[a].style.width.replace("%","")*a*a);l=100*a-f;c.slider.$slider.css("left","-"+l+"%");c.slider.$slider.find(".showing").removeClass("showing");c.slider.$pager.find(".active").removeClass("active");d(c.slider.$pages[a]).addClass("active");
|
|
d(c.slider.$slides[a]).addClass("showing");c.currentSlideIndex=a;"function"===typeof h&&h.call(c)});break;case this.SlideTransitionDirectionType.LastToFirst:f=0;/(?:\b(MS)?IE\s+|\bTrident\/7\.0;.*\s+rv:)(\d+)/.test(navigator.userAgent)&&(f=100/c.slider.$slides.length%c.slider.$slides[c.currentSlideIndex].style.width.replace("%","")*a*a);l=100*(c.currentSlideIndex+1)-f;this.slider.$slider.animate({left:"-"+l+"%"},this.transitionTime,function(){g("Last Slide to First Slide Transition");c.slider.$slider.css("left",
|
|
"-100%");c.slider.$slider.find(".showing").removeClass("showing");c.slider.$pager.find(".active").removeClass("active");d(c.slider.$pages[1]).addClass("active");d(c.slider.$slides[1]).addClass("showing");c.currentSlideIndex=1;"function"===typeof h&&h.call(c)});break;default:f=0,/(?:\b(MS)?IE\s+|\bTrident\/7\.0;.*\s+rv:)(\d+)/.test(navigator.userAgent)&&(f=100/c.slider.$slides.length%c.slider.$slides[c.currentSlideIndex].style.width.replace("%","")*a*a),l=100*a-f,this.slider.$slider.animate({left:"-"+
|
|
l+"%"},this.transitionTime,function(){g("Inner Slide Transition");c.slider.$slider.find(".showing").removeClass("showing");c.slider.$pager.find(".active").removeClass("active");d(c.slider.$pages[c.currentSlideIndex]).addClass("active");d(c.slider.$slides[c.currentSlideIndex]).addClass("showing");c.currentSlideIndex=a;"function"===typeof h&&h.call(c)})}}else this.transitionType===this.TransitionType.Fade&&(g("(Fade) Current Slide: "+this.currentSlideIndex+"; Target Slide: "+a),a>this.slideCount-1?
|
|
a=0:0>a&&(a=this.slideCount-1),d(this.slider.$slides).css("zindex",1),d(this.slider.$slides).animate({opacity:0},this.transitionTime,k),d(this.slider.$slides[a]).stop(!0).css("zindex",2).animate({opacity:1},this.transitionTime,m));c.initSlidePlusAndMinusOneIndex(a,c.slider.$slider)};b.Slideshow.prototype.next=function(a){this.transitionToSlide(this.currentSlideIndex+1,this.DirectionType.Forward,a)};b.Slideshow.prototype.previous=function(a){this.transitionToSlide(this.currentSlideIndex-1,this.DirectionType.Backward,
|
|
a)};b.Slideshow.prototype.dotClick=function(a){a=this.mapDotClickUi(a);this.transitionToSlide(a.selectedSlideIndex,this.DirectionType.Omni)};b.Slideshow.prototype.TransitionType={Fade:0,Slide:1};b.Slideshow.prototype.DirectionType={Forward:0,Backward:1,Omni:2};b.Slideshow.prototype.SlideTransitionDirectionType={Inside:0,FirstToLast:1,LastToFirst:2};b.Slideshow.prototype.GetSlideDirectionTransitionType=function(a,b){return 1>=this.currentSlideIndex&&a===this.slideCount-2&&b===this.DirectionType.Backward?
|
|
this.SlideTransitionDirectionType.FirstToLast:1===a&&this.currentSlideIndex>=this.slideCount-2&&b===this.DirectionType.Forward?this.SlideTransitionDirectionType.LastToFirst:this.SlideTransitionDirectionType.Inside};b.Slideshow.prototype.mapUi=function(a){var b={$slideshow:d(".cpSliderJS"+a).closest(".widget.slideShow"),$slider:d(".cpSliderJS"+a),$slides:d(".cpSliderJS"+a).find("li"),$pager:d(".pagerJS"+a),$pages:d(".pagerJS"+a).find("li"),transitionType:d(".cpSliderJS"+a).hasClass("slide")?this.TransitionType.Slide:
|
|
this.TransitionType.Fade,NotifySlidesAdded:function(){b.$slides=d(".cpSliderJS"+a).find("li")},values:{}};b.values.transitionTiming=b.$slideshow.children("input.transitionTiming").val();b.values.slideTiming=b.$slideshow.children("input.slideTiming").val();return b};b.Slideshow.prototype.createSlider=function(a){var b={$slider:a.$slider,$slides:a.$slides,$pager:a.$pager,$pages:a.$pages,setSlide:function(b){a.$slider.hasClass("slide")&&a.$slider.css("left","-"+b.toString()+"00%")},getCurrentlyShownSlide:function(){return a.$slider.find(".showing")},
|
|
createOverlapImagesForFirstAndLastSlides:function(){var d=a.$slider.find("li");d.first().clone().insertAfter(a.$slider.find("li").last());d.last().clone().insertBefore(a.$slider.find("li").first());a.NotifySlidesAdded();b.$slides=a.$slides}};return b};b.Slideshow.prototype.mapDotClickUi=function(a){return{$dots:a.parents(".pager").children("li"),$selectedDot:a.parent("li"),$selectedImage:d("#"+attrOrProps(a,"data-targetImageli")),$images:d("#"+attrOrProps(a,"data-targetImageli")).parent("ol").children("li"),
|
|
selectedSlideIndex:this.transitionType===this.TransitionType.Slide?parseInt(a.html()):parseInt(a.html()-1)}};b.Slideshow.prototype.bindUx=function(){var a=this;d(".prevJS"+this.uniqueID).unbind("click").click(function(){a.pause();a.previous()});d(".dotJS"+this.uniqueID).unbind("click").click(function(){a.pause();a.dotClick(d(this))});d(".nextJS"+this.uniqueID).unbind("click").click(function(){a.pause();a.next()});a.liveEditEnabled&&(a.slider.$slides.add("p.slideshowOptions.empty.placeholder").unbind("click").click(function(a){a=
|
|
d(this).closest(".widget.slideShow");var b=ContentCollectionInstance.PageID,c=ContentCollectionInstance.ModuleID,g=a.data("widgetid"),k=a.find(".hdnSlideshowUniqueID").val();callbackfnSlideshowSave=null;parentID_Slideshow=attrOrProps(a,"id");ContentCollectionInstance.SlideshowWidgetID=g;$popUp_Slideshow=openCpModal({title:"Slideshow",className:"newCP adminWrap cpPopOver admin modalSlideshow",isFrontEnd:!1,useIframe:!1,draggable:!0,url:"/Slideshow/SlideshowConfiguration/"+k+("?pageID\x3d"+b+"\x26moduleID\x3d"+
|
|
c)})}),d(".widget.slideShow").siblings("a.handle.options").each(function(){var a=d(this);a.data("cpPopover")&&a.data("cpPopover").destroy();var b=attrOrProps(a.parents('[data-cprole$\x3d"ontentContainer"]'),"id"),c=a.parents(".pageContent").filter(":first").data("containerid"),b="/ContentWidgets/SlideshowOptions?widgetID\x3d"+a.data("widgetid")+"\x26pageID\x3d"+ContentCollectionInstance.PageID+"\x26contentContainerExternalID\x3d"+b+"\x26moduleID\x3d"+ContentCollectionInstance.ModuleID+"\x26contentContainerID\x3d"+
|
|
c;a.cpPopover({url:b,className:"options adminWrap",onClose:function(a,b){a.preventDefault();window.CommonPopoverInstance.hide(b);d(document.activeElement).change()}})}))}})(this,"undefined"==typeof $?window.parent.$:$);function SlideshowColorPicker(b,d,g){this.$spectrumInput=$(b);this.$colorInput=$(d);this.defaultColor=g;this.startingColor=this.$colorInput&&this.$colorInput.val()?this.$colorInput.val():this.defaultColor}
|
|
SlideshowColorPicker.prototype.init=function(){var b=this;b.$spectrumInput.spectrum("destroy").spectrum({color:b.startingColor,showInput:!0,showPalette:!0,showPaletteOnly:!1,showSelectionPalette:!0,preferredFormat:"hex",change:function(d){d=d.toHexString();b.setValueSpectrum(d)}});b.setValueSpectrum(b.startingColor);b.$spectrumInput.parent().delegate(".clearValue","click",function(d){d&&(d.stopPropagation?d.stopPropagation():d.cancelBubble=!0);b.clearValueSpectrum()})};
|
|
SlideshowColorPicker.prototype.setValueSpectrum=function(b){this.$colorInput.val(b);this.$spectrumInput.spectrum("set",b);this.$spectrumInput.siblings("a.clearValue").remove();b&&b!==this.defaultColor&&this.$spectrumInput.next().after('\x3ca class\x3d"clearValue" title\x3d"Clear Color" href\x3d"#" onclick\x3d"return false;" style\x3d""\x3eClear\x3c/a\x3e')};
|
|
SlideshowColorPicker.prototype.clearValueSpectrum=function(){this.$spectrumInput.siblings("a.clearValue").fadeOut(300);this.$colorInput.val("");this.setValueSpectrum(this.defaultColor)}; |