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

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

Issue 1648803003: MD History: Drop-down menu allows searching for history-items by domain name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@search_functionality
Patch Set: Created 4 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 Polymer({ 5 Polymer({
6 is: 'history-card-manager', 6 is: 'history-card-manager',
7 7
8 properties: { 8 properties: {
9 // An array of objects sorted in reverse chronological order. 9 // An array of objects sorted in reverse chronological order.
10 // Each object has a date and the history items belonging to that date. 10 // Each object has a date and the history items belonging to that date.
11 historyDataByDay_: { 11 historyDataByDay_: {
12 type: Array, 12 type: Array,
13 value: function() { return []; } 13 value: function() { return []; }
14 }, 14 },
15 15
16 // The time of access of the last element of historyDataByDay_. 16 // The time of access of the last element of historyDataByDay_.
17 lastVisitedTime: { 17 lastVisitedTime: {
18 type: Number, 18 type: Number,
19 value: 0 19 value: 0
20 }, 20 },
21 21
22 menuOpen: { 22 menuOpen: {
23 type: Boolean, 23 type: Boolean,
24 value: false, 24 value: false,
25 reflectToAttribute: true 25 reflectToAttribute: true
26 }, 26 },
27 27
28 menuIdentifier: { 28 menuIdentifier: {
29 type: Number, 29 type: Array,
30 value: 0 30 value: []
calamity 2016/02/03 05:09:13 Shouldn't this be an object? Also, use value: func
hsampson 2016/02/08 00:39:37 Done.
31 }, 31 },
32 32
33 searchTerm: { 33 searchTerm: {
34 type: String, 34 type: String,
35 value: '' 35 value: ''
36 }, 36 },
37 37
38 // Message shown when no results available. Depends on searchTerm. 38 // Message shown when no results available. Depends on searchTerm.
39 noResultsMessage: { 39 noResultsMessage: {
40 type: String, 40 type: String,
(...skipping 16 matching lines...) Expand all
57 }, 57 },
58 58
59 /** 59 /**
60 * Closes the overflow menu. 60 * Closes the overflow menu.
61 */ 61 */
62 closeMenu: function() { 62 closeMenu: function() {
63 this.menuOpen = false; 63 this.menuOpen = false;
64 }, 64 },
65 65
66 /** 66 /**
67 * Search history based on the domain name associated with the pop-up menu.
68 * @private
69 */
70 onMoreFromSiteTap_: function() {
71 var domain = this.menuIdentifier.domain;
72 this.fire('more-from-site', {search: domain});
73 this.fire('refresh-results', {search: domain});
calamity 2016/02/03 05:09:13 I think it's better just to put the query call int
hsampson 2016/02/08 00:39:37 Done.
74 this.closeMenu();
75 },
76
77 /**
67 * Clear the page completely so the page can display new results (search). 78 * Clear the page completely so the page can display new results (search).
68 */ 79 */
69 resetHistoryResults: function() { 80 resetHistoryResults: function() {
70 this.loading = true; 81 this.loading = true;
71 this.splice('historyDataByDay_', 0, this.historyDataByDay_.length); 82 this.splice('historyDataByDay_', 0, this.historyDataByDay_.length);
72 }, 83 },
73 84
74 /** 85 /**
75 * Opens the overflow menu unless the menu is already open and the same button 86 * Opens the overflow menu unless the menu is already open and the same button
76 * is pressed. 87 * is pressed.
77 * @param {Event} e The event with details of the menu item that was clicked. 88 * @param {Event} e The event with details of the menu item that was clicked.
78 * @private 89 * @private
79 */ 90 */
80 toggleMenu_: function(e) { 91 toggleMenu_: function(e) {
81 var menu = this.$['overflow-menu']; 92 var menu = this.$['overflow-menu'];
82 93
83 // Menu closes if the same button is clicked. 94 // Menu closes if the same button is clicked.
84 if (this.menuOpen && this.menuIdentifier == e.detail.accessTime) { 95 if (this.menuOpen &&
96 this.menuIdentifier == e.detail.itemIdentifier) {
calamity 2016/02/03 05:09:13 Hmmmmmmmm. I believe this equality is never true s
hsampson 2016/02/08 00:39:37 Done.
85 this.closeMenu(); 97 this.closeMenu();
86 } else { 98 } else {
87 this.menuOpen = true; 99 this.menuOpen = true;
88 this.menuIdentifier = e.detail.accessTime; 100 this.menuIdentifier = e.detail.itemIdentifier;
89 101
90 cr.ui.positionPopupAtPoint(e.detail.x + this.X_OFFSET_, e.detail.y, menu, 102 cr.ui.positionPopupAtPoint(e.detail.x + this.X_OFFSET_, e.detail.y, menu,
91 cr.ui.AnchorType.BEFORE); 103 cr.ui.AnchorType.BEFORE);
92 104
93 menu.focus(); 105 menu.focus();
94 } 106 }
95 }, 107 },
96 108
97 /** 109 /**
98 * Reformat the search results so they all have the same dateRelativeDay (will 110 * Reformat the search results so they all have the same dateRelativeDay (will
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 /** 238 /**
227 * Sets the message displayed when there are no results. Displayed if there is 239 * Sets the message displayed when there are no results. Displayed if there is
228 * no history at all or if the search returned no results. 240 * no history at all or if the search returned no results.
229 * @private 241 * @private
230 */ 242 */
231 noResultsMessage_: function() { 243 noResultsMessage_: function() {
232 var messageId = this.searchTerm == '' ? 'noResults' : 'noSearchResults'; 244 var messageId = this.searchTerm == '' ? 'noResults' : 'noSearchResults';
233 this.noResultsMessage = loadTimeData.getString(messageId); 245 this.noResultsMessage = loadTimeData.getString(messageId);
234 } 246 }
235 }); 247 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698