| 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 Tile = ntp.Tile; | 8 var Tile = ntp.Tile; |
| 9 var TilePage = ntp.TilePage; | 9 var TilePage = ntp.TilePage; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Creates a new Thumbnail object for tiling. | 12 * Creates a new Thumbnail object for tiling. |
| 13 * @constructor | 13 * @constructor |
| 14 * @extends {Tile} | 14 * @extends {Tile} |
| 15 * @extends {HTMLAnchorElement} | 15 * @extends {HTMLAnchorElement} |
| 16 * @param {Object} config Tile page configuration object. | |
| 17 */ | 16 */ |
| 18 function Thumbnail(config) { | 17 function Thumbnail() { |
| 19 var el = cr.doc.createElement('a'); | 18 var el = cr.doc.createElement('a'); |
| 20 el.__proto__ = Thumbnail.prototype; | 19 el.__proto__ = Thumbnail.prototype; |
| 21 el.initialize(config); | 20 el.initialize(); |
| 22 | 21 |
| 23 return el; | 22 return el; |
| 24 } | 23 } |
| 25 | 24 |
| 26 Thumbnail.prototype = Tile.subclass({ | 25 Thumbnail.prototype = Tile.subclass({ |
| 27 __proto__: HTMLAnchorElement.prototype, | 26 __proto__: HTMLAnchorElement.prototype, |
| 28 | 27 |
| 29 /** | 28 /** |
| 30 * Initializes a Thumbnail. | 29 * Initializes a Thumbnail. |
| 31 * @param {Object} config TilePage configuration object. | |
| 32 */ | 30 */ |
| 33 initialize: function(config) { | 31 initialize: function() { |
| 34 Tile.prototype.initialize.apply(this, arguments); | 32 Tile.prototype.initialize.apply(this, arguments); |
| 35 this.classList.add('thumbnail'); | 33 this.classList.add('thumbnail'); |
| 36 this.addEventListener('mouseover', this.handleMouseOver_); | 34 this.addEventListener('mouseover', this.handleMouseOver_); |
| 37 }, | 35 }, |
| 38 | 36 |
| 39 /** | 37 /** |
| 40 * Clears the DOM hierarchy for this node, setting it back to the default | 38 * Clears the DOM hierarchy for this node, setting it back to the default |
| 41 * for a blank thumbnail. | 39 * for a blank thumbnail. |
| 42 */ | 40 */ |
| 43 reset: function() { | 41 reset: function() { |
| 44 this.innerHTML = | 42 this.innerHTML = |
| 45 '<span class="thumbnail-wrapper">' + | 43 '<span class="thumbnail-wrapper">' + |
| 46 '<span class="thumbnail-image thumbnail-card"></span>' + | 44 '<span class="thumbnail-image thumbnail-card"></span>' + |
| 47 '</span>' + | 45 '</span>' + |
| 48 '<span class="title"></span>'; | 46 '<span class="title"></span>'; |
| 49 | 47 |
| 50 this.tabIndex = -1; | 48 this.tabIndex = -1; |
| 51 this.data_ = null; | 49 this.data_ = null; |
| 52 this.title = ''; | 50 this.title = ''; |
| 53 }, | 51 }, |
| 54 | 52 |
| 55 /** | 53 /** |
| 56 * Update the appearance of this tile according to |data|. | 54 * Update the appearance of this tile according to |data|. |
| 57 * @param {Object} data A dictionary of relevant data for the page. | 55 * @param {Object} data A dictionary of relevant data for the page. |
| 58 */ | 56 */ |
| 59 setData: function(data) { | 57 set data(data) { |
| 60 Tile.prototype.setData.apply(this, arguments); | 58 Object.getOwnPropertyDescriptor(Tile.prototype, 'data').set.apply(this, |
| 59 arguments); |
| 61 | 60 |
| 62 this.formatThumbnail_(data); | 61 this.formatThumbnail_(data); |
| 63 }, | 62 }, |
| 64 | 63 |
| 65 /** | 64 /** |
| 66 * Formats this tile according to |data|. | 65 * Formats this tile according to |data|. |
| 67 * @param {Object} data A dictionary of relevant data for the page. | 66 * @param {Object} data A dictionary of relevant data for the page. |
| 68 * @private | 67 * @private |
| 69 */ | 68 */ |
| 70 formatThumbnail_: function(data) { | 69 formatThumbnail_: function(data) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 shouldAcceptDrag: function(e) { | 170 shouldAcceptDrag: function(e) { |
| 172 return false; | 171 return false; |
| 173 }, | 172 }, |
| 174 }; | 173 }; |
| 175 | 174 |
| 176 return { | 175 return { |
| 177 Thumbnail: Thumbnail, | 176 Thumbnail: Thumbnail, |
| 178 ThumbnailPage: ThumbnailPage, | 177 ThumbnailPage: ThumbnailPage, |
| 179 }; | 178 }; |
| 180 }); | 179 }); |
| OLD | NEW |