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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 }, | 395 }, |
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 /** | |
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 // ######################################################################### | 405 // ######################################################################### |
432 // Extended Chrome Instant | 406 // Extended Chrome Instant |
433 // ######################################################################### | 407 // ######################################################################### |
434 | 408 |
435 | 409 |
436 // properties | 410 // properties |
437 // ------------------------------------------------------------------------- | 411 // ------------------------------------------------------------------------- |
438 | 412 |
439 // The number of columns. | 413 // The number of columns. |
440 colCount_: 0, | 414 colCount_: 0, |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 } | 872 } |
899 | 873 |
900 return { | 874 return { |
901 // TODO(pedrosimonetti): Drag. Delete after porting the rest of the code. | 875 // TODO(pedrosimonetti): Drag. Delete after porting the rest of the code. |
902 getCurrentlyDraggingTile2: deprecate, | 876 getCurrentlyDraggingTile2: deprecate, |
903 setCurrentDropEffect2: deprecate, | 877 setCurrentDropEffect2: deprecate, |
904 Tile2: Tile, | 878 Tile2: Tile, |
905 TilePage2: TilePage | 879 TilePage2: TilePage |
906 }; | 880 }; |
907 }); | 881 }); |
OLD | NEW |