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

Side by Side Diff: remoting/webapp/me2mom/modal.js

Issue 8416007: Refactored web-app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added consistency comment. Moved debug log keyboard shortcut handling. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview
garykac 2011/10/27 22:32:39 nit: something like 'appmode.js' sounds more descr
Jamie 2011/10/27 22:51:37 Done. I went with ui_mode.js, since the relevant t
7 * Functions related to controlling the modal ui state of the app.
8 */
9
10 'use strict';
11
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
14
15 /** @enum {string} */
16 remoting.AppMode = {
17 HOME: 'home',
18 UNAUTHENTICATED: 'auth',
19 CLIENT: 'client',
20 CLIENT_UNCONNECTED: 'client.unconnected',
21 CLIENT_CONNECTING: 'client.connecting',
22 CLIENT_CONNECT_FAILED: 'client.connect-failed',
23 CLIENT_SESSION_FINISHED: 'client.session-finished',
24 HOST: 'host',
25 HOST_WAITING_FOR_CODE: 'host.waiting-for-code',
26 HOST_WAITING_FOR_CONNECTION: 'host.waiting-for-connection',
27 HOST_SHARED: 'host.shared',
28 HOST_SHARE_FAILED: 'host.share-failed',
29 HOST_SHARE_FINISHED: 'host.share-finished',
30 IN_SESSION: 'in-session'
31 };
32
33 /**
34 * @type {remoting.AppMode} The current app mode
35 */
36 remoting.currentMode;
37
38 /**
39 * Change the app's modal state to |mode|, which is considered to be a dotted
40 * hierachy of modes. For example, setMode('host.shared') will show any modal
41 * elements with an data-ui-mode attribute of 'host' or 'host.shared' and hide
42 * all others.
43 *
44 * @param {remoting.AppMode} mode The new modal state, expressed as a dotted
45 * hiearchy.
46 */
47 remoting.setMode = function(mode) {
48 var modes = mode.split('.');
49 for (var i = 1; i < modes.length; ++i)
50 modes[i] = modes[i - 1] + '.' + modes[i];
51 var elements = document.querySelectorAll('[data-ui-mode]');
52 for (var i = 0; i < elements.length; ++i) {
53 var element = /** @type {Element} */ elements[i];
54 var hidden = true;
55 for (var m = 0; m < modes.length; ++m) {
56 if (hasClass(element.getAttribute('data-ui-mode'), modes[m])) {
57 hidden = false;
58 break;
59 }
60 }
61 element.hidden = hidden;
62 }
63 remoting.debug.log('App mode: ' + mode);
64 remoting.currentMode = mode;
65 if (mode == remoting.AppMode.IN_SESSION) {
66 document.removeEventListener('keydown', remoting.DebugLog.onKeydown, false);
67 } else {
68 document.addEventListener('keydown', remoting.DebugLog.onKeydown, false);
69 }
70 };
71
72 /**
73 * Get the major mode that the app is running in.
74 * @return {string} The app's current major mode.
75 */
76 remoting.getMajorMode = function() {
77 return remoting.currentMode.split('.')[0];
78 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698