<commit_before>/**
 * @author <NAME>
 * @ver 1.0 - 2015-09-01
 *
 * Użycie:
 *
    (function (box) {
        var w = box.find('[data-widget]');
        var h = w.height();
        box.find('[data-resize]').stopsopamove({
            move: function (e, start, diff) {
                w.css({minHeight: (h + diff.y) + 'px'});
            },
            down: function () {
                h = w.height();
            }
        });
    })(box);
 */
;(function ($) {
    var doc;
    $.fn.stopsopamove = function (opt) {

        if (!doc) {
            doc = $(document);
        }

        opt = $.extend({
            move : $.noop,
            down : $.noop,
            up   : $.noop,
        }, opt || {});

        var t = $(this), hold = false, tmp; // hold button

        function move (e) {
            opt.move.apply(this, [e, tmp, {
                x : e.pageX - tmp.pageX,
                y : e.pageY - tmp.pageY
            }]);
        }

        function down (e) {
            tmp = e;
            opt.down.apply(this, arguments);
            hold = true;
            doc.on('mousemove', move)
        }
        function up() {
            opt.up.apply(this, arguments);
            hold = false;
            doc.off('mousemove', move);
            t.off('mousedown', down).off('mouseup', up)
        }

        return t
            .on('mouseenter', function () {
                if (!hold) {
                    doc.on('mousedown', down).on('mouseup', up)
                }
            })
            .on('mouseleave', function () {
                if (!hold) {
                    doc.off('mousedown', down).off('mouseup', up)
                }
            });
    }
})(jQuery);<commit_msg>revert move<commit_after>/**
 * @author <NAME>
 * @ver 1.0 - 2015-09-01
 *
 * Użycie:
 *
    (function (box) {
        //var w = box.find('[data-here]'); // co przesuwam

        var t;
        var l;


        box.find('[data-here]').stopsopamove({ // co draguję
            down: function () {
                t = parseInt($(this).css('top'), 10);
                l = parseInt($(this).css('left'), 10);
            },
            move: function (e, start, diff) {
                $(this).addClass('move___').css({
                    left : (l + diff.x) + 'px',
                    top  : (t + diff.y) + 'px'
                });
            },
            up: function () {
                $(this).stopsopamove('destroy');
            }
        });
    })($('.map'));

    alternative:
        http://greensock.com/draggable g(green stock Draggable)
 */
;(function ($, name) {

    function log(){try{window.console.log.apply(window.console,arguments);}catch(e){}};
    function error(){try{window.console.error.apply(window.console, arguments);}catch(e){}};

    var
        doc,
        key     = '_'+name,
        tools   = {
            destroy: function () {
                var t = $(this).addClass('red');
                var data = t.data(key);
                if (data) {
                    try {
                        t
                            .off('mouseenter',   data.mouseenter)
                            .off('mouseleave',   data.mouseleave)
                            .off('dragstart',    data.dragstart)
                        ;
                        doc
                            .off('mousemove',   data.move)
                            .off('mousedown',   data.down)
                            .off('mouseup',     data.up)
                        ;
                    }
                    catch (e) {
                        error(e)
                    }
                    t.removeData(key);
                }
                else {
                    error('Element is not an "'+name+'" widget');
                    return t;
                }
            }
        }
    ;

    $.fn[name] = function (opt) {

        var args = Array.prototype.slice.call( arguments, 1);

        if (!doc)
            doc = $(document);

        return $(this).each(function () {
            var
                t       = $(this),
                hold    = false,
                tmp     // hold button
            ;

            if (typeof opt === 'string') {
                if (tools[opt]) {
                    tools[opt].apply(t, args);
                }
                else {
                    error("Method '"+opt+"' is not defined in '"+name+"' plugin");
                }
                return t;
            }

            if (t.data(key)) {
                return error("Widget '"+name+"' is already initialized on this element");
            }

            opt = $.extend({
                move : $.noop,
                down : $.noop,
                up   : $.noop
            }, opt || {});

            function move(e) {
                opt.move.apply(t, [e, tmp, {
                    x : e.pageX - tmp.pageX,
                    y : e.pageY - tmp.pageY
                }]);
            }

            function down(e) {
                tmp = e;
                opt.down.apply(t, arguments);
                hold = true;
                doc.on('mousemove', move);
            }
            function up() {
                opt.up.apply(t, arguments);
                hold = false;
                doc.off('mousemove', move);
                t.off('mousedown', down).off('mouseup', up);
            }

            function mouseenter() {
                if (!hold) {
                    doc.on('mousedown', down).on('mouseup', up);
                }
            }
            function mouseleave() {
                if (!hold) {
                    doc.off('mousedown', down).off('mouseup', up);
                }
            }
            function dragstart(e) { // http://stackoverflow.com/questions/4211909/disable-dragging-an-image-from-an-html-page
                e.preventDefault();
            }

            t
                .on('mouseenter',   mouseenter)
                .on('mouseleave',   mouseleave)
                .on('dragstart',    dragstart)
            ;

            t.data(key, {
                mouseenter: mouseenter,
                mouseleave: mouseleave,
                dragstart:  dragstart,
                move:       move,
                up:         up,
                down:       down
            })
        });
    }
})(jQuery, 'stopsopamove');
{'fraction_non_alphanumeric': 0.14499842221520984, 'fraction_numerical': 0.0050489113284947935, 'mean_word_length': 0.9625386996904025, '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': '3316277', 'n_tokens_mistral': 1836, 'n_tokens_neox': 1700, 'n_words': 343}