blob: cb75d9f282beac8967f8d38676b590bbbea4213e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var mobileNav = false;
/**
* For small screen mobile the navigation buttons are moved
* below the advanced text.
*/
function onResize() {
var helpOuterBox = document.querySelector('#details');
var mainContent = document.querySelector('#main-content');
var mediaQuery = '(min-width: 240px) and (max-width: 420px) and ' +
'(max-height: 736px) and (orientation: portrait),' +
'(max-width: 736px) and (max-height: 420px) and (orientation: landscape)';
var detailsHidden = helpOuterBox.classList.contains('hidden');
var runnerContainer = document.querySelector('.runner-container');
// Check for change in nav status.
if (mobileNav != window.matchMedia(mediaQuery).matches) {
mobileNav = !mobileNav;
// Handle showing the top content / details sections according to state.
if (mobileNav) {
mainContent.classList.toggle('hidden', !detailsHidden);
helpOuterBox.classList.toggle('hidden', detailsHidden);
if (runnerContainer) {
runnerContainer.classList.toggle('hidden', !detailsHidden);
}
} else if (!detailsHidden) {
// Non mobile nav with visible details.
mainContent.classList.remove('hidden');
helpOuterBox.classList.remove('hidden');
if (runnerContainer) {
runnerContainer.classList.remove('hidden');
}
}
}
}
function setupMobileNav() {
window.addEventListener('resize', onResize);
onResize();
}
document.addEventListener('DOMContentLoaded', setupMobileNav);
|