8889841cclass-astra-scroll-to-top.php000064400000003250150442262550012213 0ustar00 masthead.offsetHeight + 100) { astScrollTop.style.display = "block"; } else { astScrollTop.style.display = "none"; } } else{ // If there is no masthead set default start scroll if ( window.pageYOffset > 300 ) { astScrollTop.style.display = "block"; } else { astScrollTop.style.display = "none"; } } } else { astScrollTop.style.display = "none"; } }; astScrollToTop(); window.addEventListener('scroll', function () { astScrollToTop(); }); astScrollTop.onclick = function(e){ e.preventDefault(); window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }); }; } }); assets/js/unminified/customizer-preview.js000064400000005516150442262550015046 0ustar00/** * 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 x.x.x */ ( function( $ ) { astra_css( 'astra-settings[scroll-to-top-icon-size]', 'font-size', '#ast-scroll-top', 'px' ); astra_css( 'astra-settings[scroll-to-top-icon-color]', 'color', '#ast-scroll-top' ); astra_css( 'astra-settings[scroll-to-top-icon-bg-color]', 'background-color', '#ast-scroll-top' ); astra_css( 'astra-settings[scroll-to-top-icon-h-color]', 'color', '#ast-scroll-top:hover' ); astra_css( 'astra-settings[scroll-to-top-icon-h-bg-color]', 'background-color', '#ast-scroll-top:hover' ); // Border Radius Fields for Button. wp.customize( 'astra-settings[scroll-to-top-icon-radius-fields]', function( value ) { value.bind( function( border ) { let tablet_break_point = astraBuilderPreview.tablet_break_point || 768, mobile_break_point = astraBuilderPreview.mobile_break_point || 544; let dynamicStyle = ''; dynamicStyle += ' #ast-scroll-top { border-top-left-radius :' + border['desktop']['top'] + border['desktop-unit'] + '; border-bottom-right-radius :' + border['desktop']['bottom'] + border['desktop-unit'] + '; border-bottom-left-radius :' + border['desktop']['left'] + border['desktop-unit'] + '; border-top-right-radius :' + border['desktop']['right'] + border['desktop-unit'] + '; } '; dynamicStyle += '@media (max-width: ' + tablet_break_point + 'px) { #ast-scroll-top { border-top-left-radius :' + border['tablet']['top'] + border['tablet-unit'] + '; border-bottom-right-radius :' + border['tablet']['bottom'] + border['tablet-unit'] + '; border-bottom-left-radius :' + border['tablet']['left'] + border['tablet-unit'] + '; border-top-right-radius :' + border['tablet']['right'] + border['tablet-unit'] + '; } }'; dynamicStyle += '@media (max-width: ' + mobile_break_point + 'px) { #ast-scroll-top { border-top-left-radius :' + border['mobile']['top'] + border['mobile-unit'] + '; border-bottom-right-radius :' + border['mobile']['bottom'] + border['mobile-unit'] + '; border-bottom-left-radius :' + border['mobile']['left'] + border['mobile-unit'] + '; border-top-right-radius :' + border['mobile']['right'] + border['mobile-unit'] + '; } }'; astra_add_dynamic_css( 'scroll-to-top-icon-radius-fields', dynamicStyle ); } ); } ); // Scroll to top position. wp.customize( 'astra-settings[scroll-to-top-icon-position]', function( value ) { value.bind( function( position ) { jQuery("#ast-scroll-top").removeClass("ast-scroll-to-top-right ast-scroll-to-top-left"); jQuery("#ast-scroll-top").addClass("ast-scroll-to-top-"+position); } ); } ); } )( jQuery ); css/dynamic-css.php000064400000010473150442262550010271 0ustar00 array( 'color' => $scroll_to_top_icon_color, 'background-color' => $scroll_to_top_icon_bg_color, 'font-size' => astra_get_css_value( $scroll_to_top_icon_size, 'rem' ), 'border-top-left-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'top', 'desktop' ), 'border-top-right-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'right', 'desktop' ), 'border-bottom-right-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'bottom', 'desktop' ), 'border-bottom-left-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'left', 'desktop' ), ), '#ast-scroll-top:hover' => array( 'color' => $scroll_to_top_icon_h_color, 'background-color' => $scroll_to_top_icon_h_bg_color, ), ); $scroll_css = astra_parse_css( $scroll_to_top ); $scroll_to_top_tablet = array( '#ast-scroll-top' => array( 'border-top-left-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'top', 'tablet' ), 'border-top-right-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'right', 'tablet' ), 'border-bottom-right-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'bottom', 'tablet' ), 'border-bottom-left-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'left', 'tablet' ), ), ); /* Parse CSS from array() -> max-width: (tablet-breakpoint) px CSS */ $scroll_css .= astra_parse_css( $scroll_to_top_tablet, '', astra_get_tablet_breakpoint() ); $scroll_to_top_mobile = array( '#ast-scroll-top' => array( 'border-top-left-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'top', 'mobile' ), 'border-top-right-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'right', 'mobile' ), 'border-bottom-right-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'bottom', 'mobile' ), 'border-bottom-left-radius' => astra_responsive_spacing( $scroll_to_top_icon_radius_fields, 'left', 'mobile' ), ), ); /* Parse CSS from array() -> max-width: (mobile-breakpoint) px CSS */ $scroll_css .= astra_parse_css( $scroll_to_top_mobile, '', astra_get_mobile_breakpoint() ); if ( is_rtl() ) { $scroll_to_top_rtl = array( '#ast-scroll-top .ast-icon.icon-arrow svg' => array( 'margin-right' => '0px', ), ); $scroll_css .= astra_parse_css( $scroll_to_top_rtl ); } if ( false === Astra_Icons::is_svg_icons() ) { $scroll_to_top_icon = array( '.ast-scroll-top-icon::before' => array( 'content' => '"\e900"', 'font-family' => 'Astra', 'text-decoration' => 'inherit', ), '.ast-scroll-top-icon' => array( 'transform' => 'rotate(180deg)', ), ); $scroll_css .= astra_parse_css( $scroll_to_top_icon ); } // Only if responsive devices is selected. $svg_width = array( /** * Add spacing based on padded layout spacing */ '#ast-scroll-top .ast-icon.icon-arrow svg' => array( 'width' => '1em', ), ); $scroll_css .= astra_parse_css( $svg_width, '', astra_get_tablet_breakpoint() ); return $dynamic_css . $scroll_css; } css/static-css.php000064400000002665150442262550010140 0ustar00 array( 'top' => ! isset( $astra_options['scroll-to-top-icon-radius'] ) ? '' : $astra_options['scroll-to-top-icon-radius'], 'right' => ! isset( $astra_options['scroll-to-top-icon-radius'] ) ? '' : $astra_options['scroll-to-top-icon-radius'], 'bottom' => ! isset( $astra_options['scroll-to-top-icon-radius'] ) ? '' : $astra_options['scroll-to-top-icon-radius'], 'left' => ! isset( $astra_options['scroll-to-top-icon-radius'] ) ? '' : $astra_options['scroll-to-top-icon-radius'], ), 'tablet' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'mobile' => array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', ), 'desktop-unit' => 'px', 'tablet-unit' => 'px', 'mobile-unit' => 'px', ); $defaults['scroll-to-top-icon-color'] = ''; $defaults['scroll-to-top-icon-h-color'] = ''; $defaults['scroll-to-top-icon-bg-color'] = ''; $defaults['scroll-to-top-icon-h-bg-color'] = ''; return $defaults; } /** * Add customizer configs for scroll to top in the Theme Customizer. * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * @since 4.0.0 */ public function new_customize_register( $wp_customize ) { require_once ASTRA_SCROLL_TO_TOP_DIR . 'classes/customizer/class-astra-scroll-to-top-configs.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound -- Not a template file so loading in a normal way. } /** * Customizer Preview * * @since 4.0.0 */ public function preview_scripts() { /** @psalm-suppress RedundantCondition */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort if ( SCRIPT_DEBUG ) { /** @psalm-suppress RedundantCondition */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort wp_enqueue_script( 'astra-scroll-to-top-customize-preview-js', ASTRA_SCROLL_TO_TOP_URL . 'assets/js/unminified/customizer-preview.js', array( 'customize-preview', 'astra-customizer-preview-js' ), ASTRA_THEME_VERSION, true ); } else { wp_enqueue_script( 'astra-scroll-to-top-customize-preview-js', ASTRA_SCROLL_TO_TOP_URL . 'assets/js/minified/customizer-preview.min.js', array( 'customize-preview', 'astra-customizer-preview-js' ), ASTRA_THEME_VERSION, true ); } } /** * Scroll to Top addon markup loader * * Loads appropriate template file based on the style option selected in options panel. * * @since 4.0.0 */ public function html_markup_loader() { if ( true === astra_get_option( 'scroll-to-top-enable', true ) ) { get_template_part( 'template-parts/scroll-to-top' ); } } } /** * Kicking this off by calling 'get_instance()' method */ Astra_Scroll_To_Top_Loader::get_instance(); classes/customizer/class-astra-scroll-to-top-configs.php000064400000024375150442262550017515 0ustar00 ASTRA_THEME_SETTINGS . '[scroll-to-top-enable]', 'default' => astra_get_option( 'scroll-to-top-enable' ), 'type' => 'control', 'section' => 'section-scroll-to-top', 'title' => __( 'Enable Scroll to Top', 'astra' ), 'priority' => 1, 'control' => 'ast-toggle-control', 'divider' => array( 'ast_class' => 'ast-section-spacing' ), ), /** * Option: Scroll to Top Display On */ array( 'name' => ASTRA_THEME_SETTINGS . '[scroll-to-top-on-devices]', 'default' => astra_get_option( 'scroll-to-top-on-devices' ), 'type' => 'control', 'control' => 'ast-selector', 'section' => 'section-scroll-to-top', 'priority' => 10, 'title' => __( 'Display On', 'astra' ), 'choices' => array( 'desktop' => __( 'Desktop', 'astra' ), 'mobile' => __( 'Mobile', 'astra' ), 'both' => __( 'Desktop + Mobile', 'astra' ), ), 'renderAs' => 'text', 'responsive' => false, 'divider' => array( 'ast_class' => 'ast-top-section-divider ast-bottom-section-divider' ), 'context' => array( 'relation' => 'AND', Astra_Builder_Helper::$general_tab_config, array( 'setting' => ASTRA_THEME_SETTINGS . '[scroll-to-top-enable]', 'operator' => '==', 'value' => true, ), ), ), /** * Option: Scroll to Top Position */ array( 'name' => ASTRA_THEME_SETTINGS . '[scroll-to-top-icon-position]', 'default' => astra_get_option( 'scroll-to-top-icon-position' ), 'type' => 'control', 'control' => 'ast-selector', 'transport' => 'postMessage', 'section' => 'section-scroll-to-top', 'title' => __( 'Position', 'astra' ), 'choices' => array( 'left' => __( 'Left', 'astra' ), 'right' => __( 'Right', 'astra' ), ), 'priority' => 11, 'responsive' => false, 'renderAs' => 'text', 'divider' => array( 'ast_class' => 'ast-bottom-section-divider' ), 'context' => array( 'relation' => 'AND', Astra_Builder_Helper::$general_tab_config, array( 'setting' => ASTRA_THEME_SETTINGS . '[scroll-to-top-enable]', 'operator' => '==', 'value' => true, ), ), ), /** * Option: Scroll To Top Icon Size */ array( 'name' => ASTRA_THEME_SETTINGS . '[scroll-to-top-icon-size]', 'default' => astra_get_option( 'scroll-to-top-icon-size' ), 'type' => 'control', 'control' => 'ast-slider', 'transport' => 'postMessage', 'section' => 'section-scroll-to-top', 'title' => __( 'Icon Size', 'astra' ), 'suffix' => 'px', 'priority' => 12, 'context' => array( 'relation' => 'AND', Astra_Builder_Helper::$general_tab_config, array( 'setting' => ASTRA_THEME_SETTINGS . '[scroll-to-top-enable]', 'operator' => '==', 'value' => true, ), ), ), array( 'name' => ASTRA_THEME_SETTINGS . '[scroll-on-top-color-group]', 'default' => astra_get_option( 'scroll-on-top-color-group' ), 'type' => 'control', 'control' => 'ast-color-group', 'title' => __( 'Icon Color', 'astra' ), 'section' => 'section-scroll-to-top', 'context' => array( 'relation' => 'AND', ( true === Astra_Builder_Helper::$is_header_footer_builder_active ) ? Astra_Builder_Helper::$design_tab_config : Astra_Builder_Helper::$general_tab_config, array( 'setting' => ASTRA_THEME_SETTINGS . '[scroll-to-top-enable]', 'operator' => '==', 'value' => true, ), ), 'priority' => 1, 'divider' => array( 'ast_class' => 'ast-section-spacing' ), ), array( 'name' => ASTRA_THEME_SETTINGS . '[scroll-on-top-bg-color-group]', 'default' => astra_get_option( 'scroll-on-top-bg-color-group' ), 'type' => 'control', 'control' => 'ast-color-group', 'title' => __( 'Background Color', 'astra' ), 'section' => 'section-scroll-to-top', 'transport' => 'postMessage', 'context' => array( 'relation' => 'AND', ( true === Astra_Builder_Helper::$is_header_footer_builder_active ) ? Astra_Builder_Helper::$design_tab_config : Astra_Builder_Helper::$general_tab_config, array( 'setting' => ASTRA_THEME_SETTINGS . '[scroll-to-top-enable]', 'operator' => '==', 'value' => true, ), ), 'priority' => 1, ), /** * Option: Scroll To Top Radius */ array( 'name' => ASTRA_THEME_SETTINGS . '[scroll-to-top-icon-radius-fields]', 'default' => astra_get_option( 'scroll-to-top-icon-radius-fields' ), 'type' => 'control', 'control' => 'ast-responsive-spacing', 'transport' => 'postMessage', 'section' => 'section-scroll-to-top', 'title' => __( 'Border Radius', 'astra' ), 'suffix' => 'px', 'priority' => 1, 'divider' => array( 'ast_class' => 'ast-top-section-divider' ), 'context' => array( 'relation' => 'AND', ( true === Astra_Builder_Helper::$is_header_footer_builder_active ) ? Astra_Builder_Helper::$design_tab_config : Astra_Builder_Helper::$general_tab_config, array( 'setting' => ASTRA_THEME_SETTINGS . '[scroll-to-top-enable]', 'operator' => '==', 'value' => true, ), ), 'linked_choices' => true, 'unit_choices' => array( 'px', 'em', '%' ), 'choices' => array( 'top' => __( 'Top', 'astra' ), 'right' => __( 'Right', 'astra' ), 'bottom' => __( 'Bottom', 'astra' ), 'left' => __( 'Left', 'astra' ), ), 'connected' => false, ), /** * Option: Icon Color */ array( 'name' => 'scroll-to-top-icon-color', 'default' => astra_get_option( 'scroll-to-top-icon-color' ), 'type' => 'sub-control', 'priority' => 1, 'parent' => ASTRA_THEME_SETTINGS . '[scroll-on-top-color-group]', 'section' => 'section-scroll-to-top', 'control' => 'ast-color', 'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_alpha_color' ), 'transport' => 'postMessage', 'title' => __( 'Color', 'astra' ), ), /** * Option: Icon Background Color */ array( 'name' => 'scroll-to-top-icon-bg-color', 'default' => astra_get_option( 'scroll-to-top-icon-bg-color' ), 'type' => 'sub-control', 'priority' => 1, 'parent' => ASTRA_THEME_SETTINGS . '[scroll-on-top-bg-color-group]', 'section' => 'section-scroll-to-top', 'transport' => 'postMessage', 'control' => 'ast-color', 'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_alpha_color' ), 'title' => __( 'Color', 'astra' ), ), /** * Option: Icon Hover Color */ array( 'name' => 'scroll-to-top-icon-h-color', 'default' => astra_get_option( 'scroll-to-top-icon-h-color' ), 'type' => 'sub-control', 'priority' => 1, 'parent' => ASTRA_THEME_SETTINGS . '[scroll-on-top-color-group]', 'section' => 'section-scroll-to-top', 'control' => 'ast-color', 'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_alpha_color' ), 'transport' => 'postMessage', 'title' => __( 'Hover Color', 'astra' ), ), /** * Option: Link Hover Background Color */ array( 'name' => 'scroll-to-top-icon-h-bg-color', 'default' => astra_get_option( 'scroll-to-top-icon-h-bg-color' ), 'type' => 'sub-control', 'priority' => 1, 'parent' => ASTRA_THEME_SETTINGS . '[scroll-on-top-bg-color-group]', 'section' => 'section-scroll-to-top', 'control' => 'ast-color', 'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_alpha_color' ), 'transport' => 'postMessage', 'title' => __( 'Hover Color', 'astra' ), ), ); if ( true === Astra_Builder_Helper::$is_header_footer_builder_active ) { $_configs[] = array( 'name' => 'section-scroll-to-top-ast-context-tabs', 'section' => 'section-scroll-to-top', 'type' => 'control', 'control' => 'ast-builder-header-control', 'priority' => 0, 'description' => '', ); $_configs[] = array( 'name' => ASTRA_THEME_SETTINGS . '[enable-scroll-to-top-notice]', 'type' => 'control', 'control' => 'ast-description', 'section' => 'section-scroll-to-top', 'priority' => 1, 'label' => '', 'help' => __( 'Note: To get design settings in action make sure to enable Scroll to Top.', 'astra' ), 'context' => array( 'relation' => 'AND', Astra_Builder_Helper::$design_tab_config, array( 'setting' => ASTRA_THEME_SETTINGS . '[scroll-to-top-enable]', 'operator' => '!=', 'value' => true, ), ), ); } $configurations = array_merge( $configurations, $_configs ); return $configurations; } } /** Creating instance for getting customizer configs. */ new Astra_Scroll_To_Top_Configs();