aboutsummaryrefslogtreecommitdiffstats
path: root/themes/elegant/scripts.js
blob: 1f946303e14e9c26d73b6aacbf5f74c0856b3a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(function() {
  var session_storage = window.sessionStorage || {};

  var menubar=jQuery("#menubar"),
      menuswitcher=jQuery("#menuSwitcher"),
      content=jQuery("#the_page > .content"),
      pcontent=jQuery("#content");

  function hideMenu(delay) {
    menubar.hide(delay);
    menuswitcher.addClass("menuhidden").removeClass("menushown");
    content.addClass("menuhidden").removeClass("menushown");
    pcontent.addClass("menuhidden").removeClass("menushown");
    session_storage['page-menu'] = 'hidden';
  }

  function showMenu(delay) {
    menubar.show(delay);
    menuswitcher.addClass("menushown").removeClass("menuhidden");
    content.addClass("menushown").removeClass("menuhidden");
    pcontent.addClass("menushown").removeClass("menuhidden");
    session_storage['page-menu'] = 'visible';
  }

  jQuery(function(){
    if (menubar.length == 1 && p_main_menu!="disabled") {
      menuswitcher.html('<div class="switchArrow">&nbsp;</div>');

      if (session_storage['page-menu'] == undefined && p_main_menu == 'off') {
        session_storage['page-menu'] = 'hidden';
      }

      if (session_storage['page-menu'] == 'hidden') {
        hideMenu(0);
      }
      else {
        showMenu(0);
      }

      menuswitcher.click(function(e){
        if (menubar.is(":hidden")) {
          showMenu(0);
        }
        else {
          hideMenu(0);
        }
        e.preventDefault();
      });
    }
    else if (menubar.length == 1 && p_main_menu=="disabled") {
      showMenu(0);
    }
  });
}());