【 以下文字转载自 Google 讨论区 】
发信人: modico (modico), 信区: Google
标 题: gmail client code review,part 17
发信站: 水木社区 (Fri Oct 27 13:49:02 2006), 站内
关于modal对话框。很可惜,除了IE,支持这个特性的浏览器太少了。google为此煞费心机的设计了一个模拟modal对话框的机制,在一个几乎完全异步的界面环境中实现了一个模拟的同步效果。
function showModal/*he*/(uri, b, width, height, x, y)
{
// b 参数应是modal对话框的回调对象
assert/*Gd*/(b && b.fb);
rl = b;
var g = x != null ? x : Math.max(Math.floor((getWindowClientWidth/*Ap*/(top) - width) / 2), 0);
var h = y != null ? y : Math.max(Math.floor((getTopWindowClientHeight/*jq*/() - height) / 2), 0);
_IF_OnModalLoaded = function()
{
suspendEvents/*Vk*/(IF_GetVisibleWindow/*z*/());
displayModalIFrame/*cR*/(width, height, g, h);
};
view_navigate/*mq*/("mi", uri);
top.main.focus();
}
function displayModalIFrame/*cR*/(width, height, x, y)
{
var e = _getElementByIdDebug/*G7*/(top.main, "mi");
var f = e.style;
f.width = width;
f.height = height;
f.top = y;
f.left = x;
f.zIndex = 5;
// 在主显示窗口和模态窗口之间垫一个半透明的层
var g = top.main;
var h = getElementByIdAlways/*Gq*/(g, "msd");
var i = h.style;
i.zIndex = 4;
i.width = width + 8;
i.height = height + 10;
i.top = y;
i.left = x - 4;
i.position = "absolute";
h.innerHTML = '<div style="height:' + height + ";" + sO +
'"></div><div style="height:' + height + ";" + tO +
'"></div><div style="clear:both"></div><div style="' + qO +
'"></div><div style="width:' + (width - 14) + ";" + pO +
'"></div><div style="' + rO +
'"></div>';
}
--
FROM 218.249.84.*