| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 }, | 285 }, |
| 286 | 286 |
| 287 /** | 287 /** |
| 288 * Removes the app tile from the page. Should be called after the app has | 288 * Removes the app tile from the page. Should be called after the app has |
| 289 * been uninstalled. | 289 * been uninstalled. |
| 290 */ | 290 */ |
| 291 remove: function(opt_animate) { | 291 remove: function(opt_animate) { |
| 292 // Unset the ID immediately, because the app is already gone. But leave | 292 // Unset the ID immediately, because the app is already gone. But leave |
| 293 // the tile on the page as it animates out. | 293 // the tile on the page as it animates out. |
| 294 this.id = ''; | 294 this.id = ''; |
| 295 this.tileCell.doRemove(opt_animate); | 295 |
| 296 if (opt_animate) { |
| 297 var cell = this.tileCell; |
| 298 var tilePage = cell.tilePage; |
| 299 tilePage.dataList_.splice(cell.index, 1); |
| 300 tilePage.animateTileRemoval(cell.index, tilePage.dataList_); |
| 301 } else { |
| 302 this.tileCell.doRemove(opt_animate); |
| 303 } |
| 296 }, | 304 }, |
| 297 | 305 |
| 298 /** | 306 /** |
| 299 * Set the URL of the icon from |this.data_|. This won't actually show the | 307 * Set the URL of the icon from |this.data_|. This won't actually show the |
| 300 * icon until loadIcon() is called (for performance reasons; we don't want | 308 * icon until loadIcon() is called (for performance reasons; we don't want |
| 301 * to load icons until we have to). | 309 * to load icons until we have to). |
| 302 */ | 310 */ |
| 303 setIcon: function() { | 311 setIcon: function() { |
| 304 var src = this.useSmallIcon_ ? this.data_.icon_small : | 312 var src = this.useSmallIcon_ ? this.data_.icon_small : |
| 305 this.data_.icon_big; | 313 this.data_.icon_big; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 * @extends {Tile} | 582 * @extends {Tile} |
| 575 */ | 583 */ |
| 576 TileClass: App, | 584 TileClass: App, |
| 577 | 585 |
| 578 // The config object should be defined by a TilePage subclass if it | 586 // The config object should be defined by a TilePage subclass if it |
| 579 // wants the non-default behavior. | 587 // wants the non-default behavior. |
| 580 config: { | 588 config: { |
| 581 // The width of a cell. | 589 // The width of a cell. |
| 582 cellWidth: 70, | 590 cellWidth: 70, |
| 583 // The start margin of a cell (left or right according to text direction). | 591 // The start margin of a cell (left or right according to text direction). |
| 584 cellMarginStart: 22, | 592 cellMarginStart: 20, |
| 585 // The maximum number of Tiles to be displayed. | 593 // The maximum number of Tiles to be displayed. |
| 586 maxTileCount: 20, | 594 maxTileCount: 20, |
| 587 // Whether the TilePage content will be scrollable. | 595 // Whether the TilePage content will be scrollable. |
| 588 scrollable: true, | 596 scrollable: true, |
| 589 }, | 597 }, |
| 590 | 598 |
| 591 initialize: function() { | 599 initialize: function() { |
| 592 TilePage.prototype.initialize.apply(this, arguments); | 600 TilePage.prototype.initialize.apply(this, arguments); |
| 593 | 601 |
| 594 this.classList.add('apps-page'); | 602 this.classList.add('apps-page'); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 621 insertApp: function(data, animate) { | 629 insertApp: function(data, animate) { |
| 622 var index = this.tiles_.length; | 630 var index = this.tiles_.length; |
| 623 for (var i = 0; i < this.tiles_.length; i++) { | 631 for (var i = 0; i < this.tiles_.length; i++) { |
| 624 if (data.title.toLocaleLowerCase() < | 632 if (data.title.toLocaleLowerCase() < |
| 625 this.tiles_[i].data.title.toLocaleLowerCase()) { | 633 this.tiles_[i].data.title.toLocaleLowerCase()) { |
| 626 index = i; | 634 index = i; |
| 627 break; | 635 break; |
| 628 } | 636 } |
| 629 } | 637 } |
| 630 | 638 |
| 631 var app = new App(data); | 639 if (animate) { |
| 632 this.addTileAt(app, index); | 640 this.dataList_.splice(index, 0, data); |
| 633 this.renderGrid_(); | 641 this.animateTileRestoration(index, this.dataList_); |
| 642 } else { |
| 643 var app = new App(data); |
| 644 this.addTileAt(app, index); |
| 645 } |
| 634 }, | 646 }, |
| 635 | 647 |
| 636 /** | 648 /** |
| 637 * Handler for 'cardselected' event, fired when |this| is selected. The | 649 * Handler for 'cardselected' event, fired when |this| is selected. The |
| 638 * first time this is called, we load all the app icons. | 650 * first time this is called, we load all the app icons. |
| 639 * @private | 651 * @private |
| 640 */ | 652 */ |
| 641 onCardSelected_: function(e) { | 653 onCardSelected_: function(e) { |
| 642 var apps = this.querySelectorAll('.app.icon-loading'); | 654 var apps = this.querySelectorAll('.app.icon-loading'); |
| 643 for (var i = 0; i < apps.length; i++) { | 655 for (var i = 0; i < apps.length; i++) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 if (app && !app.data.notifications_disabled) | 739 if (app && !app.data.notifications_disabled) |
| 728 app.setupNotification_(notification); | 740 app.setupNotification_(notification); |
| 729 } | 741 } |
| 730 | 742 |
| 731 return { | 743 return { |
| 732 appNotificationChanged: appNotificationChanged, | 744 appNotificationChanged: appNotificationChanged, |
| 733 AppsPage: AppsPage, | 745 AppsPage: AppsPage, |
| 734 launchAppAfterEnable: launchAppAfterEnable, | 746 launchAppAfterEnable: launchAppAfterEnable, |
| 735 }; | 747 }; |
| 736 }); | 748 }); |
| OLD | NEW |