Rename GetIconID to GetIconId
[chromium-blink-merge.git] / chrome / browser / resources / ntp4 / trash.js
blob463232cb425dc196141b1f3a017b6fa28d69d466
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 /**
14 * @constructor
16 function Trash(trash) {
17 trash.__proto__ = Trash.prototype;
18 trash.initialize();
19 return trash;
22 Trash.prototype = {
23 __proto__: HTMLDivElement.prototype,
25 initialize: function(element) {
26 this.dragWrapper_ = new cr.ui.DragWrapper(this, this);
29 /**
30 * Determines whether we are interested in the drag data for |e|.
31 * @param {Event} e The event from drag enter.
32 * @return {boolean} True if we are interested in the drag data for |e|.
34 shouldAcceptDrag: function(e) {
35 var tile = ntp.getCurrentlyDraggingTile();
36 if (!tile)
37 return false;
39 return tile.firstChild.canBeRemoved();
42 /**
43 * Drag over handler.
44 * @param {Event} e The drag event.
46 doDragOver: function(e) {
47 ntp.getCurrentlyDraggingTile().dragClone.classList.add(
48 'hovering-on-trash');
49 ntp.setCurrentDropEffect(e.dataTransfer, 'move');
50 e.preventDefault();
53 /**
54 * Drag enter handler.
55 * @param {Event} e The drag event.
57 doDragEnter: function(e) {
58 this.doDragOver(e);
61 /**
62 * Drop handler.
63 * @param {Event} e The drag event.
65 doDrop: function(e) {
66 e.preventDefault();
68 var tile = ntp.getCurrentlyDraggingTile();
69 tile.firstChild.removeFromChrome();
70 tile.landedOnTrash = true;
73 /**
74 * Drag leave handler.
75 * @param {Event} e The drag event.
77 doDragLeave: function(e) {
78 ntp.getCurrentlyDraggingTile().dragClone.classList.remove(
79 'hovering-on-trash');
83 return {
84 Trash: Trash,
86 });