<commit_before>/*
 * Copyright (C) 2013 Vanderbilt University, All rights reserved.
 * 
 * Author: <NAME>
 */


"use strict";

define(['./DragEffects',
        './DragConstants'], function (DragEffects, DragConstants) {

    var DEFAULT_Z_INDEX = 100000,
        DEFAULT_APPEND_TO = $('body'),
        DEFAULT_CURSOR_AT = { left: 10, top: 10 };


    var _makeDraggable = function (el, params) {
        el.draggable({
            zIndex: DEFAULT_Z_INDEX,
            appendTo: DEFAULT_APPEND_TO,
            cursorAt: DEFAULT_CURSOR_AT,
            helper: function (event) {
                var helperEl,
                    dragInfo = _createDragInfo(el, params, event);

                if (params && _.isFunction(params.helper)) {
                    helperEl = params.helper.call(el, event, dragInfo);
                } else {
                    helperEl = el.clone();
                }

                //prevent dragged helper to catch any pointer events
                helperEl.css({'pointer-events':'none'});

                //add DRAG info
                helperEl.data(DragConstants.DRAG_INFO, dragInfo);

                return helperEl;
            },
            start: function( event, ui ) {
                if (params && _.isFunction(params.start)) {
                    return params.start.call(el, event);
                }
            },
            drag: function( event, ui ) {
                if (params && _.isFunction(params.drag)) {
                    return params.drag.call(el, event);
                }
            },
            stop: function( event, ui ) {
                if (params && _.isFunction(params.stop)) {
                    return params.stop.call(el, event);
                }
            }
        });
    };


    var _destroyDraggable = function (el) {
        if (_isDraggable(el)) {
            el.draggable("destroy");
        }
    };

    var _enableDraggable = function (el, enabled) {
        var enabledStr = enabled ? 'enable' : 'disable';

        if (_isDraggable(el)) {
            el.draggable(enabledStr);
        }
    };

    var _isDraggable = function (el) {
        return el.hasClass('ui-draggable');
    };

    var _createDragInfo = function (el, params, event) {
        var dragInfo = {};<commit_msg>Added ui arg to drag arg<commit_after>/*
 * Copyright (C) 2013 Vanderbilt University, All rights reserved.
 * 
 * Author: <NAME>
 */


"use strict";

define(['./DragEffects',
        './DragConstants'], function (DragEffects, DragConstants) {

    var DEFAULT_Z_INDEX = 100000,
        DEFAULT_APPEND_TO = $('body'),
        DEFAULT_CURSOR_AT = { left: 10, top: 10 };


    var _makeDraggable = function (el, params) {
        el.draggable({
            zIndex: DEFAULT_Z_INDEX,
            appendTo: DEFAULT_APPEND_TO,
            cursorAt: DEFAULT_CURSOR_AT,
            helper: function (event) {
                var helperEl,
                    dragInfo = _createDragInfo(el, params, event);

                if (params && _.isFunction(params.helper)) {
                    helperEl = params.helper.call(el, event, dragInfo);
                } else {
                    helperEl = el.clone();
                }

                //prevent dragged helper to catch any pointer events
                helperEl.css({'pointer-events':'none'});

                //add DRAG info
                helperEl.data(DragConstants.DRAG_INFO, dragInfo);

                return helperEl;
            },
            start: function( event, ui ) {
                if (params && _.isFunction(params.start)) {
                    return params.start.call(el, event);
                }
            },
            drag: function( event, ui ) {
                if (params && _.isFunction(params.drag)) {
                    return params.drag.call(el, event, ui);
                }
            },
            stop: function( event, ui ) {
                if (params && _.isFunction(params.stop)) {
                    return params.stop.call(el, event);
                }
            }
        });
    };


    var _destroyDraggable = function (el) {
        if (_isDraggable(el)) {
            el.draggable("destroy");
        }
    };

    var _enableDraggable = function (el, enabled) {
        var enabledStr = enabled ? 'enable' : 'disable';

        if (_isDraggable(el)) {
            el.draggable(enabledStr);
        }
    };

    var _isDraggable = function (el) {
        return el.hasClass('ui-draggable');
    };

    var _createDragInfo = function (el, params, event) {
        var dragInfo = {};
{'fraction_non_alphanumeric': 0.11709345589844605, 'fraction_numerical': 0.006128255635806522, 'mean_word_length': 1.501368363437329, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4490144', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1219, 'n_words': 284}