www.webdeveloper.com
Results 1 to 2 of 2

Thread: JQuery Submenu messed up (Weebly)

  1. #1
    Join Date
    Feb 2014
    Posts
    1

    Question JQuery Submenu messed up (Weebly)

    I am designing a website with the CMS of Weebly. Unfortunately Weebly doesn't support multilingual websites, so I had to do it with JQuery. I found a script at http://blessingsweb.weebly.com/1/pos...th-weebly.html and added it to my website. The script hides the German menus, when you are on the English website and hides the English menus, when you are on the German Website. Everything is working, apart from the submenu on the German website. Somehow the script changed the position of the submenu and also the direction of the slide from left to right, to top to bottom.

    Demo: http://mop000.weebly.com/startseite.html as you can see, the submenu has some strange behaviour.

    If you click on the flag, you will see that on the English site everything is working well.

    What can I do?

    Code added as languages-1.0.js-file:

    Code:
    function hideMenus() {
    lang = language.toLowerCase();
    console.log('LANG: ' + lang);
    
    currentLang = null;
    menus = jQuery(menuSelector + ' ul li').each(function(){
        menu = jQuery(this);
        a = menu.children('a');
        span = a.children('span');
        if (span.length == 0) text = a.html();
        else text = span.html();
        text = text.toLowerCase();
    
        if (langs[text] != null) {
            currentLang = langs[text].toLowerCase();
            if (currentLang == lang) { 
                //if this is the first page of this language, we set the logo to go to this page url
                jQuery('.wsite-logo a').attr('href', a.attr('href'));
            }
        }
        show = (currentLang == lang);
        if (show) menu.show(); else menu.hide();
      console.log('MENU:' + text + ' - current lang: ' + currentLang + ' - in langs '+ langs[text] + ' - '+ (show ? 'SHOW' : 'HIDE'));
    });
    }

    Code added in the header (SEO) of the website:

    Code:
    <script src="/files/theme/jquery-1.10.2.min.js"></script>
    <script src="/files/theme/languages-1.0.js"></script>
    <script>
    langs = {          //everything in langs must be in lowercase
        'home': 'en',
        'startseite': 'de'
    };
    menuSelector = '#avmenu'; 
    $(document).ready(function(){hideMenus()});
    </script>

    Code added on the German pages:

    Code:
    <script> language = 'de'; </script>
    Code added on the English pages:

    Code:
    <script> language = 'en'; </script>
    That's it. Thanks in advance!

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,207
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles