<commit_before>
window.canvas_crop = null;
function initializeProductSearchForm() {
    /* attach a submit handler to the form */
    $("#product_search_form").submit(function (event) {
        /* stop form from submitting normally */
        event.preventDefault();

        $('#products-preloader').show();
        $('#select-products-box').html('');
        /* get some values from elements on the page: */
        var $form = $(this),
            term = $form.find('input[name="product_keywords"]').val(),
            supplier_id = $form.find('select[name="supplier_id"]').val(),
            department_taxon = $form.find('select[name="department_taxon"]').val(),
            url = $form.attr('action');
        bid = $('#canvas').data('boardId');

        //alert(taxon);
        /* Send the data using post */
        var posting = $.post(url, { keywords: term, department_taxon_id: department_taxon, supplier_id: supplier_id, per_page: 50, board_id: bid });

        /* Put the results in a div */
        posting.done(function (data) {
            $('#products-preloader').hide();
            url = $('.solr-filter-products').data('search-url');
            keywords = $('#product_keywords').val();
            $.ajax({
                dataType: 'html',
                method: 'POST',
                url: url,
                data: {keywords: keywords},
                success: function (response) {
                    $('.solr-filter-products').html(response);
                }
            });


        });
    });
}

$(window).load(function(){
    $(".products_flexi_box").flexisel({
        autoPlay: true,
        autoPlaySpeed: 3000,
        pauseOnHover: true
    });
});

$(document).on({
    click: function(e){
        e.preventDefault();
        obj = canvas.getActiveObject();

        if(!isBlank(obj)) {
            $('#crop-modal').lightbox_me({
                centered: true,
                closeClick: true,
                closeEsc: false,
                onLoad: function () {
                    generateModalCrop(obj);
                },
                onClose: function () {

                }
            });
        }
    }
}, "#bp-crop");

$(document).on({
    click: function (e) {
        var obj, value;
        e.preventDefault();
        obj = canvas.getActiveObject();
        hash_id = obj.get('hash_id');
        canvas.remove(obj);
        value = $('.js-input-hash-product').val();
        if (value.length > 0) {
            hash = JSON.parse(value);
            delete hash[hash_id];
            $('.js-input-hash-product').val(JSON.stringify(hash));
        }
    }
}, '#js-remove-new-product-from-room');

$(document).on({
    click: function(e) {
        e.preventDefault();
        options = {};
        v = $crop_image.cropper('getCroppedCanvas');
        obj = canvas.getActiveObject();
        obj.set('width', v.width);
        obj.set('height', v.height);
        obj.set('save_url', v.toDataURL());
        obj.set('cropped', true);
        obj.setElement(v);
        canvas.renderAll();
        value = $('.js-input-hash-product').val();
        hash =  JSON.parse(value);
        ha_id = '';
        if (!isBlank(hash)) {
            if (obj.get('action') === 'create') {
                ha_id = obj.get('hash_id');
            } else {
                ha_id = obj.get('id');
            }
            hash[ha_id]["image"] = v.toDataURL();
            $('.js-input-hash-product').val(JSON.stringify(hash));
        }
        $('#crop-modal').trigger('close');
    }
}, '#btnCropRoom');

$(document).on({
    click: function(e) {
        var obj;
        e.preventDefault();
        obj = canvas.getActiveObject();
        if(!isBlank(obj)){
            renderMirror(obj);
            hash = generateHash(obj);
            $('.js-input-hash-product').val(JSON.stringify(hash));
        }
    }
}, "#bp-mirror");

$(document).on({
    click: function(e){
        e.preventDefault();
        selectedImage = canvas.getActiveObject();
        if(!isBlank(selectedImage)) {
            moveLayer(selectedImage, "top")
        }
    }
}, '#bp-move-front');

$(document).on({
    click: function(e){
        e.preventDefault();
        selectedImage = canvas.getActiveObject();
        if(!isBlank(selectedImage)) {
            moveLayer(selectedImage, "forward")
        }
    }
}, '#bp-move-forward');

$(document).on({
    click: function(e){
        e.preventDefault();
        selectedImage = canvas.getActiveObject();
        if(!isBlank(selectedImage)) {
            moveLayer(selectedImage, "bottom")
        }
    }
}, '#bp-move-back');

$(document).on({
    click: function(e){
        e.preventDefault();
        selectedImage = canvas.getActiveObject();
        if(!isBlank(selectedImage)) {
            moveLayer(selectedImage, "backward")
        }
    }
}, '#bp-move-backward');

$(document).on({
    click: function(e){
        e.preventDefault();
        canvas.getActiveObject();
        rotateObject(90);
    }
}, '#bp-rotate-left');

//function initCrop(){
//    dataImg = canvas.getActiveObject();
//    options = {
//        thumbBox: '.thumbBoxRoom',
//        spinner: '.spinnerRoom',
//        imgSrc: dataImg.toDataURL()
//    };
//    cropper = $('.imageBoxRoom').cropbox(options);
//    return [dataImg, cropper]
//}

function generateModalCrop(dataImg){
    $('.croppedRoom').html('');
    delete dataImg.filters[0];
    dataImg.set('scaleX', 1.1);
    dataImg.set('scaleY', 1.1);

//    dataImg.getElement().src = dataImg.save_url;
    $('.croppedRoom').append('<img src='+dataImg.toDataURL('image/jpeg')+'>');
    $crop_image = $('.croppedRoom img');
    var options = {
        aspectRatio: NaN,<commit_msg>-fixes<commit_after>
window.canvas_crop = null;
function initializeProductSearchForm() {
    /* attach a submit handler to the form */
    $("#product_search_form").submit(function (event) {
        /* stop form from submitting normally */
        event.preventDefault();

        $('#products-preloader').show();
        $('#select-products-box').html('');
        /* get some values from elements on the page: */
        var $form = $(this),
            term = $form.find('input[name="product_keywords"]').val(),
            supplier_id = $form.find('select[name="supplier_id"]').val(),
            department_taxon = $form.find('select[name="department_taxon"]').val(),
            url = $form.attr('action');
        bid = $('#canvas').data('boardId');

        //alert(taxon);
        /* Send the data using post */
        var posting = $.post(url, { keywords: term, department_taxon_id: department_taxon, supplier_id: supplier_id, per_page: 50, board_id: bid });

        /* Put the results in a div */
        posting.done(function (data) {
            $('#products-preloader').hide();
            url = $('.solr-filter-products').data('search-url');
            keywords = $('#product_keywords').val();
            $.ajax({
                dataType: 'html',
                method: 'POST',
                url: url,
                data: {keywords: keywords},
                success: function (response) {
                    $('.solr-filter-products').html(response);
                }
            });


        });
    });
}

$(window).load(function(){
    $(".products_flexi_box").flexisel({
        autoPlay: true,
        autoPlaySpeed: 3000,
        pauseOnHover: true
    });
});

$(document).on({
    click: function(e){
        e.preventDefault();
        obj = canvas.getActiveObject();

        if(!isBlank(obj)) {
            $('#crop-modal').lightbox_me({
                centered: true,
                closeClick: true,
                closeEsc: false,
                onLoad: function () {
                    generateModalCrop(obj);
                },
                onClose: function () {

                }
            });
        }
    }
}, "#bp-crop");

$(document).on({
    click: function (e) {
        var obj, value;
        e.preventDefault();
        obj = canvas.getActiveObject();
        hash_id = obj.get('hash_id');
        canvas.remove(obj);
        value = $('.js-input-hash-product').val();
        if (value.length > 0) {
            hash = JSON.parse(value);
            delete hash[hash_id];
            $('.js-input-hash-product').val(JSON.stringify(hash));
        }
    }
}, '#js-remove-new-product-from-room');

$(document).on({
    click: function(e) {
        e.preventDefault();
        options = {};
        v = $crop_image.cropper('getCroppedCanvas');
        obj = canvas.getActiveObject();
        obj.set('width', v.width);
        obj.set('height', v.height);
        obj.set('save_url', v.toDataURL());
        obj.set('cropped', true);
        obj.setElement(v);
        canvas.renderAll();
        value = $('.js-input-hash-product').val();
        hash =  JSON.parse(value);
        ha_id = '';
        if (!isBlank(hash)) {
            if (obj.get('action') === 'create') {
                ha_id = obj.get('hash_id');
            } else {
                ha_id = obj.get('id');
            }
            hash[ha_id]["image"] = v.toDataURL();
            $('.js-input-hash-product').val(JSON.stringify(hash));
        }
        $('#crop-modal').trigger('close');
    }
}, '#btnCropRoom');

$(document).on({
    click: function(e) {
        var obj;
        e.preventDefault();
        obj = canvas.getActiveObject();
        if(!isBlank(obj)){
            renderMirror(obj);
            hash = generateHash(obj);
            $('.js-input-hash-product').val(JSON.stringify(hash));
        }
    }
}, "#bp-mirror");

$(document).on({
    click: function(e){
        e.preventDefault();
        selectedImage = canvas.getActiveObject();
        if(!isBlank(selectedImage)) {
            moveLayer(selectedImage, "top")
        }
    }
}, '#bp-move-front');

$(document).on({
    click: function(e){
        e.preventDefault();
        selectedImage = canvas.getActiveObject();
        if(!isBlank(selectedImage)) {
            moveLayer(selectedImage, "forward")
        }
    }
}, '#bp-move-forward');

$(document).on({
    click: function(e){
        e.preventDefault();
        selectedImage = canvas.getActiveObject();
        if(!isBlank(selectedImage)) {
            moveLayer(selectedImage, "bottom")
        }
    }
}, '#bp-move-back');

$(document).on({
    click: function(e){
        e.preventDefault();
        selectedImage = canvas.getActiveObject();
        if(!isBlank(selectedImage)) {
            moveLayer(selectedImage, "backward")
        }
    }
}, '#bp-move-backward');

$(document).on({
    click: function(e){
        e.preventDefault();
        canvas.getActiveObject();
        rotateObject(90);
    }
}, '#bp-rotate-left');

//function initCrop(){
//    dataImg = canvas.getActiveObject();
//    options = {
//        thumbBox: '.thumbBoxRoom',
//        spinner: '.spinnerRoom',
//        imgSrc: dataImg.toDataURL()
//    };
//    cropper = $('.imageBoxRoom').cropbox(options);
//    return [dataImg, cropper]
//}

function generateModalCrop(dataImg){
    $('.croppedRoom').html('');
    delete dataImg.filters[0];
//    dataImg.set('scaleX', 1.1);
//    dataImg.set('scaleY', 1.1);

//    dataImg.getElement().src = dataImg.save_url;
    $('.croppedRoom').append('<img src='+dataImg.toDataURL('image/jpeg')+'>');
    $crop_image = $('.croppedRoom img');
    var options = {
        aspectRatio: NaN,
{'fraction_non_alphanumeric': 0.1793521200948117, 'fraction_numerical': 0.002458080941093846, 'mean_word_length': 1.9821989528795811, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1372457', 'n_tokens_mistral': 3419, 'n_tokens_neox': 3359, 'n_words': 553}