( function( $ ) { "use strict"; /** * Adds */ function mphb_divi_add_new_style($style_id, $new_style){ var $style_old = $('#'+$style_id); if ( $style_old.length ) { $style_old.replaceWith( $new_style ); } else { $( 'head' ).append( $new_style ); } } /** * Forms font style css * * @param value * font styles * @param important_tag * important tag * @returns {string} * font style css */ function mphb_divi_font_styles( value, important_tag ) { var font_styles = value.split( '|' ), style = ''; if ( $.inArray( 'bold', font_styles ) >= 0 ) { style += "font-weight: bold " + important_tag + ";"; } else { style += "font-weight: inherit " + important_tag + ";"; } if ( $.inArray( 'italic', font_styles ) >= 0 ) { style += "font-style: italic " + important_tag + ";"; } else { style += "font-style: inherit " + important_tag + ";"; } if ( $.inArray( 'underline', font_styles ) >= 0 ) { style += "text-decoration: underline " + important_tag + ";"; } else { style += "text-decoration: inherit " + important_tag + ";"; } if ( $.inArray( 'uppercase', font_styles ) >= 0 ) { style += "text-transform: uppercase " + important_tag + ";"; } else { style += "text-transform: inherit " + important_tag + ";"; } return style; } /** * button font size css */ wp.customize( 'et_divi[all_buttons_font_size]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-font-size', $button_style); } ); } ); /** * button text color css */ wp.customize( 'et_divi[all_buttons_text_color]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-text-color', $button_style); } ); } ); /** * button bg color css */ wp.customize( 'et_divi[all_buttons_bg_color]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-bg-color', $button_style); } ); } ); /** * button border width css */ wp.customize( 'et_divi[all_buttons_border_width]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-border-width', $button_style); } ); } ); /** * button border color css */ wp.customize( 'et_divi[all_buttons_border_color]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-border-color', $button_style); } ); } ); /** * button border radius css */ wp.customize( 'et_divi[all_buttons_border_radius]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-border-radius', $button_style); } ); } ); /** * button font style css */ wp.customize( 'et_divi[all_buttons_font_style]', function( value ) { value.bind( function( to ) { var $font_style = mphb_divi_font_styles(to, ''), $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-font-style', $button_style); } ); } ); /** * button letter spacing css */ wp.customize( 'et_divi[all_buttons_spacing]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-spacing', $button_style); } ); } ); /** * button font css */ wp.customize( 'et_divi[all_buttons_font]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-font', $button_style); } ); } ); /** * button hover color css */ wp.customize( 'et_divi[all_buttons_text_color_hover]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-text-color-hover', $button_style); } ); } ); /** * button hover bg color css */ wp.customize( 'et_divi[all_buttons_bg_color_hover]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-bg-color-hover', $button_style); } ); } ); /** * button hover border color css */ wp.customize( 'et_divi[all_buttons_border_color_hover]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-border-color-hover', $button_style); } ); } ); /** * button hover border radius css */ wp.customize( 'et_divi[all_buttons_border_radius_hover]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-border-radius-hover', $button_style); } ); } ); /** * button hover letter spacing css */ wp.customize( 'et_divi[all_buttons_spacing_hover]', function( value ) { value.bind( function( to ) { var $button_style = ''; mphb_divi_add_new_style('mphb-divi-button-spacing-hover', $button_style); } ); } ); })(jQuery);