From cf2531947c5b49ff84f7c61f7526eb040c5213ba 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, 26 Aug 2022 23:26:17 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20dropdown=20=E7=9A=84?=
=?UTF-8?q?=20clickScope=20=E5=B1=9E=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
examples/dropdown.html | 5 ++++-
src/modules/dropdown.js | 12 +++++++-----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/examples/dropdown.html b/examples/dropdown.html
index 51bd13b2..18203d6b 100644
--- a/examples/dropdown.html
+++ b/examples/dropdown.html
@@ -155,7 +155,10 @@ layui.use('dropdown', function(){
,id: 'demo1'
- //菜单被点击的事件
+ // 触发点击事件的元素范围 --- default: 仅子菜单触发点击事件(默认,可不填); all: 所有父子菜单均触发点击事件
+ ,clickScope: 'all'
+
+ // 菜单被点击的事件
,click: function(obj){
console.log(obj);
}
diff --git a/src/modules/dropdown.js b/src/modules/dropdown.js
index bfaf1a12..7587f0e1 100644
--- a/src/modules/dropdown.js
+++ b/src/modules/dropdown.js
@@ -261,13 +261,15 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
//触发菜单列表事件
that.elemView.find('.layui-menu li').on('click', function(e){
- var othis = $(this)
- ,data = othis.data('item') || {}
- ,isChild = data.child && data.child.length > 0;
+ var othis = $(this);
+ var data = othis.data('item') || {};
+ var isChild = data.child && data.child.length > 0;
+ var isClickAllScope = options.clickScope === 'all'; // 是否所有父子菜单均触发点击事件
- if(!isChild && data.type !== '-'){
- that.remove();
+ if((!isChild || isClickAllScope) && data.type !== '-'){
+ isChild || that.remove();
typeof options.click === 'function' && options.click(data, othis);
+ layui.stope(e);
}
});
From f5dfdb17c81f7fe9e75cd272cabe0435c6893837 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?=
<3277200+sentsim@users.noreply.github.com>
Date: Mon, 29 Aug 2022 01:13:34 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20element=20progress=20?=
=?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=A4=BA=E4=BE=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
examples/element.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/element.html b/examples/element.html
index 46793865..21b0197f 100644
--- a/examples/element.html
+++ b/examples/element.html
@@ -93,7 +93,7 @@ body{padding:20px;}
-
+
From a23754e2ce0e26699e64931bb09b86a359ed2651 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?=
<3277200+sentsim@users.noreply.github.com>
Date: Mon, 29 Aug 2022 01:14:26 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20`element.progress()`?=
=?UTF-8?q?=20=E6=96=B9=E6=B3=95=E4=B8=8D=E6=94=AF=E6=8C=81=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E5=88=86=E6=95=B0=E5=80=BC=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/modules/element.js | 51 +++++++++++++++++++++++++-----------------
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/src/modules/element.js b/src/modules/element.js
index c5c77f94..c6ff3678 100644
--- a/src/modules/element.js
+++ b/src/modules/element.js
@@ -1,18 +1,18 @@
/**
- * element 常用元素操作
- * MIT Licensed
+ * element
+ * 常用元素操作组件
*/
layui.define('jquery', function(exports){
- "use strict";
+ 'use strict';
- var $ = layui.$
- ,hint = layui.hint()
- ,device = layui.device()
+ var $ = layui.$;
+ var hint = layui.hint();
+ var device = layui.device();
- ,MOD_NAME = 'element', THIS = 'layui-this', SHOW = 'layui-show'
+ var MOD_NAME = 'element', THIS = 'layui-this', SHOW = 'layui-show';
- ,Element = function(){
+ var Element = function(){
this.config = {};
};
@@ -82,23 +82,34 @@ layui.define('jquery', function(exports){
};
- //动态改变进度条
+ // 动态改变进度条
Element.prototype.progress = function(filter, percent){
- var ELEM = 'layui-progress'
- ,elem = $('.'+ ELEM +'[lay-filter='+ filter +']')
- ,elemBar = elem.find('.'+ ELEM +'-bar')
- ,text = elemBar.find('.'+ ELEM +'-text');
- elemBar.css('width', percent).attr('lay-percent', percent);
+ var ELEM = 'layui-progress';
+ var elem = $('.'+ ELEM +'[lay-filter='+ filter +']');
+ var elemBar = elem.find('.'+ ELEM +'-bar');
+ var text = elemBar.find('.'+ ELEM +'-text');
+
+ elemBar.css('width', function(){
+ return /^.+\/.+$/.test(percent)
+ ? (new Function('return '+ percent)() * 100) + '%'
+ : percent;
+ }).attr('lay-percent', percent);
text.text(percent);
return this;
};
- var NAV_ELEM = '.layui-nav', NAV_ITEM = 'layui-nav-item', NAV_BAR = 'layui-nav-bar'
- ,NAV_TREE = 'layui-nav-tree', NAV_CHILD = 'layui-nav-child', NAV_CHILD_C = 'layui-nav-child-c'
- ,NAV_MORE = 'layui-nav-more', NAV_DOWN = 'layui-icon-down', NAV_ANIM = 'layui-anim layui-anim-upbit'
+ var NAV_ELEM = '.layui-nav';
+ var NAV_ITEM = 'layui-nav-item';
+ var NAV_BAR = 'layui-nav-bar';
+ var NAV_TREE = 'layui-nav-tree';
+ var NAV_CHILD = 'layui-nav-child';
+ var NAV_CHILD_C = 'layui-nav-child-c';
+ var NAV_MORE = 'layui-nav-more';
+ var NAV_DOWN = 'layui-icon-down';
+ var NAV_ANIM = 'layui-anim layui-anim-upbit';
- //基础事件体
- ,call = {
+ // 基础事件体
+ var call = {
//Tab 点击
tabClick: function(e, index, liElem, options){
options = options || {};
@@ -452,7 +463,7 @@ layui.define('jquery', function(exports){
return /^.+\/.+$/.test(percent)
? (new Function('return '+ percent)() * 100) + '%'
: percent;
- }());
+ });
if(othis.attr('lay-showPercent')){
setTimeout(function(){
From 7b9aa2cdc2f7878c891cc94a4eef08fb15c42ff4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?=
<3277200+sentsim@users.noreply.github.com>
Date: Mon, 29 Aug 2022 12:30:46 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E9=87=8D=E6=9E=84=20util.fixbar=20?=
=?UTF-8?q?=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
examples/util.html | 52 ++++++++++++---
src/modules/util.js | 150 ++++++++++++++++++++++++++++++--------------
2 files changed, 147 insertions(+), 55 deletions(-)
diff --git a/examples/util.html b/examples/util.html
index fa002ffa..72a39389 100644
--- a/examples/util.html
+++ b/examples/util.html
@@ -3,7 +3,7 @@
-
工具集 - layui
+
util 组件 - layui
@@ -31,19 +31,53 @@ body{padding: 50px;}
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
+
+