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

Side by Side Diff: chrome/browser/resources/md_history/history_item.js

Issue 2578013002: [MD History] clang-format all javascript. (Closed)
Patch Set: rebase Created 3 years, 12 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 /** 5 /**
6 * @param {!Element} root 6 * @param {!Element} root
7 * @param {?Element} boundary 7 * @param {?Element} boundary
8 * @param {cr.ui.FocusRow.Delegate} delegate 8 * @param {cr.ui.FocusRow.Delegate} delegate
9 * @constructor 9 * @constructor
10 * @extends {cr.ui.FocusRow} 10 * @extends {cr.ui.FocusRow}
11 */ 11 */
12 function HistoryFocusRow(root, boundary, delegate) { 12 function HistoryFocusRow(root, boundary, delegate) {
13 cr.ui.FocusRow.call(this, root, boundary, delegate); 13 cr.ui.FocusRow.call(this, root, boundary, delegate);
14 this.addItems(); 14 this.addItems();
15 } 15 }
16 16
17 HistoryFocusRow.prototype = { 17 HistoryFocusRow.prototype = {
18 __proto__: cr.ui.FocusRow.prototype, 18 __proto__: cr.ui.FocusRow.prototype,
19 19
20 /** @override */ 20 /** @override */
21 getCustomEquivalent: function(sampleElement) { 21 getCustomEquivalent: function(sampleElement) {
22 var equivalent; 22 var equivalent;
23 23
24 if (this.getTypeForElement(sampleElement) == 'star') 24 if (this.getTypeForElement(sampleElement) == 'star')
25 equivalent = this.getFirstFocusable('title'); 25 equivalent = this.getFirstFocusable('title');
26 26
27 return equivalent || 27 return equivalent ||
28 cr.ui.FocusRow.prototype.getCustomEquivalent.call( 28 cr.ui.FocusRow.prototype.getCustomEquivalent.call(this, sampleElement);
29 this, sampleElement);
30 }, 29 },
31 30
32 addItems: function() { 31 addItems: function() {
33 this.destroy(); 32 this.destroy();
34 33
35 assert(this.addItem('checkbox', '#checkbox')); 34 assert(this.addItem('checkbox', '#checkbox'));
36 assert(this.addItem('title', '#title')); 35 assert(this.addItem('title', '#title'));
37 assert(this.addItem('menu-button', '#menu-button')); 36 assert(this.addItem('menu-button', '#menu-button'));
38 37
39 this.addItem('star', '#bookmark-star'); 38 this.addItem('star', '#bookmark-star');
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return false; 73 return false;
75 }, 74 },
76 }; 75 };
77 76
78 var HistoryItem = Polymer({ 77 var HistoryItem = Polymer({
79 is: 'history-item', 78 is: 'history-item',
80 79
81 properties: { 80 properties: {
82 // Underlying HistoryEntry data for this item. Contains read-only fields 81 // Underlying HistoryEntry data for this item. Contains read-only fields
83 // from the history backend, as well as fields computed by history-list. 82 // from the history backend, as well as fields computed by history-list.
84 item: {type: Object, observer: 'showIcon_'}, 83 item: {
84 type: Object,
85 observer: 'showIcon_',
86 },
85 87
86 // Search term used to obtain this history-item. 88 selected: {
87 searchTerm: {type: String}, 89 type: Boolean,
90 reflectToAttribute: true,
91 },
88 92
89 selected: {type: Boolean, reflectToAttribute: true}, 93 isCardStart: {
94 type: Boolean,
95 reflectToAttribute: true,
96 },
90 97
91 isCardStart: {type: Boolean, reflectToAttribute: true}, 98 isCardEnd: {
92 99 type: Boolean,
93 isCardEnd: {type: Boolean, reflectToAttribute: true}, 100 reflectToAttribute: true,
101 },
94 102
95 // True if the item is being displayed embedded in another element and 103 // True if the item is being displayed embedded in another element and
96 // should not manage its own borders or size. 104 // should not manage its own borders or size.
97 embedded: {type: Boolean, reflectToAttribute: true}, 105 embedded: {
98 106 type: Boolean,
99 hasTimeGap: {type: Boolean}, 107 reflectToAttribute: true,
100 108 },
101 numberOfItems: {type: Number},
102
103 // The path of this history item inside its parent.
104 path: String,
105
106 index: Number,
107 109
108 /** @type {Element} */ 110 /** @type {Element} */
109 lastFocused: { 111 lastFocused: {
110 type: Object, 112 type: Object,
111 notify: true, 113 notify: true,
112 }, 114 },
113 115
114 ironListTabIndex: { 116 ironListTabIndex: {
115 type: Number, 117 type: Number,
116 observer: 'ironListTabIndexChanged_', 118 observer: 'ironListTabIndexChanged_',
117 }, 119 },
120
121 hasTimeGap: Boolean,
122
123 index: Number,
124
125 numberOfItems: Number,
126
127 // The path of this history item inside its parent.
128 path: String,
129
130 // Search term used to obtain this history-item.
131 searchTerm: String,
118 }, 132 },
119 133
120 /** @private {?HistoryFocusRow} */ 134 /** @private {?HistoryFocusRow} */
121 row_: null, 135 row_: null,
122 136
123 /** @override */ 137 /** @override */
124 attached: function() { 138 attached: function() {
125 Polymer.RenderStatus.afterNextRender(this, function() { 139 Polymer.RenderStatus.afterNextRender(this, function() {
126 this.row_ = new HistoryFocusRow( 140 this.row_ = new HistoryFocusRow(
127 this.$['main-container'], null, new FocusRowDelegate(this)); 141 this.$['main-container'], null, new FocusRowDelegate(this));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 'entrySummary', item.dateTimeOfDay, 226 'entrySummary', item.dateTimeOfDay,
213 item.starred ? loadTimeData.getString('bookmarked') : '', item.title, 227 item.starred ? loadTimeData.getString('bookmarked') : '', item.title,
214 item.domain); 228 item.domain);
215 }, 229 },
216 230
217 /** 231 /**
218 * @param {boolean} selected 232 * @param {boolean} selected
219 * @return {string} 233 * @return {string}
220 * @private 234 * @private
221 */ 235 */
222 getAriaChecked_: function(selected) { 236 getAriaChecked_: function(selected) { return selected ? 'true' : 'false'; },
223 return selected ? 'true' : 'false';
224 },
225 237
226 /** 238 /**
227 * Remove bookmark of current item when bookmark-star is clicked. 239 * Remove bookmark of current item when bookmark-star is clicked.
228 * @private 240 * @private
229 */ 241 */
230 onRemoveBookmarkTap_: function() { 242 onRemoveBookmarkTap_: function() {
231 if (!this.item.starred) 243 if (!this.item.starred)
232 return; 244 return;
233 245
234 if (this.$$('#bookmark-star') == this.root.activeElement) 246 if (this.$$('#bookmark-star') == this.root.activeElement)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 currentItem.dateRelativeDay == nextItem.dateRelativeDay; 354 currentItem.dateRelativeDay == nextItem.dateRelativeDay;
343 }; 355 };
344 356
345 /** 357 /**
346 * @param {number} numberOfResults 358 * @param {number} numberOfResults
347 * @param {string} searchTerm 359 * @param {string} searchTerm
348 * @return {string} The title for a page of search results. 360 * @return {string} The title for a page of search results.
349 */ 361 */
350 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) { 362 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) {
351 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults'; 363 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults';
352 return loadTimeData.getStringF('foundSearchResults', numberOfResults, 364 return loadTimeData.getStringF(
353 loadTimeData.getString(resultId), searchTerm); 365 'foundSearchResults', numberOfResults, loadTimeData.getString(resultId),
366 searchTerm);
354 }; 367 };
355 368
356 return { HistoryItem: HistoryItem }; 369 return {HistoryItem: HistoryItem};
357 }); 370 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/history.js ('k') | chrome/browser/resources/md_history/history_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698