Chromium Code Reviews| 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('wallpapers', function() { | 5 cr.define('wallpapers', function() { |
| 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| 7 /** @const */ var Grid = cr.ui.Grid; | 7 /** @const */ var Grid = cr.ui.Grid; |
| 8 /** @const */ var GridItem = cr.ui.GridItem; | 8 /** @const */ var GridItem = cr.ui.GridItem; |
| 9 /** @const */ var GridSelectionController = cr.ui.GridSelectionController; | 9 /** @const */ var GridSelectionController = cr.ui.GridSelectionController; |
| 10 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; | 10 /** @const */ var ListSingleSelectionModel = cr.ui.ListSingleSelectionModel; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 return el; | 25 return el; |
| 26 } | 26 } |
| 27 | 27 |
| 28 WallpaperThumbnailsGridItem.prototype = { | 28 WallpaperThumbnailsGridItem.prototype = { |
| 29 __proto__: GridItem.prototype, | 29 __proto__: GridItem.prototype, |
| 30 | 30 |
| 31 /** @inheritDoc */ | 31 /** @inheritDoc */ |
| 32 decorate: function() { | 32 decorate: function() { |
| 33 GridItem.prototype.decorate.call(this); | 33 GridItem.prototype.decorate.call(this); |
| 34 var imageEl = cr.doc.createElement('img'); | 34 var imageEl = cr.doc.createElement('img'); |
| 35 // Thumbnail | 35 var xhr = new XMLHttpRequest(); |
| 36 imageEl.src = this.dataItem.baseURL + ThumbnailSuffix; | 36 xhr.open('GET', this.dataItem.baseURL + ThumbnailSuffix, true); |
| 37 // Remove any garbage added by GridItem and ListItem decorators. | 37 xhr.responseType = 'blob'; |
| 38 this.textContent = ''; | 38 xhr.send(null); |
| 39 this.appendChild(imageEl); | 39 var self = this; |
| 40 xhr.addEventListener('load', function(e) { | |
| 41 if (xhr.status === 200) { | |
| 42 self.textContent = ''; | |
| 43 imageEl.src = window.URL.createObjectURL(xhr.response); | |
| 44 imageEl.addEventListener('load', function(e) { | |
| 45 window.URL.revokeObjectURL(this.src); | |
| 46 }); | |
| 47 self.appendChild(imageEl); | |
| 48 } | |
| 49 //TODO(bshe): Add error handleing. | |
|
miket_OOO
2012/11/12 21:39:46
Nit: "handling"
Do you really think this TODO wil
bshe
2012/11/12 22:24:28
I guess I am not sure how should we proceed when t
| |
| 50 }); | |
| 40 }, | 51 }, |
| 41 }; | 52 }; |
| 42 | 53 |
| 43 /** | 54 /** |
| 44 * Creates a selection controller that wraps selection on grid ends | 55 * Creates a selection controller that wraps selection on grid ends |
| 45 * and translates Enter presses into 'activate' events. | 56 * and translates Enter presses into 'activate' events. |
| 46 * @param {cr.ui.ListSelectionModel} selectionModel The selection model to | 57 * @param {cr.ui.ListSelectionModel} selectionModel The selection model to |
| 47 * interact with. | 58 * interact with. |
| 48 * @param {cr.ui.Grid} grid The grid to interact with. | 59 * @param {cr.ui.Grid} grid The grid to interact with. |
| 49 * @constructor | 60 * @constructor |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 this.columns = 0; | 159 this.columns = 0; |
| 149 this.redraw(); | 160 this.redraw(); |
| 150 this.focus(); | 161 this.focus(); |
| 151 } | 162 } |
| 152 }; | 163 }; |
| 153 | 164 |
| 154 return { | 165 return { |
| 155 WallpaperThumbnailsGrid: WallpaperThumbnailsGrid | 166 WallpaperThumbnailsGrid: WallpaperThumbnailsGrid |
| 156 }; | 167 }; |
| 157 }); | 168 }); |
| OLD | NEW |