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

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

Issue 2643533003: MD History: Use one-way binding for history query state. (Closed)
Patch Set: Remove wrapper function Created 3 years, 11 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 // TODO(calamity): bind this to 9 // TODO(calamity): bind this to
10 // listContainer.selectedItem.selectedPaths.length. 10 // listContainer.selectedItem.selectedPaths.length.
11 count: { 11 count: {
12 type: Number, 12 type: Number,
13 value: 0, 13 value: 0,
14 observer: 'changeToolbarView_', 14 observer: 'changeToolbarView_',
15 }, 15 },
16 16
17 // True if 1 or more history items are selected. When this value changes 17 // True if 1 or more history items are selected. When this value changes
18 // the background colour changes. 18 // the background colour changes.
19 itemsSelected_: { 19 itemsSelected_: {
20 type: Boolean, 20 type: Boolean,
21 value: false, 21 value: false,
22 reflectToAttribute: true, 22 reflectToAttribute: true,
23 }, 23 },
24 24
25 // The most recent term entered in the search field. Updated incrementally 25 // The most recent term entered in the search field. Updated incrementally
26 // as the user types. 26 // as the user types.
27 searchTerm: { 27 searchTerm: {
28 type: String, 28 type: String,
29 observer: 'searchTermChanged_', 29 observer: 'searchTermChanged_',
30 notify: true,
31 }, 30 },
32 31
33 // True if the backend is processing and a spinner should be shown in the 32 // True if the backend is processing and a spinner should be shown in the
34 // toolbar. 33 // toolbar.
35 spinnerActive: { 34 spinnerActive: {
36 type: Boolean, 35 type: Boolean,
37 value: false, 36 value: false,
38 }, 37 },
39 38
40 hasDrawer: { 39 hasDrawer: {
41 type: Boolean, 40 type: Boolean,
42 reflectToAttribute: true, 41 reflectToAttribute: true,
43 }, 42 },
44 43
45 // Whether domain-grouped history is enabled. 44 // Whether domain-grouped history is enabled.
46 isGroupedMode: { 45 isGroupedMode: {
47 type: Boolean, 46 type: Boolean,
48 reflectToAttribute: true, 47 reflectToAttribute: true,
49 }, 48 },
50 49
51 // The period to search over. Matches BrowsingHistoryHandler::Range. 50 // The period to search over. Matches BrowsingHistoryHandler::Range.
52 groupedRange: { 51 groupedRange: {
53 type: Number, 52 type: Number,
54 reflectToAttribute: true, 53 reflectToAttribute: true,
55 notify: true,
56 }, 54 },
57 55
58 groupedOffset: { 56 groupedOffset: Number,
59 type: Number,
60 notify: true,
61 },
62 57
63 hasMoreResults: Boolean, 58 hasMoreResults: Boolean,
64 59
65 querying: Boolean, 60 querying: Boolean,
66 61
67 queryInfo: Object, 62 queryInfo: Object,
68 63
69 // Whether to show the menu promo (a tooltip that points at the menu button 64 // Whether to show the menu promo (a tooltip that points at the menu button
70 // in narrow mode). 65 // in narrow mode).
71 showMenuPromo: Boolean, 66 showMenuPromo: Boolean,
(...skipping 30 matching lines...) Expand all
102 this.searchField.showAndFocus(); 97 this.searchField.showAndFocus();
103 this.searchField.setValue(this.searchTerm); 98 this.searchField.setValue(this.searchTerm);
104 } 99 }
105 }, 100 },
106 101
107 /** 102 /**
108 * @param {!CustomEvent} event 103 * @param {!CustomEvent} event
109 * @private 104 * @private
110 */ 105 */
111 onSearchChanged_: function(event) { 106 onSearchChanged_: function(event) {
112 this.searchTerm = /** @type {string} */ (event.detail); 107 this.fire('change-query', {search: event.detail});
113 }, 108 },
114 109
115 /** @private */ 110 /** @private */
116 onInfoButtonTap_: function() { 111 onInfoButtonTap_: function() {
117 var dropdown = this.$.syncNotice.get(); 112 var dropdown = this.$.syncNotice.get();
118 dropdown.positionTarget = this.$$('#info-button-icon'); 113 dropdown.positionTarget = this.$$('#info-button-icon');
119 // It is possible for this listener to trigger while the dialog is 114 // It is possible for this listener to trigger while the dialog is
120 // closing. Ensure the dialog is fully closed before reopening it. 115 // closing. Ensure the dialog is fully closed before reopening it.
121 if (dropdown.style.display == 'none') 116 if (dropdown.style.display == 'none')
122 dropdown.open(); 117 dropdown.open();
(...skipping 25 matching lines...) Expand all
148 /** @private */ 143 /** @private */
149 getHistoryInterval_: function() { 144 getHistoryInterval_: function() {
150 var info = this.queryInfo; 145 var info = this.queryInfo;
151 if (this.groupedRange == HistoryRange.WEEK) 146 if (this.groupedRange == HistoryRange.WEEK)
152 return info.queryInterval; 147 return info.queryInterval;
153 148
154 if (this.groupedRange == HistoryRange.MONTH) 149 if (this.groupedRange == HistoryRange.MONTH)
155 return info.queryStartMonth; 150 return info.queryStartMonth;
156 }, 151 },
157 152
153 /**
154 * @param {Event} e
155 * @private
156 */
157 onTabSelected_: function(e) {
158 this.fire(
159 'change-query', {range: Number(e.detail.item.getAttribute('value'))});
160 },
161
162 /**
163 * @param {number} newOffset
164 * @private
165 */
166 changeOffset_: function(newOffset) {
167 if (!this.querying)
168 this.fire('change-query', {offset: newOffset});
169 },
170
158 /** @private */ 171 /** @private */
159 onTodayTap_: function() { 172 onTodayTap_: function() {
160 if (!this.querying) 173 this.changeOffset_(0);
161 this.groupedOffset = 0;
162 }, 174 },
163 175
164 /** @private */ 176 /** @private */
165 onPrevTap_: function() { 177 onPrevTap_: function() {
166 if (!this.querying) 178 this.changeOffset_(this.groupedOffset + 1);
167 this.groupedOffset = this.groupedOffset + 1;
168 }, 179 },
169 180
170 /** @private */ 181 /** @private */
171 onNextTap_: function() { 182 onNextTap_: function() {
172 if (!this.querying) 183 this.changeOffset_(this.groupedOffset - 1);
173 this.groupedOffset = this.groupedOffset - 1;
174 }, 184 },
175 185
176 /** 186 /**
177 * @private 187 * @private
178 * @return {boolean} 188 * @return {boolean}
179 */ 189 */
180 isToday_: function() { 190 isToday_: function() {
181 return this.groupedOffset == 0; 191 return this.groupedOffset == 0;
182 }, 192 },
183 }); 193 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/history_toolbar.html ('k') | chrome/browser/resources/md_history/list_container.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698