| 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 //---------------------------------------------------------------------------- | 8 //---------------------------------------------------------------------------- |
| 9 // Constants | 9 // Constants |
| 10 //---------------------------------------------------------------------------- | 10 //---------------------------------------------------------------------------- |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 /** | 298 /** |
| 299 * Whether or not this TilePage is selected. | 299 * Whether or not this TilePage is selected. |
| 300 * @type {boolean} | 300 * @type {boolean} |
| 301 */ | 301 */ |
| 302 get selected() { | 302 get selected() { |
| 303 return Array.prototype.indexOf.call(this.parentNode.children, this) == | 303 return Array.prototype.indexOf.call(this.parentNode.children, this) == |
| 304 ntp.getCardSlider().currentCard; | 304 ntp.getCardSlider().currentCard; |
| 305 }, | 305 }, |
| 306 | 306 |
| 307 /** | 307 /** |
| 308 * The notification content of this tile (if any, otherwise null). | |
| 309 * @type {!HTMLElement} | |
| 310 */ | |
| 311 get notification() { | |
| 312 return this.content_.firstChild.id == 'notification-container' ? | |
| 313 this.content_.firstChild : null; | |
| 314 }, | |
| 315 /** | |
| 316 * The notification content of this tile (if any, otherwise null). | |
| 317 * @type {!HTMLElement} | |
| 318 */ | |
| 319 set notification(node) { | |
| 320 assert(node instanceof HTMLElement, '|node| isn\'t an HTMLElement!'); | |
| 321 // NOTE: Implicitly removes from DOM if |node| is inside it. | |
| 322 this.content_.insertBefore(node, this.content_.firstChild); | |
| 323 this.positionNotification_(); | |
| 324 }, | |
| 325 | |
| 326 /** | |
| 327 * Removes the tilePage from the DOM and cleans up event handlers. | 308 * Removes the tilePage from the DOM and cleans up event handlers. |
| 328 */ | 309 */ |
| 329 remove: function() { | 310 remove: function() { |
| 330 // This checks arguments.length as most remove functions have a boolean | 311 // This checks arguments.length as most remove functions have a boolean |
| 331 // |opt_animate| argument, but that's not necesarilly applicable to | 312 // |opt_animate| argument, but that's not necesarilly applicable to |
| 332 // removing a tilePage. Selecting a different card in an animated way and | 313 // removing a tilePage. Selecting a different card in an animated way and |
| 333 // deleting the card afterward is probably a better choice. | 314 // deleting the card afterward is probably a better choice. |
| 334 assert(typeof arguments[0] != 'boolean', | 315 assert(typeof arguments[0] != 'boolean', |
| 335 'This function takes no |opt_animate| argument.'); | 316 'This function takes no |opt_animate| argument.'); |
| 336 this.tearDown_(); | 317 this.tearDown_(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 396 |
| 416 /** | 397 /** |
| 417 * Called when the page loses selection (in the card selector). | 398 * Called when the page loses selection (in the card selector). |
| 418 * @param {Event} e A custom carddeselected event. | 399 * @param {Event} e A custom carddeselected event. |
| 419 * @private | 400 * @private |
| 420 */ | 401 */ |
| 421 handleCardDeselection_: function(e) { | 402 handleCardDeselection_: function(e) { |
| 422 }, | 403 }, |
| 423 | 404 |
| 424 /** | 405 /** |
| 425 * Position the notification if there's one showing. | |
| 426 * TODO(pedrosimonetti): Fix the position of the notification. | |
| 427 */ | |
| 428 positionNotification_: function() { | |
| 429 }, | |
| 430 | |
| 431 /** | |
| 432 * Scrolls the page in response to an mousewheel event, although the event | 406 * Scrolls the page in response to an mousewheel event, although the event |
| 433 * may have been triggered on a different element. Return true if the | 407 * may have been triggered on a different element. Return true if the |
| 434 * event triggered scrolling, and false otherwise. | 408 * event triggered scrolling, and false otherwise. |
| 435 * This is called explicitly, which allows a consistent experience whether | 409 * This is called explicitly, which allows a consistent experience whether |
| 436 * the user scrolls on the page or on the page switcher, because this | 410 * the user scrolls on the page or on the page switcher, because this |
| 437 * function provides a common conversion factor between wheel delta and | 411 * function provides a common conversion factor between wheel delta and |
| 438 * scroll delta. | 412 * scroll delta. |
| 439 * @param {Event} e The mousewheel event. | 413 * @param {Event} e The mousewheel event. |
| 440 */ | 414 */ |
| 441 handleMouseWheel: function(e) { | 415 handleMouseWheel: function(e) { |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 } | 890 } |
| 917 | 891 |
| 918 return { | 892 return { |
| 919 // TODO(pedrosimonetti): Drag. Delete after porting the rest of the code. | 893 // TODO(pedrosimonetti): Drag. Delete after porting the rest of the code. |
| 920 getCurrentlyDraggingTile2: deprecate, | 894 getCurrentlyDraggingTile2: deprecate, |
| 921 setCurrentDropEffect2: deprecate, | 895 setCurrentDropEffect2: deprecate, |
| 922 Tile2: Tile, | 896 Tile2: Tile, |
| 923 TilePage2: TilePage | 897 TilePage2: TilePage |
| 924 }; | 898 }; |
| 925 }); | 899 }); |
| OLD | NEW |