• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
25function 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 searchBoxHtml;
48  if (searchEnabled) {
49    if (serverSide) {
50      searchBoxHtml='<div id="MSearchBox" class="MSearchBoxInactive">'+
51                 '<div class="left">'+
52                  '<form id="FSearchBox" action="'+relPath+searchPage+
53                    '" method="get"><span id="MSearchSelectExt">&#160;</span>'+
54                  '<input type="text" id="MSearchField" name="query" value="" placeholder="'+search+
55                    '" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)"'+
56                    ' onblur="searchBox.OnSearchFieldFocus(false)"/>'+
57                  '</form>'+
58                 '</div>'+
59                 '<div class="right"></div>'+
60                '</div>';
61    } else {
62      searchBoxHtml='<div id="MSearchBox" class="MSearchBoxInactive">'+
63                 '<span class="left">'+
64                  '<span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()"'+
65                     ' onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>'+
66                  '<input type="text" id="MSearchField" value="" placeholder="'+search+
67                    '" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" '+
68                    'onblur="searchBox.OnSearchFieldFocus(false)" '+
69                    'onkeyup="searchBox.OnSearchFieldChange(event)"/>'+
70                 '</span>'+
71                 '<span class="right"><a id="MSearchClose" '+
72                  'href="javascript:searchBox.CloseResultsWindow()">'+
73                  '<img id="MSearchCloseImg" border="0" src="'+relPath+
74                  'search/close.svg" alt=""/></a>'+
75                 '</span>'+
76                '</div>';
77    }
78  }
79
80  $('#main-nav').before('<div class="sm sm-dox"><input id="main-menu-state" type="checkbox"/>'+
81                        '<label class="main-menu-btn" for="main-menu-state">'+
82                        '<span class="main-menu-btn-icon"></span> '+
83                        'Toggle main menu visibility</label>'+
84                        '<span id="searchBoxPos1" style="position:absolute;right:8px;top:8px;height:36px;"></span>'+
85                        '</div>');
86  $('#main-nav').append(makeTree(menudata,relPath));
87  $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu');
88  if (searchBoxHtml) {
89    $('#main-menu').append('<li id="searchBoxPos2" style="float:right"></li>');
90  }
91  var $mainMenuState = $('#main-menu-state');
92  var prevWidth = 0;
93  if ($mainMenuState.length) {
94    function initResizableIfExists() {
95      if (typeof initResizable==='function') initResizable();
96    }
97    // animate mobile menu
98    $mainMenuState.change(function(e) {
99      var $menu = $('#main-menu');
100      var options = { duration: 250, step: initResizableIfExists };
101      if (this.checked) {
102        options['complete'] = function() { $menu.css('display', 'block') };
103        $menu.hide().slideDown(options);
104      } else {
105        options['complete'] = function() { $menu.css('display', 'none') };
106        $menu.show().slideUp(options);
107      }
108    });
109    // set default menu visibility
110    function resetState() {
111      var $menu = $('#main-menu');
112      var $mainMenuState = $('#main-menu-state');
113      var newWidth = $(window).outerWidth();
114      if (newWidth!=prevWidth) {
115        if ($(window).outerWidth()<768) {
116          $mainMenuState.prop('checked',false); $menu.hide();
117          $('#searchBoxPos1').html(searchBoxHtml);
118          $('#searchBoxPos2').hide();
119        } else {
120          $menu.show();
121          $('#searchBoxPos1').empty();
122          $('#searchBoxPos2').html(searchBoxHtml);
123          $('#searchBoxPos2').show();
124        }
125        if (typeof searchBox!=='undefined') {
126          searchBox.CloseResultsWindow();
127        }
128        prevWidth = newWidth;
129      }
130    }
131    $(window).ready(function() { resetState(); initResizableIfExists(); });
132    $(window).resize(resetState);
133  }
134  $('#main-menu').smartmenus();
135}
136/* @license-end */
137