Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
themes
/
reon
/
customize
/
assets
:
customizer.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
jQuery( document ).ready(function($) { "use strict"; /** * Googe Font Select Custom Control * * @author Anthony Hortin <http://maddisondesigns.com> * @license http://www.gnu.org/licenses/gpl-2.0.html * @link https://github.com/maddisondesigns */ $('.google-fonts-list').each(function (i, obj) { if (!$(obj).hasClass('select2-hidden-accessible')) { $(obj).select2(); } }); $('.google-fonts-list').on('change', function() { var elementRegularWeight = $(this).parent().parent().find('.google-fonts-regularweight-style'); var selectedFont = $(this).val(); var customizerControlName = $(this).attr('control-name'); // Clear Weight/Style dropdowns elementRegularWeight.empty(); // Get the Google Fonts control object var bodyfontcontrol = _wpCustomizeSettings.controls[customizerControlName]; // Find the index of the selected font var indexes = $.map(bodyfontcontrol.ovafontslist, function(obj, index) { if(obj.family === selectedFont) { return index; } }); var index = indexes[0]; // For the selected Google font show the available weight/style variants $.each(bodyfontcontrol.ovafontslist[index].variants, function(val, text) { elementRegularWeight.append( $('<option></option>').val(text).html(text) ); }); $(this).parent().parent().find( '.google-fonts-weight-string' ).val( bodyfontcontrol.ovafontslist[index].variants.toString() ); // Update the font category based on the selected font $(this).parent().parent().find('.google-fonts-category').val(bodyfontcontrol.ovafontslist[index].category); ovaGetAllSelects($(this).parent().parent()); }); $('.google_fonts_select_control select').on('change', function() { ovaGetAllSelects($(this).parent().parent()); }); function ovaGetAllSelects($element) { var regularweight = $element.find('.google-fonts-regularweight-style').val(); if( regularweight != null ) regularweight = regularweight.join(); var selectedFont = { font: $element.find('.google-fonts-list').val(), regularweight: regularweight, category: $element.find('.google-fonts-category').val(), }; // Important! Make sure to trigger change event so Customizer knows it has to save the field $element.find('.customize-control-google-font-selection').val(JSON.stringify(selectedFont)).trigger('change'); } });