OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 * WallpaperManager constructor. | 6 * WallpaperManager constructor. |
7 * | 7 * |
8 * WallpaperManager objects encapsulate the functionality of the wallpaper | 8 * WallpaperManager objects encapsulate the functionality of the wallpaper |
9 * manager extension. | 9 * manager extension. |
10 * | 10 * |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 window.addEventListener('online', function() { | 267 window.addEventListener('online', function() { |
268 self.downloadedListMap_ = null; | 268 self.downloadedListMap_ = null; |
269 $('wallpaper-grid').classList.remove('image-picker-offline'); | 269 $('wallpaper-grid').classList.remove('image-picker-offline'); |
270 }); | 270 }); |
271 } | 271 } |
272 $('window-close-button').addEventListener('click', function() { | 272 $('window-close-button').addEventListener('click', function() { |
273 window.close(); | 273 window.close(); |
274 }); | 274 }); |
275 this.document_.defaultView.addEventListener( | 275 this.document_.defaultView.addEventListener( |
276 'resize', this.onResize_.bind(this)); | 276 'resize', this.onResize_.bind(this)); |
277 this.document_.defaultView.addEventListener( | |
278 'keydown', this.onKeyDown_.bind(this)); | |
277 $('learn-more').href = LearnMoreURL; | 279 $('learn-more').href = LearnMoreURL; |
278 $('close-error').addEventListener('click', function() { | 280 $('close-error').addEventListener('click', function() { |
279 $('error-container').hidden = true; | 281 $('error-container').hidden = true; |
280 }); | 282 }); |
281 $('close-wallpaper-selection').addEventListener('click', function() { | 283 $('close-wallpaper-selection').addEventListener('click', function() { |
282 $('wallpaper-selection-container').hidden = true; | 284 $('wallpaper-selection-container').hidden = true; |
283 $('set-wallpaper-layout').disabled = true; | 285 $('set-wallpaper-layout').disabled = true; |
284 }); | 286 }); |
285 | 287 |
286 this.onResize_(); | 288 this.onResize_(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
646 | 648 |
647 /** | 649 /** |
648 * Resize thumbnails grid and categories list to fit the new window size. | 650 * Resize thumbnails grid and categories list to fit the new window size. |
649 */ | 651 */ |
650 WallpaperManager.prototype.onResize_ = function() { | 652 WallpaperManager.prototype.onResize_ = function() { |
651 this.wallpaperGrid_.redraw(); | 653 this.wallpaperGrid_.redraw(); |
652 this.categoriesList_.redraw(); | 654 this.categoriesList_.redraw(); |
653 }; | 655 }; |
654 | 656 |
655 /** | 657 /** |
658 * Close the active overlay on pressing the Escape key. | |
bshe
2013/08/29 16:05:03
please document function parameter like this:
@par
François Beaufort
2013/08/29 16:32:59
Done.
| |
659 */ | |
660 WallpaperManager.prototype.onKeyDown_ = function(event) { | |
661 if (event.keyCode == 27) { | |
bshe
2013/08/29 16:05:03
There might be two overlays opened at the same tim
François Beaufort
2013/08/29 16:32:59
Setting "hidden" to true is not enough since it's
bshe
2013/08/29 17:10:35
Aha. you are right. We can't simply hide it. Would
| |
662 var closeButtonSelector = '.overlay-container:not([hidden]) .close'; | |
663 var closeButton = this.document_.querySelector(closeButtonSelector); | |
664 if (closeButton) { | |
665 closeButton.click(); | |
666 event.preventDefault(); | |
667 } | |
668 } | |
669 }; | |
670 | |
671 /** | |
656 * Constructs the categories list. | 672 * Constructs the categories list. |
657 */ | 673 */ |
658 WallpaperManager.prototype.initCategoriesList_ = function() { | 674 WallpaperManager.prototype.initCategoriesList_ = function() { |
659 this.categoriesList_ = $('categories-list'); | 675 this.categoriesList_ = $('categories-list'); |
660 cr.ui.List.decorate(this.categoriesList_); | 676 cr.ui.List.decorate(this.categoriesList_); |
661 // cr.ui.list calculates items in view port based on client height and item | 677 // cr.ui.list calculates items in view port based on client height and item |
662 // height. However, categories list is displayed horizontally. So we should | 678 // height. However, categories list is displayed horizontally. So we should |
663 // not calculate visible items here. Sets autoExpands to true to show every | 679 // not calculate visible items here. Sets autoExpands to true to show every |
664 // item in the list. | 680 // item in the list. |
665 // TODO(bshe): Use ul to replace cr.ui.list for category list. | 681 // TODO(bshe): Use ul to replace cr.ui.list for category list. |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 } | 1001 } |
986 } | 1002 } |
987 } | 1003 } |
988 this.wallpaperGrid_.dataModel = wallpapersDataModel; | 1004 this.wallpaperGrid_.dataModel = wallpapersDataModel; |
989 this.wallpaperGrid_.selectedItem = selectedItem; | 1005 this.wallpaperGrid_.selectedItem = selectedItem; |
990 this.wallpaperGrid_.activeItem = selectedItem; | 1006 this.wallpaperGrid_.activeItem = selectedItem; |
991 } | 1007 } |
992 }; | 1008 }; |
993 | 1009 |
994 })(); | 1010 })(); |
OLD | NEW |