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(); | 639 if (animate) { |
632 app.data = data; | 640 this.dataList_.splice(index, 0, data); |
633 this.addTileAt(app, index); | 641 this.animateTileRestoration(index, this.dataList_); |
634 this.renderGrid_(); | 642 } else { |
| 643 var app = new App(); |
| 644 app.data = data; |
| 645 this.addTileAt(app, index); |
| 646 } |
635 }, | 647 }, |
636 | 648 |
637 /** | 649 /** |
638 * Handler for 'cardselected' event, fired when |this| is selected. The | 650 * Handler for 'cardselected' event, fired when |this| is selected. The |
639 * first time this is called, we load all the app icons. | 651 * first time this is called, we load all the app icons. |
640 * @private | 652 * @private |
641 */ | 653 */ |
642 onCardSelected_: function(e) { | 654 onCardSelected_: function(e) { |
643 var apps = this.querySelectorAll('.app.icon-loading'); | 655 var apps = this.querySelectorAll('.app.icon-loading'); |
644 for (var i = 0; i < apps.length; i++) { | 656 for (var i = 0; i < apps.length; i++) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 if (app && !app.data.notifications_disabled) | 740 if (app && !app.data.notifications_disabled) |
729 app.setupNotification_(notification); | 741 app.setupNotification_(notification); |
730 } | 742 } |
731 | 743 |
732 return { | 744 return { |
733 appNotificationChanged: appNotificationChanged, | 745 appNotificationChanged: appNotificationChanged, |
734 AppsPage: AppsPage, | 746 AppsPage: AppsPage, |
735 launchAppAfterEnable: launchAppAfterEnable, | 747 launchAppAfterEnable: launchAppAfterEnable, |
736 }; | 748 }; |
737 }); | 749 }); |
OLD | NEW |