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

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

Issue 2481693002: [MD History] Make forward/backward work in grouped mode. (Closed)
Patch Set: rebase Created 4 years 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: {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_',
43 reflectToAttribute: true, 31 reflectToAttribute: true,
44 }, 32 },
45 33
46 showSyncNotice: Boolean, 34 showSyncNotice: Boolean,
47 35
48 // Whether domain-grouped history is enabled. 36 // Whether domain-grouped history is enabled.
49 isGroupedMode: { 37 isGroupedMode: {
50 type: Boolean, 38 type: Boolean,
51 reflectToAttribute: true, 39 reflectToAttribute: true,
52 }, 40 },
53 41
54 // The period to search over. Matches BrowsingHistoryHandler::Range. 42 // The period to search over. Matches BrowsingHistoryHandler::Range.
55 groupedRange: { 43 groupedRange: {
56 type: Number, 44 type: Number,
57 value: 0,
58 reflectToAttribute: true, 45 reflectToAttribute: true,
59 notify: true 46 notify: true,
60 }, 47 },
61 48
49 groupedOffset: {
50 type: Number,
51 notify: true,
52 },
53
54 querying: Boolean,
55
56 hasMoreResults: Boolean,
57
62 // The start time of the query range. 58 // The start time of the query range.
63 queryStartTime: String, 59 queryStartTime: String,
64 60
65 // The end time of the query range. 61 // The end time of the query range.
66 queryEndTime: String, 62 queryEndTime: String,
67 63
68 // 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
69 // in narrow mode). 65 // in narrow mode).
70 showMenuPromo: Boolean, 66 showMenuPromo: Boolean,
71 }, 67 },
72 68
73 /** @return {CrToolbarSearchFieldElement} */ 69 /** @return {CrToolbarSearchFieldElement} */
74 get searchField() { 70 get searchField() {
75 return /** @type {CrToolbarElement} */ (this.$['main-toolbar']) 71 return /** @type {CrToolbarElement} */ (this.$['main-toolbar'])
76 .getSearchField(); 72 .getSearchField();
77 }, 73 },
78 74
79 showSearchField: function() { 75 showSearchField: function() { this.searchField.showAndFocus(); },
80 this.searchField.showAndFocus();
81 },
82 76
83 /** 77 /**
84 * Changes the toolbar background color depending on whether any history items 78 * Changes the toolbar background color depending on whether any history items
85 * are currently selected. 79 * are currently selected.
86 * @private 80 * @private
87 */ 81 */
88 changeToolbarView_: function() { 82 changeToolbarView_: function() { this.itemsSelected_ = this.count > 0; },
89 this.itemsSelected_ = this.count > 0;
90 },
91 83
92 /** 84 /**
93 * When changing the search term externally, update the search field to 85 * When changing the search term externally, update the search field to
94 * reflect the new search term. 86 * reflect the new search term.
87 * @private
95 */ 88 */
96 searchTermChanged_: function() { 89 searchTermChanged_: function() {
97 if (this.searchField.getValue() != this.searchTerm) { 90 if (this.searchField.getValue() != this.searchTerm) {
98 this.searchField.showAndFocus(); 91 this.searchField.showAndFocus();
99 this.searchField.setValue(this.searchTerm); 92 this.searchField.setValue(this.searchTerm);
100 } 93 }
101 }, 94 },
102 95
103 /** 96 /**
104 * @param {!CustomEvent} event 97 * @param {!CustomEvent} event
105 * @private 98 * @private
106 */ 99 */
107 onSearchChanged_: function(event) { 100 onSearchChanged_: function(event) {
108 this.searchTerm = /** @type {string} */ (event.detail); 101 this.searchTerm = /** @type {string} */ (event.detail);
109 }, 102 },
110 103
111 /** @private */ 104 /** @private */
112 onInfoButtonTap_: function() { 105 onInfoButtonTap_: function() {
113 var dropdown = this.$.syncNotice.get(); 106 var dropdown = this.$.syncNotice.get();
114 dropdown.positionTarget = this.$$('#info-button-icon'); 107 dropdown.positionTarget = this.$$('#info-button-icon');
115 // It is possible for this listener to trigger while the dialog is 108 // It is possible for this listener to trigger while the dialog is
116 // closing. Ensure the dialog is fully closed before reopening it. 109 // closing. Ensure the dialog is fully closed before reopening it.
117 if (dropdown.style.display == 'none') 110 if (dropdown.style.display == 'none')
118 dropdown.open(); 111 dropdown.open();
119 }, 112 },
120 113
121 onClearSelectionTap_: function() { 114 /** @private */
122 this.fire('unselect-all'); 115 onClearSelectionTap_: function() { this.fire('unselect-all'); },
123 },
124 116
125 onDeleteTap_: function() { 117 /** @private */
126 this.fire('delete-selected'); 118 onDeleteTap_: function() { this.fire('delete-selected'); },
127 },
128 119
129 /** 120 /**
130 * If the user is a supervised user the delete button is not shown. 121 * If the user is a supervised user the delete button is not shown.
131 * @private 122 * @private
132 */ 123 */
133 deletingAllowed_: function() { 124 deletingAllowed_: function() {
134 return loadTimeData.getBoolean('allowDeletingHistory'); 125 return loadTimeData.getBoolean('allowDeletingHistory');
135 }, 126 },
136 127
128 /** @private */
137 numberOfItemsSelected_: function(count) { 129 numberOfItemsSelected_: function(count) {
138 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : ''; 130 return count > 0 ? loadTimeData.getStringF('itemsSelected', count) : '';
139 }, 131 },
140 132
133 /** @private */
141 getHistoryInterval_: function(queryStartTime, queryEndTime) { 134 getHistoryInterval_: function(queryStartTime, queryEndTime) {
142 // TODO(calamity): Fix the format of these dates. 135 // TODO(calamity): Fix the format of these dates.
143 return loadTimeData.getStringF( 136 return loadTimeData.getStringF(
144 'historyInterval', queryStartTime, queryEndTime); 137 'historyInterval', queryStartTime, queryEndTime);
145 }, 138 },
146 139
147 /** @private */ 140 /** @private */
148 hasDrawerChanged_: function() { 141 onTodayTap_: function() {
149 this.updateStyles(); 142 if (!this.querying)
143 this.groupedOffset = 0;
150 }, 144 },
145
146 /** @private */
147 onPrevTap_: function() {
148 if (!this.querying)
149 this.groupedOffset = this.groupedOffset + 1;
150 },
151
152 /** @private */
153 onNextTap_: function() {
154 if (!this.querying)
155 this.groupedOffset = this.groupedOffset - 1;
156 },
157
158 /**
159 * @private
160 * @return {boolean}
161 */
162 isToday_: function() { return this.groupedOffset == 0; },
151 }); 163 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698