﻿/// <summary>
/// FileName : InformationPanel.js
/// Author : 
/// Description : 自定义ASP.NET Ajax客户端组件，用于在异步信息处理过程中显示信息，如成功、失败、正在进行等
/// ClassName : NBBS.CustomControl.InformationPanel
/// Namespace : NBBS.CustomControl
/// Inheritee : Sys.UI.Control
/// </summary>

Type.registerNamespace('NBBS.CustomControl');

NBBS.CustomControl.InformationPanel = function(associatedElement) {
    NBBS.CustomControl.InformationPanel.initializeBase(this, [associatedElement]);
}

NBBS.CustomControl.InformationPanel.prototype = {
    /// <summary>
    /// 私有成员变量
    /// </summary>
    /// <param name="_errorMessage">处理失败后显示的信息</param>
    /// <param name="_okMessage">处理成功后显示的信息</param>
    /// <param name="_okMessage">显示等待信息时的图片</param>
    _errorMessage: null,
    _okMessage: null,
    _loadingIcon: null,
    
    /// <summary>
    /// 属性
    /// </summary>
    get_errorMessage: function() {
        return this._errorMessage;
    },

    set_errorMessage: function(value) {
        if (this._errorMessage !== value) {
            this._errorMessage = value;
            this.raisePropertyChanged('errorMessage');
        }
    },
    
    get_okMessage: function() {
        return this._okMessage;
    },

    set_okMessage: function(value) {
        if (this._okMessage !== value) {
            this._okMessage = value;
            this.raisePropertyChanged('okMessage');
        }
    },
    
    get_loadingIcon: function() {
        return this._loadingIcon;
    },

    set_loadingIcon: function(value) {
        if (this._loadingIcon !== value) {
            this._loadingIcon = value;
            this.raisePropertyChanged('loadingIcon');
        }
    },

    /// <summary>
    /// 构造函数
    /// </summary>
    initialize: function() {
        NBBS.CustomControl.InformationPanel.callBaseMethod(this, 'initialize');
    },

    /// <summary>
    /// 析构函数
    /// </summary>
    dispose: function() {
        NBBS.CustomControl.InformationPanel.callBaseMethod(this, 'dispose');
    },

    /// <summary>
    /// 显示“正在进行处理”的提示信息
    /// </summary>
    showProcess: function() {
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_process");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_error");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_ok");
    
        Sys.UI.DomElement.addCssClass(this.get_element(), "result_process");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "hide");
    
        this.get_element().innerHTML="<span><img src=\"" + this.get_loadingIcon() + "\" alt=\"\" /></span><span>正在处理，请稍候……</span>";
    },

    /// <summary>
    /// 显示执行失败信息
    /// </summary>
    showError: function() {
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_process");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_error");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_ok");
    
        Sys.UI.DomElement.addCssClass(this.get_element(), "result_error");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "hide");
        
        this.get_element().innerHTML=this.get_errorMessage();
    },
    
    /// <summary>
    /// 显示执行成功信息
    /// </summary>
    showOk: function() {
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_process");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_error");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "result_ok");
    
        Sys.UI.DomElement.addCssClass(this.get_element(), "result_ok");
        Sys.UI.DomElement.removeCssClass(this.get_element(), "hide");
        
        this.get_element().innerHTML=this.get_okMessage();
    },

    /// <summary>
    /// 隐藏面板
    /// </summary>
    hide: function() {
        Sys.UI.DomElement.addCssClass(this.get_element(), "hide");
    }
}

NBBS.CustomControl.InformationPanel.registerClass('NBBS.CustomControl.InformationPanel', Sys.UI.Control);

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();