/// class ProspectDirector.Web.UI.FeatureSets.EditorAssemblerBaseDOM

/**
@class EditorAssemblerBaseDOM
@namespace Web.UI.FeatureSets
@constructor
**/
ProspectDirector.Web.UI.FeatureSets.EditorAssemblerBaseDOM = Class.extend({

    //==============================
    // FIELDS
    //==============================

    _options: null,
    _containerNode: null,
    _groupNode: null,
    _node: null,

    //==============================
    // CONSTRUCTOR
    //==============================

    init: function (options) {
        this._options = options;
    },

    //==============================
    // PROPERTIES
    //==============================

    get_options: function () {
        return this._options;
    },

    get_id: function () {
        return this._options.id;
    },

    get_groupId: function () {
        return this._options.groupId;
    },

    get_containerNode: function () {
        this._ensureContainerNode();
        return this._containerNode;
    },

    get_groupNode: function () {
        this._ensureGroupNode();
        return this._groupNode;
    },

    get_node: function () {
        this._ensureNode();
        return this._node;
    },

    //==============================
    // PUBLIC METHODS
    //==============================

    resize: function () {
        //do nothing on purpose
    },

    render: function () {
        //do nothing on purpose
    },

    focus: function () {
        //do nothing on purpose
    },

    activate: function () {

    },

    showLoadingMessage: function (show) {

        var $messageNode = null,
            $assemblerNode = this.get_groupNode().find("DIV:eq(0)"),
            icon = ProspectDirector.RUNTIME.resolveUrl("~/application/icons/misc/ICON_CIRCLE_ANIMATED_36X36.GIF");

        this.get_containerNode().find("[data-role=EditorAssembler-Message]").remove();

        if (show) {
            $messageNode = $("<div data-role=\"EditorAssembler-Message\" class=\"-pd-editor-assembler-message\"></div>");
            $messageNode.append("<table style=\"display:none;\"><tr><td><img src=\"" + icon + "\">&nbsp;&nbsp;Loading...</td></tr></table></div>");
            $messageNode.insertBefore($assemblerNode)
        }

        setTimeout(function () {
            $assemblerNode.parent().find("[data-role=EditorAssembler-Message] > TABLE").show();
        }, 1000);

    },

    //==============================
    // PRIVATE METHODS
    //==============================

    _ensureContainerNode: function () {
        if (!this._containerNode) {
            this._containerNode = $("#" + this._options.containerID);
        }
    },

    _ensureGroupNode: function () {
        if (!this._groupNode) {
            this._groupNode = this.get_containerNode().find("DIV[data-id=" + this.get_groupId() + "]");
        }
    },

    _ensureNode: function () {
        if (!this._node) {
            this._node = this.get_groupNode().find("#" + this.get_id());
        }
    }

});