(function ($) { wp.customize('afft-header-banner-background-color-top', function (value) { value.bind(function (top) { var bottom = wp.customize.instance('afft-header-banner-background-color-bottom').get(); var header = $('#header'); header.css('background-color', bottom); header.css('background', '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + top + '), to('+ bottom + '))'); header.css('background', '-webkit-linear-gradient(top, ' + top + ', '+ bottom + ')'); header.css('background', '-moz-linear-gradient(top, ' + top + ', '+ bottom + ')'); header.css('background', '-o-linear-gradient(top, ' + top + ', '+ bottom + ')'); header.css('background', 'linear-gradient(' + top + ', ' + bottom + ')'); }); }); wp.customize('afft-header-banner-background-color-bottom', function (value) { value.bind(function (bottom) { var top = wp.customize.instance('afft-header-banner-background-color-top').get(); var header = $('#header'); header.css('background-color', bottom); header.css('background', '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + top + '), to('+ bottom + '))'); header.css('background', '-webkit-linear-gradient(top, ' + top + ', '+ bottom + ')'); header.css('background', '-moz-linear-gradient(top, ' + top + ', '+ bottom + ')'); header.css('background', '-o-linear-gradient(top, ' + top + ', '+ bottom + ')'); header.css('background', 'linear-gradient(' + top + ', ' + bottom + ')'); }); }); wp.customize('afft-header-banner-background-image', function (value) { value.bind(function (image) { var body = $('#header'); body.css('background-image', 'url(' + image + ')'); }); }); wp.customize('afft-header-banner-background-repeat', function (value) { value.bind(function (repeat) { var body = $('#header'); body.css('background-repeat', repeat); }); }); wp.customize('afft-header-banner-background-attachment', function (value) { value.bind(function (attachment) { var body = $('#header'); body.css('background-attachment', attachment); }); }); wp.customize('afft-header-banner-background-size', function (value) { value.bind(function (size) { var body = $('#header'); if (size === 'custom') { var width = wp.customize.instance('afft-header-banner-background-width').get(); var height = wp.customize.instance('afft-header-banner-background-height').get(); body.css('background-size', width + ' ' + height); } else { body.css('background-size', size); } }); }); wp.customize('afft-header-banner-background-width', function (value) { value.bind(function (width) { var size = wp.customize.instance('afft-header-banner-background-size').get(); if (size === 'custom') { var height = wp.customize.instance('afft-header-banner-background-height').get(); var body = $('#header'); body.css('background-size', width + ' ' + height); } }); }); wp.customize('afft-header-banner-background-height', function (value) { value.bind(function (height) { var size = wp.customize.instance('afft-header-banner-background-size').get(); if (size === '#header') { var width = wp.customize.instance('afft-header-banner-background-width').get(); var body = $('header'); body.css('background-size', width + ' ' + height); } }); }); wp.customize('afft-header-banner-title-color', function (value) { value.bind(function (color) { $('#title').css('color', color); }); }); wp.customize('afft-header-banner-title-shadow-color', function (value) { value.bind(function (color) { // There is no transparent color picker. The color #600099 stands for transparency if(color !== '') { $('#title').css('text-shadow', '1px 1px 1px ' + color); } else { $('#title').css('text-shadow', '0 0 0 rgba(0, 0, 0, 0)'); } }); }); wp.customize('afft-header-banner-title-font-family', function (value) { value.bind(function (color) { $('#title').css('font-family', color); }); }); wp.customize('afft-header-banner-tagline-color', function (value) { value.bind(function (color) { $('#tagline').css('color', color); }); }); wp.customize('afft-header-banner-tagline-shadow-color', function (value) { value.bind(function (color) { // There is no transparent color picker. The color #600099 stands for transparency if(color !== '') { $('#tagline').css('text-shadow', '1px 1px 1px ' + color); } else { $('#tagline').css('text-shadow', '0 0 0 rgba(0, 0, 0, 0)'); } }); }); wp.customize('afft-header-banner-tagline-font-family', function (value) { value.bind(function (value) { $('#tagline').css('font-family', value); }); }); wp.customize('afft-header-main-menu-background-color-top', function (value) { value.bind(function (top) { var bottom = wp.customize.instance('afft-header-main-menu-background-color-bottom').get(); var menu = $('#main-menu'); menu.css('background-color', bottom); menu.css('background', '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + top + '), to('+ bottom + '))'); menu.css('background', '-webkit-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', '-moz-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', '-o-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', 'linear-gradient(' + top + ', ' + bottom + ')'); }); }); wp.customize('afft-header-main-menu-background-color-bottom', function (value) { value.bind(function (bottom) { var top = wp.customize.instance('afft-header-main-menu-background-color-top').get(); var menu = $('#main-menu'); menu.css('background-color', bottom); menu.css('background', '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + top + '), to('+ bottom + '))'); menu.css('background', '-webkit-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', '-moz-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', '-o-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', 'linear-gradient(' + top + ', ' + bottom + ')'); }); }); wp.customize('afft-header-main-menu-border-color', function (value) { value.bind(function (color) { $('#main-menu').css('border-color', color); }); }); wp.customize('afft-header-main-menu-item-background-color-hover-top', function (value) { value.bind(function (top) { var bottom = wp.customize.instance('afft-header-main-menu-item-background-color-hover-bottom').get(); $('#main-menu .navbar-nav > .menu-item a').on('hover click focus', function(e) { var menu = $(this); if (!menu.parent().hasClass('active')) { menu.css('background-color', bottom); menu.css('background', e.type === "mouseenter" ? '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + top + '), to(' + bottom + '))' : 'transparent'); menu.css('background', e.type === "mouseenter" ? '-webkit-linear-gradient(top, ' + top + ', ' + bottom + ')' : 'transparent'); menu.css('background', e.type === "mouseenter" ? '-moz-linear-gradient(top, ' + top + ', ' + bottom + ')' : 'transparent'); menu.css('background', e.type === "mouseenter" ? '-o-linear-gradient(top, ' + top + ', ' + bottom + ')' : 'transparent'); menu.css('background', e.type === "mouseenter" ? 'linear-gradient(' + top + ', ' + bottom + ')' : 'transparent'); } }); var menu = $('#main-menu .navbar-nav > .menu-item.active > a, #main-menu .navbar-nav > .menu-item.open > a'); menu.css('background-color', bottom); menu.css('background', '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + top + '), to('+ bottom + '))'); menu.css('background', '-webkit-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', '-moz-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', '-o-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', 'linear-gradient(' + top + ', ' + bottom + ')'); }); }); wp.customize('afft-header-main-menu-item-background-color-hover-bottom', function (value) { value.bind(function (bottom) { var top = wp.customize.instance('afft-header-main-menu-item-background-color-hover-top').get(); $('#main-menu .navbar-nav > .menu-item a').on('hover click focus', function(e) { var menu = $(this); if (!menu.parent().hasClass('active')) { menu.css('background-color', bottom); menu.css('background', e.type === "mouseenter" ? '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + top + '), to(' + bottom + '))' : 'transparent'); menu.css('background', e.type === "mouseenter" ? '-webkit-linear-gradient(top, ' + top + ', ' + bottom + ')' : 'transparent'); menu.css('background', e.type === "mouseenter" ? '-moz-linear-gradient(top, ' + top + ', ' + bottom + ')' : 'transparent'); menu.css('background', e.type === "mouseenter" ? '-o-linear-gradient(top, ' + top + ', ' + bottom + ')' : 'transparent'); menu.css('background', e.type === "mouseenter" ? 'linear-gradient(' + top + ', ' + bottom + ')' : 'transparent'); } }); var menu = $('#main-menu .navbar-nav > .menu-item.active > a, #main-menu .navbar-nav > .menu-item.open > a'); menu.css('background-color', bottom); menu.css('background', '-webkit-gradient(linear, 0% 0%, 0% 100%, from(' + top + '), to('+ bottom + '))'); menu.css('background', '-webkit-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', '-moz-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', '-o-linear-gradient(top, ' + top + ', '+ bottom + ')'); menu.css('background', 'linear-gradient(' + top + ', ' + bottom + ')'); }) }); wp.customize('afft-header-main-menu-link-color', function (value) { value.bind(function (color) { $('#main-menu .navbar-nav > .menu-item:not(.active) a, #main-menu .navbar-brand').css('color', color); }); }); wp.customize('afft-header-main-menu-link-color-hover', function (value) { value.bind(function (color) { $('#main-menu .navbar-nav > .menu-item a, #main-menu .navbar-brand').hover(function(e) { var standart = wp.customize.instance('afft-header-main-menu-link-color').get(); var menuItem = $(this); if(!menuItem.parent().hasClass('active')) { menuItem.css('color', e.type === "mouseenter" ? color : standart); } }); $('#main-menu .navbar-nav > .menu-item.active a').css('color', color); }); }); wp.customize('afft-header-main-menu-dropdown-background-color', function (value) { value.bind(function (color) { $('#main-menu .dropdown-menu').css('background-color', color); }); }); wp.customize('afft-header-main-menu-dropdown-item-background-color-hover', function (value) { value.bind(function (color) { $('#main-menu .dropdown-menu > .menu-item > a').hover(function(e) { var item = $(this); if(!item.parent().hasClass('active')) { item.css('background-color', e.type === "mouseenter" ? color : 'transparent'); } }); $('#main-menu .dropdown-menu .menu-item.active > a').css('color', color); }); }); wp.customize('afft-header-main-menu-dropdown-link-color', function (value) { value.bind(function (color) { $('#main-menu .dropdown-menu .menu-item > a').css('color', color); }); }); wp.customize('afft-header-main-menu-dropdown-link-color-hover', function (value) { value.bind(function (color) { $('#main-menu .dropdown-menu .menu-item > a').hover(function(e) { var standart = wp.customize.instance('afft-header-main-menu-link-color').get(); var link = $(this); link.css('color', e.type === "mouseenter" ? color : standart); }); }); }); wp.customize('afft-header-main-menu-toggle-background-color', function (value) { value.bind(function (color) { $('#main-menu .navbar-toggle').css('background-color', color); }); }); wp.customize('afft-header-main-menu-toggle-background-color-hover', function (value) { value.bind(function (color) { $('#main-menu .navbar-toggle').hover(function(e) { var fallback = wp.customize.instance('afft-header-main-menu-toggle-background-color').get(); $(this).css('background-color', e.type === "mouseenter" ? color : fallback); }); }); }); wp.customize('afft-header-main-menu-toggle-border-color', function (value) { value.bind(function (color) { $('#main-menu .navbar-toggle').css('border-color', color); $('#main-menu .navbar-toggle .icon-bar').css('background-color', color); }); }); wp.customize('afft-header-main-menu-toggle-border-color-hover', function (value) { value.bind(function (color) { $('#main-menu .navbar-toggle').hover(function(e) { var fallback = wp.customize.instance('afft-header-main-menu-toggle-border-color').get(); $('#main-menu .navbar-toggle').css('border-color', e.type === "mouseenter" ? color : fallback); $('#main-menu .navbar-toggle .icon-bar').css('background-color', e.type === "mouseenter" ? color : fallback); }); }); }); })(jQuery);