<commit_before>window.WebvfxEditor = Backbone.Model.extend({

    defaults: {
        width: 0,
        height: 0,
        scale: 1,
        stage: null,
        server: '',
        actionSafe: {
            width: 0,
            height: 0
        },
        titleSafe: {
            width: 0,
            height: 0
        },
        realTimeEdition: false,
        showSafeArea: false,
        videoPreview: false,
        liveCollection: null,
    },

    initialize: function() {
        args = arguments[0];

        this.set('width', args.width);
        this.set('height', args.height);
        this.set('scale', args.scale);

        this.set('stage', new Kinetic.Stage({
            container: 'container',
            width: this.getScaledWidth(),
            height: this.getScaledHeight(),
        }));
        this.get('stage').add(
            (('layer' in args) ? args.layer : new Kinetic.Layer())
        );

        var actionPercentage = 0.9;
        this.set('actionSafe', {
            width:  Math.round(args.width * args.scale * actionPercentage),
            height: Math.round(args.height * args.scale * actionPercentage),
        });

        var tilePercentage = 0.8;
        this.set('titleSafe', {
            width:  Math.round(args.width * args.scale * tilePercentage),
            height: Math.round(args.height * args.scale * tilePercentage),
        });

        this.set('server', args.server);
        this.set('realTimeEdition', args.realTimeEdition);
        this.set('showSafeArea', args.showSafeArea);
        this.set('videoPreview', args.videoPreview);
        this.set('liveCollection', new Sketch.LiveCollection());
    },

    getScaledWidth: function() {
        return (this.get('width') * this.get('scale'));
    },

    getScaledHeight: function() {
        return (this.get('height') * this.get('scale'));
    },

    getLayer: function() {
        return this.get('stage').children[0];
    },

    add: function(obj) {
        this.getLayer().add(obj);
    },

    draw: function() {
        this.getLayer().draw();
    },

});

window.WebvfxBase = Backbone.Model.extend({

    defaults: {
        name: '',
        width: 0,
        height: 0,
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
    },

    initialize: function() {
        this.id = this.cid;
        this.zindex = (arguments[0].zindex >= 0) ? arguments[0].zindex : -1;
        this.locked = false;
        this.created = false;
    },

    createEvents: function() {
        var self = this;

        this.kObj.on('mouseover', function() {
            document.body.style.cursor = 'pointer';
        });

        this.kObj.on('dragmove', function() {
            self.updatePosition();
            self.showInfo();
        });

        this.kObj.on('dragend', function() {
            if (self.created && webvfxEditor.get('realTimeEdition')) {
                webvfxEditor.objects.sendAll();
            }
        });

        this.kObj.on('mouseout', function() {
            document.body.style.cursor = 'default';
            $('#info').html('');
        });

        this.kObj.on('mousedown', function() {
            $('.webvfx-obj-properties').hide();
            $('#webvfx-obj-properties-' + self.id).show();
        });
    },

    draw: function() {
        webvfxEditor.draw();
        if (webvfxEditor.get('realTimeEdition')) {
            webvfxEditor.objects.sendAll();
        }
    },

    showInfo: function() {
        var info = this.getInfo();
        for (key in info) {
            $('#' + key + '-' + this.id).val(info[key]);
        }
    },

    isImage: function() {
        return this.getType() == 'image';
    },

    isBox: function() {<commit_msg>Avoid sending all objects every time one change<commit_after>window.WebvfxEditor = Backbone.Model.extend({

    defaults: {
        width: 0,
        height: 0,
        scale: 1,
        stage: null,
        server: '',
        actionSafe: {
            width: 0,
            height: 0
        },
        titleSafe: {
            width: 0,
            height: 0
        },
        realTimeEdition: false,
        showSafeArea: false,
        videoPreview: false,
        liveCollection: null,
    },

    initialize: function() {
        args = arguments[0];

        this.set('width', args.width);
        this.set('height', args.height);
        this.set('scale', args.scale);

        this.set('stage', new Kinetic.Stage({
            container: 'container',
            width: this.getScaledWidth(),
            height: this.getScaledHeight(),
        }));
        this.get('stage').add(
            (('layer' in args) ? args.layer : new Kinetic.Layer())
        );

        var actionPercentage = 0.9;
        this.set('actionSafe', {
            width:  Math.round(args.width * args.scale * actionPercentage),
            height: Math.round(args.height * args.scale * actionPercentage),
        });

        var tilePercentage = 0.8;
        this.set('titleSafe', {
            width:  Math.round(args.width * args.scale * tilePercentage),
            height: Math.round(args.height * args.scale * tilePercentage),
        });

        this.set('server', args.server);
        this.set('realTimeEdition', args.realTimeEdition);
        this.set('showSafeArea', args.showSafeArea);
        this.set('videoPreview', args.videoPreview);
        this.set('liveCollection', new Sketch.LiveCollection());
    },

    getScaledWidth: function() {
        return (this.get('width') * this.get('scale'));
    },

    getScaledHeight: function() {
        return (this.get('height') * this.get('scale'));
    },

    getLayer: function() {
        return this.get('stage').children[0];
    },

    add: function(obj) {
        this.getLayer().add(obj);
    },

    draw: function() {
        this.getLayer().draw();
    },

});

window.WebvfxBase = Backbone.Model.extend({

    defaults: {
        name: '',
        width: 0,
        height: 0,
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
    },

    initialize: function() {
        this.id = this.cid;
        this.zindex = (arguments[0].zindex >= 0) ? arguments[0].zindex : -1;
        this.locked = false;
        this.created = false;
    },

    createEvents: function() {
        var self = this;

        this.kObj.on('mouseover', function() {
            document.body.style.cursor = 'pointer';
        });

        this.kObj.on('dragmove', function() {
            self.updatePosition();
            self.showInfo();
        });

        this.kObj.on('dragend', function() {
            if (self.created && webvfxEditor.get('realTimeEdition')) {
                self.send();
            }
        });

        this.kObj.on('mouseout', function() {
            document.body.style.cursor = 'default';
            $('#info').html('');
        });

        this.kObj.on('mousedown', function() {
            $('.webvfx-obj-properties').hide();
            $('#webvfx-obj-properties-' + self.id).show();
        });
    },

    draw: function() {
        webvfxEditor.draw();
        if (webvfxEditor.get('realTimeEdition')) {
            this.send();
        }
    },

    showInfo: function() {
        var info = this.getInfo();
        for (key in info) {
            $('#' + key + '-' + this.id).val(info[key]);
        }
    },

    isImage: function() {
        return this.getType() == 'image';
    },

    isBox: function() {
{'fraction_non_alphanumeric': 0.1596661281637049, 'fraction_numerical': 0.006192784060312331, 'mean_word_length': 1.7555637982195846, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7082575', 'n_tokens_mistral': 2259, 'n_tokens_neox': 2180, 'n_words': 393}