﻿if (!Poseidon.Controls.Print.Module) {
    Poseidon.Controls.Print.Module = {};
}

Poseidon.Controls.Print.Module.DefaultMap = Ext.extend(GeoExt.MapPanel, {
    //style: 'margin: 0 auto; background-color: #ffffff; position: relative;',    

    stretch: this.stretch || true,

    moduleType: 'default_map',

    getAlignPosition: function () {
        return { x: this.align_x || this.x || 0, y: this.align_y || this.y || 0 };
    },

    setAlignPosition: function (x, y) {
        this.align_x = x;
        this.align_y = y;
    },

    getObject: function () {
        var data = {
            "width": this.width,
            "height": this.height,
            "y": this.x,
            "x": this.y,
            "module_id": this.module_id,
            "module_name": this.module_name,
            "stretch": this.stretch,
            "align": this.align,
            "align_x": this.align_x || this.x,
            "align_y": this.align_y || this.y,
            "z_index": this.x_index,
            "bbox": this.map.getExtent(), //.toArray(), //toBBOX(null, false),
            "layer_urls": []
        };
        for (var layerIndex = 0; layerIndex < this.map.layers.length; layerIndex++) {
            var layer = this.map.layers[layerIndex];
            // Extract WMS layers.
            if (layer.CLASS_NAME === 'OpenLayers.Layer.WMS') {
                data.layer_urls.push(this.map.layers[layerIndex].getURL(this.map.getExtent()));
            }
        }

        return data;
    },

    align: this.align || Poseidon.Controls.Print.AlignTypesEnum.TOP_LEFT,

    z_index: this.z_index || 200,

    getModuleType: function () {
        return this.moduleType;
    }
});

