diff options
author | Zach van Rijn <me@zv.io> | 2021-07-21 14:54:07 -0500 |
---|---|---|
committer | Zach van Rijn <me@zv.io> | 2021-07-21 14:54:07 -0500 |
commit | 9d4123cee1867ee7199b06bdc92d40611f547ecc (patch) | |
tree | 6d864e2725242863afed1f8ba12d9c7a9bc63a69 /inc/builder/type/header/search | |
download | blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.gz blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.bz2 blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.tar.xz blog-ng-9d4123cee1867ee7199b06bdc92d40611f547ecc.zip |
Initial unmodified import from Astra (Version: 3.6.5) @ /wp-content/themes/astra/.
Diffstat (limited to 'inc/builder/type/header/search')
5 files changed, 502 insertions, 0 deletions
diff --git a/inc/builder/type/header/search/assets/js/minified/customizer-preview.min.js b/inc/builder/type/header/search/assets/js/minified/customizer-preview.min.js new file mode 100644 index 0000000..d8a532b --- /dev/null +++ b/inc/builder/type/header/search/assets/js/minified/customizer-preview.min.js @@ -0,0 +1 @@ +!function(){var i=astraBuilderPreview.tablet_break_point||768,o=astraBuilderPreview.mobile_break_point||544,a=".ast-header-search";astra_color_responsive_css("header-search-icon-color","astra-settings[header-search-icon-color]","color",a+" .astra-search-icon, "+a+" .search-field::placeholder"),astra_css("astra-settings[header-search-icon-space]","font-size",a+" .astra-search-icon","px"),wp.customize("astra-settings[header-search-icon-space]",function(t){t.bind(function(t){var e;""==t.desktop&&""==t.tablet&&""==t.mobile||(e="",e+=a+" .astra-search-icon {",e+="font-size: "+t.desktop+"px;",e+="} ",e+="@media (max-width: "+i+"px) {",e+=a+" .astra-search-icon {",e+="font-size: "+t.tablet+"px;",e+="} ",e+="} ",e+="@media (max-width: "+o+"px) {",e+=a+" .astra-search-icon {",e+="font-size: "+t.mobile+"px;",e+="} ",e+="} ",astra_add_dynamic_css("header-search-icon-space",e))})}),wp.customize("astra-settings[section-header-search-margin]",function(t){t.bind(function(t){var e,a;""==t.desktop.bottom&&""==t.desktop.top&&""==t.desktop.left&&""==t.desktop.right&&""==t.tablet.bottom&&""==t.tablet.top&&""==t.tablet.left&&""==t.tablet.right&&""==t.mobile.bottom&&""==t.mobile.top&&""==t.mobile.left&&""==t.mobile.right||(a="",a+=(e=".ast-hfb-header .site-header-section > .ast-header-search, .ast-hfb-header .ast-header-search")+" {",a+="margin-left: "+t.desktop.left+t["desktop-unit"]+";",a+="margin-right: "+t.desktop.right+t["desktop-unit"]+";",a+="margin-top: "+t.desktop.top+t["desktop-unit"]+";",a+="margin-bottom: "+t.desktop.bottom+t["desktop-unit"]+";",a+="} ",a+="@media (max-width: "+i+"px) {",a+=e+" {",a+="margin-left: "+t.tablet.left+t["tablet-unit"]+";",a+="margin-right: "+t.tablet.right+t["tablet-unit"]+";",a+="margin-top: "+t.tablet.top+t["desktop-unit"]+";",a+="margin-bottom: "+t.tablet.bottom+t["desktop-unit"]+";",a+="} ",a+="} ",a+="@media (max-width: "+o+"px) {",a+=e+" {",a+="margin-left: "+t.mobile.left+t["mobile-unit"]+";",a+="margin-right: "+t.mobile.right+t["mobile-unit"]+";",a+="margin-top: "+t.mobile.top+t["desktop-unit"]+";",a+="margin-bottom: "+t.mobile.bottom+t["desktop-unit"]+";",a+="} ",a+="} ",astra_add_dynamic_css("header-search-margin",a))})}),astra_builder_visibility_css("section-header-search",a)}(jQuery);
\ No newline at end of file diff --git a/inc/builder/type/header/search/assets/js/unminified/customizer-preview.js b/inc/builder/type/header/search/assets/js/unminified/customizer-preview.js new file mode 100644 index 0000000..56d4dea --- /dev/null +++ b/inc/builder/type/header/search/assets/js/unminified/customizer-preview.js @@ -0,0 +1,102 @@ +/**
+ * This file adds some LIVE to the 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
+ * @since 3.0.0
+ */
+
+( function( $ ) {
+
+ var tablet_break_point = astraBuilderPreview.tablet_break_point || 768,
+ mobile_break_point = astraBuilderPreview.mobile_break_point || 544;
+
+ var selector = '.ast-header-search';
+ var section = 'section-header-search';
+
+ // Icon Color.
+ astra_color_responsive_css(
+ 'header-search-icon-color',
+ 'astra-settings[header-search-icon-color]',
+ 'color',
+ selector + ' .astra-search-icon, ' + selector + ' .search-field::placeholder'
+ );
+
+ // Icon Size.
+ astra_css(
+ 'astra-settings[header-search-icon-space]',
+ 'font-size',
+ selector + ' .astra-search-icon',
+ 'px'
+ );
+
+ // Icon Size.
+ wp.customize( 'astra-settings[header-search-icon-space]', function( value ) {
+ value.bind( function( size ) {
+ if( size.desktop != '' || size.tablet != '' || size.mobile != '' ) {
+ var dynamicStyle = '';
+ dynamicStyle += selector + ' .astra-search-icon {';
+ dynamicStyle += 'font-size: ' + size.desktop + 'px' + ';';
+ dynamicStyle += '} ';
+
+ dynamicStyle += '@media (max-width: ' + tablet_break_point + 'px) {';
+ dynamicStyle += selector + ' .astra-search-icon {';
+ dynamicStyle += 'font-size: ' + size.tablet + 'px' + ';';
+ dynamicStyle += '} ';
+ dynamicStyle += '} ';
+
+ dynamicStyle += '@media (max-width: ' + mobile_break_point + 'px) {';
+ dynamicStyle += selector + ' .astra-search-icon {';
+ dynamicStyle += 'font-size: ' + size.mobile + 'px' + ';';
+ dynamicStyle += '} ';
+ dynamicStyle += '} ';
+ astra_add_dynamic_css( 'header-search-icon-space', dynamicStyle );
+ }
+ } );
+ } );
+
+ // Margin.
+ wp.customize( 'astra-settings[section-header-search-margin]', function( value ) {
+ value.bind( function( margin ) {
+ if(
+ margin.desktop.bottom != '' || margin.desktop.top != '' || margin.desktop.left != '' || margin.desktop.right != '' ||
+ margin.tablet.bottom != '' || margin.tablet.top != '' || margin.tablet.left != '' || margin.tablet.right != '' ||
+ margin.mobile.bottom != '' || margin.mobile.top != '' || margin.mobile.left != '' || margin.mobile.right != ''
+ ) {
+ var selector = '.ast-hfb-header .site-header-section > .ast-header-search, .ast-hfb-header .ast-header-search';
+ var dynamicStyle = '';
+ dynamicStyle += selector + ' {';
+ dynamicStyle += 'margin-left: ' + margin['desktop']['left'] + margin['desktop-unit'] + ';';
+ dynamicStyle += 'margin-right: ' + margin['desktop']['right'] + margin['desktop-unit'] + ';';
+ dynamicStyle += 'margin-top: ' + margin['desktop']['top'] + margin['desktop-unit'] + ';';
+ dynamicStyle += 'margin-bottom: ' + margin['desktop']['bottom'] + margin['desktop-unit'] + ';';
+ dynamicStyle += '} ';
+
+ dynamicStyle += '@media (max-width: ' + tablet_break_point + 'px) {';
+ dynamicStyle += selector + ' {';
+ dynamicStyle += 'margin-left: ' + margin['tablet']['left'] + margin['tablet-unit'] + ';';
+ dynamicStyle += 'margin-right: ' + margin['tablet']['right'] + margin['tablet-unit'] + ';';
+ dynamicStyle += 'margin-top: ' + margin['tablet']['top'] + margin['desktop-unit'] + ';';
+ dynamicStyle += 'margin-bottom: ' + margin['tablet']['bottom'] + margin['desktop-unit'] + ';';
+ dynamicStyle += '} ';
+ dynamicStyle += '} ';
+
+ dynamicStyle += '@media (max-width: ' + mobile_break_point + 'px) {';
+ dynamicStyle += selector + ' {';
+ dynamicStyle += 'margin-left: ' + margin['mobile']['left'] + margin['mobile-unit'] + ';';
+ dynamicStyle += 'margin-right: ' + margin['mobile']['right'] + margin['mobile-unit'] + ';';
+ dynamicStyle += 'margin-top: ' + margin['mobile']['top'] + margin['desktop-unit'] + ';';
+ dynamicStyle += 'margin-bottom: ' + margin['mobile']['bottom'] + margin['desktop-unit'] + ';';
+ dynamicStyle += '} ';
+ dynamicStyle += '} ';
+ astra_add_dynamic_css( 'header-search-margin', dynamicStyle );
+ }
+ } );
+ } );
+
+ // Advanced Visibility CSS Generation.
+ astra_builder_visibility_css( section, selector );
+
+} )( jQuery );
diff --git a/inc/builder/type/header/search/class-astra-header-search-component-loader.php b/inc/builder/type/header/search/class-astra-header-search-component-loader.php new file mode 100644 index 0000000..b4d1f01 --- /dev/null +++ b/inc/builder/type/header/search/class-astra-header-search-component-loader.php @@ -0,0 +1,73 @@ +<?php +/** + * Search Styling Loader for Astra theme. + * + * @package astra-builder + * @author Astra + * @copyright Copyright (c) 2020, Astra + * @link https://wpastra.com/ + * @since 3.0.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly. +} + +/** + * Customizer Initialization + * + * @since 3.0.0 + */ +class Astra_Header_Search_Component_Loader { + + /** + * Constructor + * + * @since 3.0.0 + */ + public function __construct() { + + add_filter( 'astra_get_search', array( $this, 'get_search_markup' ), 10, 3 ); + add_action( 'customize_preview_init', array( $this, 'preview_scripts' ), 110 ); + } + + /** + * Customizer Preview + * + * @since 3.0.0 + */ + public function preview_scripts() { + /** + * Load unminified if SCRIPT_DEBUG is true. + */ + /* Directory and Extension */ + $dir_name = ( SCRIPT_DEBUG ) ? 'unminified' : 'minified'; + $file_prefix = ( SCRIPT_DEBUG ) ? '' : '.min'; + wp_enqueue_script( 'astra-header-builder-search-customizer-preview-js', ASTRA_HEADER_SEARCH_URI . '/assets/js/' . $dir_name . '/customizer-preview' . $file_prefix . '.js', array( 'customize-preview', 'astra-customizer-preview-js' ), ASTRA_THEME_VERSION, true ); + + } + + /** + * Adding Wrapper for Search Form. + * + * @since 3.0.0 + * + * @param string $search_markup Search Form Content. + * @param string $option Search Form Options. + * @param string $device Device Desktop/Tablet/Mobile. + * @return Search HTML structure created. + */ + public static function get_search_markup( $search_markup, $option = '', $device = '' ) { + + if ( is_customize_preview() ) { + Astra_Builder_UI_Controller::render_customizer_edit_button(); + } + + return $search_markup; + } +} + +/** +* Kicking this off by creating the object of the class. +*/ +new Astra_Header_Search_Component_Loader(); diff --git a/inc/builder/type/header/search/class-astra-header-search-component.php b/inc/builder/type/header/search/class-astra-header-search-component.php new file mode 100644 index 0000000..764daf8 --- /dev/null +++ b/inc/builder/type/header/search/class-astra-header-search-component.php @@ -0,0 +1,45 @@ +<?php +/** + * Search for Astra theme. + * + * @package astra-builder + * @author Astra + * @copyright Copyright (c) 2020, Astra + * @link https://wpastra.com/ + * @since 3.0.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly. +} + +define( 'ASTRA_HEADER_SEARCH_DIR', ASTRA_THEME_DIR . 'inc/builder/type/header/search' ); +define( 'ASTRA_HEADER_SEARCH_URI', ASTRA_THEME_URI . 'inc/builder/type/header/search' ); + +/** + * Heading Initial Setup + * + * @since 3.0.0 + */ +class Astra_Header_Search_Component { + + /** + * Constructor function that initializes required actions and hooks + */ + public function __construct() { + + // @codingStandardsIgnoreStart WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound + require_once ASTRA_HEADER_SEARCH_DIR . '/class-astra-header-search-component-loader.php'; + + // Include front end files. + if ( ! is_admin() ) { + require_once ASTRA_HEADER_SEARCH_DIR . '/dynamic-css/dynamic.css.php'; + } + // @codingStandardsIgnoreEnd WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound + } +} + +/** + * Kicking this off by creating an object. + */ +new Astra_Header_Search_Component(); diff --git a/inc/builder/type/header/search/dynamic-css/dynamic.css.php b/inc/builder/type/header/search/dynamic-css/dynamic.css.php new file mode 100644 index 0000000..9dea5fc --- /dev/null +++ b/inc/builder/type/header/search/dynamic-css/dynamic.css.php @@ -0,0 +1,281 @@ +<?php +/** + * Search - Dynamic CSS + * + * @package Astra + * @since 3.0.0 + */ + +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly. +} + +/** + * Search + */ +add_filter( 'astra_dynamic_theme_css', 'astra_hb_search_dynamic_css' ); + +/** + * Dynamic CSS + * + * @param string $dynamic_css Astra Dynamic CSS. + * @param string $dynamic_css_filtered Astra Dynamic CSS Filters. + * @return String Generated dynamic CSS for Search. + * + * @since 3.0.0 + */ +function astra_hb_search_dynamic_css( $dynamic_css, $dynamic_css_filtered = '' ) { + + if ( ! Astra_Builder_Helper::is_component_loaded( 'search', 'header' ) ) { + return $dynamic_css; + } + + $_section = 'section-header-search'; + $selector = '.ast-header-search'; + $icon_size = astra_get_option( 'header-search-icon-space' ); + + $icon_size_desktop = ( isset( $icon_size ) && isset( $icon_size['desktop'] ) && ! empty( $icon_size['desktop'] ) ) ? $icon_size['desktop'] : 20; + + $icon_size_tablet = ( isset( $icon_size ) && isset( $icon_size['tablet'] ) && ! empty( $icon_size['tablet'] ) ) ? $icon_size['tablet'] : 20; + + $icon_size_mobile = ( isset( $icon_size ) && isset( $icon_size['mobile'] ) && ! empty( $icon_size['mobile'] ) ) ? $icon_size['mobile'] : 20; + + $icon_color_desktop = astra_get_prop( astra_get_option( 'header-search-icon-color' ), 'desktop' ); + $icon_color_tablet = astra_get_prop( astra_get_option( 'header-search-icon-color' ), 'tablet' ); + $icon_color_mobile = astra_get_prop( astra_get_option( 'header-search-icon-color' ), 'mobile' ); + + $margin = astra_get_option( $_section . '-margin' ); + $margin_selector = '.ast-hfb-header .site-header-section > .ast-header-search, .ast-hfb-header .ast-header-search'; + + /** + * Search CSS. + */ + $css_output_desktop = array( + $selector . ' .ast-search-menu-icon .search-form .search-field:-ms-input-placeholder,' . $selector . ' .ast-search-menu-icon .search-form .search-field:-ms-input-placeholder' => array( + 'opacity' => '0.5', + ), + $selector . ' .ast-search-menu-icon.slide-search .search-form, .ast-header-search .ast-search-menu-icon.ast-inline-search .search-form' => array( + '-js-display' => 'flex', + 'display' => 'flex', + 'align-items' => 'center', + ), + '.ast-builder-layout-element.ast-header-search' => array( + 'height' => 'auto', + ), + $selector . ' .astra-search-icon' => array( + 'color' => esc_attr( $icon_color_desktop ), + 'font-size' => astra_get_css_value( $icon_size_desktop, 'px' ), + ), + $selector . ' .search-field::placeholder' => array( + 'color' => esc_attr( $icon_color_desktop ), + ), + $selector . ' .ast-search-menu-icon.ast-dropdown-active .search-field' => array( + 'margin-right' => astra_get_css_value( $icon_size_desktop - 10, 'px' ), + ), + $margin_selector => array( + // Margin CSS. + 'margin-top' => astra_responsive_spacing( $margin, 'top', 'desktop' ), + 'margin-bottom' => astra_responsive_spacing( $margin, 'bottom', 'desktop' ), + 'margin-left' => astra_responsive_spacing( $margin, 'left', 'desktop' ), + 'margin-right' => astra_responsive_spacing( $margin, 'right', 'desktop' ), + ), + ); + + $css_output_tablet = array( + + $selector . ' .astra-search-icon' => array( + 'color' => esc_attr( $icon_color_tablet ), + 'font-size' => astra_get_css_value( $icon_size_tablet, 'px' ), + ), + $selector . ' .search-field::placeholder' => array( + 'color' => esc_attr( $icon_color_tablet ), + ), + $selector . ' .ast-search-menu-icon.ast-dropdown-active .search-field' => array( + 'margin-right' => astra_get_css_value( $icon_size_tablet - 10, 'px' ), + ), + $margin_selector => array( + // Margin CSS. + 'margin-top' => astra_responsive_spacing( $margin, 'top', 'tablet' ), + 'margin-bottom' => astra_responsive_spacing( $margin, 'bottom', 'tablet' ), + 'margin-left' => astra_responsive_spacing( $margin, 'left', 'tablet' ), + 'margin-right' => astra_responsive_spacing( $margin, 'right', 'tablet' ), + ), + ); + + $css_output_mobile = array( + + $selector . ' .astra-search-icon' => array( + 'color' => esc_attr( $icon_color_mobile ), + 'font-size' => astra_get_css_value( $icon_size_mobile, 'px' ), + ), + $selector . ' .search-field::placeholder' => array( + 'color' => esc_attr( $icon_color_mobile ), + ), + $selector . ' .ast-search-menu-icon.ast-dropdown-active .search-field' => array( + 'margin-right' => astra_get_css_value( $icon_size_mobile - 10, 'px' ), + ), + $margin_selector => array( + // Margin CSS. + 'margin-top' => astra_responsive_spacing( $margin, 'top', 'mobile' ), + 'margin-bottom' => astra_responsive_spacing( $margin, 'bottom', 'mobile' ), + 'margin-left' => astra_responsive_spacing( $margin, 'left', 'mobile' ), + 'margin-right' => astra_responsive_spacing( $margin, 'right', 'mobile' ), + ), + ); + + /* Parse CSS from array() */ + $css_output = astra_search_static_css(); + $css_output .= astra_parse_css( $css_output_desktop ); + $css_output .= astra_parse_css( $css_output_tablet, '', astra_get_tablet_breakpoint() ); + $css_output .= astra_parse_css( $css_output_mobile, '', astra_get_mobile_breakpoint() ); + + $dynamic_css .= $css_output; + + $dynamic_css .= Astra_Builder_Base_Dynamic_CSS::prepare_visibility_css( $_section, $selector ); + + return $dynamic_css; +} + +/** + * Search Component static CSS. + * + * @return string + * @since 3.5.0 + */ +function astra_search_static_css() { + $search_css = ' + + .main-header-bar .main-header-bar-navigation .ast-search-icon { + display: block; + z-index: 4; + position: relative; + } + + .ast-search-icon { + z-index: 4; + position: relative; + line-height: normal; + } + .main-header-bar .ast-search-menu-icon .search-form { + background-color: #ffffff; + } + .ast-search-menu-icon.ast-dropdown-active.slide-search .search-form { + visibility: visible; + opacity: 1; + } + .ast-search-menu-icon .search-form { + border: 1px solid #e7e7e7; + line-height: normal; + padding: 0 3em 0 0; + border-radius: 2px; + display: inline-block; + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + position: relative; + color: inherit; + background-color: #fff; + } + .ast-search-menu-icon .astra-search-icon { + -js-display: flex; + display: flex; + line-height: normal; + } + .ast-search-menu-icon .astra-search-icon:focus { + outline: none; + } + .ast-search-menu-icon .search-field { + border: none; + background-color: transparent; + transition: width .2s; + border-radius: inherit; + color: inherit; + font-size: inherit; + width: 0; + color: #757575; + } + .ast-search-menu-icon .search-submit { + display: none; + background: none; + border: none; + font-size: 1.3em; + color: #757575; + } + .ast-search-menu-icon.ast-dropdown-active { + visibility: visible; + opacity: 1; + position: relative; + } + + .ast-search-menu-icon.ast-dropdown-active .search-field { + width: 235px; + } + .ast-header-search .ast-search-menu-icon.slide-search .search-form, .ast-header-search .ast-search-menu-icon.ast-inline-search .search-form { + -js-display: flex; + display: flex; + align-items: center; + }'; + + if ( is_rtl() ) { + $search_css .= ' + .ast-search-menu-icon.ast-inline-search .search-field { + width : 100%; + padding : 0.60em; + padding-left : 5.5em; + } + .site-header-section-left .ast-search-menu-icon.slide-search .search-form { + padding-right: 3em; + padding-left: unset; + right: -1em; + left: unset; + } + + .site-header-section-left .ast-search-menu-icon.slide-search .search-form .search-field { + margin-left: unset; + margin-right: 10px; + } + .ast-search-menu-icon.slide-search .search-form { + -webkit-backface-visibility: visible; + backface-visibility: visible; + visibility: hidden; + opacity: 0; + transition: all .2s; + position: absolute; + z-index: 3; + left: -1em; + top: 50%; + transform: translateY(-50%); + }'; + } else { + $search_css .= ' + .ast-search-menu-icon.ast-inline-search .search-field { + width : 100%; + padding : 0.60em; + padding-right : 5.5em; + } + .site-header-section-left .ast-search-menu-icon.slide-search .search-form { + padding-left: 3em; + padding-right: unset; + left: -1em; + right: unset; + } + + .site-header-section-left .ast-search-menu-icon.slide-search .search-form .search-field { + margin-right: unset; + margin-left: 10px; + } + .ast-search-menu-icon.slide-search .search-form { + -webkit-backface-visibility: visible; + backface-visibility: visible; + visibility: hidden; + opacity: 0; + transition: all .2s; + position: absolute; + z-index: 3; + right: -1em; + top: 50%; + transform: translateY(-50%); + }'; + } + + return Astra_Enqueue_Scripts::trim_css( $search_css ); +} |