<commit_before>// Remember to invoke within jQuery(window).load(...)
// If you don't, Jcrop may not initialize properly
jQuery(window).load(function(){
    // The size of the initial selection (largest, centreted rectangle)
    var w = jQuery('#profile_photo_cropbox').width();
    var h = jQuery('#profile_photo_cropbox').height();
    var t = 0;
    var l = 0;
    var initial;
    if (h < w) {
        initial = h;
        l = (w - initial) / 2;
    } else {
        initial = w;
        t = (h - initial) / 2;
    }

    jQuery('#profile_photo_cropbox').Jcrop({
        onChange: showPreview,
        onSelect: showPreview,
        aspectRatio: 1,
        setSelect: [ l, t, initial, initial ]
    });

});

// Our simple event handler, called from onChange and onSelect
// event handlers, as per the Jcrop invocation above
function showPreview(coords)
{
    if (parseInt(coords.w) > 0)
    {
        var rx = 100 / coords.w;
        var ry = 100 / coords.h;

        jQuery('#profile_photo_preview').css({
            width: Math.round(rx * jQuery('#profile_photo_cropbox').width()) + 'px',
            height: Math.round(ry * jQuery('#profile_photo_cropbox').height()) + 'px',
            marginLeft: '-' + Math.round(rx * coords.x) + 'px',
            marginTop: '-' + Math.round(ry * coords.y) + 'px'
        });

        $('#x').val(coords.x);
        $('#y').val(coords.y);
        $('#w').val(coords.w);
        $('#h').val(coords.h);
    }
}
<commit_msg>Update JCrop js for latest jquery.<commit_after>(function($) {

    $(function(){

        // The size of the initial selection (largest, centreted rectangle)
        var w = jQuery('#profile_photo_cropbox').width();
        var h = jQuery('#profile_photo_cropbox').height();
        var t = 0;
        var l = 0;
        var initial;
        if (h < w) {
            initial = h;
            l = (w - initial) / 2;
        } else {
            initial = w;
            t = (h - initial) / 2;
        }

        var jcrop_api;
        var bounds, boundx, boundy;

        $('#profile_photo_cropbox').Jcrop({
            onChange: showPreview,
            onSelect: showPreview,
            aspectRatio: 1
        },function(){
            jcrop_api = this;
            bounds = jcrop_api.getBounds();
            boundx = bounds[0];
            boundy = bounds[1];
        });

        jcrop_api.setSelect([ l, t, initial, initial ]);

        function showPreview(coords)
        {
            if (parseInt(coords.w) > 0)
            {
                var rx = 100 / coords.w;
                var ry = 100 / coords.h;

                $('#profile_photo_preview').css({
                    width: Math.round(rx * boundx) + 'px',
                    height: Math.round(ry * boundy) + 'px',
                    marginLeft: '-' + Math.round(rx * coords.x) + 'px',
                    marginTop: '-' + Math.round(ry * coords.y) + 'px'
                });

                $('#x').val(coords.x);
                $('#y').val(coords.y);
                $('#w').val(coords.w);
                $('#h').val(coords.h);
            }
        };

    });

}(jQuery));

{'fraction_non_alphanumeric': 0.15764178148029478, 'fraction_numerical': 0.008330663248958666, 'mean_word_length': 1.6547619047619047, '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': '7306011', 'n_tokens_mistral': 1006, 'n_tokens_neox': 966, 'n_words': 225}