Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: chrome/browser/resources/ntp4/tile_page.js

Issue 7713026: [ntp4] Observe and process bookmark change notifications from the bookmarks data model. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix unit tests Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // We can't pass the currently dragging tile via dataTransfer because of 8 // We can't pass the currently dragging tile via dataTransfer because of
9 // http://crbug.com/31037 9 // http://crbug.com/31037
10 var currentlyDraggingTile = null; 10 var currentlyDraggingTile = null;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 this.onNodeInsertedIntoDocument_); 406 this.onNodeInsertedIntoDocument_);
407 this.content_.addEventListener('scroll', this.onScroll_.bind(this)); 407 this.content_.addEventListener('scroll', this.onScroll_.bind(this));
408 408
409 this.dragWrapper_ = new DragWrapper(this.tileGrid_, this); 409 this.dragWrapper_ = new DragWrapper(this.tileGrid_, this);
410 410
411 $('page-list').addEventListener( 411 $('page-list').addEventListener(
412 CardSlider.EventType.CARD_CHANGED, 412 CardSlider.EventType.CARD_CHANGED,
413 this.onCardChanged.bind(this)); 413 this.onCardChanged.bind(this));
414 }, 414 },
415 415
416 get tiles() {
417 return this.tileElements_;
418 },
419
416 get tileCount() { 420 get tileCount() {
417 return this.tileElements_.length; 421 return this.tileElements_.length;
418 }, 422 },
419 423
420 get selected() { 424 get selected() {
421 return Array.prototype.indexOf.call(this.parentNode.children, this) == 425 return Array.prototype.indexOf.call(this.parentNode.children, this) ==
422 ntp4.getCardSlider().currentCard; 426 ntp4.getCardSlider().currentCard;
423 }, 427 },
424 428
425 /** 429 /**
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 483 }
480 this.calculateLayoutValues_(); 484 this.calculateLayoutValues_();
481 485
482 this.positionTile_(index); 486 this.positionTile_(index);
483 }, 487 },
484 488
485 /** 489 /**
486 * Removes the given tile and animates the respositioning of the other 490 * Removes the given tile and animates the respositioning of the other
487 * tiles. 491 * tiles.
488 * @param {HTMLElement} tile The tile to remove from |tileGrid_|. 492 * @param {HTMLElement} tile The tile to remove from |tileGrid_|.
493 * @param {?boolean} animate If true, tiles will animate.
489 */ 494 */
490 removeTile: function(tile) { 495 removeTile: function(tile, animate) {
491 this.classList.add('animating-tile-page'); 496 if (animate)
497 this.classList.add('animating-tile-page');
492 var index = Array.prototype.indexOf.call(this.tileElements_, tile); 498 var index = Array.prototype.indexOf.call(this.tileElements_, tile);
493 tile.parentNode.removeChild(tile); 499 tile.parentNode.removeChild(tile);
494 this.calculateLayoutValues_(); 500 this.calculateLayoutValues_();
495 for (var i = index; i < this.tileElements_.length; i++) { 501 for (var i = index; i < this.tileElements_.length; i++) {
496 this.positionTile_(i); 502 this.positionTile_(i);
497 } 503 }
498 }, 504 },
499 505
500 /** 506 /**
501 * Removes all tiles from the page. 507 * Removes all tiles from the page.
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 */ 1012 */
1007 tileMoved: function(draggedTile) { 1013 tileMoved: function(draggedTile) {
1008 }, 1014 },
1009 }; 1015 };
1010 1016
1011 return { 1017 return {
1012 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1018 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1013 TilePage: TilePage, 1019 TilePage: TilePage,
1014 }; 1020 };
1015 }); 1021 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698