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