From a03b4d6c24036b14a48811c76101c23f5ab5e0c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:26:07 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20util=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/util.html | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/util.html b/examples/util.html index f1d1d0aa..739369bc 100644 --- a/examples/util.html +++ b/examples/util.html @@ -16,7 +16,8 @@ body{padding: 50px;} - + +

@@ -108,7 +109,7 @@ layui.use(['lay', 'util', 'layer'], function(){ } }); - // 事件集的替换和增加 + // Test: 事件集的替换和增加 util.on({ e1: function(othis){ // 重置事件 e1 alert(othis.html() + ' - replace') @@ -121,8 +122,19 @@ layui.use(['lay', 'util', 'layer'], function(){ // 自定义触发事件的元素属性名、自定义触发事件的方式 util.on('lay-active', { e4: layui.throttle(function(othis) { - layer.tips(othis.html(), this); - }, 3000) // 3s 内不重复执行 + layer.tips(othis.html(), this, { tips: 3 }); + }, 3000), // 3s 内不重复执行 + e5: function() { + console.log(111); + } + }, { + trigger: 'mouseenter' + }); + // Test: 不同属性、相同值 + util.on('lay-active1', { + e4: function(othis) { + this.innerHTML = 'hover: '+ (Math.random()*100000 | 0); + } }, { trigger: 'mouseenter' }); From 3b781390feec3a6dd060ead4933d1fd7b0edecc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Thu, 7 Dec 2023 09:26:38 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=20`util.on()`=20?= =?UTF-8?q?=E5=9C=A8=E7=89=B9=E6=AE=8A=E6=83=85=E5=86=B5=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E7=94=A8=E6=B3=95=E9=97=AE=E9=A2=98=20Closes:=20https://gitee.?= =?UTF-8?q?com/layui/layui/issues/I8M528?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/util.js b/src/modules/util.js index ed5c88ab..cc628ee2 100644 --- a/src/modules/util.js +++ b/src/modules/util.js @@ -427,7 +427,7 @@ layui.define('jquery', function(exports){ var callbacks = dataCache.callbacks; // 根据 attr 记录事件集合 - events = $.extend(true, dataCache.events, events) || {}; + events = dataCache.events[attr] = $.extend(true, dataCache.events[attr], events); // 清除事件委托,避免重复绑定 elem.off(options.trigger, attrSelector, callbacks[attr]); From a03cd0b8da337a4683f1bd871b9b62a7bab1c4cd Mon Sep 17 00:00:00 2001 From: morning-star <1453017105@qq.com> Date: Thu, 7 Dec 2023 22:45:08 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BC=98=E5=8C=96=20layer.tips=20=E5=9C=A8?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E5=85=83=E7=B4=A0=E9=AB=98=E5=BA=A6=E8=BE=83?= =?UTF-8?q?=E5=B0=8F=E6=97=B6=E7=9A=84=E5=AE=9A=E4=BD=8D=20(#1439)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close https://gitee.com/layui/layui/issues/I8KZ9A --- src/modules/layer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/layer.js b/src/modules/layer.js index f5007fc2..af139b60 100644 --- a/src/modules/layer.js +++ b/src/modules/layer.js @@ -671,13 +671,15 @@ Class.pt.tips = function(){ }; // 辨别 tips 的方位 + // 21 为箭头大小 8*2 + 箭头相对父元素的top偏移 5 goal.where = [function(){ // 上 goal.autoLeft(); goal.tipTop = goal.top - layArea[1] - 10; tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]); }, function(){ // 右 goal.tipLeft = goal.left + goal.width + 10; - goal.tipTop = goal.top; + goal.tipTop = goal.top - (goal.height * 0.75 < 21 ? 21 - goal.height * 0.5 : 0); + goal.tipTop = Math.max(goal.tipTop, 0); tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]); }, function(){ // 下 goal.autoLeft(); @@ -685,7 +687,8 @@ Class.pt.tips = function(){ tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]); }, function(){ // 左 goal.tipLeft = goal.left - layArea[0] - 10; - goal.tipTop = goal.top; + goal.tipTop = goal.top - (goal.height * 0.75 < 21 ? 21 - goal.height * 0.5 : 0); + goal.tipTop = Math.max(goal.tipTop, 0); tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]); }]; goal.where[guide-1](); From 8f0c87f95d057d307ed6433c9ffaab92b51e2f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Fri, 8 Dec 2023 00:00:53 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20layer=20=E7=9A=84=20if?= =?UTF-8?q?rame=20=E5=B1=82=E5=9C=A8=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E5=87=BA=E7=8E=B0=E5=BC=82=E5=B8=B8=E7=BA=B5=E5=90=91?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/modules/layer.css | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/css/modules/layer.css b/src/css/modules/layer.css index 937ae235..fe48e817 100644 --- a/src/css/modules/layer.css +++ b/src/css/modules/layer.css @@ -260,7 +260,6 @@ html #layuicss-layer{display: none; position: absolute; width: 1989px;} .layui-layer-photos-footer a:hover{text-decoration: underline;} .layui-layer-photos-footer em{font-style: normal;} - /* 关闭动画 */ @-webkit-keyframes layer-bounceOut { 100% {opacity: 0; -webkit-transform: scale(.7); transform: scale(.7)} @@ -273,9 +272,3 @@ html #layuicss-layer{display: none; position: absolute; width: 1989px;} 0% {-webkit-transform: scale(1); -ms-transform: scale(1);transform: scale(1);} } .layer-anim-close{-webkit-animation-name: layer-bounceOut; animation-name: layer-bounceOut; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.2s; animation-duration:.2s;} - -@media screen and (max-width: 1100px) { - .layui-layer-iframe{overflow-y: auto; -webkit-overflow-scrolling: touch;} -} - - From 4edebe878dd2e71fd9b3621d29e6786f9cd3e127 Mon Sep 17 00:00:00 2001 From: morning-star Date: Fri, 8 Dec 2023 22:21:39 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20element.nav=20?= =?UTF-8?q?=E5=9C=A8=20IE8=20=E4=B8=8B=E5=AD=90=E8=8F=9C=E5=8D=95=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E8=89=B2=20(#1445)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复 element.nav 在 IE8 下子菜单背景色 --- src/css/layui.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/css/layui.css b/src/css/layui.css index 9f552896..0c8202e0 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -1319,7 +1319,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh .layui-nav-itemed>a{color: #fff !important;} .layui-nav-tree .layui-nav-bar{background-color: #16baaa;} -.layui-nav-tree .layui-nav-child{position: relative; z-index: 0; top: 0; border: none; background-color: rgba(0,0,0,.3); box-shadow: none;} +.layui-nav-tree .layui-nav-child{position: relative; z-index: 0; top: 0; border: none; background: none; background-color: rgba(0,0,0,.3); box-shadow: none;} .layui-nav-tree .layui-nav-child dd{margin: 0;} .layui-nav-tree .layui-nav-child a{color: #fff; color: rgba(255,255,255,.7);} .layui-nav-tree .layui-nav-child a:hover{background: none; color: #fff;} From 3f148a9086465859e46340ef3af8745a07325a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 9 Dec 2023 12:55:02 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20`treeTable.reloadData(?= =?UTF-8?q?)`=20=E5=9C=A8=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=20Closes:=20https?= =?UTF-8?q?://gitee.com/layui/layui/issues/I8M5HS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 016cecd1..d8d3ad91 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -93,7 +93,7 @@ layui.define(['table'], function (exports) { var updateCache = function (id, childrenKey, data) { var tableCache = table.cache[id]; layui.each(data || tableCache, function (index, item) { - var itemDataIndex = item[LAY_DATA_INDEX]; + var itemDataIndex = item[LAY_DATA_INDEX] || ''; if (itemDataIndex.indexOf('-') !== -1) { tableCache[itemDataIndex] = item } From 780cd72ee2be0d89e3ab6772ad80bec92682f046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 9 Dec 2023 12:55:27 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20table=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/table-test.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/table-test.html b/examples/table-test.html index 2772f388..9941be3b 100644 --- a/examples/table-test.html +++ b/examples/table-test.html @@ -222,13 +222,22 @@ layui.use(['table', 'dropdown'], function(){ },{ id: 'unchecked', title: '取消选中某行' + },{ + id: 'mult-checked', + title: '同时选中多个' },{ id: 'reset-checked', title: '给选中行取消选中状态' }], // 菜单被点击的事件 - click: function(obj){ - if(obj.id === 'reset-checked'){ + click: function(obj) { + if (obj.id === 'mult-checked') { + // 同时选中多个 + table.setRowChecked(id, { + index: [3, 4, 5], // 2.9.1+ + checked: true + }); + } else if(obj.id === 'reset-checked') { // 给选中行取消选中状态 table.setRowChecked(id, { index: 'all', From 7c12ddfdf3e5e44b29bbd1fc4159973bddef0c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sat, 9 Dec 2023 13:04:01 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=20`table.setRowChecked()?= =?UTF-8?q?`=20=E6=96=B9=E6=B3=95=EF=BC=8C=E6=94=AF=E6=8C=81=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 10a3b6c1..652cad36 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1560,10 +1560,16 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ Class.prototype.setRowChecked = function(opts){ var that = this; var options = that.config; - var isCheckAll = opts.index === 'all'; - var tr = that.layBody.find('tr'+ ( - isCheckAll ? '' : '[data-index="'+ opts.index +'"]' - )); + var isCheckAll = opts.index === 'all'; // 是否操作全部 + var isCheckMult = layui.type(opts.index) === 'array'; // 是否操作多个 + + // 匹配行元素 + var tr = function(tr) { + return isCheckAll ? tr : tr.filter(isCheckMult ? function() { + var dataIndex = $(this).data('index'); + return opts.index.indexOf(dataIndex) !== -1; + } : '[data-index="'+ opts.index +'"]'); + }(that.layBody.find('tr')); // 默认属性 opts = $.extend({ @@ -1573,18 +1579,31 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ // 同步数据选中属性值 var thisData = table.cache[that.key]; var existChecked = 'checked' in opts; + + // 若为单选框,则单向选中;若为复选框,则切换选中。 var getChecked = function(value){ - // 若为单选框,则单向选中;若为复选框,则切换选中。 return opts.type === 'radio' ? true : (existChecked ? opts.checked : !value) }; - // 设置数据选中属性 + // 设置选中状态 layui.each(thisData, function(i, item){ - if(layui.type(item) === 'array' || item[options.disabledName]) return; // 空项 - if(Number(opts.index) === i || isCheckAll){ + // 绕过空项和禁用项 + if(layui.type(item) === 'array' || item[options.disabledName]) return; + + // 匹配条件 + var matched = isCheckAll || ( + isCheckMult ? opts.index.indexOf(i) !== -1 : Number(opts.index) === i + ); + + // 设置匹配项的选中值 + if(matched){ + // 标记数据选中状态 var checked = item[options.checkName] = getChecked(item[options.checkName]); - var currTr = isCheckAll ? tr.filter('[data-index="'+ i +'"]') : tr; - currTr[checked ? 'addClass' : 'removeClass'](ELEM_CHECKED); // 标记当前选中行背景色 + + // 标记当前行背景色 + var currTr = tr.filter('[data-index="'+ i +'"]'); + currTr[checked ? 'addClass' : 'removeClass'](ELEM_CHECKED); + // 若为 radio 类型,则取消其他行选中背景色 if(opts.type === 'radio'){ currTr.siblings().removeClass(ELEM_CHECKED);