Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/modules/dropdown.js
#	src/modules/table.js
pull/1224/head
sunxiaobin89 2023-03-10 15:05:56 +08:00
commit 9c5c76879a
10 changed files with 92 additions and 94 deletions

2
dist/css/layui.css vendored

File diff suppressed because one or more lines are too long

2
dist/layui.js vendored

File diff suppressed because one or more lines are too long

View File

@ -167,10 +167,11 @@ layui.use('dropdown', function(){
var inst = dropdown.render({
elem: '#demo2'
//,show: true
// ,show: true
,data: [{
title: 'menu item 1'
,href: '#1'
,disabled: true
},{
title: 'menu item 2(点击不关闭)'
,href: '#2'
@ -185,6 +186,9 @@ layui.use('dropdown', function(){
return false;
}
}
,ready: function(){
console.log(arguments);
}
});

View File

@ -1,6 +1,6 @@
{
"name": "layui",
"version": "2.8.0-rc.10",
"version": "2.8.0-rc.11",
"description": "Classic modular Front-End UI library",
"main": "dist/layui.js",
"license": "MIT",

View File

@ -11,8 +11,8 @@ a:active,a:hover{outline:0}
img{display: inline-block; border: none; vertical-align: middle;}
li{list-style:none;}
table{border-collapse: collapse; border-spacing: 0;}
h1,h2,h3{font-weight: 400;}
h4, h5, h6{font-size: 100%; font-weight: 400;}
h1,h2,h3{font-weight: 700;}
h4,h5,h6{font-weight: 500; font-size: 100%;}
button,input,select,textarea{font-size: 100%; }
input,button,textarea,select,optgroup,option{font-family: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; outline: 0;}
pre{white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;}
@ -610,7 +610,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-text h3,
.layui-text h4,
.layui-text h5,
.layui-text h6{font-weight: 500; color: #3A3A3A;}
.layui-text h6{color: #3A3A3A;}
.layui-text h1{font-size: 32px;}
.layui-text h2{font-size: 24px;}
.layui-text h3{font-size: 18px;}
@ -1120,6 +1120,8 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
.layui-menu-body-title a{padding: 5px 15px; color: initial}
.layui-menu li{position: relative; margin: 1px 0; width: calc(100% + 1px); line-height: 26px; color: rgba(0,0,0,.8); font-size: 14px; white-space: nowrap; cursor: pointer; transition: all .3s;}
.layui-menu li:hover{background-color: #f8f8f8; }
.layui-menu li.layui-disabled,
.layui-menu li.layui-disabled *{background: none !important; color: #d2d2d2 !important; cursor: not-allowed !important;}
.layui-menu-item-parent:hover>.layui-menu-body-panel{display: block; animation-name: layui-fadein; animation-duration: 0.3s; animation-fill-mode: both; animation-delay:.2s;}
.layui-menu-item-parent .layui-menu-body-title,
@ -1259,10 +1261,10 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
/** Tab 选项卡 **/
.layui-tab{margin: 10px 0; text-align: left !important;}
.layui-tab[overflow]>.layui-tab-title{overflow: hidden;}
.layui-tab-title{position: relative; left: 0; height: 40px; white-space: nowrap; font-size: 0; border-bottom-width: 1px; border-bottom-style: solid; transition: all .2s; -webkit-transition: all .2s;}
.layui-tab-title li{display: inline-block; *display: inline; *zoom: 1; vertical-align: middle; font-size: 14px; transition: all .2s; -webkit-transition: all .2s;}
.layui-tab-title li{position: relative; line-height: 40px; min-width: 65px; padding: 0 15px; text-align: center; cursor: pointer;}
.layui-tab-title li a{display: block; padding: 0 15px; margin: 0 -15px;}
.layui-tab .layui-tab-title{position: relative; left: 0; height: 40px; padding-left: 0; white-space: nowrap; font-size: 0; border-bottom-width: 1px; border-bottom-style: solid; transition: all .2s; -webkit-transition: all .2s;}
.layui-tab .layui-tab-title li{display: inline-block; *display: inline; *zoom: 1; vertical-align: middle; font-size: 14px; transition: all .2s; -webkit-transition: all .2s;}
.layui-tab .layui-tab-title li{position: relative; line-height: 40px; min-width: 65px; margin: 0; padding: 0 15px; text-align: center; cursor: pointer;}
.layui-tab .layui-tab-title li a{display: block; padding: 0 15px; margin: 0 -15px;}
.layui-tab-title .layui-this{color: #000;}
.layui-tab-title .layui-this:after{position: absolute; left:0; top: 0; content: ""; width:100%; height: 41px; border-width: 1px; border-style: solid; border-bottom-color: #fff; border-radius: 2px 2px 0 0; box-sizing: border-box; pointer-events: none;}

View File

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

View File

@ -48,9 +48,6 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
,reload: function(options){
that.reload.call(that, options);
}
,reloadData: function(options){
dropdown.reloadData(id, options);
}
,close: function () {
that.remove()
}
@ -86,14 +83,14 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
};
//重载实例
Class.prototype.reload = function(options, type){
Class.prototype.reload = function(options){
var that = this;
that.config = $.extend({}, that.config, options);
that.init(true, type);
that.init(true);
};
//初始化准备
Class.prototype.init = function(rerender, type){
Class.prototype.init = function(rerender){
var that = this
,options = that.config
,elem = options.elem = $(options.elem);
@ -113,18 +110,18 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
var newThat = thisModule.getThis(elem.data(MOD_INDEX));
if(!newThat) return;
return newThat.reload(options, type);
return newThat.reload(options);
}
//初始化 id 参数
options.id = ('id' in options) ? options.id : that.index;
if(options.show) that.render(rerender, type); //初始即显示
if(options.show) that.render(rerender); //初始即显示
that.events(); //事件
};
//渲染
Class.prototype.render = function(rerender, type){
Class.prototype.render = function(rerender){
var that = this
,options = that.config
,elemBody = $('body')
@ -239,41 +236,27 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
//判断是否已经打开了下拉菜单面板
if(!rerender && options.elem.data(MOD_INDEX +'_opened')) return;
//记录模板对象
that.elemView = $(TPL_MAIN);
that.elemView.append(options.content || getDefaultView());
//初始化某些属性
if(options.className) that.elemView.addClass(options.className);
if(options.style) that.elemView.attr('style', options.style);
//记录当前执行的实例索引
dropdown.thisId = options.id;
//插入视图
that.remove(); //移除非当前绑定元素的面板
elemBody.append(that.elemView);
options.elem.data(MOD_INDEX +'_opened', true);
//记录模板对象
that.elemView = $('.' + STR_ELEM + '[lay-id="' + options.id + '"]');
if (type === 'reloadData' && that.elemView.length) {
that.elemView.html(options.content || getDefaultView());
} else {
that.elemView = $(TPL_MAIN).attr('lay-id', options.id);
that.elemView.append(options.content || getDefaultView());
//初始化某些属性
if(options.className) that.elemView.addClass(options.className);
if(options.style) that.elemView.attr('style', options.style);
//插入视图
that.remove(); //移除非当前绑定元素的面板
elemBody.append(that.elemView);
options.elem.data(MOD_INDEX +'_opened', true);
//遮罩
var shade = options.shade ? ('<div class="'+ STR_ELEM_SHADE +'" style="'+ ('z-index:'+ (that.elemView.css('z-index')-1) +'; background-color: ' + (options.shade[1] || '#000') + '; opacity: ' + (options.shade[0] || options.shade)) +'"></div>') : '';
that.elemView.before(shade);
//如果是鼠标移入事件,则鼠标移出时自动关闭
if(options.trigger === 'mouseenter'){
that.elemView.on('mouseenter', function(){
clearTimeout(thisModule.timer);
}).on('mouseleave', function(){
that.delayRemove();
});
}
}
//遮罩
var shade = options.shade ? ('<div class="'+ STR_ELEM_SHADE +'" style="'+ ('z-index:'+ (that.elemView.css('z-index')-1) +'; background-color: ' + (options.shade[1] || '#000') + '; opacity: ' + (options.shade[0] || options.shade)) +'"></div>') : '';
that.elemView.before(shade);
//坐标定位
that.position();
thisModule.prevElem = that.elemView; //记录当前打开的元素,以便在下次关闭
@ -290,8 +273,11 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
var data = othis.data('item') || {};
var isChild = data.child && data.child.length > 0;
var isClickAllScope = options.clickScope === 'all'; // 是否所有父子菜单均触发点击事件
if(data.disabled) return; // 菜单项禁用状态
if((!isChild || isClickAllScope) && data.type !== '-' && !data.disabled){
// 普通菜单项点击后的回调及关闭面板
if((!isChild || isClickAllScope) && data.type !== '-'){
var ret = typeof options.click === 'function' && options.click(data, othis);
ret === false || (isChild || that.remove());
layui.stope(e);
@ -308,9 +294,21 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
thisModule.spread(elemGroup);
}
});
//如果是鼠标移入事件,则鼠标移出时自动关闭
if(options.trigger === 'mouseenter'){
that.elemView.on('mouseenter', function(){
clearTimeout(thisModule.timer);
}).on('mouseleave', function(){
that.delayRemove();
});
}
//组件打开完毕的事件
typeof options.ready === 'function' && options.ready(that.elemView, options.elem);
// 组件打开完毕的事件
typeof options.ready === 'function' && options.ready(
that.elemView,
options.elem
);
};
//位置定位
@ -475,6 +473,8 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
parent.find('.'+ STR_ITEM_CHECKED2).removeClass(STR_ITEM_CHECKED2); //清除父级菜单选中样式
othis.addClass(STR_ITEM_CHECKED); //添加选中样式
othis.parents('.'+ STR_ITEM_PARENT).addClass(STR_ITEM_CHECKED2); //添加父级菜单选中样式
options.title = options.title || $.trim(othis.children('.'+ STR_MENU_TITLE).text());
//触发事件
layui.event.call(this, MOD_NAME, 'click('+ filter +')', options);
@ -526,34 +526,14 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
}();
//重载实例
dropdown.reload = function(id, options, type){
dropdown.reload = function(id, options){
var that = thisModule.getThis(id);
if(!that) return this;
that.reload(options, type);
that.reload(options);
return thisModule.call(that);
};
// 仅重载数据
dropdown.reloadData = function(){
var args = $.extend([], arguments);
args[2] = 'reloadData';
// 重载时,与数据相关的参数
var dataParams = new RegExp('^('+ [
'data', 'templet', 'content', 'show'
].join('|') + ')$');
// 过滤与数据无关的参数
layui.each(args[1], function (key, value) {
if(!dataParams.test(key)){
delete args[1][key];
}
});
return dropdown.reload.apply(null, args);
};
//核心入口
dropdown.render = function(options){
var inst = new Class(options);

View File

@ -110,17 +110,25 @@ layui.define('jquery', function(exports){
// 基础事件体
var call = {
//Tab 点击
// Tab 点击
tabClick: function(e, index, liElem, options){
options = options || {};
var othis = liElem || $(this)
,index = index || othis.parent().children('li').index(othis)
,parents = options.headerElem ? othis.parent() : othis.parents('.layui-tab').eq(0)
,item = options.bodyElem ? $(options.bodyElem) : parents.children('.layui-tab-content').children('.layui-tab-item')
,elemA = othis.find('a')
,isJump = elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank' //是否存在跳转
,unselect = typeof othis.attr('lay-unselect') === 'string' //是否禁用选中
,filter = parents.attr('lay-filter');
var othis = liElem || $(this);
var parents = options.headerElem
? othis.parent()
: othis.parents('.layui-tab').eq(0);
var item = options.bodyElem
? $(options.bodyElem)
: parents.children('.layui-tab-content').children('.layui-tab-item');
var elemA = othis.find('a');
var isJump = elemA.attr('href') !== 'javascript:;' && elemA.attr('target') === '_blank'; //是否存在跳转
var unselect = typeof othis.attr('lay-unselect') === 'string'; //是否禁用选中
var filter = parents.attr('lay-filter');
// 下标
index = index === undefined
? othis.parent().children('li').index(othis)
: index;
//执行切换
if(!(isJump || unselect)){
@ -177,8 +185,8 @@ layui.define('jquery', function(exports){
call.hideTabMore(true)
}
//允许关闭
if(othis.attr('lay-allowClose')){
// 开启关闭图标
if(othis.attr('lay-allowclose')){
title.find('li').each(function(){
var li = $(this);
if(!li.find('.'+CLOSE)[0]){
@ -465,7 +473,7 @@ layui.define('jquery', function(exports){
: percent;
});
if(othis.attr('lay-showPercent')){
if(othis.attr('lay-showpercent')){
setTimeout(function(){
elemBar.html('<span class="'+ ELEM +'-text">'+ percent +'</span>');
},350);

View File

@ -988,8 +988,12 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
});
} else if(layui.type(options.data) === 'array'){ //已知数据
var res = {};
var startLimit = curr*options.limit - options.limit;
var newData = options.data.concat();
res[response.dataName] = options.page ? options.data.concat().splice(curr*options.limit - options.limit, options.limit) : options.data.concat();
res[response.dataName] = options.page
? newData.splice(startLimit, options.limit)
: newData;
res[response.countName] = options.data.length;
//记录合计行数据

View File

@ -20,8 +20,8 @@ layui.define('jquery', function(exports){
target: 'body', // fixbar 的插入目标选择器
bars: [], // bar 信息
default: true, // 是否显示默认 bar
showHeight: 200, // 出现 top bar 的滚动条高度临界值
duration: 200 // top bar 等动画时长(毫秒)
margin: 160, // 出现 top bar 的滚动条高度临界值
duration: 320 // top bar 等动画时长(毫秒)
}, options);
// 目标元素对象
@ -113,7 +113,7 @@ layui.define('jquery', function(exports){
var lock;
var setTopBar = (function setTopBar(){
var top = $scroll.scrollTop();
if(top >= options.showHeight){
if(top >= options.margin){
lock || (elemTopBar.show(), lock = 1);
} else {
lock && (elemTopBar.hide(), lock = 0);