This commit is contained in:
贤心
2022-06-23 00:03:41 +08:00
parent 8e66f49320
commit 3b8f6a0477
15 changed files with 545 additions and 469 deletions

View File

@@ -673,12 +673,15 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-form-item .layui-input-inline{float: left; width: 190px; margin-right: 10px;}
.layui-form-text .layui-input-inline{width: auto;}
/* 分割块 */.layui-form-mid{position: relative; float: left; display: block; padding: 9px 0 !important; line-height: 20px; margin-right: 10px;}
/* 警告域 */.layui-form-danger:focus
,.layui-form-danger+.layui-form-select .layui-input{border-color: #FF5722 !important;}
/* 分割块 */
.layui-form-mid{position: relative; float: left; display: block; padding: 9px 0 !important; line-height: 20px; margin-right: 10px;}
/* 警告条 */
.layui-form-danger:focus,
.layui-form-danger+.layui-form-select .layui-input{border-color: #FF5722 !important;}
/* 下拉选择 */.layui-form-select{position: relative;}
/* 下拉选择 */
.layui-form-select{position: relative;}
.layui-form-select .layui-input{padding-right: 30px; cursor: pointer;}
.layui-form-select .layui-edge{position: absolute; right: 10px; top: 50%; margin-top: -3px; cursor: pointer; border-width: 6px; border-top-color: #c2c2c2; border-top-style: solid; transition: all .3s; -webkit-transition: all .3s;}
.layui-form-select dl{display: none; position: absolute; left: 0; top: 42px; padding: 5px 0; z-index: 899; min-width: 100%; border: 1px solid #eee; max-height: 300px; overflow-y: auto; background-color: #fff; border-radius: 2px; box-shadow: 1px 1px 4px rgb(0 0 0 / 8%); box-sizing: border-box;}

View File

@@ -15,7 +15,7 @@
}
,Layui = function(){
this.v = '2.7.0-rc1'; // layui 版本号
this.v = '2.7.0-rc.1'; // layui 版本号
}
//识别预先可能定义的指定全局对象

View File

@@ -276,11 +276,15 @@ layui.define('jquery', function(exports){
that.haveSlide = true;
layui.event.call(this, MOD_NAME, 'change('+ filter +')', {
// 回调返回的参数
var params = {
index: options.index
,prevIndex: thisIndex
,item: elemItem.eq(options.index)
});
};
typeof options.change === 'function' && options.change(params);
layui.event.call(this, MOD_NAME, 'change('+ filter +')', params);
};
//事件处理
@@ -292,10 +296,10 @@ layui.define('jquery', function(exports){
//移入移出容器
options.elem.on('mouseenter', function(){
if (that.config.autoplay === 'always') return;
if (options.autoplay === 'always') return;
clearInterval(that.timer);
}).on('mouseleave', function(){
if (that.config.autoplay === 'always') return;
if (options.autoplay === 'always') return;
that.autoplay();
});

View File

@@ -179,6 +179,9 @@ layui.define('layer', function(exports){
,nearElem; //select 组件当前选中的附近元素,用于辅助快捷键功能
if(disabled) return;
// 搜索项
var laySearch = select.attr('lay-search');
//展开下拉
var showDown = function(){
@@ -339,13 +342,22 @@ layui.define('layer', function(exports){
}
});
//检测值是否不属于 select 项
// 检测值是否不属于 select 项
var notOption = function(value, callback, origin){
var num = 0;
layui.each(dds, function(){
var othis = $(this)
,text = othis.text()
,not = text.indexOf(value) === -1;
var othis = $(this);
var text = othis.text();
// 是否区分大小写
if(laySearch !== 'exact'){
text = text.toLowerCase();
value = value.toLowerCase();
}
// 匹配
var not = text.indexOf(value) === -1;
if(value === '' || (origin === 'blur') ? value !== text : not) num++;
origin === 'keyup' && othis[not ? 'addClass' : 'removeClass'](HIDE);
});
@@ -649,28 +661,29 @@ layui.define('layer', function(exports){
return that;
};
// verifyElem: 要验证的节点或者范围 返回验证通过返回true否则返回false
Form.prototype.validate = function(verifyElem){
var stop = null //验证不通过状态
,verify = form.config.verify //验证规则
,DANGER = 'layui-form-danger' //警示样式
// elem 要验证的区域表单选择器 - return true or false
Form.prototype.validate = function(elem){
var stop = null; //验证不通过状态
var verify = form.config.verify; //验证规则
var DANGER = 'layui-form-danger'; //警示样式
if (layui.type(verifyElem) !== 'object') { // 不符合要求的格式直接判通过
hint.error('validate: 参数错误');
return true;
}
if (!verifyElem.attr('lay-verify')) {
// 验证某个容器内的节点
verifyElem = verifyElem.find('*[lay-verify]');
elem = $(elem);
// 节点不存在可视为 true
if(!elem[0]) return !0;
// 若节点不存在特定属性,则查找容器内有待验证的子节点
if(!elem.attr('lay-verify')){
elem = elem.find('*[lay-verify]');
}
//开始校验
layui.each(verifyElem, function(_, item){
var othis = $(this)
,verifyStr = othis.attr('lay-verify') || ''
,vers = verifyStr.split('|')
,verType = othis.attr('lay-verType') //提示方式
,value = othis.val();
layui.each(elem, function(_, item){
var othis = $(this);
var verifyStr = othis.attr('lay-verify') || '';
var vers = verifyStr.split('|');
var verType = othis.attr('lay-verType'); //提示方式
var value = othis.val();
othis.removeClass(DANGER); //移除警示样式
@@ -711,21 +724,27 @@ layui.define('layer', function(exports){
else if(/\bstring|number\b/.test(typeof errorText)){
layer.msg(errorText, {icon: 5, shift: 6});
}
setTimeout(function(){
(isForm2Elem ? othis.next().find('input') : item).focus();
}, 7);
//非移动设备自动定位焦点
/*
// 非移动设备自动定位焦点
if(!device.mobile){
setTimeout(function(){
(isForm2Elem ? othis.next().find('input') : item).focus();
}, 7);
} else { //移动设备定位
} else { // 移动设备定位
$dom.scrollTop(function(){
try {
return (isForm2Elem ? othis.next() : othis).offset().top - 15
return (isForm2Elem ? othis.next() : othis).focus().offset().top - 15
} catch(e){
return 0;
}
}());
}
*/
othis.addClass(DANGER);
return stop = true;

View File

@@ -341,7 +341,7 @@
//主面板
,elem = that.elem = lay.elem('div', {
id: that.elemID
,'class': [
,"class": [
'layui-laydate'
,options.range ? ' layui-laydate-range' : ''
,isStatic ? (' '+ ELEM_STATIC) : ''
@@ -357,7 +357,7 @@
//底部区域
,divFooter = that.footer = lay.elem('div', {
'class': ELEM_FOOTER
"class": ELEM_FOOTER
});
if(options.zIndex) elem.style.zIndex = options.zIndex;
@@ -370,38 +370,38 @@
//头部区域
var divHeader = lay.elem('div', {
'class': 'layui-laydate-header'
"class": 'layui-laydate-header'
})
//左右切换
,headerChild = [function(){ //上一年
var elem = lay.elem('i', {
'class': 'layui-icon laydate-icon laydate-prev-y'
"class": 'layui-icon laydate-icon laydate-prev-y'
});
elem.innerHTML = '';
return elem;
}(), function(){ //上一月
var elem = lay.elem('i', {
'class': 'layui-icon laydate-icon laydate-prev-m'
"class": 'layui-icon laydate-icon laydate-prev-m'
});
elem.innerHTML = '';
return elem;
}(), function(){ //年月选择
var elem = lay.elem('div', {
'class': 'laydate-set-ym'
"class": 'laydate-set-ym'
}), spanY = lay.elem('span'), spanM = lay.elem('span');
elem.appendChild(spanY);
elem.appendChild(spanM);
return elem;
}(), function(){ //下一月
var elem = lay.elem('i', {
'class': 'layui-icon laydate-icon laydate-next-m'
"class": 'layui-icon laydate-icon laydate-next-m'
});
elem.innerHTML = '';
return elem;
}(), function(){ //下一年
var elem = lay.elem('i', {
'class': 'layui-icon laydate-icon laydate-next-y'
"class": 'layui-icon laydate-icon laydate-next-y'
});
elem.innerHTML = '';
return elem;
@@ -409,7 +409,7 @@
//日历内容区域
,divContent = lay.elem('div', {
'class': 'layui-laydate-content'
"class": 'layui-laydate-content'
})
,table = lay.elem('table')
,thead = lay.elem('thead'), theadTr = lay.elem('tr');
@@ -436,7 +436,7 @@
divContent.appendChild(table);
elemMain[i] = lay.elem('div', {
'class': 'layui-laydate-main laydate-main-list-'+ i
"class": 'layui-laydate-main laydate-main-list-'+ i
});
elemMain[i].appendChild(divHeader);
@@ -549,7 +549,7 @@
var that = this
,options = that.config
,div = lay.elem('div', {
'class': ELEM_HINT
"class": ELEM_HINT
});
if(!that.elem) return;
@@ -865,7 +865,7 @@
lay.each(tds, function(index_, item){
var YMD = [dateTime.year, dateTime.month], st = 0;
item = lay(item);
item.removeAttr('class');
item.removeAttr("class");
if(index_ < startWeek){
st = prevMaxDate - startWeek + index_;
item.addClass('laydate-day-prev');
@@ -948,7 +948,7 @@
,isAlone = options.range && options.type !== 'date' && options.type !== 'datetime' //独立范围选择器
,ul = lay.elem('ul', {
'class': ELEM_LIST + ' ' + ({
"class": ELEM_LIST + ' ' + ({
year: 'laydate-year-list'
,month: 'laydate-month-list'
,time: 'laydate-time-list'
@@ -1131,7 +1131,7 @@
});
} else { //时间选择面板 - 选择事件
var span = lay.elem('span', {
'class': ELEM_TIME_TEXT
"class": ELEM_TIME_TEXT
})
//滚动条定位

View File

@@ -28,35 +28,43 @@ layui.define(function(exports){
}
};
//分页视图
// 分页视图
Class.prototype.view = function(){
var that = this
,config = that.config
,groups = config.groups = 'groups' in config ? (config.groups|0) : 5; //连续页码个数
var that = this;
var config = that.config;
// 连续页码个数
var groups = config.groups = 'groups' in config
? (Number(config.groups) || 0)
: 5;
//排版
// 排版
config.layout = typeof config.layout === 'object'
? config.layout
: ['prev', 'page', 'next'];
config.count = config.count|0; //数据总数
config.curr = (config.curr|0) || 1; //当前页
config.count = Number(config.count) || 0; // 数据总数
config.curr = Number(config.curr) || 1; // 当前页
//每页条数的选择项
// 每页条数的选择项
config.limits = typeof config.limits === 'object'
? config.limits
: [10, 20, 30, 40, 50];
config.limit = (config.limit|0) || 10; //默认条数
// 默认条数
config.limit = Number(config.limit) || 10;
//总页数
config.pages = Math.ceil(config.count/config.limit) || 1;
//当前页不能超过总页数
// 当前页不能超过总页数
if(config.curr > config.pages){
config.curr = config.pages;
} else if(config.curr < 1) { // 当前分页不能小于 1
config.curr = 1;
}
//连续分页个数不能低于0且不能大于总页数
//连续分页个数不能低于 0 且不能大于总页数
if(groups < 0){
groups = 1;
} else if (groups > config.pages){
@@ -197,7 +205,7 @@ layui.define(function(exports){
,input = elem[tag]('input')[0]
,select = elem[tag]('select')[0]
,skip = function(){
var curr = input.value.replace(/\s|\D/g, '')|0;
var curr = Number(input.value.replace(/\s|\D/g, ''));
if(curr){
config.curr = curr;
that.render();
@@ -210,7 +218,7 @@ layui.define(function(exports){
for(var i = 0, len = childs.length; i < len; i++){
if(childs[i].nodeName.toLowerCase() === 'a'){
laypage.on(childs[i], 'click', function(){
var curr = this.getAttribute('data-page')|0;
var curr = Number(this.getAttribute('data-page'));
if(curr < 1 || curr > config.pages) return;
config.curr = curr;
that.render();

View File

@@ -4,7 +4,7 @@
layui.define('jquery', function(exports){
"use strict";
var $ = layui.jquery
var $ = layui.$
//外部接口
,slider = {
@@ -111,7 +111,7 @@ layui.define('jquery', function(exports){
var theme = options.disabled ? '#c2c2c2' : options.theme;
//滑块
var temp = '<div class="layui-slider '+ (options.type === 'vertical' ? 'layui-slider-vertical' : '') +'">'+ (options.tips ? '<div class="layui-slider-tips"></div>' : '') +
var temp = '<div class="layui-slider '+ (options.type === 'vertical' ? 'layui-slider-vertical' : '') +'">'+ (options.tips ? '<div class="'+ SLIDER_TIPS +'"></div>' : '') +
'<div class="layui-slider-bar" style="background:'+ theme +'; '+ (options.type === 'vertical' ? 'height' : 'width') +':'+ scale +';'+ (options.type === 'vertical' ? 'bottom' : 'left') +':'+ (scaleFir || 0) +';"></div><div class="layui-slider-wrap" style="'+ (options.type === 'vertical' ? 'bottom' : 'left') +':'+ (scaleFir || scale) +';">' +
'<div class="layui-slider-wrap-btn" style="border: 2px solid '+ theme +';"></div></div>'+ (options.range ? '<div class="layui-slider-wrap" style="'+ (options.type === 'vertical' ? 'bottom' : 'left') +':'+ scaleSec +';"><div class="layui-slider-wrap-btn" style="border: 2px solid '+ theme +';"></div></div>' : '') +'</div>';
@@ -174,6 +174,7 @@ layui.define('jquery', function(exports){
};
//划过滑块显示数值
var timer;
that.elemTemp.find('.' + SLIDER_WRAP_BTN).on('mouseover', function(){
var sliderWidth = options.type === 'vertical' ? options.height : that.elemTemp[0].offsetWidth
,sliderWrap = that.elemTemp.find('.' + SLIDER_WRAP)
@@ -182,12 +183,24 @@ layui.define('jquery', function(exports){
,value = $(this).parent().data('value')
,tipsTxt = options.setTips ? options.setTips(value) : value;
that.elemTemp.find('.' + SLIDER_TIPS).html(tipsTxt);
if(options.type === 'vertical'){
that.elemTemp.find('.' + SLIDER_TIPS).css({"bottom":left + '%', "margin-bottom":"20px", "display":"inline-block"});
}else{
that.elemTemp.find('.' + SLIDER_TIPS).css({"left":left + '%', "display":"inline-block"});
};
clearTimeout(timer);
timer = setTimeout(function(){
if(options.type === 'vertical'){
that.elemTemp.find('.' + SLIDER_TIPS).css({
"bottom": left + '%',
"margin-bottom": "20px",
"display": "inline-block"
});
} else {
that.elemTemp.find('.' + SLIDER_TIPS).css({
"left": left + '%',
"display": "inline-block"
});
};
}, 300);
}).on('mouseout', function(){
clearTimeout(timer);
that.elemTemp.find('.' + SLIDER_TIPS).css("display", "none");
});
};

View File

@@ -254,7 +254,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,loading: true //请求数据时,是否显示 loading
,escape: true // 是否开启 HTML 编码功能,即转义 html 原文
,cellMinWidth: 60 //所有单元格默认最小宽度
,editTrigger: 'click' //单元格编辑的触发方式
,editTrigger: 'click' //单元格编辑的事件触发方式
,defaultToolbar: ['filter', 'exports', 'print'] //工具栏右侧图标
,autoSort: true //是否前端自动排序。如果否,则需自主排序(通常为服务端处理好排序)
,text: {
@@ -1647,7 +1647,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
}));
});
//行事件
// 行事件
that.layBody.on('mouseenter', 'tr', function(){ //鼠标移入行
var othis = $(this)
,index = othis.index();
@@ -1674,7 +1674,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
);
};
//单元格编辑
// 单元格编辑
that.layBody.on('change', '.'+ELEM_EDIT, function(){
var othis = $(this)
,value = this.value
@@ -1711,7 +1711,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
othis.remove();
});
//单元格单击事件
// 单元格事件
that.layBody.on(options.editTrigger, 'td', function(e){
var othis = $(this)
,field = othis.data('field')
@@ -1790,14 +1790,29 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
layui.stope(e);
});
//行工具条操作事件
that.layBody.on('click', '*[lay-event]', function(){
var othis = $(this)
,index = othis.parents('tr').eq(0).data('index');
layui.event.call(this, MOD_NAME, 'tool('+ filter +')', commonMember.call(this, {
event: othis.attr('lay-event')
}));
// 行工具条操作事件
var toolFn = function(type){
var othis = $(this);
var index = othis.parents('tr').eq(0).data('index');
layui.event.call(
this,
MOD_NAME,
(type || 'tool') + '('+ filter +')',
commonMember.call(this, {
event: othis.attr('lay-event')
})
);
that.setThisRowChecked(index);
};
// 行工具条单击事件
that.layBody.on('click', '*[lay-event]', function(){
toolFn.call(this);
return false;
}).on('dblclick', '*[lay-event]', function(){ //行工具条双击事件
toolFn.call(this, 'toolDouble');
return false;
});
//同步滚动条
@@ -1934,7 +1949,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
}
};
//遍历表头
// 遍历表头
table.eachCols = function(id, callback, cols){
var config = thisTable.config[id] || {}
,arrs = [], index = 0;
@@ -1962,7 +1977,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
eachArrs();
};
//表格选中状态
// 表格选中状态
table.checkStatus = function(id){
var nums = 0
,invalidNum = 0
@@ -1985,7 +2000,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
};
};
//获取表格当前页的所有行数据
// 获取表格当前页的所有行数据
table.getData = function(id){
var arr = []
,data = table.cache[id] || [];
@@ -1998,7 +2013,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
return arr;
};
//表格导出
// 表格导出
table.exportFile = function(id, data, type){
data = data || table.clearCacheKey(table.cache[id]);
type = type || 'csv';
@@ -2075,7 +2090,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
document.body.removeChild(alink);
};
//重置表格尺寸结构
// 重置表格尺寸结构
table.resize = function(id){
//如果指定表格唯一 id则只执行该 id 对应的表格实例
if(id){
@@ -2121,13 +2136,13 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
return table.reload.apply(null, args);
};
//核心入口
// 核心入口
table.render = function(options){
var inst = new Class(options);
return thisTable.call(inst);
};
//清除临时Key
// 清除临时 Key
table.clearCacheKey = function(data){
data = $.extend({}, data);
delete data[table.config.checkName];
@@ -2135,7 +2150,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
return data;
};
//自动完成渲染
// 自动完成渲染
$(function(){
table.init();
});

View File

@@ -404,7 +404,7 @@ layui.define(['laytpl', 'form'], function(exports){
}, 0)
});
//双击记录
// 双击穿梭
that.elem.on('dblclick', '.' + ELEM_DATA + '>li', function(event){
var elemThis = $(this)
,thisElemCheckbox = elemThis.children('input[type="checkbox"]')
@@ -416,7 +416,7 @@ layui.define(['laytpl', 'form'], function(exports){
that.transfer(thisBoxElem.data('index'), elemThis);
})
//按钮事件
// 穿梭按钮事件
that.layBtn.on('click', function(){
var othis = $(this)
,_index = othis.data('index')