<commit_before>(function(window, document, $) {

    'use strict';

    var defaults = {
        animateTime: 100,
        minViewWidth: 150,
        toggleWidth: 1/3,
        maxWidthProp: 2/3
    };

    var CommentPane = CommentPane || function(selector, options) {

        var $pane = $(selector);
        var $handle = $pane.find('.cp-handle');
        var $sidebar = $pane.find('.cp-sidebar');
        var $bar = $pane.find('.cp-bar');
        var $toggleElm = $.merge($pane, $sidebar);

        options = $.extend({}, defaults, options);
        if (options.maxWidthProp < options.toggleWidth) {
            throw(
                'Option `toggleWidth` must be greater than or equal to ' +
                'option `maxWidthProp`.'
            );
        }

        var makeAllElementsUnselectable = function(){
            $(document).children().each(function (index, elm) {
                $(elm).addClass('unselectable');
            });
        };

        var makeAllElementsSelectable = function(){
            $(document).children().each(function (index, elm) {
                $(elm).removeClass('unselectable');
            });
        };

        var maxWidth = function(targetWidth) {
            var bodyWidth = $(document.body).width();
            return Math.min(targetWidth, bodyWidth * options.maxWidthProp);
        };

        var toggle = function() {
            var width;
            if ($pane.width()) {
                width = 0;
            } else {
                var bodyWidth = $(document.body).width();
                width = options.toggleWidth * bodyWidth;
            }
            $toggleElm.animate(
                {width: width},
                options.animateTime
            );
        };

        var init = function(){

            $bar.on('mousedown', function() {
                makeAllElementsUnselectable();
                $(document).on('mousemove', function(event) {
                    var bodyWidth = $(document.body).width();
                    var dragWidth = document.body.clientWidth - event.pageX;
                    var width = maxWidth(dragWidth) + 'px';
                    $pane.css('width', width);
                    $('.cp-sidebar').css('width', width);
                });
                $(document).on('mouseup', function(){
                    $(document).off('mousemove');
                    $(document).off('mouseup');
                    makeAllElementsSelectable();
                    if ($pane.width() < options.minViewWidth) {
                        $pane.animate(
                            {width: '0'}, options.animateTime
                        );
                    }
                })
            });

            $(window).on('resize', function() {
                var bodyWidth = $(document.body).width();

            });

            $handle.on('click', toggle);

        };
<commit_msg>prevent comment pane from getting too big on resize<commit_after>(function(window, document, $) {

    'use strict';

    var defaults = {
        animateTime: 100,
        minViewWidth: 150,
        toggleWidth: 1/3,
        maxWidthProp: 2/3
    };

    var CommentPane = CommentPane || function(selector, options) {

        var $pane = $(selector);
        var $handle = $pane.find('.cp-handle');
        var $sidebar = $pane.find('.cp-sidebar');
        var $bar = $pane.find('.cp-bar');
        var $toggleElm = $.merge($pane, $sidebar);

        options = $.extend({}, defaults, options);
        if (options.maxWidthProp < options.toggleWidth) {
            throw(
                'Option `toggleWidth` must be greater than or equal to ' +
                'option `maxWidthProp`.'
            );
        }

        var makeAllElementsUnselectable = function(){
            $(document).children().each(function (index, elm) {
                $(elm).addClass('unselectable');
            });
        };

        var makeAllElementsSelectable = function(){
            $(document).children().each(function (index, elm) {
                $(elm).removeClass('unselectable');
            });
        };

        var getMaxWidth = function() {
            return $(document.body).width() * options.maxWidthProp;
        };

        var toggle = function() {
            var width;
            if ($pane.width()) {
                width = 0;
            } else {
                var bodyWidth = $(document.body).width();
                width = options.toggleWidth * bodyWidth;
            }
            $toggleElm.animate(
                {width: width},
                options.animateTime
            );
        };

        var init = function(){

            // Bind drag & drop handlers
            $bar.on('mousedown', function() {
                makeAllElementsUnselectable();
                $(document).on('mousemove', function(event) {
                    var bodyWidth = $(document.body).width();
                    var dragWidth = document.body.clientWidth - event.pageX;
                    var width = Math.min(dragWidth, getMaxWidth()) + 'px';
                    $pane.css('width', width);
                    $('.cp-sidebar').css('width', width);
                });
                $(document).on('mouseup', function(){
                    $(document).off('mousemove');
                    $(document).off('mouseup');
                    makeAllElementsSelectable();
                    if ($pane.width() < options.minViewWidth) {
                        $pane.animate(
                            {width: '0'}, options.animateTime
                        );
                    }
                })
            });

            // Bind toggle handler
            $handle.on('click', toggle);

            // Prevent comment pane from getting too big on resize
            $(window).on('resize', function() {
                var maxWidth = getMaxWidth();
                if ($pane.width() > maxWidth) {
                    $toggleElm.width(maxWidth.toString() + 'px');
                }
            });

        };

{'fraction_non_alphanumeric': 0.13676348547717843, 'fraction_numerical': 0.003983402489626556, 'mean_word_length': 1.3761829652996846, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '3496662', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1462, 'n_words': 306}