| 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 /** | 5 /** |
| 6 * @fileoverview New tab page | 6 * @fileoverview New tab page |
| 7 * This is the main code for the new tab page. NewTabView manages page list, | 7 * This is the main code for the new tab page. NewTabView manages page list, |
| 8 * dot list and handles apps pages callbacks from backend. It also handles | 8 * dot list and handles apps pages callbacks from backend. It also handles |
| 9 * the layout of the Bottom Panel and the global UI states of the New Tab Page. | 9 * the layout of the Bottom Panel and the global UI states of the New Tab Page. |
| 10 */ | 10 */ |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 * | 422 * |
| 423 * Note that calls to this function can occur at any time, not just in | 423 * Note that calls to this function can occur at any time, not just in |
| 424 * response to a getApps request. For example, when a user | 424 * response to a getApps request. For example, when a user |
| 425 * installs/uninstalls an app on another synchronized devices. | 425 * installs/uninstalls an app on another synchronized devices. |
| 426 * @param {Object} data An object with all the data on available | 426 * @param {Object} data An object with all the data on available |
| 427 * applications. | 427 * applications. |
| 428 */ | 428 */ |
| 429 getAppsCallback: function(data) { | 429 getAppsCallback: function(data) { |
| 430 assert(loadTimeData.getBoolean('showApps')); | 430 assert(loadTimeData.getBoolean('showApps')); |
| 431 | 431 |
| 432 var page = this.appsPage; | |
| 433 var state = page && page.getTileRepositioningState(); | |
| 434 if (state) { | |
| 435 if (state.isRemoving) | |
| 436 page.animateTileRemoval(state.index, data); | |
| 437 else | |
| 438 page.animateTileRestoration(state.index, data); | |
| 439 | |
| 440 page.resetTileRepositioningState(); | |
| 441 return; | |
| 442 } | |
| 443 | |
| 444 var startTime = Date.now(); | 432 var startTime = Date.now(); |
| 445 | 433 |
| 446 | |
| 447 // Get the array of apps and add any special synthesized entries. | 434 // Get the array of apps and add any special synthesized entries. |
| 448 var apps = data.apps; | 435 var apps = data.apps; |
| 449 | 436 |
| 450 // Sort alphabetically. | 437 // Sort alphabetically. |
| 451 apps.sort(function(a, b) { | 438 apps.sort(function(a, b) { |
| 452 return a.title.toLocaleLowerCase() > b.title.toLocaleLowerCase() ? 1 : | 439 return a.title.toLocaleLowerCase() > b.title.toLocaleLowerCase() ? 1 : |
| 453 a.title.toLocaleLowerCase() < b.title.toLocaleLowerCase() ? -1 : 0; | 440 a.title.toLocaleLowerCase() < b.title.toLocaleLowerCase() ? -1 : 0; |
| 454 }); | 441 }); |
| 455 | 442 |
| 456 // An app to animate (in case it was just installed). | 443 // An app to animate (in case it was just installed). |
| 457 var highlightApp; | 444 var highlightApp; |
| 458 | 445 |
| 459 if (this.appsPage) { | 446 if (this.appsPage) { |
| 460 this.appsPage.removeAllTiles(); | 447 this.appsPage.removeAllTiles(); |
| 461 } else { | 448 } else { |
| 462 this.appendTilePage(new ntp.AppsPage(), | 449 var page = new ntp.AppsPage(); |
| 463 loadTimeData.getString('appDefaultPageName')); | 450 page.setDataList(apps); |
| 451 this.appendTilePage(page, loadTimeData.getString('appDefaultPageName')); |
| 464 } | 452 } |
| 465 | 453 |
| 466 for (var i = 0; i < apps.length; i++) { | 454 for (var i = 0; i < apps.length; i++) { |
| 467 var app = apps[i]; | 455 var app = apps[i]; |
| 468 if (app.id == this.highlightAppId) | 456 if (app.id == this.highlightAppId) |
| 469 highlightApp = app; | 457 highlightApp = app; |
| 470 else | 458 else |
| 471 this.appsPage.insertApp(app, false); | 459 this.appsPage.insertApp(app, false); |
| 472 } | 460 } |
| 473 | 461 |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 setRecentlyClosedTabs: noop, | 1145 setRecentlyClosedTabs: noop, |
| 1158 showNotification: showNotification, | 1146 showNotification: showNotification, |
| 1159 themeChanged: themeChanged, | 1147 themeChanged: themeChanged, |
| 1160 updateLogin: noop, | 1148 updateLogin: noop, |
| 1161 }; | 1149 }; |
| 1162 }); | 1150 }); |
| 1163 | 1151 |
| 1164 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 1152 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
| 1165 | 1153 |
| 1166 var toCssPx = cr.ui.toCssPx; | 1154 var toCssPx = cr.ui.toCssPx; |
| OLD | NEW |