Skip to content

Commit c9380d1

Browse files
Add support for jQuery
1 parent 8c53ae5 commit c9380d1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

angular-drag-and-drop-lists.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ angular.module('dndLists', [])
7272
* which is the primary way we communicate with the target element
7373
*/
7474
element.on('dragstart', function(event) {
75+
event = event.originalEvent || event;
76+
7577
// Serialize the data associated with this element. IE only supports the Text drag type
7678
event.dataTransfer.setData("Text", angular.toJson(scope.$eval(attr.dndDraggable)));
7779

@@ -99,6 +101,8 @@ angular.module('dndLists', [])
99101
* we will invoke the callbacks specified with the dnd-moved or dnd-copied attribute.
100102
*/
101103
element.on('dragend', function(event) {
104+
event = event.originalEvent || event;
105+
102106
// If the dropEffect is none it means that the drag action was aborted or
103107
// that the browser does not support this field. In either case we use
104108
// the fallback which was initialized to none
@@ -130,6 +134,8 @@ angular.module('dndLists', [])
130134
* specified with the dnd-selected attribute.
131135
*/
132136
element.on('click', function(event) {
137+
event = event.originalEvent || event;
138+
133139
scope.$apply(function() {
134140
$parse(attr.dndSelected)(scope);
135141
});
@@ -183,6 +189,8 @@ angular.module('dndLists', [])
183189
* is being dragged over our list, or over an child element.
184190
*/
185191
element.on('dragover', function(event) {
192+
event = event.originalEvent || event;
193+
186194
// Disallow drop if it comes from an external source or is not text.
187195
// Usually we would use a custom drag type for this, but IE doesn't support that.
188196
if (!dndDragTypeWorkaround.isDragging) return true;
@@ -258,6 +266,8 @@ angular.module('dndLists', [])
258266
* one child element per array element.
259267
*/
260268
element.on('drop', function(event) {
269+
event = event.originalEvent || event;
270+
261271
// Unserialize the data that was serialized in dragstart. According to the HTML5 specs,
262272
// the "Text" drag type will be converted to text/plain, but IE does not do that.
263273
var transferredObject = JSON.parse(event.dataTransfer.getData("Text")
@@ -298,6 +308,8 @@ angular.module('dndLists', [])
298308
* is still dragging over the list. If you know a better way of doing this, please tell me!
299309
*/
300310
element.on('dragleave', function(event) {
311+
event = event.originalEvent || event;
312+
301313
element.removeClass("dndDragover");
302314
$timeout(function() {
303315
if (!element.hasClass("dndDragover")) {

demo/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
<meta charset="UTF-8">
55
<title>Drag &amp; Drop Lists for angular.js</title>
66

7+
<!-- jQuery is not required, it's only used in the demo to test compatibility -->
8+
<!--<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>-->
9+
710
<!-- angular is the only dependency! -->
811
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
912
<script src="../angular-drag-and-drop-lists.js"></script>

0 commit comments

Comments
 (0)