/// class ProspectDirector.Web.UI.FeatureSets.ElementEditorDialog
/// using ProspectDirector.Web.UI.FeatureSets.TargetEditorDialog

ProspectDirector.Web.UI.FeatureSets.ElementEditorDialog =
    ProspectDirector.Web.UI.FeatureSets.TargetEditorDialog.extend({

        //================================
        // PROTECTED METHODS
        //================================

        _getArbiter: function () {

            var data = this.get_options().data

            return {
                "initialized": false,
                "arbiter": {
                    type: "ProspectDirector.Web.UI.Canvas.ElementArbiter",
                    targetType: data.targetType,
                    json: JSON.stringify(data.targetData),
                    attributes: data.attributes
                }
            };

        },

        _load: function () {

            var that = this;

            this._requestMonitorStart();

            PD.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: ProspectDirector.RUNTIME.resolveUrl("~/Target/EditWithValidation"),
                data: JSON.stringify(this._getArbiter()),
                success: $.proxy(this._loadSuccess, this),
                error: function (e) {

                    if (e.responseJSON.editor != null) {
                        that._loadSuccess(e.responseJSON.editor);
                        that._commitError(e);
                    }

                }
            });

        }

    });

//================================
// SHARED METHODS
//================================

ProspectDirector.Web.UI.FeatureSets.ElementEditorDialog.open = function (options) {
    return new ProspectDirector.Web.UI.FeatureSets.ElementEditorDialog(options);
};