( function( api ) { api.sectionConstructor['upsell'] = api.Section.extend( { // No events for this type of section. attachEvents: function () {}, // Always make the section active. isContextuallyActive: function () { return true; } } ); } )( wp.customize ); jQuery(document).ready(function($) { "use strict"; /** * Script for switch option */ $('.switch_options').each(function() { //This object var obj = $(this); var switchPart = obj.children('.switch_part').attr('data-switch'); var input = obj.children('input'); //cache the element where we must set the value var input_val = obj.children('input').val(); //cache the element where we must set the value obj.children('.switch_part.'+input_val).addClass('selected'); obj.children('.switch_part').on('click', function(){ var switchVal = $(this).attr('data-switch'); obj.children('.switch_part').removeClass('selected'); $(this).addClass('selected'); $(input).val(switchVal).change(); //Finally change the value to 1 }); }); /** * Radio Image control in customizer */ // Handles setting the new value in the customizer. $( '.customize-control-astrad-radio-image input:radio' ).change( function() { // Get the name of the setting. var setting = $( this ).attr( 'data-customize-setting-link' ); // Get the value of the currently-checked radio input. var image = $( this ).val(); // Set the new value. wp.customize( setting, function( obj ) { obj.set( image ); } ); } ); /** * MultiCheck box Control JS */ $( 'body' ).on( 'change', '.customize-control-checkbox-multiple input[type="checkbox"]' , function() { var new_checkbox_values = $( this ).parents( '.customize-control-checkbox-multiple' ).find( 'input[type="checkbox"]:checked' ).map(function(){ return $( this ).val(); }).get().join( ',' ); $( this ).parents( '.customize-control-checkbox-multiple' ).find( 'input[type="hidden"]' ).val( new_checkbox_values ).trigger( 'change' ); }); /** * Radio image button Control JS */ // Use buttonset() for radio images. jQuery( '.customize-control-astrad-radio-image .buttonset' ).buttonset(); // Handles setting the new value in the customizer. jQuery( '.customize-control-astrad-radio-image input:radio' ).change( function() { // Get the name of the setting. var setting = jQuery( this ).attr( 'data-customize-setting-link' ); // Get the value of the currently-checked radio input. var image = jQuery( this ).val(); // Set the new value. wp.customize( setting, function( obj ) { obj.set( image ); } ); } ); }); // jQuery( document ).ready