xref: /aosp_15_r20/external/tinyxml2/docs/menu.js (revision 7485b22521f577cf944e5687361548d8993d8d2c)
1*7485b225SElliott Hughes/*
2*7485b225SElliott Hughes @licstart  The following is the entire license notice for the JavaScript code in this file.
3*7485b225SElliott Hughes
4*7485b225SElliott Hughes The MIT License (MIT)
5*7485b225SElliott Hughes
6*7485b225SElliott Hughes Copyright (C) 1997-2020 by Dimitri van Heesch
7*7485b225SElliott Hughes
8*7485b225SElliott Hughes Permission is hereby granted, free of charge, to any person obtaining a copy of this software
9*7485b225SElliott Hughes and associated documentation files (the "Software"), to deal in the Software without restriction,
10*7485b225SElliott Hughes including without limitation the rights to use, copy, modify, merge, publish, distribute,
11*7485b225SElliott Hughes sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
12*7485b225SElliott Hughes furnished to do so, subject to the following conditions:
13*7485b225SElliott Hughes
14*7485b225SElliott Hughes The above copyright notice and this permission notice shall be included in all copies or
15*7485b225SElliott Hughes substantial portions of the Software.
16*7485b225SElliott Hughes
17*7485b225SElliott Hughes THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
18*7485b225SElliott Hughes BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19*7485b225SElliott Hughes NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20*7485b225SElliott Hughes DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21*7485b225SElliott Hughes OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*7485b225SElliott Hughes
23*7485b225SElliott Hughes @licend  The above is the entire license notice for the JavaScript code in this file
24*7485b225SElliott Hughes */
25*7485b225SElliott Hughesfunction initMenu(relPath,searchEnabled,serverSide,searchPage,search) {
26*7485b225SElliott Hughes  function makeTree(data,relPath) {
27*7485b225SElliott Hughes    let result='';
28*7485b225SElliott Hughes    if ('children' in data) {
29*7485b225SElliott Hughes      result+='<ul>';
30*7485b225SElliott Hughes      for (let i in data.children) {
31*7485b225SElliott Hughes        let url;
32*7485b225SElliott Hughes        const link = data.children[i].url;
33*7485b225SElliott Hughes        if (link.substring(0,1)=='^') {
34*7485b225SElliott Hughes          url = link.substring(1);
35*7485b225SElliott Hughes        } else {
36*7485b225SElliott Hughes          url = relPath+link;
37*7485b225SElliott Hughes        }
38*7485b225SElliott Hughes        result+='<li><a href="'+url+'">'+
39*7485b225SElliott Hughes                                data.children[i].text+'</a>'+
40*7485b225SElliott Hughes                                makeTree(data.children[i],relPath)+'</li>';
41*7485b225SElliott Hughes      }
42*7485b225SElliott Hughes      result+='</ul>';
43*7485b225SElliott Hughes    }
44*7485b225SElliott Hughes    return result;
45*7485b225SElliott Hughes  }
46*7485b225SElliott Hughes  let searchBoxHtml;
47*7485b225SElliott Hughes  if (searchEnabled) {
48*7485b225SElliott Hughes    if (serverSide) {
49*7485b225SElliott Hughes      searchBoxHtml='<div id="MSearchBox" class="MSearchBoxInactive">'+
50*7485b225SElliott Hughes                 '<div class="left">'+
51*7485b225SElliott Hughes                  '<form id="FSearchBox" action="'+relPath+searchPage+
52*7485b225SElliott Hughes                    '" method="get"><span id="MSearchSelectExt">&#160;</span>'+
53*7485b225SElliott Hughes                  '<input type="text" id="MSearchField" name="query" value="" placeholder="'+search+
54*7485b225SElliott Hughes                    '" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)"'+
55*7485b225SElliott Hughes                    ' onblur="searchBox.OnSearchFieldFocus(false)"/>'+
56*7485b225SElliott Hughes                  '</form>'+
57*7485b225SElliott Hughes                 '</div>'+
58*7485b225SElliott Hughes                 '<div class="right"></div>'+
59*7485b225SElliott Hughes                '</div>';
60*7485b225SElliott Hughes    } else {
61*7485b225SElliott Hughes      searchBoxHtml='<div id="MSearchBox" class="MSearchBoxInactive">'+
62*7485b225SElliott Hughes                 '<span class="left">'+
63*7485b225SElliott Hughes                  '<span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()"'+
64*7485b225SElliott Hughes                     ' onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>'+
65*7485b225SElliott Hughes                  '<input type="text" id="MSearchField" value="" placeholder="'+search+
66*7485b225SElliott Hughes                    '" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" '+
67*7485b225SElliott Hughes                    'onblur="searchBox.OnSearchFieldFocus(false)" '+
68*7485b225SElliott Hughes                    'onkeyup="searchBox.OnSearchFieldChange(event)"/>'+
69*7485b225SElliott Hughes                 '</span>'+
70*7485b225SElliott Hughes                 '<span class="right"><a id="MSearchClose" '+
71*7485b225SElliott Hughes                  'href="javascript:searchBox.CloseResultsWindow()">'+
72*7485b225SElliott Hughes                  '<img id="MSearchCloseImg" border="0" src="'+relPath+
73*7485b225SElliott Hughes                  'search/close.svg" alt=""/></a>'+
74*7485b225SElliott Hughes                 '</span>'+
75*7485b225SElliott Hughes                '</div>';
76*7485b225SElliott Hughes    }
77*7485b225SElliott Hughes  }
78*7485b225SElliott Hughes
79*7485b225SElliott Hughes  $('#main-nav').before('<div class="sm sm-dox"><input id="main-menu-state" type="checkbox"/>'+
80*7485b225SElliott Hughes                        '<label class="main-menu-btn" for="main-menu-state">'+
81*7485b225SElliott Hughes                        '<span class="main-menu-btn-icon"></span> '+
82*7485b225SElliott Hughes                        'Toggle main menu visibility</label>'+
83*7485b225SElliott Hughes                        '<span id="searchBoxPos1" style="position:absolute;right:8px;top:8px;height:36px;"></span>'+
84*7485b225SElliott Hughes                        '</div>');
85*7485b225SElliott Hughes  $('#main-nav').append(makeTree(menudata,relPath));
86*7485b225SElliott Hughes  $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu');
87*7485b225SElliott Hughes  if (searchBoxHtml) {
88*7485b225SElliott Hughes    $('#main-menu').append('<li id="searchBoxPos2" style="float:right"></li>');
89*7485b225SElliott Hughes  }
90*7485b225SElliott Hughes  const $mainMenuState = $('#main-menu-state');
91*7485b225SElliott Hughes  let prevWidth = 0;
92*7485b225SElliott Hughes  if ($mainMenuState.length) {
93*7485b225SElliott Hughes    const initResizableIfExists = function() {
94*7485b225SElliott Hughes      if (typeof initResizable==='function') initResizable();
95*7485b225SElliott Hughes    }
96*7485b225SElliott Hughes    // animate mobile menu
97*7485b225SElliott Hughes    $mainMenuState.change(function() {
98*7485b225SElliott Hughes      const $menu = $('#main-menu');
99*7485b225SElliott Hughes      let options = { duration: 250, step: initResizableIfExists };
100*7485b225SElliott Hughes      if (this.checked) {
101*7485b225SElliott Hughes        options['complete'] = () => $menu.css('display', 'block');
102*7485b225SElliott Hughes        $menu.hide().slideDown(options);
103*7485b225SElliott Hughes      } else {
104*7485b225SElliott Hughes        options['complete'] = () => $menu.css('display', 'none');
105*7485b225SElliott Hughes        $menu.show().slideUp(options);
106*7485b225SElliott Hughes      }
107*7485b225SElliott Hughes    });
108*7485b225SElliott Hughes    // set default menu visibility
109*7485b225SElliott Hughes    const resetState = function() {
110*7485b225SElliott Hughes      const $menu = $('#main-menu');
111*7485b225SElliott Hughes      const newWidth = $(window).outerWidth();
112*7485b225SElliott Hughes      if (newWidth!=prevWidth) {
113*7485b225SElliott Hughes        if ($(window).outerWidth()<768) {
114*7485b225SElliott Hughes          $mainMenuState.prop('checked',false); $menu.hide();
115*7485b225SElliott Hughes          $('#searchBoxPos1').html(searchBoxHtml);
116*7485b225SElliott Hughes          $('#searchBoxPos2').hide();
117*7485b225SElliott Hughes        } else {
118*7485b225SElliott Hughes          $menu.show();
119*7485b225SElliott Hughes          $('#searchBoxPos1').empty();
120*7485b225SElliott Hughes          $('#searchBoxPos2').html(searchBoxHtml);
121*7485b225SElliott Hughes          $('#searchBoxPos2').show();
122*7485b225SElliott Hughes        }
123*7485b225SElliott Hughes        if (typeof searchBox!=='undefined') {
124*7485b225SElliott Hughes          searchBox.CloseResultsWindow();
125*7485b225SElliott Hughes        }
126*7485b225SElliott Hughes        prevWidth = newWidth;
127*7485b225SElliott Hughes      }
128*7485b225SElliott Hughes    }
129*7485b225SElliott Hughes    $(window).ready(function() { resetState(); initResizableIfExists(); });
130*7485b225SElliott Hughes    $(window).resize(resetState);
131*7485b225SElliott Hughes  }
132*7485b225SElliott Hughes  $('#main-menu').smartmenus();
133*7485b225SElliott Hughes}
134*7485b225SElliott Hughes/* @license-end */
135