📄 base.js
字号:
oShadow.style.background = "#000000";
oShadow.style.display = "";
oIframe.style.display = "";
oShadow.style.opacity = "0.2";
oShadow.style.filter = "alpha(opacity=20)";
oShadow.style.top = (oDialog.offsetTop + 6)+"px";
oShadow.style.left = (oDialog.offsetLeft + 6)+"px";
oShadow.style.width = oDialog.offsetWidth;
oShadow.style.height = oDialog.offsetHeight;
oIframe.style.top = oDialog.offsetTop+"px";
oIframe.style.left = oDialog.offsetLeft+"px";
oIframe.style.width = oDialog.offsetWidth+"px";
oIframe.style.height = oDialog.offsetHeight+"px";
}
<!--展示-->
this.open = function(_sUrl, _sMode){
this.show();
if(!_sMode || _sMode == "no" || _sMode == "yes"){
$("dialogBody").innerHTML = "<iframe id=\"_openIframe\" style=\"margin:0px;padding:0px;width:100%;height:"+height+"px \" src='" + _sUrl + "' frameborder='0' scrolling='" + _sMode + "'></iframe>";
}
}
this.showWindow = function(_sUrl, _iWidth, _iHeight, _sMode, _sTitle){
var oWindow;
var sLeft = (screen.width) ? (screen.width - _iWidth)/2 : 0;
var iTop = -80 + (screen.height - _iHeight)/2;
iTop = iTop > 0 ? iTop : (screen.height - _iHeight)/2;
var sTop = (screen.height) ? iTop : 0;
if(window.showModalDialog && _sMode == "m"){
oWindow = window.showModalDialog(_sUrl,_sTitle,"dialogWidth:" + _iWidth + "px;dialogheight:" + _iHeight + "px");
} else {
oWindow = window.open(_sUrl, _sTitle, 'height=' + _iHeight + ', width=' + _iWidth + ', top=' + sTop + ', left=' + sLeft + ', toolbar=no, menubar=no, scrollbars=' + _sMode + ', resizable=no,location=no, status=no');
this.reset();
}
}
<!--增加按钮,更换按钮-->
this.event = function(_sMsg, _sOk, _sCancel, _sClose){
$('dialogFunc').innerHTML = sFunc;
$('dialogClose').innerHTML = sClose;
$('dialogBodyBox') == null ? $('dialogBody').innerHTML = sBody : function(){};
$('dialogMsg') ? $('dialogMsg').innerHTML = _sMsg : function(){};
_sOk && _sOk != "" ? this.button('dialogOk', _sOk)| $('dialogOk').focus() : $('dialogOk').style.display = 'none';
_sCancel && _sCancel != "" ? this.button('dialogCancel', _sCancel) : $('dialogCancel').style.display = 'none';
//_sOk ? this.button('dialogOk', _sOk) : _sOk == "" ? function(){} : $('dialogCancel').style.display = 'none';
//_sCancel ? this.button('dialogCancel', _sCancel) : _sCancel == "" ? function(){} : $('dialogCancel').style.display = 'none';
_sClose ? this.button('dialogBoxClose', _sClose) : function(){};
this.show();
this.middle('dialogBox');
}
this.set = function(_oAttr, _sVal){
var oShadow = $('dialogBoxShadow');
var oDialog = $('dialogBox');
var oHeight = $('dialogHeight');
var oIframe = $('dialogBoxIframe');
if(_sVal != ''){
switch(_oAttr){
case 'title':
$('dialogBoxTitle').innerHTML = _sVal;
title = _sVal;
break;
case 'width':
oDialog.style.width = _sVal+"px";
width = _sVal;
break;
case 'height':
oHeight.style.height = _sVal+"px";
height = _sVal;
break;
case 'src':
if(parseInt(_sVal) > 0){
$('dialogBoxFace') ? $('dialogBoxFace').src = path + _sVal + '.gif' : function(){};
}else{
$('dialogBoxFace') ? $('dialogBoxFace').src = _sVal : function(){};
}
src = _sVal;
break;
}
}
this.middle('dialogBox');
oShadow.style.top = (oDialog.offsetTop + 6)+"px";
oShadow.style.left = (oDialog.offsetLeft + 6)+"px";
oShadow.style.width = oDialog.offsetWidth+"px";
oShadow.style.height = oDialog.offsetHeight+"px";
oIframe.style.top = oDialog.offsetTop+"px";
oIframe.style.left = oDialog.offsetLeft+"px";
oIframe.style.width = oDialog.offsetWidth+"px";
oIframe.style.height = oDialog.offsetHeight+"px";
}
this.moveStart = function (e, _sId){
function fixE(e) {
if (typeof e == 'undefined') e = window.event;
if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
return e;
}
function getX(e){ return fixE(e).clientX; };
function getY(e){ return fixE(e).clientY; };
function drag(e){
v = document.getElementById(_sId);
var nX = getX(e);
var nY = getY(e);
var ll = v.rL + nX - v.oX;
var tt = v.rT + nY - v.oY;
v.style.left = ll + 'px';
v.style.top = tt + 'px';
$('dialogBoxShadow').style.left = ll + 6 +'px';
$('dialogBoxShadow').style.top = tt + 6 + 'px';
$('dialogBoxIframe').style.left = ll + 'px';
$('dialogBoxIframe').style.top = tt + 'px';
return false;
}
function end() {
document.onmousemove = null;
document.onmouseup = null;
}
v = $(_sId);
v.oX = getX(e);
v.oY = getY(e);
v.rL = parseInt(v.style.left ? v.style.left : 0);
v.rT = parseInt(v.style.top ? v.style.top : 0);
document.onmousemove = drag;
document.onmouseup = end;
return false;
}
/**
* 隐藏或显示模块,将某类型的元素设置为显示或隐藏
* @param _sType tagName
* @param _sDisplay showModel
*/
this.hideModule = function(_sType, _sDisplay){
var aIframe = parent.document.getElementsByTagName("iframe");aIframe=0;
var aType = document.getElementsByTagName(_sType);
var iChildObj, iChildLen;
for (var i = 0; i < aType.length; i++){
aType[i].style.display = _sDisplay;
}
for (var j = 0; j < aIframe.length; j++){
iChildObj = document.frames ? document.frames[j] : aIframe[j].contentWindow;
iChildLen = iChildObj.document.body.getElementsByTagName(_sType).length;
for (var k = 0; k < iChildLen; k++){
iChildObj.document.body.getElementsByTagName(_sType)[k].style.display = _sDisplay;
}
}
}
/**
* 将对象在其容器中居中显示,目前用于摆正按钮body的位置
* @param _sId 对象名称
*/
this.middle = function(_sId){
var obj = document.getElementById(_sId);
var sClientWidth = getWinSize().width;
var sClientHeight = parent ? getWinSize(parent).height - 50 : getWinSize().height ;
var sScrollTop ;//= parent ? parent.document.body.scrollTop : document.body.scrollTop;
if (document.documentElement && document.documentElement.scrollTop)
sScrollTop = document.documentElement.scrollTop;
else if (document.body) sScrollTop = document.body.scrollTop;
obj.style.display = "";
obj.style.position = "absolute";
obj.style.left = (sClientWidth - obj.offsetWidth)<0?0:(sClientWidth - obj.offsetWidth)/2 + 'px';
obj.style.top = (sClientHeight - obj.offsetHeight)<0?0:(sClientHeight - obj.offsetHeight)/2+sScrollTop + 'px';
}
}
/**
* 得到当前窗口的body的高度
* @return body的长度 一般用于计算scroll
*/
function getBodyHeight(){
if (document.documentElement && document.documentElement.scrollTop){
return document.documentElement.scrollTop;
}
else if (document.body) {
return document.body.scrollHeight;
}
}
/**
* 得到当前窗口的大小
* @param _target window 对象
*/
function getWinSize(_target) {
var windowWidth, windowHeight;
if(_target) target = _target.document;
else target = document;
if (self.innerHeight) { //all except Explorer IE支持
if(_target) target = _target.self;
else target = self;
windowWidth = target.innerWidth;
windowHeight = target.innerHeight;
} else if (target.documentElement && target.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = target.documentElement.clientWidth;
windowHeight = target.documentElement.clientHeight;
} else if (target.body) { // other Explorers
windowWidth = target.body.clientWidth;
windowHeight = target.body.clientHeight;
}
return {width:parseInt(windowWidth),height:parseInt(windowHeight)};
}
/**
* 得到当前窗口的body的size
* getBodySize()
*/
function getBodySize(_target) {
var windowWidth, windowHeight;
if(_target) target = _target.document;
else target = document;
if(browser.isIE){
windowWidth = target.body.clientWidth;
windowHeight =target.body.clientHeight;
}else if(browser.isNS){
windowWidth = target.documentElement.scrollWidth;
windowHeight = target.documentElement.scrollHeight;//.clientHeight;
}else{
windowWidth = target.body.clientWidth;
windowHeight = target.body.clientHeight;
}
return {width:parseInt(windowWidth),height:parseInt(windowHeight)};
}
/**
* 弹出窗口的入口程序-一般用于错误显示
* @param msg 将要在弹出窗口显示的消息
* @param click ok按钮的innerHTML
* @param icon 要显示图标的名称
* @param title 窗口上方标题的显示
*/
function _error_msg_show(msg, click, icon, title)
{
click = click ? click : ' ';
icon = icon ? icon : '';
title = title ? title : '系统提示信息';
switch (icon)
{
case 'forbid':
icon = 1;
break;
case 'succ':
icon = 2;
break;
case 'smile':
icon = 3;
break;
case 'forget':
icon = 4;
break;
case 'sorry':
icon = 5;
break;
case 'care':
icon = 6;
break;
case '':
icon = 3;
break;
}
dg=new dialog();
dg.init();
dg.set('src', icon);
dg.set('title', title);
msg = "<font color='#000'>"+msg+"</font>";//为提示信息统一加上默认的字体颜色(临时解决黑色模版下,提示信息显示不出来的问题)
dg.event(msg, click, '', click);
}
/**
* 弹出窗口的入口程序-一般用于错误信息
* @param msg 将要在弹出窗口显示的消息
* @param click ok按钮的innerHTML
* @param icon 按钮的名称
* @param top 离窗口上方的距离
* @param left 离窗口左方的距离
* @param width 宽度
* @param height 高度
*/
function _win_error_msg_show(msg, click, icon, top, left, width, height)
{
click = click ? click : ' ';
icon = icon ? icon : '';
title = '系统提示信息';
top = top ? top : 80;
switch (icon)
{
case 'forbid':
icon = 1;
break;
case 'succ':
icon = 2;
break;
case 'smile':
icon = 3;
break;
case 'forget':
icon = 4;
break;
case 'sorry':
icon = 5;
break;
case 'care':
icon = 6;
break;
case '':
icon = 5;
break;
}
dg=new dialog();
dg.init();
dg.set('src', icon);
dg.set('title', title);
if (width)
{
dg.set('width', width);
}
if (height)
{
dg.set('height', height);
}
if (left)
{
document.getElementById('dialogBox').style.left = left+"px";
document.getElementById('dialogBoxShadow').style.left = left+"px";
}
if (top)
{
document.getElementById('dialogBox').style.top = top+"px";
document.getElementById('dialogBoxShadow').style.top = top+"px";
}
dg.event(msg, click, '', click);
}
/**
* 弹出窗口的入口程序-一般用于确认
* @param msg 将要在弹出窗口显示的消息
* @param click_ok ok按钮的innerHTML
* @param clcik_no 取消按钮的innerHTML
* @param title 窗口上方标题的显示
*/
function _confirm_msg_show(msg, click_ok, click_no, title)
{
//_disabled_bg();
click_ok = click_ok ? click_ok : ' ';
click_no = click_no ? click_no : ' ';
title = title ? title : '系统提示信息';
dg=new dialog();
dg.init();
dg.set('src', 3); // smile
dg.set('title', title);
dg.event(msg, click_ok, click_no, click_no);
}
/**
* 弹出窗口的入口程序-一般用于确认
* @param msg 将要在弹出窗口显示的消息
* @param click_ok ok按钮的innerHTML
* @param clcik_no 取消按钮的innerHTML
* @param top 离窗口上方的距离
* @param left 离窗口左方的距离
* @param width 宽度
* @param height 高度
*/
function _win_confirm_msg_show(msg, click_ok, click_no, top, left, width, height)
{
click_ok = click_ok ? click_ok : ' ';
click_no = click_no ? click_no : ' ';
title = '系统提示信息';
top = top ? top : 80;
dg=new dialog();
dg.init();
dg.set('src', 3); // smile
dg.set('title', title);
if (width)
{
dg.set('width', width);
}
if (height)
{
dg.set('height', height);
}
dg.event(msg, click_ok, click_no, click_no);
if (left)
{
document.getElementById('dialogBox').style.left = left+"px";
document.getElementById('dialogBoxShadow').style.left = left+"px";
}
if (top)
{
document.getElementById('dialogBox').style.top = top+"px";
document.getElementById('dialogBoxShadow').style.top = top+"px";
}
}
var timer
var Opacity = 0
function hide() {
document.getElementById('pDiv').style.display = "block"
Opacity = 0
//changeHidden();
timer = window.setInterval("changeHidden()", 5);
}
function changeHidden()
{
/** if (Opacity == 50)
{
window.clearInterval(timer)
return
}
*/
//Opacity = 50;// ( Opacity + 50 ) > 50 ? 50 : Opacity + 3
// document.getElementById('pDiv').style.filt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -