var cactus_customizer_sections = function ( $ ) { 'use strict'; $( function () { var customize = wp.customize; customize.preview.bind( 'clicked-customizer-section', function( data ) { data = data.replace('sub-accordion-section-section-',''); var sectionId = ''; switch (data) { case 'banner': sectionId = 'div.cactus-section-banner'; break; case 'works': sectionId = 'div.cactus-section-works'; break; case 'service': sectionId = 'div.cactus-section-service'; break; case 'promo': sectionId = 'div.cactus-section-promo'; break; case 'team': sectionId = 'div.cactus-section-team'; break; case 'counter': sectionId = 'div.cactus-section-counter'; break; case 'testimonial': sectionId = 'div.cactus-section-testimonial'; break; case 'news': sectionId = 'div.cactus-section-news'; break; case 'contact': sectionId = 'div.cactus-section-contact'; break; case 'pricing': sectionId = 'div.cactus-section-pricing'; break; case 'call_to_action': sectionId = 'div.cactus-section-call_to_action'; break; case 'subscribe': sectionId = 'div.cactus-section-video'; break; case 'video': sectionId = 'div.cactus-section-video'; break; default: sectionId = 'div.cactus-section-' + data; break; } if ( $(sectionId).length > 0) { $('html, body').animate({ scrollTop: $(sectionId).offset().top - 100 }, 1000); } } ); customize.preview.bind( 'clicked-customizer-footer', function( data ) { $('html, body').animate({ scrollTop: $(data).offset().top - 100 }, 1000); } ); customize.preview.bind( 'clicked-customizer-title_tagline', function( data ) { $('html, body').animate({ scrollTop: $(data).offset().top - 100 }, 1000); } ); customize.preview.bind( 'banner_selective', function( data ) { var slideHeight = []; var sliderHeight = 0; $( '.banner_selective' ).html( data ).addClass('cactus-slider owl-carousel'); $( '.cactus-slider' ).trigger('destroy.owl.carousel'); $('.banner_selective .cactus-slider-item').each(function(index, element) { slideHeight[index] = $(this).height(); }); if(slideHeight.length>0) sliderHeight = Math.min.apply(null, slideHeight); if(sliderHeight>0) $( '.banner_selective .cactus-slider-item' ).css({'height':sliderHeight}); $( '.cactus-slider' ).owlCarousel({items: 1 }); } ); customize.preview.bind( 'remove_banner_image', function( data ) { var slideHeight = []; var sliderHeight = 0; $('.banner_selective .cactus-slider-item').each(function(index, element) { slideHeight[index] = $(this).height(); }); if(slideHeight.length>0) sliderHeight = Math.min.apply(null, slideHeight); $( '.banner_selective .cactus-slider-item:eq('+data+')' ).find('img').attr('src', '' ).css({'max-width':'100%'}); if(sliderHeight>0) $( '.banner_selective .cactus-slider-item:eq('+data+')' ).css({'height':sliderHeight}); } ); customize.preview.bind( 'service_selective', function( data ) { $( '.service_selective' ).html( data ); } ); customize.preview.bind( 'remove_service_image', function( data ) { $( '.service_selective >li:eq('+data+')' ).find('img').attr('src', '' ); } ); customize.preview.bind( 'works_selective', function( data ) { $( '.works_selective' ).html( data.html ); var $grid = $('#'+data.id).isotope({}); $(document).on( 'click', '.cactus-portfolio-filter a', function() { $(this).parents('.cactus-portfolio-filter').find('li').removeClass('active'); $(this).parent('li').addClass('active'); var filterValue = $(this).attr('data-filter'); $grid.isotope({ filter: filterValue }); }); } ); customize.preview.bind( 'columns_works', function( data ) { $( '.works_selective .cactus-portfolio-list' ).attr('class', function(i, c){ return c.replace(/(^|\s)cactus-list-md-\S+/g, ''); }).addClass('cactus-list-md-'+data); var $grid = $('.cactus-portfolio-list').isotope({}); $(document).on( 'click', '.cactus-portfolio-filter a', function() { $(this).parents('.cactus-portfolio-filter').find('li').removeClass('active'); $(this).parent('li').addClass('active'); var filterValue = $(this).attr('data-filter'); $grid.isotope({ filter: filterValue }); }); } ); customize.preview.bind( 'remove_works_image', function( data ) { $( '.works_selective .cactus-portfolio-list > li:eq('+data+')' ).remove; var $grid = $('.cactus-portfolio-list').isotope({}); $(document).on( 'click', '.cactus-portfolio-filter a', function() { $(this).parents('.cactus-portfolio-filter').find('li').removeClass('active'); $(this).parent('li').addClass('active'); var filterValue = $(this).attr('data-filter'); $grid.isotope({ filter: filterValue }); }); } ); customize.preview.bind( 'team_selective', function( data ) { $( '.team_selective' ).html( data ); } ); customize.preview.bind( 'remove_team_image', function( data ) { $( '.team_selective >li:eq('+data+')' ).find('img').attr('src', '' ); } ); customize.preview.bind( 'counter_selective', function( data ) { $( '.counter_selective' ).html( data ); } ); customize.preview.bind( 'testimonial_selective', function( data ) { $( '.testimonial_selective' ).html( data ); $('.cactus-testimonials-carousel').trigger('destroy.owl.carousel'); $('.cactus-testimonials-carousel').owlCarousel({items: 1,nav: true }); } ); customize.preview.bind( 'clients_selective', function( data ) { $( '.clients_selective' ).html( data ); $( '.cactus-clients-carousel' ).trigger('destroy.owl.carousel'); $( '.cactus-clients-carousel' ).owlCarousel({ responsive:{ 0:{ items:1 }, 400:{ items:2 }, 700:{ items:3 }, 1000:{ items:4 }, 1200:{ items:5 } }, dots: true }); } ); customize.preview.bind( 'pricing_selective', function( data ) { $( '.pricing_selective' ).html( data ); } ); customize.preview.bind( 'remove_clients_image', function( data ) { $( '.clients_selective .cactus-client-item:eq('+data+')' ).find('img').attr('src', '' ); } ); customize.preview.bind( 'footer_icons_selective', function( data ) { $( '.footer_icons_selective' ).html( data ); } ); } ); }; cactus_customizer_sections( jQuery );