/*! ET et_shortcodes_frontend.js */ // et_switcher plugin v2.2 (function($) { $.fn.et_shortcodes_switcher = function(options) { var defaults = { slides: '>div', activeClass: 'active', linksNav: '', findParent: true, //use parent elements to define active states lengthElement: 'li', //parent element, used only if findParent is set to true useArrows: false, arrowLeft: 'a#prev-arrow', arrowRight: 'a#next-arrow', auto: false, autoSpeed: 5000, slidePadding: '', pauseOnHover: true, fx: 'fade', sliderType: '' }; var options = $.extend(defaults, options); return this.each(function() { var slidesContainer = jQuery(this).parent().css('position','relative'), $slides = jQuery(this).css({'overflow':'hidden','position':'relative'}), $slides_wrapper_box = slidesContainer.find('.et-tabs-content-wrapper'), $slides_wrapper = $slides_wrapper_box.parent(), $slide = $slides.find( '.et-tabs-content-wrapper' + options.slides), slidesNum = $slide.length, zIndex = slidesNum, currentPosition = 1, slideHeight = 0, $activeSlide, $nextSlide, slides_wrapper_width = $slides_wrapper.width(), $et_shortcodes_mobile_nav, $et_shortcodes_mobile_controls; if (options.fx === 'slide') { $slides_wrapper_box.width( ( ( slidesNum + 2 ) * 200 ) + '%' ); $slide.css({ 'width': slides_wrapper_width + 'px', 'visibility': 'visible', }); $slides_wrapper_box.append($slide.first().clone().removeClass().addClass('et_slidecontent_cloned')); $slides_wrapper_box.prepend( $slide.last().clone().removeClass().addClass('et_slidecontent_cloned') ); $slides_wrapper_box.css('left', - slides_wrapper_width + 'px'); } $slide.first().css({ 'display': 'block' }).addClass('et_shortcode_slide_active'); if ('' !== options.slidePadding) { var slidePaddingOption = 'number' === typeof options.slidePadding ? options.slidePadding + 'px' : options.slidePadding; $slide.css('padding', slidePaddingOption); } if (options.linksNav != '') { var linkSwitcher = jQuery(options.linksNav); var linkSwitcherTab = ''; if (options.findParent) linkSwitcherTab = linkSwitcher.parent(); else linkSwitcherTab = linkSwitcher; if (!linkSwitcherTab.filter('.active').length) linkSwitcherTab.first().addClass('active'); linkSwitcher.on('click', function() { var targetElement, orderNum; if (options.findParent) targetElement = jQuery(this).parent(); else targetElement = jQuery(this); orderNum = targetElement.prevAll(options.lengthElement).length+1; if (orderNum > currentPosition) gotoSlide(orderNum, 1); else gotoSlide(orderNum, -1); return false; }); } if (options.useArrows) { var $right_arrow = jQuery(options.arrowRight), $left_arrow = jQuery(options.arrowLeft); $right_arrow.on('click', function(){ et_shortcodes_go_to_next_slide(); return false; }); $left_arrow.on('click', function(){ et_shortcodes_go_to_previous_slide(); return false; }); } function changeTab(){ if (linkSwitcherTab != '') { linkSwitcherTab.siblings().removeClass('active'); linkSwitcherTab.eq(currentPosition - 1).addClass('active'); } } function gotoSlide(slideNumber,dir){ if ($slide.filter(':animated').length) return; $activeSlide = $slide.parent().find('.et_slidecontent').eq(currentPosition - 1); if (currentPosition === slideNumber) return; $activeSlide.removeClass('et_shortcode_slide_active'); $nextSlide = $slide.parent().find('.et_slidecontent').eq(slideNumber - 1).addClass('et_shortcode_slide_active'); if ((currentPosition > slideNumber || currentPosition === 1) && (dir === -1)) { if (options.fx === 'slide') slideBack(500); if (options.fx === 'fade') slideFade(500); } else { if (options.fx === 'slide') slideForward(500); if (options.fx === 'fade') slideFade(500); } currentPosition = $nextSlide.prevAll('.et_slidecontent').length + 1; if (options.linksNav != '') changeTab(); if ( options.sliderType === 'images' || options.sliderType === 'simple' ){ $et_shortcodes_mobile_controls.find('li').removeClass('et_shortcodes_active_control'); $et_shortcodes_mobile_controls.find('li').eq(currentPosition-1).addClass('et_shortcodes_active_control'); } return false; } if (options.auto) { auto_rotate(); var pauseSlider = false; } if (options.pauseOnHover) { slidesContainer.on('mouseenter', function(){ pauseSlider = true; }).on('mouseleave', function(){ pauseSlider = false; }); } function auto_rotate(){ interval_shortcodes = setInterval(function(){ if (!pauseSlider) { if (currentPosition === slidesNum) gotoSlide(1,1); else gotoSlide(currentPosition+1,1); if (options.linksNav != '') changeTab(); } },options.autoSpeed); } function slideFade(speed){ $activeSlide.css( { 'display' : 'none', 'opacity' : '0' } ); $nextSlide.css({'opacity' : '0', 'display':'block'}).animate( { opacity : 1 }, 700 ); } function slideForward(speed){ var next_slide_order = $nextSlide.prevAll('.et_slidecontent').length+1, go_to_first_slide = false; if ( $activeSlide.next('.et_slidecontent_cloned').length ) { next_slide_order = $activeSlide.prevAll().length+1; go_to_first_slide = true; } $slides_wrapper_box.animate( { left : - ( $slides_wrapper.width() * next_slide_order ) }, 500, function(){ if (go_to_first_slide) { $slides_wrapper_box.css('left', - $slides_wrapper.width() + 'px'); } } ); } function slideBack(speed){ var next_slide_order = $nextSlide.prevAll('.et_slidecontent').length+1, go_to_last_slide = false; if ( $activeSlide.prev('.et_slidecontent_cloned').length ) { next_slide_order = 0; go_to_last_slide = true; } $slides_wrapper_box.animate( { left : - ( $slides_wrapper.width() * next_slide_order ) }, 500, function(){ if (go_to_last_slide) { $slides_wrapper_box.css('left', - ($slides_wrapper.width() * slidesNum) + 'px'); } } ); } if (options.fx === 'slide') { $(window).on('resize', function(){ $slides_wrapper_box.find('>div').css({ 'width' : $slides_wrapper.width() + 'px' }); $slides_wrapper_box.css('left', - ($slides_wrapper.width() * currentPosition) + 'px'); } ); } et_generate_mobile_nav(); function et_generate_mobile_nav(){ var et_shortcodes_slides_num = slidesContainer.find( '.et_slidecontent' ).length, et_shortcodes_controllers_html = ''; if ( et_shortcodes_slides_num > 1 && ( options.sliderType === 'images' || options.sliderType === 'simple' ) ){ slidesContainer.append( '
' ); $et_shortcodes_mobile_controls = slidesContainer.find('.et_shortcodes_controls'); for ( var i = 0; i < et_shortcodes_slides_num; i++ ) { et_shortcodes_controllers_html += '