Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / resources / ntp4 / trash.js
blobc15eb93625814941ffd2ef71583d2bb21d59a92e
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
3 // found in the LICENSE file.
5 /**
6 * @fileoverview Trash
7 * This is the class for the trash can that appears when dragging an app.
8 */
10 cr.define('ntp', function() {
11 'use strict';
13 function Trash(trash) {
14 trash.__proto__ = Trash.prototype;
15 trash.initialize();
16 return trash;
19 Trash.prototype = {
20 __proto__: HTMLDivElement.prototype,
22 initialize: function(element) {
23 this.dragWrapper_ = new cr.ui.DragWrapper(this, this);
26 /**
27 * Determines whether we are interested in the drag data for |e|.
28 * @param {Event} e The event from drag enter.
29 * @return {boolean} True if we are interested in the drag data for |e|.
31 shouldAcceptDrag: function(e) {
32 var tile = ntp.getCurrentlyDraggingTile();
33 if (!tile)
34 return false;
36 return tile.firstChild.canBeRemoved();
39 /**
40 * Drag over handler.
41 * @param {Event} e The drag event.
43 doDragOver: function(e) {
44 ntp.getCurrentlyDraggingTile().dragClone.classList.add(
45 'hovering-on-trash');
46 ntp.setCurrentDropEffect(e.dataTransfer, 'move');
47 e.preventDefault();
50 /**
51 * Drag enter handler.
52 * @param {Event} e The drag event.
54 doDragEnter: function(e) {
55 this.doDragOver(e);
58 /**
59 * Drop handler.
60 * @param {Event} e The drag event.
62 doDrop: function(e) {
63 e.preventDefault();
65 var tile = ntp.getCurrentlyDraggingTile();
66 tile.firstChild.removeFromChrome();
67 tile.landedOnTrash = true;
70 /**
71 * Drag leave handler.
72 * @param {Event} e The drag event.
74 doDragLeave: function(e) {
75 ntp.getCurrentlyDraggingTile().dragClone.classList.remove(
76 'hovering-on-trash');
80 return {
81 Trash: Trash,
83 });