Init commit. DnD working

This commit is contained in:
2017-03-16 10:02:06 +05:30
commit 984fab4703
5 changed files with 666 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
(function(){
var ngDragEventDirectives = {};
angular.forEach(
'drag dragend dragenter dragexit dragleave dragover dragstart drop'.split(' '),
function(eventName) {
var directiveName = 'ng' + eventName.charAt(0).toUpperCase() + eventName.slice(1);
ngDragEventDirectives[directiveName] = ['$parse', '$rootScope', function($parse, $rootScope) {
return {
restrict: 'A',
compile: function($element, attr) {
var fn = $parse(attr[directiveName], null, true);
return function ngDragEventHandler(scope, element) {
element.on(eventName, function(event) {
var callback = function() {
fn(scope, {$event: event});
};
scope.$apply(callback);
});
};
}
};
}];
}
);
angular
.module('ngDrag', [])
.directive(ngDragEventDirectives);
}());