<commit_before>Planting.prototype.toggle_start_button = function () {
    var that = this;
    return function () {
        if (that.pano.getVisible()) {
            that.startBtn.show();
        } else {
            that.startBtn.hide();
        }
    };
};

Planting.prototype.start_planting = function () {
    var that = this;
    return function () {
        that.overlay.show();
        that.toolbox.show();
        $('.layers-menu').show();
        that.startBtn.hide();
        that.pano.setOptions({
            panControl: false,
            zoomControl: false,
            addressControl: false,
            linksControl: false
        });
    };
};

Planting.prototype.plant_object = function () {
    var that = this;
    return function (e, ui) {
        for (var i = 0; i < that.toolboxobjects.length; i++) {
            if (ui.draggable.is(that.toolboxobjects[i].draggable)) {

                var containerOffset = that.container.offset();
                var objectOffset = that.toolboxobjects[i].draggable.offset();
                var top = objectOffset.top - containerOffset.top;
                var left = objectOffset.left - containerOffset.left;

                var img = $('<img />').attr('src', that.toolboxobjects[i].projections[0]);
                var uiTrash = $('<span class="icon-trash" />');
                var uiResize = $('<span class="icon-resize" />');
                var uiRotate = $('<span class="icon-loop" />');
                var uiRotateWrapper = $('<div class="wrapper-rotate" />')
                    .append('<span class="icon-menu-left" />')
                    .append('<span class="degrees">0&deg;</span>')
                    .append('<span class="icon-menu-right" />')
                    .append(uiRotate);
                var tools = $('<div class="plantingjs-plantedobject-tools" />')
                    .append(uiTrash)
                    .append(uiResize)
                    .append(uiRotateWrapper);

                var container = $('<div class="plantingjs-plantedobject-container">')
                    .offset({ top: ui.offset.top, left: ui.offset.left})
                    .draggable({ cancel: ".icon-loop, .icon-trash, .icon-resize"})
                    .append(img)
                    .append(tools);

                that.overlay.append(container);
                
                var layerItem = $('<div class="plantingjs-layer-item">' + i + '</div>');
                that.overlay.parent().find('.layers-menu').append(layerItem);
                            

                var plant = {
                    object: i,
                    projection: 0,
                    container: container,
                    tools: tools,
                    img: img
                };

                uiResize.on('mousedown', {plantedObject: plant}, that.resize_object);
                uiRotate.on('mousedown', {toolBoxObjects: that.toolboxobjects, plantedObject: plant}, that.rotate_object);
                uiTrash.on('click', {plantedObjectsArray: that.plantedobjects, plantedObject: plant}, that.remove_object);
                that.plantedobjects.push(plant);
                that.toolboxobjects[i].draggable.css({'top': '0px', 'left': '0px'});
            }
        }
    };
};

Planting.prototype.plant_objects_for_view = function () {
    var that = this;
    return function (data) {
        for (var i = 0; i < that.plantedobjects.length; i++) {
            that.plantedobjects[i].url = data.toolboxobjects[that.plantedobjects[i].object].projections[that.plantedobjects[i].projection];
            var img = $('<img />')
                .attr('src', that.plantedobjects[i].url);
            var containerOffset = that.container.offset();
            var div = $('<div class="plantingjs-plantedobject-container" />')
                .offset({<commit_msg>Dodanie mechanizmu do zarządzania warstwami<commit_after>Planting.prototype.toggle_start_button = function () {
    var that = this;
    return function () {
        if (that.pano.getVisible()) {
            that.startBtn.show();
        } else {
            that.startBtn.hide();
        }
    };
};

Planting.prototype.start_planting = function () {
    var that = this;
    return function () {
        that.overlay.show();
        that.toolbox.show();
        $('.layers-menu').show();
        that.startBtn.hide();
        that.pano.setOptions({
            panControl: false,
            zoomControl: false,
            addressControl: false,
            linksControl: false
        });
    };
};

Planting.prototype.plant_object = function () {
    var that = this;
    return function (e, ui) {
        for (var i = 0; i < that.toolboxobjects.length; i++) {
            if (ui.draggable.is(that.toolboxobjects[i].draggable)) {

                var containerOffset = that.container.offset();
                var objectOffset = that.toolboxobjects[i].draggable.offset();
                var top = objectOffset.top - containerOffset.top;
                var left = objectOffset.left - containerOffset.left;

                var img = $('<img />').attr('src', that.toolboxobjects[i].projections[0]);
                var uiTrash = $('<span class="icon-trash" />');
                var uiResize = $('<span class="icon-resize" />');
                var uiRotate = $('<span class="icon-loop" />');
                var uiRotateWrapper = $('<div class="wrapper-rotate" />')
                    .append('<span class="icon-menu-left" />')
                    .append('<span class="degrees">0&deg;</span>')
                    .append('<span class="icon-menu-right" />')
                    .append(uiRotate);
                var tools = $('<div class="plantingjs-plantedobject-tools" />')
                    .append(uiTrash)
                    .append(uiResize)
                    .append(uiRotateWrapper);

                var container = $('<div class="plantingjs-plantedobject-container">')
                    .offset({ top: ui.offset.top, left: ui.offset.left})
                    .draggable({ cancel: ".icon-loop, .icon-trash, .icon-resize"})
                    .append(img)
                    .append(tools);

                that.overlay.append(container);
                
                var layerItem = $('<div class="plantingjs-layer-item">' + i + '</div>');
                that.overlay.parent().find('.layers-menu').append(layerItem);
                            

                var plant = {
                    object: i,
                    projection: 0,
                    container: container,
                    tools: tools,
                    img: img
                };

                uiResize.on('mousedown', {plantedObject: plant}, that.resize_object);
                uiRotate.on('mousedown', {toolBoxObjects: that.toolboxobjects, plantedObject: plant}, that.rotate_object);
                uiTrash.on('click', {plantedObjectsArray: that.plantedobjects, plantedObject: plant}, that.remove_object);
                that.add_plant(plant);
                that.toolboxobjects[i].draggable.css({'top': '0px', 'left': '0px'});
            }
        }
    };
};

Planting.prototype.add_plant = function(plant) {
    this.plantedobjects.push(plant);
    this.update_plants_zIndex();
};

Planting.prototype.update_plants_zIndex = function() {
    if (!this.plantedobjects.length) {
        return;
    }

    this.plantedobjects.forEach(function(plant, index) {
        plant.container.css({ zIndex: index });
    });
};

Planting.prototype.change_plant_index = function (at, to) {
    while (at < 0) {
        at += this.plantedobjects.length;
    }
    while (to < 0) {
        to += this.plantedobjects.length;
    }
    if (to >= this.plantedobjects.length) {
        var k = to - this.plantedobjects.length;
        while ((k--) + 1) {
            this.plantedobjects.push(undefined);
        }
    }
    this.plantedobjects.splice(to, 0, this.plantedobjects.splice(at, 1)[0]);

    this.update_plants_zIndex();
};

Planting.prototype.plant_objects_for_view = function () {
    var that = this;
    return function (data) {
        for (var i = 0; i < that.plantedobjects.length; i++) {
            that.plantedobjects[i].url = data.toolboxobjects[that.plantedobjects[i].object].projections[that.plantedobjects[i].projection];
            var img = $('<img />')
                .attr('src', that.plantedobjects[i].url);
            var containerOffset = that.container.offset();
            var div = $('<div class="plantingjs-plantedobject-container" />')
                .offset({
{'fraction_non_alphanumeric': 0.14519523030161327, 'fraction_numerical': 0.002338087444470423, 'mean_word_length': 1.7830188679245282, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 34, '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': '2475351', 'n_tokens_mistral': 2467, 'n_tokens_neox': 2352, 'n_words': 419}