"use strict"; /** * File customize-preview.js. * * Instantly live-update customizer settings in the preview for improved user experience. */ //not using in end but leaving here for now function swapImgToSvg(selector) { var $img = $(selector), imgURL = $img.attr('src'), imgID = $img.attr('id'); $.get(imgURL, function(data) { // Get the SVG tag, ignore the rest var $svg = $(data).find('svg'); // Add replaced image's ID to the new SVG if (typeof imgID !== 'undefined') { $svg = $svg.attr('id', imgID); } $svg = $svg.removeAttr('xmlns:a'); $img.replaceWith($svg); }, 'xml'); } ; swapImgToSvg('.custom-logo-link img'); (function($) { //check if custom logo is there and hide site title if it is if ($('.custom-logo-link').is(':visible')) { $('.site-name').hide(); } wp.customize('custom_logo', function(value) { value.bind(function(to) { if (to != '') { $('.site-name').hide(); } else { $('.site-name').show(); } }); }); // Site title and description. wp.customize('blogname', function(value) { // If logo isn't set then bind site-title for live update. if (!parent.wp.customize('custom_logo')()) { value.bind(function(to) { $('.site-title a').text(to); }); } }); wp.customize('blogdescription', function(value) { value.bind(function(to) { $('.site-description').text(to); }); }); wp.customize('site_top_contained', function(value) { value.bind(function(to) { $('.site-top-container').removeClass('container'); $('.site-top-container').removeClass('container-fluid'); $('.site-top-container').addClass(to); }); }); // Switch logo side by adding class to site-top wp.customize('site_top_layout', function(value) { //console.log( value ); value.bind(function(to) { $('.site-top').removeClass('no-logo logo-left logo-right logo-center logo-in-middle logo-center-under'); $('.site-top').addClass(to); //if logo was min middle move it out on logo position change or move it in if it becomes middle if (to == 'logo-in-middle') { var navigationLi = $('.site-navigation__nav-holder .menu li'); var middle = Math.floor($(navigationLi).length / 2) - 1; $('