|
106 | 106 | return (elem.offsetParent === null)
|
107 | 107 | }
|
108 | 108 |
|
| 109 | + function showSidebar() { |
| 110 | + var elems = document.getElementsByClassName("sidebar-elems")[0]; |
| 111 | + if (elems) { |
| 112 | + elems.style.display = "block"; |
| 113 | + } |
| 114 | + var sidebar = document.getElementsByClassName('sidebar')[0]; |
| 115 | + sidebar.style.position = 'fixed'; |
| 116 | + sidebar.style.width = '100%'; |
| 117 | + sidebar.style.marginLeft = '0'; |
| 118 | + document.getElementsByTagName("body")[0].style.marginTop = '45px'; |
| 119 | + } |
| 120 | + |
| 121 | + function hideSidebar() { |
| 122 | + var elems = document.getElementsByClassName("sidebar-elems")[0]; |
| 123 | + if (elems) { |
| 124 | + elems.style.display = ""; |
| 125 | + } |
| 126 | + var sidebar = document.getElementsByClassName('sidebar')[0]; |
| 127 | + sidebar.style.position = ''; |
| 128 | + sidebar.style.width = ''; |
| 129 | + sidebar.style.marginLeft = ''; |
| 130 | + document.getElementsByTagName("body")[0].style.marginTop = ''; |
| 131 | + } |
| 132 | + |
109 | 133 | // used for special search precedence
|
110 | 134 | var TY_PRIMITIVE = itemTypes.indexOf("primitive");
|
111 | 135 |
|
|
130 | 154 | }
|
131 | 155 |
|
132 | 156 | function highlightSourceLines(ev) {
|
| 157 | + // If we're in mobile mode, we should add the sidebar in any case. |
| 158 | + hideSidebar(); |
133 | 159 | var search = document.getElementById("search");
|
134 | 160 | var i, from, to, match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
|
135 | 161 | if (match) {
|
|
1459 | 1485 |
|
1460 | 1486 | // delayed sidebar rendering.
|
1461 | 1487 | function initSidebarItems(items) {
|
1462 |
| - var sidebar = document.getElementsByClassName('sidebar')[0]; |
| 1488 | + var sidebar = document.getElementsByClassName('sidebar-elems')[0]; |
1463 | 1489 | var current = window.sidebarCurrent;
|
1464 | 1490 |
|
1465 | 1491 | function block(shortty, longty) {
|
|
1829 | 1855 | removeClass(search, "hidden");
|
1830 | 1856 | search.innerHTML = '<h3 style="text-align: center;">Loading search results...</h3>';
|
1831 | 1857 | }
|
| 1858 | + |
| 1859 | + var sidebar_menu = document.getElementsByClassName("sidebar-menu")[0]; |
| 1860 | + if (sidebar_menu) { |
| 1861 | + sidebar_menu.onclick = function() { |
| 1862 | + var sidebar = document.getElementsByClassName('sidebar')[0]; |
| 1863 | + if (sidebar.style.position === "fixed") { |
| 1864 | + hideSidebar(); |
| 1865 | + } else { |
| 1866 | + showSidebar(); |
| 1867 | + } |
| 1868 | + }; |
| 1869 | + } |
| 1870 | + |
| 1871 | + window.onresize = function() { |
| 1872 | + hideSidebar(); |
| 1873 | + }; |
1832 | 1874 | }());
|
1833 | 1875 |
|
1834 | 1876 | // Sets the focus on the search bar at the top of the page
|
|
0 commit comments