jQuery(document).ready(function($){ 'use strict'; var customize = wp.customize; /*banner tpl*/ function cactus_banner_tpl(){ var html = ''; $('#customize-control-cactus-banner .repeater-fields > li').each(function(index, element) { var title = $(this).find( 'input[data-field="title"]').val(); var subtitle = $(this).find( 'input[data-field="subtitle"]').val(); var image = $(this).find( 'input[data-field="image"]').parents('.repeater-field-image').find('img').attr('src'); var btn_text = $(this).find( 'input[data-field="btn_text"]').val(); var btn_link = $(this).find( 'input[data-field="btn_link"]').val(); html += '
'; if(image !='' && typeof image!='undefined'){ html += ''+title+''; } html += '
'; html += '
'; html += '
'; html += '

'+title+'

'; html += '

'+subtitle+'

'; html += ''; html += '
'; html += '
'; html += '
'; html += '
'; }); customize.previewer.send('banner_selective', html); } wp.customize( 'cactus[banner]', function( value ) { value.bind( function( to ) { cactus_banner_tpl(); } ); } ); $(document).on('click','#customize-control-cactus-banner .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_banner_tpl(); }); $(document).on('click','#customize-control-cactus-banner .remove-button',function(){ cactus_banner_tpl(); var row = $(this).parents('li.repeater-row').data('row'); customize.previewer.send('remove_banner_image', row); }); /*service tpl*/ function cactus_service_tpl(){ var html = ''; var columns = $('#customize-control-cactus-columns_works').find('select').val(); $('#customize-control-cactus-service .repeater-fields > li').each(function(index, element) { var icon_type = $(this).find( 'select[data-field="icon_type"]').val(); var icon = $(this).find( 'input[data-field="icon"]').val(); var image = $(this).find( 'input[data-field="image"]').parents('.repeater-field-image').find('img').attr('src'); var title = $(this).find( 'input[data-field="title"]').val(); var text = $(this).find( 'textarea[data-field="text"]').val(); var title_link = $(this).find( 'input[data-field="title_link"]').val(); if( typeof icon_type == 'undefined' ){ icon_type = 'icon'; } if(icon !==''){ icon = icon.replace('fa ',''); icon = icon.replace('fa-',''); } title = '

'+title+'

'; if(title_link !='' ) title = ''+title+''; html += '
  • '; if(icon_type == 'image'){ if(image !='' && typeof image!='undefined'){ html += '
    '; } }else{ html += '
    '; } html += '
    '+title+'

    '+text+'

  • '; }); customize.previewer.send('service_selective', html); } wp.customize( 'cactus[service]', function( value ) { value.bind( function( to ) { cactus_service_tpl(); } ); } ); wp.customize( 'cactus[service]', function( value ) { value.bind( function( to ) { cactus_service_tpl(); } ); } ); $(document).on('click','#customize-control-cactus-service .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_service_tpl(); }); $(document).on('click','#customize-control-cactus-service .remove-button',function(){ cactus_service_tpl(); var row = $(this).parents('li.repeater-row').data('row'); customize.previewer.send('remove_service_image', row); }); /* works tpl*/ function cactus_works_tpl(){ var html = ''; var items = ''; var tags = []; var columns = $('#customize-control-cactus-columns_works').find('select').val(); var worksID = 'works-'+Math.ceil(Math.random()*10); $('#customize-control-cactus-works .repeater-fields > li').each(function(index, element) { var title = $(this).find( 'input[data-field="title"]').val(); var image = $(this).find( 'input[data-field="image"]').parents('.repeater-field-image').find('img').attr('src'); var link = $(this).find( 'input[data-field="link"]').val(); var tag = $(this).find( 'input[data-field="tag"]').val(); var cssClass = '';; if( tag != ''){ var slug = tag.toLowerCase().replace(' ','-'); cssClass = 'group-'+slug; tags[slug] = '
  • '+tag+'
  • '; } items += '
  • '; items += ''; items += '
  • '; }); if( tags ){ html += ''; } html += ''; customize.previewer.send('works_selective', {html:html,id:worksID}); } wp.customize( 'cactus[works]', function( value ) { value.bind( function( to ) { cactus_works_tpl(); } ); } ); $(document).on('click','#customize-control-cactus-works .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_works_tpl(); }); $(document).on('click','#customize-control-cactus-works .remove-button',function(){ cactus_works_tpl(); var row = $(this).parents('li.repeater-row').data('row'); customize.previewer.send('remove_works_image', row); }); /* team tpl*/ function cactus_team_tpl(){ var html = ''; var items = ''; var tags = []; var columns = $('#customize-control-cactus-columns_team').find('select').val(); $('#customize-control-cactus-team .repeater-fields > li').each(function(index, element) { var name = $(this).find( 'input[data-field="name"]').val(); var avatar = $(this).find( 'input[data-field="avatar"]').parents('.repeater-field-image').find('img').attr('src'); var byline = $(this).find( 'input[data-field="byline"]').val(); var link = $(this).find( 'input[data-field="link"]').val(); html += '
  • '; html += '
    '+name+''; if(link){ html += ''; } html += '
    '; html += '
    '; html += '
    '; html += '

    '+name+'

    '; html += '

    '+byline+'

    '; html += '
    '; html += '
    '; html += '
    '; if( link !=''){ html += '
    '; } html += '
    '; html += '
  • '; }); customize.previewer.send('team_selective', html); } wp.customize( 'cactus[team]', function( value ) { value.bind( function( to ) { cactus_team_tpl(); } ); } ); $(document).on('click','#customize-control-cactus-team .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_team_tpl(); }); $(document).on('click','#customize-control-cactus-team .remove-button',function(){ cactus_team_tpl(); var row = $(this).parents('li.repeater-row').data('row'); customize.previewer.send('remove_team_image', row); }); /*counter tpl*/ function cactus_counter_tpl(){ var html = ''; $('#customize-control-cactus-counter .repeater-fields > li').each(function(index, element) { var title = $(this).find( 'input[data-field="title"]').val(); var icon = $(this).find( 'input[data-field="icon"]').val(); var number = $(this).find( 'input[data-field="number"]').val(); if(icon !==''){ icon = icon.replace('fa ',''); icon = icon.replace('fa-',''); } html += '
  • '; html += '
    '; html += '
    '; html += '
    '+number+'
    '; html += '

    '+title+'

    '; html += '
    '; html += '
  • '; }); customize.previewer.send('counter_selective', html); } wp.customize( 'cactus[counter]', function( value ) { value.bind( function( to ) { cactus_counter_tpl(); } ); } ); $(document).on('click','#customize-control-cactus-counter .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_counter_tpl(); }); /* testimonial tpl*/ function cactus_testimonial_tpl(){ var html = ''; $('#customize-control-cactus-testimonial .repeater-fields > li').each(function(index, element) { var name = $(this).find( 'input[data-field="name"]').val(); var avatar = $(this).find( 'input[data-field="avatar"]').parents('.repeater-field-image').find('img').attr('src'); var byline = $(this).find( 'input[data-field="byline"]').val(); var text = $(this).find( 'textarea[data-field="text"]').val(); html += '
    '; html += '
    '+text+'
    '; html += '
    '+name+'
    '; html += '
    '; html += '

    '+name+'

    '; html += '

    '+byline+'

    '; html += '
    '; html += '
    '; }); customize.previewer.send('testimonial_selective', html); } wp.customize( 'cactus[testimonial]', function( value ) { value.bind( function( to ) { cactus_testimonial_tpl(); } ); } ); $(document).on('click','#customize-control-cactus-testimonial .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_testimonial_tpl(); }); $(document).on('click','#customize-control-cactus-testimonial .remove-button',function(){ cactus_testimonial_tpl(); var row = $(this).parents('li.repeater-row').data('row'); customize.previewer.send('remove_testimonial_image', row); }); /* clients tpl */ function cactus_clients_tpl(){ var html = ''; $('#customize-control-cactus-clients .repeater-fields > li').each(function(index, element) { var image = $(this).find( 'input[data-field="image"]').parents('.repeater-field-image').find('img').attr('src'); var title = $(this).find( 'input[data-field="title"]').val(); var link = $(this).find( 'input[data-field="link"]').val(); html += '
    '+title+'
    '; }); customize.previewer.send('clients_selective', html); } wp.customize( 'cactus[clients]', function( value ) { value.bind( function( to ) { cactus_clients_tpl(); } ); } ); wp.customize( 'cactus[columns_works]', function( value ) { value.bind( function( to ) { customize.previewer.send('columns_works', to); } ); } ); $(document).on('click','#customize-control-cactus-clients .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_clients_tpl(); }); $(document).on('click','#customize-control-cactus-clients .remove-button',function(){ cactus_clients_tpl(); var row = $(this).parents('li.repeater-row').data('row'); customize.previewer.send('remove_clients_image', row); }); /* pricing tpl*/ function cactus_pricing_tpl(){ var html = ''; $('#customize-control-cactus-pricing .repeater-fields > li').each(function(index, element) { var featured = $(this).find( 'input[data-field="featured"]').val(); var icon = $(this).find( 'input[data-field="icon"]').val(); var image = $(this).find( 'input[data-field="image"]').parents('.repeater-field-image').find('img').attr('src'); var title = $(this).find( 'input[data-field="title"]').val(); var currency = $(this).find( 'input[data-field="currency"]').val(); var price = $(this).find( 'input[data-field="price"]').val(); var unit = $(this).find( 'input[data-field="unit"]').val(); var features = $(this).find( 'textarea[data-field="features"]').val(); var button_text = $(this).find( 'input[data-field="button_text"]').val(); var button_link = $(this).find( 'input[data-field="button_link"]').val(); var button_target = $(this).find( 'input[data-field="button_target"]').val(); var css_class = ''; var button_class = 'cactus-dark'; if(featured=='1' || featured=='on'){ css_class = 'cactus-featured'; button_class = ''; } icon = icon.replace('fa-',''); icon = icon.replace('fa ',''); var icon_str = ''; var unit_str = ''; if( image !='' && typeof image !='undefined') icon_str = ''; else icon_str = ' '; if(unit!='') unit_str = '/ '+unit; html += '
  • '; html += '
    '; html += '
    '; html += '
    '; html += icon_str; html += '
    '; html += '

    '; html += title; html += '

    '; html += '
    '; html += '
    '; html += ''+currency+''; html += ''+price+''; html += ''+unit_str+''; html += '
    '; html += '
    '; html += '
      '; if( features ){ var features_array = features.split("\n"); $.each( features_array, function(index,value){ html += '
    • '+value+'
    • '; } ); } html += '
    '; html += '
    '; html += '
    '; html += ''+button_text+''; html += '
    '; html += '
    '; html += '
  • '; }); customize.previewer.send('pricing_selective', html); } wp.customize( 'cactus[pricing]', function( value ) { value.bind( function( to ) { cactus_pricing_tpl(); } ); } ); $(document).on('click','#customize-control-cactus-pricing .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_pricing_tpl(); }); $(document).on('click','#customize-control-cactus-pricing .remove-button',function(){ cactus_pricing_tpl(); var row = $(this).parents('li.repeater-row').data('row'); customize.previewer.send('remove_pricing_image', row); }); /*footer icons tpl*/ function cactus_footer_icons_tpl(){ var html = ''; $('#customize-control-cactus-footer_icons .repeater-fields > li').each(function(index, element) { var title = $(this).find( 'input[data-field="title"]').val(); var icon = $(this).find( 'input[data-field="icon"]').val(); var link = $(this).find( 'input[data-field="link"]').val(); if(icon !==''){ icon = icon.replace('fa ',''); icon = icon.replace('fa-',''); } if(icon !='') html += '
  • '; }); customize.previewer.send('footer_icons_selective', html); } wp.customize( 'cactus[footer_icons]', function( value ) { value.bind( function( to ) { cactus_footer_icons_tpl(); } ); } ); $(document).on('click','#customize-control-cactus-footer_icons .repeater-row-remove',function(){ $(this).parents('li.repeater-row').remove(); cactus_footer_icons_tpl(); }); var cactus_customize_scroller = function ( $ ) { 'use strict'; $( function () { var customize = wp.customize; $('ul[id*="frontpage-sections"] .accordion-section').not('.panel-meta').each( function () { $( this ).on( 'click', function() { var section = $( this ).attr('aria-owns').split( '_' ).pop(); customize.previewer.send('clicked-customizer-section', section); }); }); $( '#accordion-section-panel-footer' ).on( 'click', function() { customize.previewer.send('clicked-customizer-footer', '.site-footer'); }); $( '#accordion-section-title_tagline' ).on( 'click', function() { customize.previewer.send('clicked-customizer-title_tagline', '.header-wrap'); }); } ); }; cactus_customize_scroller( jQuery ); });