| 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 /** | 5 /** |
| 6 * @fileoverview Trash | 6 * @fileoverview Trash |
| 7 * This is the class for the trash can that appears when dragging an app. | 7 * This is the class for the trash can that appears when dragging an app. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('ntp4', function() { | 10 cr.define('ntp4', function() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 initialize: function(element) { | 22 initialize: function(element) { |
| 23 this.dragWrapper_ = new DragWrapper(this, this); | 23 this.dragWrapper_ = new DragWrapper(this, this); |
| 24 }, | 24 }, |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Determines whether we are interested in the drag data for |e|. | 27 * Determines whether we are interested in the drag data for |e|. |
| 28 * @param {Event} e The event from drag enter. | 28 * @param {Event} e The event from drag enter. |
| 29 * @return {bool} | 29 * @return {bool} |
| 30 */ | 30 */ |
| 31 shouldAcceptDrag: function(e) { | 31 shouldAcceptDrag: function(e) { |
| 32 return !!ntp4.getCurrentlyDraggingTile().querySelector('.app'); | 32 var tile = ntp4.getCurrentlyDraggingTile(); |
| 33 if (!tile) |
| 34 return false; |
| 35 |
| 36 var app = tile.querySelector('.app'); |
| 37 if (!app) |
| 38 return false; |
| 39 |
| 40 return app.appData.can_uninstall; |
| 33 }, | 41 }, |
| 34 | 42 |
| 35 /** | 43 /** |
| 36 * Drag over handler. | 44 * Drag over handler. |
| 37 * @param {Event} e The drag event. | 45 * @param {Event} e The drag event. |
| 38 */ | 46 */ |
| 39 doDragOver: function(e) { | 47 doDragOver: function(e) { |
| 48 ntp4.getCurrentlyDraggingTile().dragClone.classList.add( |
| 49 'hovering-on-trash'); |
| 40 e.preventDefault(); | 50 e.preventDefault(); |
| 41 e.dataTransfer.dropEffect = 'move'; | 51 e.dataTransfer.dropEffect = 'move'; |
| 42 }, | 52 }, |
| 43 | 53 |
| 44 /** | 54 /** |
| 45 * Drag enter handler. | 55 * Drag enter handler. |
| 46 * @param {Event} e The drag event. | 56 * @param {Event} e The drag event. |
| 47 */ | 57 */ |
| 48 doDragEnter: function(e) { | 58 doDragEnter: function(e) { |
| 49 this.doDragOver(e); | 59 this.doDragOver(e); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 var page = tile.tilePage; | 76 var page = tile.tilePage; |
| 67 tile.parentNode.removeChild(tile); | 77 tile.parentNode.removeChild(tile); |
| 68 page.cleanupDrag(); | 78 page.cleanupDrag(); |
| 69 }, | 79 }, |
| 70 | 80 |
| 71 /** | 81 /** |
| 72 * Drag leave handler. | 82 * Drag leave handler. |
| 73 * @param {Event} e The drag event. | 83 * @param {Event} e The drag event. |
| 74 */ | 84 */ |
| 75 doDragLeave: function(e) { | 85 doDragLeave: function(e) { |
| 86 ntp4.getCurrentlyDraggingTile().dragClone.classList.remove( |
| 87 'hovering-on-trash'); |
| 76 }, | 88 }, |
| 77 }; | 89 }; |
| 78 | 90 |
| 79 return { | 91 return { |
| 80 Trash: Trash, | 92 Trash: Trash, |
| 81 }; | 93 }; |
| 82 }); | 94 }); |
| OLD | NEW |