(function ($, window, document, undefined) { "use strict"; var ipTheme = 'bizflow'; /** * Convert HEX to HSL value * @param {String} hex * @returns {Object} HSL value */ var hexToHsl = function (hex) { var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); var r = parseInt(result[1], 16); var g = parseInt(result[2], 16); var b = parseInt(result[3], 16); r /= 255, g /= 255, b /= 255; var max = Math.max(r, g, b), min = Math.min(r, g, b); var h, s, l = (max + min) / 2; if (max == min) { h = s = 0; // achromatic } else { var d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } s = s * 100; s = Math.round(s); l = l * 100; l = Math.round(l); h = Math.round(360 * h); return { h: h, s: s, l: l }; }; /** * Add callback functions to customizer * Implement changes */ wp.customize('blogname', function (value) { value.bind(function (newval) { $('.site-title').text(newval); }); }); wp.customize('blogdescription', function (value) { value.bind(function (newval) { $('.site-description').text(newval); }); }); wp.customize(ipTheme + 'back_to_top_show', function (value) { value.bind(function (newval) { if(newval == 'hide'){ $('.back-to-top').hide(); }else{ $('.back-to-top').show(); } }); }); wp.customize(ipTheme + 'mobile_hide_footer', function (value) { value.bind(function (newval) { if(newval == 'show'){ $('.footer-container').css('display', 'block'); }else{ $('.footer-container').css('display', 'none'); } }); }); wp.customize(ipTheme + 'copyright_text', function (value) { value.bind(function (newval) { $('.copyright').text(newval); }); }); wp.customize(ipTheme + 'text_color', function (value) { value.bind(function (newval) { $('body').css('color', newval); }); }); wp.customize('background_color', function (value) { value.bind(function (newval) { $('body').css('background-color', newval); }); }); wp.customize(ipTheme + 'footer_bg', function (value) { value.bind(function (newval) { $('.footer-container').css('background-color', newval); }); }); wp.customize(ipTheme + 'footer_color', function (value) { value.bind(function (newval) { var hsl = hexToHsl(newval); $('.footer-container').css('color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 5.6) + '%)' ); $('.footer-container a, .footer-container h1, .footer-container h2, .footer-container h3, .footer-container h4, .footer-container h5').css('color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 3.5) + '%)' ); $('.footer-container a:hover').css('color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l) + '%)' ); }); }); wp.customize(ipTheme + 'content_bg', function (value) { value.bind(function (newval) { var hsl = hexToHsl(newval); $('code, kbd, samp').css('background-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 2.5) + '%)'); $('table, table td, table th').css('border-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 7.5) + '%)'); $('button,input[type="button"],input[type="submit"],.button,.btn').css('border-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 7.5) + '%)').css('background-color', newval).hover( function () { $(this).css('background-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l + 7.5) + '%)'); }, function () { $(this).css('background-color', newval); } ); $('input,textarea,select,input[type="text"],input[type="number"],input[type="date"],input[type="url"],input[type="date"],input[type="email"],input[type="checkbox"],input[type="radio"]').css('background', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 2.5) + '%)').css('border-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 7.5) + '%)'); $('.content-container.container-boxed,.content-wrapper,.sidebar,.site-content,body.sidebar-config .site-content').css('background-color', newval); $('.archive-cat-links a.cat-link').css('background-color', 'hsl(' + hsl.h + ',' + (hsl.s - 25) + '%,' + (hsl.l - 7.5) + '%)'); $('.ip-single-item .before-entry-title a.cat-link,.ip-single-item .entry-footer a.tag-link,.ip-single-item .entry-footer a[rel="tag"]').css('background-color', 'hsl(' + hsl.h + ',' + (hsl.s - 15) + '%,' + (hsl.l - 0.5) + '%)').css('border-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 7.5) + '%)'); }); }); wp.customize(ipTheme + 'header_bg', function (value) { value.bind(function (newval) { var hsl = hexToHsl(newval); $('.header-container,.header-container.container-boxed').css('background-color', newval); $('.ip-nav-secondary').css('border-bottom-color', 'hsl(' + hsl.h + ',' + (hsl.s - 10) + '%,' + (hsl.l - 5) + '%)'); $('.ip-nav-secondary li a').hover( function () { $(this).css('background-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 7.5) + '%)'); }, function () { $(this).css('color', 'transparent'); } ); $('.ip-nav-secondary li.current-menu-item > a, .ip-nav-secondary li.menu-item-has-children > ul').css('background-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 7.5) + '%)'); }); }); wp.customize(ipTheme + 'primary_color', function (value) { value.bind(function (newval) { var hsl = hexToHsl(newval); $('a').css('color', newval).hover(function () { $(this).css('color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 12) + '%)'); }, function () { $(this).css('color', newval); }); $('blockquote, .wp-block-quote, .wp-block-quote.is-large').css('border-left-color', newval); $('button,input[type="button"],input[type="submit"],.button,.btn').hover( function () { $(this).css('border-color', newval).css('color', newval); }, function () { $(this).css('border-color', '').css('color', ''); } ); $('input:focus,textarea:focus,select:focus,input[type="text"]:focus,input[type="number"]:focus,input[type="date"]:focus,input[type="url"]:focus,input[type="date"]:focus,input[type="email"]:focus,input[type="checkbox"]:checked,input[type="radio"]:checked').css('border-color', newval); $('.entry-header h2 a, .entry-footer .excerpt-read-more').hover( function () { $(this).css('border-color', newval).css('color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 12) + '%)'); }, function () { $(this).css('border-color', '').css('color', ''); } ); $('.back-to-top').css('border-color', newval).css('background-color', newval).css('color', '').hover( function () { $(this).css('border-color', newval).css('color', newval); }, function () { $(this).css('border-color', '').css('color', ''); } ); $('.archive-cat-links a.cat-link').hover( function () { $(this).css('background-color', 'hsl(' + hsl.h + ',' + (hsl.s - 22.5) + '%,' + hsl.l + '%)'); }, function () { $(this).css('background-color', ''); } ); $('.ip-single-item .before-entry-title a.cat-link,.ip-single-item .entry-footer a.tag-link,.ip-single-item .entry-footer a[rel="tag"]').hover( function () { $(this).css('background-color', 'hsl(' + hsl.h + ',' + (hsl.s - 22.5) + '%,' + hsl.l + '%)').css('border-color', 'hsl(' + hsl.h + ',' + (hsl.s - 22.5) + '%,' + hsl.l + '%)'); }, function () { $(this).css('background-color', '').css('border-color', ''); } ); }); }); wp.customize(ipTheme + 'navbar_color', function (value) { value.bind(function (newval) { var hsl = hexToHsl(newval); $('.main-navigation .ip-nav li a').css('color', newval); $('.main-navigation .ip-nav li a').hover( function () { $(this).css('color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l + 16.5) + '%)'); }, function () { $(this).css('color', newval); } ); $('.sidebar-widget .widget-title span').css('color', newval); }); }); wp.customize(ipTheme + 'navbar_bg', function (value) { value.bind(function (newval) { var hsl = hexToHsl(newval); //$('.container-fullwidth.header-type_logo_left, .main-navigation, .header-type_logo_left .main-navigation').css('background-color', newval); $('.container-fullwidth .main-navigation, .container-fullwidth.header-type_logo_left>.container-inner, .header-container.container-boxed .main-navigation>.container-inner-restrict, .container-boxed.header-type_logo_left .container-inner-restrict').css('background-color', newval); $('.main-navigation .ip-nav li a').hover( function () { $(this).css('background-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 12) + '%)'); }, function () { $(this).css('background-color', 'transparent'); } ); $('.main-navigation li.current-menu-item > a').css('background-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 12) + '%)'); $('.main-navigation .ip-nav li ul').css('background-color', 'hsl(' + hsl.h + ',' + hsl.s + '%,' + (hsl.l - 7.3) + '%)'); $('.sidebar-widget .widget-title').css('border-bottom-color', 'hsl(' + hsl.h + ',' + (hsl.s - 25) + '%,' + (hsl.l - 7.5) + '%)'); $('.sidebar-widget .widget-title span').css('background-color', 'hsl(' + hsl.h + ',' + (hsl.s - 25) + '%,' + (hsl.l - 7.5) + '%)'); }); }); wp.customize(ipTheme + 'navbar_height', function (value) { value.bind(function (newval) { var fontSize = parseInt( $('.main-navigation .ip-nav > li > a').css('font-size') ); $('.main-navigation .ip-nav > li').css('padding-top', ( (newval - ( 3.5*fontSize ) )/2) + 'px').css('padding-bottom', ( (newval - ( 3.5*fontSize ) )/2) + 'px'); }); }); wp.customize(ipTheme + 'mobile_menu_position', function (value) { value.bind(function (newval) { if (newval == 'right') { $('#mobile-menu-offcanvas').removeClass('navmenu-fixed-left'); $('#mobile-menu-offcanvas').addClass('navmenu-fixed-right'); } else { $('#mobile-menu-offcanvas').removeClass('navmenu-fixed-right'); $('#mobile-menu-offcanvas').addClass('navmenu-fixed-left'); } }); }); wp.customize(ipTheme + 'font_size', function (value) { value.bind(function (newval) { $('body').css('font-size', newval + 'px'); }); }); wp.customize(ipTheme + 'single_title_size', function (value) { value.bind(function (newval) { $('.ip-single-item .entry-title').css('font-size', newval + 'px'); }); }); wp.customize(ipTheme + 'archive_title_size', function (value) { value.bind(function (newval) { $('.ip-archive-item .entry-header h2').css('font-size', newval + 'px'); }); }); wp.customize(ipTheme + 'navbar_font_size', function (value) { value.bind(function (newval) { $('.main-navigation .ip-nav > li > a').css('font-size', newval + 'px').css('padding-top', newval*1.25 + 'px').css('padding-bottom', newval*1.25 + 'px'); }); }); })(jQuery, window, document);