/**
 * Created by JetBrains PhpStorm.
 * User: kulitskyd
 * Date: 08.09.11
 * Time: 15:03
 * To change this template use File | Settings | File Templates.
 */

Arboreus.namespace('Arboreus.Components.Mask');

Arboreus.Components.Mask = function (options) { // must be container & maskContainer
    this.options = {};

    jQuery.extend(this.options, options);
    jQuery.extend(this, this.options);

    // inheritance from abstract component:
    jQuery.extend(this, new Arboreus.Components());

    this.container     = jQuery(this.container);
    this.maskContainer = jQuery(this.maskContainer);

    this.init();

    return false;
}


jQuery.extend(Arboreus.Components.Mask.prototype, {
    init: function() {
        var position = this.container.position();

        this.width = this.container.attr('offsetWidth');
        this.height = this.container.attr('offsetHeight');

        this.maskContainer.css('left', (position.left) + 'px');
        this.maskContainer.css('top', (position.top) + 'px');
    },

    show: function() {
        this.update();

        this.maskContainer.show();
        this.maskContainer.width(this.width);
        this.maskContainer.height(this.height);
    },

    hide: function() {
        this.maskContainer.hide();
    },

    update: function() {
        this.init();
    }
})
