小鬼之家

流浪,游走于文明与原始之间. 关注底层技术,实现美好生活。

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
    对话框是网页中常用的显示信息的工具,所以我自己实现了一个小的对话框。
dialog = {
    createDialog:
function(content, newId){
        mask();
        
var dialogBox = document.createElement('div');
        dialogBox.innerHTML 
= content;
        
if(!ctit.utility.isNull(newId)){
            dialogBox.id 
= newId;
        }
else{
            dialogBox.id 
= "__dialogBox__";
        }

        
var width = 300;
        
var height = 500;
        
var left = parseInt((ctit.utility.getViewWidth() - width)/2 + document.documentElement.scrollLeft);
        
var top = parseInt((document.documentElement.clientHeight - height)/2 + document.documentElement.scrollTop);
        Element.setStyle(dialogBox, 
{position:"absolute", zIndex:1010, left: left + "px", top: top + "px", width:parseInt(width) + "px", height: parseInt(height) + "px"});
        dialogBox.style.backgroundColor 
= "#fff";
        document.body.appendChild(dialogBox);
        dialog.keepON(dialogBox.id);
        
return dialogBox;
    }
,
    resetWidthHeight:
function(id, width, height){
        
var o = $(id);
        o.setStyle(
{width:parseInt(width)+"px", height:parseInt(height)+"px"});
    }
,
    fixedWH:
function(id){
        
var o = $(id);
        
var width = 333;
        
var height = 555;
        o.setStyle(
{width:parseInt(width)+"px", height:parseInt(height)+"px"});
    }
,
    keepON:
function(id){
        
var o = $(id);
        
var width = Element.getWidth(o);
        
var height = Element.getHeight(o);
        
var left = parseInt((ctit.utility.getViewWidth() - width)/2 + document.documentElement.scrollLeft);
        
var top = parseInt((document.documentElement.clientHeight - height)/2 + document.documentElement.scrollTop);
        o.setStyle(
{left:left+"px", top:top+"px"});
        clearTimeout(dialog.timing);
        dialog.timing 
= setTimeout("dialog.keepON('" + o.id + "');"300);
    }
,
    removeDialog:
function(id){
        
var o = $(id);
        clearTimeout(dialog.timing);
        document.body.removeChild(o);
        unMask();
    }

}
posted on 2007-09-22 20:52  黄尚  阅读(355)  评论(0编辑  收藏  举报