resize.js (5054B)
1/* 2 @licstart The following is the entire license notice for the JavaScript code in this file. 3 4 The MIT License (MIT) 5 6 Copyright (C) 1997-2020 by Dimitri van Heesch 7 8 Permission is hereby granted, free of charge, to any person obtaining a copy of this software 9 and associated documentation files (the "Software"), to deal in the Software without restriction, 10 including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 furnished to do so, subject to the following conditions: 13 14 The above copyright notice and this permission notice shall be included in all copies or 15 substantial portions of the Software. 16 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 18 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 23 @licend The above is the entire license notice for the JavaScript code in this file 24 */ 25function initResizable() 26{ 27 var cookie_namespace = 'doxygen'; 28 var sidenav,navtree,content,header,collapsed,collapsedWidth=0,barWidth=6,desktop_vp=768,titleHeight; 29 30 function readCookie(cookie) 31 { 32 var myCookie = cookie_namespace+"_"+cookie+"="; 33 if (document.cookie) { 34 var index = document.cookie.indexOf(myCookie); 35 if (index != -1) { 36 var valStart = index + myCookie.length; 37 var valEnd = document.cookie.indexOf(";", valStart); 38 if (valEnd == -1) { 39 valEnd = document.cookie.length; 40 } 41 var val = document.cookie.substring(valStart, valEnd); 42 return val; 43 } 44 } 45 return 0; 46 } 47 48 function writeCookie(cookie, val, expiration) 49 { 50 if (val==undefined) return; 51 if (expiration == null) { 52 var date = new Date(); 53 date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week 54 expiration = date.toGMTString(); 55 } 56 document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; expires=" + expiration+"; path=/"; 57 } 58 59 function resizeWidth() 60 { 61 var windowWidth = $(window).width() + "px"; 62 var sidenavWidth = $(sidenav).outerWidth(); 63 content.css({marginLeft:parseInt(sidenavWidth)+"px"}); 64 writeCookie('width',sidenavWidth-barWidth, null); 65 } 66 67 function restoreWidth(navWidth) 68 { 69 var windowWidth = $(window).width() + "px"; 70 content.css({marginLeft:parseInt(navWidth)+barWidth+"px"}); 71 sidenav.css({width:navWidth + "px"}); 72 } 73 74 function resizeHeight() 75 { 76 var headerHeight = header.outerHeight(); 77 var footerHeight = footer.outerHeight(); 78 var windowHeight = $(window).height() - headerHeight - footerHeight; 79 content.css({height:windowHeight + "px"}); 80 navtree.css({height:windowHeight + "px"}); 81 sidenav.css({height:windowHeight + "px"}); 82 var width=$(window).width(); 83 if (width!=collapsedWidth) { 84 if (width<desktop_vp && collapsedWidth>=desktop_vp) { 85 if (!collapsed) { 86 collapseExpand(); 87 } 88 } else if (width>desktop_vp && collapsedWidth<desktop_vp) { 89 if (collapsed) { 90 collapseExpand(); 91 } 92 } 93 collapsedWidth=width; 94 } 95 if (location.hash.slice(1)) { 96 (document.getElementById(location.hash.slice(1))||document.body).scrollIntoView(); 97 } 98 } 99 100 function collapseExpand() 101 { 102 if (sidenav.width()>0) { 103 restoreWidth(0); 104 collapsed=true; 105 } 106 else { 107 var width = readCookie('width'); 108 if (width>200 && width<$(window).width()) { restoreWidth(width); } else { restoreWidth(200); } 109 collapsed=false; 110 } 111 } 112 113 header = $("#top"); 114 sidenav = $("#side-nav"); 115 content = $("#doc-content"); 116 navtree = $("#nav-tree"); 117 footer = $("#nav-path"); 118 $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } }); 119 $(sidenav).resizable({ minWidth: 0 }); 120 $(window).resize(function() { resizeHeight(); }); 121 var device = navigator.userAgent.toLowerCase(); 122 var touch_device = device.match(/(iphone|ipod|ipad|android)/); 123 if (touch_device) { /* wider split bar for touch only devices */ 124 $(sidenav).css({ paddingRight:'20px' }); 125 $('.ui-resizable-e').css({ width:'20px' }); 126 $('#nav-sync').css({ right:'34px' }); 127 barWidth=20; 128 } 129 var width = readCookie('width'); 130 if (width) { restoreWidth(width); } else { resizeWidth(); } 131 resizeHeight(); 132 var url = location.href; 133 var i=url.indexOf("#"); 134 if (i>=0) window.location.hash=url.substr(i); 135 var _preventDefault = function(evt) { evt.preventDefault(); }; 136 $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault); 137 $(".ui-resizable-handle").dblclick(collapseExpand); 138 $(window).on('load',resizeHeight); 139} 140/* @license-end */