diff --git a/dev/index.html b/dev/index.html
index dea0cb9..957b233 100644
--- a/dev/index.html
+++ b/dev/index.html
@@ -38,7 +38,7 @@
-
+
diff --git a/src/js/draggableDirective.js b/src/js/draggableDirective.js
index 41984fe..d57ab52 100644
--- a/src/js/draggableDirective.js
+++ b/src/js/draggableDirective.js
@@ -1,49 +1,51 @@
-angular.module('objectTable').directive("allowDrag", function() {
+angular.module('objectTable').directive('allowDrag', function() {
return {
- restrict: "A",
- controller:function(){},
- compile:function (el,attr){
+ restrict: 'A',
+ controller: function() {},
+ compile: function(el, attr) {
- function removeDragClass(element,className){
+ function removeDragClass(element, className) {
var elm = element[0].parentNode.querySelector('.' + className);
- if(!!elm)
+ if (!!elm)
elm.classList.remove(className);
}
- return function pre(scope, element, attrs,ctrl) {
+ return function pre(scope, element, attrs, ctrl) {
element.attr('draggable',true);
- element.bind("dragstart", function( e ) {
+ element.bind('dragstart', function(e) {
ctrl.target = this;
- this.classList.add("dragged");
- e.dataTransfer.setData("text", ctrl.target.cellIndex);
+ this.classList.add('dragged');
+ var ev = e.originalEvent || e; // override event for touch events
+ ev.dataTransfer.setData('text', ctrl.target.cellIndex);
});
- element.bind("dragover", function( e ) {
+ element.bind('dragover', function(e) {
e.preventDefault();
});
- element.bind("dragenter", function( e ) {
+ element.bind('dragenter', function(e) {
ctrl.toTarget = this;
- if(!this.classList.contains("draggedOver") && !this.classList.contains("dragged"))
- this.classList.add("draggedOver");
+ if (!this.classList.contains('draggedOver') && !this.classList.contains('dragged'))
+ this.classList.add('draggedOver');
e.preventDefault();
e.stopPropagation();
});
- element.bind("dragend", function( e ) {
- if(this.classList.contains("dragged"))
- this.classList.remove("dragged");
+ element.bind('dragend', function(e) {
+ if (this.classList.contains('dragged'))
+ this.classList.remove('dragged');
e.preventDefault();
});
- element.bind("dragleave", function( e ) {
- this.classList.remove("draggedOver");
+ element.bind('dragleave', function(e) {
+ this.classList.remove('draggedOver');
});
- element.bind("drop", function( e ) {
+ element.bind('drop', function(e) {
var currentIndex = ctrl.toTarget.cellIndex,
- draggedIndex = parseInt(e.dataTransfer.getData("text"),10);
+ ev = e.originalEvent || e,
+ draggedIndex = parseInt(ev.dataTransfer.getData('text'),10);
removeDragClass(element, 'dragged');
removeDragClass(element, 'draggedOver');
element.parent().controller('objectTable').changeColumnsOrder(currentIndex,draggedIndex);
@@ -53,4 +55,4 @@ angular.module('objectTable').directive("allowDrag", function() {
}
};
-});
\ No newline at end of file
+});