<commit_before>﻿
/*app.js module*/
module.directive( 'drag', function () {

    var drags = [],
        dragging = new RegExp( '(\\s|^)dragging(\\s|$)' );;

    return {
        restrict: 'A',
        scope: { item: '=drag' },
        link: function ( scope, elem, attr, ctrl ) {

            elem.bind( 'dragstart', function ( e ) {

                if ( drags.length === 0 ) {
                    drags = document.querySelectorAll( '.drop' );
                }

                angular.forEach( drags, function ( value, key ) {

                    value.className = value.className + ' dragging';

                } );

                this.style.opacity = '0.4';

                e.originalEvent.dataTransfer.effectAllowed = 'move';

                e.originalEvent.dataTransfer.setData( 'text', angular.toJson( scope.item ) );

            } );

            
            elem.bind( 'dragend', function ( e ) {

                this.style.opacity = '1';

                angular.forEach( drags, function ( value, key ) {

                    value.className = value.className.replace( dragging, '' );

                } );

            } );

            elem[0].draggable = true;

            elem[0].className = elem[0].className + ' drag';

        }
    };
} );

module.directive( 'drop', function () {

    var drags = [],
        dragging = new RegExp( '(\\s|^)dragging(\\s|$)' );;

    return {
        scope: {
            items: '=drop',
            whendrop: '&'
        },
        link: function ( scope, elem, attr, ctrl ) {

            elem.bind( 'drop', function ( e ) {

                e.stopPropagation();
                e.preventDefault();
                
                if (e.originalEvent.dataTransfer.dropEffect !== 'move') {

                    e.originalEvent.dataTransfer.clearData();

                    return;
                }

                var data = angular.fromJson( e.originalEvent.dataTransfer.getData( 'text' ) );

                scope.$apply( function () {

                    scope.whendrop( { data: data } );

                } );

                if ( drags.length === 0 ) {
                    drags = document.querySelectorAll( '.drop' );
                }

                angular.forEach( drags, function ( value, key ) {

                    value.className = value.className.replace( dragging, '' );

                } );

            } );

            elem.bind( 'dragover', function ( e ) {

                if ( e.preventDefault ) {
                    e.preventDefault();
                }

                return false;

            } );

            elem[0].className = elem[0].className + ' drop';

        }
    };
} );
<commit_msg>Update dragandrop.js<commit_after>angular.module('dragAndDrop', [])
    .directive( 'drag', function () {

    var drags = [],
        dragging = new RegExp( '(\\s|^)dragging(\\s|$)' );;

    return {
        restrict: 'A',
        scope: { item: '=drag' },
        link: function ( scope, elem, attr, ctrl ) {

            elem.bind( 'dragstart', function ( e ) {

                if ( drags.length === 0 ) {
                    drags = document.querySelectorAll( '.drop' );
                }

                angular.forEach( drags, function ( value, key ) {

                    value.className = value.className + ' dragging';

                } );

                this.style.opacity = '0.4';

                e.dataTransfer.effectAllowed = 'move';
                e.dataTransfer.setData( 'text', angular.toJson( scope.item ) );

            } );


            elem.bind( 'dragend', function ( e ) {

                this.style.opacity = '1';

                angular.forEach( drags, function ( value, key ) {

                    value.className = value.className.replace( dragging, '' );

                } );

            } );

            elem[0].draggable = true;

            elem[0].className = elem[0].className + ' drag';

        }
    };
} ).directive( 'drop', function () {

    var drags = [],
        dragging = new RegExp( '(\\s|^)dragging(\\s|$)' );;

    return {
        scope: {
            drop : '=',
            whenDrop: '&'
        },
        link: function ( scope, elem, attr, ctrl ) {

            elem.bind( 'drop', function ( e ) {

                if(e.stopPropagation()){
                    e.preventDefault();
                }

                var data = angular.fromJson( e.dataTransfer.getData( 'text' ) );

                scope.$apply( function () {
                    scope.whenDrop( { data: data } );
                } );

                if ( drags.length === 0 ) {
                    drags = document.querySelectorAll( '.drop' );
                }

                angular.forEach( drags, function ( value, key ) {

                    value.className = value.className.replace( dragging, '' );

                } );

            } );

            elem.bind ( 'dragenter', function(e){
                e.dataTransfer.dropEffect = 'move'
            });

            elem.bind( 'dragover', function ( e ) {

                if ( e.preventDefault ) {
                    e.preventDefault();
                }

                return false;

            } );

            elem[0].className = elem[0].className + ' drop';

        }
    };
} );

{'fraction_non_alphanumeric': 0.14428895612708018, 'fraction_numerical': 0.0037821482602118004, 'mean_word_length': 1.2101964061847055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4637852', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1376, 'n_words': 270}