var EditLocateIcon = function (parent) {
    this.Parent = parent;
    this.Dialog = $('#edit-locate-icon-dialog');
    this.LocateIcon = {};

    this.Setup = function () {
        $('#file').on('change', this.onFileChange.bind(this))
        $("#icon-sure-btn").on("click", this.OnSureButtonClick.bind(this));
        $("#icon-cancel-btn").on("click", this.HideDialog.bind(this));
        $("#icon-close").on("click", this.HideDialog.bind(this));
    };

    this.Show = function (data) {
        this.Dialog.show();
        this.LocateIcon = data;
        $("#path").textbox('setValue', data.Value);
    };

    this.onFileChange = function (event) {
        $("#path").textbox('setValue', event.target.files[0].name);
    };

    this.OnSureButtonClick = function () {
        this.LocateIcon.Value = $('#path').textbox('getValue');

        this.UpdateLocateIcon();
        this.Dialog.hide();
        this.Parent.DisabledEvent();
    };

    this.UpdateLocateIcon = function () {
        $.ajax({
            type: "POST",
            dataType: 'text',
            url: '/ConfigManagement/Update',
            data: this.LocateIcon,
            success: function () {
                this.Parent.ReLoadTableData();
            }.bind(this)
        });
    };

    this.HideDialog = function () {
        this.Dialog.hide();
    };
};