Browse Source

新增 dropdown 对 `data` 的 `disabled` 属性支持

pull/1210/head
贤心 2 years ago
parent
commit
c968ab358d
  1. 2
      src/css/layui.css
  2. 5
      src/modules/dropdown.js

2
src/css/layui.css

@ -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,

5
src/modules/dropdown.js

@ -179,7 +179,7 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
if(isChild || type){
return ' class="'+ className[type] +'"';
}
return '';
return item.disabled ? ' class="'+ STR_DISABLED +'"' : '';
}() +'>'
//标题区
@ -273,7 +273,10 @@ 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 !== '-'){
var ret = typeof options.click === 'function' && options.click(data, othis);
ret === false || (isChild || that.remove());

Loading…
Cancel
Save