( function( $ ) { /** Front-page video popup. */ $( document ).on( 'click', '.video-static, .body-fixed', function( evnt ) { evnt.preventDefault(); $( 'body' ).toggleClass( 'body-fixed' ); $( '.video-preview' ).fadeToggle(); $( '.content-block-video iframe' ).fadeToggle(); } ); /** Front-page slideshow. */ $( document ).on( 'click', '.slideshow-button', function( evnt ) { evnt.preventDefault(); var currId = parseInt( $( '.active-slide' ).data( 'id' ) ) ; var gotoId = currId + 1; // Going backwards by clicking on the prev button. if ( $( this ).hasClass( 'slideshow-button-prev' ) ) { gotoId = currId - 1; } // Move to 1st slide if out of bound. if ( gotoId < 0 || gotoId > $( '.slideshow-container img' ).length - 1 ) { currId = gotoId = 0; } // Fixing the the 0 start for data-id. var nthId = gotoId + 1 var pictureOffset = gotoId * ( $( '.slideshow-container img' ).width() ); // + padding 4rem var contentOffset = gotoId * $( '.slideshow-content' ).width(); $( '.slideshow-nav-container a' ).removeClass( 'active-slide' ); $( '.slideshow-container img' ).removeClass( 'active-slide' ); $( '.slideshow-content-container div' ).removeClass( 'active-slide' ); $( '.slideshow-nav-container a:nth-child(' + nthId + ')').addClass( 'active-slide' ); $( '.slideshow-container img:nth-child(' + nthId + ')').addClass( 'active-slide' ); $( '.slideshow-container' ).css( { 'margin-left' : '-' + pictureOffset + 'px' } ); if ( $( window ).width() > 800 ) { $( '.slideshow-content-container .slide:nth-child(' + nthId + ')').addClass( 'active-slide' ); $( '.slideshow-content-container' ).css( { 'margin-left' : '-' + contentOffset + 'px' } ); } } ); $( document ).on( 'click', '.slideshow-nav-container a', function( evnt ) { evnt.preventDefault(); var $parent = $( this ).closest( '.content-block-slideshow' ); var currId = parseInt( $( this ).data( 'id' ) ); var pictureOffset = currId * ( $parent.find( '.slideshow' ).width() + 64 ); // + padding 4rem var contentOffset = currId * $parent.find( '.slideshow-content' ).width(); $parent.find( '*' ).removeClass( 'active-slide' ); $parent.find( '[data-id="' + currId + '"]' ).addClass( 'active-slide' ); $parent.find( '.slideshow-container' ).css( { 'margin-left' : '-' + pictureOffset + 'px' } ); if ( $( window ).width() > 800 ) { $parent.find( '.slideshow-content-container' ).css( { 'margin-left' : '-' + contentOffset + 'px' } ); } } ); /** Front-page products slider. */ $( document ).on( 'click', '.product nav a', function( evnt ) { evnt.preventDefault(); var $parent = $( this ).closest( '.product' ); var currId = parseInt( $( this ).data( 'id' ) ); var productOffset = currId * $( this ).closest( '.product' ).find( '> ul > li' ).width(); $parent.find( '*' ).removeClass( 'active-product' ); $parent.find( '[data-id="' + currId + '"]' ).addClass( 'active-product' ); $parent.find( '> ul' ).css( { 'margin-left' : '-' + productOffset + 'px' } );; } ); } ) ( jQuery );