NBash

Форк
0
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">&#160;</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" onmouseover="return searchBox.OnSearchSelectShow()"'+
64
                     ' onmouseout="return searchBox.OnSearchSelectHide()">&#160;</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
                  '<img id="MSearchCloseImg" border="0" src="'+relPath+
73
                  'search/close.svg" alt=""/></a>'+
74
                 '</span>'+
75
                '</div>';
76
    }
77
  }
78

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

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.