/// class ProspectDirector.Web.UI.FeatureSets.MacroEditorBaseDOM
/// using ProspectDirector.Web.UI.FeatureSets.EditorBase

/**
[NEEDS DOCUMENTATION]
@constructor
@class MacroEditorBaseDOM
@namespace Web.UI.FeatureSets
@extends Web.UI.FeatureSets.EditorBase
**/
ProspectDirector.Web.UI.FeatureSets.MacroEditorBaseDOM = ProspectDirector.Web.UI.FeatureSets.EditorBase.extend({

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

    get_element: function () {
        return $("#" + this.getId());
    },

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

    render: function () {
        return "<div id=\"" + this.getId() + "\" style=\"height:100px;\">&nbsp;</div>";
    },

    calculateDimensions: function (height, width) {

        var node = this.get_domNode(),
            paddingY = parseFloat(node.css("paddingTop")) + parseFloat(node.css("paddingBottom")),
            paddingX = parseFloat(node.css("paddingRight")) + parseFloat(node.css("paddingLeft"));

        return {
            height: height - paddingY,
            width: width - paddingX
        }
    },

    setValidationErrors: function (errors) {

        var that = this,
            featureType = this.get_definition().get_type(),
            errors = validationErrors.getByFeatureType(featureType);

        this.get_element().find("LABEL[for]").removeClass("-pd-macro-editor-val-error");

        this.get_element().find("LABEL[for]").each(function (index, element) {
            Tipped.remove(element);
        });

        errors.each(function (index, error) {

            var labelDomNode = that.get_element().find("LABEL[for=" + error.get_propertyName() + "]");

            labelDomNode.addClass("-pd-macro-editor-val-error");
            Tipped.create(labelDomNode, error.get_message(), { skin: "validation-error" });

        });

    }

});