﻿/// <summary>
/// FileName : MaskWindow.js
/// Author : 
/// Description : 自定义ASP.NET Ajax客户端组件，用于显示由DIV模拟的模态窗体
/// ClassName : NBBS.CustomControl.MaskWindow
/// Namespace : NBBS.CustomControl
/// Inheritee : Sys.UI.Control
/// </summary>

Type.registerNamespace('NBBS.CustomControl');

NBBS.CustomControl.MaskWindow = function(associatedElement) {
    NBBS.CustomControl.MaskWindow.initializeBase(this, [associatedElement]);
}

NBBS.CustomControl.MaskWindow.prototype = {
    /// <summary>
    /// 私有成员变量
    /// </summary>
    /// <param name="_windowElement">在模态下，显示信息的窗体DIV</param>
    _windowElement: null,
    _windowWidth: null,
    _windowHeight: null,
    
    /// <summary>
    /// 属性
    /// </summary>
    get_windowElement: function() {
        return this._windowElement;
    },

    set_windowElement: function(value) {
        if (this._windowElement !== value) {
            this._windowElement = value;
            this.raisePropertyChanged('windowElement');
        }
    },
    
    get_windowWidth: function() {
        return this._windowWidth;
    },

    set_windowWidth: function(value) {
        if (this._windowWidth !== value) {
            this._windowWidth = value;
            this.raisePropertyChanged('windowWidth');
        }
    },
    
    get_windowHeight: function() {
        return this._windowHeight;
    },

    set_windowHeight: function(value) {
        if (this._windowHeight !== value) {
            this._windowHeight = value;
            this.raisePropertyChanged('windowHeight');
        }
    },
    
    /// <summary>
    /// 构造函数
    /// </summary>
    initialize: function() {
        NBBS.CustomControl.MaskWindow.callBaseMethod(this, 'initialize');
        
        var bhOpacityMask=new Sys.Preview.UI.Effects.OpacityBehavior(this.get_element());
        bhOpacityMask.set_value(0.5);
        bhOpacityMask.initialize();
    },

    /// <summary>
    /// 析构函数
    /// </summary>
    dispose: function() {
        NBBS.CustomControl.MaskWindow.callBaseMethod(this, 'dispose');
    },
    
    /// <summary>
    /// 打开模态窗体及信息
    /// </summary>
    show: function() {
        var bhOpacityWindow=new Sys.Preview.UI.Effects.OpacityBehavior(this.get_windowElement());
        bhOpacityWindow.set_value(0.8);
        bhOpacityWindow.initialize();
        
        this.get_element().style.width = document.documentElement.scrollWidth + "px";
        this.get_element().style.height = document.documentElement.scrollHeight + "px";
        
        pLeft = (document.documentElement.clientWidth - this.get_windowWidth()) / 2;
        pLeft=Math.round(pLeft);
        pTop = (window.screen.availHeight - this.get_windowHeight() - 100) / 2 + document.documentElement.scrollTop;
        pTop=Math.round(pTop);
        
        Sys.UI.DomElement.setLocation(this.get_windowElement(), pLeft, pTop);
        
        Sys.UI.DomElement.removeCssClass(this.get_element(), "hide");
        Sys.UI.DomElement.removeCssClass(this.get_windowElement(), "hide");
    },
    
    /// <summary>
    /// 关闭模态窗体及信息
    /// </summary>
    hide: function () {
        Sys.UI.DomElement.addCssClass(this.get_windowElement(), "hide");
        Sys.UI.DomElement.addCssClass(this.get_element(), "hide");
    }
}

NBBS.CustomControl.MaskWindow.registerClass('NBBS.CustomControl.MaskWindow', Sys.UI.Control);

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();