function addShowcase(sc) { if (sc){ v5.showcaseList.push(sc); } } function removeShowcase(sc) { for (i = 0; i < v5.showcaseList.length; i++){ if (v5.showcaseList[i] == sc){ if (typeof(v5.showcaseList[i].stopAutoRotate) == 'function') { v5.showcaseList[i].stopAutoRotate(); } v5.showcaseList.splice(i, 1); break; } } } function removeAllShowcases() { removeAllShowcaseIntervals(); v5.showcaseList.splice(0); v5.showcaseList.length = 0; } function addShowcaseInterval(intv, playFunc) { v5.showcaseIntervals.push(intv); v5.showcasePlayFunctions.push(playFunc); } function removeShowcaseInterval(intv, keepPlay) { for (i = 0; i < v5.showcaseIntervals.length; i++){ if (v5.showcaseIntervals[i] == intv){ v5.showcaseIntervals.splice(i, 1); v5.showcasePlayFunctions.splice(i, 1); break; } } clearInterval(intv); } function removeAllShowcaseIntervals() { for (i = 0; i < v5.showcaseIntervals.length; i++){ clearInterval(v5.showcaseIntervals[i]); } v5.showcaseIntervals.length = 0; //alert('showcase intervals cleared'); } function removeAllPlayFunctions() { v5.showcasePlayFunctions.length = 0; } function stopAllShowcases() { removeAllShowcaseIntervals(); /* for (i = 0; i < v5.showcaseList.length; i++){ v5.showcaseList[i].sliderShowcase.showcaseWrapper.stopAutoRotate(); } */ } function startAllShowcases() { for (i = 0; i < v5.showcasePlayFunctions.length; i++){ if (typeof(v5.showcasePlayFunctions[i]) == 'function'){ interval = v5.showcasePlayFunctions[i](); setTimeout(function() { addShowcaseInterval(interval, v5.showcasePlayFunctions[i]); }, 0); } } } (function($) { $.fn.accordionShowcase = function(options) { var defaults = { slides: '>div', animationSpeed: 900, autorotation: true, autorotationSpeed: 3, easing: 'easeOutQuint', event: 'mouseover', imageShadow:true, imageShadowStrength:0.5, fontOpacity: 1, backgroundOpacity: 0.8 }; var options = $.extend(defaults, options); return this.each(function() { $(this).bind('contextmenu',function(e){ return noEvent(e); }); var slideWrapper = $(this), slides = slideWrapper.find(options.slides).css('display','block'), slide_count = slides.length, slide_width = slideWrapper.width() / slide_count, expand_slide = slides.width(), minimized_slide = (slideWrapper.width() - expand_slide) / (slide_count - 1), overlay_modifier = 200 *(1- options.imageShadowStrength), excerptWrapper = slideWrapper.find('.feature_excerpt'), interval = '', current_slide = 0; excerptWrapper.wrap('').removeClass('feature_excerpt').addClass('position_excerpt'); excerptWrapper = slideWrapper.find('.feature_excerpt').css('opacity',options.backgroundOpacity); excerptWrapper.equalHeights().find('.position_excerpt').css({display:'block', opacity:0, position:'absolute'}); var excerptWrapperHeight = excerptWrapper.height(); slides.each(function(i) { var this_slide = $(this), this_slide_a = this_slide.find('a'), real_excerpt = this_slide.find('.position_excerpt'), feature_excerpt = this_slide.find('.feature_excerpt'), real_excerpt_height = real_excerpt.height(), slide_heading = this_slide.find('.sliderheading'), cloned_heading = slide_heading.clone().appendTo(this_slide_a).addClass('heading_clone').removeClass('real_heading').css({opacity:options.fontOpacity, width:slide_width-30}), clone_height = cloned_heading.height(), modifier = parseInt(feature_excerpt.css('paddingBottom')); this_slide.css('backgroundPosition',parseInt((slide_width/2)-8) + 'px ' + parseInt((this_slide.height()- excerptWrapperHeight)/2 -8) + 'px'); cloned_heading.css({bottom: (excerptWrapperHeight-clone_height)/2 +modifier}); real_excerpt.css({bottom: (excerptWrapperHeight-real_excerpt_height)/2 +modifier}); this_slide.data( 'data', { this_slides_position: i * slide_width, pos_active_higher: i * minimized_slide, pos_active_lower: ((i-1) * minimized_slide) + expand_slide }); this_slide.css({zIndex:i+1, left: i * slide_width, width:slide_width + overlay_modifier}); }); jQuery('#'+slideWrapper.attr('id')).imagePreloader({callback:add_functionality}); function add_functionality() { startAutoRotate(); slides.each(function(i) { var this_slide = $(this), real_excerpt = this_slide.find('.position_excerpt'), cloned_heading = this_slide.find('.heading_clone'); real_heading = this_slide.find('.real_heading'); this_slide.bind(options.event, function(event, continue_autoslide) { if(!continue_autoslide) { stopAutoRotate(); } var objData = this_slide.data( 'data' ); real_excerpt.stop().animate({opacity:options.fontOpacity},options.animationSpeed, options.easing); cloned_heading.stop().animate({opacity:0},options.animationSpeed, options.easing); this_slide.stop().animate({ width: expand_slide + (overlay_modifier * 1.2), left: objData.pos_active_higher}, options.animationSpeed, options.easing); slides.each(function(j){ if (i !== j) { var this_slide = $(this), real_excerpt = this_slide.find('.position_excerpt'), cloned_heading = this_slide.find('.heading_clone'), objData = this_slide.data('data'), new_pos = objData.pos_active_higher; if(i < j) { new_pos = objData.pos_active_lower; } this_slide.stop().animate({left: new_pos, width:minimized_slide + overlay_modifier},options.animationSpeed, options.easing); real_excerpt.stop().animate({opacity:0},options.animationSpeed, options.easing); cloned_heading.stop().animate({opacity:options.fontOpacity},options.animationSpeed, options.easing); } }); }); this_slide.bind('mouseout', function(event) { startAutoRotate(); }); }); slideWrapper.bind('mouseleave', function() { slides.each(function(i) { var this_slide = $(this), real_excerpt = this_slide.find('.position_excerpt'), cloned_heading = this_slide.find('.heading_clone'), objData = this_slide.data('data'), new_pos = objData.this_slides_position; this_slide.stop().animate({left: new_pos, width:slide_width + overlay_modifier},options.animationSpeed, options.easing); real_excerpt.stop().animate({opacity:0},options.animationSpeed, options.easing); cloned_heading.stop().animate({opacity:options.fontOpacity},options.animationSpeed, options.easing); }); }); } function startAutoRotate() { if(options.autorotation){ current_slide = 0; interval = setInterval(function() { autorotation(); }, (parseInt(options.autorotationSpeed) * 1000)); addShowcaseInterval(interval); } } function stopAutoRotate() { if (interval){ removeShowcaseInterval(interval); interval = null; } } function autorotation() { if(slide_count == current_slide) { slideWrapper.trigger('mouseleave'); current_slide = 0; } else { slides.filter(':eq('+current_slide+')').trigger(options.event,[true]); current_slide ++; } } function getAlpha(rgb, opacity){ var rgba = ''; if (rgb && rgb.indexOf('rgb(') != -1){ var tmp = rgb.replace('rgb(', '').replace(')', ''); rgba = 'rgba('+tmp+', '+opacity+')'; return rgba; } else if (rgb && rgb.indexOf('rgba(') != -1){ var tmp = rgb.replace('rgba(', '').replace(')', ''); var commas = 0; var tmpEx = ''; for (i = 0; i < tmp.length; i++){ tmpEx += tmp[i]; if (tmp[i] == ','){ commas++; if (commas == 3) { break; } } } rgba = 'rgba('+tmpEx+' '+opacity+')'; return rgba; } return rgb; } }); }; })(jQuery); jQuery.fn.equalHeights = function() { return this.height(Math.max.apply(null, this.map(function() { return jQuery(this).height(); }).get())); };