OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('ntp', function() { | 5 cr.define('ntp', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 var Thumbnail = ntp.Thumbnail; | 8 var Thumbnail = ntp.Thumbnail; |
9 var ThumbnailPage = ntp.ThumbnailPage; | 9 var ThumbnailPage = ntp.ThumbnailPage; |
10 | 10 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 * @param {Object} config TilePage configuration object. | 132 * @param {Object} config TilePage configuration object. |
133 */ | 133 */ |
134 initialize: function(config) { | 134 initialize: function(config) { |
135 ThumbnailPage.prototype.initialize.apply(this, arguments); | 135 ThumbnailPage.prototype.initialize.apply(this, arguments); |
136 this.classList.add('recently-closed-page'); | 136 this.classList.add('recently-closed-page'); |
137 }, | 137 }, |
138 | 138 |
139 /** | 139 /** |
140 * Sets the data that will be used to create Thumbnails. | 140 * Sets the data that will be used to create Thumbnails. |
141 * @param {Array} data The array of data. | 141 * @param {Array} data The array of data. |
142 * @type (Array} | |
143 */ | 142 */ |
144 set data(data) { | 143 setData: function(data) { |
145 var startTime = Date.now(); | 144 var startTime = Date.now(); |
146 var maxTileCount = this.config_.maxTileCount; | 145 ThumbnailPage.prototype.setData.apply(this, arguments); |
147 | 146 |
148 this.data_ = data.slice(0, maxTileCount); | |
149 var dataLength = data.length; | |
150 var tileCount = this.tileCount; | |
151 // Create new tiles if necessary. | |
152 // TODO(jeremycho): Verify this handles the removal of tiles, once that | |
153 // functionality is supported. | |
154 if (tileCount < dataLength) | |
155 this.createTiles_(dataLength - tileCount); | |
156 | |
157 this.updateTiles_(); | |
158 // Only show the dot if we have recently closed tabs to display. | 147 // Only show the dot if we have recently closed tabs to display. |
159 var dot = this.navigationDot; | 148 var dot = this.navigationDot; |
160 if (dot) | 149 if (this.data_.length == 0) { |
161 dot.hidden = dataLength == 0; | 150 dot.hidden = true; |
| 151 // If the last tab has been removed (by a user click) and we're still on |
| 152 // the Recently Closed page, fall back to the first page in the dot |
| 153 // list. |
| 154 var cardSlider = ntp.getCardSlider(); |
| 155 if (cardSlider.currentCardValue == this) |
| 156 cardSlider.selectCard(0, true); |
| 157 } else { |
| 158 dot.hidden = false; |
| 159 } |
162 | 160 |
163 logEvent('recentlyClosed.layout: ' + (Date.now() - startTime)); | 161 logEvent('recentlyClosed.layout: ' + (Date.now() - startTime)); |
164 } | 162 } |
165 }; | 163 }; |
166 | 164 |
167 /** | 165 /** |
168 * Returns the text used for a recently closed window. | 166 * Returns the text used for a recently closed window. |
169 * @param {number} numTabs Number of tabs in the window. | 167 * @param {number} numTabs Number of tabs in the window. |
170 * @return {string} The text to use. | 168 * @return {string} The text to use. |
171 */ | 169 */ |
172 function formatTabsText(numTabs) { | 170 function formatTabsText(numTabs) { |
173 if (numTabs == 1) | 171 if (numTabs == 1) |
174 return loadTimeData.getString('closedwindowsingle'); | 172 return loadTimeData.getString('closedwindowsingle'); |
175 return loadTimeData.getStringF('closedwindowmultiple', numTabs); | 173 return loadTimeData.getStringF('closedwindowmultiple', numTabs); |
176 } | 174 } |
177 | 175 |
178 return { | 176 return { |
179 RecentlyClosedPage: RecentlyClosedPage, | 177 RecentlyClosedPage: RecentlyClosedPage, |
180 }; | 178 }; |
181 }); | 179 }); |
OLD | NEW |