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

Side by Side Diff: chrome/browser/resources/md_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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 for (var j = i + 1; !before && j < this.items_.length; ++j) { 100 for (var j = i + 1; !before && j < this.items_.length; ++j) {
101 if (this.items_[j].parentNode) 101 if (this.items_[j].parentNode)
102 before = this.items_[j]; 102 before = this.items_[j];
103 } 103 }
104 // If |before| is null, |item| will just get added at the end. 104 // If |before| is null, |item| will just get added at the end.
105 this.node_.insertBefore(item, before); 105 this.node_.insertBefore(item, before);
106 } 106 }
107 107
108 var noDownloadsOrResults = $('no-downloads-or-results'); 108 var noDownloadsOrResults = $('no-downloads-or-results');
109 noDownloadsOrResults.textContent = loadTimeData.getString( 109 noDownloadsOrResults.textContent = loadTimeData.getString(
110 this.searchText_ ? 'no_search_results' : 'no_downloads'); 110 this.searchText_ ? 'noSearchResults' : 'noDownloads');
111 111
112 var hasDownloads = this.size_() > 0; 112 var hasDownloads = this.size_() > 0;
113 this.node_.hidden = !hasDownloads; 113 this.node_.hidden = !hasDownloads;
114 noDownloadsOrResults.hidden = hasDownloads; 114 noDownloadsOrResults.hidden = hasDownloads;
115 115
116 if (loadTimeData.getBoolean('allow_deleting_history')) 116 if (loadTimeData.getBoolean('allowDeletingHistory'))
117 $('clear-all').hidden = !hasDownloads || this.searchText_.length > 0; 117 $('clear-all').hidden = !hasDownloads || this.searchText_.length > 0;
118 }, 118 },
119 119
120 /** 120 /**
121 * @param {!downloads.Data} data 121 * @param {!downloads.Data} data
122 * @private 122 * @private
123 */ 123 */
124 updateItem_: function(data) { 124 updateItem_: function(data) {
125 this.idMap_[data.id].update(data); 125 this.idMap_[data.id].update(data);
126 }, 126 },
127 127
128 /** 128 /**
129 * @return {number} The number of downloads shown on the page. 129 * @return {number} The number of downloads shown on the page.
130 * @private 130 * @private
131 */ 131 */
132 size_: function() { 132 size_: function() {
133 return this.items_.length; 133 return this.items_.length;
134 }, 134 },
135 135
136 /** @private */ 136 /** @private */
137 clearAll_: function() { 137 clearAll_: function() {
138 if (loadTimeData.getBoolean('allow_deleting_history')) { 138 if (loadTimeData.getBoolean('allowDeletingHistory')) {
139 chrome.send('clearAll'); 139 chrome.send('clearAll');
140 this.setSearchText_(''); 140 this.setSearchText_('');
141 } 141 }
142 }, 142 },
143 143
144 /** @private */ 144 /** @private */
145 onLoad_: function() { 145 onLoad_: function() {
146 this.node_ = $('downloads-display'); 146 this.node_ = $('downloads-display');
147 147
148 $('clear-all').onclick = function() { 148 $('clear-all').onclick = function() {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 }; 225 };
226 226
227 Manager.size = function() { 227 Manager.size = function() {
228 return Manager.getInstance().size_(); 228 return Manager.getInstance().size_();
229 }; 229 };
230 230
231 return {Manager: Manager}; 231 return {Manager: Manager};
232 }); 232 });
233 233
234 window.addEventListener('load', downloads.Manager.onLoad); 234 window.addEventListener('load', downloads.Manager.onLoad);
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_downloads/item_view.js ('k') | chrome/browser/ui/webui/downloads_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698