/** * Theme Customizer enhancements for a better user experience. * * Contains handlers to make Theme Customizer preview reload changes asynchronously. */ ( function( $ ) { // Site title and description. wp.customize( 'blogname', function( value ) { value.bind( function( to ) { console.log(to); $( '.site-title a' ).text( to ); } ); } ); wp.customize( 'blogdescription', function( value ) { value.bind( function( to ) { $( '.site-description' ).text( to ); } ); } ); $.each(cactus_customizer.sections,function(index,key){ wp.customize( 'cactus[section_hide_'+key+']', function( value ) { value.bind( function( to ) { if(to=='1') $( '.cactus-section-'+key).hide(); else $( '.cactus-section-'+key).show(); } ); } ); wp.customize( 'cactus[section_title_'+key+']', function( value ) { value.bind( function( to ) { $( '.section_title_'+key+'_selective' ).text( to ); } ); } ); wp.customize( 'cactus[section_subtitle_'+key+']', function( value ) { value.bind( function( to ) { $( '.section_subtitle_'+key+'_selective' ).text( to ); } ); } ); wp.customize( 'cactus[font_color_'+key+']', function( value ) { value.bind( function( to ) { if( to =='1' ){$( '.cactus-section-'+key+'').addClass('cactus-text-light');}else{$( '.cactus-section-'+key+'').removeClass('cactus-text-light');} } ); } ); wp.customize( 'cactus[background_color_'+key+']', function( value ) { value.bind( function( to ) { $( '.cactus-section-'+key+'').css( {'background-color':to} ); } ); } ); wp.customize( 'cactus[background_image_'+key+']', function( value ) { value.bind( function( to ) { $( '.cactus-section-'+key+'').css( {'background-image':'url('+to+')'} ); } ); } ); wp.customize( 'cactus[background_parallax_'+key+']', function( value ) { value.bind( function( to ) { if(to=='1'){ $( '.cactus-section-'+key+'').addClass( 'cactus-parallax' ); $('.cactus-parallax').parallax("50%", 0.1); } else{ $( '.cactus-section-'+key+'').removeClass( 'cactus-parallax' ); } } ); } ); wp.customize( 'cactus[section_id_'+key+']', function( value ) { value.bind( function( to ) { $( '.cactus-section-'+key+'').attr( 'id',to ); } ); } ); }); wp.customize( 'cactus[columns_service]', function( value ) { value.bind( function( to ) { $( '.service_selective' ).attr('class', function(i, c){ return c.replace(/(^|\s)cactus-list-md-\S+/g, ''); }).addClass('cactus-list-md-'+to); } ); } ); wp.customize( 'cactus[image_promo]', function( value ) { value.bind( function( to ) { $( '.image_promo_selective img' ).attr( 'src', to ); } ); } ); wp.customize( 'cactus[image_contact]', function( value ) { value.bind( function( to ) { $( '.image_contact_selective img' ).attr( 'src', to ); } ); } ); wp.customize( 'cactus[button_text_news]', function( value ) { value.bind( function( to ) { $( '.button_text_news_selective' ).html( to ); } ); } ); wp.customize( 'cactus[button_link_news]', function( value ) { value.bind( function( to ) { $( '.button_text_news_selective' ).parent( 'a' ).attr('href',to); } ); } ); wp.customize( 'cactus[button_link_call_to_action]', function( value ) { value.bind( function( to ) { $( '.button_text_call_to_action_selective' ).parent( 'a' ).attr('href',to); } ); } ); wp.customize( 'cactus[button_target_call_to_action]', function( value ) { value.bind( function( to ) { $( '.button_text_call_to_action_selective' ).parent( 'a' ).attr('target',to); } ); } ); } )( jQuery );