Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

menu.js 2.8KB

5 år sedan
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. @licstart The following is the entire license notice for the
  3. JavaScript code in this file.
  4. Copyright (C) 1997-2017 by Dimitri van Heesch
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. @licend The above is the entire license notice
  17. for the JavaScript code in this file
  18. */
  19. function initMenu(relPath,searchEnabled,serverSide,searchPage,search) {
  20. function makeTree(data,relPath) {
  21. var result='';
  22. if ('children' in data) {
  23. result+='<ul>';
  24. for (var i in data.children) {
  25. result+='<li><a href="'+relPath+data.children[i].url+'">'+
  26. data.children[i].text+'</a>'+
  27. makeTree(data.children[i],relPath)+'</li>';
  28. }
  29. result+='</ul>';
  30. }
  31. return result;
  32. }
  33. $('#main-nav').append(makeTree(menudata,relPath));
  34. $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu');
  35. if (searchEnabled) {
  36. if (serverSide) {
  37. $('#main-menu').append('<li style="float:right"><div id="MSearchBox" class="MSearchBoxInactive"><div class="left"><form id="FSearchBox" action="'+searchPage+'" method="get"><img id="MSearchSelect" src="'+relPath+'search/mag.png" alt=""/><input type="text" id="MSearchField" name="query" value="'+search+'" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"></form></div><div class="right"></div></div></li>');
  38. } else {
  39. $('#main-menu').append('<li style="float:right"><div id="MSearchBox" class="MSearchBoxInactive"><span class="left"><img id="MSearchSelect" src="'+relPath+'search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/><input type="text" id="MSearchField" value="'+search+'" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/></span><span class="right"><a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="'+relPath+'search/close.png" alt=""/></a></span></div></li>');
  40. }
  41. }
  42. $('#main-menu').smartmenus();
  43. }
  44. /* @license-end */