/** * File customizer.js. * * Theme Customizer enhancements for a better user experience. * * Contains handlers to make Theme Customizer preview reload changes asynchronously. */ ( function( $ ) { var api = wp.customize, body = $( 'body' ); // Site title and description. wp.customize( 'blogname', function( value ) { value.bind( function( to ) { $( '.site-title a' ).text( to ); } ); } ); wp.customize( 'blogdescription', function( value ) { value.bind( function( to ) { $( '.site-description' ).text( to ); } ); } ); //bind auto scrollTo wp.customize.bind( 'preview-ready', function() { //slide_title wp.customize.preview.bind( 'section-highlight-slide-title', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.site-frontpage-slide'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); //slide_title wp.customize.preview.bind( 'section-highlight-about-content', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.frontpage-content-wrap'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); //team wp.customize.preview.bind( 'section-highlight-team', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.frontpage-team-wrap'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); //blog wp.customize.preview.bind( 'section-highlight-blog', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.frontpage-blog-wrap'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); //features wp.customize.preview.bind( 'section-highlight-features', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.frontpage-features-wrap'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); //action wp.customize.preview.bind( 'section-highlight-action', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.frontpage-action-wrap'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); //subscribe wp.customize.preview.bind( 'section-highlight-subscribe', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.frontpage-subscribe-wrap'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); //contact wp.customize.preview.bind( 'section-highlight-contact', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.frontpage-contact-wrap'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); //footer wp.customize.preview.bind( 'section-highlight-footer', function( data ) { // scroll to section if ( true === data.expanded ) { var elem = jQuery('.site-footer'); if( elem.length ) { $(window).scrollTop(elem.offset().top); } } else { $(window).scrollTop(0); } }); }); // Header Height api( 'kirhero_admin_header_height', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.header-widget-area' ).css("max-height", to +"px" ); $( '.site-header .wrap' ).css("height", to +"px" ); $( '.site-inner' ).css("margin-top", to +"px" ); } ); } ); // Header background color api( 'kirhero_header_background', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.site-header' ).css("background-color", to ); $( '.nav-primary .sub-menu' ).css("background-color", to ); } ); } ); // Header Menu background color api( 'kirhero_header_menu_background', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.nav-primary .wrap' ).css("background-color", to ); $( '.nav-primary .sub-menu' ).css("background-color", to ); } ); } ); // Header Menu position api( 'kirhero_header_menu_position', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.nav-primary' ).css("text-align", to ); } ); } ); // Header link color api( 'kirhero_header_menu_link_color', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.genesis-nav-menu a' ).css("color", to ); $( '.kirhero-text' ).css("color", to ); $( '.hamburger-inner, .hamburger-inner::after, .hamburger-inner::before' ).css("background-color", to ); $( '.hamburger-inner::after' ).css("background-color", to ); $( '.hamburger-inner::before' ).css("background-color", to ); } ); } ); // Logo color api( 'kirhero_admin_header_logo_color', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.site-title a' ).css("color", to ); } ); } ); // Logo tagline color api( 'kirhero_admin_header_tagline_color', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.site-description' ).css("color", to ); } ); } ); // Logo tagline color api( 'kirhero_admin_header_logo_height', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.custom-logo' ).css("height", to +"px"); } ); } ); // Logo tagline color api( 'kirhero_admin_header_logo_width', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.custom-logo' ).css("width", to +"px"); } ); } ); // Header Menu dropdown background api( 'kirhero_admin_header_dropdown_menu_background', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.genesis-nav-menu .sub-menu a' ).css("background-color", to ); } ); } ); // Header Menu dropdown link color api( 'kirhero_admin_header_dropdown_menu_link_color', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.nav-primary .sub-menu a' ).css("color", to ); } ); } ); // Blog subheader background color api( 'kirhero_blog_subheader_background_color', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.single-post .general-page-header' ).css("background-color", to ); } ); } ); // Blog subheader background color api( 'kirhero_blog_subheader_text_background_color', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.single-post .general-page-header' ).css("color", to ); } ); } ); // Blog subheader padding api( 'kirhero_blog_subheader_padding_top', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.single-post .general-page-header' ).css("padding-top", to + "px"); } ); } ); // Blog subheader padding api( 'kirhero_blog_subheader_padding_bottom', function( value ) { value.bind( function( to ) { //var $child = $( '.customizer-kirhero_header_height' ); $( '.single-post .general-page-header' ).css("padding-bottom", to + "px"); } ); } ); } )( jQuery );