/*
* artdialog v2.1.1
* date: 2010-06-02
* http://code.google.com/p/artdialog/
* (c) 2009-2010 tangbin, http://www.planeart.cn
*
* this is licensed under the gnu lgpl, version 2.1 or later.
* for details, see: http://creativecommons.org/licenses/lgpl/2.1/
*/
(function() {
this.art = {};
var ini = function(c, y, n) {
// artdialog('无配置参数的简写形式')
if (typeof c === 'string') {
var txt = c;
c = {};
c.content = txt;
c.fixed = true;
};
if (c.id && $gid(c.id)) return newbox(c.id);// 如果id存在则返回此id对话框
if (c.lock) c.fixed = true; // 执行锁屏也同时执行静止定位
if (c.menubtn) c.fixed = false; // 使用菜单模式就使用绝对定位
if (typeof y === 'function') c.yesfn = y;
if (typeof n === 'function') c.nofn = n;
if (c.url) c.iframe = c.url; // 兼容<2.1版调用方式
var config = {
id: c.id, // 对话框id
title: c.title || '\u63d0\u793a', // 标题
content: c.content, // 普通消息
iframe: c.iframe, // iframe消息
yestext: c.yestext || '\u786e\u5b9a', // 确定按钮文本
notext: c.notext || '\u53d6\u6d88', // 取消按钮文本
yesfn: c.yesfn, // 确定按钮事件
nofn: c.nofn, // 取消按钮事件
closefn: c.nofn, // 关闭按钮事件
width: c.width, // 宽度
height: c.height, // 高度
menubtn: c.menubtn, // 触发菜单模式的元素
left: c.left, // x轴坐标
top: c.top, // y轴坐标
fixed: c.fixed, // 是否静止定位
style: c.style, // 动态风格
lock: c.lock, // 是否锁屏
time: c.time // 限时关闭
//btopen //打开新窗口
};
return newbox(c.id).int(config);
},
alphafx = 4, // 锁屏遮罩透明渐变速度(等于1的时候不渐变,默认4)
zindex = 999999, // 对话框初始叠加高度(重要:opera浏览器z-index的最大值限制都小于其他浏览器)
hideid = 'temp_artdialog', // 用于预加载背景图的对话框id
bigbox = 100000, // 指定超过此面积的对话框拖动的时候用替身,(等于0的时候全部用替身, 默认240000)
closetext = '×', // 关闭按钮文本
loadtext = 'loading..', // iframe加载提示文本
pagelock = 0,
m = {},
tempbox,
boxs = [],
onmouse,
infocus,
closekey,
ie = !-[1,], // !+'\v1',
ie6 = ie && ([/msie (\d)\.0/i.exec(navigator.useragent)][0][1] == 6),
// 遍历
each = function(a, b) {
for (var i = 0, len = a.length; i < len; i++) b(a[i], i);
},
// 获取页面尺寸相关数据
// 如果要获取父页面或子页面的数据,请指定win参数
getpage = function(win){
var dd = win ? win.document.documentelement : document.documentelement,
db = win ? win.document.body : document.body,
dom = dd || db;
return {
width: math.max(dom.clientwidth, dom.scrollwidth), // 页面宽度
height: math.max(dom.clientheight, dom.scrollheight), // 页面长度
left: math.max(dd.scrollleft, db.scrollleft), // 被滚动条卷去的文档宽度
top: math.max(dd.scrolltop, db.scrolltop), // 被滚动条卷去的文档高度
winwidth: dom.clientwidth, // 浏览器视口宽度
winheight: dom.clientheight // 浏览器视口高度
};
},
// 事件绑定
bind = function (obj, type, fn) {
if (obj.attachevent) {
obj['e' + type + fn] = fn;
obj[type + fn] = function(){obj['e' + type + fn](window.event);}
obj.attachevent('on' + type, obj[type + fn]);
} else {
obj.addeventlistener(type, fn, false);
};
},
// 移除事件
unbind = function (obj, type, fn) {
if (obj.detachevent) {
try {
obj.detachevent('on' + type, obj[type + fn]);
obj[type + fn] = null;
} catch(_) {};
} else {
obj.removeeventlistener(type, fn, false);
};
},
// 阻止事件冒泡
stopbubble = function(e){
e.stoppropagation ? e.stoppropagation() : e.cancelbubble = true;
},
// 阻止浏览器默认行为
stopdefault = function(e){
e.preventdefault ? e.preventdefault() : e.returnvalue = false;
},
// 清除文本选择
clsselect = function(){
try{
window.getselection ? window.getselection().removeallranges() : document.selection.empty();
}catch(_){};
},
// 创建xhtml元素节点
$ce = function (name){
return document.createelement(name);
},
// 创建文本节点
$ctn = function (txt){
return document.createtextnode(txt);
},
// 用id获取对象
$gid = function (id){
return document.getelementbyid(id);
},
// 用标签获取对象
$gtag = function (tag) {
return document.getelementsbytagname(tag);
},
// 判断css类是否存在
hasclass = function(o, c){
var reg = new regexp('(\\s|^)'+c+'(\\s|$)');
return o.classname.match(reg);
},
// 添加css类
addclass = function(o, c){
if(!hasclass(o, c)){
o.classname += ' '+c;
};
},
// 移除css类
removeclass = function(o, c){
if(hasclass(o, c)){
var reg = new regexp('(\\s|^)'+c+'(\\s|$)');
o.classname = o.classname.replace(reg, ' ');
};
},
// 向head添加css
addstyle = function(s) {
var t = this.style;
if(!t){
t = this.style = $ce('style');
t.setattribute('type', 'text/css');
$gtag('head')[0].appendchild(t);
};
t.stylesheet && (t.stylesheet.csstext += s) || t.appendchild($ctn(s));
},
// 鼠标行为处理
cmd = function(evt, x) {
var e = evt || window.event,
b = this.data.box,
m = this.data.movetemp,
p = getpage(),
i = this.security(b);
m.box = this;
this.zindex();
onmouse = true;
m.x = e.clientx;
m.y = e.clienty;
m.top = parseint(b.style.top);
m.left = parseint(b.style.left);
m.width = b.offsetwidth;
m.height = b.offsetheight;
m.winwidth = p.winwidth;
m.winheight = p.winheight;
m.pagewidth = p.width;
m.pageheight = p.height;
m.pageleft = p.left;
m.pagetop = p.top;
// 保存最大拖动范围限制数据
m.maxx = i.maxx;
m.maxy = i.maxy;
var regular = setinterval(function(){
clsselect();
}, 40);
clsselect();
//对于超过预计尺寸的对话框用替身代替拖动,保证流畅性
if(m.width * m.height >= bigbox && !x) {
tempbox = true;
m.style.width = m.width + 'px';
m.style.height = m.height + 'px';
m.style.left = m.left + 'px';
m.style.top = m.top + 'px';
m.style.visibility = 'visible';
};
addclass(m.box.data.wrap, 'ui_move');
addclass($gtag('html')[0], 'ui_page_move');
document.onmousemove = function(a) {
x ? resize.call(b, a, x) : drag.call(b, a);
};
document.onmouseup = function() {
onmouse = false;
document.onmouseup = null;
if (document.body.releasecapture) b.releasecapture();// ie释放鼠标监控
removeclass(m.box.data.wrap, 'ui_move');
removeclass($gtag('html')[0], 'ui_page_move');
clearinterval(regular);
if (tempbox) {
m.style.visibility = 'hidden';
b.style.left = m.style.left;
b.style.top = m.style.top;
tempbox = false;
};
};
// 让ie下鼠标超出视口仍可控制
if (document.body.setcapture) {
b.setcapture();
};
},
// 拖动
drag = function(a) {
if (onmouse === false) return false;
var e = a || window.event,
obj = tempbox ? m.box.data.movetemp : m.box.data.box,
x = e.clientx,
y = e.clienty,
p = getpage(),
l = parseint(m.left - m.x + x - m.pageleft + p.left),
t = parseint(m.top - m.y + y - m.pagetop + p.top);
if (l > m.maxx) l = m.maxx;
if (t > m.maxy ) t = m.maxy;
if (l < 0) l = 0;
if (t < 0) t = 0;
obj.style.left = l + 'px';
obj.style.top = t + 'px';
return false;
},
// 调整对话框大小
resize = function(a, o) {
if (onmouse === false) return false;
var e = a || window.event,
x = e.clientx,
y = e.clienty,
w = m.width + x - m.x + o.w,
h = m.height + y - m.y + o.h;
if (w > 0) o.obj.style.width = w + 'px';
if (h > 0) o.obj.style.height = h + 'px';
// 覆盖下拉控件的遮罩
if (ie6) {
m.box.data.selectmask.style.width = m.box.data.box.offsetwidth + 'px';
m.box.data.selectmask.style.height = m.box.data.box.offsetheight + 'px';
};
return false;
},
// 生产对话框
newbox = function(id) {
// 循环利用
var j = -1;
each(boxs, function(o, i) {
if (id && o.data.wrap.id === id) {
j = i;
} else
if (o.free === true){
j = i;
};
});
if (j >= 0) return boxs[j];
//
// 九宫格布局
//
// 基于table 与 div,自适应
//
var _title_wrap = $ce('td'), // 标题栏
_title = $ce('div'), // 标题与按钮外套
_title_text = $ce('div'), // 标题文字内容
_close = $ce('a'); // 关闭按钮
_title_wrap.classname = 'ui_title_wrap';
_title.classname = 'ui_title';
_title_text.classname = 'ui_title_text';
_close.classname = 'ui_close';
_close.href = '#';
_close.setattribute('accesskey', 'c');
_close.appendchild($ctn(closetext));
_title.appendchild(_title_text);
_title.appendchild(_close);
_title_wrap.appendchild(_title);
var _content_wrap = $ce('td'), // 内容区
_content = $ce('div'),
_content_mask = $ce('div'), // iframe内容遮罩
_loading_tip = $ce('div');
_loading_tip.classname = 'ui_loading_tip'; // iframe加载提示
_loading_tip.appendchild($ctn(loadtext));
_content_wrap.classname = 'ui_content_wrap';
_content.classname = 'ui_content';
_content_mask.classname = 'ui_content_mask';
_content_wrap.appendchild(_content);
_content_wrap.appendchild(_loading_tip);
var _yesbtn = $ce('button'), // 确定按钮
_yeswrap = $ce('span'),
_nobtn = $ce('button'), // 取消按钮
_nowrap = $ce('span');
_yesbtn.setattribute('accesskey', 'y');
_yeswrap.classname = 'ui_yes';
_nobtn.setattribute('accesskey', 'n');
_nowrap.classname = 'ui_no';
var _bottom_wrap = $ce('td'), // 底部按钮区
_bottom = $ce('div'),
_btns = $ce('div'),
_resize = $ce('div'); // 调节对话框大小的手柄
_bottom_wrap.classname = 'ui_bottom_wrap';
_bottom.classname = 'ui_bottom';
_btns.classname = 'ui_btns';
_resize.classname = 'ui_resize';
_bottom.appendchild(_btns);
_bottom.appendchild(_resize);
_bottom_wrap.appendchild(_bottom);
var _dialog_main = $ce('table'), // 内容表格
_ctbody = $ce('tbody');
_dialog_main.classname = 'ui_dialog_main';
for(var r = 0; r < 3; r++){
var _tr = $ce('tr');
if (r == 0) _tr.appendchild(_title_wrap);
if (r == 1) _tr.appendchild(_content_wrap);
if (r == 2) _tr.appendchild(_bottom_wrap);
_ctbody.appendchild(_tr);
};
_dialog_main.appendchild(_ctbody);
var _btable = $ce('table'), // 外边框表格
_btbody = $ce('tbody');
for(var r=0;r<3;r++){
var _tr = $ce('tr');
for(var d=0; d<3; d++){
var _td = $ce('td');
if(r == 1 && d == 1) {
_td.classname = 'ui_td_' + r + d;
_td.appendchild(_dialog_main);
}else{
_td.classname = 'ui_border ' + 'ui_td_' + r + d;
};
_tr.appendchild(_td);
};
_btbody.appendchild(_tr);
};
_btable.appendchild(_btbody);
var _dialog = $ce('div'); // 对话框
_dialog.classname = 'ui_dialog';
if (ie6) {
var _ie6_select_mask = $ce('iframe'); // 使用一个iframe覆盖ie6下拉控件
_ie6_select_mask.classname = 'ui_ie6_select_mask';
_dialog.appendchild(_ie6_select_mask);
};
_dialog.appendchild(_btable);
var _overlay = $ce('div'); // 锁屏遮罩
_overlay.classname = 'ui_overlay';
_overlay.appendchild($ce('div'));
var _move_temp = $ce('div'); // 对话框移动状态的替身
_move_temp.classname = 'ui_move_temp';
_move_temp.appendchild($ce('div'));
document.body.appendchild(_move_temp);
var _dialog_wrap = $ce('div'); // 对话框外套
_dialog_wrap.classname = 'ui_dialog_wrap';
_dialog_wrap.appendchild(_overlay);
_dialog_wrap.appendchild(_dialog);
_dialog_wrap.appendchild(_move_temp);
/*九宫格布局结束*/
// 触发拖动函数
_title_text.onmousedown = function(a) {
cmd.call($, a, false);
return false;
};
// 触发调节大小函数
_resize.onmousedown = function(a) {
var d = _dialog,
c = _content_wrap;
cmd.call($, a, {obj:c, w:c.offsetwidth - d.offsetwidth, h:c.offsetheight - d.offsetheight});
return false;
};
// 给定tab切换焦点的按钮的值
_yesbtn.onfocus = _yesbtn.onblur = function(){
$.data.btntab = _nobtn;
};
_nobtn.onfocus = _nobtn.onblur = function(){
$.data.btntab = _yesbtn;
};
// 向页面插入对话框
document.body.appendchild(_dialog_wrap);
var $ = {
// 数据缓存
data: {
box: _dialog,
movetemp: _move_temp,
selectmask: _ie6_select_mask,
wrap: _dialog_wrap
},
int: function(c){
$.data.config = c;
if (typeof c.id === 'string') _dialog_wrap.id = c.id;
if (typeof c.style === 'string') _btable.classname = c.style;
$.content(c.title, c.content, c.iframe).
yesbtn(c.yesfn, c.yestext).
nobtn(c.nofn, c.notext).
closebtn(c.closefn).
size(c.width, c.height).
align(c.menubtn, c.left, c.top, c.fixed);
if (c.lock) $.lock.show();
if (c.time) $.time(c.time);
return $;
},
// 消息内容构建(标题, html内容, iframe)
content: function(title, content, iframe) {
$.free = false;
$.data.content = _content;// 存储内容容器
if (content) {
_content.innerhtml = '' + content;
$.btnfocus();
} else
if (iframe) {
$.loading.show();
$._iframe = $ce('iframe');
$._iframe.setattribute('frameborder', 0, 0); // 消除ie7可能会出现的边框
$._iframe.src = iframe;
addclass(_dialog_wrap, 'ui_iframe');
_content.appendchild($._iframe);
_content.appendchild(_content_mask);
// iframe加载完毕
$.data.iframeload = function(){
var c = $.data.config;
$.loading.hide();
if (!c.width && !c.height) try{
var i = getpage($._iframe.contentwindow);
$.size(i.width, i.height);
}catch (_){};
$._iframe.style.csstext = 'width:100%;height:100%'; // 自适应宽度需要最后设置,否则ie6、7无法正确获取iframe实际尺寸
if (!c.left && !c.top) $.center();
$.btnfocus();
};
bind($._iframe, 'load', $.data.iframeload);
// 存储iframe内容对象
$.data.iframe = $._iframe.contentwindow || $._iframe;
} else {
return $;
};
_title_text.innerhtml = '' + title;
_dialog_wrap.style.visibility = 'visible';
return $;
},
// 尺寸(宽度, 高度)
size: function(w, h) {
if(parseint(w) == w) w = w + 'px';
if(parseint(h) == h) h = h + 'px';
_content_wrap.style.width = w || '';
_content_wrap.style.height = h || '';
// 覆盖下拉控件的遮罩
if (ie6) {
_ie6_select_mask.style.width = _dialog.offsetwidth;
_ie6_select_mask.style.height = _dialog.offsetheight;
};
return $;
},
// 对话框安全范围计算
security: function(obj){
var minx, miny, maxx, maxy, centerx, centery;
$.data.boxwidth = obj.offsetwidth;
$.data.boxheight = obj.offsetheight;
var p = getpage();
m.winwidth = p.winwidth;
m.winheight = p.winheight;
m.pagewidth = p.width;
m.pageheight = p.height;
m.pageleft = p.left;
m.pagetop = p.top;
if ($.data.config.fixed) {
minx = 0;
maxx = m.winwidth - $.data.boxwidth;
centerx = maxx / 2;
miny = 0;
maxy = m.winheight - $.data.boxheight;
// 小对话框在视觉黄金比例垂直居中,大对话框绝对居中
var hc = m.winheight * 0.382 - $.data.boxheight / 2;
centery = ($.data.boxheight < m.winheight / 2) ? hc : maxy / 2;
} else {
minx = m.pageleft;
maxx = m.winwidth + minx - $.data.boxwidth;
centerx = maxx / 2;
miny = m.pagetop;
maxy = m.winheight + miny - $.data.boxheight;
// 黄金比例垂直居中
var hc = m.winheight * 0.382 - $.data.boxheight / 2 + miny;
centery = ($.data.boxheight < m.winheight / 2) ? hc : (maxy + miny) / 2;
};
if (centerx < 0) centerx = 0;
if (centery < 0) centery = 0;
return {minx: minx, miny: miny, maxx: maxx, maxy: maxy, centerx: centerx, centery: centery};
},
// 居中对齐
center: function(){
var t = $.security(_dialog)
_dialog.style.left = t.centerx + 'px';
_dialog.style.top = t.centery + 'px';
return $;
},
// 位置(指定元素附近弹出, 横坐标, 纵坐标, 是否静止定位)
align: function(menubtn, left, top, fixed) {
var t = $.security(_dialog);
// 获取指定对象的坐标,让对话框在按钮附近当作菜单弹出
if (menubtn && menubtn.getboundingclientrect) {
var w = $.data.boxwidth / 2 - menubtn.offsetwidth / 2,
h = menubtn.offsetheight,
ml = menubtn.getboundingclientrect().left,
mt = menubtn.getboundingclientrect().top;
if (w > ml) w = 0;
if (mt + h > m.winheight - $.data.boxheight) h = - $.data.boxheight;
left = ml + m.pageleft - w;
top = mt + m.pagetop + h;
};
if (fixed) {
if (ie6) addclass($gtag('html')[0], 'ui_ie6_fixed');// 关闭对话框不要清除此类,它只用来消除ie6抖动的问题
addclass(_dialog_wrap, 'ui_fixed');
};
if(!left){
$.data.boxleft = t.centerx;
}else if(left == 'left'){
$.data.boxleft = t.minx;
}else if(left == 'right'){
$.data.boxleft = t.maxx;
}else{
left = fixed ? left - m.pageleft : left;// 把原点移到浏览器视口
left = left < t.minx ? t.minx : left;
left = left > t.maxx ? t.maxx : left;
$.data.boxleft = left;
};
if (!top){
$.data.boxtop = t.centery;
} else if (top == 'top'){
$.data.boxtop = t.miny;
} else if (top == 'bottom'){
$.data.boxtop = t.maxy;
} else {
top = fixed ? top - m.pagetop : top;// 把原点移到浏览器视口
top = top < t.miny ? t.miny : top;
top = top > t.maxy ? t.maxy : top;
$.data.boxtop = top;
};
if (_dialog_wrap.id == hideid) $.data.boxleft = '-99999';// 让预加载背景图的对话框偏离可视范围
_dialog.style.left = $.data.boxleft + 'px';
_dialog.style.top = $.data.boxtop + 'px';
$.zindex(_dialog);
return $;
},
// 确定按钮(回调函数, 按钮文本)
yesbtn: function(fn, txt){
if (typeof fn === 'function') {
_yesbtn.innerhtml = txt;
_yeswrap.appendchild(_yesbtn);
_btns.appendchild(_yeswrap);
_yesbtn.onclick = function() {
var f = fn();
if (f != false) $.close();// 如果回调函数返回false则不关闭对话框
};
// 给确定按钮添加一个 ctrl + enter 快捷键
_dialog.onkeyup = function(evt){
var e = evt || window.event;
if(e.ctrlkey && e.keycode == 13) _yesbtn.click();
};
};
return $;
},
// 取消按钮(回调函数, 按钮文本)
nobtn: function(fn, txt){
if (typeof fn === 'function') {
_nobtn.innerhtml = txt;
_nowrap.appendchild(_nobtn);
_btns.appendchild(_nowrap);
_nobtn.onclick = function() {
var f = fn();
if (f != false) $.close();// 如果回调函数返回false则不关闭对话框
};
};
return $;
},
// 关闭按钮(回调函数)
closebtn: function(fn){
_close.onclick = function(){
if (typeof fn === 'function') {
var f = fn();
if (f != false) $.close();// 如果回调函数返回false则不关闭对话框
} else {
$.close();
};
return false;
};
return $;
},
// 焦点定位
btnfocus: function(){
settimeout(function(){
try{
if ($.data.config.nofn) {
_nobtn.focus();
} else
if ($.data.config.yesfn) {
_yesbtn.focus();
} else {
_close.focus();
};
}catch(_){};
}, 40);
return $;
},
// 关闭对话框(回调函数)
close: function(f) {
if (f) {
if (typeof f === 'function') $.data.closefn = f;
return $;
};
// 执行回调函数
if ($.data.closefn) {
var cfn = $.data.closefn();
if (cfn != false) {
$.data.closefn = null;
} else {
return $;
};
};
_btable.classname = _dialog.style.csstext = _title_text.innerhtml = _content.innerhtml = _btns.innerhtml = _dialog_wrap.id = '';// 设置复位
each(['ui_fixed', 'ui_loading', 'ui_focus', 'ui_iframe'], function(o, i) {
removeclass(_dialog_wrap, o);
});
_dialog_wrap.style.visibility = 'hidden';
$._iframe = null;
$.lock.hide();
onmouse = false;
$.free = true;
},
// 定时关闭对话框(秒)
time: function(t) {
if (typeof t === 'number') settimeout(function(){
$.close();
}, 1000 * t);
return $;
},
// 对话框叠加高度
zindex: function() {
zindex++;
_dialog.style.zindex = _overlay.style.zindex = _dialog_wrap.style.zindex = zindex; //_dialog_wrap: ie6与opera叠加高度受具有绝对或者相对定位的父元素z-index控制
_move_temp.style.zindex = zindex + 1;
// 当出现多个对话框时,让顶层对话框显得与众不同
if (infocus) removeclass(infocus, 'ui_focus');
addclass(_dialog_wrap, 'ui_focus');
infocus = _dialog_wrap;
// 定义esc键关闭最高的弹出层
if (closekey) unbind(document, 'keyup', closekey);
closekey = function(evt){
var e = evt || window.event;
if (e.keycode == 27) _close.onclick();
};
bind(document, 'keyup', closekey);
return $;
},
// 显示加载提示
loading: {
show: function(){
addclass(_dialog_wrap, 'ui_loading');
return $;
},
hide: function(){
removeclass(_dialog_wrap, 'ui_loading');
return $;
}
},
// 锁屏
lock: {
show: function(){
if (pagelock >= 1) return $;// 遮罩数量限制(ie只支持一个)
var h = $gtag('html')[0];
addclass(_dialog_wrap, 'ui_lock');
addclass(h, 'ui_page_lock');
$.zindex(_overlay);
// 让tab等键在对话框中仍然能使用
_dialog.onkeydown = function(evt){
var e = evt || window.event,
key = e.keycode;
if (key == 9 || key == 38 || key == 40) stopbubble(e);
};
// 让右键在对话框中仍然能使用
_dialog.oncontextmenu = function(evt){
var e = evt || window.event;
stopbubble(e);
};
// 页面鼠标操作限制
var p = getpage();
m.pageleft = p.left,
m.pagetop = p.top;
$.data.lockmouse = function(evt){
var e = evt || window.event;
stopbubble(e);
stopdefault(e);
scroll(m.pageleft, m.pagetop);
};
each(['dommousescroll', 'mousewheel', 'scroll'], function(o, i) {
bind(document, o, $.data.lockmouse);
});
// 屏蔽特定按键: f5, ctrl + r, ctrl + a, tab, up, down
$.data.lockkey = function(evt){
var e = evt || window.event,
key = e.keycode;
// 切换按钮焦点
if (key == 37 || key == 39 || key == 9) {
try{
$.data.btntab.focus();
}catch(_){};
};
if((key == 116) || (e.ctrlkey && key == 82) || (e.ctrlkey && key == 65) || (key == 9) || (key == 38) || (key == 40)) {
try{
e.keycode = 0;// 阻止f5键默认行为需要加上这句(ie8测试)
}catch(_){};
stopdefault(e);
};
};
bind(document, 'keydown', $.data.lockkey);
_overlay.onclick = _overlay.oncontextmenu = function(){
$.btnfocus();
return false;
};
$.alpha(_overlay, 0, function(){
pagelock ++;
});
return $;
},
// 关闭锁屏
hide: function(){
if (_dialog_wrap.classname.indexof('ui_lock') > -1){
$.alpha(_overlay, 1, function(){
removeclass(_dialog_wrap, 'ui_lock');
if (pagelock == 1) removeclass($gtag('html')[0], 'ui_page_lock');// 移除顶级页面锁屏样式
each(['dommousescroll', 'mousewheel', 'scroll', 'contextmenu'], function(o, i) {
unbind(document, o, $.data.lockmouse); // 解除页面鼠标操作限制
});
unbind(document, 'keydown', $.data.lockkey); // 解除屏蔽的按键
pagelock --;
});
};
return $;
}
},
// 透明渐变(元素, 初始透明值[0,1], 回调函数)
alpha: function(obj, int, fn){
var m = obj.filters ? 100 : 1, // 最大值
s = m / alphafx; // 速度
s = int == 0 ? s : -s;
int = (obj.filters && int == 1) ? 100 : int;
var fx = function(){
int = int + s;
obj.filters ? obj.filters.alpha.opacity = int : obj.style.opacity = int;
if (0 >= int || int >= m) {
if (fn) fn();
clearinterval($.data.startfx);
};
};
fx();
clearinterval($.data.startfx);
$.data.startfx = setinterval(fx, 40);
return $;
}
};
// 保存对话框列队
return boxs[boxs.push($) - 1];
};
//
// artdialog兼容框架样式[内部版本1.3 2010-06-02]
//
//
addstyle('.ui_dialog_wrap{visibility:hidden}.ui_title_icon,.ui_content,.ui_dialog_icon,.ui_btns span{display:inline-block;*zoom:1;*display:inline}.ui_dialog{text-align:left;position:absolute;top:0}.ui_dialog table{border:0;margin:0;border-collapse:collapse}.ui_dialog td{padding:0}.ui_title_icon,.ui_dialog_icon{vertical-align:middle;_font-size:0}.ui_title_text{overflow:hidden;cursor:default}.ui_close{display:block;position:absolute;outline:none}.ui_content_wrap{text-align:center}.ui_content{margin:10px;text-align:left}.ui_iframe .ui_content{margin:0;*padding:0;display:block;height:100%;position:relative}.ui_iframe .ui_content iframe{border:none;overflow:auto}.ui_content_mask {visibility:hidden;width:100%;height:100%;position:absolute;top:0;left:0;background:#fff;filter:alpha(opacity=0);opacity:0}.ui_bottom{position:relative}.ui_resize{position:absolute;right:0;bottom:0;z-index:1;cursor:nw-resize;_font-size:0}.ui_btns{text-align:right;white-space:nowrap}.ui_btns span{margin:5px 10px}.ui_btns button{cursor:pointer}* .ui_ie6_select_mask{position:absolute;top:0;left:0;z-index:-1;filter:alpha(opacity=0)}.ui_loading .ui_content_wrap{position:relative;min-width:9em;min-height:3.438em}.ui_loading .ui_btns{display:none}.ui_loading_tip{visibility:hidden;width:5em;height:1.2em;text-align:center;line-height:1.2em;position:absolute;top:50%;left:50%;margin:-0.6em 0 0 -2.5em}.ui_loading .ui_loading_tip,.ui_loading .ui_content_mask{visibility:visible}.ui_loading .ui_content_mask{filter:alpha(opacity=100);opacity:1}.ui_move .ui_title_text{cursor:move}.ui_page_move .ui_content_mask{visibility:visible}.ui_move_temp{visibility:hidden;position:absolute;cursor:move}.ui_move_temp div{height:100%}html>body .ui_fixed .ui_move_temp{position:fixed}html>body .ui_fixed .ui_dialog{position:fixed}* .ui_ie6_fixed{background:url(*) fixed}* .ui_ie6_fixed body{height:100%}* html .ui_fixed{width:100%;height:100%;position:absolute;left:expression(documentelement.scrollleft+documentelement.clientwidth-this.offsetwidth);top:expression(documentelement.scrolltop+documentelement.clientheight-this.offsetheight)}* .ui_page_lock select,* .ui_page_lock .ui_ie6_select_mask{visibility:hidden}.ui_overlay{visibility:hidden;_display:none;position:fixed;top:0;left:0;width:100%;height:100%;filter:alpha(opacity=0);opacity:0;_overflow:hidden}.ui_lock .ui_overlay{visibility:visible;_display:block}.ui_overlay div{height:100%}* html body{margin:0}');
if (ie6) document.execcommand('backgroundimagecache', false, true);// 开启ie css背景图片缓存
// 页面载入即启动一个隐秘对话框,让浏览器预先加载皮肤背景图片
bind(window, 'load', function(){
if (!infocus) artdialog({id:hideid, style:'confirm alert error succeed', time:10}, function(){}, function(){});
});
// 对话框接口
art.dialog = ini;
this.artdialog = ini;// 兼容老版本调用方式
})();