My Project - RET HER  versionsnr
resize.js
Go to the documentation of this file.
1 /*
2  @licstart The following is the entire license notice for the
3  JavaScript code in this file.
4 
5  Copyright (C) 1997-2017 by Dimitri van Heesch
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 
21  @licend The above is the entire license notice
22  for the JavaScript code in this file
23  */
24 function initResizable()
25 {
26  var cookie_namespace = 'doxygen';
27  var sidenav,navtree,content,header,collapsed,collapsedWidth=0,barWidth=6,desktop_vp=768,titleHeight;
28 
29  function readCookie(cookie)
30  {
31  var myCookie = cookie_namespace+"_"+cookie+"=";
32  if (document.cookie) {
33  var index = document.cookie.indexOf(myCookie);
34  if (index != -1) {
35  var valStart = index + myCookie.length;
36  var valEnd = document.cookie.indexOf(";", valStart);
37  if (valEnd == -1) {
38  valEnd = document.cookie.length;
39  }
40  var val = document.cookie.substring(valStart, valEnd);
41  return val;
42  }
43  }
44  return 0;
45  }
46 
47  function writeCookie(cookie, val, expiration)
48  {
49  if (val==undefined) return;
50  if (expiration == null) {
51  var date = new Date();
52  date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week
53  expiration = date.toGMTString();
54  }
55  document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; expires=" + expiration+"; path=/";
56  }
57 
58  function resizeWidth()
59  {
60  var windowWidth = $(window).width() + "px";
61  var sidenavWidth = $(sidenav).outerWidth();
62  content.css({marginLeft:parseInt(sidenavWidth)+"px"});
63  writeCookie('width',sidenavWidth-barWidth, null);
64  }
65 
66  function restoreWidth(navWidth)
67  {
68  var windowWidth = $(window).width() + "px";
69  content.css({marginLeft:parseInt(navWidth)+barWidth+"px"});
70  sidenav.css({width:navWidth + "px"});
71  }
72 
73  function resizeHeight()
74  {
75  var headerHeight = header.outerHeight();
76  var footerHeight = footer.outerHeight();
77  var windowHeight = $(window).height() - headerHeight - footerHeight;
78  content.css({height:windowHeight + "px"});
79  navtree.css({height:windowHeight + "px"});
80  sidenav.css({height:windowHeight + "px"});
81  var width=$(window).width();
82  if (width!=collapsedWidth) {
83  if (width<desktop_vp && collapsedWidth>=desktop_vp) {
84  if (!collapsed) {
85  collapseExpand();
86  }
87  } else if (width>desktop_vp && collapsedWidth<desktop_vp) {
88  if (collapsed) {
89  collapseExpand();
90  }
91  }
92  collapsedWidth=width;
93  }
94  (document.getElementById(location.hash.slice(1))||document.body).scrollIntoView();
95  }
96 
97  function collapseExpand()
98  {
99  if (sidenav.width()>0) {
100  restoreWidth(0);
101  collapsed=true;
102  }
103  else {
104  var width = readCookie('width');
105  if (width>200 && width<$(window).width()) { restoreWidth(width); } else { restoreWidth(200); }
106  collapsed=false;
107  }
108  }
109 
110  header = $("#top");
111  sidenav = $("#side-nav");
112  content = $("#doc-content");
113  navtree = $("#nav-tree");
114  footer = $("#nav-path");
115  $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } });
116  $(sidenav).resizable({ minWidth: 0 });
117  $(window).resize(function() { resizeHeight(); });
118  var device = navigator.userAgent.toLowerCase();
119  var touch_device = device.match(/(iphone|ipod|ipad|android)/);
120  if (touch_device) { /* wider split bar for touch only devices */
121  $(sidenav).css({ paddingRight:'20px' });
122  $('.ui-resizable-e').css({ width:'20px' });
123  $('#nav-sync').css({ right:'34px' });
124  barWidth=20;
125  }
126  var width = readCookie('width');
127  if (width) { restoreWidth(width); } else { resizeWidth(); }
128  resizeHeight();
129  var url = location.href;
130  var i=url.indexOf("#");
131  if (i>=0) window.location.hash=url.substr(i);
132  var _preventDefault = function(evt) { evt.preventDefault(); };
133  $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
134  $(".ui-resizable-handle").dblclick(collapseExpand);
135  $(window).on('load',resizeHeight);
136 }
137 /* @license-end */