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

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

Issue 10832191: Major revision of page cycler UI. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Newer version with requested decomposition into separate sources 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 var CaptureTab = function (cyclerUI, cyclerData, playbackTab) {
6 // Members for all UI elements subject to programmatic adjustment.
7 this.captureTab_ = $('#capture-tab');
8 this.captureName_ = $('#capture-name');
9 this.captureURLs_ = $('#capture-urls');
10 this.doCaptureButton_ = $('#do-capture');
11
12 // References to other major components of the extension.
13 this.cyclerUI_ = cyclerUI;
14 this.cyclerData_ = cyclerData;
15 this.playbackTab_ = playbackTab;
16
17 /*
18 * Enable the capture tab.
19 */
20 this.enable = function() {
21 this.captureTab_.hidden = false;
22 };
23
24 /*
25 * Disable the capture tab.
26 */
27 this.disable = function() {
28 this.captureTab_.hidden = true;
29 };
30
31 /**
32 * Do a capture using current data from the capture tab. Post an error
33 * dialog if said data is incorrect or incomplete. Otherwise pass
34 * control to the browser side.
35 * @private
36 */
37 this.doCapture_ = function() {
38 var errors = [];
39 var captureName = this.captureName_.value.trim();
40 var urlList;
41
42 urlList = this.captureURLs_.value.split('\n');
43 if (captureName.length == 0)
44 errors.push('Must give a capture name');
45 if (urlList.length == 0)
46 errors.push('Must give at least one URL');
47
48 if (errors.length > 0) {
49 this.cyclerUI_.showMessage(errors.join('\n'), 'Ok');
50 } else {
51 this.doCaptureButton_.disabled = true;
52 chrome.experimental.record.captureURLs(captureName, urlList,
53 this.onCaptureDone.bind(this));
54 }
55 }
56
57 /**
58 * Callback for completed (or possibly failed) capture. Post a message
59 * box, either with errors or "Success!" message.
60 * @param {!Array.<string>} errors List of errors that occured
61 * during capture, if any.
62 */
63 this.onCaptureDone = function(errors) {
64 this.doCaptureButton_.disabled = false;
65
66 if (errors.length > 0) {
67 this.cyclerUI_.showMessage(errors.join('\n'), 'Ok');
68 } else {
69 this.cyclerUI_.showMessage('Success!', 'Ok');
70 this.cyclerUI_.currentCaptureName = this.captureName_.value.trim();
71 this.cyclerData_.saveCapture(this.cyclerUI_.currentCaptureName);
72 this.playbackTab_.updatePlaybackChoices_();
Jeffrey Yasskin 2012/08/15 01:03:59 It seems odd to update this here without showing t
clintstaley 2012/08/15 23:54:20 This is an asynchronous return, and it may be some
Jeffrey Yasskin 2012/08/16 20:19:31 Ah, yes. I hadn't thought of the user switching ta
clintstaley 2012/08/17 04:12:25 A later CL will include the ability to cancel an o
Jeffrey Yasskin 2012/08/17 19:32:14 You may want to make the cyclerData observable (ya
73 }
74 }
75
76 // Set up listener for capture button.
77 this.doCaptureButton_.addEventListener('click', this.doCapture_.bind(this));
78 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698