OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @typedef {{querying: boolean, | 6 * @typedef {{querying: boolean, |
7 * searchTerm: string, | 7 * searchTerm: string, |
8 * results: ?Array<!HistoryEntry>, | 8 * results: ?Array<!HistoryEntry>, |
9 * info: ?HistoryQuery, | 9 * info: ?HistoryQuery, |
10 * incremental: boolean, | 10 * incremental: boolean, |
11 * range: HistoryRange, | 11 * range: HistoryRange, |
12 * groupedOffset: number, | 12 * groupedOffset: number, |
13 * sessionList: ?Array<!ForeignSession>}} | 13 * sessionList: ?Array<!ForeignSession>}} |
14 */ | 14 */ |
15 var QueryState; | 15 var QueryState; |
16 | 16 |
17 Polymer({ | 17 Polymer({ |
18 is: 'history-app', | 18 is: 'history-app', |
19 | 19 |
20 properties: { | 20 properties: { |
21 // The id of the currently selected page. | 21 // The id of the currently selected page. |
22 selectedPage_: String, | 22 selectedPage_: { |
23 type: String, | |
24 value: 'history-list', | |
25 observer: 'unselectAll' | |
26 }, | |
23 | 27 |
24 // Whether domain-grouped history is enabled. | 28 // Whether domain-grouped history is enabled. |
25 grouped_: { | 29 grouped_: { |
26 type: Boolean, | 30 type: Boolean, |
27 reflectToAttribute: true | 31 reflectToAttribute: true |
28 }, | 32 }, |
29 | 33 |
30 // Whether the first set of results have returned. | 34 // Whether the first set of results have returned. |
31 firstLoad_: { type: Boolean, value: true }, | 35 firstLoad_: { type: Boolean, value: true }, |
32 | 36 |
(...skipping 23 matching lines...) Expand all Loading... | |
56 }, | 60 }, |
57 }, | 61 }, |
58 | 62 |
59 observers: [ | 63 observers: [ |
60 'searchTermChanged_(queryState_.searchTerm)', | 64 'searchTermChanged_(queryState_.searchTerm)', |
61 'groupedRangeChanged_(queryState_.range)', | 65 'groupedRangeChanged_(queryState_.range)', |
62 ], | 66 ], |
63 | 67 |
64 // TODO(calamity): Replace these event listeners with data bound properties. | 68 // TODO(calamity): Replace these event listeners with data bound properties. |
65 listeners: { | 69 listeners: { |
70 'cr-menu-tap': 'onMenuTap_', | |
66 'history-checkbox-select': 'checkboxSelected', | 71 'history-checkbox-select': 'checkboxSelected', |
67 'unselect-all': 'unselectAll', | 72 'unselect-all': 'unselectAll', |
68 'delete-selected': 'deleteSelected', | 73 'delete-selected': 'deleteSelected', |
69 'search-domain': 'searchDomain_', | 74 'search-domain': 'searchDomain_', |
70 'load-more-history': 'loadMoreHistory_', | 75 'load-more-history': 'loadMoreHistory_', |
71 }, | 76 }, |
72 | 77 |
73 /** @override */ | 78 /** @override */ |
74 ready: function() { | 79 ready: function() { |
75 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 80 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
76 }, | 81 }, |
77 | 82 |
83 onMenuTap_: function() { | |
dpapad
2016/06/25 01:24:44
@private
tsergeant
2016/06/27 04:57:49
Done.
| |
84 this.$['side-bar'].toggle(); | |
85 }, | |
86 | |
78 /** | 87 /** |
79 * Listens for history-item being selected or deselected (through checkbox) | 88 * Listens for history-item being selected or deselected (through checkbox) |
80 * and changes the view of the top toolbar. | 89 * and changes the view of the top toolbar. |
81 * @param {{detail: {countAddition: number}}} e | 90 * @param {{detail: {countAddition: number}}} e |
82 */ | 91 */ |
83 checkboxSelected: function(e) { | 92 checkboxSelected: function(e) { |
84 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); | 93 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); |
85 toolbar.count += e.detail.countAddition; | 94 toolbar.count += e.detail.countAddition; |
86 }, | 95 }, |
87 | 96 |
88 /** | 97 /** |
89 * Listens for call to cancel selection and loops through all items to set | 98 * Listens for call to cancel selection and loops through all items to set |
90 * checkbox to be unselected. | 99 * checkbox to be unselected. |
91 */ | 100 */ |
92 unselectAll: function() { | 101 unselectAll: function() { |
dpapad
2016/06/25 01:24:44
Could this also be private?
tsergeant
2016/06/27 04:57:49
Done.
| |
93 var historyList = | 102 var historyList = |
94 /** @type {HistoryListElement} */(this.$['history-list']); | 103 /** @type {HistoryListElement} */(this.$['history-list']); |
95 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); | 104 var toolbar = /** @type {HistoryToolbarElement} */(this.$.toolbar); |
96 historyList.unselectAllItems(toolbar.count); | 105 historyList.unselectAllItems(toolbar.count); |
97 toolbar.count = 0; | 106 toolbar.count = 0; |
98 }, | 107 }, |
99 | 108 |
100 /** | 109 /** |
101 * Listens for call to delete all selected items and loops through all items | 110 * Listens for call to delete all selected items and loops through all items |
102 * to determine which ones are selected and deletes these. | 111 * to determine which ones are selected and deletes these. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
249 * @param {boolean} incremental | 258 * @param {boolean} incremental |
250 * @param {string} searchTerm | 259 * @param {string} searchTerm |
251 * @return {boolean} Whether a loading spinner should be shown (implies the | 260 * @return {boolean} Whether a loading spinner should be shown (implies the |
252 * backend is querying a new search term). | 261 * backend is querying a new search term). |
253 * @private | 262 * @private |
254 */ | 263 */ |
255 shouldShowSpinner_: function(querying, incremental, searchTerm) { | 264 shouldShowSpinner_: function(querying, incremental, searchTerm) { |
256 return querying && !incremental && searchTerm != ''; | 265 return querying && !incremental && searchTerm != ''; |
257 } | 266 } |
258 }); | 267 }); |
OLD | NEW |