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

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

Issue 2684693004: MD History: Remove list-container and list-behavior (Closed)
Patch Set: Rename listeners Created 3 years, 10 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}
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 type: Boolean, 115 type: Boolean,
116 value: !loadTimeData.getBoolean('allowDeletingHistory'), 116 value: !loadTimeData.getBoolean('allowDeletingHistory'),
117 }, 117 },
118 118
119 hasTimeGap: Boolean, 119 hasTimeGap: Boolean,
120 120
121 index: Number, 121 index: Number,
122 122
123 numberOfItems: Number, 123 numberOfItems: Number,
124 124
125 // The path of this history item inside its parent.
126 path: String,
127
128 // Search term used to obtain this history-item. 125 // Search term used to obtain this history-item.
129 searchTerm: String, 126 searchTerm: String,
130 }, 127 },
131 128
132 /** @private {?HistoryFocusRow} */ 129 /** @private {?HistoryFocusRow} */
133 row_: null, 130 row_: null,
134 131
135 /** @override */ 132 /** @override */
136 attached: function() { 133 attached: function() {
137 Polymer.RenderStatus.afterNextRender(this, function() { 134 Polymer.RenderStatus.afterNextRender(this, function() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 (elem.nodeName == 'A' || elem.nodeName == 'BUTTON')) { 189 (elem.nodeName == 'A' || elem.nodeName == 'BUTTON')) {
193 return; 190 return;
194 } 191 }
195 } 192 }
196 193
197 if (this.selectionNotAllowed_) 194 if (this.selectionNotAllowed_)
198 return; 195 return;
199 196
200 this.$.checkbox.focus(); 197 this.$.checkbox.focus();
201 this.fire('history-checkbox-select', { 198 this.fire('history-checkbox-select', {
202 element: this, 199 index: this.index,
203 shiftKey: e.shiftKey, 200 shiftKey: e.shiftKey,
204 }); 201 });
205 }, 202 },
206 203
207 /** 204 /**
208 * @param {MouseEvent} e 205 * @param {MouseEvent} e
209 * @private 206 * @private
210 */ 207 */
211 onItemMousedown_: function(e) { 208 onItemMousedown_: function(e) {
212 // Prevent shift clicking a checkbox from selecting text. 209 // Prevent shift clicking a checkbox from selecting text.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 252
256 /** 253 /**
257 * Fires a custom event when the menu button is clicked. Sends the details 254 * Fires a custom event when the menu button is clicked. Sends the details
258 * of the history item and where the menu should appear. 255 * of the history item and where the menu should appear.
259 */ 256 */
260 onMenuButtonTap_: function(e) { 257 onMenuButtonTap_: function(e) {
261 this.fire('open-menu', { 258 this.fire('open-menu', {
262 target: Polymer.dom(e).localTarget, 259 target: Polymer.dom(e).localTarget,
263 index: this.index, 260 index: this.index,
264 item: this.item, 261 item: this.item,
265 path: this.path,
266 }); 262 });
267 263
268 // Stops the 'tap' event from closing the menu when it opens. 264 // Stops the 'tap' event from closing the menu when it opens.
269 e.stopPropagation(); 265 e.stopPropagation();
270 }, 266 },
271 267
272 /** 268 /**
273 * Record metrics when a result is clicked. This is deliberately tied to 269 * Record metrics when a result is clicked. This is deliberately tied to
274 * on-click rather than on-tap, as on-click triggers from middle clicks. 270 * on-click rather than on-tap, as on-click triggers from middle clicks.
275 */ 271 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 318
323 /** @private */ 319 /** @private */
324 addTimeTitle_: function() { 320 addTimeTitle_: function() {
325 var el = this.$['time-accessed']; 321 var el = this.$['time-accessed'];
326 el.setAttribute('title', new Date(this.item.time).toString()); 322 el.setAttribute('title', new Date(this.item.time).toString());
327 this.unlisten(el, 'mouseover', 'addTimeTitle_'); 323 this.unlisten(el, 'mouseover', 'addTimeTitle_');
328 }, 324 },
329 }); 325 });
330 326
331 /** 327 /**
332 * Check whether the time difference between the given history item and the
333 * next one is large enough for a spacer to be required.
334 * @param {Array<HistoryEntry>} visits
335 * @param {number} currentIndex
336 * @param {string} searchedTerm
337 * @return {boolean} Whether or not time gap separator is required.
338 */
339 HistoryItem.needsTimeGap = function(visits, currentIndex, searchedTerm) {
340 if (currentIndex >= visits.length - 1 || visits.length == 0)
341 return false;
342
343 var currentItem = visits[currentIndex];
344 var nextItem = visits[currentIndex + 1];
345
346 if (searchedTerm)
347 return currentItem.dateShort != nextItem.dateShort;
348
349 return currentItem.time - nextItem.time > BROWSING_GAP_TIME &&
350 currentItem.dateRelativeDay == nextItem.dateRelativeDay;
351 };
352
353 /**
354 * @param {number} numberOfResults 328 * @param {number} numberOfResults
355 * @param {string} searchTerm 329 * @param {string} searchTerm
356 * @return {string} The title for a page of search results. 330 * @return {string} The title for a page of search results.
357 */ 331 */
358 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) { 332 HistoryItem.searchResultsTitle = function(numberOfResults, searchTerm) {
359 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults'; 333 var resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults';
360 return loadTimeData.getStringF( 334 return loadTimeData.getStringF(
361 'foundSearchResults', numberOfResults, loadTimeData.getString(resultId), 335 'foundSearchResults', numberOfResults, loadTimeData.getString(resultId),
362 searchTerm); 336 searchTerm);
363 }; 337 };
364 338
365 return {HistoryItem: HistoryItem}; 339 return {HistoryItem: HistoryItem};
366 }); 340 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/compiled_resources2.gyp ('k') | chrome/browser/resources/md_history/history_list.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698