Projekt

Obecné

Profil

Stáhnout (5.73 KB) Statistiky
| Větev: | Tag: | Revize:
1
/*
2
 @licstart  The following is the entire license notice for the JavaScript code in this file.
3

    
4
 The MIT License (MIT)
5

    
6
 Copyright (C) 1997-2020 by Dimitri van Heesch
7

    
8
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
9
 and associated documentation files (the "Software"), to deal in the Software without restriction,
10
 including without limitation the rights to use, copy, modify, merge, publish, distribute,
11
 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
12
 furnished to do so, subject to the following conditions:
13

    
14
 The above copyright notice and this permission notice shall be included in all copies or
15
 substantial portions of the Software.
16

    
17
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
18
 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20
 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22

    
23
 @licend  The above is the entire license notice for the JavaScript code in this file
24
 */
25
function initMenu(relPath,searchEnabled,serverSide,searchPage,search) {
26
  function makeTree(data,relPath) {
27
    var result='';
28
    if ('children' in data) {
29
      result+='<ul>';
30
      for (var i in data.children) {
31
        var url;
32
        var link;
33
        link = data.children[i].url;
34
        if (link.substring(0,1)=='^') {
35
          url = link.substring(1);
36
        } else {
37
          url = relPath+link;
38
        }
39
        result+='<li><a href="'+url+'">'+
40
                                data.children[i].text+'</a>'+
41
                                makeTree(data.children[i],relPath)+'</li>';
42
      }
43
      result+='</ul>';
44
    }
45
    return result;
46
  }
47
  var searchBox;
48
  if (searchEnabled) {
49
    if (serverSide) {
50
      searchBox='<div id="MSearchBox" class="MSearchBoxInactive">'+
51
                 '<div class="left">'+
52
                  '<form id="FSearchBox" action="'+relPath+searchPage+
53
                    '" method="get"><img id="MSearchSelect" src="'+
54
                    relPath+'search/mag.svg" alt=""/>'+
55
                  '<input type="text" id="MSearchField" name="query" value="'+search+
56
                    '" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)"'+
57
                    ' onblur="searchBox.OnSearchFieldFocus(false)">'+
58
                  '</form>'+
59
                 '</div>'+
60
                 '<div class="right"></div>'+
61
                '</div>';
62
    } else {
63
      searchBox='<div id="MSearchBox" class="MSearchBoxInactive">'+
64
                 '<span class="left">'+
65
                  '<img id="MSearchSelect" src="'+relPath+
66
                     'search/mag_sel.svg" onmouseover="return searchBox.OnSearchSelectShow()"'+
67
                     ' onmouseout="return searchBox.OnSearchSelectHide()" alt=""/>'+
68
                  '<input type="text" id="MSearchField" value="'+search+
69
                    '" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" '+
70
                    'onblur="searchBox.OnSearchFieldFocus(false)" '+
71
                    'onkeyup="searchBox.OnSearchFieldChange(event)"/>'+
72
                 '</span>'+
73
                 '<span class="right"><a id="MSearchClose" '+
74
                  'href="javascript:searchBox.CloseResultsWindow()">'+
75
                  '<img id="MSearchCloseImg" border="0" src="'+relPath+
76
                  'search/close.svg" alt=""/></a>'
77
                 '</span>'
78
                '</div>';
79
    }
80
  }
81

    
82
  $('#main-nav').before('<div class="sm sm-dox"><input id="main-menu-state" type="checkbox"/>'+
83
                        '<label class="main-menu-btn" for="main-menu-state">'+
84
                        '<span class="main-menu-btn-icon"></span> '+
85
                        'Toggle main menu visibility</label>'+
86
                        '<span id="searchBoxPos1" style="position:absolute;right:8px;top:8px;height:36px;"></span>'+
87
                        '</div>');
88
  $('#main-nav').append(makeTree(menudata,relPath));
89
  $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu');
90
  if (searchBox) {
91
    $('#main-menu').append('<li id="searchBoxPos2" style="float:right"></li>');
92
  }
93
  var $mainMenuState = $('#main-menu-state');
94
  var prevWidth = 0;
95
  if ($mainMenuState.length) {
96
    function initResizableIfExists() {
97
      if (typeof initResizable==='function') initResizable();
98
    }
99
    // animate mobile menu
100
    $mainMenuState.change(function(e) {
101
      var $menu = $('#main-menu');
102
      var options = { duration: 250, step: initResizableIfExists };
103
      if (this.checked) {
104
        options['complete'] = function() { $menu.css('display', 'block') };
105
        $menu.hide().slideDown(options);
106
      } else {
107
        options['complete'] = function() { $menu.css('display', 'none') };
108
        $menu.show().slideUp(options);
109
      }
110
    });
111
    // set default menu visibility
112
    function resetState() {
113
      var $menu = $('#main-menu');
114
      var $mainMenuState = $('#main-menu-state');
115
      var newWidth = $(window).outerWidth();
116
      if (newWidth!=prevWidth) {
117
        if ($(window).outerWidth()<768) {
118
          $mainMenuState.prop('checked',false); $menu.hide();
119
          $('#searchBoxPos1').html(searchBox);
120
          $('#searchBoxPos2').hide();
121
        } else {
122
          $menu.show();
123
          $('#searchBoxPos1').empty();
124
          $('#searchBoxPos2').html(searchBox);
125
          $('#searchBoxPos2').show();
126
        }
127
        prevWidth = newWidth;
128
      }
129
    }
130
    $(window).ready(function() { resetState(); initResizableIfExists(); });
131
    $(window).resize(resetState);
132
  }
133
  $('#main-menu').smartmenus();
134
}
135
/* @license-end */
(89-89/123)