]> begriffs open source - cmsis/blob - v6.1.0-rc1/Driver/resize.js
Update documentation for release v6.1.0
[cmsis] / v6.1.0-rc1 / Driver / resize.js
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  */
25 var once=1;
26 function initResizable()
27 {
28   var cookie_namespace = 'doxygen';
29   var sidenav,navtree,content,header,barWidth=6,desktop_vp=768,titleHeight;
30
31   function readSetting(cookie)
32   {
33     if (window.chrome) {
34       var val = localStorage.getItem(cookie_namespace+'_width');
35       if (val) return val;
36     } else {
37       var myCookie = cookie_namespace+"_"+cookie+"=";
38       if (document.cookie) {
39         var index = document.cookie.indexOf(myCookie);
40         if (index != -1) {
41           var valStart = index + myCookie.length;
42           var valEnd = document.cookie.indexOf(";", valStart);
43           if (valEnd == -1) {
44             valEnd = document.cookie.length;
45           }
46           var val = document.cookie.substring(valStart, valEnd);
47           return val;
48         }
49       }
50     }
51     return 0;
52   }
53
54   function writeSetting(cookie, val)
55   {
56     if (window.chrome) {
57       localStorage.setItem(cookie_namespace+"_width",val);
58     } else {
59       var date = new Date();
60       date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week
61       expiration = date.toGMTString();
62       document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; SameSite=Lax; expires=" + expiration+"; path=/";
63     }
64   }
65
66   function resizeWidth()
67   {
68     var windowWidth = $(window).width() + "px";
69     var sidenavWidth = $(sidenav).outerWidth();
70     content.css({marginLeft:parseInt(sidenavWidth)+"px"});
71     if (typeof page_layout!=='undefined' && page_layout==1) {
72       footer.css({marginLeft:parseInt(sidenavWidth)+"px"});
73     }
74     writeSetting('width',sidenavWidth-barWidth);
75   }
76
77   function restoreWidth(navWidth)
78   {
79     var windowWidth = $(window).width() + "px";
80     content.css({marginLeft:parseInt(navWidth)+barWidth+"px"});
81     if (typeof page_layout!=='undefined' && page_layout==1) {
82       footer.css({marginLeft:parseInt(navWidth)+barWidth+"px"});
83     }
84     sidenav.css({width:navWidth + "px"});
85   }
86
87   function resizeHeight()
88   {
89     var headerHeight = header.outerHeight();
90     var footerHeight = footer.outerHeight();
91     var windowHeight = $(window).height();
92     var contentHeight,navtreeHeight,sideNavHeight;
93     if (typeof page_layout==='undefined' || page_layout==0) { /* DISABLE_INDEX=NO */
94       contentHeight = windowHeight - headerHeight - footerHeight;
95       navtreeHeight = contentHeight;
96       sideNavHeight = contentHeight;
97     } else if (page_layout==1) { /* DISABLE_INDEX=YES */
98       contentHeight = windowHeight - footerHeight;
99       navtreeHeight = windowHeight - headerHeight;
100       sideNavHeight = windowHeight;
101     }
102     content.css({height:contentHeight + "px"});
103     navtree.css({height:navtreeHeight + "px"});
104     sidenav.css({height:sideNavHeight + "px"});
105     if (location.hash.slice(1)) {
106       (document.getElementById(location.hash.slice(1))||document.body).scrollIntoView();
107     }
108   }
109
110   function collapseExpand()
111   {
112     var newWidth;
113     if (sidenav.width()>0) {
114       newWidth=0;
115     }
116     else {
117       var width = readSetting('width');
118       newWidth = (width>250 && width<$(window).width()) ? width : 250;
119     }
120     restoreWidth(newWidth);
121     var sidenavWidth = $(sidenav).outerWidth();
122     writeSetting('width',sidenavWidth-barWidth);
123   }
124
125   header  = $("#top");
126   sidenav = $("#side-nav");
127   content = $("#doc-content");
128   navtree = $("#nav-tree");
129   footer  = $("#nav-path");
130   $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } });
131   $(sidenav).resizable({ minWidth: 0 });
132   $(window).resize(function() { resizeHeight(); });
133   var device = navigator.userAgent.toLowerCase();
134   var touch_device = device.match(/(iphone|ipod|ipad|android)/);
135   if (touch_device) { /* wider split bar for touch only devices */
136     $(sidenav).css({ paddingRight:'20px' });
137     $('.ui-resizable-e').css({ width:'20px' });
138     $('#nav-sync').css({ right:'34px' });
139     barWidth=20;
140   }
141   var width = readSetting('width');
142   if (width) { restoreWidth(width); } else { resizeWidth(); }
143   resizeHeight();
144   var url = location.href;
145   var i=url.indexOf("#");
146   if (i>=0) window.location.hash=url.substr(i);
147   var _preventDefault = function(evt) { evt.preventDefault(); };
148   $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
149   if (once) {
150     $(".ui-resizable-handle").dblclick(collapseExpand);
151     once=0
152   }
153   $(window).on('load',resizeHeight);
154 }
155 /* @license-end */