📄 messagebox.js
字号:
jspp.using("mocom.WAPmo.xWindow");
MessageBox = new function()
{
var core = this;
var $box = null;
var $icon = null;
var $aButton = null;
var $cButton = false;
var $accept = null;
var $cancel = null;
var $text = null;
var $import = null;
var $type = 0;
var w, h;
this.show = function(t, s, d)
{
w = (t == MSG_IMPORT ? 420 : 240);
h = 120;
$type = t;
$box = new xWindow("frmMessage" + jspp.index, "width=" + w + ",height=" + h + ",minButton=false,maxButton=false,clsButton=true", true);
$icon = document.createElement("IMG");
$icon.border = "0";
$icon.src = jspp.Home + "images/xw_msg" + t + ".gif";
$box.draw($icon, 10, 10);
$accept = document.createElement("INPUT");
$accept.type = "button";
$accept.value = "确定";
$accept.className = "btn";
$accept.style.width = "60px";
$accept.onclick = $box.cls.onclick;
$box.draw($accept, 10, 10);
$cancel = document.createElement("INPUT");
$cancel.type = "button";
$cancel.value = "取消";
$cancel.className = "btn";
$cancel.style.width = "60px";
$cancel.onclick = $box.cls.onclick;
$box.draw($cancel, 10, 10);
$text = document.createElement("SPAN");
$text.style.fontSize = "12px";
$text.style.fontFamily = "楷体";
$text.innerHTML = s;
$box.draw($text, 50, 20);
switch (t)
{
case MSG_HINT:
$box.setCaption(jspp.Caption + " 提示");
$aButton = true;
$cButton = false;
break;
case MSG_INFORMATION:
$box.setCaption(jspp.Caption + " 提示");
$aButton = true;
$cButton = false;
break;
case MSG_WARNING:
$box.setCaption(jspp.Caption + " 警告");
$aButton = true;
$cButton = false;
break;
case MSG_CONFIRM:
$box.setCaption(jspp.Caption + " 确认");
$aButton = true;
$cButton = true;
break;
case MSG_IMPORT:
$box.setCaption(jspp.Caption + " 输入");
$aButton = true;
$cButton = true;
$import = document.createElement("INPUT");
$import.type = "text";
if (d) $import.value = d;
$import.className = "txt";
$import.size = "50";
$import.onkeyup = function(ev)
{
var ee = window.event || ev;
if (ee.keyCode == 13)
{
$accept.onclick();
}
};
$box.draw($import, 50, 40);
break;
case MSG_WAITING:
$box.setCaption(jspp.Caption + " 等待");
$aButton = false;
$cButton = false;
break;
default:
$box.setCaption(jspp.Caption + " 提示");
$aButton = true;
$cButton = false;
break;
}
core.reset();
};
this.doAccept = function(func, cls)
{
$accept.onclick = function()
{
if (cls) $box.free();
func();
if (!cls) $box.free();
}
};
this.doCancel = function(func, cls)
{
$cancel.onclick = function()
{
if (cls) $box.free();
func();
if (!cls) $box.free();
}
};
this.returnValue = function()
{
if ($import)
return $import.value;
return null;
};
this.write = function(s)
{
$text.innerHTML += "<br/>" + s;
core.reset();
};
this.reset = function()
{
if ($text.offsetWidth > w - 70)
{
w = $text.offsetWidth + 70;
}
if ($type == MSG_IMPORT)
{
if ($text.offsetHeight > 14)
{
h = $text.offsetHeight + 24 + 20 + 56;
}
$import.style.top = $text.offsetHeight + 20;
}
else if ($type == MSG_WAITING)
{
if ($text.offsetHeight > 48)
{
h = $text.offsetHeight + 24 + 20 + 16;
}
}
else
{
if ($text.offsetHeight > 24)
{
h = $text.offsetHeight + 24 + 56;
}
}
$box.resizeTo(w, h);
if ($aButton && $cButton)
{
$accept.style.display = "";
$accept.style.left = (w - 140) / 2 + "px";
$accept.style.top = (h - 56) + "px";
$cancel.style.display = "";
$cancel.style.left = (w - 140) / 2 + 80 + "px";
$cancel.style.top = (h - 56) + "px";
}
else if ($aButton)
{
$accept.style.display = "";
$accept.style.left = (w - 60) / 2 + "px";
$accept.style.top = (h - 56) + "px";
$cancel.style.display = "none";
}
else
{
$accept.style.display = "none";
$cancel.style.display = "none";
}
$box.center();
};
this.setType = function(t)
{
$type = t;
$icon.src = jspp.Home + "images/xw_msg" + t + ".gif";
switch (t)
{
case MSG_HINT:
$box.setCaption(jspp.Caption + " 提示");
$aButton = true;
$cButton = false;
break;
case MSG_INFORMATION:
$box.setCaption(jspp.Caption + " 提示");
$aButton = true;
$cButton = false;
break;
case MSG_WARNING:
$box.setCaption(jspp.Caption + " 警告");
$aButton = true;
$cButton = false;
break;
case MSG_CONFIRM:
$box.setCaption(jspp.Caption + " 确认");
$aButton = true;
$cButton = true;
break;
case MSG_IMPORT:
$box.setCaption(jspp.Caption + " 输入");
$aButton = true;
$cButton = true;
$import = document.createElement("INPUT");
$import.type = "text";
if (d) $import.value = d;
$import.className = "txt";
$import.size = "50";
$box.draw($import, 50, 40);
break;
case MSG_WAITING:
$box.setCaption(jspp.Caption + " 等待");
$aButton = false;
$cButton = false;
break;
default:
$box.setCaption(jspp.Caption + " 提示");
$aButton = true;
$cButton = false;
break;
}
core.reset();
};
this.close = function()
{
$box.free();
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -