Skip to content

Commit

Permalink
Merge pull request #1290 from layui/revert-1289-revert-1287-2.x
Browse files Browse the repository at this point in the history
恢复 #1287
  • Loading branch information
sentsim committed Jun 20, 2023
2 parents 489b849 + ddbf760 commit bf5fa9d
Show file tree
Hide file tree
Showing 15 changed files with 227 additions and 114 deletions.
2 changes: 1 addition & 1 deletion dist/css/layui.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/layui.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/layer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ layer.prompt({
| 私有属性 | 描述 | 类型 | 默认值 |
| --- | --- | --- | --- |
| photos | 图片层的数据源,格式详见下述示例。 | object | - |
| hideFooter <sup>2.8+</sup> | 是否隐藏底部栏 | boolean | `false` |
| tab | 图片层切换后的回调函数,返回的参数见下述示例 | function | - |

该方法用于弹出图片层,基于 `type: 1`(即 `page` 层)的自定义内容。
Expand Down
15 changes: 13 additions & 2 deletions docs/table/examples/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ layui.use(['table', 'dropdown'], function(){
{type: 'checkbox', fixed: 'left'},
{field:'id', fixed: 'left', width:80, title: 'ID', sort: true, totalRowText: '合计:'},
{field:'username', width:80, title: '用户'},
{field:'email', title:'邮箱 <i class="layui-icon layui-icon-tips layui-font-14" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '邮箱', hide: 0, width:150, edit: 'text'},
{field:'email', title:'邮箱 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '邮箱', hide: 0, width:150, edit: 'text'},
{field:'sex', width:80, title: '性别', sort: true},
{field:'city', width:115, title: '城市', minWidth:115, templet: '#cityTpl', exportTemplet: function(d, obj){
// console.log(obj)
Expand Down Expand Up @@ -285,7 +285,18 @@ layui.use(['table', 'dropdown'], function(){
break;
};
});


// 表头自定义元素工具事件 --- 2.8.8+
table.on('colTool(test)', function(obj){
var event = obj.event;
console.log(obj);
if(event === 'email-tips'){
layer.alert(layui.util.escape(JSON.stringify(obj.col)), {
title: '当前列属性配置项'
});
}
});

// 触发单元格工具事件
table.on('tool(test)', function(obj){ // 双击 toolDouble
var data = obj.data; // 获得当前行数据
Expand Down
31 changes: 30 additions & 1 deletion docs/table/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ table.hideCol('test', false); // `true` or `false`
| event | 描述 |
| --- | --- |
| [toolbar](#on-toolbar) | 头部工具栏事件 |
| [sort](#on-sort) | 排序切换事件 |
| [sort](#on-sort) | 表头排序切换事件 |
| [colTool](#on-colTool) <sup>2.8.8+</sup> | 表头自定义元素工具事件 |
| [colResized](#on-colResized) <sup>2.8+</sup> | 列拖拽宽度后的事件 |
| [colToggled](#on-colToggled) <sup>2.8+</sup> | 列筛选(显示或隐藏)后的事件 |
| [row / rowDouble](#on-row) | 行单击和双击事件 |
Expand Down Expand Up @@ -632,6 +633,32 @@ table.on('sort(test)', function(obj){
});
```

<h3 id="on-colTool" lay-pid="table.on" class="ws-anchor ws-bold">表头自定义元素工具事件 <sup>2.8.8+</sup></h3>

`table.on('colTool(filter)', callback);`

点击表头单元格中带有 `lay-event` 属性的自定义元素触发,可充分借助该事件扩展 table 更多的操作空间。

```js
var table = layui.table;

// 渲染
table.render({
elem: '#test',
cols: [[
{field:'username', title:'用户名 <i class="layui-icon layui-icon-username" lay-event="username"></i>'
]]
// … // 其他属性
});

// 列拖拽宽度后的事件
table.on('colTool(test)', function(obj){
var col = obj.col; // 获取当前列属性配置项
var options = obj.config; // 获取当前表格基础属性配置项
var layEvent = obj.event; // 获得自定义元素对应的 lay-event 属性值
console.log(obj); // 查看对象所有成员
});
```
<h3 id="on-colResized" lay-pid="table.on" class="ws-anchor ws-bold">列拖拽宽度后的事件 <sup>2.8+</sup></h3>
Expand Down Expand Up @@ -700,6 +727,7 @@ table.render({
// 行单击事件
table.on('row(test)', function(obj){
var data = obj.data; // 得到当前行数据
var dataCache = obj.dataCache; // 得到当前行缓存数据,包含特定字段 --- 2.8.8+
var index = obj.index; // 得到当前行索引
var tr = obj.tr; // 得到当前行 <tr> 元素的 jQuery 对象
var options = obj.config; // 获取当前表格基础属性配置项
Expand Down Expand Up @@ -804,6 +832,7 @@ layui.use(function(){
// 单元格工具事件
table.on('tool(test)', function(obj){
var data = obj.data; // 得到当前行数据
var dataCache = obj.dataCache; // 得到当前行缓存数据,包含特定字段 --- 2.8.8+
var index = obj.index; // 得到当前行索引
var layEvent = obj.event; // 获得元素对应的 lay-event 属性值
var tr = obj.tr; // 得到当前行 <tr> 元素的 jQuery 对象
Expand Down
14 changes: 14 additions & 0 deletions docs/upload/detail/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,20 @@ acceptMime: 'image/jpeg, image/png` // 只筛选 jpg,png 格式图片

`false`

</td>
</tr>
<tr>
<td>unified <sup>2.8.8+</sup></td>
<td>

选择多文件时,是否统一上传,即只发送一次请求。

</td>
<td>boolean</td>
<td>

`false`

</td>
</tr>
<tr>
Expand Down
31 changes: 26 additions & 5 deletions docs/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,46 @@ toc: true
> 导读:📑 [Layui 2.8 《升级指南》](/notes/2.8/upgrade-guide.html) · 📑 [Layui 新版文档站上线初衷](/notes/2.8/news.html)

<h2 id="2.8.8" class="ws-anchor">
2.8.8
<span class="layui-badge-rim">2023-06-20</span>
</h2>

- #### form
- 新增 `input` 获取焦点时的光环效果,以提升当前活动输入框的辨别度
- 取消 上个版本对 `select` 开启搜索时 `value` 的改动,由于存在若干不可控的影响
- #### table
- 新增 `colTool` 事件,点击表头自定义元素触发,并返回当前列的相关信息,提升 table 的可玩性
- 新增 `row,tool,checkbox,radio` 事件返回的 `dataCache` 属性,可获得当前行缓存数据,包含特定字段
- #### upload
- 新增 `unified` 属性,用于选择多文件时是否统一上传,即只发送一次请求 # I6Z171
- #### 其他
- 优化 `layui.js,layer.js` 部分代码细节 # 1285

### 下载: [layui-v2.8.8.zip](https://gitee.com/layui/layui/attach_files/1444527/download)

---

<h2 id="2.8.7" class="ws-anchor">
2.8.7
<span class="layui-badge-rim">2023-06-16</span>
</h2>

#### form
- 优化 `select` 开启搜索时输入状态,将值转义到 `placeholder`,便于输入 # 1280
#### table
- #### form
- ~~优化 `select` 开启搜索时输入状态,将值转移到 `placeholder`,便于输入~~ # 1280
<br>*注:由于存在若干影响,该项功能已在 `2.8.8` 中取消*
- #### table
- 新增 表头复选框的半选效果,当数据项部分选中且未全选时显示
- 优化 `table.setRowChecked()` 方法,新增当前行选中背景色,便于与 hover 等活动背景色区分
- 剔除 `table.setRowChecked()` 方法中的 `selectedStyle` 属性,因为没有实质意义
- 优化 表头部分字段为 `hide` 在数据异常的情况下可能出现的表头错位的问题 # 1281
- 优化 `done` 回调函数,新增参数 `origin` 用于区分重载和重新渲染数据 # 1281
- 加强 `ignoreExport` 表头属性,允许指定不排除哪些字段 # 1281
#### treeTable
- #### treeTable
- 新增 `view.expandAllDefault` 属性,用于设置是否默认展开全部节点 # 1281
- 修复 开启排序且在 `done` 回调中执行了 `expandAll` 展开全部导致死循环问题 # 1281
- 修复 执行 `treeTable.reload(id)``id` 未匹配到对应实例时出现的报错问题 # 1281/I7CXLN
#### grid
- #### grid
- 修复 space30 和 space32 边距相同的问题 # I7D7YP

### 下载: [layui-v2.8.7.zip](https://gitee.com/layui/layui/attach_files/1441026/download)
Expand Down
13 changes: 9 additions & 4 deletions examples/table-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@
{type: 'checkbox', fixed: 'left'}
//,{type: 'numbers', fixed: 'left'}
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
,{field:'username', title:'用户名', width:120, edit: function(d){
,{field:'username', title:'用户名 <i class="layui-icon layui-icon-username" lay-event="username"></i>', width:120, edit: function(d){
return !d.LAY_DISABLED;
}, templet: '#usernameTpl'}
,{field:'xxx', title:'测试', edit: 'text'}
,{field:'email', minWidth: 160, maxWidth: 320, title:'邮箱 <i class="layui-icon layui-icon-email"></i>', fieldTitle: '邮箱', hide: 0, edit: 'text', templet: function(d){
,{field:'email', minWidth: 160, maxWidth: 320, title:'邮箱 <i class="layui-icon layui-icon-email" lay-event="email"></i>', fieldTitle: '邮箱', hide: 0, edit: 'text', templet: function(d){
return '<em>'+ layui.util.escape(d.email) +'</em>'
}}
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true, escape: false}
Expand Down Expand Up @@ -421,7 +421,7 @@
});
});

// 工具栏事件
// 头部工具栏事件
table.on('toolbar(test)', function(obj){
var id = obj.config.id;
var checkStatus = table.checkStatus(id);
Expand All @@ -445,6 +445,11 @@
};
});

// 表头自定义元素工具事件
table.on('colTool(test)', function(obj){
console.log(obj);
});

//触发单元格工具事件
table.on('tool(test)', function(obj){ // 双击 toolDouble
var data = obj.data;
Expand Down Expand Up @@ -489,7 +494,7 @@

// 行单击事件
table.on('row(test)', function(obj){
// console.log(obj);
console.log(obj);
// layer.closeAll('tips');
obj.setRowChecked({
// type: 'radio'
Expand Down
20 changes: 11 additions & 9 deletions examples/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@
<script src="../src/layui.js" src1="https://cdn.staticfile.org/layui/2.6.8/layui.js"></script>
<script>
layui.use(['upload', 'element'], function(){
var $ = layui.jquery
,upload = layui.upload
,element = layui.element;
var $ = layui.$;
var upload = layui.upload;
var element = layui.element;

var uploadInst = upload.render({
elem: '#test1'
Expand All @@ -103,7 +103,7 @@
//,accept: 'file'
,method: 'get'
,fileAccept: 'image/*'
,exts: "jpg|png|gif|bmp|jpeg|pdf"
,exts: 'jpg|png|gif|bmp|jpeg|pdf'
,data: { //额外参数
a: 1
,b: function(){
Expand Down Expand Up @@ -162,7 +162,8 @@
upload.render({
elem: '#test2'
,url: 'https://httpbin.org/post'
,multiple: true
,multiple: true // 多文件
,unified: true // 一起上传 --- 2.8.8+
,accept: 'images'
,number: 3 //同时上传的数量
,size: 1024
Expand All @@ -172,18 +173,18 @@
$('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
});

//this.files = obj.pushFile();
// this.files = obj.pushFile();
}
,done: function(res, index){
//上传完毕
//console.log(this.files)
// 上传完毕
console.log(res, index)
}
,allDone: function(obj){
console.log(obj)
}
});

//演示多文件列表
// 演示多文件列表 --- 本示例仅演示未开启 unified 属性的情况
var demoListView = $('#demoList');
var uploadListIns = upload.render({
elem: '#testList'
Expand Down Expand Up @@ -247,6 +248,7 @@
}
,progress: function(n, elem, e, index){
console.log(n);
console.log(index);
element.progress('progress-'+ index, n + '%'); //进度条
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "layui",
"version": "2.8.7",
"version": "2.8.8",
"description": "Classic modular Front-End UI library",
"main": "dist/layui.js",
"license": "MIT",
Expand Down
8 changes: 5 additions & 3 deletions src/css/layui.css
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-select::-webkit-input-placeholder{line-height: 1.3;}
.layui-input, .layui-textarea{display: block; width: 100%; padding-left: 10px;}
.layui-input:hover, .layui-textarea:hover{border-color: #d2d2d2 !important;}
.layui-input:focus, .layui-textarea:focus{border-color: #d2d2d2 !important;}
.layui-input:focus, .layui-textarea:focus{border-color: #16b777 !important; box-shadow: 0 0 0 3px rgba(22,183,119,0.08);}
.layui-textarea{position: relative; min-height: 100px; height: auto; line-height: 20px; padding: 6px 10px; resize: vertical;}
.layui-select{padding: 0 10px;}
.layui-form select,
Expand All @@ -744,7 +744,7 @@ a cite{font-style: normal; *cursor:pointer;}

/* 警告条 */
.layui-form-danger:focus,
.layui-form-danger+.layui-form-select .layui-input{border-color: #ff5722 !important;}
.layui-form-danger+.layui-form-select .layui-input{border-color: #ff5722 !important; box-shadow: 0 0 0 3px rgba(255,87,34,0.08);}


/* 输入框点缀 */
Expand Down Expand Up @@ -780,7 +780,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-input-wrap .layui-input-prefix,
.layui-input-wrap .layui-input-suffix,
.layui-input-wrap .layui-input-split{pointer-events: none;}
.layui-input-wrap .layui-input:focus + .layui-input-split{border-color: #d2d2d2;}
.layui-input-wrap .layui-input:focus + .layui-input-split{border-color: #16b777;}
.layui-input-wrap .layui-input-prefix.layui-input-split{border-width: 0; border-right-width: 1px;}

/* 输入框动态点缀 */
Expand Down Expand Up @@ -1011,7 +1011,9 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-table-view .layui-table[lay-skin="row"]{border-width: 0; border-bottom-width: 1px;}
.layui-table-view .layui-table th,
.layui-table-view .layui-table td{padding: 0; border-top: none; border-left: none;}
.layui-table-view .layui-table th [lay-event],
.layui-table-view .layui-table th.layui-unselect .layui-table-cell span{cursor: pointer;}
.layui-table-view .layui-table th span,
.layui-table-view .layui-table td{cursor: default;}
.layui-table-view .layui-table td[data-edit]{cursor: text;}
.layui-table-view .layui-table td[data-edit]:hover:after{position: absolute; left: 0; top: 0; width: 100%; height: 100%; box-sizing: border-box; border: 1px solid #16B777; pointer-events: none; content: "";}
Expand Down
2 changes: 1 addition & 1 deletion src/layui.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
};

var Layui = function(){
this.v = '2.8.7'; // Layui 版本号
this.v = '2.8.8'; // Layui 版本号
};

// 识别预先可能定义的指定全局对象
Expand Down
8 changes: 0 additions & 8 deletions src/modules/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,6 @@ layui.define(['lay', 'layer', 'util'], function(exports){
if(top + dlHeight > $win.height() && top >= dlHeight){
reElem.addClass(CLASS + 'up');
}

// 删除 input 已有文本并放入 placeholder,方便输入
var inputValue = $.trim(input.val());
// 有值时才删除并替换 placeholder
if(inputValue){
input.attr('placeholder', inputValue);
input.val(''); // 清空输入框的值
}

followScroll();
};
Expand Down
28 changes: 22 additions & 6 deletions src/modules/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1809,13 +1809,13 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
var _BODY = $('body');
var dict = {};

// 工具栏操作事件
// 头部工具栏操作事件
that.layTool.on('click', '*[lay-event]', function(e){
var othis = $(this)
,events = othis.attr('lay-event')
,openPanel = function(sets){
var list = $(sets.list)
,panel = $('<ul class="' + ELEM_TOOL_PANEL + '"></ul>');
var othis = $(this);
var events = othis.attr('lay-event');
var openPanel = function(sets){
var list = $(sets.list);
var panel = $('<ul class="' + ELEM_TOOL_PANEL + '"></ul>');

panel.html(list);

Expand Down Expand Up @@ -1948,6 +1948,21 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
},{}));
});

// 表头自定义元素事件
that.layHeader.on('click', '*[lay-event]', function(e){
var othis = $(this);
var events = othis.attr('lay-event');
var th = othis.closest('th');
var key = th.data('key');
var col = that.col(key);

layui.event.call(this, MOD_NAME, 'colTool('+ filter +')', $.extend({
event: events,
config: options,
col: col
},{}));
});

// 分页栏操作事件
that.layPagebar.on('click', '*[lay-event]', function(e){
var othis = $(this);
Expand Down Expand Up @@ -2113,6 +2128,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
tr: tr, // 行元素
config: options,
data: table.clearCacheKey(data), // 当前行数据
dataCache: data, // 当前行缓存中的数据
index: index,
del: function(){ // 删除行数据
table.cache[that.key][index] = [];
Expand Down

0 comments on commit bf5fa9d

Please sign in to comment.