/** * File customizer-controls.js * * The file for generic customizer controls. * * @package Hestia */ /* global imageObject */ jQuery( document ).ready( function () { 'use strict'; jQuery.aboutBackground = { init: function () { this.updateBackgroundControl(); this.updateBackgroundControlBuffer(); this.focusMenu(); this.updateEditorLink(); }, updateBackgroundControl: function () { wp.customize( 'page_on_front', function( value ) { value.bind( function( newval ) { jQuery.ajax({ type: 'POST', data: { action: 'update_image_buffer', pid: newval, nonce: imageObject.imagenonce }, url: imageObject.ajaxurl, success: function (result) { var image = result.data; var html; if (image !== '' && image !== 'undefined') { html = '' + '
' + '
' + ' ' + '
' + '
' + '' + ' ' + '
' + '
' + '
'; } else { html = '' + '' + '
\n' + '
' + 'No image selected' + '
' + '
' + '' + '' + '
' + '
'; } wp.customize.control( 'hestia_feature_thumbnail' ).container['0'].innerHTML = html; wp.customize.instance( 'hestia_feature_thumbnail' ).previewer.refresh(); } }); } ); } ); }, updateBackgroundControlBuffer: function () { /** * Update the buffer for about background. */ wp.customize( 'hestia_feature_thumbnail', function ( value ) { value.bind( function ( newval ) { jQuery.ajax({ type: 'POST', data: { action: 'update_image_buffer', value: newval, nonce: imageObject.imagenonce }, url: imageObject.imagenonce }); }); }); }, /** * Focus menu when the user clicks on customizer shortcut of the menu. */ focusMenu: function () { wp.customize.previewer.bind( 'trigger-focus-menu', function() { wp.customize.section( 'menu_locations' ).focus(); } ); }, updateEditorLink: function () { wp.customize( 'page_on_front', function( value ) { value.bind( function( newval ) { if( typeof wp.customize.control( 'hestia_shortcut_editor' ) !== 'undefined' ){ var newLink = wp.customize.control( 'hestia_shortcut_editor' ).container['0'].innerHTML .replace(/(post=).*?(&)/,'$1' + newval + '$2'); wp.customize.control( 'hestia_shortcut_editor' ).container['0'].innerHTML = newLink; } } ); } ); } }; jQuery.aboutBackground.init(); wp.customize( 'hestia_team_content', function ( value ) { value.bind( function () { var authors_values; var result = ''; if ( jQuery.isFunction( wp.customize._value.hestia_authors_on_blog ) ) { authors_values = wp.customize._value.hestia_authors_on_blog(); } jQuery( '#customize-control-hestia_team_content .customizer-repeater-general-control-repeater-container' ).each( function () { var title = jQuery( this ).find( '.customizer-repeater-title-control' ).val(); var id = jQuery( this ).find( '.social-repeater-box-id' ).val(); if ( typeof (title) !== 'undefined' && title !== '' && typeof (id) !== 'undefined' && id !== '' ) { result += '