Merge pull request #1029 from layui/main

同步 2.x
This commit is contained in:
贤心 2022-05-27 07:32:14 +08:00 committed by GitHub
commit 186e925175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 129 additions and 278 deletions

View File

@ -1,30 +1,30 @@
<p align="center">
<a href="http://www.layui.com">
<img src="https://sentsin.gitee.io/res/images/layui/layui.png" alt="layui" width="360">
<img src="https://unpkg.com/outeres/img/layui/logo-1.png" alt="layui" width="360">
</a>
</p>
<p align="center">
Classic modular front-end UI framework
Classic modular front-end UI library
</p>
<p align="center">
<a href="https://www.npmjs.com/package/layui"><img src="https://img.shields.io/npm/v/layui.svg?sanitize=true" alt="Version"></a>
<a href="https://www.npmjs.com/package/layui"><img src="https://img.shields.io/npm/l/layui.svg?sanitize=true" alt="License"></a>
<a href="https://travis-ci.org/sentsin/layui"><img alt="Build Status" src="https://img.shields.io/travis/sentsin/layui/master.svg"></a>
<a href="https://coveralls.io/r/sentsin/layui?branch=master"><img alt="Test Coverage" src="https://img.shields.io/coveralls/sentsin/layui/master.svg"></a>
<!--<a href="https://saucelabs.com/beta/builds/7e6196205e4f492496203388fc003b65"><img src="https://saucelabs.com/buildstatus/layui" alt="Build Status"></a>-->
<a href="https://www.npmjs.com/package/layui">
<img src="https://img.shields.io/npm/v/layui" alt="Version">
</a>
<a href="https://www.npmjs.com/package/layui">
<img src="https://img.shields.io/github/license/layui/layui" alt="License">
</a>
<a href="https://github.com/layui/layui/blob/master/dist/css/layui.css">
<img src="https://img.badgesize.io/layui/layui/master/dist/css/layui.css?compression=brotli&label=CSS Brotli size" alt="CSS Brotli size">
</a>
<a href="https://github.com/layui/layui/blob/master/dist/layui.js">
<img src="https://img.badgesize.io/layui/layui/master/dist/layui.js?compression=brotli&label=JS Brotli size" alt="JS Brotli size">
</a>
</p>
<!--
<p align="center">
<a href="https://saucelabs.com/beta/builds/7e6196205e4f492496203388fc003b65"><img src="https://saucelabs.com/browser-matrix/layui.svg" alt="Browser Matrix"></a>
</p>
-->
---
layui 是一套开源的 Web UI 解决方案,采用自身经典的模块化规范,并遵循原生 HTML/CSS/JS 的开发方式极易上手拿来即用。其风格简约轻盈而组件优雅丰盈从源代码到使用方法的每一处细节都经过精心雕琢非常适合网页界面的快速开发。layui 区别于那些基于 MVVM 底层的前端框架,却并非逆道而行,而是信奉返璞归真之道。准确地说,它更多是面向后端开发者,你无需涉足前端的各种工具,只需面对浏览器本身,让一切你所需要的元素与交互,从这里信手拈来。
layui 是一套开源的 Web UI 组件库,采用自身经典的模块化规范,并遵循原生 HTML/CSS/JS 的开发方式极易上手拿来即用。其风格简约轻盈而组件优雅丰盈从源代码到使用方法的每一处细节都经过精心雕琢非常适合网页界面的快速开发。layui 区别于那些基于 MVVM 底层的前端框架,却并非逆道而行,而是信奉返璞归真之道。准确地说,它更多是面向后端开发者,你无需涉足前端的各种工具,只需面对浏览器本身,让一切你所需要的元素与交互,从这里信手拈来。
## 快速上手
@ -60,16 +60,16 @@ layui.use(['layer', 'form'], function(){
```
## 阅读文档
[**最新文档**](https://gitee.com/layui)
[**最新文档**](https://layui.github.io/)
愿 layui 能成为你得心应手的 Web 界面解决方案,化作你方寸屏幕前的亿万字节!
## 贡献者
[贡献者列表](https://github.com/sentsin/layui/graphs/contributors)
[贡献者列表](https://github.com/layui/layui/graphs/contributors)
> 大概是因为 layui 让开发者变得更懒,所以贡献者才如此之少。
## 相关
> layui 官网已于2021年10月13日下线。
> layui 官网已于2021年10月13日下线。
目前包括版本更新、文档等在内的所有日常维护,都以 Github 或 Gitee 项目主页为准。

2
dist/css/layui.css vendored

File diff suppressed because one or more lines are too long

2
dist/layui.js vendored

File diff suppressed because one or more lines are too long

View File

@ -199,6 +199,8 @@ layui.use('laydate', function(laydate){
,type: 'year'
//,range: true
//,trigger: 'click'
//,min:'2021-01-01'
//,max:'2022-12-31'
,done: function(value, date, endDate){
console.log(value, date, endDate);
}
@ -213,7 +215,8 @@ layui.use('laydate', function(laydate){
,type: 'month'
,range: true
,trigger: 'click'
//,max: -30
,min:'2022-03-01'
,max:'2022-05-31'
,done: function(value, date, endDate){
console.log(value, date, endDate);
}

View File

@ -89,8 +89,8 @@ var runTest = function(run, $, layer){
};
window.jQuery && runTest(1, window.jQuery, window.layer);
layui.use('layer', function(){
var $ = layui.jquery, layer = layui.layer;
layui.use(['layer', 'util'], function(layer, util){
var $ = layui.jquery;
//return
var index = layer.msg('hello');
@ -166,7 +166,7 @@ layui.use('layer', function(){
layer.close(index);
layer.prompt({title: '随便写点啥,并确认', formType: 2}, function(text, index){
layer.close(index);
layer.msg('演示完毕!您的口令:'+ pass +'<br>您最后写下了:'+text);
layer.msg('演示完毕!您的口令:'+ util.escape(pass) +'<br>您最后写下了:'+ util.escape(text));
});
});
}

View File

@ -21,7 +21,9 @@
<div>模板</div>
<textarea id="demoTPL1"><h1>{{ d.title }}</h1>
<p>转义 html{{= d.desc }}</p>
<p>转义输出(HTML){{ d.desc }}</p>
<p>转义输出(HTML){{= d.desc }}</p>
<p>原始输出(HTML){{- d.desc }}</p>
{{#}}
<div class="layui-section">
@ -69,7 +71,7 @@
<textarea id="demoData1">
{
"title": "标题",
"desc": "<a href=\"\">一段描述</a>",
"desc": "<a href=\"\" style=\"color:blue;\">一段描述</a>",
"items": [
{
"title": "list 1",
@ -121,7 +123,7 @@
<script type="type/html" template id="laytplTestTpl">
{{# for(var i = 0; i < d.items.length; i++){ }}
第{{d.items[i].index}}个Name: {{d.items[i].name}} Number: {{d.items[i].number}}
第{{= d.items[i].index }}个Name: {{- d.items[i].name }} Number: {{= d.items[i].number }}
{{# } }}
</script>

View File

@ -111,12 +111,22 @@ layui.use(['table', 'dropdown'], function(){
,layEvent: 'LAYTABLE_TIPS'
,icon: 'layui-icon-tips'
}]
,cols: [[
,cols: !1 ? [[ //仅用于测试
{type: 'checkbox', fixed: 'left'}
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
,{field:'username', title:'用户名', width:120, edit: 'text'}
,{field:'email', title:'邮箱', hide: 0, width:150, edit: 'text'}
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
,{field:'city', title:'城市', width:120}
,{field:'sign', title:'签名'}
,{field: 'experience', title: '积分', width:80, sort: true, align:'center', totalRow: '{{ d.TOTAL_NUMS }} 😊'}
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
]] : [[
{type: 'checkbox', fixed: 'left'}
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
,{field:'username', title:'用户名', width:120, edit: 'text', templet: '#usernameTpl'}
,{field:'email', title:'邮箱', hide: 0, width:150, edit: 'text', templet: function(d){
return '<em>'+ d.email +'</em>'
return '<em>'+ layui.util.escape(d.email) +'</em>'
}}
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
,{field:'city', title:'城市', width:120, templet: '#cityTpl', exportTemplet: function(d, obj){
@ -212,7 +222,7 @@ layui.use(['table', 'dropdown'], function(){
break;
case 'getCheckData':
var data = checkStatus.data;
layer.alert(JSON.stringify(data));
layer.alert(layui.util.escape(JSON.stringify(data)));
break;
case 'getCheckLength':
var data = checkStatus.data;

View File

@ -21,35 +21,15 @@
<a href="table-static.html" class="layui-btn">静态表格</a>
</div>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
<button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
<button class="layui-btn layui-btn-sm" lay-event="getData">获取当前页所有数据</button>
<button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
<button class="layui-btn layui-btn-sm" lay-event="reload">重载(保留初始参数)</button>
<button class="layui-btn layui-btn-sm" lay-event="reload2">重载(不保留初始参数)</button>
<button class="layui-btn layui-btn-sm" id="dropdown">
更多菜单
<i class="layui-icon layui-icon-down layui-font-12"></i>
</button>
</div>
</script>
<table id="test" lay-filter="test"></table>
<div id="appendtest"></div>
<script type="text/html" id="TPL_appendtest">
<table class="layui-table" lay-data="{url:'json/table/demo2.json', page: true, limit: 6}" lay-filter="appendtest">
<thead>
<tr>
<th lay-data="{checkbox:true, fixed:'left'}" rowspan="2"></th>
<th lay-data="{field:'username', width:80}" rowspan="2">联系人</th>
<th lay-data="{field:'amount', width:120}" rowspan="2">金额</th>
</tr>
</thead>
</table>
</script>
<table class="layui-table" lay-data="{url:'json/table/demo2.json', page: true, limit: 6}" lay-filter="appendtest">
<thead>
<tr>
<th lay-data="{checkbox:true, fixed:'left'}" rowspan="2"></th>
<th lay-data="{field:'username', width:80}" rowspan="2">联系人</th>
<th lay-data="{field:'amount', width:120}" rowspan="2">金额</th>
</tr>
</thead>
</table>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
@ -222,189 +202,6 @@ layui.use(['table', 'dropdown'], function(){
//,height: 300
});
$('#appendtest').append($('#TPL_appendtest').html())
table.init('appendtest');
//渲染
window.ins1 = table.render({
elem: '#test'
,height: 400
//,width: 600
,title: '用户数据表'
,url: 'json/table/demo1.json'
//,size: 'lg'
,page: {
}
//,autoSort: false //是否自动排序。如果否,则由服务端排序
//,loading: false
,totalRow: true
,limit: 30
,toolbar: '#toolbarDemo'
,defaultToolbar: ['filter', 'exports', 'print', {
title: '帮助'
,layEvent: 'LAYTABLE_TIPS'
,icon: 'layui-icon-tips'
}]
,escape: true
,cols: [[
{type: 'checkbox', fixed: 'left'}
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
,{field:'username', title:'用户名', width:120, edit: 'text', templet: '#usernameTpl'}
,{field:'email', title:'邮箱', hide: 0, width:150, edit: 'text', templet: function(d){
return '<em>'+ d.email +'</em>'
}}
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
,{field:'city', title:'城市', width:120}
,{field:'sign', title:'签名'}
,{field:'experience', title:'积分', width:80, sort: true, totalRow: '{{ d.TOTAL_NUMS }} 分', templet: '<div>{{ d.experience }} 分</div>'}
,{field:'ip', title:'IP', width:120}
,{field:'logins', title:'登入次数', width:100, sort: true, totalRow: true}
,{field:'joinTime', title:'加入时间', width:120}
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
]]
,initSort1: {
field: 'experience' //排序字段,对应 cols 设定的各字段名
,type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
}
,headers: {headers_token: 'sasasas'}
,where: $.extend({}, table.config.where, {
test: '渲染的 test'
,token: '渲染的 token'
,key: 'experience'
,order: 'asc'
})
,done: function(){
//下拉菜单
dropdown.render({
elem: '#dropdown' //可绑定在任意元素中,此处以上述按钮为例
,data: [{
id: 0,
title: '刷新'
}]
//菜单被点击的事件
,click: function(obj){
table.reload('test');
}
});
}
,error: function(res, msg){
console.log(res, msg)
}
/*
,response: {
statusName: 'status'
,statusCode: 200
}
,parseData: function(res){
return {
"status": res.status
,"msg": res.message
,"count": res.total
,"data": res.data.list
};
}
*/
});
//排序事件
table.on('sort(test)', function(obj){
console.log(obj);
return;
layer.msg('服务端排序。order by '+ obj.field + ' ' + obj.type);
//服务端排序
table.reload('test', {
initSort: obj
//,page: {curr: 1} //重新从第一页开始
,where: { //重新请求服务端
key: obj.field //排序字段
,order: obj.type //排序方式
}
}, true);
});
//工具栏事件
table.on('toolbar(test)', function(obj){
var config = obj.config;
var checkStatus = table.checkStatus(config.id);
switch(obj.event){
case 'add':
layer.msg('添加');
break;
case 'update':
layer.msg('编辑');
break;
case 'delete':
layer.msg('删除');
break;
case 'getCheckData':
var data = checkStatus.data;
layer.alert(JSON.stringify(data));
break;
case 'getCheckLength':
var data = checkStatus.data;
layer.msg('选中了:'+ data.length + ' 个');
break;
case 'getData':
var getData = table.getData(obj.config.id);
console.log(getData);
layer.alert(JSON.stringify(getData));
break;
case 'isAll':
layer.msg(checkStatus.isAll ? '全选': '未全选')
break;
case 'LAYTABLE_TIPS':
layer.alert(config.title || 'Table for layui-v'+ layui.v);
break;
case 'reload':
//深度重载
var instReload = table.reload('test', {
where: {
abc: 123
,test: '重载的 test'
}
,page: {curr: 5, limit: 20}
,cols: ins1.config.cols
//,height: 300
//,url: 'x'
}, true);
break;
case 'reload2':
//浅重载
table.reload('test', {
where: {
efg: 'sasasas'
//,test: '新的 test2'
//,token: '新的 token2'
}
,cols: [[
{type: 'checkbox', fixed: 'left'}
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计:'}
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
,{field:'experience', title:'积分', width:80, sort: true, totalRow: true, templet: '<div>{{ d.experience }} 分</div>'}
,{field:'logins', title:'登入次数', width:100, sort: true, totalRow: true}
,{field:'joinTime', title:'加入时间', width:120}
]]
//,height: 500
});
break;
};
});
table.on('row(test)', function(obj){
console.log(obj);
//layer.closeAll('tips');
});
table.render({
elem: '#test2'

View File

@ -98,7 +98,7 @@ layui.use(['upload', 'element'], function(){
var uploadInst = upload.render({
elem: '#test1'
,url: 'http://httpbin.org/post'
,url: 'https://httpbin.org/post'
//,size: 2000 //限制文件大小,单位 KB
//,accept: 'file'
,method: 'get'
@ -110,8 +110,8 @@ layui.use(['upload', 'element'], function(){
return 2
}
}
,choose: function(){
,choose: function(obj){
console.log('choose', obj);
}
,before: function(obj){
//预读本地文件示例不支持ie8

View File

@ -1,7 +1,7 @@
{
"name": "layui",
"realname": "layui",
"version": "2.6.10",
"version": "2.6.11",
"description": "Classic modular Front-End UI library",
"main": "dist/layui.js",
"license": "MIT",

View File

@ -243,7 +243,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-icon-music:before{content:"\e690"}
/* 基本布局 */
.layui-main{position: relative; width: 1140px; margin: 0 auto;}
.layui-main{position: relative; width: 1160px; margin: 0 auto;}
.layui-header{position: relative; z-index: 1000; height: 60px;}
.layui-header a:hover{transition: all .5s; -webkit-transition: all .5s;}
.layui-side{position: fixed; left: 0; top: 0; bottom: 0; z-index: 999; width: 200px; overflow-x: hidden;}
@ -264,7 +264,7 @@ a cite{font-style: normal; *cursor:pointer;}
/* 栅格布局 */
.layui-container{position: relative; margin: 0 auto; padding: 0 15px; box-sizing: border-box;}
.layui-container{position: relative; margin: 0 auto; box-sizing: border-box;}
.layui-fluid{position: relative; margin: 0 auto; padding: 0 15px;}
.layui-row:before, .layui-row:after{content: ""; display: block; clear: both;}
@ -302,7 +302,8 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-col-xs-offset12{margin-left: 100%;}
/* 超小屏幕(手机) */
@media screen and (max-width: 768px) {
@media screen and (max-width: 767.98px) {
.layui-container{padding: 0 15px;}
.layui-hide-xs{display: none!important;}
.layui-show-xs-block{display: block!important;}
.layui-show-xs-inline{display: inline!important;}
@ -311,7 +312,7 @@ a cite{font-style: normal; *cursor:pointer;}
/* 小型屏幕(平板) */
@media screen and (min-width: 768px) {
.layui-container{width: 750px;}
.layui-container{width: 720px;}
.layui-hide-sm{display: none!important;}
.layui-show-sm-block{display: block!important;}
.layui-show-sm-inline{display: inline!important;}
@ -346,7 +347,7 @@ a cite{font-style: normal; *cursor:pointer;}
}
/* 中型屏幕(桌面) */
@media screen and (min-width: 992px) {
.layui-container{width: 970px;}
.layui-container{width: 960px;}
.layui-hide-md{display: none!important;}
.layui-show-md-block{display: block!important;}
.layui-show-md-inline{display: inline!important;}
@ -381,7 +382,7 @@ a cite{font-style: normal; *cursor:pointer;}
}
/* 大型屏幕(桌面) */
@media screen and (min-width: 1200px) {
.layui-container{width: 1170px;}
.layui-container{width: 1150px;}
.layui-hide-lg{display: none!important;}
.layui-show-lg-block{display: block!important;}
.layui-show-lg-inline{display: inline!important;}

View File

@ -1,6 +1,6 @@
/**
* Layui
* Classic modular Front-End UI library
* Classic modular front-end UI library
* MIT Licensed
*/
@ -15,7 +15,7 @@
}
,Layui = function(){
this.v = '2.6.10'; // layui 版本号
this.v = '2.6.11'; // layui 版本号
}
//识别预先可能定义的指定全局对象

View File

@ -917,7 +917,9 @@
}
//通过检测当前有效日期,来设定确定按钮是否可点
if(!options.range) that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0, ['hours', 'minutes', 'seconds']);
if(!options.range){
that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0, ['hours', 'minutes', 'seconds']);
}
//同步按钮可点状态
that.setBtnStatus();
@ -960,10 +962,18 @@
lay.each(new Array(15), function(i){
var li = lay.elem('li', {
'lay-ym': yearNum
}), ymd = {year: yearNum};
})
,ymd = {
year: yearNum
,month: 0
,date: 1
};
yearNum == listYM[0] && lay(li).addClass(THIS);
li.innerHTML = yearNum + text;
ul.appendChild(li);
/*
if(yearNum < that.firstDate.year){
ymd.month = options.min.month;
ymd.date = options.min.date;
@ -971,9 +981,12 @@
ymd.month = options.max.month;
ymd.date = options.max.date;
}
*/
that.limit(lay(li), ymd, index);
yearNum++;
});
lay(elemYM[isCN ? 0 : 1]).attr('lay-ym', (yearNum - 8) + '-' + listYM[1])
.html((startY + text) + ' - ' + (yearNum - 1 + text));
}
@ -983,17 +996,28 @@
lay.each(new Array(12), function(i){
var li = lay.elem('li', {
'lay-ym': i
}), ymd = {year: listYM[0], month: i};
})
,ymd = {
year: listYM[0]
,month: i
,date: 1
};
i + 1 == listYM[1] && lay(li).addClass(THIS);
li.innerHTML = lang.month[i] + (isCN ? '月' : '');
ul.appendChild(li);
/*
if(listYM[0] < that.firstDate.year){
ymd.date = options.min.date;
} else if(listYM[0] >= that.firstDate.year){
ymd.date = options.max.date;
}
*/
that.limit(lay(li), ymd, index);
});
lay(elemYM[isCN ? 0 : 1]).attr('lay-ym', listYM[0] + '-' + listYM[1])
.html(listYM[0] + text);
}
@ -1016,7 +1040,9 @@
}][i], index, [['hours'], ['hours', 'minutes'], ['hours', 'minutes', 'seconds']][i]);
});
});
if(!options.range) that.limit(lay(that.footer).find(ELEM_CONFIRM), that[startEnd], 0, ['hours', 'minutes', 'seconds']);
if(!options.range){
that.limit(lay(that.footer).find(ELEM_CONFIRM), that[startEnd], 0, ['hours', 'minutes', 'seconds']);
}
};
//初始化时间对象

View File

@ -3,7 +3,6 @@
*/
layui.define(function(exports){
"use strict";
var config = {
@ -24,8 +23,15 @@ layui.define(function(exports){
return exp((_||'') + config.open + types + config.close + (__||''));
},
escape: function(html){
return String(html||'').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
var exp = /[<"'>]|&(?=#[a-zA-Z0-9]+)/g;
if(html === undefined || html === null) return '';
html += '';
if(!exp.test(html)) return html;
return html.replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
.replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
},
error: function(e, tplog){
var error = 'Laytpl Error: ';
@ -61,22 +67,24 @@ layui.define(function(exports){
return str
})
//匹配JS规则内容
//匹配 JS 语法
.replace(/(?="|')/g, '\\').replace(tool.query(), function(str){
str = str.replace(jss, '').replace(jsse, '');
return '";' + str.replace(/\\(.)/g, '$1') + ';view+="';
})
//匹配普通字段
//匹配普通输出语句
.replace(tool.query(1), function(str){
var start = '"+(';
var start = '"+laytpl.escape(';
if(str.replace(/\s/g, '') === config.open+config.close){
return '';
}
str = str.replace(exp(config.open+'|'+config.close), '');
if(/^=/.test(str)){
str = str.replace(/^=/, '');
start = '"+laytpl.escape(';
} else if(/^-/.test(str)){
str = str.replace(/^-/, '');
start = '"+(';
}
return start + str.replace(/\\(.)/g, '$1') + ')+"';
});

View File

@ -77,7 +77,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,item3 = obj.item3 //表头数据
,content = obj.content; //原始内容
//是否防 xss
//是否编码 HTML
if(options.escape) content = util.escape(content);
//获取模板
@ -249,6 +249,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
Class.prototype.config = {
limit: 10 //每页显示的数量
,loading: true //请求数据时,是否显示 loading
,escape: true // 是否开启 HTML 编码功能,即转义 html 原文
,cellMinWidth: 60 //所有单元格默认最小宽度
,defaultToolbar: ['filter', 'exports', 'print'] //工具栏右侧图标
,autoSort: true //是否前端自动排序。如果否,则需自主排序(通常为服务端处理好排序)
@ -1546,21 +1547,19 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
if(key in data) data[key] = value;
that.eachCols(function(i, item3){
var templet = item3.templet || item3.toolbar;
//更新相应列视图
if(item3.field == key && item3.templet){
if(item3.field == key){
cell.html(parseTempData.call(that, {
item3: {templet: item3.templet}
item3: item3
,content: value
,tplData: data
}));
td.data('content', value);
} else if(templet){ //更新所有其他列的模板
} else if(item3.templet || item3.toolbar){ //更新所有其他列的模板
var thisTd = tr.children('td[data-field="'+ (item3.field || i) +'"]')
,content = data[item3.field];
thisTd.children(ELEM_CELL).html(parseTempData.call(that, {
item3: {templet: templet}
item3: item3
,content: content
,tplData: data
}));
@ -1663,7 +1662,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,field: field
}));
}).on('blur', '.'+ELEM_EDIT, function(){
var templet
var item3
,othis = $(this)
,thisElem = this
,field = othis.parent().data('field')
@ -1671,12 +1670,12 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,data = table.cache[that.key][index];
that.eachCols(function(i, item){
if(item.field == field && item.templet){
templet = item.templet;
item3 = item;
}
});
othis.siblings(ELEM_CELL).html(function(value){
return parseTempData.call(that, {
item3: {templet: templet}
item3: item3 || {}
,content: value
,tplData: data
});

View File

@ -169,10 +169,14 @@ layui.define('jquery', function(exports){
.replace(/ss/g, hms[2]);
}
//转义 html,防 xss 攻击
//转义 html
,escape: function(html){
if(html === undefined || html === null) html = '';
var exp = /[<"'>]|&(?=#[a-zA-Z0-9]+)/g;
if(html === undefined || html === null) return '';
html += '';
if(!exp.test(html)) return html;
return html.replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
.replace(/</g, '&lt;').replace(/>/g, '&gt;')
.replace(/'/g, '&#39;').replace(/"/g, '&quot;');
@ -182,6 +186,7 @@ layui.define('jquery', function(exports){
,unescape: function(html){
if(html === undefined || html === null) html = '';
html += '';
return html.replace(/\&amp;/g, '&')
.replace(/\&lt;/g, '<').replace(/\&gt;/g, '>')
.replace(/\&#39;/, '\'').replace(/\&quot;/, '"');
@ -248,6 +253,6 @@ layui.define('jquery', function(exports){
!function(a,b,c){"$:nomunge";function l(){f=b[g](function(){d.each(function(){var b=a(this),c=b.width(),d=b.height(),e=a.data(this,i);(c!==e.w||d!==e.h)&&b.trigger(h,[e.w=c,e.h=d])}),l()},e[j])}var f,d=a([]),e=a.resize=a.extend(a.resize,{}),g="setTimeout",h="resize",i=h+"-special-event",j="delay",k="throttleWindow";e[j]=250,e[k]=!0,a.event.special[h]={setup:function(){if(!e[k]&&this[g])return!1;var b=a(this);d=d.add(b),a.data(this,i,{w:b.width(),h:b.height()}),1===d.length&&l()},teardown:function(){if(!e[k]&&this[g])return!1;var b=a(this);d=d.not(b),b.removeData(i),d.length||clearTimeout(f)},add:function(b){function f(b,e,f){var g=a(this),h=a.data(this,i)||{};h.w=e!==c?e:g.width(),h.h=f!==c?f:g.height(),d.apply(this,arguments)}if(!e[k]&&this[g])return!1;var d;return a.isFunction(b)?(d=b,f):(d=b.handler,b.handler=f,void 0)}}}($,window);
*/
//暴露接口
// 输出接口
exports('util', util);
});