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

Side by Side Diff: chrome/browser/resources/downloads/manager.js

Issue 1228263002: Fix downloads-related web_dev_style presubmit issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dl-rough-draft2
Patch Set: Created 5 years, 5 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 cr.define('downloads', function() { 5 cr.define('downloads', function() {
6 /** 6 /**
7 * Class to own and manage download items. 7 * Class to own and manage download items.
8 * @constructor 8 * @constructor
9 */ 9 */
10 function Manager() {} 10 function Manager() {}
11 11
12 cr.addSingletonGetter(Manager); 12 cr.addSingletonGetter(Manager);
13 13
14 Manager.prototype = { 14 Manager.prototype = {
15 /** @private {string} */ 15 /** @private {string} */
16 searchText_: '', 16 searchText_: '',
17 17
18 /** 18 /**
19 * Sets the search text, updates related UIs, and tells the browser. 19 * Sets the search text, updates related UIs, and tells the browser.
20 * @param {string} searchText Text we're searching for. 20 * @param {string} searchText Text we're searching for.
21 * @private 21 * @private
22 */ 22 */
23 setSearchText_: function(searchText) { 23 setSearchText_: function(searchText) {
24 this.searchText_ = searchText; 24 this.searchText_ = searchText;
25 25
26 $('downloads-summary-text').textContent = this.searchText_ ? 26 $('downloads-summary-text').textContent = this.searchText_ ?
27 loadTimeData.getStringF('searchresultsfor', this.searchText_) : ''; 27 loadTimeData.getStringF('searchResultsFor', this.searchText_) : '';
28 28
29 // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']). 29 // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']).
30 function trim(s) { return s.trim(); } 30 function trim(s) { return s.trim(); }
31 chrome.send('getDownloads', searchText.split(/"([^"]*)"/).map(trim)); 31 chrome.send('getDownloads', searchText.split(/"([^"]*)"/).map(trim));
32 }, 32 },
33 33
34 /** 34 /**
35 * @return {number} A guess at how many items could be visible at once. 35 * @return {number} A guess at how many items could be visible at once.
36 * @private 36 * @private
37 */ 37 */
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 for (var j = i + 1; !before && j < this.items_.length; ++j) { 102 for (var j = i + 1; !before && j < this.items_.length; ++j) {
103 if (this.items_[j].node.parentNode) 103 if (this.items_[j].node.parentNode)
104 before = this.items_[j].node; 104 before = this.items_[j].node;
105 } 105 }
106 // If |before| is null, |item| will just get added at the end. 106 // If |before| is null, |item| will just get added at the end.
107 this.node_.insertBefore(item.node, before); 107 this.node_.insertBefore(item.node, before);
108 } 108 }
109 109
110 var noDownloadsOrResults = $('no-downloads-or-results'); 110 var noDownloadsOrResults = $('no-downloads-or-results');
111 noDownloadsOrResults.textContent = loadTimeData.getString( 111 noDownloadsOrResults.textContent = loadTimeData.getString(
112 this.searchText_ ? 'no_search_results' : 'no_downloads'); 112 this.searchText_ ? 'noSearchResults' : 'noDownloads');
113 113
114 var hasDownloads = this.size_() > 0; 114 var hasDownloads = this.size_() > 0;
115 this.node_.hidden = !hasDownloads; 115 this.node_.hidden = !hasDownloads;
116 noDownloadsOrResults.hidden = hasDownloads; 116 noDownloadsOrResults.hidden = hasDownloads;
117 117
118 if (loadTimeData.getBoolean('allow_deleting_history')) 118 if (loadTimeData.getBoolean('allowDeletingHistory'))
119 $('clear-all').hidden = !hasDownloads || this.searchText_.length > 0; 119 $('clear-all').hidden = !hasDownloads || this.searchText_.length > 0;
120 120
121 this.rebuildFocusGrid_(); 121 this.rebuildFocusGrid_();
122 }, 122 },
123 123
124 /** 124 /**
125 * @param {!downloads.Data} data Info about the item to update. 125 * @param {!downloads.Data} data Info about the item to update.
126 * @private 126 * @private
127 */ 127 */
128 updateItem_: function(data) { 128 updateItem_: function(data) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 /** 174 /**
175 * @return {number} The number of downloads shown on the page. 175 * @return {number} The number of downloads shown on the page.
176 * @private 176 * @private
177 */ 177 */
178 size_: function() { 178 size_: function() {
179 return this.items_.length; 179 return this.items_.length;
180 }, 180 },
181 181
182 /** @private */ 182 /** @private */
183 clearAll_: function() { 183 clearAll_: function() {
184 if (loadTimeData.getBoolean('allow_deleting_history')) { 184 if (loadTimeData.getBoolean('allowDeletingHistory')) {
185 chrome.send('clearAll'); 185 chrome.send('clearAll');
186 this.setSearchText_(''); 186 this.setSearchText_('');
187 } 187 }
188 }, 188 },
189 189
190 /** @private */ 190 /** @private */
191 onLoad_: function() { 191 onLoad_: function() {
192 this.node_ = $('downloads-display'); 192 this.node_ = $('downloads-display');
193 193
194 $('clear-all').onclick = function() { 194 $('clear-all').onclick = function() {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 }; 255 };
256 256
257 Manager.size = function() { 257 Manager.size = function() {
258 return Manager.getInstance().size_(); 258 return Manager.getInstance().size_();
259 }; 259 };
260 260
261 return {Manager: Manager}; 261 return {Manager: Manager};
262 }); 262 });
263 263
264 window.addEventListener('DOMContentLoaded', downloads.Manager.onLoad); 264 window.addEventListener('DOMContentLoaded', downloads.Manager.onLoad);
OLDNEW
« no previous file with comments | « chrome/browser/resources/downloads/item_view.js ('k') | chrome/browser/resources/md_downloads/downloads.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698