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