<commit_before>Ext.namespace('Kwc.Abstract.Image');
Kwc.Abstract.Image.CropWindow = Ext.extend(Ext.Window, {
    cropData: null,
    imageUrl: '',
    resizable: false,
    title: trlKwf('Image Crop Utility'),
    width: 660,
    height: 510,
    modal: true,
    preserveRatio: false,

    initComponent: function() {
        this.fbar = {
            xtype: 'toolbar',
            items: [
                {
                    xtype: 'button',
                    text: trlKwf('Cancel'),
                    itemId: 'cancelButton'
                },
                {
                    xtype: 'button',
                    text: trlKwf('Save'),
                    itemId: 'saveButton'
                }
            ]
        };

        Kwc.Abstract.Image.CropWindow.superclass.initComponent.call(this);

        //TODO implement mask while loading
        var imgLoad = new Image();
        imgLoad.onerror = (function() {
            Ext.Msg.alert(trlKwf('Error'), trlKwf('Couldn\'t load image.'));
        });
        imgLoad.onload = (function(){
            this.setSize(imgLoad.width+14, imgLoad.height + 69);
            var cropWidth, cropHeight, cropX = 0, cropY = 0;
            if (this.cropData) {
                cropX = this.cropData.x;
                cropY = this.cropData.y;
                cropWidth = this.cropData.width;
                cropHeight = this.cropData.height;
            } else {
                cropWidth = imgLoad.width;
                cropHeight = imgLoad.height;

                if (this.preserveRatio) {
                    if (cropHeight / this.outHeight > cropWidth / this.outWidth) {
                        // orientate on width
                        cropHeight = this.outHeight * cropWidth / this.outWidth;
                        cropY = (imgLoad.height - cropHeight)/2;
                    } else {
                        // orientate on height
                        cropWidth = this.outWidth * cropHeight / this.outHeight;
                        cropX = (imgLoad.width - cropWidth)/2;
                    }
                }
            }<commit_msg>Implement loading-mask<commit_after>Ext.namespace('Kwc.Abstract.Image');
Kwc.Abstract.Image.CropWindow = Ext.extend(Ext.Window, {
    cropData: null,
    imageUrl: '',
    resizable: false,
    title: trlKwf('Image Crop Utility'),
    width: 660,
    height: 510,
    modal: true,
    preserveRatio: false,

    initComponent: function() {
        this.fbar = {
            xtype: 'toolbar',
            items: [
                {
                    xtype: 'button',
                    text: trlKwf('Cancel'),
                    itemId: 'cancelButton'
                },
                {
                    xtype: 'button',
                    text: trlKwf('Save'),
                    itemId: 'saveButton'
                }
            ]
        };

        Kwc.Abstract.Image.CropWindow.superclass.initComponent.call(this);

        Ext.getBody().mask(trlKwf('Loading image'), 'x-mask-loading');
        var imgLoad = new Image();
        imgLoad.onerror = (function() {
            Ext.getBody().unmask();
            Ext.Msg.alert(trlKwf('Error'), trlKwf('Couldn\'t load image.'));
        });
        imgLoad.onload = (function(){
            Ext.getBody().unmask();
            this.setSize(imgLoad.width+14, imgLoad.height + 69);
            var cropWidth, cropHeight, cropX = 0, cropY = 0;
            if (this.cropData) {
                cropX = this.cropData.x;
                cropY = this.cropData.y;
                cropWidth = this.cropData.width;
                cropHeight = this.cropData.height;
            } else {
                cropWidth = imgLoad.width;
                cropHeight = imgLoad.height;

                if (this.preserveRatio) {
                    if (cropHeight / this.outHeight > cropWidth / this.outWidth) {
                        // orientate on width
                        cropHeight = this.outHeight * cropWidth / this.outWidth;
                        cropY = (imgLoad.height - cropHeight)/2;
                    } else {
                        // orientate on height
                        cropWidth = this.outWidth * cropHeight / this.outHeight;
                        cropX = (imgLoad.width - cropWidth)/2;
                    }
                }
            }
{'fraction_non_alphanumeric': 0.11113678373382625, 'fraction_numerical': 0.006469500924214418, 'mean_word_length': 1.2488311688311688, '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': '6792628', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1163, 'n_words': 219}