customizer-dependency.js 0000666 00000026337 15214245400 0011436 0 ustar 00 /** * Customizer controls * * @package Astra */ (function ($) { 'use strict'; /* Internal shorthand */ var api = wp.customize; /** * Helper class for the main Customizer interface. * * @since 1.4.3 * @class Astra_Customizer */ var Astra_Customizer = { controls: {}, /** * Initializes the logic for showing and hiding controls * when a setting changes. * * @since 1.4.3 * @access private * @method init */ init: function () { var $this = this; $this.handleDependency(); $this.hideEmptySections(); api.bind('change', function ( setting, data ) { var has_dependents = $this.hasDependentControls( setting.id ); if( has_dependents ) { $this.handleDependency(); $this.hideEmptySections(); } }); }, hasDependentControls: function( control_id ) { var check = false; $.each(astra.config, function (index, val) { if( !_.isUndefined( val.conditions ) ) { var conditions = val.conditions; $.each( conditions, function (index, val) { var control = val[0]; if( control_id == control ) { check = true; return; } }); } else { var control = val[0]; if( control_id == control ) { check = true; return; } } }); return check; }, /** * Handles dependency for controls. * * @since 1.4.3 * @access private * @method handleDependency */ handleDependency: function () { var $this = this; var values = api.get(); $this.checked_controls = {}; _.each(values, function (value, id) { var control = api.control(id); $this.checkControlVisibility( control, id ); }); }, /** * Hide OR display controls according to dependency * * @since 1.4.3 * @access private * @method checkControlVisibility */ checkControlVisibility: function (control, id) { var $this = this; var values = api.get(); if ( !_.isUndefined( control ) ) { // If control has dependency defined if ( 'undefined' != typeof astra.config[id] ) { var check = false; var required_param = astra.config[id]; var conditions = !_.isUndefined(required_param.conditions) ? required_param.conditions : required_param; var operator = !_.isUndefined(required_param.operator) ? required_param.operator : 'AND'; if ( 'undefined' !== typeof conditions ) { check = $this.checkDependency(conditions, values, operator); this.checked_controls[id] = check; if (!check) { control.container.addClass('ast-hide'); } else { control.container.removeClass('ast-hide'); } } } } }, /** * Checks dependency condtions for controls * * @since 1.4.3 * @access private * @method checkDependency */ checkDependency: function (conditions, values, compare_operator) { var control = this; var check = true; var returnNow = false; var test = conditions[0]; if ( _.isString( test ) ) { var cond = conditions[1]; var cond_val = conditions[2]; var value; if ( !_.isUndefined( astra.config[test] ) ) { var conditions = !_.isUndefined(astra.config[test]['conditions']) ? astra.config[test]['conditions'] : astra.config[test]; var operator = !_.isUndefined(astra.config[test]['operator']) ? astra.config[test]['operator'] : 'AND'; if ( !_.isUndefined( conditions ) ) { // Check visibility for dependent controls also if ( ! control.checkDependency( conditions, values, operator ) ) { returnNow = true; check = false; if( 'AND' == compare_operator ) { return; } } else { var control_obj = api.control(test); control_obj.container.removeClass('ast-hide'); } } } if ( !_.isUndefined( values[test] ) && !returnNow && check ) { value = values[test]; check = control.compareValues( value, cond, cond_val ); } } else if ( _.isArray( test ) ) { $.each( conditions, function ( index, val ) { var cond_key = val[0]; var cond_cond = val[1]; var cond_val = val[2]; var t_val = !_.isUndefined( values[cond_key] ) ? values[cond_key] : ''; if ( 'undefined' !== typeof astra.config[cond_key] ) { var conditions = !_.isUndefined(astra.config[cond_key]['conditions']) ? astra.config[cond_key]['conditions'] : astra.config[cond_key]; var operator = !_.isUndefined(astra.config[cond_key]['operator']) ? astra.config[cond_key]['operator'] : 'AND'; if ( !_.isUndefined( conditions ) ) { // Check visibility for dependent controls also if ( ! control.checkDependency( conditions, values, operator ) ) { check = false; if( 'AND' == compare_operator ) { return; } } else { check = true; var control_obj = api.control(cond_key); control_obj.container.removeClass('ast-hide'); } } } else { check = true; } if( check ) { if ( 'AND' == compare_operator ) { if ( ! control.compareValues( t_val, cond_cond, cond_val ) ) { check = false; return false; } } else { if ( control.compareValues( t_val, cond_cond, cond_val ) ) { returnNow = true; check = true; } else { check = false; } } } }); // Break loop in case of OR operator if ( returnNow && 'OR' == compare_operator ) { check = true; } } return check; }, /** * Hide Section without Controls. * */ hideEmptySections: function () { $('ul.accordion-section.control-section-ast_section').each(function () { var parentId = $(this).attr('id'); var visibleIt = false; var controls = $(this).find(' > .customize-control'); if ( controls.length > 0 ) { controls.each(function () { if ( ! $(this).hasClass('ast-hide') && $(this).css('display') != 'none' ) { visibleIt = true; } }); if (!visibleIt) { $('.control-section[aria-owns="' + parentId + '"]').addClass('ast-hide'); } else { $('.control-section[aria-owns="' + parentId + '"]').removeClass('ast-hide'); } } }); }, /** * Compare values * * @since 1.4.3 * @access private * @method compareValues */ compareValues: function (value1, cond, value2) { var equal = false; switch (cond) { case '===': equal = (value1 === value2) ? true : false; break; case '>': equal = (value1 > value2) ? true : false; break; case '<': equal = (value1 < value2) ? true : false; break; case '<=': equal = (value1 <= value2) ? true : false; break; case '>=': equal = (value1 >= value2) ? true : false; break; case '!=': equal = (value1 != value2) ? true : false; break; case 'empty': var _v = _.clone(value1); if (_.isObject(_v) || _.isArray(_v)) { _.each(_v, function (v, i) { if (_.isEmpty(v)) { delete _v[i]; } }); equal = _.isEmpty(_v) ? true : false; } else { equal = _.isNull(_v) || _v == '' ? true : false; } break; case 'not_empty': var _v = _.clone(value1); if (_.isObject(_v) || _.isArray(_v)) { _.each(_v, function (v, i) { if (_.isEmpty(v)) { delete _v[i]; } }) } equal = _.isEmpty(_v) ? false : true; break; case 'contains': if (_.isArray(value1)) { if ($.inArray(value2, value1) !== -1) { equal = true; } } break; default: if (_.isArray(value2)) { if (!_.isEmpty(value2) && !_.isEmpty(value1)) { equal = _.contains(value2, value1); } else { equal = false; } } else { equal = (value1 == value2) ? true : false; } } return equal; }, }; $(function () { Astra_Customizer.init(); }); })(jQuery); extend-customizer.js 0000666 00000014601 15214245400 0010576 0 ustar 00 /** * Extend Customizer Panel * * @package Astra */ ( function( $ ) { var api = wp.customize; api.bind( 'pane-contents-reflowed', function() { // Reflow sections var sections = []; api.section.each( function( section ) { if ( 'ast_section' !== section.params.type || 'undefined' === typeof section.params.section ) { return; } sections.push( section ); }); sections.sort( api.utils.prioritySort ).reverse(); $.each( sections, function( i, section ) { var parentContainer = $( '#sub-accordion-section-' + section.params.section ); parentContainer.children( '.section-meta' ).after( section.headContainer ); }); // Reflow panels var panels = []; api.panel.each( function( panel ) { if ( 'ast_panel' !== panel.params.type || 'undefined' === typeof panel.params.panel ) { return; } panels.push( panel ); }); panels.sort( api.utils.prioritySort ).reverse(); $.each( panels, function( i, panel ) { var parentContainer = $( '#sub-accordion-panel-' + panel.params.panel ); parentContainer.children( '.panel-meta' ).after( panel.headContainer ); }); }); // Extend Panel var _panelEmbed = wp.customize.Panel.prototype.embed; var _panelIsContextuallyActive = wp.customize.Panel.prototype.isContextuallyActive; var _panelAttachEvents = wp.customize.Panel.prototype.attachEvents; wp.customize.Panel = wp.customize.Panel.extend({ attachEvents: function() { if ( 'ast_panel' !== this.params.type || 'undefined' === typeof this.params.panel ) { _panelAttachEvents.call( this ); return; } _panelAttachEvents.call( this ); var panel = this; panel.expanded.bind( function( expanded ) { var parent = api.panel( panel.params.panel ); if ( expanded ) { parent.contentContainer.addClass( 'current-panel-parent' ); } else { parent.contentContainer.removeClass( 'current-panel-parent' ); } }); panel.container.find( '.customize-panel-back' ) .off( 'click keydown' ) .on( 'click keydown', function( event ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } event.preventDefault(); // Keep this AFTER the key filter above if ( panel.expanded() ) { api.panel( panel.params.panel ).expand(); } }); }, embed: function() { if ( 'ast_panel' !== this.params.type || 'undefined' === typeof this.params.panel ) { _panelEmbed.call( this ); return; } _panelEmbed.call( this ); var panel = this; var parentContainer = $( '#sub-accordion-panel-' + this.params.panel ); parentContainer.append( panel.headContainer ); }, isContextuallyActive: function() { if ( 'ast_panel' !== this.params.type ) { return _panelIsContextuallyActive.call( this ); } var panel = this; var children = this._children( 'panel', 'section' ); api.panel.each( function( child ) { if ( ! child.params.panel ) { return; } if ( child.params.panel !== panel.id ) { return; } children.push( child ); }); children.sort( api.utils.prioritySort ); var activeCount = 0; _( children ).each( function ( child ) { if ( child.active() && child.isContextuallyActive() ) { activeCount += 1; } }); return ( activeCount !== 0 ); } }); // Extend Section var _sectionEmbed = wp.customize.Section.prototype.embed; var _sectionIsContextuallyActive = wp.customize.Section.prototype.isContextuallyActive; var _sectionAttachEvents = wp.customize.Section.prototype.attachEvents; wp.customize.Section = wp.customize.Section.extend({ attachEvents: function() { if ( 'ast_section' !== this.params.type || 'undefined' === typeof this.params.section ) { _sectionAttachEvents.call( this ); return; } _sectionAttachEvents.call( this ); var section = this; section.expanded.bind( function( expanded ) { var parent = api.section( section.params.section ); if ( expanded ) { parent.contentContainer.addClass( 'current-section-parent' ); } else { parent.contentContainer.removeClass( 'current-section-parent' ); } }); section.container.find( '.customize-section-back' ) .off( 'click keydown' ) .on( 'click keydown', function( event ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } event.preventDefault(); // Keep this AFTER the key filter above if ( section.expanded() ) { api.section( section.params.section ).expand(); } }); }, embed: function() { if ( 'ast_section' !== this.params.type || 'undefined' === typeof this.params.section ) { _sectionEmbed.call( this ); return; } _sectionEmbed.call( this ); var section = this; var parentContainer = $( '#sub-accordion-section-' + this.params.section ); parentContainer.append( section.headContainer ); }, isContextuallyActive: function() { if ( 'ast_section' !== this.params.type ) { return _sectionIsContextuallyActive.call( this ); } var section = this; var children = this._children( 'section', 'control' ); api.section.each( function( child ) { if ( ! child.params.section ) { return; } if ( child.params.section !== section.id ) { return; } children.push( child ); }); children.sort( api.utils.prioritySort ); var activeCount = 0; _( children ).each( function ( child ) { if ( 'undefined' !== typeof child.isContextuallyActive ) { if ( child.active() && child.isContextuallyActive() ) { activeCount += 1; } } else { if ( child.active() ) { activeCount += 1; } } }); return ( activeCount !== 0 ); } }); })( jQuery ); style.js 0000666 00000046747 15214245400 0006265 0 ustar 00 /** * File navigation.js * * Handles toggling the navigation menu for small screens and enables tab * support for dropdown menus. * * @package Astra */ /** * Get all of an element's parent elements up the DOM tree * * @param {Node} elem The element. * @param {String} selector Selector to match against [optional]. * @return {Array} The parent elements. */ var getParents = function ( elem, selector ) { // Element.matches() polyfill. if ( ! Element.prototype.matches) { Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function(s) { var matches = (this.document || this.ownerDocument).querySelectorAll( s ), i = matches.length; while (--i >= 0 && matches.item( i ) !== this) {} return i > -1; }; } // Setup parents array. var parents = []; // Get matching parent elements. for ( ; elem && elem !== document; elem = elem.parentNode ) { // Add matching parents to array. if ( selector ) { if ( elem.matches( selector ) ) { parents.push( elem ); } } else { parents.push( elem ); } } return parents; }; /** * Toggle Class funtion * * @param {Node} elem The element. * @param {String} selector Selector to match against [optional]. * @return {Array} The parent elements. */ var toggleClass = function ( el, className ) { if ( el.classList.contains( className ) ) { el.classList.remove( className ); } else { el.classList.add( className ); } }; // CustomEvent() constructor functionality in Internet Explorer 9 and higher. (function () { if (typeof window.CustomEvent === "function") return false; function CustomEvent(event, params) { params = params || { bubbles: false, cancelable: false, detail: undefined }; var evt = document.createEvent('CustomEvent'); evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); return evt; } CustomEvent.prototype = window.Event.prototype; window.CustomEvent = CustomEvent; })(); /** * Trigget custom JS Event. * * @since 1.4.6 * * @link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent * @param {Node} el Dom Node element on which the event is to be triggered. * @param {Node} typeArg A DOMString representing the name of the event. * @param {String} A CustomEventInit dictionary, having the following fields: * "detail", optional and defaulting to null, of type any, that is an event-dependent value associated with the event. */ var astraTriggerEvent = function astraTriggerEvent( el, typeArg ) { var customEventInit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var event = new CustomEvent(typeArg, customEventInit); el.dispatchEvent(event); }; ( function() { var menu_toggle_all = document.querySelectorAll( '.main-header-menu-toggle' ); var menu_click_listeners = {}; /* Add break point Class and related trigger */ var updateHeaderBreakPoint = function () { // Content overrflowing out of screen can give incorrect window.innerWidth. // Adding overflow hidden and then calculating the window.innerWidth fixes the problem. var originalOverflow = document.querySelector('body').style.overflow; document.querySelector('body').style.overflow = 'hidden'; var ww = window.innerWidth; document.querySelector('body').style.overflow = originalOverflow; var break_point = astra.break_point, headerWrap = document.querySelectorAll('.main-header-bar-wrap'); if (headerWrap.length > 0) { for (var i = 0; i < headerWrap.length; i++) { if (headerWrap[i].tagName == 'DIV' && headerWrap[i].classList.contains('main-header-bar-wrap')) { if (ww > break_point) { //remove menu toggled class. if (null != menu_toggle_all[i]) { menu_toggle_all[i].classList.remove('toggled'); } document.body.classList.remove("ast-header-break-point"); document.body.classList.add("ast-desktop"); astraTriggerEvent(document.body, "astra-header-responsive-enabled"); } else { document.body.classList.add("ast-header-break-point"); document.body.classList.remove("ast-desktop"); astraTriggerEvent(document.body, "astra-header-responsive-disabled") } } } } } updateHeaderBreakPoint(); AstraToggleSubMenu = function() { var parent_li = this.parentNode; if (parent_li.classList.contains('ast-submenu-expanded') && document.querySelector("header.site-header").classList.contains("ast-menu-toggle-link")) { if (!this.classList.contains('ast-menu-toggle')) { var link = parent_li.querySelector('a').getAttribute('href'); if ('' !== link || '#' !== link) { window.location = link; } } } var parent_li_child = parent_li.querySelectorAll('.menu-item-has-children, .page_item_has_children'); for (var j = 0; j < parent_li_child.length; j++) { parent_li_child[j].classList.remove('ast-submenu-expanded'); var parent_li_child_sub_menu = parent_li_child[j].querySelector('.sub-menu, .children'); parent_li_child_sub_menu.style.display = 'none'; }; var parent_li_sibling = parent_li.parentNode.querySelectorAll('.menu-item-has-children, .page_item_has_children'); for (var j = 0; j < parent_li_sibling.length; j++) { if (parent_li_sibling[j] != parent_li) { parent_li_sibling[j].classList.remove('ast-submenu-expanded'); var all_sub_menu = parent_li_sibling[j].querySelectorAll('.sub-menu, .children'); for (var k = 0; k < all_sub_menu.length; k++) { all_sub_menu[k].style.display = 'none'; }; } }; if (parent_li.classList.contains('menu-item-has-children') || parent_li.classList.contains('page_item_has_children')) { toggleClass(parent_li, 'ast-submenu-expanded'); if (parent_li.classList.contains('ast-submenu-expanded')) { parent_li.querySelector('.sub-menu, .children').style.display = 'block'; } else { parent_li.querySelector('.sub-menu, .children').style.display = 'none'; } } }; AstraNavigationMenu = function( parentList ) { console.warn( 'AstraNavigationMenu() function has been deprecated since version 1.6.5 or above of Astra Theme and will be removed in the future.' ); }; AstraToggleMenu = function( astra_menu_toggle ) { console.warn('AstraToggleMenu() function has been deprecated since version 1.6.5 or above of Astra Theme and will be removed in the future. Use AstraToggleSubMenu() instead.'); // Add Eventlisteners for Submenu. if (astra_menu_toggle.length > 0) { for (var i = 0; i < astra_menu_toggle.length; i++) { astra_menu_toggle[i].addEventListener('click', AstraToggleSubMenu, false); }; } }; AstraToggleSetup = function () { var __main_header_all = document.querySelectorAll('.main-header-bar-navigation'); if (menu_toggle_all.length > 0) { for (var i = 0; i < menu_toggle_all.length; i++) { menu_toggle_all[i].setAttribute('data-index', i); if ( ! menu_click_listeners[i] ) { menu_click_listeners[i] = menu_toggle_all[i]; menu_toggle_all[i].addEventListener('click', astraNavMenuToggle, false); } if ('undefined' !== typeof __main_header_all[i]) { if (document.querySelector("header.site-header").classList.contains("ast-menu-toggle-link")) { var astra_menu_toggle = __main_header_all[i].querySelectorAll('.ast-header-break-point .main-header-menu .menu-item-has-children > a, .ast-header-break-point .main-header-menu .page_item_has_children > a, .ast-header-break-point ul.main-header-menu .ast-menu-toggle'); } else { var astra_menu_toggle = __main_header_all[i].querySelectorAll('ul.main-header-menu .ast-menu-toggle'); } // Add Eventlisteners for Submenu. if (astra_menu_toggle.length > 0) { for (var j = 0; j < astra_menu_toggle.length; j++) { astra_menu_toggle[j].addEventListener('click', AstraToggleSubMenu, false); }; } } }; } }; astraNavMenuToggle = function ( event ) { event.preventDefault(); var __main_header_all = document.querySelectorAll('.main-header-bar-navigation'); var event_index = this.getAttribute('data-index'); if ('undefined' === typeof __main_header_all[event_index]) { return false; } var menuHasChildren = __main_header_all[event_index].querySelectorAll('.menu-item-has-children, .page_item_has_children'); for (var i = 0; i < menuHasChildren.length; i++) { menuHasChildren[i].classList.remove('ast-submenu-expanded'); var menuHasChildrenSubMenu = menuHasChildren[i].querySelectorAll('.sub-menu, .children'); for (var j = 0; j < menuHasChildrenSubMenu.length; j++) { menuHasChildrenSubMenu[j].style.display = 'none'; }; } var menu_class = this.getAttribute('class') || ''; if ( menu_class.indexOf('main-header-menu-toggle') !== -1 ) { toggleClass(__main_header_all[event_index], 'toggle-on'); toggleClass(menu_toggle_all[event_index], 'toggled'); if (__main_header_all[event_index].classList.contains('toggle-on')) { __main_header_all[event_index].style.display = 'block'; document.body.classList.add("ast-main-header-nav-open"); } else { __main_header_all[event_index].style.display = ''; document.body.classList.remove("ast-main-header-nav-open"); } } }; document.body.addEventListener("astra-header-responsive-enabled", function () { var __main_header_all = document.querySelectorAll('.main-header-bar-navigation'); if (__main_header_all.length > 0) { for (var i = 0; i < __main_header_all.length; i++) { if (null != __main_header_all[i]) { __main_header_all[i].classList.remove('toggle-on'); __main_header_all[i].style.display = ''; } var sub_menu = __main_header_all[i].getElementsByClassName('sub-menu'); for (var j = 0; j < sub_menu.length; j++) { sub_menu[j].style.display = ''; } var child_menu = __main_header_all[i].getElementsByClassName('children'); for (var k = 0; k < child_menu.length; k++) { child_menu[k].style.display = ''; } var searchIcons = __main_header_all[i].getElementsByClassName('ast-search-menu-icon'); for (var l = 0; l < searchIcons.length; l++) { searchIcons[l].classList.remove('ast-dropdown-active'); searchIcons[l].style.display = ''; } } } }, false); window.addEventListener('resize', function () { // Skip resize event when keyboard display event triggers on devices. if( 'INPUT' !== document.activeElement.tagName ) { updateHeaderBreakPoint(); AstraToggleSetup(); } }); document.addEventListener('DOMContentLoaded', function () { AstraToggleSetup(); /** * Navigation Keyboard Navigation. */ var container, button, menu, links, subMenus, i, len, count; container = document.querySelectorAll( '.navigation-accessibility' ); for ( count = 0; count <= container.length - 1; count++ ) { if ( container[count] ) { navigation_accessibility( container[count] ); } } }); var get_browser = function () { var ua = navigator.userAgent,tem,M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if(/trident/i.test(M[1])) { tem = /\brv[ :]+(\d+)/g.exec(ua) || []; return; } if( 'Chrome' === M[1] ) { tem = ua.match(/\bOPR|Edge\/(\d+)/) if(tem != null) { return; } } M = M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; if((tem = ua.match(/version\/(\d+)/i)) != null) { M.splice(1,1,tem[1]); } bodyElement = document.body; if( 'Safari' === M[0] && M[1] < 11 ) { bodyElement.classList.add( "ast-safari-browser-less-than-11" ); } } get_browser(); /* Search Script */ var SearchIcons = document.getElementsByClassName( 'astra-search-icon' ); for (var i = 0; i < SearchIcons.length; i++) { SearchIcons[i].onclick = function(event) { if ( this.classList.contains( 'slide-search' ) ) { event.preventDefault(); var sibling = this.parentNode.parentNode.parentNode.querySelector( '.ast-search-menu-icon' ); if ( ! sibling.classList.contains( 'ast-dropdown-active' ) ) { sibling.classList.add( 'ast-dropdown-active' ); sibling.querySelector( '.search-field' ).setAttribute('autocomplete','off'); setTimeout(function() { sibling.querySelector( '.search-field' ).focus(); },200); } else { var searchTerm = sibling.querySelector( '.search-field' ).value || ''; if( '' !== searchTerm ) { sibling.querySelector( '.search-form' ).submit(); } sibling.classList.remove( 'ast-dropdown-active' ); } } } }; /* Hide Dropdown on body click*/ document.body.onclick = function( event ) { if ( typeof event.target.classList !== 'undefined' ) { if ( ! event.target.classList.contains( 'ast-search-menu-icon' ) && getParents( event.target, '.ast-search-menu-icon' ).length === 0 && getParents( event.target, '.ast-search-icon' ).length === 0 ) { var dropdownSearchWrap = document.getElementsByClassName( 'ast-search-menu-icon' ); for (var i = 0; i < dropdownSearchWrap.length; i++) { dropdownSearchWrap[i].classList.remove( 'ast-dropdown-active' ); }; } } } /** * Navigation Keyboard Navigation. */ function navigation_accessibility( container ) { if ( ! container ) { return; } button = container.getElementsByTagName( 'button' )[0]; if ( 'undefined' === typeof button ) { button = container.getElementsByTagName( 'a' )[0]; if ( 'undefined' === typeof button ) { return; } } menu = container.getElementsByTagName( 'ul' )[0]; // Hide menu toggle button if menu is empty and return early. if ( 'undefined' === typeof menu ) { button.style.display = 'none'; return; } menu.setAttribute( 'aria-expanded', 'false' ); if ( -1 === menu.className.indexOf( 'nav-menu' ) ) { menu.className += ' nav-menu'; } button.onclick = function() { if ( -1 !== container.className.indexOf( 'toggled' ) ) { container.className = container.className.replace( ' toggled', '' ); button.setAttribute( 'aria-expanded', 'false' ); menu.setAttribute( 'aria-expanded', 'false' ); } else { container.className += ' toggled'; button.setAttribute( 'aria-expanded', 'true' ); menu.setAttribute( 'aria-expanded', 'true' ); } }; // Get all the link elements within the menu. links = menu.getElementsByTagName( 'a' ); subMenus = menu.getElementsByTagName( 'ul' ); // Set menu items with submenus to aria-haspopup="true". for ( i = 0, len = subMenus.length; i < len; i++ ) { subMenus[i].parentNode.setAttribute( 'aria-haspopup', 'true' ); } // Each time a menu link is focused or blurred, toggle focus. for ( i = 0, len = links.length; i < len; i++ ) { links[i].addEventListener( 'focus', toggleFocus, true ); links[i].addEventListener( 'blur', toggleBlurFocus, true ); links[i].addEventListener( 'click', toggleClose, true ); } } /** * Close the Toggle Menu on Click on hash (#) link. * * @since 1.3.2 * @return void */ function toggleClose( ) { var self = this || '', hash = '#'; if( self && ! self.classList.contains('astra-search-icon') ) { var link = new String( self ); if( link.indexOf( hash ) !== -1 ) { var link_parent = self.parentNode; if ( document.body.classList.contains('ast-header-break-point') && ! ( document.querySelector("header.site-header").classList.contains("ast-menu-toggle-link") && link_parent.classList.contains("menu-item-has-children") ) ) { /* Close Main Header Menu */ var main_header_menu_toggle = document.querySelector( '.main-header-menu-toggle' ); main_header_menu_toggle.classList.remove( 'toggled' ); var main_header_bar_navigation = document.querySelector( '.main-header-bar-navigation' ); main_header_bar_navigation.classList.remove( 'toggle-on' ); main_header_bar_navigation.style.display = 'none'; /* Close Below Header Menu */ var before_header_menu_toggle = document.querySelector( '.menu-below-header-toggle' ); var before_header_bar_navigation = document.querySelector( '.ast-below-header' ); var before_header_bar = document.querySelector( '.ast-below-header-actual-nav' ); if ( before_header_menu_toggle && before_header_bar_navigation && before_header_bar ) { before_header_menu_toggle.classList.remove( 'toggled' ); before_header_bar_navigation.classList.remove( 'toggle-on' ); before_header_bar.style.display = 'none'; } /* Close After Header Menu */ var after_header_menu_toggle = document.querySelector( '.menu-above-header-toggle' ); var after_header_bar_navigation = document.querySelector( '.ast-above-header' ); var after_header_bar = document.querySelector( '.ast-above-header-navigation' ); if ( after_header_menu_toggle && after_header_bar_navigation && after_header_bar ) { after_header_menu_toggle.classList.remove( 'toggled' ); after_header_bar_navigation.classList.remove( 'toggle-on' ); after_header_bar.style.display = 'none'; } astraTriggerEvent( document.querySelector('body'), 'astraMenuHashLinkClicked' ); } else { while ( -1 === self.className.indexOf( 'nav-menu' ) ) { // On li elements toggle the class .focus. if ( 'li' === self.tagName.toLowerCase() ) { if ( -1 !== self.className.indexOf( 'focus' ) ) { self.className = self.className.replace( ' focus', '' ); } } self = self.parentElement; } } } } } /** * Sets or removes .focus class on an element on focus. */ function toggleFocus() { var self = this; // Move up through the ancestors of the current link until we hit .nav-menu. while ( -1 === self.className.indexOf( 'nav-menu' ) ) { // On li elements toggle the class .focus. if ( 'li' === self.tagName.toLowerCase() ) { if ( -1 !== self.className.indexOf( 'focus' ) ) { self.className = self.className.replace( ' focus', '' ); } else { self.className += ' focus'; } } self = self.parentElement; } } /** * Sets or removes .focus class on an element on blur. */ function toggleBlurFocus() { var self = this || '', hash = '#'; link = new String( self ); if( link.indexOf( hash ) !== -1 && document.body.classList.contains('ast-mouse-clicked') ) { return; } // Move up through the ancestors of the current link until we hit .nav-menu. while ( -1 === self.className.indexOf( 'nav-menu' ) ) { // On li elements toggle the class .focus. if ( 'li' === self.tagName.toLowerCase() ) { if ( -1 !== self.className.indexOf( 'focus' ) ) { self.className = self.className.replace( ' focus', '' ); } else { self.className += ' focus'; } } self = self.parentElement; } } /* Add class if mouse clicked and remove if tab pressed */ if ( 'querySelector' in document && 'addEventListener' in window ) { var body = document.body; body.addEventListener( 'mousedown', function() { body.classList.add( 'ast-mouse-clicked' ); } ); body.addEventListener( 'keydown', function() { body.classList.remove( 'ast-mouse-clicked' ); } ); } } )(); customizer-controls.js 0000666 00000003734 15214245400 0011157 0 ustar 00 /** * Customizer controls * * @package Astra */ ( function( $ ) { /* Internal shorthand */ var api = wp.customize; /** * Helper class for the main Customizer interface. * * @since 1.0.0 * @class ASTCustomizer */ ASTCustomizer = { controls : {}, /** * Initializes our custom logic for the Customizer. * * @since 1.0.0 * @method init */ init: function() { ASTCustomizer._initToggles(); }, /** * Initializes the logic for showing and hiding controls * when a setting changes. * * @since 1.0.0 * @access private * @method _initToggles */ _initToggles: function() { // Trigger the Adv Tab Click trigger. ASTControlTrigger.triggerHook( 'astra-toggle-control', api ); // Loop through each setting. $.each( ASTCustomizerToggles, function( settingId, toggles ) { // Get the setting object. api( settingId, function( setting ) { // Loop though the toggles for the setting. $.each( toggles, function( i, toggle ) { // Loop through the controls for the toggle. $.each( toggle.controls, function( k, controlId ) { // Get the control object. api.control( controlId, function( control ) { // Define the visibility callback. var visibility = function( to ) { control.container.toggle( toggle.callback( to ) ); }; // Init visibility. visibility( setting.get() ); // Bind the visibility callback to the setting. setting.bind( visibility ); }); }); }); }); }); } }; $( function() { ASTCustomizer.init(); } ); })( jQuery ); ( function( api ) { // Extends our custom astra-pro section. api.sectionConstructor['astra-pro'] = api.Section.extend( { // No events for this type of section. attachEvents: function () {}, // Always make the section active. isContextuallyActive: function () { return true; } } ); } )( wp.customize ); wp-color-picker-alpha.js 0000666 00000036361 15214245400 0011214 0 ustar 00 /**! * wp-color-picker-alpha * * Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker * Only run in input and is defined data alpha in true * * Version: 2.1.3 * https://github.com/kallookoo/wp-color-picker-alpha * Licensed under the GPLv2 license or later. */ ( function( $ ) { // Prevent double-init. if ( $.wp.wpColorPicker.prototype._hasAlpha ) { return; } // Variable for some backgrounds ( grid ) var image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==', // html stuff for wpColorPicker copy of the original color-picker.js _after = '
', _wrap = '', _button = '', // Prevent CSS issues in < WordPress 4.9 _deprecated = ( wpColorPickerL10n.current !== undefined ); // Declare some global variables when is deprecated or not if ( _deprecated ) { var _before = ''; } else { var _before = '', _wrappingLabel = '', _wrappingLabelText = ''; } /** * Overwrite Color * for enable support rbga */ Color.fn.toString = function() { if ( this._alpha < 1 ) return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' ); var hex = parseInt( this._color, 10 ).toString( 16 ); if ( this.error ) return ''; if ( hex.length < 6 ) hex = ( '00000' + hex ).substr( -6 ); return '#' + hex; }; /** * Overwrite wpColorPicker */ $.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, { _hasAlpha: true, /** * @summary Creates the color picker. * * Creates the color picker, sets default values, css classes and wraps it all in HTML. * * @since 3.5.0 * * @access private * * @returns {void} */ _create: function() { // Return early if Iris support is missing. if ( ! $.support.iris ) { return; } var self = this, el = self.element; // Override default options with options bound to the element. $.extend( self.options, el.data() ); // Create a color picker which only allows adjustments to the hue. if ( self.options.type === 'hue' ) { return self._createHueOnly(); } // Bind the close event. self.close = $.proxy( self.close, self ); self.initialValue = el.val(); // Add a CSS class to the input field. el.addClass( 'wp-color-picker' ); if ( _deprecated ) { el.hide().wrap( _wrap ); self.wrap = el.parent(); self.toggler = $( _before ) .insertBefore( el ) .css( { backgroundColor : self.initialValue } ) .attr( 'title', wpColorPickerL10n.pick ) .attr( 'data-current', wpColorPickerL10n.current ); self.pickerContainer = $( _after ).insertAfter( el ); self.button = $( _button ).addClass('hidden'); } else { /* * Check if there's already a wrapping label, e.g. in the Customizer. * If there's no label, add a default one to match the Customizer template. */ if ( ! el.parent( 'label' ).length ) { // Wrap the input field in the default label. el.wrap( _wrappingLabel ); // Insert the default label text. self.wrappingLabelText = $( _wrappingLabelText ) .insertBefore( el ) .text( wpColorPickerL10n.defaultLabel ); } /* * At this point, either it's the standalone version or the Customizer * one, we have a wrapping label to use as hook in the DOM, let's store it. */ self.wrappingLabel = el.parent(); // Wrap the label in the main wrapper. self.wrappingLabel.wrap( _wrap ); // Store a reference to the main wrapper. self.wrap = self.wrappingLabel.parent(); // Set up the toggle button and insert it before the wrapping label. self.toggler = $( _before ) .insertBefore( self.wrappingLabel ) .css( { backgroundColor: self.initialValue } ); // Set the toggle button span element text. self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick ); // Set up the Iris container and insert it after the wrapping label. self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel ); // Store a reference to the Clear/Default button. self.button = $( _button ); } // Set up the Clear/Default button. if ( self.options.defaultColor ) { self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString ); if ( ! _deprecated ) { self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel ); } } else { self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear ); if ( ! _deprecated ) { self.button.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel ); } } if ( _deprecated ) { el.wrap( '' ).after( self.button ); } else { // Wrap the wrapping label in its wrapper and append the Clear/Default button. self.wrappingLabel .wrap( '' ) .after( self.button ); /* * The input wrapper now contains the label+input+Clear/Default button. * Store a reference to the input wrapper: we'll use this to toggle * the controls visibility. */ self.inputWrapper = el.closest( '.wp-picker-input-wrap' ); } el.iris( { target: self.pickerContainer, hide: self.options.hide, width: self.options.width, mode: self.options.mode, palettes: self.options.palettes, /** * @summary Handles the onChange event if one has been defined in the options. * * Handles the onChange event if one has been defined in the options and additionally * sets the background color for the toggler element. * * @since 3.5.0 * * @param {Event} event The event that's being called. * @param {HTMLElement} ui The HTMLElement containing the color picker. * * @returns {void} */ change: function( event, ui ) { if ( self.options.alpha ) { self.toggler.css( { 'background-image' : 'url(' + image + ')' } ); if ( _deprecated ) { self.toggler.html( '' ); } else { self.toggler.css( { 'position' : 'relative' } ); if ( self.toggler.find('span.color-alpha').length == 0 ) { self.toggler.append(''); } } self.toggler.find( 'span.color-alpha' ).css( { 'width' : '30px', 'height' : '28px', 'position' : 'absolute', 'top' : 0, 'left' : 0, 'border-top-left-radius' : '2px', 'border-bottom-left-radius' : '2px', 'background' : ui.color.toString() } ); } else { self.toggler.css( { backgroundColor : ui.color.toString() } ); } if ( $.isFunction( self.options.change ) ) { self.options.change.call( this, event, ui ); } } } ); el.val( self.initialValue ); self._addListeners(); // Force the color picker to always be closed on initial load. if ( ! self.options.hide ) { self.toggler.click(); } }, /** * @summary Binds event listeners to the color picker. * * @since 3.5.0 * * @access private * * @returns {void} */ _addListeners: function() { var self = this; /** * @summary Prevent any clicks inside this widget from leaking to the top and closing it. * * @since 3.5.0 * * @param {Event} event The event that's being called. * * @returs {void} */ self.wrap.on( 'click.wpcolorpicker', function( event ) { event.stopPropagation(); }); /** * @summary Open or close the color picker depending on the class. * * @since 3.5 */ self.toggler.click( function(){ if ( self.toggler.hasClass( 'wp-picker-open' ) ) { self.close(); } else { self.open(); } }); /** * @summary Checks if value is empty when changing the color in the color picker. * * Checks if value is empty when changing the color in the color picker. * If so, the background color is cleared. * * @since 3.5.0 * * @param {Event} event The event that's being called. * * @returns {void} */ self.element.on( 'change', function( event ) { // Empty or Error = clear if ( $( this ).val() === '' || self.element.hasClass( 'iris-error' ) ) { if ( self.options.alpha ) { if ( _deprecated ) { self.toggler.removeAttr( 'style' ); } self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' ); } else { self.toggler.css( 'backgroundColor', '' ); } // fire clear callback if we have one if ( $.isFunction( self.options.clear ) ) self.options.clear.call( this, event ); } } ); /** * @summary Enables the user to clear or revert the color in the color picker. * * Enables the user to either clear the color in the color picker or revert back to the default color. * * @since 3.5.0 * * @param {Event} event The event that's being called. * * @returns {void} */ self.button.on( 'click', function( event ) { if ( $( this ).hasClass( 'wp-picker-clear' ) ) { self.element.val( '' ); if ( self.options.alpha ) { if ( _deprecated ) { self.toggler.removeAttr( 'style' ); } self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' ); } else { self.toggler.css( 'backgroundColor', '' ); } if ( $.isFunction( self.options.clear ) ) self.options.clear.call( this, event ); self.element.trigger( 'change' ); } else if ( $( this ).hasClass( 'wp-picker-default' ) ) { self.element.val( self.options.defaultColor ).change(); } }); }, }); /** * Overwrite iris */ $.widget( 'a8c.iris', $.a8c.iris, { _create: function() { this._super(); // Global option for check is mode rbga is enabled this.options.alpha = this.element.data( 'alpha' ) || false; // Is not input disabled if ( ! this.element.is( ':input' ) ) this.options.alpha = false; if ( typeof this.options.alpha !== 'undefined' && this.options.alpha ) { var self = this, el = self.element, _html = '', aContainer = $( _html ).appendTo( self.picker.find( '.iris-picker-inner' ) ), aSlider = aContainer.find( '.iris-slider-offset-alpha' ), controls = { aContainer : aContainer, aSlider : aSlider }; if ( typeof el.data( 'custom-width' ) !== 'undefined' ) { self.options.customWidth = parseInt( el.data( 'custom-width' ) ) || 0; } else { self.options.customWidth = 100; } // Set default width for input reset self.options.defaultWidth = el.width(); // Update width for input if ( self._color._alpha < 1 || self._color.toString().indexOf('rgb') != -1 ) el.width( parseInt( 88 ) ); // Push new controls $.each( controls, function( k, v ) { self.controls[k] = v; } ); // Change size strip and add margin for sliders self.controls.square.css( { 'margin-right': '0' } ); var emptyWidth = ( self.picker.width() - self.controls.square.width() - 20 ), stripsMargin = ( emptyWidth / 6 ), stripsWidth = ( ( emptyWidth / 2 ) - stripsMargin ); $.each( [ 'aContainer', 'strip' ], function( k, v ) { self.controls[v].width( stripsWidth ).css( { 'margin-left' : stripsMargin + 'px' } ); } ); // Add new slider self._initControls(); // For updated widget self._change(); } }, _initControls: function() { this._super(); if ( this.options.alpha ) { var self = this, controls = self.controls; controls.aSlider.slider({ orientation : 'vertical', min : 0, max : 100, step : 1, value : parseInt( self._color._alpha * 100 ), slide : function( event, ui ) { // Update alpha value self._color._alpha = parseFloat( ui.value / 100 ); self._change.apply( self, arguments ); } }); } }, _change: function() { this._super(); var self = this, el = self.element; if ( this.options.alpha ) { var controls = self.controls, alpha = parseInt( self._color._alpha * 100 ), color = self._color.toRgb(), gradient = [ 'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%', 'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%' ], defaultWidth = self.options.defaultWidth, customWidth = self.options.customWidth, target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' ); // Generate background slider alpha, only for CSS3 old browser fuck!! :) controls.aContainer.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + image + ')' } ); if ( target.hasClass( 'wp-picker-open' ) ) { // Update alpha value controls.aSlider.slider( 'value', alpha ); /** * Disabled change opacity in default slider Saturation ( only is alpha enabled ) * and change input width for view all value */ if ( self._color._alpha < 1 ) { controls.strip.attr( 'style', controls.strip.attr( 'style' ).replace( /rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g, 'rgb($1$3$5)' ) ); el.width( parseInt( 88 ) ); } else { el.width( defaultWidth ); } } } var reset = el.data( 'reset-alpha' ) || false; if ( reset ) { self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() { self._color._alpha = 1; self.active = 'external'; self._change(); } ); } el.trigger( 'change' ); }, _addInputListeners: function( input ) { var self = this, debounceTimeout = 100, callback = function( event ) { var color = new Color( input.val() ), val = input.val(); input.removeClass( 'iris-error' ); // we gave a bad color if ( color.error ) { // don't error on an empty input if ( val !== '' ) input.addClass( 'iris-error' ); } else { if ( color.toString() !== self._color.toString() ) { // let's not do this on keyup for hex shortcodes if ( ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) ) self._setOption( 'color', color.toString() ); } } }; input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) ); // If we initialized hidden, show on first focus. The rest is up to you. if ( self.options.hide ) { input.on( 'focus', function() { self.show(); } ); } } } ); }( jQuery ) ); // Auto Call plugin is class is color-picker jQuery( document ).ready( function( $ ) { $( '.color-picker' ).wpColorPicker(); } ); customizer-controls-toggle.js 0000666 00000005263 15214245400 0012435 0 ustar 00 /** * Customizer controls toggles * * @package Astra */ ( function( $ ) { /* Internal shorthand */ var api = wp.customize; /** * Trigger hooks */ ASTControlTrigger = { /** * Trigger a hook. * * @since 1.0.0 * @method triggerHook * @param {String} hook The hook to trigger. * @param {Array} args An array of args to pass to the hook. */ triggerHook: function( hook, args ) { $( 'body' ).trigger( 'astra-control-trigger.' + hook, args ); }, /** * Add a hook. * * @since 1.0.0 * @method addHook * @param {String} hook The hook to add. * @param {Function} callback A function to call when the hook is triggered. */ addHook: function( hook, callback ) { $( 'body' ).on( 'astra-control-trigger.' + hook, callback ); }, /** * Remove a hook. * * @since 1.0.0 * @method removeHook * @param {String} hook The hook to remove. * @param {Function} callback The callback function to remove. */ removeHook: function( hook, callback ) { $( 'body' ).off( 'astra-control-trigger.' + hook, callback ); }, }; /** * Helper class that contains data for showing and hiding controls. * * @since 1.0.0 * @class ASTCustomizerToggles */ ASTCustomizerToggles = { 'astra-settings[display-site-title]' : [], 'astra-settings[display-site-tagline]' : [], 'astra-settings[ast-header-retina-logo]' :[], 'custom_logo' : [], /** * Section - Header * * @link ?autofocus[section]=section-header */ /** * Layout 2 */ // Layout 2 > Right Section > Text / HTML // Layout 2 > Right Section > Search Type // Layout 2 > Right Section > Search Type > Search Box Type. 'astra-settings[header-main-rt-section]' : [], 'astra-settings[hide-custom-menu-mobile]' :[], /** * Blog */ 'astra-settings[blog-width]' :[], 'astra-settings[blog-post-structure]' :[], /** * Blog Single */ 'astra-settings[blog-single-post-structure]' : [], 'astra-settings[blog-single-width]' : [], 'astra-settings[blog-single-meta]' :[], /** * Small Footer */ 'astra-settings[footer-sml-layout]' : [], 'astra-settings[footer-sml-section-1]' :[], 'astra-settings[footer-sml-section-2]' :[], 'astra-settings[footer-sml-divider]' :[], 'astra-settings[header-main-sep]' :[], 'astra-settings[disable-primary-nav]' :[], /** * Footer Widgets */ 'astra-settings[footer-adv]' :[], 'astra-settings[shop-archive-width]' :[], 'astra-settings[mobile-header-logo]' :[], 'astra-settings[different-mobile-logo]' :[], }; } )( jQuery ); navigation.js 0000666 00000046747 15214245400 0007264 0 ustar 00 /** * File navigation.js * * Handles toggling the navigation menu for small screens and enables tab * support for dropdown menus. * * @package Astra */ /** * Get all of an element's parent elements up the DOM tree * * @param {Node} elem The element. * @param {String} selector Selector to match against [optional]. * @return {Array} The parent elements. */ var getParents = function ( elem, selector ) { // Element.matches() polyfill. if ( ! Element.prototype.matches) { Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function(s) { var matches = (this.document || this.ownerDocument).querySelectorAll( s ), i = matches.length; while (--i >= 0 && matches.item( i ) !== this) {} return i > -1; }; } // Setup parents array. var parents = []; // Get matching parent elements. for ( ; elem && elem !== document; elem = elem.parentNode ) { // Add matching parents to array. if ( selector ) { if ( elem.matches( selector ) ) { parents.push( elem ); } } else { parents.push( elem ); } } return parents; }; /** * Toggle Class funtion * * @param {Node} elem The element. * @param {String} selector Selector to match against [optional]. * @return {Array} The parent elements. */ var toggleClass = function ( el, className ) { if ( el.classList.contains( className ) ) { el.classList.remove( className ); } else { el.classList.add( className ); } }; // CustomEvent() constructor functionality in Internet Explorer 9 and higher. (function () { if (typeof window.CustomEvent === "function") return false; function CustomEvent(event, params) { params = params || { bubbles: false, cancelable: false, detail: undefined }; var evt = document.createEvent('CustomEvent'); evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); return evt; } CustomEvent.prototype = window.Event.prototype; window.CustomEvent = CustomEvent; })(); /** * Trigget custom JS Event. * * @since 1.4.6 * * @link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent * @param {Node} el Dom Node element on which the event is to be triggered. * @param {Node} typeArg A DOMString representing the name of the event. * @param {String} A CustomEventInit dictionary, having the following fields: * "detail", optional and defaulting to null, of type any, that is an event-dependent value associated with the event. */ var astraTriggerEvent = function astraTriggerEvent( el, typeArg ) { var customEventInit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; var event = new CustomEvent(typeArg, customEventInit); el.dispatchEvent(event); }; ( function() { var menu_toggle_all = document.querySelectorAll( '.main-header-menu-toggle' ); var menu_click_listeners = {}; /* Add break point Class and related trigger */ var updateHeaderBreakPoint = function () { // Content overrflowing out of screen can give incorrect window.innerWidth. // Adding overflow hidden and then calculating the window.innerWidth fixes the problem. var originalOverflow = document.querySelector('body').style.overflow; document.querySelector('body').style.overflow = 'hidden'; var ww = window.innerWidth; document.querySelector('body').style.overflow = originalOverflow; var break_point = astra.break_point, headerWrap = document.querySelectorAll('.main-header-bar-wrap'); if (headerWrap.length > 0) { for (var i = 0; i < headerWrap.length; i++) { if (headerWrap[i].tagName == 'DIV' && headerWrap[i].classList.contains('main-header-bar-wrap')) { if (ww > break_point) { //remove menu toggled class. if (null != menu_toggle_all[i]) { menu_toggle_all[i].classList.remove('toggled'); } document.body.classList.remove("ast-header-break-point"); document.body.classList.add("ast-desktop"); astraTriggerEvent(document.body, "astra-header-responsive-enabled"); } else { document.body.classList.add("ast-header-break-point"); document.body.classList.remove("ast-desktop"); astraTriggerEvent(document.body, "astra-header-responsive-disabled") } } } } } updateHeaderBreakPoint(); AstraToggleSubMenu = function() { var parent_li = this.parentNode; if (parent_li.classList.contains('ast-submenu-expanded') && document.querySelector("header.site-header").classList.contains("ast-menu-toggle-link")) { if (!this.classList.contains('ast-menu-toggle')) { var link = parent_li.querySelector('a').getAttribute('href'); if ('' !== link || '#' !== link) { window.location = link; } } } var parent_li_child = parent_li.querySelectorAll('.menu-item-has-children, .page_item_has_children'); for (var j = 0; j < parent_li_child.length; j++) { parent_li_child[j].classList.remove('ast-submenu-expanded'); var parent_li_child_sub_menu = parent_li_child[j].querySelector('.sub-menu, .children'); parent_li_child_sub_menu.style.display = 'none'; }; var parent_li_sibling = parent_li.parentNode.querySelectorAll('.menu-item-has-children, .page_item_has_children'); for (var j = 0; j < parent_li_sibling.length; j++) { if (parent_li_sibling[j] != parent_li) { parent_li_sibling[j].classList.remove('ast-submenu-expanded'); var all_sub_menu = parent_li_sibling[j].querySelectorAll('.sub-menu, .children'); for (var k = 0; k < all_sub_menu.length; k++) { all_sub_menu[k].style.display = 'none'; }; } }; if (parent_li.classList.contains('menu-item-has-children') || parent_li.classList.contains('page_item_has_children')) { toggleClass(parent_li, 'ast-submenu-expanded'); if (parent_li.classList.contains('ast-submenu-expanded')) { parent_li.querySelector('.sub-menu, .children').style.display = 'block'; } else { parent_li.querySelector('.sub-menu, .children').style.display = 'none'; } } }; AstraNavigationMenu = function( parentList ) { console.warn( 'AstraNavigationMenu() function has been deprecated since version 1.6.5 or above of Astra Theme and will be removed in the future.' ); }; AstraToggleMenu = function( astra_menu_toggle ) { console.warn('AstraToggleMenu() function has been deprecated since version 1.6.5 or above of Astra Theme and will be removed in the future. Use AstraToggleSubMenu() instead.'); // Add Eventlisteners for Submenu. if (astra_menu_toggle.length > 0) { for (var i = 0; i < astra_menu_toggle.length; i++) { astra_menu_toggle[i].addEventListener('click', AstraToggleSubMenu, false); }; } }; AstraToggleSetup = function () { var __main_header_all = document.querySelectorAll('.main-header-bar-navigation'); if (menu_toggle_all.length > 0) { for (var i = 0; i < menu_toggle_all.length; i++) { menu_toggle_all[i].setAttribute('data-index', i); if ( ! menu_click_listeners[i] ) { menu_click_listeners[i] = menu_toggle_all[i]; menu_toggle_all[i].addEventListener('click', astraNavMenuToggle, false); } if ('undefined' !== typeof __main_header_all[i]) { if (document.querySelector("header.site-header").classList.contains("ast-menu-toggle-link")) { var astra_menu_toggle = __main_header_all[i].querySelectorAll('.ast-header-break-point .main-header-menu .menu-item-has-children > a, .ast-header-break-point .main-header-menu .page_item_has_children > a, .ast-header-break-point ul.main-header-menu .ast-menu-toggle'); } else { var astra_menu_toggle = __main_header_all[i].querySelectorAll('ul.main-header-menu .ast-menu-toggle'); } // Add Eventlisteners for Submenu. if (astra_menu_toggle.length > 0) { for (var j = 0; j < astra_menu_toggle.length; j++) { astra_menu_toggle[j].addEventListener('click', AstraToggleSubMenu, false); }; } } }; } }; astraNavMenuToggle = function ( event ) { event.preventDefault(); var __main_header_all = document.querySelectorAll('.main-header-bar-navigation'); var event_index = this.getAttribute('data-index'); if ('undefined' === typeof __main_header_all[event_index]) { return false; } var menuHasChildren = __main_header_all[event_index].querySelectorAll('.menu-item-has-children, .page_item_has_children'); for (var i = 0; i < menuHasChildren.length; i++) { menuHasChildren[i].classList.remove('ast-submenu-expanded'); var menuHasChildrenSubMenu = menuHasChildren[i].querySelectorAll('.sub-menu, .children'); for (var j = 0; j < menuHasChildrenSubMenu.length; j++) { menuHasChildrenSubMenu[j].style.display = 'none'; }; } var menu_class = this.getAttribute('class') || ''; if ( menu_class.indexOf('main-header-menu-toggle') !== -1 ) { toggleClass(__main_header_all[event_index], 'toggle-on'); toggleClass(menu_toggle_all[event_index], 'toggled'); if (__main_header_all[event_index].classList.contains('toggle-on')) { __main_header_all[event_index].style.display = 'block'; document.body.classList.add("ast-main-header-nav-open"); } else { __main_header_all[event_index].style.display = ''; document.body.classList.remove("ast-main-header-nav-open"); } } }; document.body.addEventListener("astra-header-responsive-enabled", function () { var __main_header_all = document.querySelectorAll('.main-header-bar-navigation'); if (__main_header_all.length > 0) { for (var i = 0; i < __main_header_all.length; i++) { if (null != __main_header_all[i]) { __main_header_all[i].classList.remove('toggle-on'); __main_header_all[i].style.display = ''; } var sub_menu = __main_header_all[i].getElementsByClassName('sub-menu'); for (var j = 0; j < sub_menu.length; j++) { sub_menu[j].style.display = ''; } var child_menu = __main_header_all[i].getElementsByClassName('children'); for (var k = 0; k < child_menu.length; k++) { child_menu[k].style.display = ''; } var searchIcons = __main_header_all[i].getElementsByClassName('ast-search-menu-icon'); for (var l = 0; l < searchIcons.length; l++) { searchIcons[l].classList.remove('ast-dropdown-active'); searchIcons[l].style.display = ''; } } } }, false); window.addEventListener('resize', function () { // Skip resize event when keyboard display event triggers on devices. if( 'INPUT' !== document.activeElement.tagName ) { updateHeaderBreakPoint(); AstraToggleSetup(); } }); document.addEventListener('DOMContentLoaded', function () { AstraToggleSetup(); /** * Navigation Keyboard Navigation. */ var container, button, menu, links, subMenus, i, len, count; container = document.querySelectorAll( '.navigation-accessibility' ); for ( count = 0; count <= container.length - 1; count++ ) { if ( container[count] ) { navigation_accessibility( container[count] ); } } }); var get_browser = function () { var ua = navigator.userAgent,tem,M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if(/trident/i.test(M[1])) { tem = /\brv[ :]+(\d+)/g.exec(ua) || []; return; } if( 'Chrome' === M[1] ) { tem = ua.match(/\bOPR|Edge\/(\d+)/) if(tem != null) { return; } } M = M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; if((tem = ua.match(/version\/(\d+)/i)) != null) { M.splice(1,1,tem[1]); } bodyElement = document.body; if( 'Safari' === M[0] && M[1] < 11 ) { bodyElement.classList.add( "ast-safari-browser-less-than-11" ); } } get_browser(); /* Search Script */ var SearchIcons = document.getElementsByClassName( 'astra-search-icon' ); for (var i = 0; i < SearchIcons.length; i++) { SearchIcons[i].onclick = function(event) { if ( this.classList.contains( 'slide-search' ) ) { event.preventDefault(); var sibling = this.parentNode.parentNode.parentNode.querySelector( '.ast-search-menu-icon' ); if ( ! sibling.classList.contains( 'ast-dropdown-active' ) ) { sibling.classList.add( 'ast-dropdown-active' ); sibling.querySelector( '.search-field' ).setAttribute('autocomplete','off'); setTimeout(function() { sibling.querySelector( '.search-field' ).focus(); },200); } else { var searchTerm = sibling.querySelector( '.search-field' ).value || ''; if( '' !== searchTerm ) { sibling.querySelector( '.search-form' ).submit(); } sibling.classList.remove( 'ast-dropdown-active' ); } } } }; /* Hide Dropdown on body click*/ document.body.onclick = function( event ) { if ( typeof event.target.classList !== 'undefined' ) { if ( ! event.target.classList.contains( 'ast-search-menu-icon' ) && getParents( event.target, '.ast-search-menu-icon' ).length === 0 && getParents( event.target, '.ast-search-icon' ).length === 0 ) { var dropdownSearchWrap = document.getElementsByClassName( 'ast-search-menu-icon' ); for (var i = 0; i < dropdownSearchWrap.length; i++) { dropdownSearchWrap[i].classList.remove( 'ast-dropdown-active' ); }; } } } /** * Navigation Keyboard Navigation. */ function navigation_accessibility( container ) { if ( ! container ) { return; } button = container.getElementsByTagName( 'button' )[0]; if ( 'undefined' === typeof button ) { button = container.getElementsByTagName( 'a' )[0]; if ( 'undefined' === typeof button ) { return; } } menu = container.getElementsByTagName( 'ul' )[0]; // Hide menu toggle button if menu is empty and return early. if ( 'undefined' === typeof menu ) { button.style.display = 'none'; return; } menu.setAttribute( 'aria-expanded', 'false' ); if ( -1 === menu.className.indexOf( 'nav-menu' ) ) { menu.className += ' nav-menu'; } button.onclick = function() { if ( -1 !== container.className.indexOf( 'toggled' ) ) { container.className = container.className.replace( ' toggled', '' ); button.setAttribute( 'aria-expanded', 'false' ); menu.setAttribute( 'aria-expanded', 'false' ); } else { container.className += ' toggled'; button.setAttribute( 'aria-expanded', 'true' ); menu.setAttribute( 'aria-expanded', 'true' ); } }; // Get all the link elements within the menu. links = menu.getElementsByTagName( 'a' ); subMenus = menu.getElementsByTagName( 'ul' ); // Set menu items with submenus to aria-haspopup="true". for ( i = 0, len = subMenus.length; i < len; i++ ) { subMenus[i].parentNode.setAttribute( 'aria-haspopup', 'true' ); } // Each time a menu link is focused or blurred, toggle focus. for ( i = 0, len = links.length; i < len; i++ ) { links[i].addEventListener( 'focus', toggleFocus, true ); links[i].addEventListener( 'blur', toggleBlurFocus, true ); links[i].addEventListener( 'click', toggleClose, true ); } } /** * Close the Toggle Menu on Click on hash (#) link. * * @since 1.3.2 * @return void */ function toggleClose( ) { var self = this || '', hash = '#'; if( self && ! self.classList.contains('astra-search-icon') ) { var link = new String( self ); if( link.indexOf( hash ) !== -1 ) { var link_parent = self.parentNode; if ( document.body.classList.contains('ast-header-break-point') && ! ( document.querySelector("header.site-header").classList.contains("ast-menu-toggle-link") && link_parent.classList.contains("menu-item-has-children") ) ) { /* Close Main Header Menu */ var main_header_menu_toggle = document.querySelector( '.main-header-menu-toggle' ); main_header_menu_toggle.classList.remove( 'toggled' ); var main_header_bar_navigation = document.querySelector( '.main-header-bar-navigation' ); main_header_bar_navigation.classList.remove( 'toggle-on' ); main_header_bar_navigation.style.display = 'none'; /* Close Below Header Menu */ var before_header_menu_toggle = document.querySelector( '.menu-below-header-toggle' ); var before_header_bar_navigation = document.querySelector( '.ast-below-header' ); var before_header_bar = document.querySelector( '.ast-below-header-actual-nav' ); if ( before_header_menu_toggle && before_header_bar_navigation && before_header_bar ) { before_header_menu_toggle.classList.remove( 'toggled' ); before_header_bar_navigation.classList.remove( 'toggle-on' ); before_header_bar.style.display = 'none'; } /* Close After Header Menu */ var after_header_menu_toggle = document.querySelector( '.menu-above-header-toggle' ); var after_header_bar_navigation = document.querySelector( '.ast-above-header' ); var after_header_bar = document.querySelector( '.ast-above-header-navigation' ); if ( after_header_menu_toggle && after_header_bar_navigation && after_header_bar ) { after_header_menu_toggle.classList.remove( 'toggled' ); after_header_bar_navigation.classList.remove( 'toggle-on' ); after_header_bar.style.display = 'none'; } astraTriggerEvent( document.querySelector('body'), 'astraMenuHashLinkClicked' ); } else { while ( -1 === self.className.indexOf( 'nav-menu' ) ) { // On li elements toggle the class .focus. if ( 'li' === self.tagName.toLowerCase() ) { if ( -1 !== self.className.indexOf( 'focus' ) ) { self.className = self.className.replace( ' focus', '' ); } } self = self.parentElement; } } } } } /** * Sets or removes .focus class on an element on focus. */ function toggleFocus() { var self = this; // Move up through the ancestors of the current link until we hit .nav-menu. while ( -1 === self.className.indexOf( 'nav-menu' ) ) { // On li elements toggle the class .focus. if ( 'li' === self.tagName.toLowerCase() ) { if ( -1 !== self.className.indexOf( 'focus' ) ) { self.className = self.className.replace( ' focus', '' ); } else { self.className += ' focus'; } } self = self.parentElement; } } /** * Sets or removes .focus class on an element on blur. */ function toggleBlurFocus() { var self = this || '', hash = '#'; link = new String( self ); if( link.indexOf( hash ) !== -1 && document.body.classList.contains('ast-mouse-clicked') ) { return; } // Move up through the ancestors of the current link until we hit .nav-menu. while ( -1 === self.className.indexOf( 'nav-menu' ) ) { // On li elements toggle the class .focus. if ( 'li' === self.tagName.toLowerCase() ) { if ( -1 !== self.className.indexOf( 'focus' ) ) { self.className = self.className.replace( ' focus', '' ); } else { self.className += ' focus'; } } self = self.parentElement; } } /* Add class if mouse clicked and remove if tab pressed */ if ( 'querySelector' in document && 'addEventListener' in window ) { var body = document.body; body.addEventListener( 'mousedown', function() { body.classList.add( 'ast-mouse-clicked' ); } ); body.addEventListener( 'keydown', function() { body.classList.remove( 'ast-mouse-clicked' ); } ); } } )(); customizer-preview.js 0000666 00000161054 15214245400 0010775 0 ustar 00 /** * This file adds some LIVE to the Theme Customizer live preview. To leverage * this, set your custom settings to 'postMessage' and then add your handling * here. Your javascript should grab settings from customizer controls, and * then make any necessary changes to the page using jQuery. * * @package Astra */ /** * Generate font size in PX & REM */ function astra_font_size_rem( size, with_rem, device ) { var css = ''; if( size != '' ) { var device = ( typeof device != undefined ) ? device : 'desktop'; // font size with 'px'. css = 'font-size: ' + size + 'px;'; // font size with 'rem'. if ( with_rem ) { var body_font_size = wp.customize( 'astra-settings[font-size-body]' ).get(); body_font_size['desktop'] = ( body_font_size['desktop'] != '' ) ? body_font_size['desktop'] : 15; body_font_size['tablet'] = ( body_font_size['tablet'] != '' ) ? body_font_size['tablet'] : body_font_size['desktop']; body_font_size['mobile'] = ( body_font_size['mobile'] != '' ) ? body_font_size['mobile'] : body_font_size['tablet']; css += 'font-size: ' + ( size / body_font_size[device] ) + 'rem;'; } } return css; } /** * Apply CSS for the element */ function astra_color_responsive_css( addon, control, css_property, selector ) { wp.customize( control, function( value ) { value.bind( function( value ) { if ( value.desktop || value.mobile || value.tablet ) { // Remove ' ); } else { wp.customize.preview.send( 'refresh' ); jQuery( 'style#' + control + '-' + addon ).remove(); } } ); } ); } /** * Responsive Font Size CSS */ function astra_responsive_font_size( control, selector ) { wp.customize( control, function( value ) { value.bind( function( value ) { if ( value.desktop || value.mobile || value.tablet ) { // Remove ' ); } else { jQuery( 'style#' + control ).remove(); } } ); } ); } /** * Responsive Spacing CSS */ function astra_responsive_spacing( control, selector, type, side ) { wp.customize( control, function( value ) { value.bind( function( value ) { var sidesString = ""; var spacingType = "padding"; if ( value.desktop.top || value.desktop.right || value.desktop.bottom || value.desktop.left || value.tablet.top || value.tablet.right || value.tablet.bottom || value.tablet.left || value.mobile.top || value.mobile.right || value.mobile.bottom || value.mobile.left ) { if ( typeof side != undefined ) { sidesString = side + ""; sidesString = sidesString.replace(/,/g , "-"); } if ( typeof type != undefined ) { spacingType = type + ""; } // Remove ' ); } else { wp.customize.preview.send( 'refresh' ); jQuery( 'style#' + control + '-' + spacingType + '-' + sidesString ).remove(); } } ); } ); } /** * CSS */ function astra_css_font_size( control, selector ) { wp.customize( control, function( value ) { value.bind( function( size ) { if ( size ) { // Remove ' ); } else { jQuery( 'style#' + control ).remove(); } } ); } ); } /** * Return get_hexdec() */ function get_hexdec( hex ) { var hexString = hex.toString( 16 ); return parseInt( hexString, 16 ); } /** * Apply CSS for the element */ function astra_css( control, css_property, selector, unit ) { wp.customize( control, function( value ) { value.bind( function( new_value ) { // Remove ' ); } else { // Remove old. jQuery( 'style#' + control ).remove(); } } ); } ); } /** * Dynamic Internal/Embedded Style for a Control */ function astra_add_dynamic_css( control, style ) { control = control.replace( '[', '-' ); control = control.replace( ']', '' ); jQuery( 'style#' + control ).remove(); jQuery( 'head' ).append( '' ); } /** * Generate background_obj CSS */ function astra_background_obj_css( wp_customize, bg_obj, ctrl_name, style ) { var gen_bg_css = ''; var bg_img = bg_obj['background-image']; var bg_color = bg_obj['background-color']; if( '' === bg_color && '' === bg_img ) { wp_customize.preview.send( 'refresh' ); }else{ if ( '' !== bg_img && '' !== bg_color) { if ( undefined !== bg_color ) { gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_img + ');'; } }else if ( '' !== bg_img ) { gen_bg_css = 'background-image: url(' + bg_img + ');'; }else if ( '' !== bg_color ) { gen_bg_css = 'background-color: ' + bg_color + ';'; gen_bg_css += 'background-image: none;'; } if ( '' !== bg_img ) { gen_bg_css += 'background-repeat: ' + bg_obj['background-repeat'] + ';'; gen_bg_css += 'background-position: ' + bg_obj['background-position'] + ';'; gen_bg_css += 'background-size: ' + bg_obj['background-size'] + ';'; gen_bg_css += 'background-attachment: ' + bg_obj['background-attachment'] + ';'; } var dynamicStyle = style.replace( "{{css}}", gen_bg_css ); astra_add_dynamic_css( ctrl_name, dynamicStyle ); } } /** * Apply CSS for the element */ function astra_apply_background_css(group, subControl, selector ) { wp.customize(group, function (control) { control.bind(function (value, oldValue) { var parse_bg_obj = JSON.parse(value); bg_obj = parse_bg_obj[subControl]; if ( '' === bg_obj || undefined === bg_obj ) { return; } jQuery( 'style#' + subControl ).remove(); var gen_bg_css = ''; var bg_img = bg_obj['background-image']; var bg_color = bg_obj['background-color']; if ('' !== bg_img && '' !== bg_color) { if (undefined !== bg_color) { gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_img + ');'; } } else if ('' !== bg_img) { gen_bg_css = 'background-image: url(' + bg_img + ');'; } else if ('' !== bg_color) { gen_bg_css = 'background-color: ' + bg_color + ';'; } if ('' == bg_img) { gen_bg_css += 'background-image: none;'; } else { gen_bg_css += 'background-repeat: ' + bg_obj['background-repeat'] + ';'; gen_bg_css += 'background-position: ' + bg_obj['background-position'] + ';'; gen_bg_css += 'background-size: ' + bg_obj['background-size'] + ';'; gen_bg_css += 'background-attachment: ' + bg_obj['background-attachment'] + ';'; } var dynamicStyle = '' // Concat and append new ' + link ); }); }); } /* * Generate Font Weight CSS */ function astra_generate_font_weight_css( font_control, control, css_property, selector ) { wp.customize( control, function( value ) { value.bind( function( new_value ) { control = control.replace( '[', '-' ); control = control.replace( ']', '' ); if ( new_value ) { /** * If ( unit == 'url' ) then = url('{VALUE}') * If ( unit == 'px' ) then = {VALUE}px * If ( unit == 'em' ) then = {VALUE}em * If ( unit == 'rem' ) then = {VALUE}rem. */ if ( 'undefined' != typeof unit) { if ( 'url' === unit ) { new_value = 'url(' + new_value + ')'; } else { new_value = new_value + unit; } } fontName = wp.customize._value[font_control]._value; fontName = fontName.split(','); fontName = fontName[0].replace( /'/g, '' ); // Remove old. jQuery( 'style#' + control + '-' + css_property ).remove(); if ( fontName in astraCustomizer.googleFonts ) { // Remove old. jQuery('#' + font_control).remove(); link = ''; } // Concat and append new ' + link ); } else { // Remove old. jQuery( 'style#' + control ).remove(); } } ); }); } /** * Apply CSS for the element */ function astra_apply_responsive_background_css( control, selector, device, singleColorSelector, addon ) { wp.customize( control, function( value ) { value.bind( function( bg_obj ) { addon = addon || ''; singleColorSelector = singleColorSelector || ''; addon = ( addon ) ? addon : 'header'; control = control.replace( '[', '-' ); control = control.replace( ']', '' ); if( '' === bg_obj[device] || undefined === bg_obj[device] ){ return; } var gen_bg_css = ''; var bg_img = bg_obj[device]['background-image']; var bg_tab_img = bg_obj['tablet']['background-image']; var bg_desk_img = bg_obj['desktop']['background-image']; var bg_color = bg_obj[device]['background-color']; var tablet_css = ( bg_obj['tablet']['background-image'] ) ? true : false; var desktop_css = ( bg_obj['desktop']['background-image'] ) ? true : false; if ( '' !== bg_img && '' !== bg_color && undefined !== bg_color ) { gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_img + ');'; } else if ( '' !== bg_img ) { gen_bg_css = 'background-image: url(' + bg_img + ');'; } else if ( '' !== bg_color ) { if( 'mobile' === device ) { if( true == desktop_css && true == tablet_css ) { gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_tab_img + ');'; } else if( true == desktop_css ) { gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_desk_img + ');'; } else if( true == tablet_css ) { gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_tab_img + ');'; } else { gen_bg_css = 'background-color: ' + bg_color + ';'; gen_bg_css += 'background-image: none;'; } } else if( 'tablet' === device ) { if( true == desktop_css ) { gen_bg_css = 'background-image: linear-gradient(to right, ' + bg_color + ', ' + bg_color + '), url(' + bg_desk_img + ');'; } else { gen_bg_css = 'background-color: ' + bg_color + ';'; gen_bg_css += 'background-image: none;'; } } else { gen_bg_css = 'background-color: ' + bg_color + ';'; gen_bg_css += 'background-image: none;'; } if( ! selector.includes( singleColorSelector ) ) { selector += ', ' + singleColorSelector; } } if ( '' != bg_img ) { gen_bg_css += 'background-repeat: ' + bg_obj[device]['background-repeat'] + ';'; gen_bg_css += 'background-position: ' + bg_obj[device]['background-position'] + ';'; gen_bg_css += 'background-size: ' + bg_obj[device]['background-size'] + ';'; gen_bg_css += 'background-attachment: ' + bg_obj[device]['background-attachment'] + ';'; } // Remove old. jQuery( 'style#' + control + '-' + device + '-' + addon ).remove(); if ( 'desktop' == device ) { var dynamicStyle = '' } if ( 'tablet' == device ) { var dynamicStyle = '' } if ( 'mobile' == device ) { var dynamicStyle = '' } // Concat and append new