代码优化

This commit is contained in:
火烈鸟 2023-06-17 23:33:54 +08:00
parent 12c3cba183
commit 528276438b
2 changed files with 15 additions and 15 deletions

View File

@ -550,7 +550,7 @@
// 移动设备 // 移动设备
result.android = /android/.test(agent); result.android = /android/.test(agent);
result.ios = result.os === 'ios'; result.ios = result.os === 'ios';
result.mobile = (result.android || result.ios) ? true : false; result.mobile = (result.android || result.ios);
return result; return result;
}; };

View File

@ -74,7 +74,7 @@ var isLayui = window.layui && layui.define, $, win, ready = {
//如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范 //如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范
if(++timeout > 10 * 1000 / delay){ if(++timeout > 10 * 1000 / delay){
return window.console && console.error(app +'.css: Invalid'); return window.console && console.error(app +'.css: Invalid');
}; }
//css 加载就绪 //css 加载就绪
if(parseInt(ready.getStyle(getLinkElem, 'width')) === 1989){ if(parseInt(ready.getStyle(getLinkElem, 'width')) === 1989){
@ -406,9 +406,9 @@ Class.pt.creat = function(){
} else if(options.hideOnClose){ } else if(options.hideOnClose){
elemShade.show(); elemShade.show();
layero.show(); layero.show();
}; }
})(); })();
}; }
// 是否移除活动元素的焦点 // 是否移除活动元素的焦点
if(config.removeFocus) { if(config.removeFocus) {
@ -518,7 +518,7 @@ Class.pt.creat = function(){
that.layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ that.layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
$(this).removeClass(animClass); $(this).removeClass(animClass);
}); });
}; }
// 记录配置信息 // 记录配置信息
that.layero.data('config', config); that.layero.data('config', config);
@ -571,7 +571,7 @@ Class.pt.auto = function(index){
setHeight('.'+doms[5]); setHeight('.'+doms[5]);
} }
break; break;
}; }
return that; return that;
}; };
@ -660,7 +660,7 @@ Class.pt.tips = function(){
tipsG.css({right: 12, left: 'auto'}); tipsG.css({right: 12, left: 'auto'});
} else { } else {
goal.tipLeft = goal.left; goal.tipLeft = goal.left;
}; }
}; };
//辨别tips的方位 //辨别tips的方位
@ -1016,11 +1016,11 @@ layer.style = function(index, options, limit){
if(!limit){ if(!limit){
if(parseFloat(options.width) <= 260){ if(parseFloat(options.width) <= 260){
options.width = 260; options.width = 260;
}; }
if(parseFloat(options.height) - titHeight - btnHeight <= 64){ if(parseFloat(options.height) - titHeight - btnHeight <= 64){
options.height = 64 + titHeight + btnHeight; options.height = 64 + titHeight + btnHeight;
}; }
} }
layero.css(options); layero.css(options);
btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
@ -1131,7 +1131,7 @@ layer.restore = function(index){
// 全屏(最大化) // 全屏(最大化)
layer.full = function(index){ layer.full = function(index){
var layero = $('#'+ doms[0] + index), timer; var layero = $('#'+ doms[0] + index);
var maxminStatus = layero.data('maxminStatus'); var maxminStatus = layero.data('maxminStatus');
if(maxminStatus === 'max') return // 检查当前的状态是否已经是最大化 if(maxminStatus === 'max') return // 检查当前的状态是否已经是最大化
@ -1143,8 +1143,8 @@ layer.full = function(index){
if(!doms.html.attr('layer-full')){ if(!doms.html.attr('layer-full')){
doms.html.css('overflow','hidden').attr('layer-full', index); doms.html.css('overflow','hidden').attr('layer-full', index);
} }
clearTimeout(timer);
timer = setTimeout(function(){ setTimeout(function(){
var isfix = layero.css('position') === 'fixed'; var isfix = layero.css('position') === 'fixed';
layer.style(index, { layer.style(index, {
top: isfix ? 0 : win.scrollTop(), top: isfix ? 0 : win.scrollTop(),
@ -1262,7 +1262,7 @@ layer.closeAll = function(type, callback){
if(typeof type === 'function'){ if(typeof type === 'function'){
callback = type; callback = type;
type = null; type = null;
}; }
var domsElem = $('.'+doms[0]); var domsElem = $('.'+doms[0]);
$.each(domsElem, function(_index){ $.each(domsElem, function(_index){
var othis = $(this); var othis = $(this);
@ -1455,7 +1455,7 @@ layer.photos = function(options, loop, key){
dict.imgIndex++; dict.imgIndex++;
if(dict.imgIndex > data.length){ if(dict.imgIndex > data.length){
dict.imgIndex = 1; dict.imgIndex = 1;
if (errorMsg) {return}; if (errorMsg) {return}
} }
dict.tabimg(key) dict.tabimg(key)
}; };
@ -1521,7 +1521,7 @@ layer.photos = function(options, loop, key){
img.onerror = null; img.onerror = null;
error(e); error(e);
}; };
}; }
dict.loadi = layer.load(1, { dict.loadi = layer.load(1, {
shade: 'shade' in options ? false : 0.9, shade: 'shade' in options ? false : 0.9,