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 var APP_LAUNCH = ntp.APP_LAUNCH; | 10 var APP_LAUNCH = ntp.APP_LAUNCH; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 onUninstall_: function(e) { | 178 onUninstall_: function(e) { |
179 chrome.send('uninstallApp', [this.app_.data.id]); | 179 chrome.send('uninstallApp', [this.app_.data.id]); |
180 }, | 180 }, |
181 onCreateShortcut_: function(e) { | 181 onCreateShortcut_: function(e) { |
182 chrome.send('createAppShortcut', [this.app_.data.id]); | 182 chrome.send('createAppShortcut', [this.app_.data.id]); |
183 }, | 183 }, |
184 }; | 184 }; |
185 | 185 |
186 /** | 186 /** |
187 * Creates a new App object. | 187 * Creates a new App object. |
| 188 * @param {Object=} opt_data The data representing the app. |
188 * @constructor | 189 * @constructor |
189 * @extends {HTMLDivElement} | 190 * @extends {HTMLDivElement} |
190 */ | 191 */ |
191 function App(data) { | 192 function App(opt_data) { |
192 var el = cr.doc.createElement('div'); | 193 var el = cr.doc.createElement('div'); |
193 el.__proto__ = App.prototype; | 194 el.__proto__ = App.prototype; |
194 el.initialize_(); | 195 el.initialize_(); |
195 el.data = data; | 196 |
| 197 if (opt_data) |
| 198 el.data = opt_data; |
196 | 199 |
197 return el; | 200 return el; |
198 } | 201 } |
199 | 202 |
200 App.prototype = Tile.subclass({ | 203 App.prototype = Tile.subclass({ |
201 __proto__: HTMLDivElement.prototype, | 204 __proto__: HTMLDivElement.prototype, |
202 | 205 |
203 /** | 206 /** |
204 * Initialize the app object. | 207 * Initialize the app object. |
205 * @private | 208 * @private |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 TileClass: App, | 587 TileClass: App, |
585 | 588 |
586 // The config object should be defined by a TilePage subclass if it | 589 // The config object should be defined by a TilePage subclass if it |
587 // wants the non-default behavior. | 590 // wants the non-default behavior. |
588 config: { | 591 config: { |
589 // The width of a cell. | 592 // The width of a cell. |
590 cellWidth: 70, | 593 cellWidth: 70, |
591 // The start margin of a cell (left or right according to text direction). | 594 // The start margin of a cell (left or right according to text direction). |
592 cellMarginStart: 20, | 595 cellMarginStart: 20, |
593 // The maximum number of Tiles to be displayed. | 596 // The maximum number of Tiles to be displayed. |
594 maxTileCount: 20, | 597 maxTileCount: 512, |
595 // Whether the TilePage content will be scrollable. | 598 // Whether the TilePage content will be scrollable. |
596 scrollable: true, | 599 scrollable: true, |
597 }, | 600 }, |
598 | 601 |
599 initialize: function() { | 602 initialize: function() { |
600 TilePage.prototype.initialize.apply(this, arguments); | 603 TilePage.prototype.initialize.apply(this, arguments); |
601 | 604 |
602 this.classList.add('apps-page'); | 605 this.classList.add('apps-page'); |
603 | 606 |
604 this.addEventListener('cardselected', this.onCardSelected_); | 607 this.addEventListener('cardselected', this.onCardSelected_); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 if (app && !app.data.notifications_disabled) | 742 if (app && !app.data.notifications_disabled) |
740 app.setupNotification_(notification); | 743 app.setupNotification_(notification); |
741 } | 744 } |
742 | 745 |
743 return { | 746 return { |
744 appNotificationChanged: appNotificationChanged, | 747 appNotificationChanged: appNotificationChanged, |
745 AppsPage: AppsPage, | 748 AppsPage: AppsPage, |
746 launchAppAfterEnable: launchAppAfterEnable, | 749 launchAppAfterEnable: launchAppAfterEnable, |
747 }; | 750 }; |
748 }); | 751 }); |
OLD | NEW |