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

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

Issue 1643693003: MD History: Implement search functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch_to_be_uploaded
Patch Set: Fix commenting. 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-toolbar', 6 is: 'history-toolbar',
7 properties: { 7 properties: {
8 // Number of history items currently selected. 8 // Number of history items currently selected.
9 count: { 9 count: {
10 type: Number, 10 type: Number,
11 value: 0, 11 value: 0,
12 observer: 'changeToolbarView_' 12 observer: 'changeToolbarView_'
13 }, 13 },
14
14 // True if 1 or more history items are selected. When this value changes 15 // True if 1 or more history items are selected. When this value changes
15 // the background colour changes. 16 // the background colour changes.
16 itemsSelected_: { 17 itemsSelected_: {
17 type: Boolean, 18 type: Boolean,
18 value: false, 19 value: false,
19 reflectToAttribute: true 20 reflectToAttribute: true
21 },
22
23 searchTerm: {
calamity 2016/02/05 02:30:10 Comment.
hsampson 2016/02/08 04:40:23 Done.
24 type: String,
25 value: ''
20 } 26 }
21 }, 27 },
22 28
23 /** 29 /**
24 * Changes the toolbar background color depending on whether any history items 30 * Changes the toolbar background color depending on whether any history items
25 * are currently selected. 31 * are currently selected.
26 * @private 32 * @private
27 */ 33 */
28 changeToolbarView_: function() { 34 changeToolbarView_: function() {
29 this.itemsSelected_ = this.count != 0; 35 this.itemsSelected_ = this.count != 0;
30 }, 36 },
31 37
38 /**
39 * If the search term has changed reload for the new search.
40 */
41 onSearchTermSearch: function(searchTerm) {
42 if (searchTerm != this.searchTerm)
43 this.fire('refresh-results', {search: searchTerm});
44 this.searchTerm = searchTerm;
45 },
46
47 attached: function() {
48 this.async(function() {
calamity 2016/02/05 02:30:10 Why async?
hsampson 2016/02/08 04:40:23 Because otherwise this function was being called b
tsergeant 2016/02/08 22:59:01 This -should- be fixed by removing the dom-ifs fro
hsampson 2016/02/09 02:17:51 If the async is removed and you refresh the page w
49 this.searchFieldDelegate_ = new ToolbarSearchFieldDelegate(this);
50 this.$$('#search-input').setDelegate(this.searchFieldDelegate_);
calamity 2016/02/05 02:30:10 I believe this can also become this.$['search-inpu
hsampson 2016/02/08 04:40:23 Done.
51 });
52 },
53
32 onClearSelectionTap_: function() { 54 onClearSelectionTap_: function() {
33 this.fire('unselect-all'); 55 this.fire('unselect-all');
34 } 56 }
35 }); 57 });
58
59 /**
60 * @constructor
61 * @implements {SearchFieldDelegate}
62 * @param {!Object} toolbar This history-toolbar.
63 */
64 function ToolbarSearchFieldDelegate(toolbar) {
65 this.toolbar_ = toolbar;
66 }
67
68 ToolbarSearchFieldDelegate.prototype = {
69 /** @override */
70 onSearchTermSearch: function(searchTerm) {
71 this.toolbar_.onSearchTermSearch(searchTerm);
72 }
73 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698