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

Side by Side Diff: chrome/browser/resources/file_manager/js/progress_center_common.js

Issue 39123003: [Files.app] Split the JavaScript files into subdirectories: common, background, and foreground (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed test failure. Created 7 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 2013 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 'use strict';
6
7 /**
8 * Where to display the item.
9 * @enum {string}
10 * @const
11 */
12 var ProgressItemContainer = Object.freeze({
13 CLIENT: 'client',
14 NOTIFICATION: 'notification'
15 });
16
17 /**
18 * Event of the ProgressCenter class.
19 * @enum {string}
20 * @const
21 */
22 var ProgressCenterEvent = Object.freeze({
23 /**
24 * Background page notifies item update to application windows.
25 */
26 ITEM_UPDATED: 'itemUpdated',
27
28 /**
29 * Background page notifies all the items are cleared.
30 */
31 RESET: 'reset'
32 });
33
34 /**
35 * State of progress items.
36 * @enum {string}
37 * @const
38 */
39 var ProgressItemState = Object.freeze({
40 PROGRESSING: 'progressing',
41 COMPLETE: 'complete',
42 ERROR: 'error',
43 CANCELED: 'canceled'
44 });
45
46 /**
47 * Item of the progress center.
48 * @constructor
49 */
50 var ProgressCenterItem = function() {
51 /**
52 * Item ID.
53 * @type {string}
54 * @private
55 */
56 this.id_ = null;
57
58 /**
59 * State of the progress item.
60 * @type {ProgressItemState}
61 */
62 this.state = ProgressItemState.PROGRESSING;
63
64 /**
65 * Message of the progress item.
66 * @type {string}
67 */
68 this.message = '';
69
70 /**
71 * Max value of the progress.
72 * @type {number}
73 */
74 this.progressMax = 0;
75
76 /**
77 * Current value of the progress.
78 * @type {number}
79 */
80 this.progressValue = 0;
81
82 /**
83 * Where to the item is displayed.
84 * @type {ProgressItemContainer}
85 */
86 this.container = ProgressItemContainer.CLIENT;
87
88 /**
89 * Whether the item is summarized item or not.
90 * @type {boolean}
91 */
92 this.summarized = false;
93
94 /**
95 * Callback function to cancel the item.
96 * @type {function()}
97 */
98 this.cancelCallback = null;
99
100 Object.seal(this);
101 };
102
103 ProgressCenterItem.prototype = {
104 /**
105 * Setter of Item ID.
106 * @param {string} value New value of ID.
107 */
108 set id(value) {
109 if (!this.id_)
110 this.id_ = value;
111 else
112 console.error('The ID is already set. (current ID: ' + this.id_ + ')');
113 },
114
115 /**
116 * Getter of Item ID.
117 * @return {string} Item ID.
118 */
119 get id() {
120 return this.id_;
121 },
122
123 /**
124 * Gets progress rate by percent.
125 * @return {number} Progress rate by percent.
126 */
127 get progressRateByPercent() {
128 return ~~(100 * this.progressValue / this.progressMax);
129 },
130
131 /**
132 * Whether the item can be canceled or not.
133 * @return {boolean} True if the item can be canceled.
134 */
135 get cancelable() {
136 return !!(this.state == ProgressItemState.PROGRESSING &&
137 this.cancelCallback &&
138 !this.summarized);
139 }
140 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/progress_center.js ('k') | chrome/browser/resources/file_manager/js/scrollbar.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698