<commit_before>//--
// Copyright (c) 2012, Net-ng.
// All rights reserved.
//
// This software is licensed under the BSD License, as described in
// the file LICENSE.txt, which you should have received as part of
// this distribution.
//--

(function () {
    'use strict';
    var Y = YAHOO.util,
        Dom = Y.Dom,
        Event = Y.Event,
        ECN = Dom.getElementsByClassName,
        NS = YAHOO.namespace('kansha'),
        DDM = YAHOO.util.DDM;

    /**
     * Helper log function
     */
    var log = function (args) {
        var s = '', i;
        for (i in args) {
            s = s + args[i] + ' ';
        }
        console.log(s);
    };
    /**
     * A DnD proxy that scrolls his container
     * Sources:
     *  - http://new.davglass.com/files/yui/dd15/
     *  - yui dragdrop.js source
     */
    var ScrollProxy = function (id, sGroup, config) {
        ScrollProxy.superclass.constructor.apply(this, arguments);
        // Can drag using A elements
        this.invalidHandleTypes.A = false;
        // Disable drag for textarea and input elements
        this.invalidHandleTypes.TEXTAREA = 'TEXTAREA';
        this.invalidHandleTypes.INPUT = 'INPUT';
        // Element used for scrolling
        this.scrollParent = Dom.get(config.scrollParent);
        // Attributes used to determine the drag orientation
        this.lastX = 0;
        this.goingRight = false;
        this.lastY = 0;
        this.goingDown = false;
        this.scrollInt = null;
    };
    YAHOO.extend(ScrollProxy, YAHOO.util.DDProxy, {
        /**
         * Auto-scroll the lists div if the dragged object has been moved
         * beyond the visible viewport boundary.
         * @method autoScroll
         * @param {int} x the drag element's x position
         * @param {int} y the drag element's y position
         * @param {int} h the height of the drag element
         * @param {int} w the width of the drag element
         */
        autoScroll: function (x, y, h, w) {

            // How many pixels to scroll per autoscroll op.  This helps to
            // reduce clunky scrolling. IE is more sensitive about this ...
            // it needs this value to be higher.
            var scrAmt = (document.all) ? 80 : 30;
            // How close to the edge the cursor must be before we scroll
            var thresh = 50;

            // Horizontal scrolling is done on the scrollParent element
            // (not the window)
            // Right marker coordinates
            var rightMarker = Dom.getRegion(this.scrollParent).right - thresh;
            // Left marker coordinates
            var leftMarker = Dom.getRegion(this.scrollParent).left + thresh;
            // Current scroll left
            var sl = this.scrollParent.scrollLeft;

            // Scroll left
            YAHOO.log('autoScroll: ' + sl + '/' + x + '/' + leftMarker);

            if (sl > 0 && x < leftMarker) {
                this.scrollParent.scrollLeft = sl - scrAmt;
            }
            // Scroll right
            if (x + w > rightMarker) {
                this.scrollParent.scrollLeft = sl + scrAmt;
            }

            // Vertical scrolling
            // For mobile, scroll the client window
            if (YAHOO.kansha.app.isMobile()) {
                // Current scroll top
                var st = this.DDM.getScrollTop();
                // Top marker coordinates
                var topMarker = st + thresh;
                // Bottom marker coordinates
                var bottomMarker = st + this.DDM.getClientHeight() - thresh;

                // Scroll top
                if (st > 0 && y < topMarker) {
                    window.scrollTo(this.scrollParent.scrollLeft, st - scrAmt);
                }
                // Scroll bottom
                if (y + h > bottomMarker) {
                    window.scrollTo(this.scrollParent.scrollLeft, st + scrAmt);
                }
            }
            DDM.refreshCache();
        },
        /**
         * Update drag orientation
         */
        onDrag: function (e) {
            var c = Event.getXY(e);
            this.goingRight = (c[0] >= this.lastX);
            this.goingDown = (c[1] >= this.lastY);
            this.lastX = c[0];
            this.lastY = c[1];
        }
    });

    NS.dnd = {
        listMarker: undefined,
        cardMarker: undefined,
        init: function () {
            var target = new YAHOO.util.DDTarget(Dom.get('list-target'), 'list'),
                listBody;
            NS.dnd.listMarker = document.createElement('div');
            Dom.addClass(NS.dnd.listMarker, 'list-marker');

            NS.dnd.cardMarker = document.createElement('div');
            Dom.addClass(NS.dnd.cardMarker, 'card-marker');

            listBody = ECN('list-body', 'div', list_id);
            alert(listBody);
            target = YAHOO.util.DDTarget(listBody);
        },
        initConstraints: function (drag) {
            //Get Region wrapper
            var region = Dom.getRegion('viewport-wrapper');
            //Clear old constraints
            drag.clearConstraints();

            //Get the element we are working on
            var el = drag.getEl();

            //Get the xy position of it
            var xy = Dom.getXY(el);

            //Get the height
            var height = parseInt(Dom.getStyle(el, 'height'), 10);

            //Set top to y minus top
            var top = xy[1] - region.top;

            //Set bottom to bottom minus y minus height
            var bottom = region.bottom - xy[1] - height - 20;

            //Set the constraints based on the above calculations
            drag.setYConstraint(top, bottom);

            //resetConstraints must be called if you manually
            //reposition a dd element.
            drag.resetConstraints();
        },
        /**
         * Initialize DnD List
         */
        initList: function (list_id) {
            var drag = new ScrollProxy(list_id, 'list', {
                dragElId: 'dnd-frame',
                scrollParent: 'lists'
            });
            var handle = ECN('list-header', 'div', list_id).pop();
            drag.setHandleElId(Dom.getAttribute(handle, 'id'));

            drag.b4StartDrag = function (x, y) {
                this.showFrame(x, y);
                if (YAHOO.kansha.app.isDesktop()) {
                    this.clearConstraints();
                    this.setYConstraint(0, 0);
                } else {
                    this.clearConstraints();
                    this.setXConstraint(0, 0);
                }
                this.resetConstraints();
                YAHOO.kansha.app.hideOverlay();
            };

            drag.startDrag = function (x, y) {
                var src = this.getEl(),
                    dragEl = this.getDragEl(),
                    region = Dom.getRegion(src);
                Dom.batch(Selector.query('.list-header .list-actions', src), function (elem) {
                    YAHOO.kansha.app.show(elem, false);
                });
                if (YAHOO.kansha.app.isDesktop()) {
                    Dom.setAttribute(dragEl, 'class', 'list list-proxy');<commit_msg>Removed vertical constraint on list drag. Closes #184.<commit_after>//--
// Copyright (c) 2012, Net-ng.
// All rights reserved.
//
// This software is licensed under the BSD License, as described in
// the file LICENSE.txt, which you should have received as part of
// this distribution.
//--

(function () {
    'use strict';
    var Y = YAHOO.util,
        Dom = Y.Dom,
        Event = Y.Event,
        ECN = Dom.getElementsByClassName,
        NS = YAHOO.namespace('kansha'),
        DDM = YAHOO.util.DDM;

    /**
     * Helper log function
     */
    var log = function (args) {
        var s = '', i;
        for (i in args) {
            s = s + args[i] + ' ';
        }
        console.log(s);
    };
    /**
     * A DnD proxy that scrolls his container
     * Sources:
     *  - http://new.davglass.com/files/yui/dd15/
     *  - yui dragdrop.js source
     */
    var ScrollProxy = function (id, sGroup, config) {
        ScrollProxy.superclass.constructor.apply(this, arguments);
        // Can drag using A elements
        this.invalidHandleTypes.A = false;
        // Disable drag for textarea and input elements
        this.invalidHandleTypes.TEXTAREA = 'TEXTAREA';
        this.invalidHandleTypes.INPUT = 'INPUT';
        // Element used for scrolling
        this.scrollParent = Dom.get(config.scrollParent);
        // Attributes used to determine the drag orientation
        this.lastX = 0;
        this.goingRight = false;
        this.lastY = 0;
        this.goingDown = false;
        this.scrollInt = null;
    };
    YAHOO.extend(ScrollProxy, YAHOO.util.DDProxy, {
        /**
         * Auto-scroll the lists div if the dragged object has been moved
         * beyond the visible viewport boundary.
         * @method autoScroll
         * @param {int} x the drag element's x position
         * @param {int} y the drag element's y position
         * @param {int} h the height of the drag element
         * @param {int} w the width of the drag element
         */
        autoScroll: function (x, y, h, w) {

            // How many pixels to scroll per autoscroll op.  This helps to
            // reduce clunky scrolling. IE is more sensitive about this ...
            // it needs this value to be higher.
            var scrAmt = (document.all) ? 80 : 30;
            // How close to the edge the cursor must be before we scroll
            var thresh = 50;

            // Horizontal scrolling is done on the scrollParent element
            // (not the window)
            // Right marker coordinates
            var rightMarker = Dom.getRegion(this.scrollParent).right - thresh;
            // Left marker coordinates
            var leftMarker = Dom.getRegion(this.scrollParent).left + thresh;
            // Current scroll left
            var sl = this.scrollParent.scrollLeft;

            // Scroll left
            YAHOO.log('autoScroll: ' + sl + '/' + x + '/' + leftMarker);

            if (sl > 0 && x < leftMarker) {
                this.scrollParent.scrollLeft = sl - scrAmt;
            }
            // Scroll right
            if (x + w > rightMarker) {
                this.scrollParent.scrollLeft = sl + scrAmt;
            }

            // Vertical scrolling
            // For mobile, scroll the client window
            if (YAHOO.kansha.app.isMobile()) {
                // Current scroll top
                var st = this.DDM.getScrollTop();
                // Top marker coordinates
                var topMarker = st + thresh;
                // Bottom marker coordinates
                var bottomMarker = st + this.DDM.getClientHeight() - thresh;

                // Scroll top
                if (st > 0 && y < topMarker) {
                    window.scrollTo(this.scrollParent.scrollLeft, st - scrAmt);
                }
                // Scroll bottom
                if (y + h > bottomMarker) {
                    window.scrollTo(this.scrollParent.scrollLeft, st + scrAmt);
                }
            }
            DDM.refreshCache();
        },
        /**
         * Update drag orientation
         */
        onDrag: function (e) {
            var c = Event.getXY(e);
            this.goingRight = (c[0] >= this.lastX);
            this.goingDown = (c[1] >= this.lastY);
            this.lastX = c[0];
            this.lastY = c[1];
        }
    });

    NS.dnd = {
        listMarker: undefined,
        cardMarker: undefined,
        init: function () {
            var target = new YAHOO.util.DDTarget(Dom.get('list-target'), 'list'),
                listBody;
            NS.dnd.listMarker = document.createElement('div');
            Dom.addClass(NS.dnd.listMarker, 'list-marker');

            NS.dnd.cardMarker = document.createElement('div');
            Dom.addClass(NS.dnd.cardMarker, 'card-marker');

            listBody = ECN('list-body', 'div', list_id);
            alert(listBody);
            target = YAHOO.util.DDTarget(listBody);
        },
        initConstraints: function (drag) {
            //Get Region wrapper
            var region = Dom.getRegion('viewport-wrapper');
            //Clear old constraints
            drag.clearConstraints();

            //Get the element we are working on
            var el = drag.getEl();

            //Get the xy position of it
            var xy = Dom.getXY(el);

            //Get the height
            var height = parseInt(Dom.getStyle(el, 'height'), 10);

            //Set top to y minus top
            var top = xy[1] - region.top;

            //Set bottom to bottom minus y minus height
            var bottom = region.bottom - xy[1] - height - 20;

            //Set the constraints based on the above calculations
            drag.setYConstraint(top, bottom);

            //resetConstraints must be called if you manually
            //reposition a dd element.
            drag.resetConstraints();
        },
        /**
         * Initialize DnD List
         */
        initList: function (list_id) {
            var drag = new ScrollProxy(list_id, 'list', {
                dragElId: 'dnd-frame',
                scrollParent: 'lists'
            });
            var handle = ECN('list-header', 'div', list_id).pop();
            drag.setHandleElId(Dom.getAttribute(handle, 'id'));

            drag.b4StartDrag = function (x, y) {
                this.showFrame(x, y);
                if (YAHOO.kansha.app.isDesktop()) {
                    this.clearConstraints();
                    // this.setYConstraint(0, 0);
                } else {
                    this.clearConstraints();
                    this.setXConstraint(0, 0);
                }
                this.resetConstraints();
                YAHOO.kansha.app.hideOverlay();
            };

            drag.startDrag = function (x, y) {
                var src = this.getEl(),
                    dragEl = this.getDragEl(),
                    region = Dom.getRegion(src);
                Dom.batch(Selector.query('.list-header .list-actions', src), function (elem) {
                    YAHOO.kansha.app.show(elem, false);
                });
                if (YAHOO.kansha.app.isDesktop()) {
                    Dom.setAttribute(dragEl, 'class', 'list list-proxy');
{'fraction_non_alphanumeric': 0.11031358885017421, 'fraction_numerical': 0.004529616724738676, 'mean_word_length': 1.4552609067579128, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '6565156', 'n_tokens_mistral': 4041, 'n_tokens_neox': 3818, 'n_words': 1076}