aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/panels/Timeline/DragDrop.js160
1 files changed, 0 insertions, 160 deletions
diff --git a/js/panels/Timeline/DragDrop.js b/js/panels/Timeline/DragDrop.js
deleted file mode 100644
index 739eac93..00000000
--- a/js/panels/Timeline/DragDrop.js
+++ /dev/null
@@ -1,160 +0,0 @@
1/* <copyright>
2Copyright (c) 2012, Motorola Mobility, Inc
3All Rights Reserved.
4BSD License.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9 - Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11 - Redistributions in binary form must reproduce the above copyright
12 notice, this list of conditions and the following disclaimer in the
13 documentation and/or other materials provided with the distribution.
14 - Neither the name of Motorola Mobility nor the names of its contributors
15 may be used to endorse or promote products derived from this software
16 without specific prior written permission.
17
18THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28POSSIBILITY OF SUCH DAMAGE.
29</copyright> */
30
31var Montage = require("montage/core/core").Montage;
32var Composer = require("montage/ui/composer/composer").Composer;
33
34exports.DragDropComposer = Montage.create(Composer, {
35
36 draggable: {
37 value: true
38 },
39
40 droppable: {
41 value: true
42 },
43
44 identifier: {
45 value: "generic"
46 },
47
48 _dragover: {
49 value: false
50 },
51
52 load: {
53 value: function() {
54 //TODO: to make this work even better check to see if this is a component or not
55 //right now it does not support data-montage id's
56 this.element.addEventListener("mouseover", this, true);
57 this.element.addEventListener("mouseout", this, true);
58 this.component.element.addEventListener("dragenter", this, true);
59 this.component.element.addEventListener("dragleave", this, true);
60 this.component.element.addEventListener("dragend", this, true);
61 this.component.element.addEventListener("drop", this, true);
62 this.component.element.addEventListener("dragover", this, true);
63 this.component.element.addEventListener("dragstart", this, true);
64 }
65 },
66
67 unload: {
68 value: function() {
69 this.element.removeEventListener("mouseover", this, true);
70 this.element.removeEventListener("mouseout", this, true);
71 this.component.element.removeEventListener("dragenter", this, true);
72 this.component.element.removeEventListener("dragleave", this, true);
73 this.component.element.removeEventListener("dragend", this, true);
74 this.component.element.removeEventListener("drop", this, true);
75 this.component.element.removeEventListener("dragover", this, true);
76 this.component.element.removeEventListener("dragstart", this, true);
77 }
78 },
79
80 captureMouseover: {
81 value: function(e) {
82 if(this.draggable) {
83 this.component.element.draggable = true;
84 }
85 }
86 },
87
88 captureMouseout: {
89 value: function(e) {
90 this.component.element.draggable = false;
91 }
92 },
93
94 /* ------ Drag Drop Events ------- */
95
96 // This Function will determine what is being moved
97 captureDragstart: {
98 value:function(e) {
99 e.dataTransfer.effectAllowed = 'move';
100 e.dataTransfer.setData('Text', this.identifier);
101 this.component.element.classList.add("dragging");
102 this.component.application.ninja.componentBeingDragged = this.component;
103 }
104 },
105
106 captureDragenter: {
107 value: function(e) {
108
109 }
110 },
111
112 captureDragover: {
113 value:function(e) {
114 e.preventDefault();
115 e.stopImmediatePropagation();
116 if (!this._dragover) {
117 this._dragover = true;
118 this.component.element.classList.add("dragOver");
119 }
120 }
121 },
122
123 captureDragleave: {
124 value: function(e) {
125 if (this._dragover) {
126 this._dragover = false;
127 this.component.element.classList.remove("dragOver");
128 }
129 }
130 },
131
132 captureDrop: {
133 value:function(e) {
134 e.stopPropagation(); // Stops some browsers from redirecting.
135 e.preventDefault();
136 if (this._dragover) {
137 this._dragover = false;
138 this.component.element.classList.remove("dragOver");
139 if (this.identifier === e.dataTransfer.getData("Text")) {
140 if(this.component.application.ninja.componentBeingDragged !== this.component) {
141 dropEvent = document.createEvent("CustomEvent");
142 dropEvent.initCustomEvent("dropped", true, false, null);
143 dropEvent.draggedComponent = this.component.application.ninja.componentBeingDragged;
144 dropEvent.droppedComponent = this.component;
145 this.component.dispatchEvent(dropEvent);
146 }
147 }
148 this.component.application.ninja.componentBeingDragged = null;
149 }
150
151 }
152 },
153
154 captureDragend: {
155 value:function(e) {
156 this.component.element.classList.remove("dragging");
157 }
158 }
159
160});