mirror of https://github.com/layui/layer
3.0
parent
20c6d29d3f
commit
943169f38a
27
src/layer.js
27
src/layer.js
|
@ -27,7 +27,12 @@ var isLayui = window.layui && layui.define, $, win, ready = {
|
||||||
//默认内置方法。
|
//默认内置方法。
|
||||||
var layer = {
|
var layer = {
|
||||||
v: '3.0',
|
v: '3.0',
|
||||||
ie6: !!window.ActiveXObject&&!window.XMLHttpRequest,
|
ie: function(){ //ie版本
|
||||||
|
var agent = navigator.userAgent.toLowerCase();
|
||||||
|
return (!!window.ActiveXObject || "ActiveXObject" in window) ? (
|
||||||
|
(agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识
|
||||||
|
) : false;
|
||||||
|
}(),
|
||||||
index: (window.layer && window.layer.v) ? 100000 : 0,
|
index: (window.layer && window.layer.v) ? 100000 : 0,
|
||||||
path: ready.getPath,
|
path: ready.getPath,
|
||||||
config: function(options, fn){
|
config: function(options, fn){
|
||||||
|
@ -295,7 +300,7 @@ Class.pt.creat = function(){
|
||||||
config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times);
|
config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times);
|
||||||
}).auto(times);
|
}).auto(times);
|
||||||
|
|
||||||
config.type == 2 && layer.ie6 && that.layero.find('iframe').attr('src', content[0]);
|
config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]);
|
||||||
|
|
||||||
//坐标自适应浏览器窗口尺寸
|
//坐标自适应浏览器窗口尺寸
|
||||||
config.type == 4 ? that.tips() : that.offset();
|
config.type == 4 ? that.tips() : that.offset();
|
||||||
|
@ -323,7 +328,7 @@ Class.pt.auto = function(index){
|
||||||
var that = this, config = that.config, layero = $('#'+ doms[0] + index);
|
var that = this, config = that.config, layero = $('#'+ doms[0] + index);
|
||||||
if(config.area[0] === '' && config.maxWidth > 0){
|
if(config.area[0] === '' && config.maxWidth > 0){
|
||||||
//为了修复IE7下一个让人难以理解的bug
|
//为了修复IE7下一个让人难以理解的bug
|
||||||
if(/MSIE 7/.test(navigator.userAgent) && config.btn){
|
if(layer.ie && layer.ie < 8 && config.btn){
|
||||||
layero.width(layero.innerWidth());
|
layero.width(layero.innerWidth());
|
||||||
}
|
}
|
||||||
layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth);
|
layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth);
|
||||||
|
@ -518,7 +523,9 @@ Class.pt.move = function(){
|
||||||
//拖拽移动
|
//拖拽移动
|
||||||
if(dict.moveStart){
|
if(dict.moveStart){
|
||||||
var X = e.clientX - dict.offset[0]
|
var X = e.clientX - dict.offset[0]
|
||||||
,Y = e.clientY - dict.offset[1]
|
,Y = e.clientY - dict.offset[1];
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
dict.stX = config.fixed ? 0 : win.scrollLeft();
|
dict.stX = config.fixed ? 0 : win.scrollLeft();
|
||||||
dict.stY = config.fixed ? 0 : win.scrollTop();
|
dict.stY = config.fixed ? 0 : win.scrollTop();
|
||||||
|
@ -537,20 +544,20 @@ Class.pt.move = function(){
|
||||||
left: X
|
left: X
|
||||||
,top: Y
|
,top: Y
|
||||||
});
|
});
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Resize
|
//Resize
|
||||||
if(config.resize && dict.resizeStart){
|
if(config.resize && dict.resizeStart){
|
||||||
var X = e.clientX - dict.offset[0]
|
var X = e.clientX - dict.offset[0]
|
||||||
,Y = e.clientY - dict.offset[1]
|
,Y = e.clientY - dict.offset[1];
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
layer.style(that.index, {
|
layer.style(that.index, {
|
||||||
width: dict.area[0] + X
|
width: dict.area[0] + X
|
||||||
,height: dict.area[1] + Y
|
,height: dict.area[1] + Y
|
||||||
})
|
})
|
||||||
dict.isResize = true;
|
dict.isResize = true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}).on('mouseup', function(e){
|
}).on('mouseup', function(e){
|
||||||
if(dict.moveStart){
|
if(dict.moveStart){
|
||||||
|
@ -579,7 +586,7 @@ Class.pt.callback = function(){
|
||||||
config.success(layero, that.index);
|
config.success(layero, that.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layer.ie6 && that.IE6(layero);
|
layer.ie == 6 && that.IE6(layero);
|
||||||
|
|
||||||
//按钮
|
//按钮
|
||||||
layero.find('.'+ doms[6]).children('a').on('click', function(){
|
layero.find('.'+ doms[6]).children('a').on('click', function(){
|
||||||
|
@ -876,7 +883,7 @@ layer.close = function(index){
|
||||||
};
|
};
|
||||||
layero.addClass(closeAnim);
|
layero.addClass(closeAnim);
|
||||||
$('#layui-layer-moves, #layui-layer-shade' + index).remove();
|
$('#layui-layer-moves, #layui-layer-shade' + index).remove();
|
||||||
layer.ie6 && ready.reselect();
|
layer.ie == 6 && ready.reselect();
|
||||||
ready.rescollbar(index);
|
ready.rescollbar(index);
|
||||||
typeof ready.end[index] === 'function' && ready.end[index]();
|
typeof ready.end[index] === 'function' && ready.end[index]();
|
||||||
delete ready.end[index];
|
delete ready.end[index];
|
||||||
|
@ -886,7 +893,7 @@ layer.close = function(index){
|
||||||
}
|
}
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
remove();
|
remove();
|
||||||
}, 200);
|
}, (layer.ie && layer.ie < 10) ? 0 : 200);
|
||||||
};
|
};
|
||||||
|
|
||||||
//关闭所有层
|
//关闭所有层
|
||||||
|
|
Loading…
Reference in New Issue