OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 var mobileNav = false; |
| 6 |
| 7 var showDetails = false; |
| 8 |
| 9 /** |
| 10 * For small screen mobile the navigation buttons are moved |
| 11 * below the advanced text. |
| 12 */ |
| 13 function onResize() { |
| 14 var mediaQuery = '(min-width: 240px) and (max-width: 420px) and ' + |
| 15 '(max-height: 736px) and (min-height: 401px) and ' + |
| 16 '(orientation: portrait), (max-width: 736px) and ' + |
| 17 '(max-height: 420px) and (min-height: 240px) and ' + |
| 18 '(min-width: 421px) and (orientation: landscape)'; |
| 19 |
| 20 // Check for change in nav status. |
| 21 if (mobileNav != window.matchMedia(mediaQuery).matches) { |
| 22 mobileNav = !mobileNav; |
| 23 updateDetails(); |
| 24 } |
| 25 } |
| 26 |
| 27 function updateDetails() { |
| 28 $('information-container').hidden = mobileNav && showDetails; |
| 29 $('details').hidden = !showDetails; |
| 30 } |
| 31 |
| 32 function setupMobileNav() { |
| 33 window.addEventListener('resize', onResize); |
| 34 onResize(); |
| 35 } |
| 36 |
| 37 document.addEventListener('DOMContentLoaded', setupMobileNav); |
| 38 |
5 function sendCommand(cmd) { | 39 function sendCommand(cmd) { |
6 window.domAutomationController.setAutomationId(1); | 40 window.domAutomationController.setAutomationId(1); |
7 window.domAutomationController.send(cmd); | 41 window.domAutomationController.send(cmd); |
8 } | 42 } |
9 | 43 |
10 function makeImageSet(url1x, url2x) { | 44 function makeImageSet(url1x, url2x) { |
11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; | 45 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; |
12 } | 46 } |
13 | 47 |
14 function initialize() { | 48 function initialize() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 'secondCustodianEmail'); | 84 'secondCustodianEmail'); |
51 } | 85 } |
52 } | 86 } |
53 var showDetailsLink = loadTimeData.getString('showDetailsLink'); | 87 var showDetailsLink = loadTimeData.getString('showDetailsLink'); |
54 $('show-details-link').hidden = !showDetailsLink; | 88 $('show-details-link').hidden = !showDetailsLink; |
55 $('back-button').hidden = showDetailsLink || !window.domAutomationController; | 89 $('back-button').hidden = showDetailsLink || !window.domAutomationController; |
56 $('back-button').onclick = function(event) { | 90 $('back-button').onclick = function(event) { |
57 sendCommand('back'); | 91 sendCommand('back'); |
58 }; | 92 }; |
59 $('show-details-link').onclick = function(event) { | 93 $('show-details-link').onclick = function(event) { |
60 $('details').hidden = false; | 94 showDetails = true; |
61 $('show-details-link').hidden = true; | 95 $('show-details-link').hidden = true; |
62 $('hide-details-link').hidden = false; | 96 $('hide-details-link').hidden = false; |
63 $('information-container').classList.add('hidden-on-mobile'); | 97 updateDetails(); |
64 $('request-access-button').classList.add('hidden-on-mobile'); | |
65 }; | 98 }; |
66 $('hide-details-link').onclick = function(event) { | 99 $('hide-details-link').onclick = function(event) { |
67 $('details').hidden = true; | 100 showDetails = false; |
68 $('show-details-link').hidden = false; | 101 $('show-details-link').hidden = false; |
69 $('hide-details-link').hidden = true; | 102 $('hide-details-link').hidden = true; |
70 $('information-container').classList.remove('hidden-on-mobile'); | 103 updateDetails(); |
71 $('request-access-button').classList.remove('hidden-on-mobile'); | |
72 }; | 104 }; |
73 if (window.domAutomationController && | 105 if (window.domAutomationController && |
74 loadTimeData.getBoolean('showFeedbackLink')) { | 106 loadTimeData.getBoolean('showFeedbackLink')) { |
75 $('feedback-link').onclick = function(event) { | 107 $('feedback-link').onclick = function(event) { |
76 sendCommand('feedback'); | 108 sendCommand('feedback'); |
77 }; | 109 }; |
78 } else { | 110 } else { |
79 $('feedback').hidden = true; | 111 $('feedback').hidden = true; |
80 } | 112 } |
81 } | 113 } |
82 | 114 |
83 /** | 115 /** |
84 * Updates the interstitial to show that the request failed or was sent. | 116 * Updates the interstitial to show that the request failed or was sent. |
85 * @param {boolean} isSuccessful Whether the request was successful or not. | 117 * @param {boolean} isSuccessful Whether the request was successful or not. |
86 */ | 118 */ |
87 function setRequestStatus(isSuccessful) { | 119 function setRequestStatus(isSuccessful) { |
88 console.log('setRequestStatus(' + isSuccessful +')'); | 120 console.log('setRequestStatus(' + isSuccessful +')'); |
89 $('block-page-header').hidden = true; | 121 $('block-page-header').hidden = true; |
90 $('block-page-message').hidden = true; | 122 $('block-page-message').hidden = true; |
| 123 $('hide-details-link').hidden = true; |
| 124 showDetails = false; |
| 125 updateDetails(); |
| 126 |
91 if (isSuccessful) { | 127 if (isSuccessful) { |
92 $('request-failed-message').hidden = true; | 128 $('request-failed-message').hidden = true; |
93 $('request-sent-message').hidden = false; | 129 $('request-sent-message').hidden = false; |
94 $('show-details-link').hidden = true; | |
95 $('hide-details-link').hidden = true; | |
96 $('details').hidden = true; | |
97 $('back-button').hidden = !window.domAutomationController; | 130 $('back-button').hidden = !window.domAutomationController; |
98 $('request-access-button').hidden = true; | 131 $('request-access-button').hidden = true; |
| 132 $('show-details-link').hidden = true; |
99 } else { | 133 } else { |
100 $('request-failed-message').hidden = false; | 134 $('request-failed-message').hidden = false; |
101 $('request-access-button').hidden = false; | 135 $('request-access-button').hidden = false; |
| 136 $('show-details-link').hidden = false; |
102 } | 137 } |
103 } | 138 } |
104 | 139 |
105 document.addEventListener('DOMContentLoaded', initialize); | 140 document.addEventListener('DOMContentLoaded', initialize); |
OLD | NEW |