menu.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. function initMenu(relPath,searchEnabled,serverSide,searchPage,search) {
  2. function makeTree(data,relPath) {
  3. var result='';
  4. if ('children' in data) {
  5. result+='<ul>';
  6. if (searchEnabled) {
  7. if (serverSide) {
  8. result += '<li id="wolfssl_search"><div id="MSearchBox" class="MSearchBoxInactive">' +
  9. '<div class="left">' +
  10. '<form id="FSearchBox" action="' + searchPage + '" method="get">' +
  11. '<img id="MSearchSelect" src="' + relPath + 'search/mag.png" alt=""/>' +
  12. '<input type="text" id="MSearchField" name="query" value="' + search +
  13. '" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" ' +
  14. 'onblur="searchBox.OnSearchFieldFocus(false)">' +
  15. '</form>' +
  16. '</div><div class="right"></div>' +
  17. '</div></li>';
  18. } else {
  19. result += '<li id="wolfssl_search"><div id="MSearchBox" class="MSearchBoxInactive">' +
  20. '<span class="left">' +
  21. '<img id="MSearchSelect" src="' + relPath + 'search/mag_sel.png" ' +
  22. 'onmouseover="return searchBox.OnSearchSelectShow()" ' +
  23. 'onmouseout="return searchBox.OnSearchSelectHide()" alt=""/>' +
  24. '<input type="text" id="MSearchField" value="' + search +
  25. '" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" ' +
  26. 'onblur="searchBox.OnSearchFieldFocus(false)" ' +
  27. 'onkeyup="searchBox.OnSearchFieldChange(event)"/>' +
  28. '</span>' +
  29. '<span class="right">' +
  30. '<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()">' +
  31. '<img id="MSearchCloseImg" border="0" src="' + relPath + 'search/close.png" alt=""/></a>' +
  32. '</span>' +
  33. '</div></li>';
  34. }
  35. }
  36. for (var i in data.children) {
  37. if (relPath+data.children[i].style) {
  38. result+='<li style="'+relPath+data.children[i].style+'"><a href="'+relPath+data.children[i].url+'">'+
  39. data.children[i].text+'</a>'+
  40. makeTree(data.children[i],relPath)+'</li>';
  41. } else {
  42. result+='<li><a href="'+relPath+data.children[i].url+'">'+
  43. data.children[i].text+'</a>'+
  44. makeTree(data.children[i],relPath)+'</li>';
  45. }
  46. }
  47. result+='</ul>';
  48. }
  49. return result;
  50. }
  51. $('#main-nav').append(makeTree(menudata,relPath));
  52. $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu');
  53. $('#main-menu').smartmenus();
  54. }