| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 }, | 274 }, |
| 275 | 275 |
| 276 /** | 276 /** |
| 277 * Removes the app tile from the page. Should be called after the app has | 277 * Removes the app tile from the page. Should be called after the app has |
| 278 * been uninstalled. | 278 * been uninstalled. |
| 279 */ | 279 */ |
| 280 remove: function(opt_animate) { | 280 remove: function(opt_animate) { |
| 281 // Unset the ID immediately, because the app is already gone. But leave | 281 // Unset the ID immediately, because the app is already gone. But leave |
| 282 // the tile on the page as it animates out. | 282 // the tile on the page as it animates out. |
| 283 this.id = ''; | 283 this.id = ''; |
| 284 this.tileCell.doRemove(opt_animate); | 284 |
| 285 if (opt_animate) { |
| 286 var cell = this.tileCell; |
| 287 var tilePage = cell.tilePage; |
| 288 tilePage.dataList_.splice(cell.index, 1); |
| 289 tilePage.animateTileRemoval(cell.index, tilePage.dataList_); |
| 290 } else { |
| 291 this.tileCell.doRemove(opt_animate); |
| 292 } |
| 285 }, | 293 }, |
| 286 | 294 |
| 287 /** | 295 /** |
| 288 * Set the URL of the icon from |data_|. This won't actually show the | 296 * Set the URL of the icon from |data_|. This won't actually show the |
| 289 * icon until loadIcon() is called (for performance reasons; we don't want | 297 * icon until loadIcon() is called (for performance reasons; we don't want |
| 290 * to load icons until we have to). | 298 * to load icons until we have to). |
| 291 */ | 299 */ |
| 292 setIcon: function() { | 300 setIcon: function() { |
| 293 var src = this.useSmallIcon_ ? this.data_.icon_small : | 301 var src = this.useSmallIcon_ ? this.data_.icon_small : |
| 294 this.data_.icon_big; | 302 this.data_.icon_big; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 * @extends {Tile} | 580 * @extends {Tile} |
| 573 */ | 581 */ |
| 574 TileClass: App, | 582 TileClass: App, |
| 575 | 583 |
| 576 // The config object should be defined by a TilePage subclass if it | 584 // The config object should be defined by a TilePage subclass if it |
| 577 // wants the non-default behavior. | 585 // wants the non-default behavior. |
| 578 config: { | 586 config: { |
| 579 // The width of a cell. | 587 // The width of a cell. |
| 580 cellWidth: 70, | 588 cellWidth: 70, |
| 581 // The start margin of a cell (left or right according to text direction). | 589 // The start margin of a cell (left or right according to text direction). |
| 582 cellMarginStart: 22, | 590 cellMarginStart: 20, |
| 583 // The maximum number of Tiles to be displayed. | 591 // The maximum number of Tiles to be displayed. |
| 584 maxTileCount: 20, | 592 maxTileCount: 20, |
| 585 // Whether the TilePage content will be scrollable. | 593 // Whether the TilePage content will be scrollable. |
| 586 scrollable: true, | 594 scrollable: true, |
| 587 }, | 595 }, |
| 588 | 596 |
| 589 initialize: function() { | 597 initialize: function() { |
| 590 TilePage.prototype.initialize.apply(this, arguments); | 598 TilePage.prototype.initialize.apply(this, arguments); |
| 591 | 599 |
| 592 this.classList.add('apps-page'); | 600 this.classList.add('apps-page'); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 619 insertApp: function(data, animate) { | 627 insertApp: function(data, animate) { |
| 620 var index = this.tiles_.length; | 628 var index = this.tiles_.length; |
| 621 for (var i = 0; i < this.tiles_.length; i++) { | 629 for (var i = 0; i < this.tiles_.length; i++) { |
| 622 if (data.title.toLocaleLowerCase() < | 630 if (data.title.toLocaleLowerCase() < |
| 623 this.tiles_[i].data.title.toLocaleLowerCase()) { | 631 this.tiles_[i].data.title.toLocaleLowerCase()) { |
| 624 index = i; | 632 index = i; |
| 625 break; | 633 break; |
| 626 } | 634 } |
| 627 } | 635 } |
| 628 | 636 |
| 629 var app = new App(); | 637 if (animate) { |
| 630 app.data = data; | 638 this.dataList_.splice(index, 0, data); |
| 631 this.addTileAt(app, index); | 639 this.animateTileRestoration(index, this.dataList_); |
| 632 this.renderGrid_(); | 640 } else { |
| 641 var app = new App(); |
| 642 app.data = data; |
| 643 this.addTileAt(app, index); |
| 644 this.renderGrid_(); |
| 645 } |
| 633 }, | 646 }, |
| 634 | 647 |
| 635 /** | 648 /** |
| 636 * Handler for 'cardselected' event, fired when |this| is selected. The | 649 * Handler for 'cardselected' event, fired when |this| is selected. The |
| 637 * first time this is called, we load all the app icons. | 650 * first time this is called, we load all the app icons. |
| 638 * @private | 651 * @private |
| 639 */ | 652 */ |
| 640 onCardSelected_: function(e) { | 653 onCardSelected_: function(e) { |
| 641 var apps = this.querySelectorAll('.app.icon-loading'); | 654 var apps = this.querySelectorAll('.app.icon-loading'); |
| 642 for (var i = 0; i < apps.length; i++) { | 655 for (var i = 0; i < apps.length; i++) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 if (app && !app.data.notifications_disabled) | 852 if (app && !app.data.notifications_disabled) |
| 840 app.setupNotification_(notification); | 853 app.setupNotification_(notification); |
| 841 } | 854 } |
| 842 | 855 |
| 843 return { | 856 return { |
| 844 appNotificationChanged: appNotificationChanged, | 857 appNotificationChanged: appNotificationChanged, |
| 845 AppsPage: AppsPage, | 858 AppsPage: AppsPage, |
| 846 launchAppAfterEnable: launchAppAfterEnable, | 859 launchAppAfterEnable: launchAppAfterEnable, |
| 847 }; | 860 }; |
| 848 }); | 861 }); |
| OLD | NEW |