Jenkins | 514be65 | 2019-02-28 12:25:18 +0000 | [diff] [blame^] | 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 | */ |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 24 | function initResizable() |
| 25 | { |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 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 | } |
| 95 | |
| 96 | function collapseExpand() |
| 97 | { |
| 98 | if (sidenav.width()>0) { |
| 99 | restoreWidth(0); |
| 100 | collapsed=true; |
| 101 | } |
| 102 | else { |
| 103 | var width = readCookie('width'); |
| 104 | if (width>200 && width<$(window).width()) { restoreWidth(width); } else { restoreWidth(200); } |
| 105 | collapsed=false; |
| 106 | } |
| 107 | } |
| 108 | |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 109 | header = $("#top"); |
| 110 | sidenav = $("#side-nav"); |
| 111 | content = $("#doc-content"); |
| 112 | navtree = $("#nav-tree"); |
| 113 | footer = $("#nav-path"); |
| 114 | $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } }); |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 115 | $(sidenav).resizable({ minWidth: 0 }); |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 116 | $(window).resize(function() { resizeHeight(); }); |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 117 | var device = navigator.userAgent.toLowerCase(); |
| 118 | var touch_device = device.match(/(iphone|ipod|ipad|android)/); |
| 119 | if (touch_device) { /* wider split bar for touch only devices */ |
| 120 | $(sidenav).css({ paddingRight:'20px' }); |
| 121 | $('.ui-resizable-e').css({ width:'20px' }); |
| 122 | $('#nav-sync').css({ right:'34px' }); |
| 123 | barWidth=20; |
| 124 | } |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 125 | var width = readCookie('width'); |
| 126 | if (width) { restoreWidth(width); } else { resizeWidth(); } |
| 127 | resizeHeight(); |
| 128 | var url = location.href; |
| 129 | var i=url.indexOf("#"); |
| 130 | if (i>=0) window.location.hash=url.substr(i); |
| 131 | var _preventDefault = function(evt) { evt.preventDefault(); }; |
| 132 | $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault); |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 133 | $(".ui-resizable-handle").dblclick(collapseExpand); |
| 134 | $(window).load(resizeHeight); |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 135 | } |
Jenkins | 514be65 | 2019-02-28 12:25:18 +0000 | [diff] [blame^] | 136 | /* @license-end */ |