Micro template library A library for building device drivers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

137 lines
4.4 KiB

  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 initResizable()
  20. {
  21. var cookie_namespace = 'doxygen';
  22. var sidenav,navtree,content,header,collapsed,collapsedWidth=0,barWidth=6,desktop_vp=768,titleHeight;
  23. function readCookie(cookie)
  24. {
  25. var myCookie = cookie_namespace+"_"+cookie+"=";
  26. if (document.cookie) {
  27. var index = document.cookie.indexOf(myCookie);
  28. if (index != -1) {
  29. var valStart = index + myCookie.length;
  30. var valEnd = document.cookie.indexOf(";", valStart);
  31. if (valEnd == -1) {
  32. valEnd = document.cookie.length;
  33. }
  34. var val = document.cookie.substring(valStart, valEnd);
  35. return val;
  36. }
  37. }
  38. return 0;
  39. }
  40. function writeCookie(cookie, val, expiration)
  41. {
  42. if (val==undefined) return;
  43. if (expiration == null) {
  44. var date = new Date();
  45. date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week
  46. expiration = date.toGMTString();
  47. }
  48. document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; expires=" + expiration+"; path=/";
  49. }
  50. function resizeWidth()
  51. {
  52. var windowWidth = $(window).width() + "px";
  53. var sidenavWidth = $(sidenav).outerWidth();
  54. content.css({marginLeft:parseInt(sidenavWidth)+"px"});
  55. writeCookie('width',sidenavWidth-barWidth, null);
  56. }
  57. function restoreWidth(navWidth)
  58. {
  59. var windowWidth = $(window).width() + "px";
  60. content.css({marginLeft:parseInt(navWidth)+barWidth+"px"});
  61. sidenav.css({width:navWidth + "px"});
  62. }
  63. function resizeHeight()
  64. {
  65. var headerHeight = header.outerHeight();
  66. var footerHeight = footer.outerHeight();
  67. var windowHeight = $(window).height() - headerHeight - footerHeight;
  68. content.css({height:windowHeight + "px"});
  69. navtree.css({height:windowHeight + "px"});
  70. sidenav.css({height:windowHeight + "px"});
  71. var width=$(window).width();
  72. if (width!=collapsedWidth) {
  73. if (width<desktop_vp && collapsedWidth>=desktop_vp) {
  74. if (!collapsed) {
  75. collapseExpand();
  76. }
  77. } else if (width>desktop_vp && collapsedWidth<desktop_vp) {
  78. if (collapsed) {
  79. collapseExpand();
  80. }
  81. }
  82. collapsedWidth=width;
  83. }
  84. }
  85. function collapseExpand()
  86. {
  87. if (sidenav.width()>0) {
  88. restoreWidth(0);
  89. collapsed=true;
  90. }
  91. else {
  92. var width = readCookie('width');
  93. if (width>200 && width<$(window).width()) { restoreWidth(width); } else { restoreWidth(200); }
  94. collapsed=false;
  95. }
  96. }
  97. header = $("#top");
  98. sidenav = $("#side-nav");
  99. content = $("#doc-content");
  100. navtree = $("#nav-tree");
  101. footer = $("#nav-path");
  102. $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } });
  103. $(sidenav).resizable({ minWidth: 0 });
  104. $(window).resize(function() { resizeHeight(); });
  105. var device = navigator.userAgent.toLowerCase();
  106. var touch_device = device.match(/(iphone|ipod|ipad|android)/);
  107. if (touch_device) { /* wider split bar for touch only devices */
  108. $(sidenav).css({ paddingRight:'20px' });
  109. $('.ui-resizable-e').css({ width:'20px' });
  110. $('#nav-sync').css({ right:'34px' });
  111. barWidth=20;
  112. }
  113. var width = readCookie('width');
  114. if (width) { restoreWidth(width); } else { resizeWidth(); }
  115. resizeHeight();
  116. var url = location.href;
  117. var i=url.indexOf("#");
  118. if (i>=0) window.location.hash=url.substr(i);
  119. var _preventDefault = function(evt) { evt.preventDefault(); };
  120. $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
  121. $(".ui-resizable-handle").dblclick(collapseExpand);
  122. $(window).load(resizeHeight);
  123. }
  124. /* @license-end */