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

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: code review changes; rebase 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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 this.addEventListener('mousewheel', this.onMouseWheel_); 410 this.addEventListener('mousewheel', this.onMouseWheel_);
411 this.content_.addEventListener('scroll', this.onScroll_.bind(this)); 411 this.content_.addEventListener('scroll', this.onScroll_.bind(this));
412 412
413 this.dragWrapper_ = new DragWrapper(this.tileGrid_, this); 413 this.dragWrapper_ = new DragWrapper(this.tileGrid_, this);
414 414
415 $('page-list').addEventListener( 415 $('page-list').addEventListener(
416 CardSlider.EventType.CARD_CHANGED, 416 CardSlider.EventType.CARD_CHANGED,
417 this.onCardChanged.bind(this)); 417 this.onCardChanged.bind(this));
418 }, 418 },
419 419
420 get tiles() {
421 return this.tileElements_;
422 },
423
420 get tileCount() { 424 get tileCount() {
421 return this.tileElements_.length; 425 return this.tileElements_.length;
422 }, 426 },
423 427
424 get selected() { 428 get selected() {
425 return Array.prototype.indexOf.call(this.parentNode.children, this) == 429 return Array.prototype.indexOf.call(this.parentNode.children, this) ==
426 ntp4.getCardSlider().currentCard; 430 ntp4.getCardSlider().currentCard;
427 }, 431 },
428 432
429 /** 433 /**
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 487 }
484 this.calculateLayoutValues_(); 488 this.calculateLayoutValues_();
485 489
486 this.positionTile_(index); 490 this.positionTile_(index);
487 }, 491 },
488 492
489 /** 493 /**
490 * Removes the given tile and animates the respositioning of the other 494 * Removes the given tile and animates the respositioning of the other
491 * tiles. 495 * tiles.
492 * @param {HTMLElement} tile The tile to remove from |tileGrid_|. 496 * @param {HTMLElement} tile The tile to remove from |tileGrid_|.
497 * @param {?boolean} animate If true, tiles will animate.
493 */ 498 */
494 removeTile: function(tile) { 499 removeTile: function(tile, animate) {
495 this.classList.add('animating-tile-page'); 500 if (animate)
501 this.classList.add('animating-tile-page');
496 var index = Array.prototype.indexOf.call(this.tileElements_, tile); 502 var index = Array.prototype.indexOf.call(this.tileElements_, tile);
497 tile.parentNode.removeChild(tile); 503 tile.parentNode.removeChild(tile);
498 this.calculateLayoutValues_(); 504 this.calculateLayoutValues_();
499 for (var i = index; i < this.tileElements_.length; i++) { 505 for (var i = index; i < this.tileElements_.length; i++) {
500 this.positionTile_(i); 506 this.positionTile_(i);
501 } 507 }
502 }, 508 },
503 509
504 /** 510 /**
505 * Removes all tiles from the page. 511 * Removes all tiles from the page.
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 */ 1036 */
1031 tileMoved: function(draggedTile) { 1037 tileMoved: function(draggedTile) {
1032 }, 1038 },
1033 }; 1039 };
1034 1040
1035 return { 1041 return {
1036 getCurrentlyDraggingTile: getCurrentlyDraggingTile, 1042 getCurrentlyDraggingTile: getCurrentlyDraggingTile,
1037 TilePage: TilePage, 1043 TilePage: TilePage,
1038 }; 1044 };
1039 }); 1045 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698