OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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('ntp4', function() { | 5 cr.define('ntp4', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 var localStrings = new LocalStrings; | 8 var localStrings = new LocalStrings; |
9 | 9 |
10 /** | 10 /** |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 * Invoked when a node has been added. | 377 * Invoked when a node has been added. |
378 * @param {string} id The id of the newly created bookmark node. | 378 * @param {string} id The id of the newly created bookmark node. |
379 * @param {Object} bookmark The new bookmark node. | 379 * @param {Object} bookmark The new bookmark node. |
380 * @param {boolean} fromCurrentPage True if the action was from this page. | 380 * @param {boolean} fromCurrentPage True if the action was from this page. |
381 */ | 381 */ |
382 bookmarkNodeAdded: function(id, bookmark, fromCurrentPage) { | 382 bookmarkNodeAdded: function(id, bookmark, fromCurrentPage) { |
383 if (this.importing) return; | 383 if (this.importing) return; |
384 if (this.currentlyInFolder_(bookmark.parentId)) { | 384 if (this.currentlyInFolder_(bookmark.parentId)) { |
385 // Hide the import promo if it exists. | 385 // Hide the import promo if it exists. |
386 this.hideImportPromo_(); | 386 this.hideImportPromo_(); |
387 // If source of the add came from this page, show an animated insertion, | 387 // Only add the item if it should be visible. |
388 // otherwise just quietly do it. | 388 if (bookmark.index < MAX_BOOKMARK_TILES) { |
389 this.addTileAt(new Bookmark(bookmark), bookmark.index, fromCurrentPage); | 389 // If source of the add came from this page, show an animated |
390 this.repositionTiles_(); | 390 // insertion, otherwise just quietly do it. |
391 this.addTileAt(new Bookmark(bookmark), bookmark.index, | |
392 fromCurrentPage); | |
393 // Delete extra tiles if they exist. | |
394 while (this.tiles.length > MAX_BOOKMARK_TILES) { | |
395 var tile = this.tiles[this.tiles.length-1]; | |
Evan Stade
2011/09/22 02:52:19
spaces around operators
csilv
2011/09/22 17:07:01
Done.
| |
396 this.removeTile(tile, false); | |
397 } | |
398 this.repositionTiles_(); | |
399 } | |
391 } | 400 } |
392 }, | 401 }, |
393 | 402 |
394 /** | 403 /** |
395 * Invoked when the title or url of a node changes. | 404 * Invoked when the title or url of a node changes. |
396 * @param {string} id The id of the changed node. | 405 * @param {string} id The id of the changed node. |
397 * @param {Object} changeInfo Details of the changed node. | 406 * @param {Object} changeInfo Details of the changed node. |
398 */ | 407 */ |
399 bookmarkNodeChanged: function(id, changeInfo) { | 408 bookmarkNodeChanged: function(id, changeInfo) { |
400 if (this.importing) return; | 409 if (this.importing) return; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 tile.stripeColor = color; | 643 tile.stripeColor = color; |
635 } | 644 } |
636 | 645 |
637 return { | 646 return { |
638 BookmarksPage: BookmarksPage, | 647 BookmarksPage: BookmarksPage, |
639 initBookmarkChevron: initBookmarkChevron, | 648 initBookmarkChevron: initBookmarkChevron, |
640 }; | 649 }; |
641 }); | 650 }); |
642 | 651 |
643 window.addEventListener('load', ntp4.initBookmarkChevron); | 652 window.addEventListener('load', ntp4.initBookmarkChevron); |
OLD | NEW |