<commit_before>(function () {
	var module = angular.module("lvl.directives.dragdrop", ['lvl.services']);

	module.directive('lvlDraggable', ['$rootScope', 'uuid', function($rootScope, uuid) {
		    return {
		        restrict: 'A',
		        scope: {
		            dragid : '='
		        },
		        link: function(scope, el, attrs, controller) {
		        	angular.element(el).attr("draggable", "true");

		            var id;
		            if (scope.dragid) {
		                id = scope.dragid;
		            } else {
	                        id = angular.element(el).attr("id");
	                        if (!id) {
	                            id = uuid.new()
	                            angular.element(el).attr("id", id);
	                        }
		            }
		            
		            el.bind("dragstart", function(e) {
		                e.dataTransfer.setData('text', id);

		                $rootScope.$emit("LVL-DRAG-START");
		            });
		            
		            el.bind("dragend", function(e) {
		                $rootScope.$emit("LVL-DRAG-END");
		            });
		        }
	    	}
		}]);

	module.directive('lvlDropTarget', ['$rootScope', 'uuid', function($rootScope, uuid) {
		    return {
		        restrict: 'A',
		        scope: {
		            onDrop: '&',
		            dropid: '='
		        },
		        link: function(scope, el, attrs, controller) {
		            var id;
		            if (scope.dropid) {
		                id = scope.dropid;
		            } else {
		                id = angular.element(el).attr("id");
		                if (!id) {
		                    id = uuid.new()
		                    angular.element(el).attr("id", id);
		                }
		            }
		                       
		            el.bind("dragover", function(e) {
		              if (e.preventDefault) {
		                e.preventDefault(); // Necessary. Allows us to drop.
		              }
		              
		              e.dataTransfer.dropEffect = 'move';  // See the section on the DataTransfer object.
		              return false;
		            });
		            
		            el.bind("dragenter", function(e) {
		              // this / e.target is the current hover target.
		              angular.element(e.target).addClass('lvl-over');
		            });
		            
		            el.bind("dragleave", function(e) {
		              angular.element(e.target).removeClass('lvl-over');  // this / e.target is previous target element.
		            });
		            
		            el.bind("drop", function(e) {
		              if (e.preventDefault) {
		                e.preventDefault(); // Necessary. Allows us to drop.
		              }

		              if (e.stopPropagation) {
		                e.stopPropagation(); // Necessary. Allows us to drop.
		              }
		            	var data = e.dataTransfer.getData("text");
		                var dest = id;
		                var src = data;
		                
		                scope.onDrop({dragEl: src, dropEl: dest});
		            });

		            $rootScope.$on("LVL-DRAG-START", function() {
		                var el = document.getElementById(id);
		                angular.element(el).addClass("lvl-target");
		            });
		            
		            $rootScope.$on("LVL-DRAG-END", function() {
		                var el = document.getElementById(id);
		                angular.element(el).removeClass("lvl-target");
		                angular.element(el).removeClass("lvl-over");
		            });
		        }
	    	}
		}]);
})();<commit_msg>dragDrop extended with dragData which is a placeholder for storing data object in the dragged items.<commit_after>(function () {
	'use strict';

	var module = angular.module("lvl.directives.dragdrop", ['lvl.services']);

	/**
	 * @ngdoc directive
	 * @name lvlDraggable
	 *
	 * @description
	 * Directive to enable drag on elements
	 *
	 * <example module="lvl.directives.dragdrop">
	 *     <file name="index.html">
	 *
	 *         <div ng-controller="exampleController">
	 *           <div lvl-draggable="true" dragid="someDragId" drag-data="dragObj">
	 *             {{dragObj.name}}
	 *           </div>
	 *         </div>
	 *
	 *     </file>
	 *     <file name="exampleController.js">
	 *
	 *         angular.module('lvl.directives.dragdrop').controller('exampleController', function(scope){
     *              scope.dragObj = { name: '<NAME>', id: 999 };
     *         });
	 *
	 *     </file>
	 * </example>
	 *
	 * @param  {string} dragid A unique string to identificate the draggable element
	 * @param {object} dragData placeholder for a data object which can be 'transported' with the dragging element.
	 *
	 * @restrict A
	 * */
	module.directive('lvlDraggable', ['$rootScope', 'uuid', function ($rootScope, uuid) {
		return {
			restrict: 'A',
			scope: {
				dragid: '=',
				dragData: '='
			},
			link: function (scope, el, attrs, controller) {
				angular.element(el).attr("draggable", "true");

				var id;
				if (scope.dragid) {
					id = scope.dragid;
				} else {
					id = angular.element(el).attr("id") || uuid.new();
				}
				var dragData = angular.isDefined(scope.dragData) ? JSON.stringify(scope.dragData) : undefined;

				el.bind("dragstart", function (e) {
					e.dataTransfer.setData('text', id);
					e.dataTransfer.setData('dragData', dragData);
					$rootScope.$emit("LVL-DRAG-START");
				});

				el.bind("dragend", function (e) {
					$rootScope.$emit("LVL-DRAG-END");
				});
			}
		}
	}]);

	/**
	 * @ngdoc directive
	 * @name lvlDropTarget
	 *
	 * @description
	 * Directive for accepting drop action of draggable elements
	 *
	 * <example module="lvl.directives.dragdrop">
	 *     <file name="index.html">
	 *         <div ng-controller="exampleController">
	 *             <div lvl-drop-target="true" dropid="myTargetZone" on-drop="droppedItem(dragEl, dropEl, dragData);"></div>
	 *         </div>
	 *     </file>
	 *     <file name="exampleController.js">
	 *
	 *         angular.module('lvl.directives.dragdrop').controller('exampleController', function(scope){
     *
     *              scope.droppedItem = function(dragId, dropId, dragData){
     *                  console.log(dragId, dropId, dragData);
     *              };
     *
     *         });
	 *
	 *     </file>
	 * </example>
	 *
	 * @param {function} onDrop Function that emitted when draggable element dropped on the element.
	 * @param {string} dropid A unique string to identificate the element where the draggable element dropped to.
	 *
	 * @restrict A
	 * */
	module.directive('lvlDropTarget', ['$rootScope', 'uuid', function ($rootScope, uuid) {
		return {
			restrict: 'A',
			scope: {
				onDrop: '&',
				dropid: '='
			},
			link: function (scope, el, attrs, controller) {
				var id;
				if (scope.dropid) {
					id = scope.dropid;
				} else {
					id = angular.element(el).attr("id");
					if (!id) {
						id = uuid.new();
						angular.element(el).attr("id", id);
					}
				}

				el.bind("dragover", function (e) {
					if (e.preventDefault) {
						e.preventDefault(); // Necessary. Allows us to drop.
					}

					e.dataTransfer.dropEffect = 'move';  // See the section on the DataTransfer object.
					return false;
				});

				el.bind("dragenter", function (e) {
					// this / e.target is the current hover target.
					angular.element(e.target).addClass('lvl-over');
				});

				el.bind("dragleave", function (e) {
					angular.element(e.target).removeClass('lvl-over');  // this / e.target is previous target element.
				});

				el.bind("drop", function (e) {
					if (e.preventDefault) {
						e.preventDefault(); // Necessary. Allows us to drop.
					}

					if (e.stopPropagation) {
						e.stopPropagation(); // Necessary. Allows us to drop.
					}

					var data = e.dataTransfer.getData("text");
					var dest = id;
					var src = data;

					var dragData = e.dataTransfer.getData('dragData');
					dragData = JSON.parse(dragData) || undefined;
					scope.onDrop({dragEl: src, dropEl: dest, dragData: dragData});
				});

				$rootScope.$on("LVL-DRAG-START", function () {
					var el = document.getElementById(id);
					angular.element(el).addClass("lvl-target");
				});

				$rootScope.$on("LVL-DRAG-END", function () {
					var el = document.getElementById(id);
					angular.element(el).removeClass("lvl-target");
					angular.element(el).removeClass("lvl-over");
				});
			}
		}
	}]);
})();
{'fraction_non_alphanumeric': 0.15042246816613114, 'fraction_numerical': 0.0003570153516601214, 'mean_word_length': 1.73123171920702, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1967817', 'n_tokens_mistral': 2956, 'n_tokens_neox': 2437, 'n_words': 494}