<commit_before>/*!
 * xButton v0.1 ~ Copyright (c) 2013 <NAME>, http://galaxyard.com
 * Released under MIT license
 */

(function(){
    var isTouchPad = (/hp-tablet/gi).test(navigator.appVersion),
        hasTouch = 'ontouchstart' in window && !isTouchPad,
        START_EV = hasTouch ? 'touchstart' : 'mousedown',
        MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
        END_EV = hasTouch ? 'touchend' : 'mouseup',
        CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup';

    var XButton = function(el, relations, handler, btnDownClass, delta){
        var btn = this.element = typeof el == 'object' ? el : document.getElementById(el);
        btn.btnData = {};
        btn.btnData.delta = delta || 10;
        btn.btnData.relations = relations;
        btn.btnData.style = btnDownClass;
        btn.btnData.handler = handler;
        btn.addEventListener(START_EV, touchHandler, false);
        btn.addEventListener(MOVE_EV, touchHandler, false);
        btn.addEventListener(END_EV, touchHandler, false);
        if (hasTouch) {
            btn.addEventListener(CANCEL_EV, touchHandler, false);
        }
    };

    XButton.prototype = {
        destroy : function() {
            var btn = this.element;
            btn.btnData = null;
            btn.removeEventListener(START_EV, touchHandler, false );
            btn.removeEventListener(MOVE_EV, touchHandler, false );
            btn.removeEventListener(END_EV, touchHandler, false );
            if (hasTouch) {
                btn.removeEventListener(CANCEL_EV, touchHandler, false);
            }
        }
    };

    function touchHandler(e) {
        var data = this.btnData,
            delta = data.delta,
            point = hasTouch ? e.touches[0] : e;

        if (e.type == START_EV) {
            addClass(data.style, this);
            data.x = point.pageX;
            data.y = point.pageY;
            data.cancel = false;
        } else if (e.type == MOVE_EV) {
            var dx = Math.abs(data.x - point.pageX);
            var dy = Math.abs(data.y - point.pageY);
            if (dx > delta || dy > delta) {
                data.cancel = true;
                removeClass(data.style, this);
            }
        } else if (e.type == END_EV) {
            if (!data.cancel) {
                removeClass(data.style, this);
                //execute handler
                data.handler.call(this, data.relations);
            }
        } else if (e.type == CANCEL_EV) {
            data.cancel = true;
            removeClass(data.style, this);
        }
    }

    function addClass( classname, element ) {
        if (classname == null || classname == '') return;
        var cn = element.className;
        //test for existance
        if( cn.indexOf( classname ) != -1 ) {
            return;
        }
        //add a space if the element already has class
        if( cn != '' ) {
            classname = ' '+classname;
        }
        element.className = cn+classname;
    }

    function removeClass( classname, element ) {
        if (classname == null || classname == '') return;
        var cn = element.className;
        var rxp = new RegExp( "\\s?\\b"+classname+"\\b", "g" );
        cn = cn.replace( rxp, '' );
        element.className = cn;
    }

    window.XButton = function(element, relations, handler, style) {
        return new XButton(element, relations, handler, style);
    };
}());<commit_msg>- fix for touch precision parameter<commit_after>/*!
 * xButton v0.1 ~ Copyright (c) 2013 <NAME>, http://galaxyard.com
 * Released under MIT license
 */

(function(){
    var isTouchPad = (/hp-tablet/gi).test(navigator.appVersion),
        hasTouch = 'ontouchstart' in window && !isTouchPad,
        START_EV = hasTouch ? 'touchstart' : 'mousedown',
        MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
        END_EV = hasTouch ? 'touchend' : 'mouseup',
        CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup';

    var XButton = function(el, relations, handler, btnDownClass, delta){
        var btn = this.element = typeof el == 'object' ? el : document.getElementById(el);
        btn.btnData = {};
        btn.btnData.delta = delta || 10;
        btn.btnData.relations = relations;
        btn.btnData.style = btnDownClass;
        btn.btnData.handler = handler;
        btn.addEventListener(START_EV, touchHandler, false);
        btn.addEventListener(MOVE_EV, touchHandler, false);
        btn.addEventListener(END_EV, touchHandler, false);
        if (hasTouch) {
            btn.addEventListener(CANCEL_EV, touchHandler, false);
        }
    };

    XButton.prototype = {
        destroy : function() {
            var btn = this.element;
            btn.btnData = null;
            btn.removeEventListener(START_EV, touchHandler, false );
            btn.removeEventListener(MOVE_EV, touchHandler, false );
            btn.removeEventListener(END_EV, touchHandler, false );
            if (hasTouch) {
                btn.removeEventListener(CANCEL_EV, touchHandler, false);
            }
        }
    };

    function touchHandler(e) {
        var data = this.btnData,
            delta = data.delta,
            point = hasTouch ? e.touches[0] : e;

        if (e.type == START_EV) {
            addClass(data.style, this);
            data.x = point.pageX;
            data.y = point.pageY;
            data.cancel = false;
        } else if (e.type == MOVE_EV) {
            var dx = Math.abs(data.x - point.pageX);
            var dy = Math.abs(data.y - point.pageY);
            if (dx > delta || dy > delta) {
                data.cancel = true;
                removeClass(data.style, this);
            }
        } else if (e.type == END_EV) {
            if (!data.cancel) {
                removeClass(data.style, this);
                //execute handler
                data.handler.call(this, data.relations);
            }
        } else if (e.type == CANCEL_EV) {
            data.cancel = true;
            removeClass(data.style, this);
        }
    }

    function addClass( classname, element ) {
        if (classname == null || classname == '') return;
        var cn = element.className;
        //test for existance
        if( cn.indexOf( classname ) != -1 ) {
            return;
        }
        //add a space if the element already has class
        if( cn != '' ) {
            classname = ' '+classname;
        }
        element.className = cn+classname;
    }

    function removeClass( classname, element ) {
        if (classname == null || classname == '') return;
        var cn = element.className;
        var rxp = new RegExp( "\\s?\\b"+classname+"\\b", "g" );
        cn = cn.replace( rxp, '' );
        element.className = cn;
    }

    window.XButton = function(element, relations, handler, style, delta) {
        return new XButton(element, relations, handler, style, delta);
    };
}());
{'fraction_non_alphanumeric': 0.12747668997668998, 'fraction_numerical': 0.002913752913752914, 'mean_word_length': 1.8663883089770354, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1137007', 'n_tokens_mistral': 2044, 'n_tokens_neox': 1988, 'n_words': 467}