Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: components/supervised_user_error_page/resources/supervised_user_block_interstitial.js

Issue 2739473006: Update supervised user interstitial pages. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 var helpOuterBox = $('details');
29 var mainContent = $('information-container');
30 var requestAccessButton = $('request-access-button');
31
32 // Handle showing the top content / details sections according to state.
33 if (mobileNav) {
34 mainContent.hidden = showDetails;
35 requestAccessButton.hidden = showDetails;
36 helpOuterBox.hidden = !showDetails;
37 } else if (showDetails) {
38 // Non mobile nav with visible details.
39 mainContent.hidden = false;
40 requestAccessButton.hidden = false;
41 helpOuterBox.hidden = false;
42 }
43 }
44
45 function setupMobileNav() {
46 window.addEventListener('resize', onResize);
47 onResize();
48 }
49
50 document.addEventListener('DOMContentLoaded', setupMobileNav);
51
5 function sendCommand(cmd) { 52 function sendCommand(cmd) {
6 window.domAutomationController.setAutomationId(1); 53 window.domAutomationController.setAutomationId(1);
7 window.domAutomationController.send(cmd); 54 window.domAutomationController.send(cmd);
8 } 55 }
9 56
10 function makeImageSet(url1x, url2x) { 57 function makeImageSet(url1x, url2x) {
11 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)'; 58 return '-webkit-image-set(url(' + url1x + ') 1x, url(' + url2x + ') 2x)';
12 } 59 }
13 60
14 function initialize() { 61 function initialize() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 'secondCustodianEmail'); 97 'secondCustodianEmail');
51 } 98 }
52 } 99 }
53 var showDetailsLink = loadTimeData.getString('showDetailsLink'); 100 var showDetailsLink = loadTimeData.getString('showDetailsLink');
54 $('show-details-link').hidden = !showDetailsLink; 101 $('show-details-link').hidden = !showDetailsLink;
55 $('back-button').hidden = showDetailsLink || !window.domAutomationController; 102 $('back-button').hidden = showDetailsLink || !window.domAutomationController;
56 $('back-button').onclick = function(event) { 103 $('back-button').onclick = function(event) {
57 sendCommand('back'); 104 sendCommand('back');
58 }; 105 };
59 $('show-details-link').onclick = function(event) { 106 $('show-details-link').onclick = function(event) {
60 $('details').hidden = false; 107 showDetails = true;
61 $('show-details-link').hidden = true; 108 $('show-details-link').hidden = true;
62 $('hide-details-link').hidden = false; 109 $('hide-details-link').hidden = false;
63 $('information-container').classList.add('hidden-on-mobile'); 110 updateDetails();
64 $('request-access-button').classList.add('hidden-on-mobile');
65 }; 111 };
66 $('hide-details-link').onclick = function(event) { 112 $('hide-details-link').onclick = function(event) {
67 $('details').hidden = true; 113 showDetails = false;
68 $('show-details-link').hidden = false; 114 $('show-details-link').hidden = false;
69 $('hide-details-link').hidden = true; 115 $('hide-details-link').hidden = true;
70 $('information-container').classList.remove('hidden-on-mobile'); 116 updateDetails();
71 $('request-access-button').classList.remove('hidden-on-mobile');
72 }; 117 };
73 if (window.domAutomationController && 118 if (window.domAutomationController &&
74 loadTimeData.getBoolean('showFeedbackLink')) { 119 loadTimeData.getBoolean('showFeedbackLink')) {
75 $('feedback-link').onclick = function(event) { 120 $('feedback-link').onclick = function(event) {
76 sendCommand('feedback'); 121 sendCommand('feedback');
77 }; 122 };
78 } else { 123 } else {
79 $('feedback').hidden = true; 124 $('feedback').hidden = true;
80 } 125 }
81 } 126 }
82 127
83 /** 128 /**
84 * Updates the interstitial to show that the request failed or was sent. 129 * Updates the interstitial to show that the request failed or was sent.
85 * @param {boolean} isSuccessful Whether the request was successful or not. 130 * @param {boolean} isSuccessful Whether the request was successful or not.
86 */ 131 */
87 function setRequestStatus(isSuccessful) { 132 function setRequestStatus(isSuccessful) {
88 console.log('setRequestStatus(' + isSuccessful +')'); 133 console.log('setRequestStatus(' + isSuccessful +')');
89 $('block-page-header').hidden = true; 134 $('block-page-header').hidden = true;
90 $('block-page-message').hidden = true; 135 $('block-page-message').hidden = true;
91 if (isSuccessful) { 136 if (isSuccessful) {
92 $('request-failed-message').hidden = true; 137 $('request-failed-message').hidden = true;
93 $('request-sent-message').hidden = false; 138 $('request-sent-message').hidden = false;
94 $('show-details-link').hidden = true; 139 $('show-details-link').hidden = true;
95 $('hide-details-link').hidden = true; 140 $('hide-details-link').hidden = true;
96 $('details').hidden = true; 141 showDetails = false;
142 updateDetails();
97 $('back-button').hidden = !window.domAutomationController; 143 $('back-button').hidden = !window.domAutomationController;
98 $('request-access-button').hidden = true; 144 $('request-access-button').hidden = true;
99 } else { 145 } else {
100 $('request-failed-message').hidden = false; 146 $('request-failed-message').hidden = false;
101 $('request-access-button').hidden = false; 147 $('request-access-button').hidden = false;
102 } 148 }
103 } 149 }
104 150
105 document.addEventListener('DOMContentLoaded', initialize); 151 document.addEventListener('DOMContentLoaded', initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698