You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/plugins/configs/ts/customAlert.ts

122 lines
3.9 KiB

8 years ago
/// <reference path="../../includes.ts"/>
module Configs{
export function customAlert(title, content, func, cancel, focus, icon){
/*
alert
title :
text :
func :
cancel:
focus :
icon :
*/
icon = "../../../new/images/msgbox_" + icon + ".png";
create_mask();
var temp = "<div class=\"custom-alert\" >"
+ "<div class=\"custom-alert-title\">" + title + "</div>"
+ "<table class=\"custom-alert-body\"><tr><td class=\"custom-alert-td\"><img src=\""
+ icon + "\" class=\"custom-alert-img\"></td>"
+ "<td ><div calss=\"custom-alert-content\">"
+ content + "</div></td></tr></table>"
+ "<div class=\"custom-alert-bottom\"><input type='button' "
+ " class=\"custom-alert-ok\" value='确认' id=\"msgconfirmb\" onclick=\"Configs.remove();"
+ func + ";\">";
if (null != cancel) {
temp += "&nbsp;&nbsp;&nbsp;<input type='button' class=\"custom-alert-cancel\" onClick='Configs.remove()'>";
}
temp += "</div></div>";
create_msgbox(400, 200, temp);
if (focus == 0 || focus == "0" || null == focus) {
document.getElementById("msgconfirmb").focus();
} else if (focus == 1 || focus == "1") {
document.getElementById("msgcancelb").focus();
}
}
function get_width() {
return (document.body.clientWidth + document.body.scrollLeft);
}
function get_height() {
return (document.body.clientHeight + document.body.scrollTop);
}
function get_left(w) {
var bw = document.body.clientWidth;
var bh = document.body.clientHeight;
w = parseFloat(w);
return (bw / 2 - w / 2 + document.body.scrollLeft);
}
function get_top(h) {
var bw = document.body.clientWidth;
var bh = document.body.clientHeight;
h = parseFloat(h);
return (bh / 2 - h / 2 + document.body.scrollTop);
}
export function create_mask() {
var mask = document.createElement("div");
mask.id = "mask";
mask.style.position = "absolute";
mask.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=4,opacity=25)";
mask.style.opacity = "0.4";
mask.style.background = "black";
mask.style.top = "0px";
mask.style.left = "0px";
mask.style.width = get_width() + "px";
mask.style.height = get_height() + "px";
mask.style.zIndex = "1000000000";
document.body.appendChild(mask);
}
function create_msgbox(w, h, t) {
var box = document.createElement("div");
box.id = "msgbox";
box.style.position = "absolute";
box.style.width = w + "px";
box.style.height = h + "px";
box.style.overflow = "visible";
box.innerHTML = t;
box.style.zIndex = "1000000001";
document.body.appendChild(box);
re_pos();
}
function re_mask() {
var mask = document.getElementById("mask");
if (null == mask) return;
mask.style.width = get_width() + "px";
mask.style.height = get_height() + "px";
}
function re_pos() {
var box = document.getElementById("msgbox");
if (null != box) {
var w = box.style.width;
var h = box.style.height;
box.style.left = get_left(w) + "px";
box.style.top = get_top(h) + "px";
}
}
export function remove() {
var mask = document.getElementById("mask");
var msgbox = document.getElementById("msgbox");
if (null == mask && null == msgbox) return;
document.body.removeChild(mask);
document.body.removeChild(msgbox);
}
function re_show() {
re_pos();
re_mask();
}
function load_func() {
window.onresize = re_show;
window.onscroll = re_show;
}
}