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-list', | 6 is: 'history-list', |
7 | 7 |
8 behaviors: [HistoryListBehavior], | 8 behaviors: [HistoryListBehavior], |
9 | 9 |
10 properties: { | 10 properties: { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 /** @type {IronScrollThresholdElement} */(this.$['scroll-threshold']) | 76 /** @type {IronScrollThresholdElement} */(this.$['scroll-threshold']) |
77 .clearTriggers(); | 77 .clearTriggers(); |
78 | 78 |
79 if (!incremental) { | 79 if (!incremental) { |
80 this.resultLoadingDisabled_ = false; | 80 this.resultLoadingDisabled_ = false; |
81 if (this.historyData_) | 81 if (this.historyData_) |
82 this.splice('historyData_', 0, this.historyData_.length); | 82 this.splice('historyData_', 0, this.historyData_.length); |
83 this.fire('unselect-all'); | 83 this.fire('unselect-all'); |
84 } | 84 } |
85 | 85 |
| 86 var offset = (this.historyData_ ? this.historyData_.length : 0); |
| 87 results.forEach(function(item, index) { |
| 88 item.index = index + offset; |
| 89 }); |
| 90 |
86 if (this.historyData_) { | 91 if (this.historyData_) { |
87 // If we have previously received data, push the new items onto the | 92 // If we have previously received data, push the new items onto the |
88 // existing array. | 93 // existing array. |
89 results.unshift('historyData_'); | 94 results.unshift('historyData_'); |
90 this.push.apply(this, results); | 95 this.push.apply(this, results); |
91 } else { | 96 } else { |
92 // The first time we receive data, use set() to ensure the iron-list is | 97 // The first time we receive data, use set() to ensure the iron-list is |
93 // initialized correctly. | 98 // initialized correctly. |
94 this.set('historyData_', results); | 99 this.set('historyData_', results); |
95 } | 100 } |
96 }, | 101 }, |
97 | 102 |
| 103 refreshItemIndexes: function() { |
| 104 this.historyData_.forEach(function(item, index) { |
| 105 item.index = index; |
| 106 }); |
| 107 }, |
| 108 |
98 /** | 109 /** |
99 * Called when the page is scrolled to near the bottom of the list. | 110 * Called when the page is scrolled to near the bottom of the list. |
100 * @private | 111 * @private |
101 */ | 112 */ |
102 loadMoreData_: function() { | 113 loadMoreData_: function() { |
103 if (this.resultLoadingDisabled_ || this.querying) | 114 if (this.resultLoadingDisabled_ || this.querying) |
104 return; | 115 return; |
105 | 116 |
106 this.fire('load-more-history'); | 117 this.fire('load-more-history'); |
107 }, | 118 }, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 181 |
171 /** | 182 /** |
172 * @param {number} index | 183 * @param {number} index |
173 * @return {string} | 184 * @return {string} |
174 * @private | 185 * @private |
175 */ | 186 */ |
176 pathForItem_: function(index) { | 187 pathForItem_: function(index) { |
177 return 'historyData_.' + index; | 188 return 'historyData_.' + index; |
178 }, | 189 }, |
179 }); | 190 }); |
OLD | NEW |