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 var APP_LAUNCH = { | 8 var APP_LAUNCH = { |
9 // The histogram buckets (keep in sync with extension_constants.h). | 9 // The histogram buckets (keep in sync with extension_constants.h). |
10 NTP_APPS_MAXIMIZED: 0, | 10 NTP_APPS_MAXIMIZED: 0, |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 | 656 |
657 this.addEventListener('tilePage:tile_added', this.onTileAdded_); | 657 this.addEventListener('tilePage:tile_added', this.onTileAdded_); |
658 | 658 |
659 this.content_.addEventListener('scroll', this.onScroll_.bind(this)); | 659 this.content_.addEventListener('scroll', this.onScroll_.bind(this)); |
660 }, | 660 }, |
661 | 661 |
662 /** | 662 /** |
663 * Similar to appendApp, but it respects the app_launch_ordinal field of | 663 * Similar to appendApp, but it respects the app_launch_ordinal field of |
664 * |appData|. | 664 * |appData|. |
665 * @param {Object} appData The data that describes the app. | 665 * @param {Object} appData The data that describes the app. |
666 * @param {boolean} animate Whether to animate the insertion. | |
666 */ | 667 */ |
667 insertApp: function(appData) { | 668 insertApp: function(appData, animate) { |
668 var index = this.tileElements_.length; | 669 var index = this.tileElements_.length; |
669 for (var i = 0; i < this.tileElements_.length; i++) { | 670 for (var i = 0; i < this.tileElements_.length; i++) { |
670 if (appData.app_launch_ordinal < | 671 if (appData.app_launch_ordinal < |
671 this.tileElements_[i].firstChild.appData.app_launch_ordinal) { | 672 this.tileElements_[i].firstChild.appData.app_launch_ordinal) { |
672 index = i; | 673 index = i; |
673 break; | 674 break; |
674 } | 675 } |
675 } | 676 } |
676 | 677 |
677 this.addTileAt(new App(appData), index, false); | 678 this.addTileAt(new App(appData), index, animate); |
678 }, | 679 }, |
679 | 680 |
680 /** | 681 /** |
681 * Handler for 'cardselected' event, fired when |this| is selected. The | 682 * Handler for 'cardselected' event, fired when |this| is selected. The |
682 * first time this is called, we load all the app icons. | 683 * first time this is called, we load all the app icons. |
683 * @private | 684 * @private |
684 */ | 685 */ |
685 onCardSelected_: function(e) { | 686 onCardSelected_: function(e) { |
686 var apps = this.querySelectorAll('.app.icon-loading'); | 687 var apps = this.querySelectorAll('.app.icon-loading'); |
687 for (var i = 0; i < apps.length; i++) { | 688 for (var i = 0; i < apps.length; i++) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
742 return; | 743 return; |
743 for (var i = 0; i < this.tileElements_.length; i++) { | 744 for (var i = 0; i < this.tileElements_.length; i++) { |
744 var app = this.tileElements_[i].firstChild; | 745 var app = this.tileElements_[i].firstChild; |
745 assert(app instanceof App); | 746 assert(app instanceof App); |
746 if (app.currentBubbleShowing_) | 747 if (app.currentBubbleShowing_) |
747 app.currentBubbleShowing_.resizeAndReposition(); | 748 app.currentBubbleShowing_.resizeAndReposition(); |
748 } | 749 } |
749 }, | 750 }, |
750 | 751 |
751 /** @inheritDoc */ | 752 /** @inheritDoc */ |
752 doDragOver: function(e) { | |
753 var tile = ntp.getCurrentlyDraggingTile(); | |
754 if (tile && !tile.querySelector('.app')) { | |
755 e.preventDefault(); | |
756 this.setDropEffect(e.dataTransfer); | |
Dan Beam
2012/05/15 01:46:03
this was avoiding calling TilePage#updateDropIndic
Evan Stade
2012/05/15 03:01:11
yes this is intentional, you will notice that most
Dan Beam
2012/05/15 04:00:44
OK, fixed outside data handling to match.
| |
757 } else { | |
758 TilePage.prototype.doDragOver.call(this, e); | |
759 } | |
760 }, | |
761 | |
762 /** @inheritDoc */ | |
763 shouldAcceptDrag: function(e) { | 753 shouldAcceptDrag: function(e) { |
764 if (ntp.getCurrentlyDraggingTile()) | 754 if (ntp.getCurrentlyDraggingTile()) |
765 return true; | 755 return true; |
766 if (!e.dataTransfer || !e.dataTransfer.types) | 756 if (!e.dataTransfer || !e.dataTransfer.types) |
767 return false; | 757 return false; |
768 return Array.prototype.indexOf.call(e.dataTransfer.types, | 758 return Array.prototype.indexOf.call(e.dataTransfer.types, |
769 'text/uri-list') != -1; | 759 'text/uri-list') != -1; |
770 }, | 760 }, |
771 | 761 |
772 /** @inheritDoc */ | 762 /** @inheritDoc */ |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
896 app.setupNotification_(notification); | 886 app.setupNotification_(notification); |
897 } | 887 } |
898 | 888 |
899 return { | 889 return { |
900 APP_LAUNCH: APP_LAUNCH, | 890 APP_LAUNCH: APP_LAUNCH, |
901 appNotificationChanged: appNotificationChanged, | 891 appNotificationChanged: appNotificationChanged, |
902 AppsPage: AppsPage, | 892 AppsPage: AppsPage, |
903 launchAppAfterEnable: launchAppAfterEnable, | 893 launchAppAfterEnable: launchAppAfterEnable, |
904 }; | 894 }; |
905 }); | 895 }); |
OLD | NEW |