/// class ProspectDirector.Web.UI.FeatureSets.Editors.TextAreaEditor
/// using ProspectDirector.Web.UI.FeatureSets.MicroEditorBase

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

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

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

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

    activate: function () {

        var that = this,
            definition = this.get_definition().get_data();

        this.get_element().prop("readonly", definition.readOnly);
        this.get_element().prop("disabled", definition.disabled);

        this.get_element().on("blur", $.proxy(function (e) {

            var value = $(e.target).val();

            if (that.validate(value)) {
                that.setPrimaryValue(value);
            }

        }, this));

    },

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

    render: function () {
        var value = this.getPrimaryValue();
        var height = this.get_definition().get_data()["height"];
        return "<textarea class='-pd-micro-editor-textarea' id='" + this.getId() + "' style='height:" + height + "px'>" + (value ? value : "") + "</textarea>";
    }

});