/// class ProspectDirector.Modules.ExplorerModel.Forms.FeatureHtmlTemplate
/// using ProspectDirector.Types.Core.Feature

/**
@class FeatureHtmlTemplate
@namespace ProspectDirector.Modules.ExplorerModel.Forms
**/
ProspectDirector.Modules.ExplorerModel.Forms.FeatureHtmlTemplate = ProspectDirector.Types.Core.Feature.extend({

    //---------------------------
    //--- CONSTRUCTOR
    //---------------------------

    init: function (options) {
        this._super(options);
        this.get_buttonExternal().on("click", $.proxy(this.buttonExternal_onClick, this));
    },

    //---------------------------
    //--- PROPERTIES
    //---------------------------

    get_buttonExternal: function () {
        return this.get_container().find("INPUT[type=button][data-role=template-selector]");
    },

    get_fileId: function () {
        return this.get_container().find("[data-role=file-id]");
    },

    get_fileName: function () {
        return this.get_container().find("[data-role=file-name]");
    },

    //---------------------------
    //--- EVENT HANDLERS
    //---------------------------

    buttonExternal_onClick: function (e) {

        var that = this;

        PD.Manage.Modules.Resources.ResourceSelectionDialog.open({
            extensions: [".html", ".htm"],
            selectMode: {
                type: "files",
                multiple: false
            },
            callbacks: {
                ok: function (sender, e) {
                    var file = _.first(e.files)
                    that.get_fileId().val(file.id);
                    that.get_fileName().val(file.name);
                }
            }
        });

    }

});