| OLD | NEW |
| 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 var localStrings = new LocalStrings; | 8 var localStrings = new LocalStrings; |
| 9 | 9 |
| 10 var APP_LAUNCH = { | 10 var APP_LAUNCH = { |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 if (tile && !tile.querySelector('.app')) { | 654 if (tile && !tile.querySelector('.app')) { |
| 655 e.preventDefault(); | 655 e.preventDefault(); |
| 656 this.setDropEffect(e.dataTransfer); | 656 this.setDropEffect(e.dataTransfer); |
| 657 } else { | 657 } else { |
| 658 TilePage.prototype.doDragOver.call(this, e); | 658 TilePage.prototype.doDragOver.call(this, e); |
| 659 } | 659 } |
| 660 }, | 660 }, |
| 661 | 661 |
| 662 /** @inheritDoc */ | 662 /** @inheritDoc */ |
| 663 shouldAcceptDrag: function(e) { | 663 shouldAcceptDrag: function(e) { |
| 664 var tile = ntp4.getCurrentlyDraggingTile(); | 664 return !!ntp4.getCurrentlyDraggingTile() || |
| 665 if (tile && tile.querySelector('.bookmark')) | |
| 666 return !!tile.firstChild.data.url; | |
| 667 | |
| 668 return tile || | |
| 669 (e.dataTransfer && e.dataTransfer.types.indexOf('url') != -1); | 665 (e.dataTransfer && e.dataTransfer.types.indexOf('url') != -1); |
| 670 }, | 666 }, |
| 671 | 667 |
| 672 /** @inheritDoc */ | 668 /** @inheritDoc */ |
| 673 addDragData: function(dataTransfer, index) { | 669 addDragData: function(dataTransfer, index) { |
| 674 var sourceId = -1; | 670 var sourceId = -1; |
| 675 var currentlyDraggingTile = ntp4.getCurrentlyDraggingTile(); | 671 var currentlyDraggingTile = ntp4.getCurrentlyDraggingTile(); |
| 676 if (currentlyDraggingTile) { | 672 if (currentlyDraggingTile) { |
| 677 var tileContents = currentlyDraggingTile.firstChild; | 673 var tileContents = currentlyDraggingTile.firstChild; |
| 678 if (tileContents.classList.contains('app')) { | 674 if (tileContents.classList.contains('app')) { |
| 679 sourceId = currentlyDraggingTile.tilePage == this ? | 675 sourceId = currentlyDraggingTile.tilePage == this ? |
| 680 DRAG_SOURCE.SAME_APPS_PANE : DRAG_SOURCE.OTHER_APPS_PANE; | 676 DRAG_SOURCE.SAME_APPS_PANE : DRAG_SOURCE.OTHER_APPS_PANE; |
| 681 this.tileGrid_.insertBefore( | 677 this.tileGrid_.insertBefore( |
| 682 currentlyDraggingTile, | 678 currentlyDraggingTile, |
| 683 this.tileElements_[index]); | 679 this.tileElements_[index]); |
| 684 this.tileMoved(currentlyDraggingTile); | 680 this.tileMoved(currentlyDraggingTile); |
| 685 } else if (currentlyDraggingTile.querySelector('.most-visited')) { | 681 } else if (currentlyDraggingTile.querySelector('.most-visited')) { |
| 686 this.generateAppForLink(tileContents.data); | 682 this.generateAppForLink(tileContents.data); |
| 687 sourceId = DRAG_SOURCE.MOST_VISITED_PANE; | 683 sourceId = DRAG_SOURCE.MOST_VISITED_PANE; |
| 688 } else if (currentlyDraggingTile.querySelector('.bookmark')) { | |
| 689 this.generateAppForLink(tileContents.data); | |
| 690 sourceId = DRAG_SOURCE.BOOKMARK_PANE; | |
| 691 } | 684 } |
| 692 } else { | 685 } else { |
| 693 this.addOutsideData_(dataTransfer, index); | 686 this.addOutsideData_(dataTransfer, index); |
| 694 sourceId = DRAG_SOURCE.OUTSIDE_NTP; | 687 sourceId = DRAG_SOURCE.OUTSIDE_NTP; |
| 695 } | 688 } |
| 696 | 689 |
| 697 assert(sourceId != -1); | 690 assert(sourceId != -1); |
| 698 chrome.send('metricsHandler:recordInHistogram', | 691 chrome.send('metricsHandler:recordInHistogram', |
| 699 ['NewTabPage.AppsPageDragSource', sourceId, DRAG_SOURCE_LIMIT]); | 692 ['NewTabPage.AppsPageDragSource', sourceId, DRAG_SOURCE_LIMIT]); |
| 700 }, | 693 }, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 appNotificationChanged: appNotificationChanged, | 793 appNotificationChanged: appNotificationChanged, |
| 801 AppsPage: AppsPage, | 794 AppsPage: AppsPage, |
| 802 launchAppAfterEnable: launchAppAfterEnable, | 795 launchAppAfterEnable: launchAppAfterEnable, |
| 803 }; | 796 }; |
| 804 }); | 797 }); |
| 805 | 798 |
| 806 // TODO(estade): update the content handlers to use ntp namespace instead of | 799 // TODO(estade): update the content handlers to use ntp namespace instead of |
| 807 // making these global. | 800 // making these global. |
| 808 var appNotificationChanged = ntp4.appNotificationChanged; | 801 var appNotificationChanged = ntp4.appNotificationChanged; |
| 809 var launchAppAfterEnable = ntp4.launchAppAfterEnable; | 802 var launchAppAfterEnable = ntp4.launchAppAfterEnable; |
| OLD | NEW |