/** * Script load in customizer preview (iframe) */ /* * Script run inside a Customizer preview frame. */ ( function( $ ) { "use strict"; function closeSidebar() { if ($("amp-sidebar").attr('open') === 'open') { $('.navbar-toggle').click(); } } function openSidebar() { if ($("amp-sidebar").attr('open') !== 'open') { $('.navbar-toggle').click(); } } function scrollToEnd() { $("html, body").animate({scrollTop: $(document).height()}, 500); } $(document).ready(function() { var c = wp.customize; /* ===================== Sidebar ======================================= */ c('amp-wp-sidebar-logo-text', function (value) { value.bind(function (to) { openSidebar(); $('.sidebar-brand .brand-name').html(to); }); }); c('amp-wp-sidebar-logo-img', function (value) { value.bind(openSidebar); }); /* ============================ Colors Section =========================== */ c('amp-wp-color-theme', function (value) { value.bind(function(to) { $('.post-terms.cats .term-type,.post-terms a:hover,.search-form .search-submit,.amp-wp-main-link a,.sidebar-brand,.site-header,.listing-item a.post-read-more:hover') .css('background', to); $('.single-post .post-meta a,.entry-content ul.amp-wp-shortcode-list li:before') .css('color', to); }); }); c('amp-wp-color-bg', function (value) { value.bind(function(to) { $('body.body').css('background', to); }); }); c('amp-wp-color-text', function (value) { value.bind(function(to) { $('.amp-wp-wrapper').css('color', to); }); }); c('amp-wp-color-footer-nav-bg', function (value) { value.bind(function(to) { scrollToEnd(); $('.amp-wp-footer-nav').css('background', to); }); }); c('amp-wp-color-footer-bg', function (value) { value.bind(function(to) { scrollToEnd(); $('.amp-wp-footer').css('background', to); }); }); }); })( jQuery );