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

Side by Side Diff: chrome/common/extensions/docs/examples/apps/cycler/cycler_ui.js

Issue 10832191: Major revision of page cycler UI. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixes per jyasskin Created 8 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 function $(criterion) {
6 return document.querySelector(criterion);
7 }
8
9 var cyclerUI = new (function () {
10
11 /**
12 * Enum for different UI states.
13 * @enum {number}
14 * @private
15 */
16 var EnableState_ = {capture: 0, playback: 1};
17
18 this.cyclerData_ = new CyclerData();
19
20 // Members for all UI elements subject to programmatic adjustment.
21 this.captureTabLabel_ = $('#capture-tab-label');
22 this.playbackTabLabel_ = $('#playback-tab-label');
23
24 this.playbackTab_ = new PlaybackTab(this, this.cyclerData_);
25 this.captureTab_ = new CaptureTab(this, this.cyclerData_, this.playbackTab_);
26
27 this.popupDialog_ = $('#popup');
28 this.popupContent_ = $('#popup-content');
29 this.doPopupDismiss_ = $('#do-popup-dismiss');
30
31 /**
32 * Name of the most recent capture made, or the one most recently chosen
33 * for playback.
34 * @type {!string}
35 */
36 this.currentCaptureName = null;
37
38 /**
39 * Current state of tab enables.
Jeffrey Yasskin 2012/08/16 20:19:31 Try not to just restate the name of a variable in
clintstaley 2012/08/17 04:12:25 Done.
40 * @type {number}
41 */
42 this.enableState = null;
43
44 /*
45 * Enable the capture tab, changing tab labels approproiately.
46 * @private
47 */
48 this.enableCapture_ = function() {
49 if (this.enableState != EnableState_.capture) {
50 this.enableState = EnableState_.capture;
51
52 this.captureTab_.enable();
53 this.playbackTab_.disable();
54 }
55 };
56
57 /*
58 * Enable the playback tab, changing tab labels approproiately.
59 * @private
60 */
61 this.enablePlayback_ = function() {
62 if (this.enableState != EnableState_.playback) {
63 this.enableState = EnableState_.playback;
64
65 this.captureTab_.disable();
66 this.playbackTab_.enable();
67 }
68 };
69
70 /**
71 * Show an overlay with a message, a dismiss button with configurable
72 * label, and an action to call upon dismissal.
73 * @param {!string} content The message to display.
74 * @param {!string} dismissLabel The label on the dismiss button.
75 * @param {function()} action Additional action to take, if any, upon
76 * dismissal.
77 */
78 this.showMessage = function(content, dismissLabel, action) {
79 this.popupContent_.innerText = content;
80 this.doPopupDismiss_.innerText = dismissLabel;
81 this.popupDialog_.hidden = false;
82 if (action != null)
83 doPopupDismiss_.addEventListener('click', action);
84 }
85
86 /**
87 * Default action for popup dismissal button, performed in addition to
88 * any other actions that may be specified in showMessage_ call.
89 * @private
90 */
91 this.clearMessage_ = function() {
92 this.popupDialog_.hidden = true;
93 }
94
95 // Set up listeners on all buttons.
96 this.doPopupDismiss_.addEventListener('click', this.clearMessage_.bind(this));
97
98 // Set up listeners on tab labels.
99 this.captureTabLabel_.addEventListener('click',
100 this.enableCapture_.bind(this));
101 this.playbackTabLabel_.addEventListener('click',
102 this.enablePlayback_.bind(this));
103
104 // Start with capture tab displayed.
105 this.enableCapture_();
106 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698