OLD | NEW |
---|---|
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: {type: Number, value: 0, observer: 'changeToolbarView_'}, |
12 type: Number, | |
13 value: 0, | |
14 observer: 'changeToolbarView_' | |
15 }, | |
16 | 12 |
17 // True if 1 or more history items are selected. When this value changes | 13 // True if 1 or more history items are selected. When this value changes |
18 // the background colour changes. | 14 // the background colour changes. |
19 itemsSelected_: { | 15 itemsSelected_: {type: Boolean, value: false, reflectToAttribute: true}, |
20 type: Boolean, | |
21 value: false, | |
22 reflectToAttribute: true | |
23 }, | |
24 | 16 |
25 // The most recent term entered in the search field. Updated incrementally | 17 // The most recent term entered in the search field. Updated incrementally |
26 // as the user types. | 18 // as the user types. |
27 searchTerm: { | 19 searchTerm: { |
28 type: String, | 20 type: String, |
29 observer: 'searchTermChanged_', | 21 observer: 'searchTermChanged_', |
30 notify: true, | 22 notify: true, |
31 }, | 23 }, |
32 | 24 |
33 // True if the backend is processing and a spinner should be shown in the | 25 // True if the backend is processing and a spinner should be shown in the |
34 // toolbar. | 26 // toolbar. |
35 spinnerActive: { | 27 spinnerActive: {type: Boolean, value: false}, |
36 type: Boolean, | |
37 value: false | |
38 }, | |
39 | 28 |
40 hasDrawer: { | 29 hasDrawer: { |
41 type: Boolean, | 30 type: Boolean, |
42 observer: 'hasDrawerChanged_', | 31 observer: 'hasDrawerChanged_', |
43 reflectToAttribute: true, | 32 reflectToAttribute: true, |
44 }, | 33 }, |
45 | 34 |
46 showSyncNotice: Boolean, | 35 showSyncNotice: Boolean, |
47 | 36 |
48 // Whether domain-grouped history is enabled. | 37 // Whether domain-grouped history is enabled. |
49 isGroupedMode: { | 38 isGroupedMode: { |
50 type: Boolean, | 39 type: Boolean, |
51 reflectToAttribute: true, | 40 reflectToAttribute: true, |
52 }, | 41 }, |
53 | 42 |
54 // The period to search over. Matches BrowsingHistoryHandler::Range. | 43 // The period to search over. Matches BrowsingHistoryHandler::Range. |
55 groupedRange: { | 44 groupedRange: { |
56 type: Number, | 45 type: Number, |
57 value: 0, | |
58 reflectToAttribute: true, | 46 reflectToAttribute: true, |
59 notify: true | 47 notify: true, |
60 }, | 48 }, |
61 | 49 |
50 groupedOffset: { | |
51 type: Number, | |
52 notify: true, | |
53 }, | |
54 | |
55 querying: Boolean, | |
56 | |
57 queryFinished: Boolean, | |
tsergeant
2016/11/11 02:34:27
I was a bit confused by this name, because it soun
calamity
2016/11/22 06:44:56
hasMoreResults is probably optimally clear. Even w
| |
58 | |
62 // The start time of the query range. | 59 // The start time of the query range. |
63 queryStartTime: String, | 60 queryStartTime: String, |
64 | 61 |
65 // The end time of the query range. | 62 // The end time of the query range. |
66 queryEndTime: String, | 63 queryEndTime: String, |
67 | 64 |
68 // Whether to show the menu promo (a tooltip that points at the menu button | 65 // Whether to show the menu promo (a tooltip that points at the menu button |
69 // in narrow mode). | 66 // in narrow mode). |
70 showMenuPromo: Boolean, | 67 showMenuPromo: Boolean, |
71 }, | 68 }, |
72 | 69 |
73 /** @return {CrToolbarSearchFieldElement} */ | 70 /** @return {CrToolbarSearchFieldElement} */ |
74 get searchField() { | 71 get searchField() { |
75 return /** @type {CrToolbarElement} */ (this.$['main-toolbar']) | 72 return /** @type {CrToolbarElement} */ (this.$['main-toolbar']) |
76 .getSearchField(); | 73 .getSearchField(); |
77 }, | 74 }, |
78 | 75 |
79 showSearchField: function() { | 76 showSearchField: function() { this.searchField.showAndFocus(); }, |
80 this.searchField.showAndFocus(); | |
81 }, | |
82 | 77 |
83 /** | 78 /** |
84 * Changes the toolbar background color depending on whether any history items | 79 * Changes the toolbar background color depending on whether any history items |
85 * are currently selected. | 80 * are currently selected. |
86 * @private | 81 * @private |
87 */ | 82 */ |
88 changeToolbarView_: function() { | 83 changeToolbarView_: function() { this.itemsSelected_ = this.count > 0; }, |
89 this.itemsSelected_ = this.count > 0; | |
90 }, | |
91 | 84 |
92 /** | 85 /** |
93 * When changing the search term externally, update the search field to | 86 * When changing the search term externally, update the search field to |
94 * reflect the new search term. | 87 * reflect the new search term. |
88 * @private | |
95 */ | 89 */ |
96 searchTermChanged_: function() { | 90 searchTermChanged_: function() { |
97 if (this.searchField.getValue() != this.searchTerm) { | 91 if (this.searchField.getValue() != this.searchTerm) { |
98 this.searchField.showAndFocus(); | 92 this.searchField.showAndFocus(); |
99 this.searchField.setValue(this.searchTerm); | 93 this.searchField.setValue(this.searchTerm); |
100 } | 94 } |
101 }, | 95 }, |
102 | 96 |
103 /** | 97 /** |
104 * @param {!CustomEvent} event | 98 * @param {!CustomEvent} event |
105 * @private | 99 * @private |
106 */ | 100 */ |
107 onSearchChanged_: function(event) { | 101 onSearchChanged_: function(event) { |
108 this.searchTerm = /** @type {string} */ (event.detail); | 102 this.searchTerm = /** @type {string} */ (event.detail); |
109 }, | 103 }, |
110 | 104 |
111 /** @private */ | 105 /** @private */ |
112 onInfoButtonTap_: function() { | 106 onInfoButtonTap_: function() { |
113 var dropdown = this.$.syncNotice.get(); | 107 var dropdown = this.$.syncNotice.get(); |
114 dropdown.positionTarget = this.$$('#info-button-icon'); | 108 dropdown.positionTarget = this.$$('#info-button-icon'); |
115 // It is possible for this listener to trigger while the dialog is | 109 // It is possible for this listener to trigger while the dialog is |
116 // closing. Ensure the dialog is fully closed before reopening it. | 110 // closing. Ensure the dialog is fully closed before reopening it. |
117 if (dropdown.style.display == 'none') | 111 if (dropdown.style.display == 'none') |
118 dropdown.open(); | 112 dropdown.open(); |
119 }, | 113 }, |
120 | 114 |
121 onClearSelectionTap_: function() { | 115 /** @private */ |
122 this.fire('unselect-all'); | 116 onClearSelectionTap_: function() { this.fire('unselect-all'); }, |
123 }, | |
124 | 117 |
125 onDeleteTap_: function() { | 118 /** @private */ |
126 this.fire('delete-selected'); | 119 onDeleteTap_: function() { this.fire('delete-selected'); }, |
127 }, | |
128 | 120 |
129 /** | 121 /** |
130 * If the user is a supervised user the delete button is not shown. | 122 * If the user is a supervised user the delete button is not shown. |
131 * @private | 123 * @private |
132 */ | 124 */ |
133 deletingAllowed_: function() { | 125 deletingAllowed_: function() { |
134 return loadTimeData.getBoolean('allowDeletingHistory'); | 126 return loadTimeData.getBoolean('allowDeletingHistory'); |
135 }, | 127 }, |
136 | 128 |
129 /** @private */ | |
137 numberOfItemsSelected_: function(count) { | 130 numberOfItemsSelected_: function(count) { |
138 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; | 131 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; |
139 }, | 132 }, |
140 | 133 |
134 /** @private */ | |
141 getHistoryInterval_: function(queryStartTime, queryEndTime) { | 135 getHistoryInterval_: function(queryStartTime, queryEndTime) { |
142 // TODO(calamity): Fix the format of these dates. | 136 // TODO(calamity): Fix the format of these dates. |
143 return loadTimeData.getStringF( | 137 return loadTimeData.getStringF( |
144 'historyInterval', queryStartTime, queryEndTime); | 138 'historyInterval', queryStartTime, queryEndTime); |
145 }, | 139 }, |
146 | 140 |
147 /** @private */ | 141 /** @private */ |
148 hasDrawerChanged_: function() { | 142 hasDrawerChanged_: function() { this.updateStyles(); }, |
tsergeant
2016/11/11 02:34:27
While you're here...
I'm pretty sure this listene
calamity
2016/11/22 06:44:56
Done.
| |
149 this.updateStyles(); | 143 |
144 /** @private */ | |
145 todayTapped_: function() { | |
146 if (!this.querying) | |
147 this.groupedOffset = 0; | |
150 }, | 148 }, |
149 | |
150 /** @private */ | |
151 prevTapped_: function() { | |
152 if (!this.querying) | |
153 this.groupedOffset = this.groupedOffset + 1; | |
154 }, | |
155 | |
156 /** @private */ | |
157 nextTapped_: function() { | |
158 if (!this.querying) | |
159 this.groupedOffset = this.groupedOffset - 1; | |
160 }, | |
161 | |
162 /** | |
163 * @private | |
164 * @return {boolean} | |
165 */ | |
166 isToday_: function() { return this.groupedOffset == 0; }, | |
151 }); | 167 }); |
OLD | NEW |