Reply 185604 to: WPML LANGUAGE SWITCHER IN MOBILE FIXED HEADER

Avatar: BWA2
BWA2
Participant
February 20, 2018 at 09:25

Hi Rose,
I have done
1. added wp_enqueue_script(‘child-theme’, get_stylesheet_directory_uri().’/etheme-child.js’,array(‘etheme’),false,true); to our child theme function.php

Then I created etheme-child.js and added the following code to it:

fixedHeader: function() {

            // **********************************************************************//
            // ! Fixed header
            // **********************************************************************//

            if ( $( 'body' ).hasClass( 'et-fixed-disable' ) ) return;
            if ( $( 'body' ).hasClass( 'et-vertical-fixed' ) && $(window).width() > 992 ) return;

            var header = $('.header-wrapper'),
                logo = header.find('.header-logo').html(),
                menu = header.find('.menu-wrapper').first(),
                menuClass = menu.attr('class'),
                menuRight = header.find('.menu-wrapper-right'),
                navbar = header.find('.navbar-header').html(),
                menuBtn = header.find('.navbar-toggle').html(),
                color = $('.page-wrapper').data('fixed-color'),
                startOffset = 240,
                menuHtml;
				var menu_switcher = header.find('.mobile-language-switcher').html();

            // Do it for non standard navbar
            if ( $( 'body' ).hasClass( 'shop-top-bar' ) ){
                navbar = this.NavbarHeader( 'fixed' );
            }

            if( menuRight.length > 0 ) {
                menuHtml = menu.html() + menuRight.html();
            } else {
                menuHtml = menu.html();
            }

            // Check values for "Toolset Layouts" plugin
            if ( logo == null ) logo = '';
            if ( menuHtml == null ) menuHtml = '';
            if ( navbar == null ) navbar = '';
            if ( menuBtn == null ) menuBtn = '<span class="sr-only">Menu</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>';

            var fixedHeaderHtml = '<div class="fixed-header header-color-' + color + '"><div class="container"><div class="header-logo">' + logo + '</div><div class="' + menuClass + '">' + menuHtml + '</div><div class="mobile-language-switcher">'+menu_switcher+'</div><div class="navbar-header">' + navbar + '</div><div class="navbar-toggle">' + menuBtn + '</div></div></div>';

            header.before(fixedHeaderHtml);

            if ($(window).width() < 768 ) { startOffset = 120; }

            var fixed = $('.fixed-header');
            if ( $('body').hasClass('et-header-fixed') ) {
                $(window).scroll(function(){
                    var currentScroll = $(this).scrollTop();

                    if( currentScroll > startOffset ) {
                        showFixed();
                    } else {
                        hideFixed();
                    }

                });
            }
            else {
                if ( $('body').hasClass('et-header-sticky') ) {
                    var previousScroll = 0,
                    animatedTimer = 0,
                    stickyHeight = fixed.outerHeight(),
                    stickyAfter = fixed.outerHeight() + 20;
                        $(window).scroll(function() {
                            var currentScroll = $(this).scrollTop();

                            // sticky header
                            if( ( currentScroll < previousScroll ) && ( currentScroll > startOffset ) ) {
                                fixed.addClass('sticky-header-enabled');
                            } else {
                                fixed.removeClass('sticky-header-enabled');
                            }

                        /*if (currentScroll < previousScroll){
                            // Scroll up
                        } else {
                            //Scroll down
                        }*/

                        previousScroll = currentScroll;
                    });
                }
            }

            var showFixed = function() {
                fixed.addClass('fixed-enabled');
            };

            var hideFixed = function() {
                fixed.removeClass('fixed-enabled');
            };
        },

and then I uploaded the etheme-child.js to the same folder as the child theme’s functions.php file.

But the WMPL flags still don’t show in the fixed mobile menu unfortunately. They only show in the initial main menu.

Go To The Whole Conversation In Topic
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.