Skip to content

Commit

Permalink
Merge pull request layui#295 from nmxiaowei/master
Browse files Browse the repository at this point in the history
new atree
  • Loading branch information
贤心 authored Aug 18, 2018
2 parents 72253f6 + e67073c commit 5e30e00
Show file tree
Hide file tree
Showing 10 changed files with 652 additions and 16 deletions.
Empty file added HARD
Empty file.
24 changes: 24 additions & 0 deletions doc/atree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# atree2.0.0属性含义
* spreadAll 设置checkbox全部选中
* check勾选风格,不写没有勾选框
* props 设置key属性别名
- addBtnLabel:新增按钮标题
- deleteBtnLabel:删除按钮标题
- name:树显示的标题
- id:主键对应的字段名
- children:子类对应的字段名
- checkbox:选中对应的字段名
- spread:是否展开对应的字段名
* change选中回调函数
- val:选中的对象数组
* click点击标题回调函数
- item:当前点击的对象
* addClick:新增回调函数
- item:当前父节点的对象
- elem:当前节点的dom对象
- done:添加到dom节点的方法
* deleteClick:删除回调函数
- item:当前父节点的对象
- elem:当前节点的dom对象
- done:删除dom节点的方法

151 changes: 151 additions & 0 deletions examples/atree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>树模块 - layui</title>

<link rel="stylesheet" href="../src/css/layui.css">

<style>
body {
padding: 50px 100px;
}
</style>
</head>

<body>

<ul id="demo"></ul>

<script src="../src/layui.js"></script>
<script>
layui.use('atree', function() {
var tree = layui.atree({
elem: '#demo' //指定元素
,
check: 'checkbox' //勾选风格
,
skin: 'as' //设定皮肤
//,target: '_blank' //是否新选项卡打开(比如节点返回href才有效)
,
// drag: true,
spreadAll:true,
props:{
addBtnLabel:'新增',
deleteBtnLabel:'删除',
name: 'name',
id: 'id',
children:'children',
checkbox:'checkbox',
spread:'spread'
},
change:function(val){
console.group('change event')
console.log('Array')
console.log(val);
console.groupEnd()
},
click: function(item) { //点击节点回调
console.group('click event')
console.log('Object')
console.log(item);
console.groupEnd()
},
addClick:function(item,elem,add){
console.group('append event')
console.log('Object')
console.log(item);
console.log('dom')
console.log(elem);
console.log('dom add event')
var item ={
name: '测试节点'+new Date().getTime(),
id:-1
}
add(item)
console.groupEnd()
},
deleteClick:function(item,elem,done){
console.group('delete event')
console.log('Object')
console.log(item);
console.log('dom')
console.log(elem);
console.log('dom delete event')
done();
console.groupEnd()
},
nodes: [ //节点
{
name: '常用文件夹',
id: 1,
alias: 'changyong',
children: [{
name: '所有未读',
id: 11
//,href: 'http://www.layui.com/'
,
alias: 'weidu'
}, {
name: '置顶邮件',
id: 12
}, {
name: '标签邮件',
id: 13
}]
}, {
name: '我的邮箱',
id: 2,
spread: true,
children: [{
name: 'QQ邮箱',
id: 21,
spread: true,
children: [{
name: '收件箱',
id: 211,
spread: true,
children: [{
name: '所有未读',
checkbox:true,
id: 2111
}, {
name: '置顶邮件',
id: 2112
}, {
name: '标签邮件',
id: 2113
}]
}, {
name: '已发出的邮件',
id: 212
}, {
name: '垃圾邮件',
id: 213
}]
}, {
name: '阿里云邮',
id: 22,
children: [{
name: '收件箱',
id: 221
}, {
name: '已发出的邮件',
id: 222
}, {
name: '垃圾邮件',
id: 223
}]
}]
}
]
});

});
</script>

</body>

</html>
21 changes: 21 additions & 0 deletions src/css/layui.css
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,27 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
.layui-tree-drag{display: none; position: absolute; left: -666px; top: -666px; background-color: #f2f2f2; padding: 5px 10px; border: 1px dotted #000; white-space: nowrap}
.layui-tree-drag i{padding-right: 5px;}

/** atree **/
.layui-atree{line-height: 26px;}
.layui-atree li{position:relative;text-overflow: ellipsis; overflow:hidden; white-space: nowrap;}
.layui-atree li a,
.layui-atree li .layui-atree-spread{display: inline-block; vertical-align: top;font-size: 12px; height: 26px; *display: inline; *zoom:1; cursor: pointer;color: #c0c4cc}
.layui-atree li a{font-size: 0;}
.layui-atree li a i{font-size: 16px;}
.layui-atree li a cite{padding: 0 6px; font-size: 14px; font-style: normal;color: #606266;}
.layui-atree li i{padding-left: 6px; -moz-user-select: none;}
.layui-atree li .layui-atree-check{font-size: 16px;color: #dcdfe6}
.layui-atree li .layui-atree-check:hover{color: #409eff;}
.layui-atree li .layui-atree-check.is-checked{color: #409eff;}
.layui-atree li ul{ display:none;margin-left: 40px;}
.layui-atree li .layui-atree-enter{line-height: 24px; border: 1px dotted #000;}
.layui-atree-drag{display: none; position: absolute; left: -666px; top: -666px; background-color: #f2f2f2; padding: 5px 10px; border: 1px dotted #000; white-space: nowrap}
.layui-atree-drag i{padding-right: 5px;}
.layui-atree-node{position: relative;}
.layui-atree-node:hover { background-color:#eee;}
.layui-atree-menu{position: absolute;top:0;right: 0;z-index:1024;}
.layui-atree-menu span{margin-left: 10px;}

/** 导航菜单 **/
.layui-nav{position: relative; padding: 0 20px; background-color: #393D49; color: #fff; border-radius: 2px; font-size: 0; box-sizing: border-box;}
.layui-nav *{font-size: 14px;}
Expand Down
Binary file modified src/font/iconfont.eot
Binary file not shown.
Loading

0 comments on commit 5e30e00

Please sign in to comment.