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

Side by Side Diff: remoting/webapp/crd/js/event_handlers.js

Issue 742473002: [Chromoting] Break up the webapp's init function into smaller chunks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browsertest break by removing onload handler Created 6 years 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
« no previous file with comments | « remoting/webapp/crd/js/crd_main.js ('k') | remoting/webapp/crd/js/remoting.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 'use strict'; 5 'use strict';
6 6
7 /** @suppress {duplicate} */ 7 /** @suppress {duplicate} */
8 var remoting = remoting || {}; 8 var remoting = remoting || {};
9 9
10 function onLoad() { 10 remoting.initEventHandlers = function() {
11 var goHome = function() { 11 var goHome = function() {
12 remoting.setMode(remoting.AppMode.HOME); 12 remoting.setMode(remoting.AppMode.HOME);
13 }; 13 };
14 var goEnterAccessCode = function() { 14 var goEnterAccessCode = function() {
15 // We don't need a token until we authenticate, but asking for one here 15 // We don't need a token until we authenticate, but asking for one here
16 // handles the token-expired case earlier, avoiding asking the user for 16 // handles the token-expired case earlier, avoiding asking the user for
17 // the access code both before and after re-authentication. 17 // the access code both before and after re-authentication.
18 remoting.identity.callWithToken( 18 remoting.identity.callWithToken(
19 /** @param {string} token */ 19 /** @param {string} token */
20 function(token) { 20 function(token) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 { event: 'click', id: 'auth-button', fn: doAuthRedirect }, 108 { event: 'click', id: 'auth-button', fn: doAuthRedirect },
109 { event: 'click', id: 'cancel-connect-button', fn: goHome }, 109 { event: 'click', id: 'cancel-connect-button', fn: goHome },
110 { event: 'click', id: 'sign-out', fn:remoting.signOut }, 110 { event: 'click', id: 'sign-out', fn:remoting.signOut },
111 { event: 'click', id: 'token-refresh-error-ok', fn: goHome }, 111 { event: 'click', id: 'token-refresh-error-ok', fn: goHome },
112 { event: 'click', id: 'token-refresh-error-sign-in', fn: fixAuthError } 112 { event: 'click', id: 'token-refresh-error-sign-in', fn: fixAuthError }
113 ]; 113 ];
114 registerEventListeners(it2me_actions); 114 registerEventListeners(it2me_actions);
115 registerEventListeners(me2me_actions); 115 registerEventListeners(me2me_actions);
116 registerEventListeners(host_actions); 116 registerEventListeners(host_actions);
117 registerEventListeners(auth_actions); 117 registerEventListeners(auth_actions);
118 remoting.init();
119 118
120 window.addEventListener('resize', remoting.onResize, false); 119 window.addEventListener('resize', remoting.onResize, false);
121 // When a window goes full-screen, a resize event is triggered, but the 120 // When a window goes full-screen, a resize event is triggered, but the
122 // Fullscreen.isActive call is not guaranteed to return true until the 121 // Fullscreen.isActive call is not guaranteed to return true until the
123 // full-screen event is triggered. In apps v2, the size of the window's 122 // full-screen event is triggered. In apps v2, the size of the window's
124 // client area is calculated differently in full-screen mode, so register 123 // client area is calculated differently in full-screen mode, so register
125 // for both events. 124 // for both events.
126 remoting.fullscreen.addListener(remoting.onResize); 125 remoting.fullscreen.addListener(remoting.onResize);
127 if (!base.isAppsV2()) { 126 if (!base.isAppsV2()) {
128 window.addEventListener('beforeunload', remoting.promptClose, false); 127 window.addEventListener('beforeunload', remoting.promptClose, false);
(...skipping 21 matching lines...) Expand all
150 function registerEventListener(id, eventname, fn) { 149 function registerEventListener(id, eventname, fn) {
151 var element = document.getElementById(id); 150 var element = document.getElementById(id);
152 if (element) { 151 if (element) {
153 element.addEventListener(eventname, fn, false); 152 element.addEventListener(eventname, fn, false);
154 } else { 153 } else {
155 console.error('Could not set ' + eventname + 154 console.error('Could not set ' + eventname +
156 ' event handler on element ' + id + 155 ' event handler on element ' + id +
157 ': element not found.'); 156 ': element not found.');
158 } 157 }
159 } 158 }
160
161 window.addEventListener('load', onLoad, false);
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/crd_main.js ('k') | remoting/webapp/crd/js/remoting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698