mirror of https://github.com/layui/layui
update
parent
ce805ee6b3
commit
902aea37d9
|
@ -7,6 +7,7 @@
|
|||
*.diff
|
||||
*.patch
|
||||
*.bak
|
||||
*.bat
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
.svn/
|
||||
|
@ -17,12 +18,8 @@ Thumbs.db
|
|||
.npmignore
|
||||
node_modules/
|
||||
_site/
|
||||
run.bat
|
||||
dir.txt
|
||||
.git/
|
||||
|
||||
release/
|
||||
build/
|
||||
rc/
|
||||
|
||||
coverage/
|
||||
v/
|
||||
package-lock.json
|
|
@ -1,3 +1,3 @@
|
|||
|
||||
# 更新日志
|
||||
https://github.com/sentsin/layui/releases
|
||||
https://github.com/layui/layui/releases
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
> 任何用户在使用由 layui 技术开发团队(以下简称「本团队」)研发的系列开源界面框架(以下简称「layui 开源界面框架」)前,请您仔细阅读并透彻理解本声明。您可以选择不使用 layui 开源界面框架,若您一旦使用 layui 开源界面框架,您的使用行为即被视为对本声明全部内容的认可和接受。
|
||||
|
||||
1. layui 开源界面框架是一款开源免费的 Web UI 纯静态框架 ,主要用于更高效地开发网页界面。且 layui 开源界面框架并不具备「互联网接入、网络数据存储、通讯传输以及窃取用户隐私」中的任何一项与用户数据等信息相关的动态功能,layui 开源界面框架仅是 UI 组件或素材类的本地资源。
|
||||
2. layui 开源界面框架仅属于 Web 前端的 UI 组件库,并不涉及任何后台程序代码;其尊重并保护所有用户的个人隐私权,不窃取任何用户计算机中的信息。更不具备用户数据存储等网络传输功能。
|
||||
3. 您承诺秉着合法、合理的原则使用 layui 开源界面框架,不利用 layui 开源界面框架进行任何违法、侵害他人合法利益等恶意的行为,亦不将 layui 开源界面框架运用于任何违反我国法律法规的 Web 平台。
|
||||
4. 任何单位或个人因下载使用 layui 开源界面框架而产生的任何意外、疏忽、合约毁坏、诽谤、版权或知识产权侵犯及其造成的损失 (包括但不限于直接、间接、附带或衍生的损失等),本团队不承担任何法律责任。
|
||||
5. 用户明确并同意本声明条款列举的全部内容,对使用 layui 开源界面框架可能存在的风险和相关后果将完全由用户自行承担,本团队不承担任何法律责任。
|
||||
6. 任何单位或个人在阅读本免责声明后,应在《MIT 开源许可证》所允许的范围内进行合法的发布、传播和使用 layui 开源界面框架等行为,若违反本免责声明条款或违反法律法规所造成的法律责任(包括但不限于民事赔偿和刑事责任),由违约者自行承担。
|
||||
7. 本团队对 layui 开源界面框架拥有知识产权(包括但不限于商标权、专利权、著作权、商业秘密等),上述产品均受到相关法律法规的保护。
|
||||
8. 任何单位或个人不得在未经本团队书面授权的情况下对 layui 开源界面框架本身申请相关的知识产权。
|
||||
9. 如果本声明的任何部分被认为无效或不可执行,则该部分将被解释为反映本团队的初衷,其余部分仍具有完全效力。不可执行的部分声明,并不构成我们放弃执行该声明的权利。
|
||||
10. 本团队有权随时对本声明条款及附件内容进行单方面的变更,并以消息推送、网页公告等方式予以公布,公布后立即自动生效,无需另行单独通知;若您在本声明内容公告变更后继续使用的,表示您已充分阅读、理解并接受修改后的声明内容。
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#FAFAFA;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view .layui-code-ol li:first-child{padding-top:10px}.layui-code-view .layui-code-ol li:last-child{padding-bottom:10px}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}
|
||||
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-view{display:block;position:relative;margin:10px 0;padding:0;border:1px solid #eee;border-left-width:6px;background-color:#fafafa;color:#333;font-family:Courier New;font-size:12px}.layui-code-h3{position:relative;padding:0 10px;height:40px;line-height:40px;border-bottom:1px solid #eee;font-size:12px}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 10px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view .layui-code-ol li:first-child{padding-top:10px}.layui-code-view .layui-code-ol li:last-child{padding-bottom:10px}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0c0c0c;border-left-color:#3f3f3f;background-color:#0c0c0c;color:#c2be9e}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3f3f3f;border-left:none}.layui-code-demo .layui-code{visibility:visible!important;margin:-15px;border-top:none;border-right:none;border-bottom:none}.layui-code-demo .layui-tab-content{padding:15px;border-top:none}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,97 +1,127 @@
|
|||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>基础方法测试用例 - layui</title>
|
||||
|
||||
<link rel="stylesheet" href="../src/css/layui.css">
|
||||
|
||||
<link href="../src/css/layui.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="layui-container" style="padding: 30px 0;">
|
||||
|
||||
<div class="" style="padding: 30px 0;">
|
||||
|
||||
<blockquote class="layui-elem-quote" style="color: #666;">
|
||||
调试结果查看浏览器控制台
|
||||
点击按钮开始测试,测试结果打开浏览器控制台查看
|
||||
</blockquote>
|
||||
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn" lay-on="sort">layui.sort</button>
|
||||
<button class="layui-btn" lay-on="type">layui.type</button>
|
||||
<button class="layui-btn" lay-on="isArray">layui.isArray</button>
|
||||
<button class="layui-btn" lay-on="extend">lay.extend</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../src/layui.js"></script>
|
||||
<script>
|
||||
layui.use('lay', function(){
|
||||
var lay = layui.lay;
|
||||
layui.use(['lay', 'util'], function(){
|
||||
var lay = layui.lay
|
||||
,util = layui.util;
|
||||
|
||||
//sort
|
||||
console.log(
|
||||
'layui.sort: 数字',
|
||||
layui.sort([{a: 3},{a: 0},{a: 0},{a: -1},{a: -5},{a: 6},{a: 9},{a: -333333}], 'a')
|
||||
);
|
||||
console.log(
|
||||
'layui.sort: 中文',
|
||||
layui.sort([{a: '男'},{a: '女'},{a: '男'},{a: '女'},{a: '男'}], 'a')
|
||||
);
|
||||
console.log(
|
||||
'layui.sort: 英文',
|
||||
layui.sort([{a: 'E'},{a: 'B'},{a: 'D'},{a: 'C'},{a: 'A'}], 'a')
|
||||
);
|
||||
console.log(
|
||||
'layui.sort: 混合'
|
||||
,layui.sort([
|
||||
{a: 3}
|
||||
,{a: '男'}
|
||||
,{a: 0}
|
||||
,{a: 66}
|
||||
,{a: 99}
|
||||
,{a: 'C'}
|
||||
,{a: '女'}
|
||||
,{a: 0}
|
||||
,{a: -1}
|
||||
,{a: 'B'}
|
||||
,{a: '男'}
|
||||
,{a: 'A'}
|
||||
,{a: -5}
|
||||
,{a: '男'}
|
||||
,{a: 6}
|
||||
,{a: 9}
|
||||
], 'a')
|
||||
);
|
||||
//事件
|
||||
var style = 'color: orange; font-size: 16px;';
|
||||
util.event('lay-on', {
|
||||
sort: function(){
|
||||
//sort
|
||||
console.log('%c> layui.sort: ', style);
|
||||
console.log(
|
||||
'数字-整数型',
|
||||
layui.sort([{a: 3},{a: 0},{a: 0},{a: -1},{a: -5},{a: 6},{a: 9},{a: -333333}], 'a')
|
||||
);
|
||||
console.log(
|
||||
'数字-浮点型',
|
||||
layui.sort([{a: 3.5},{a: 0.5},{a: 0.5},{a: -1.5},{a: -5.5},{a: 6.5},{a: 9.5},{a: -333333.5}], 'a')
|
||||
);
|
||||
console.log(
|
||||
'数字-混合型',
|
||||
layui.sort([{a: 1},{a: 20.5},{a: 20.3},{a: 3},{a: 52},{a: 4.3}], 'a')
|
||||
);
|
||||
console.log(
|
||||
'中文',
|
||||
layui.sort([{a: '男'},{a: '女'},{a: '男'},{a: '女'},{a: '男'}], 'a')
|
||||
);
|
||||
console.log(
|
||||
'英文',
|
||||
layui.sort([{a: 'E'},{a: 'B'},{a: 'D'},{a: 'C'},{a: 'A'}], 'a')
|
||||
);
|
||||
console.log(
|
||||
'混合'
|
||||
,layui.sort([
|
||||
{a: 3}
|
||||
,{a: '男'}
|
||||
,{a: 0}
|
||||
,{a: 66}
|
||||
,{a: 99}
|
||||
,{a: 'C'}
|
||||
,{a: '女'}
|
||||
,{a: 3.5}
|
||||
,{a: 0}
|
||||
,{a: -1}
|
||||
,{a: 'B'}
|
||||
,{a: 5.5}
|
||||
,{a: '男'}
|
||||
,{a: 'A'}
|
||||
,{a: -5}
|
||||
,{a: '男'}
|
||||
,{a: 6}
|
||||
,{a: 9}
|
||||
], 'a')
|
||||
);
|
||||
console.log(
|
||||
'数组成员全为数字',
|
||||
layui.sort([1, 20.5, 19.5, 52, 4.5])
|
||||
);
|
||||
console.log(
|
||||
'数组成员为混合型',
|
||||
layui.sort([1, {a: 32}, 20.5, {a: 6}, 52, 5.5], 'a') //按成员对象的 key 为 a 进行比较
|
||||
);
|
||||
}
|
||||
|
||||
,type: function(){
|
||||
console.log('%c> layui.type: ', style);
|
||||
console.log(
|
||||
'new RegExp():', layui.type(new RegExp()),
|
||||
'\nnew Date():', layui.type(new Date()),
|
||||
'\n[]:', layui.type([])
|
||||
);
|
||||
}
|
||||
|
||||
,isArray: function(){
|
||||
console.log('%c> layui.isArray: ', style);
|
||||
console.log(
|
||||
'[1,6]:', layui.isArray([1,6]),
|
||||
'\nlay("div"):', layui.isArray(lay('div')),
|
||||
'\ndocument.querySelectorAll("div"):', layui.isArray(document.querySelectorAll('div')),
|
||||
'\n{"key": "value"}:', layui.isArray({key: 'value'})
|
||||
);
|
||||
}
|
||||
|
||||
,extend: function(){
|
||||
console.log('%c> lay.extend: ', style);
|
||||
console.log(
|
||||
lay.extend(
|
||||
{},
|
||||
{a: 123, c: {ccc: 'ccc'}, arr: [1,3]},
|
||||
{a: 111, b: 1, c: {bbb: 'bbb'}},
|
||||
{a: 222222, arr: [5]}
|
||||
)
|
||||
);
|
||||
console.log(
|
||||
lay.extend([], [1,3,5])
|
||||
);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
console.log(
|
||||
'layui._typeof: ',
|
||||
layui._typeof(new RegExp()),
|
||||
layui._typeof(new Date()),
|
||||
layui._typeof([])
|
||||
);
|
||||
|
||||
console.log(
|
||||
'layui._isArray ',
|
||||
layui._isArray([1,6]),
|
||||
layui._isArray(lay('div')),
|
||||
layui._isArray(document.querySelectorAll('div')),
|
||||
layui._isArray({key: 'value'})
|
||||
);
|
||||
|
||||
console.log(
|
||||
'lay.extend {}: ',
|
||||
lay.extend(
|
||||
{},
|
||||
{a: 123, c: {ccc: 'ccc'}, arr: [1,3]},
|
||||
{a: 111, b: 1, c: {bbb: 'bbb'}},
|
||||
{a: 222222, arr: [5]}
|
||||
)
|
||||
);
|
||||
console.log(
|
||||
'lay.extend []: ',
|
||||
lay.extend([], [1,3,5])
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
,"data": [{
|
||||
"id": "10001"
|
||||
,"username": "杜甫"
|
||||
,"email": "test@email.com"
|
||||
,"email": "test1@email.com"
|
||||
,"sex": "男"
|
||||
,"city": "浙江杭州"
|
||||
,"sign": "鼠标移动到此处,可以通过点击单元格右侧的下拉图标,查看到被隐藏的全部内容。"
|
||||
|
@ -19,7 +19,7 @@
|
|||
}, {
|
||||
"id": "10002"
|
||||
,"username": "李白"
|
||||
,"email": "test@email.com"
|
||||
,"email": "test2@email.com"
|
||||
,"sex": "男"
|
||||
,"city": "浙江杭州"
|
||||
,"sign": "君不见,黄河之水天上来,奔流到海不复回。 君不见,高堂明镜悲白发,朝如青丝暮成雪。 人生得意须尽欢,莫使金樽空对月。 天生我材必有用,千金散尽还复来。 烹羊宰牛且为乐,会须一饮三百杯。 岑夫子,丹丘生,将进酒,杯莫停。 与君歌一曲,请君为我倾耳听。(倾耳听 一作:侧耳听) 钟鼓馔玉不足贵,但愿长醉不复醒。(不足贵 一作:何足贵;不复醒 一作:不愿醒/不用醒) 古来圣贤皆寂寞,惟有饮者留其名。(古来 一作:自古;惟 通:唯) 陈王昔时宴平乐,斗酒十千恣欢谑。 主人何为言少钱,径须沽取对君酌。 五花马,千金裘,呼儿将出换美酒,与尔同销万古愁。"
|
||||
|
@ -30,8 +30,8 @@
|
|||
,"LAY_CHECKED": true
|
||||
}, {
|
||||
"id": "10003"
|
||||
,"username": "王勃"
|
||||
,"email": "test@email.com"
|
||||
,"username": "苏轼"
|
||||
,"email": "test3@email.com"
|
||||
,"sex": "男"
|
||||
,"city": "浙江杭州"
|
||||
,"sign": "人生恰似一场修行"
|
||||
|
@ -42,7 +42,7 @@
|
|||
}, {
|
||||
"id": "10004"
|
||||
,"username": "李清照"
|
||||
,"email": "test@email.com"
|
||||
,"email": "test4@email.com"
|
||||
,"sex": "女"
|
||||
,"city": "浙江杭州"
|
||||
,"sign": "人生恰似一场修行"
|
||||
|
@ -53,7 +53,7 @@
|
|||
}, {
|
||||
"id": "10005"
|
||||
,"username": "冰心"
|
||||
,"email": "test@email.com"
|
||||
,"email": "test5@email.com"
|
||||
,"sex": "女"
|
||||
,"city": "浙江杭州"
|
||||
,"sign": "人生恰似一场修行"
|
||||
|
@ -64,7 +64,7 @@
|
|||
}, {
|
||||
"id": "10006"
|
||||
,"username": "贤心"
|
||||
,"email": "test@email.com"
|
||||
,"email": "test6@email.com"
|
||||
,"sex": "男"
|
||||
,"city": "浙江杭州"
|
||||
,"sign": "人生恰似一场修行"
|
||||
|
@ -75,7 +75,7 @@
|
|||
}, {
|
||||
"id": "10007"
|
||||
,"username": "贤心"
|
||||
,"email": "test@email.com"
|
||||
,"email": "test7@email.com"
|
||||
,"sex": "男"
|
||||
,"city": "浙江杭州"
|
||||
,"sign": "人生恰似一场修行"
|
||||
|
@ -86,7 +86,7 @@
|
|||
}, {
|
||||
"id": "10008"
|
||||
,"username": "贤心"
|
||||
,"email": "test@email.com"
|
||||
,"email": "test8@email.com"
|
||||
,"sex": "男"
|
||||
,"city": "浙江杭州"
|
||||
,"sign": "人生恰似一场修行"
|
||||
|
|
|
@ -126,12 +126,14 @@ layui.use('laydate', function(laydate){
|
|||
//,lang: 'en'
|
||||
//,theme: 'grid'
|
||||
,range: true //开启日期范围,默认使用“-”分割
|
||||
//,min: '1949-10-1'
|
||||
//,min: '1970-1-1'
|
||||
//,max: '2021-5-9'
|
||||
//,value: '2021-05-09 12:06:09'
|
||||
//,value: '2021-05-08 - 2021-03-27'
|
||||
,done: function(value, date, endDate){
|
||||
console.log(value, date, endDate);
|
||||
|
||||
//this.elem.val(123);
|
||||
}
|
||||
,change: function(value, date, endDate){
|
||||
console.log(value, date, endDate);
|
||||
|
@ -157,6 +159,7 @@ layui.use('laydate', function(laydate){
|
|||
}
|
||||
,done: function(value, date, endDate){
|
||||
console.log(value, date, endDate);
|
||||
//this.elem.val(111111);
|
||||
}
|
||||
,change: function(value){
|
||||
console.log(value);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>富文本编辑器 - layui</title>
|
||||
<title>简单富文本编辑器 - layui</title>
|
||||
|
||||
<link rel="stylesheet" href="../src/css/layui.css">
|
||||
|
||||
|
|
|
@ -0,0 +1,224 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>视图模板引擎 - layui</title>
|
||||
|
||||
<link rel="stylesheet" href="../src/css/layui.css">
|
||||
<style>
|
||||
.laytpl-demo{border: 1px solid #EBEBEB;}
|
||||
.laytpl-demo>textarea{position: relative; display: block; width:100%; height: 300px; padding: 11px; border: 0; box-sizing: border-box; resize: none; background-color: #fff; font-family: Courier New; font-size: 13px;}
|
||||
.laytpl-demo>div:first-child{height: 32px; line-height: 32px; padding: 6px 11px; border-bottom: 1px solid #EBEBEB; background-color: #F8F9FA;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs6 laytpl-demo">
|
||||
<div>模板</div>
|
||||
<textarea id="demoTPL1"><h1>{{ d.title }}</h1>
|
||||
|
||||
<p>转义 html:{{= d.desc }}</p>
|
||||
{{#}}
|
||||
|
||||
<div class="layui-section">
|
||||
<hr>
|
||||
<ul>
|
||||
{{# var str = "a b c";
|
||||
layui.each(d.items, function(index, item){ }}
|
||||
<li class="{{ index > 0 ? 'list' : '' }}">
|
||||
<strong>{{ item.title }}</strong>
|
||||
{{# if(item.content){ }}
|
||||
<span>{{ item.content }}</span>
|
||||
{{# } }}
|
||||
<span>{{ item.time || '' }}</span>
|
||||
{{ str }}
|
||||
|
||||
|
||||
</li>
|
||||
{{# }); if(d.items.length === 0){ }}
|
||||
无数据
|
||||
{{# } }}
|
||||
</ul>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ d.content || '' }}
|
||||
{{ }} {{}}
|
||||
{{ }}
|
||||
|
||||
\a
|
||||
'12'"""""
|
||||
"哈''哈"
|
||||
</div>
|
||||
|
||||
<p>渲染时间:{{ layui.util.toDateString(new Date()) }}</p></textarea>
|
||||
</div>
|
||||
|
||||
<div class="layui-col-xs6 laytpl-demo">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs3">数据</div>
|
||||
<div class="layui-col-xs9" style="text-align: right">
|
||||
<button class="layui-btn layui-btn-sm layui-btn-primary" lay-on="createData">生成数据</button>
|
||||
</div>
|
||||
</div>
|
||||
<textarea id="demoData1">
|
||||
{
|
||||
"title": "标题",
|
||||
"desc": "<a href=\"\">一段描述</a>",
|
||||
"items": [
|
||||
{
|
||||
"title": "list 1",
|
||||
"child": [{
|
||||
"title": "list 1-1",
|
||||
"child": [{
|
||||
"title": "list 1-1-1"
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
"title": "list 2",
|
||||
"child": [{
|
||||
"title": "list 2-1"
|
||||
}]
|
||||
},
|
||||
{"title": "list 3"}
|
||||
]
|
||||
}</textarea>
|
||||
</div>
|
||||
<div class="layui-col-xs12 laytpl-demo">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-xs4">视图</div>
|
||||
<div class="layui-col-xs4" style="text-align: center">
|
||||
<button class="layui-btn layui-btn-sm layui-btn-primary" lay-on="test1">性能测试</button>
|
||||
</div>
|
||||
<div class="layui-col-xs4" style="text-align: right">
|
||||
<span id="demoViewTime"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-padding-sm" id="demoView1"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="type/html" template id="demoTplCommon">
|
||||
公共模板 - {{ d.title }}
|
||||
</script>
|
||||
|
||||
<script type="type/html" template id="demoTplList">
|
||||
{{# if(d.items && d.items.length > 0){ }}
|
||||
<ul>
|
||||
{{# layui.each(d.items, function(index, item){ }}
|
||||
<li><strong>{{ item.title }}</strong>{{ laytpl.include('demoTplList', {items: item.child}) }}</li>
|
||||
{{# }); }}
|
||||
</ul>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<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}}
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../src/layui.js"></script>
|
||||
<script>
|
||||
layui.use(['laytpl', 'util'], function(){
|
||||
var laytpl = layui.laytpl
|
||||
,util = layui.util
|
||||
,$ = layui.$;
|
||||
|
||||
//获取模板和数据
|
||||
var get = function(type){
|
||||
return {
|
||||
template: $('#demoTPL1').val() //获取模板
|
||||
,data: function(){ //获取数据
|
||||
try {
|
||||
return JSON.parse($('#demoData1').val());
|
||||
} catch(e){
|
||||
$('#demoView1').html(e);
|
||||
}
|
||||
}()
|
||||
};
|
||||
};
|
||||
|
||||
var data = get();
|
||||
|
||||
//耗时计算
|
||||
var startTime = new Date().getTime(), timer = function(startTime, title){
|
||||
var endTime = new Date().getTime();
|
||||
$('#demoViewTime').html((title || '模板解析耗时:')+ (endTime - startTime) + 'ms');
|
||||
};
|
||||
|
||||
//渲染模板
|
||||
var thisTpl = laytpl(data.template);
|
||||
|
||||
//执行渲染
|
||||
thisTpl.render(data.data, function(view){
|
||||
timer(startTime);
|
||||
$('#demoView1').html(view);
|
||||
});
|
||||
|
||||
//编辑
|
||||
$('.laytpl-demo textarea').on('input', function(){
|
||||
var data = get();
|
||||
if(!data.data) return;
|
||||
|
||||
//计算模板渲染耗时
|
||||
var startTime = new Date().getTime();
|
||||
|
||||
//若模板有变化,则重新解析模板;若模板没变,数据有变化,则从模板缓存中直接渲染(效率大增)
|
||||
if(this.id === 'demoTPL1'){
|
||||
thisTpl.parse(data.template, data.data); //解析模板
|
||||
}
|
||||
|
||||
//执行渲染
|
||||
thisTpl.render(data.data, function(view){
|
||||
timer(startTime);
|
||||
$('#demoView1').html(view);
|
||||
});
|
||||
});
|
||||
|
||||
//事件
|
||||
util.event('lay-on', {
|
||||
//性能测试
|
||||
test1: function(){
|
||||
var dataLen = 1000 //数据量
|
||||
,renderTimes = 1000; //渲染次数
|
||||
|
||||
//初始化数据
|
||||
var data = {
|
||||
title: '性能测试'
|
||||
,items: function(items){
|
||||
for(var i = 0; i < dataLen; i++){
|
||||
items.push({
|
||||
index: i
|
||||
,name: '<strong style="color: red;">张三</strong>'
|
||||
,number: 100+i
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}([])
|
||||
};
|
||||
|
||||
//模板
|
||||
var startTime = new Date();
|
||||
for(var j = 0; j < renderTimes; j++){
|
||||
var template = document.getElementById('laytplTestTpl').innerHTML;
|
||||
var html = laytpl(template).render(data);
|
||||
}
|
||||
timer(startTime, '本次测试耗时:');
|
||||
$('#demoView1').html(html);
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -15,6 +15,12 @@
|
|||
</head>
|
||||
<body>
|
||||
|
||||
<div class="layui-btn-container">
|
||||
<a href="table.html" class="layui-btn">表格综合</a>
|
||||
<a href="table-test.html" class="layui-btn layui-btn-primary">表格测试</a>
|
||||
<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>
|
||||
|
@ -32,7 +38,9 @@
|
|||
|
||||
<script type="text/html" id="barDemo">
|
||||
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
|
||||
{{# if(d.email.trim()){ }}
|
||||
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="usernameTpl">
|
||||
|
@ -44,7 +52,7 @@
|
|||
</script>
|
||||
|
||||
<script type="text/html" id="cityTpl">
|
||||
<select lay-ignore>
|
||||
<select id="demoCity1" lay-ignore>
|
||||
<option value="浙江杭州">浙江杭州</option>
|
||||
<option value="江西南昌">江西南昌</option>
|
||||
<option value="湖北武汉">湖北武汉</option>
|
||||
|
@ -67,7 +75,8 @@ layui.use(['table', 'dropdown'], function(){
|
|||
var table = layui.table
|
||||
,$ = layui.$
|
||||
,laytpl = layui.laytpl
|
||||
,dropdown = layui.dropdown;;
|
||||
,dropdown = layui.dropdown
|
||||
,form = layui.form;
|
||||
|
||||
//全局设定某参数
|
||||
table.set({
|
||||
|
@ -91,7 +100,7 @@ layui.use(['table', 'dropdown'], function(){
|
|||
,title: '用户数据表'
|
||||
,url: 'json/table/demo1.json'
|
||||
//,size: 'lg'
|
||||
|
||||
//,skin: 'line'
|
||||
//,autoSort: false //是否自动排序。如果否,则由服务端排序
|
||||
//,loading: false
|
||||
,totalRow: true
|
||||
|
@ -107,13 +116,16 @@ layui.use(['table', 'dropdown'], function(){
|
|||
,{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){
|
||||
console.log(d)
|
||||
return '<em>'+ d.email +'</em>'
|
||||
}}
|
||||
,{field:'sex', title:'性别', width:80, edit: 'text', sort: true}
|
||||
,{field:'city', title:'城市', width:120, templet: '#cityTpl'}
|
||||
,{field:'city', title:'城市', width:120, templet: '#cityTpl', exportTemplet: function(d, obj){
|
||||
//console.log(obj)
|
||||
var td = obj.td(this.field); //获取当前 td
|
||||
return td.find('select').val();
|
||||
}}
|
||||
,{field:'sign', title:'签名'}
|
||||
,{field: 'experience', title: '积分', width:80, sort: true, totalRow: '{{ d.TOTAL_NUMS }} 😊', templet: '<div>{{ d.experience }} 分</div>'}
|
||||
,{field: 'experience', title: '积分', width:80, sort: true, align:'center', totalRow: '{{ d.TOTAL_NUMS }} 😊', templet: '<div>{{ d.experience }} 分</div>'}
|
||||
,{field:'ip', title:'IP', width: 120}
|
||||
,{field:'logins', title:'登入次数', width: 100, sort: true, totalRow: '{{ parseInt(d.TOTAL_NUMS) }} 次'}
|
||||
,{field:'joinTime', title:'加入时间', width: 120}
|
||||
|
@ -254,12 +266,43 @@ layui.use(['table', 'dropdown'], function(){
|
|||
};
|
||||
});
|
||||
|
||||
//触发行工具事件
|
||||
table.on('tool(test)', function(obj){
|
||||
var data = obj.data;
|
||||
//console.log(obj)
|
||||
if(obj.event === 'del'){
|
||||
layer.confirm('真的删除行么', function(index){
|
||||
obj.del();
|
||||
layer.close(index);
|
||||
});
|
||||
} else if(obj.event === 'edit'){
|
||||
layer.prompt({
|
||||
formType: 2
|
||||
,value: data.email
|
||||
}, function(value, index){
|
||||
obj.update({
|
||||
email: value
|
||||
});
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//触发单元格编辑
|
||||
table.on('edit(test)', function(obj){
|
||||
var field = obj.field //得到字段
|
||||
,value = obj.value //得到修改后的值
|
||||
,data = obj.data; //得到所在行所有键值
|
||||
|
||||
var update = {};
|
||||
update[field] = value;
|
||||
obj.update(update);
|
||||
});
|
||||
|
||||
table.on('row(test)', function(obj){
|
||||
console.log(obj);
|
||||
//console.log(obj);
|
||||
//layer.closeAll('tips');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="layui-btn-container">
|
||||
<a href="table.html" class="layui-btn layui-btn-primary">表格综合</a>
|
||||
<a href="table-test.html" class="layui-btn">表格测试</a>
|
||||
<a href="table-static.html" class="layui-btn">静态表格</a>
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbarDemo">
|
||||
<div class="layui-btn-container">
|
||||
|
@ -434,27 +438,27 @@ layui.use(['table', 'dropdown'], function(){
|
|||
]]
|
||||
});
|
||||
|
||||
//监听表格行点击
|
||||
//触发表格行点击
|
||||
table.on('tr', function(obj){
|
||||
console.log(obj)
|
||||
});
|
||||
|
||||
//监听表格复选框选择
|
||||
//触发表格复选框选择
|
||||
table.on('checkbox(test)', function(obj){
|
||||
console.log(obj)
|
||||
});
|
||||
|
||||
//监听表格单选框选择
|
||||
//触发表格单选框选择
|
||||
table.on('radio(test)', function(obj){
|
||||
console.log(obj)
|
||||
});
|
||||
|
||||
//监听表格单选框选择
|
||||
//触发表格单选框选择
|
||||
table.on('rowDouble(test)', function(obj){
|
||||
console.log(obj);
|
||||
});
|
||||
|
||||
//监听单元格编辑
|
||||
//触发单元格编辑
|
||||
table.on('edit(test)', function(obj){
|
||||
var value = obj.value //得到修改后的值
|
||||
,data = obj.data //得到所在行所有键值
|
||||
|
@ -463,7 +467,7 @@ layui.use(['table', 'dropdown'], function(){
|
|||
console.log(obj)
|
||||
});
|
||||
|
||||
//监听行工具事件
|
||||
//触发行工具事件
|
||||
table.on('tool(test)', function(obj){
|
||||
var data = obj.data;
|
||||
//console.log(obj)
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
|
||||
<!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">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="layui-container" style="padding: 30px 0;">
|
||||
|
||||
<div class="" style="padding: 30px 0;">
|
||||
|
||||
123
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="../src/layui.js"></script>
|
||||
<script>
|
||||
layui.use('lay', function(){
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
284
gulpfile.js
284
gulpfile.js
|
@ -1,187 +1,171 @@
|
|||
|
||||
/*!
|
||||
* layui Build
|
||||
*/
|
||||
/**
|
||||
* Layui Build
|
||||
*/
|
||||
|
||||
var pkg = require('./package.json');
|
||||
var inds = pkg.independents;
|
||||
|
||||
var gulp = require('gulp');
|
||||
var uglify = require('gulp-uglify');
|
||||
var minify = require('gulp-minify-css');
|
||||
var cleanCSS = require('gulp-clean-css');
|
||||
var concat = require('gulp-concat');
|
||||
var rename = require('gulp-rename');
|
||||
var replace = require('gulp-replace');
|
||||
var header = require('gulp-header');
|
||||
var footer = require('gulp-footer');
|
||||
var del = require('del');
|
||||
var gulpif = require('gulp-if');
|
||||
var minimist = require('minimist');
|
||||
var zip = require('gulp-zip');
|
||||
var yargs = require('yargs');
|
||||
|
||||
//基础配置
|
||||
var config = {
|
||||
//注释
|
||||
comment: [
|
||||
'/** <%= pkg.version %> | <%= pkg.license %> Licensed */<%= js %>'
|
||||
,{pkg: pkg, js: ';'}
|
||||
]
|
||||
//模块
|
||||
,modules: 'lay,laytpl,laypage,laydate,jquery,layer,util,dropdown,slider,colorpicker,element,upload,form,table,tree,transfer,carousel,rate,flow,code'
|
||||
};
|
||||
|
||||
//获取参数
|
||||
var argv = require('minimist')(process.argv.slice(2), {
|
||||
default: {
|
||||
ver: 'all'
|
||||
version: pkg.version
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
//注释
|
||||
,note = [
|
||||
// '/*! <%= pkg.realname %> v<%= pkg.version %> | Released under the <%= pkg.license %> license */\n <%= js %>'
|
||||
'/*! <%= pkg.license %> Licensed */<%= js %>'
|
||||
,{pkg: pkg, js: ';'}
|
||||
]
|
||||
|
||||
//模块
|
||||
,mods = 'lay,laytpl,laypage,laydate,jquery,layer,util,element,upload,dropdown,slider,colorpicker,form,tree,transfer,table,carousel,rate,flow,layedit,code'
|
||||
|
||||
//发行版本目录
|
||||
,releaseDir = './release/zip/layui-v' + pkg.version
|
||||
,release = releaseDir + '/layui'
|
||||
|
||||
//目标木
|
||||
,destDir = function(ver){
|
||||
return ver ? release : function(){
|
||||
return argv.rc ? 'rc' : 'dist'
|
||||
}();
|
||||
}
|
||||
|
||||
//任务
|
||||
,task = {
|
||||
//聚合 JS 文件
|
||||
alljs: function(ver){
|
||||
var src = [
|
||||
'./src/**/{layui,layui.all,'+ mods +'}.js'
|
||||
]
|
||||
,dir = destDir(ver);
|
||||
|
||||
return gulp.src(src).pipe(uglify({
|
||||
output: {
|
||||
ascii_only: true //escape Unicode characters in strings and regexps
|
||||
}
|
||||
}))
|
||||
.pipe(concat('layui.js', {newLine: ''}))
|
||||
.pipe(header.apply(null, note))
|
||||
.pipe(gulp.dest('./'+ dir));
|
||||
}
|
||||
|
||||
//压缩 css 文件
|
||||
,mincss: function(ver){
|
||||
var src = [
|
||||
'./src/css/**/*.css'
|
||||
,'!./src/css/**/font.css'
|
||||
]
|
||||
,dir = destDir(ver)
|
||||
,noteNew = JSON.parse(JSON.stringify(note));
|
||||
|
||||
noteNew[1].js = '';
|
||||
|
||||
return gulp.src(src).pipe(minify({
|
||||
compatibility: 'ie7'
|
||||
})) //.pipe(header.apply(null, noteNew))
|
||||
.pipe(gulp.dest('./'+ dir +'/css'));
|
||||
}
|
||||
|
||||
//复制iconfont文件
|
||||
,font: function(ver){
|
||||
var dir = destDir(ver);
|
||||
|
||||
return gulp.src('./src/font/*')
|
||||
.pipe(rename({}))
|
||||
.pipe(gulp.dest('./'+ dir +'/font'));
|
||||
}
|
||||
|
||||
//复制组件可能所需的非css和js资源
|
||||
,mv: function(ver){
|
||||
var src = ['./src/**/*.{png,jpg,gif,html,mp3,json}']
|
||||
,dir = destDir(ver);
|
||||
|
||||
gulp.src(src).pipe(rename({}))
|
||||
.pipe(gulp.dest('./'+ dir));
|
||||
}
|
||||
|
||||
//复制发行的引导文件
|
||||
,release: function(){
|
||||
gulp.src('./release/doc/**/*')
|
||||
.pipe(replace('http://local.res.layui.com/layui/dist/', 'layui/'))
|
||||
.pipe(gulp.dest(releaseDir));
|
||||
}
|
||||
//前置目录
|
||||
var dir = {
|
||||
rls: './release/zip/layui-v' + pkg.version
|
||||
};
|
||||
|
||||
//清理
|
||||
gulp.task('clear', function(cb) {
|
||||
return del(['./'+ (argv.rc ? 'rc' : 'dist') +'/*'], cb);
|
||||
});
|
||||
gulp.task('clearRelease', function(cb) {
|
||||
return del([releaseDir], cb);
|
||||
});
|
||||
//输出目录
|
||||
var dest = ({
|
||||
dist: './dist'
|
||||
,rls: dir.rls + '/layui'
|
||||
}[argv.dest || 'dist'] || argv.dest) + (argv.vs ? '/'+ pkg.version : '');
|
||||
|
||||
gulp.task('alljs', task.alljs);
|
||||
gulp.task('mincss', task.mincss);
|
||||
gulp.task('font', task.font);
|
||||
gulp.task('mv', task.mv);
|
||||
gulp.task('release', task.release);
|
||||
//js
|
||||
var js = function(){
|
||||
var src = [
|
||||
'./src/**/{layui,layui.all,'+ config.modules +'}.js'
|
||||
];
|
||||
return gulp.src(src).pipe(uglify({
|
||||
output: {
|
||||
ascii_only: true //escape Unicode characters in strings and regexps
|
||||
}
|
||||
})).pipe(concat('layui.js', {newLine: ''}))
|
||||
.pipe(header.apply(null, config.comment))
|
||||
.pipe(gulp.dest(dest));
|
||||
};
|
||||
|
||||
//css
|
||||
var css = function(){
|
||||
var src = [
|
||||
'./src/css/**/*.css'
|
||||
,'!./src/css/**/font.css'
|
||||
]
|
||||
return gulp.src(src).pipe(cleanCSS({
|
||||
compatibility: 'ie8'
|
||||
}))
|
||||
//.pipe(concat('layui.css', {newLine: ''}))
|
||||
.pipe(gulp.dest(dest +'/css'));
|
||||
};
|
||||
|
||||
//files
|
||||
var files = function(){
|
||||
var src = ['./src/**/*.{eot,svg,ttf,woff,woff2,html,json,png,jpg,gif}'];
|
||||
return gulp.src(src)
|
||||
.pipe(gulp.dest(dest));
|
||||
};
|
||||
|
||||
//完整任务 gulp
|
||||
gulp.task('default', ['clear'], function(){ //rc 版:gulp --rc
|
||||
for(var key in task){
|
||||
task[key]();
|
||||
}
|
||||
});
|
||||
//mv
|
||||
var mv = function(){
|
||||
return gulp.src('./dist/**/*')
|
||||
.pipe(gulp.dest(dest));
|
||||
};
|
||||
|
||||
//release
|
||||
var rls = function(){
|
||||
return gulp.src('./release/doc/**/*')
|
||||
.pipe(replace(/[^'"]+(\/layui\.css)/, 'layui/css$1')) //替换 css 引入路径中的本地 path
|
||||
.pipe(replace(/[^'"]+(\/layui\.js)/, 'layui$1')) //替换 js 引入路径中的本地 path
|
||||
.pipe(gulp.dest(dir.rls));
|
||||
};
|
||||
|
||||
//发行版 gulp rls
|
||||
gulp.task('rls', ['clearRelease'], function(){ // gulp rls
|
||||
for(var key in task){
|
||||
task[key]('release');
|
||||
}
|
||||
});
|
||||
//clean
|
||||
var clean = function(cb) {
|
||||
return del([dest], {
|
||||
force: true
|
||||
});
|
||||
};
|
||||
var cleanRLS = function(cb) {
|
||||
return del([dir.rls]);
|
||||
};
|
||||
|
||||
//打包 layer 单独版
|
||||
gulp.task('layer', function(){
|
||||
var dir = './release/layer';
|
||||
//Define all task
|
||||
exports.js = js;
|
||||
exports.css = css;
|
||||
exports.files = files;
|
||||
exports.default = gulp.series(clean, gulp.parallel(js, css, files)); //default task
|
||||
exports.mv = gulp.series(clean, mv);
|
||||
exports.rls = gulp.series(cleanRLS, rls); //release task
|
||||
|
||||
//layer task
|
||||
exports.layer = function(){ // gulp layer
|
||||
var dest = './release/layer';
|
||||
|
||||
gulp.src('./src/css/modules/layer/default/*')
|
||||
.pipe(gulp.dest(dir + '/src/theme/default'));
|
||||
.pipe(gulp.dest(dest + '/src/theme/default'));
|
||||
|
||||
return gulp.src('./src/modules/layer.js')
|
||||
.pipe(gulp.dest(dir + '/src'));
|
||||
});
|
||||
.pipe(gulp.dest(dest + '/src'));
|
||||
};
|
||||
|
||||
|
||||
//打包 layDate 单独版
|
||||
gulp.task('laydate', function(){
|
||||
//发行目录
|
||||
var dir = './release/laydate'
|
||||
|
||||
//注释
|
||||
,notes = [
|
||||
//laydate task
|
||||
exports.laydate = function(){ // gulp laydate
|
||||
var dest = './release/laydate/' //发行目录
|
||||
,comment = [ //注释
|
||||
'\n/*! \n * <%= title %> \n * <%= license %> Licensed \n */ \n\n'
|
||||
,{title: 'layDate 日期与时间组件(单独版)', license: 'MIT'}
|
||||
];
|
||||
|
||||
//合并所依赖的 css 文件
|
||||
gulp.src('./src/css/modules/laydate/default/{font,laydate}.css')
|
||||
.pipe(concat('laydate.css', {newLine: '\n\n'}))
|
||||
.pipe(gulp.dest(dir + '/src/theme/default'));
|
||||
//css
|
||||
gulp.src('./src/css/modules/laydate.css')
|
||||
.pipe(gulp.dest(dest + 'src/'));
|
||||
|
||||
//合并所依赖的 js 文件
|
||||
//js
|
||||
return gulp.src(['./src/layui.js', './src/modules/{lay,laydate}.js'])
|
||||
.pipe(replace('win.layui =', 'var layui =')) //将 layui 替换为局部变量
|
||||
.pipe(replace('}(window); //gulp build: layui-footer', '')) //替换 layui.js 的落脚
|
||||
.pipe(replace(';!function(window){ //gulp build: lay-header', '')) //替换 lay.js 的头部
|
||||
|
||||
.pipe(concat('laydate.js', {newLine: ''}))
|
||||
.pipe(header.apply(null, notes)) //追加头部
|
||||
.pipe(gulp.dest(dir + '/src'));
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.pipe(replace('win.layui =', 'var layui =')) //将 layui 替换为局部变量
|
||||
.pipe(replace('})(window); //gulp build: layui-footer', '')) //替换 layui.js 的落脚
|
||||
.pipe(replace('(function(window){ //gulp build: lay-header', '')) //替换 lay.js 的头部
|
||||
.pipe(concat('laydate.js', {newLine: ''}))
|
||||
.pipe(header.apply(null, comment)) //追加头部
|
||||
.pipe(gulp.dest(dest + 'src'));
|
||||
};
|
||||
|
||||
//help
|
||||
exports.help = function(){
|
||||
var usage = '\nUsage: gulp [options] tasks'
|
||||
,parser = yargs.usage(usage, {
|
||||
dest: {
|
||||
type: 'string'
|
||||
,desc: '定义输出目录,可选项:dist(默认)、rls、任意路径'
|
||||
}
|
||||
,vs: {
|
||||
type: 'boolean'
|
||||
,desc: '生成一个带版本号的文件夹'
|
||||
}
|
||||
});
|
||||
|
||||
parser.showHelp(console.log);
|
||||
console.log([
|
||||
'Tasks:'
|
||||
,' default 默认任务'
|
||||
,' rls 发行任务'
|
||||
,' mv 将 dist 目录复制并拷贝一份到参数 --dest 指向的目录'
|
||||
].join('\n'), '\n\nExamples:\n gulp mv --dest ./v --vs', '\n');
|
||||
return gulp.src('./');
|
||||
};
|
||||
|
||||
|
||||
|
|
44
package.json
44
package.json
|
@ -1,49 +1,39 @@
|
|||
{
|
||||
"name": "layui",
|
||||
"realname": "layui",
|
||||
"version": "2.6.8",
|
||||
"version": "2.6.9",
|
||||
"description": "Classic modular Front-End UI library",
|
||||
"main": "dist/layui.js",
|
||||
"license": "MIT",
|
||||
"scripts": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/sentsin/layui.git"
|
||||
"url": "git+ssh://git@github.com/layui/layui.git"
|
||||
},
|
||||
"homepage": "https://github.com/sentsin/layui/",
|
||||
"homepage": "https://github.com/layui/layui/",
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.4",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"gulp-clean-css": "^4.3.0",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-replace": "^1.1.3",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-header": "^2.0.9",
|
||||
"gulp-footer": "^2.1.0",
|
||||
"del": "^2.2.2",
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-concat": "^2.6.0 ",
|
||||
"gulp-footer": "^2.0.2",
|
||||
"gulp-header": "^1.8.8",
|
||||
"gulp-if": "^2.0.1",
|
||||
"gulp-minify-css": "^1.2.4",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-replace": "^0.6.1",
|
||||
"gulp-uglify": "^1.5.4",
|
||||
"gulp-zip": "^4.0.0",
|
||||
"minimist": "^1.2.5",
|
||||
"mocha": "^3.2.0",
|
||||
"sinon": "^3.2.1",
|
||||
"sinon-chai": "^2.13.0"
|
||||
"minimist": "^1.2.5"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://gitee.com/sentsin/layui/issues"
|
||||
},
|
||||
"directories": {
|
||||
"doc": "doc",
|
||||
"example": "examples",
|
||||
"test": "test"
|
||||
},
|
||||
"dependencies": {},
|
||||
"keywords": [
|
||||
"layui",
|
||||
"ui",
|
||||
"ui library",
|
||||
"javascript framework",
|
||||
"toolkit",
|
||||
"front-end component library"
|
||||
"javascript",
|
||||
"css",
|
||||
"components",
|
||||
"framework",
|
||||
"library"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -887,7 +887,7 @@ a cite{font-style: normal; *cursor:pointer;}
|
|||
.layui-table[lay-data]{display: none;}
|
||||
.layui-table-box{position: relative; overflow: hidden;}
|
||||
.layui-table-view{margin: 10px 0;}
|
||||
.layui-table-view .layui-table{position: relative; width: auto; margin: 0;}
|
||||
.layui-table-view .layui-table{position: relative; width: auto; margin: 0; border: 0; border-collapse: separate;}
|
||||
.layui-table-view .layui-table[lay-skin="line"]{border-width: 0; border-right-width: 1px;}
|
||||
.layui-table-view .layui-table[lay-skin="row"]{border-width: 0; border-bottom-width: 1px;}
|
||||
.layui-table-view .layui-table th,
|
||||
|
|
100
src/layui.js
100
src/layui.js
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* Layui
|
||||
* Classic modular Front-End UI library
|
||||
* MIT Licensed
|
||||
|
@ -16,7 +15,7 @@
|
|||
}
|
||||
|
||||
,Layui = function(){
|
||||
this.v = '2.6.8'; // layui 版本号
|
||||
this.v = '2.6.9'; // layui 版本号
|
||||
}
|
||||
|
||||
//识别预先可能定义的指定全局对象
|
||||
|
@ -371,7 +370,7 @@
|
|||
};
|
||||
|
||||
// location.hash 路由解析
|
||||
Layui.prototype.router = function(hash){
|
||||
Layui.prototype.router = Layui.prototype.hash = function(hash){
|
||||
var that = this
|
||||
,hash = hash || location.hash
|
||||
,data = {
|
||||
|
@ -541,7 +540,7 @@
|
|||
};
|
||||
|
||||
//typeof 类型细分 -> string/number/boolean/undefined/null、object/array/function/…
|
||||
Layui.prototype._typeof = function(operand){
|
||||
Layui.prototype._typeof = Layui.prototype.type = function(operand){
|
||||
if(operand === null) return String(operand);
|
||||
|
||||
//细分引用类型
|
||||
|
@ -559,10 +558,10 @@
|
|||
};
|
||||
|
||||
//对象是否具备数组结构(此处为兼容 jQuery 对象)
|
||||
Layui.prototype._isArray = function(obj){
|
||||
Layui.prototype._isArray = Layui.prototype.isArray = function(obj){
|
||||
var that = this
|
||||
,len
|
||||
,type = that._typeof(obj);
|
||||
,type = that.type(obj);
|
||||
|
||||
if(!obj || (typeof obj !== 'object') || obj === win) return false;
|
||||
|
||||
|
@ -584,7 +583,7 @@
|
|||
obj = obj || [];
|
||||
|
||||
//优先处理数组结构
|
||||
if(that._isArray(obj)){
|
||||
if(that.isArray(obj)){
|
||||
for(key = 0; key < obj.length; key++){
|
||||
if(callFn(key, obj)) break;
|
||||
}
|
||||
|
@ -597,25 +596,57 @@
|
|||
return that;
|
||||
};
|
||||
|
||||
//将数组中的对象按其某个成员排序
|
||||
Layui.prototype.sort = function(obj, key, desc){
|
||||
var clone = JSON.parse(
|
||||
JSON.stringify(obj || [])
|
||||
// 将数组中的成员对象按照某个 key 的 value 值进行排序
|
||||
Layui.prototype.sort = function(arr, key, desc){
|
||||
var that = this
|
||||
,clone = JSON.parse(
|
||||
JSON.stringify(arr || [])
|
||||
);
|
||||
|
||||
if(!key) return clone;
|
||||
// 若未传入 key,则直接返回原对象
|
||||
if(that.type(arr) === 'object' && !key){
|
||||
return clone;
|
||||
} else if(typeof arr !== 'object'){ //若 arr 非对象
|
||||
return [clone];
|
||||
}
|
||||
|
||||
//如果是数字,按大小排序;如果是非数字,则按字典序排序
|
||||
// 开始排序
|
||||
clone.sort(function(o1, o2){
|
||||
var v1 = o1[key]
|
||||
,v2 = o2[key]
|
||||
,isNum = [
|
||||
!isNaN(v1)
|
||||
,!isNaN(v2)
|
||||
];
|
||||
|
||||
,v2 = o2[key];
|
||||
|
||||
//若为数字比较
|
||||
/*
|
||||
* 特殊数据
|
||||
* 若比较的成员均非对象
|
||||
*/
|
||||
|
||||
// 若比较的成员均为数字
|
||||
if(!isNaN(o1) && !isNaN(o2)) return o1 - o2;
|
||||
// 若比较的成员只存在某一个非对象
|
||||
if(!isNaN(o1) && isNaN(o2)){
|
||||
if(key && typeof o2 === 'object'){
|
||||
v1 = o1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if (isNaN(o1) && !isNaN(o2)){
|
||||
if(key && typeof o1 === 'object'){
|
||||
v2 = o2;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 正常数据
|
||||
* 即成员均为对象,也传入了对比依据: key
|
||||
* 若 value 为数字,按「大小」排序;若 value 非数字,则按「字典序」排序
|
||||
*/
|
||||
|
||||
// value 是否为数字
|
||||
var isNum = [!isNaN(v1), !isNaN(v2)];
|
||||
|
||||
// 若为数字比较
|
||||
if(isNum[0] && isNum[1]){
|
||||
if(v1 && (!v2 && v2 !== 0)){ //数字 vs 空
|
||||
return 1;
|
||||
|
@ -630,9 +661,9 @@
|
|||
* 字典序排序
|
||||
*/
|
||||
|
||||
//若为非数字比较
|
||||
// 若为非数字比较
|
||||
if(!isNum[0] && !isNum[1]){
|
||||
//字典序比较
|
||||
// 字典序比较
|
||||
if(v1 > v2){
|
||||
return 1;
|
||||
} else if (v1 < v2) {
|
||||
|
@ -642,33 +673,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
//若为混合比较
|
||||
// 若为混合比较
|
||||
if(isNum[0] || !isNum[1]){ //数字 vs 非数字
|
||||
return -1;
|
||||
} else if(!isNum[0] || isNum[1]) { //非数字 vs 数字
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
//老版本
|
||||
if(v1 && !v2){
|
||||
return 1;
|
||||
} else if(!v1 && v2){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(v1 > v2){
|
||||
return 1;
|
||||
} else if (v1 < v2) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
});
|
||||
|
||||
desc && clone.reverse(); //倒序
|
||||
desc && clone.reverse(); // 倒序
|
||||
return clone;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/*!
|
||||
* 用于加载所有内置模块
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* carousel 轮播模块
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* code 代码修饰器
|
||||
* MIT Licensed
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* colorpicker
|
||||
* 颜色选择组件
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* MODULE_DEMO_NAME 模块组件通用结构
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
@ -73,7 +72,7 @@ layui.define([''], function(exports){
|
|||
|
||||
//防止数组深度合并
|
||||
layui.each(options, function(key, item){
|
||||
if(layui._typeof(item) === 'array') delete that.config[key];
|
||||
if(layui.type(item) === 'array') delete that.config[key];
|
||||
});
|
||||
|
||||
that.config = $.extend(true, {}, that.config, options);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/**
|
||||
|
||||
@Name:dropdown 下拉菜单组件
|
||||
@License:MIT
|
||||
|
||||
* dropdown
|
||||
* 下拉菜单组件
|
||||
*/
|
||||
|
||||
layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* element 常用元素操作
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
/**
|
||||
|
||||
@Name flow 流加载组件
|
||||
@License:MIT
|
||||
|
||||
* flow 流加载组件
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* form 表单组件
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/*! lay 基础 DOM 操作 | MIT Licensed */
|
||||
/** lay 基础 DOM 操作 | MIT Licensed */
|
||||
|
||||
;!function(window){ //gulp build: lay-header
|
||||
"use strict";
|
||||
|
@ -33,9 +33,11 @@
|
|||
|
||||
//普通对象深度扩展
|
||||
lay.extend = function(){
|
||||
var ai = 1, args = arguments
|
||||
var ai = 1
|
||||
,length
|
||||
,args = arguments
|
||||
,clone = function(target, obj){
|
||||
target = target || (layui._typeof(obj) === 'array' ? [] : {}); //目标对象
|
||||
target = target || (layui.type(obj) === 'array' ? [] : {}); //目标对象
|
||||
for(var i in obj){
|
||||
//如果值为普通对象,则进入递归,继续深度合并
|
||||
target[i] = (obj[i] && obj[i].constructor === Object)
|
||||
|
@ -46,8 +48,9 @@
|
|||
}
|
||||
|
||||
args[0] = typeof args[0] === 'object' ? args[0] : {};
|
||||
length = args.length
|
||||
|
||||
for(; ai < args.length; ai++){
|
||||
for(; ai < length; ai++){
|
||||
if(typeof args[ai] === 'object'){
|
||||
clone(args[0], args[ai]);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/*! layDate 日期与时间控件 | MIT Licensed */
|
||||
/** layDate 日期与时间控件 | MIT Licensed */
|
||||
|
||||
;!function(window, document){
|
||||
"use strict";
|
||||
|
@ -192,7 +192,7 @@
|
|||
that.rangeStr = options.range ? (typeof options.range === 'string' ? options.range : '-') : '';
|
||||
|
||||
//若 range 参数为数组,则表示为开始日期和结束日期的 input 对象
|
||||
if(layui._typeof(options.range) === 'array'){
|
||||
if(layui.type(options.range) === 'array'){
|
||||
that.rangeElem = [
|
||||
lay(options.range[0]),
|
||||
lay(options.range[1])
|
||||
|
@ -264,7 +264,6 @@
|
|||
,'0-5-4': '青年'
|
||||
,'0-6-1': '儿童'
|
||||
,'0-9-10': '教师'
|
||||
,'0-9-18': '国耻'
|
||||
,'0-10-1': '国庆'
|
||||
,'0-12-25': '圣诞'
|
||||
} : {}, options.mark);
|
||||
|
@ -274,7 +273,15 @@
|
|||
var ymd = [], hms = [];
|
||||
if(typeof options[item] === 'number'){ //如果为数字
|
||||
var day = options[item]
|
||||
,time = new Date().getTime()
|
||||
,tDate = new Date()
|
||||
,time = that.newDate({ //今天的最大毫秒数
|
||||
year: tDate.getFullYear()
|
||||
,month: tDate.getMonth()
|
||||
,date: tDate.getDate()
|
||||
,hours: '23'
|
||||
,minutes: '59'
|
||||
,seconds: '59'
|
||||
}).getTime()
|
||||
,STAMP = 86400000 //代表一天的毫秒数
|
||||
,thisDate = new Date(
|
||||
day ? (
|
||||
|
@ -282,7 +289,7 @@
|
|||
) : time
|
||||
);
|
||||
ymd = [thisDate.getFullYear(), thisDate.getMonth() + 1, thisDate.getDate()];
|
||||
day < STAMP || (hms = [thisDate.getHours(), thisDate.getMinutes(), thisDate.getSeconds()]);
|
||||
hms = [thisDate.getHours(), thisDate.getMinutes(), thisDate.getSeconds()];
|
||||
} else {
|
||||
ymd = (options[item].match(/\d+-\d+-\d+/) || [''])[0].split('-');
|
||||
hms = (options[item].match(/\d+:\d+:\d+/) || [''])[0].split(':');
|
||||
|
@ -304,7 +311,7 @@
|
|||
|
||||
//默认赋值
|
||||
if(options.value && options.isInitValue){
|
||||
if(layui._typeof(options.value) === 'date'){
|
||||
if(layui.type(options.value) === 'date'){
|
||||
that.setValue(that.parse(0, that.systemDate(options.value)));
|
||||
} else {
|
||||
that.setValue(options.value);
|
||||
|
@ -696,7 +703,7 @@
|
|||
) + lang.formatError[1]);
|
||||
error = true;
|
||||
}
|
||||
} else if(value && layui._typeof(value) === 'date'){ //如果值为日期对象时
|
||||
} else if(value && layui.type(value) === 'date'){ //如果值为日期对象时
|
||||
options.dateTime = that.systemDate(value);
|
||||
} else {
|
||||
//重置开始日期
|
||||
|
@ -739,7 +746,9 @@
|
|||
};
|
||||
|
||||
//校验主面板是否在可选日期区间
|
||||
if(getDateTime(dateTime) > getDateTime(options.max) || getDateTime(dateTime) < getDateTime(options.min)){
|
||||
if(getDateTime(dateTime) > getDateTime(options.max)){ //若超出最大日期
|
||||
dateTime = options.dateTime = lay.extend({}, options.max);
|
||||
} else if(getDateTime(dateTime) < getDateTime(options.min)){ //若少于最小日期
|
||||
dateTime = options.dateTime = lay.extend({}, options.min);
|
||||
}
|
||||
|
||||
|
@ -1040,7 +1049,6 @@
|
|||
lay(ul).find('li').on('click', function(){
|
||||
var ym = lay(this).attr('lay-ym') | 0;
|
||||
if(lay(this).hasClass(DISABLED)) return;
|
||||
|
||||
if(index === 0){
|
||||
dateTime[type] = ym;
|
||||
that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0);
|
||||
|
@ -1302,9 +1310,9 @@
|
|||
//补充时分秒
|
||||
lay.each(['startTime', 'endTime'], function(i, item){
|
||||
that[item] = that[item] || {
|
||||
hours: 0
|
||||
,minutes: 0
|
||||
,seconds: 0
|
||||
hours: i ? 23: 0
|
||||
,minutes: i ? 59: 0
|
||||
,seconds: i ? 59: 0
|
||||
};
|
||||
});
|
||||
that.calendar(null, index).done(null, 'change');
|
||||
|
@ -1377,8 +1385,9 @@
|
|||
} else {
|
||||
if(lay(btn).hasClass(DISABLED)) return that.hint(lang.invalidDate);
|
||||
}
|
||||
|
||||
that.setValue(that.parse()).remove();
|
||||
that.done();
|
||||
that.setValue(that.parse()).remove()
|
||||
}
|
||||
};
|
||||
active[type] && active[type]();
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
/**
|
||||
|
||||
@Name:layedit 富文本编辑器
|
||||
@License:MIT
|
||||
|
||||
* layedit 富文本编辑器
|
||||
*/
|
||||
|
||||
layui.define(['layer', 'form'], function(exports){
|
||||
|
@ -28,7 +25,7 @@ layui.define(['layer', 'form'], function(exports){
|
|||
,'|'
|
||||
,'left', 'center', 'right'
|
||||
,'|'
|
||||
,'link', 'unlink', 'face', 'image'
|
||||
,'link', 'unlink'
|
||||
]
|
||||
,hideTool: []
|
||||
,height: 280 //默认高
|
||||
|
@ -372,38 +369,6 @@ layui.define(['layer', 'form'], function(exports){
|
|||
,unlink: function(range){
|
||||
iframeDOM.execCommand('unlink');
|
||||
}
|
||||
//表情
|
||||
,face: function(range){
|
||||
face.call(this, function(img){
|
||||
insertInline.call(iframeWin, 'img', {
|
||||
src: img.src
|
||||
,alt: img.alt
|
||||
}, range);
|
||||
});
|
||||
}
|
||||
//图片
|
||||
,image: function(range){
|
||||
var that = this;
|
||||
layui.use('upload', function(upload){
|
||||
var uploadImage = set.uploadImage || {};
|
||||
upload.render({
|
||||
url: uploadImage.url
|
||||
,method: uploadImage.type
|
||||
,elem: $(that).find('input')[0]
|
||||
,done: function(res){
|
||||
if(res.code == 0){
|
||||
res.data = res.data || {};
|
||||
insertInline.call(iframeWin, 'img', {
|
||||
src: res.data.src
|
||||
,alt: res.data.title
|
||||
}, range);
|
||||
} else {
|
||||
layer.msg(res.msg||'上传失败');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
//插入代码
|
||||
,code: function(range){
|
||||
code.call(body, function(pre){
|
||||
|
@ -471,7 +436,6 @@ layui.define(['layer', 'form'], function(exports){
|
|||
//触发内容区域
|
||||
body.on('click', function(){
|
||||
toolCheck.call(iframeWin, tools);
|
||||
layer.close(face.index);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -523,48 +487,6 @@ layui.define(['layer', 'form'], function(exports){
|
|||
link.index = index;
|
||||
}
|
||||
|
||||
//表情面板
|
||||
,face = function(callback){
|
||||
//表情库
|
||||
var faces = function(){
|
||||
var alt = ["[微笑]", "[嘻嘻]", "[哈哈]", "[可爱]", "[可怜]", "[挖鼻]", "[吃惊]", "[害羞]", "[挤眼]", "[闭嘴]", "[鄙视]", "[爱你]", "[泪]", "[偷笑]", "[亲亲]", "[生病]", "[太开心]", "[白眼]", "[右哼哼]", "[左哼哼]", "[嘘]", "[衰]", "[委屈]", "[吐]", "[哈欠]", "[抱抱]", "[怒]", "[疑问]", "[馋嘴]", "[拜拜]", "[思考]", "[汗]", "[困]", "[睡]", "[钱]", "[失望]", "[酷]", "[色]", "[哼]", "[鼓掌]", "[晕]", "[悲伤]", "[抓狂]", "[黑线]", "[阴险]", "[怒骂]", "[互粉]", "[心]", "[伤心]", "[猪头]", "[熊猫]", "[兔子]", "[ok]", "[耶]", "[good]", "[NO]", "[赞]", "[来]", "[弱]", "[草泥马]", "[神马]", "[囧]", "[浮云]", "[给力]", "[围观]", "[威武]", "[奥特曼]", "[礼物]", "[钟]", "[话筒]", "[蜡烛]", "[蛋糕]"], arr = {};
|
||||
layui.each(alt, function(index, item){
|
||||
arr[item] = layui.cache.dir + 'images/face/'+ index + '.gif';
|
||||
});
|
||||
return arr;
|
||||
}();
|
||||
face.hide = face.hide || function(e){
|
||||
if($(e.target).attr('layedit-event') !== 'face'){
|
||||
layer.close(face.index);
|
||||
}
|
||||
}
|
||||
return face.index = layer.tips(function(){
|
||||
var content = [];
|
||||
layui.each(faces, function(key, item){
|
||||
content.push('<li title="'+ key +'"><img src="'+ item +'" alt="'+ key +'"></li>');
|
||||
});
|
||||
return '<ul class="layui-clear">' + content.join('') + '</ul>';
|
||||
}(), this, {
|
||||
tips: 1
|
||||
,time: 0
|
||||
,skin: 'layui-box layui-util-face'
|
||||
,maxWidth: 500
|
||||
,success: function(layero, index){
|
||||
layero.css({
|
||||
marginTop: -4
|
||||
,marginLeft: -10
|
||||
}).find('.layui-clear>li').on('click', function(){
|
||||
callback && callback({
|
||||
src: faces[this.title]
|
||||
,alt: this.title
|
||||
});
|
||||
layer.close(index);
|
||||
});
|
||||
$(document).off('click', face.hide).on('click', face.hide);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//插入代码面板
|
||||
,code = function(callback){
|
||||
var body = this, index = layer.open({
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* layer - 通用 Web 弹出层组件
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
/**
|
||||
|
||||
@Name : laypage 分页组件
|
||||
@License:MIT
|
||||
|
||||
* laypage 分页组件
|
||||
*/
|
||||
|
||||
layui.define(function(exports){
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
/**
|
||||
|
||||
@Name : laytpl 模板引擎
|
||||
@License:MIT
|
||||
|
||||
* laytpl 模板引擎
|
||||
*/
|
||||
|
||||
layui.define(function(exports){
|
||||
|
@ -79,7 +76,7 @@ layui.define(function(exports){
|
|||
str = str.replace(exp(config.open+'|'+config.close), '');
|
||||
if(/^=/.test(str)){
|
||||
str = str.replace(/^=/, '');
|
||||
start = '"+_escape_(';
|
||||
start = '"+laytpl.escape(';
|
||||
}
|
||||
return start + str.replace(/\\(.)/g, '$1') + ')+"';
|
||||
});
|
||||
|
@ -87,8 +84,8 @@ layui.define(function(exports){
|
|||
tpl = '"use strict";var view = "' + tpl + '";return view;';
|
||||
|
||||
try{
|
||||
that.cache = tpl = new Function('d, _escape_', tpl);
|
||||
return tpl(data, tool.escape);
|
||||
that.cache = tpl = new Function('d, laytpl', tpl);
|
||||
return tpl(data, tool);
|
||||
} catch(e){
|
||||
delete that.cache;
|
||||
return tool.error(e, tplog);
|
||||
|
@ -98,7 +95,7 @@ layui.define(function(exports){
|
|||
Tpl.pt.render = function(data, callback){
|
||||
var that = this, tpl;
|
||||
if(!data) return tool.error('no data');
|
||||
tpl = that.cache ? that.cache(data, tool.escape) : that.parse(that.tpl, data);
|
||||
tpl = that.cache ? that.cache(data, tool) : that.parse(that.tpl, data);
|
||||
if(!callback) return tpl;
|
||||
callback(tpl);
|
||||
};
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* 用于打包聚合版,该文件不会存在于构建后的目录
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/**
|
||||
|
||||
@Name:layui 移动模块入口 | 构建后则为移动模块集合
|
||||
@License:MIT
|
||||
|
||||
* layui 移动模块入口
|
||||
* 构建后则为移动模块集合
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
/**
|
||||
|
||||
@Title: rate 评分评星组件
|
||||
@License:MIT
|
||||
|
||||
* rate 评分评星组件
|
||||
*/
|
||||
|
||||
layui.define('jquery',function(exports){
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
/**
|
||||
|
||||
@Title: slider 滑块组件
|
||||
@License:MIT
|
||||
|
||||
* slider 滑块组件
|
||||
*/
|
||||
|
||||
layui.define('jquery', function(exports){
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* layui.table
|
||||
* 数据表格组件
|
||||
*/
|
||||
|
@ -71,19 +70,28 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
}
|
||||
|
||||
//解析自定义模板数据
|
||||
,parseTempData = function(item3, content, tplData, text){ //表头数据、原始内容、表体数据、是否只返回文本
|
||||
var options = this.config || {};
|
||||
,parseTempData = function(obj){
|
||||
obj = obj || {};
|
||||
|
||||
var options = this.config || {}
|
||||
,item3 = obj.item3 //表头数据
|
||||
,content = obj.content; //原始内容
|
||||
|
||||
//是否防 xss
|
||||
if(options.escape) content = util.escape(content);
|
||||
|
||||
//获取内容
|
||||
var str = item3.templet ? function(){
|
||||
return typeof item3.templet === 'function'
|
||||
? item3.templet(tplData)
|
||||
: laytpl($(item3.templet).html() || String(content)).render(tplData)
|
||||
}() : content;
|
||||
return text ? $('<div>'+ str +'</div>').text() : str;
|
||||
//获取模板
|
||||
var templet = obj.text && item3.exportTemplet || (item3.templet || item3.toolbar);
|
||||
|
||||
//获取模板内容
|
||||
if(templet){
|
||||
content = typeof templet === 'function'
|
||||
? templet.call(item3, obj.tplData, obj.obj)
|
||||
: laytpl($(templet).html() || String(content)).render(obj.tplData);
|
||||
}
|
||||
|
||||
//是否只返回文本
|
||||
return obj.text ? $('<div>'+ content +'</div>').text() : content;
|
||||
}
|
||||
|
||||
//字符常量
|
||||
|
@ -650,7 +658,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
|
||||
//防止数组深度合并
|
||||
layui.each(options, function(key, item){
|
||||
if(layui._typeof(item) === 'array') delete that.config[key];
|
||||
if(layui.type(item) === 'array') delete that.config[key];
|
||||
});
|
||||
|
||||
//对参数进行深度或浅扩展
|
||||
|
@ -744,7 +752,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
typeof options.error === 'function' && options.error(e, msg);
|
||||
}
|
||||
});
|
||||
} else if(layui._typeof(options.data) === 'array'){ //已知数据
|
||||
} else if(layui.type(options.data) === 'array'){ //已知数据
|
||||
var res = {}
|
||||
,startLimit = curr*options.limit - options.limit
|
||||
|
||||
|
@ -790,7 +798,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
,numbers = i1 + options.limit*(curr - 1) + 1; //序号
|
||||
|
||||
//若数据项为空数组,则不往下执行(因为删除数据时,会将原有数据设置为 [])
|
||||
if(layui._typeof(item1) === 'array' && item1.length === 0) return;
|
||||
if(layui.type(item1) === 'array' && item1.length === 0) return;
|
||||
|
||||
//记录下标索引,用于恢复排序
|
||||
if(!sort){
|
||||
|
@ -810,7 +818,6 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
var td = ['<td data-field="'+ field +'" data-key="'+ key +'" '+ function(){ //追加各种属性
|
||||
var attr = [];
|
||||
if(item3.edit) attr.push('data-edit="'+ item3.edit +'"'); //是否允许单元格编辑
|
||||
if(item3.align) attr.push('align="'+ item3.align +'"'); //对齐方式
|
||||
if(item3.templet) attr.push('data-content="'+ content +'"'); //自定义模板
|
||||
if(item3.toolbar) attr.push('data-off="true"'); //行工具列关闭单元格事件
|
||||
if(item3.event) attr.push('lay-event="'+ item3.event +'"'); //自定义事件
|
||||
|
@ -826,7 +833,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
,'<div class="layui-table-cell laytable-cell-'+ function(){ //返回对应的CSS类标识
|
||||
return item3.type === 'normal' ? key
|
||||
: (key + ' laytable-cell-' + item3.type);
|
||||
}() +'">' + function(){
|
||||
}() +'"'+ (item3.align ? ' align="'+ item3.align +'"' : '') +'>' + function(){
|
||||
var tplData = $.extend(true, {
|
||||
LAY_INDEX: numbers
|
||||
,LAY_COL: item3
|
||||
|
@ -861,7 +868,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
if(item3.toolbar){
|
||||
return laytpl($(item3.toolbar).html()||'').render(tplData);
|
||||
}
|
||||
return parseTempData.call(that, item3, content, tplData);
|
||||
return parseTempData.call(that, {
|
||||
item3: item3
|
||||
,content: content
|
||||
,tplData: tplData
|
||||
});
|
||||
}()
|
||||
,'</div></td>'].join('');
|
||||
|
||||
|
@ -957,7 +968,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
|
||||
layui.each(data, function(i1, item1){
|
||||
//若数据项为空数组,则不往下执行(因为删除数据时,会将原有数据设置为 [])
|
||||
if(layui._typeof(item1) === 'array' && item1.length === 0) return;
|
||||
if(layui.type(item1) === 'array' && item1.length === 0) return;
|
||||
|
||||
that.eachCols(function(i3, item3){
|
||||
var field = item3.field || i3
|
||||
|
@ -985,7 +996,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
tplData[field] = thisTotalNum;
|
||||
|
||||
//获取自动计算的合并内容
|
||||
getContent = item3.totalRow ? (parseTempData.call(that, item3, thisTotalNum, tplData) || text) : text;
|
||||
getContent = item3.totalRow ? (parseTempData.call(that, {
|
||||
item3: item3
|
||||
,content: thisTotalNum
|
||||
,tplData: tplData
|
||||
}) || text) : text;
|
||||
|
||||
//如果直接传入了合计行数据,则不输出自动计算的结果
|
||||
return totalRowData ? (totalRowData[item3.field] || getContent) : getContent;
|
||||
|
@ -1142,7 +1157,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
,options = that.config
|
||||
,thisData = table.cache[that.key];
|
||||
if(!thisData[index]) return;
|
||||
if(layui._typeof(thisData[index]) === 'array') return;
|
||||
if(layui.type(thisData[index]) === 'array') return;
|
||||
thisData[index][options.checkName] = checked;
|
||||
};
|
||||
|
||||
|
@ -1194,7 +1209,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
Class.prototype.fullSize = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,height = options.height, bodyHeight;
|
||||
,height = options.height
|
||||
,bodyHeight;
|
||||
|
||||
if(that.fullHeightGap){
|
||||
height = _WIN.height() - that.fullHeightGap;
|
||||
|
@ -1209,17 +1225,17 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
|
||||
//减去工具栏的高度
|
||||
if(options.toolbar){
|
||||
bodyHeight = bodyHeight - (that.layTool.outerHeight() || 50);
|
||||
bodyHeight -= (that.layTool.outerHeight() || 50);
|
||||
}
|
||||
|
||||
//减去统计朗的高度
|
||||
if(options.totalRow){
|
||||
bodyHeight = bodyHeight - (that.layTotal.outerHeight() || 40);
|
||||
bodyHeight -= (that.layTotal.outerHeight() || 40);
|
||||
}
|
||||
|
||||
//减去分页栏的高度
|
||||
if(options.page){
|
||||
bodyHeight = bodyHeight - (that.layPage.outerHeight() || 41);
|
||||
bodyHeight -= (that.layPage.outerHeight() || 41);
|
||||
}
|
||||
|
||||
that.layMain.css('height', bodyHeight - 2);
|
||||
|
@ -1503,7 +1519,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
});
|
||||
|
||||
//数据行中的事件返回的公共对象成员
|
||||
var commonMember = function(sets){
|
||||
var commonMember = that.commonMember = function(sets){
|
||||
var othis = $(this)
|
||||
,index = othis.parents('tr').eq(0).data('index')
|
||||
,tr = that.layBody.find('tr[data-index="'+ index +'"]')
|
||||
|
@ -1523,19 +1539,34 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
,update: function(fields){ //修改行数据
|
||||
fields = fields || {};
|
||||
layui.each(fields, function(key, value){
|
||||
if(key in data){
|
||||
var templet, td = tr.children('td[data-field="'+ key +'"]');
|
||||
data[key] = value;
|
||||
that.eachCols(function(i, item2){
|
||||
if(item2.field == key && item2.templet){
|
||||
templet = item2.templet;
|
||||
}
|
||||
});
|
||||
td.children(ELEM_CELL).html(parseTempData.call(that, {
|
||||
templet: templet
|
||||
}, value, data));
|
||||
td.data('content', value);
|
||||
}
|
||||
var td = tr.children('td[data-field="'+ key +'"]')
|
||||
,cell = td.children(ELEM_CELL); //获取当前修改的列
|
||||
|
||||
//更新缓存中的数据
|
||||
if(key in data) data[key] = value;
|
||||
|
||||
that.eachCols(function(i, item3){
|
||||
var templet = item3.templet || item3.toolbar;
|
||||
|
||||
//更新相应列视图
|
||||
if(item3.field == key && item3.templet){
|
||||
cell.html(parseTempData.call(that, {
|
||||
item3: {templet: item3.templet}
|
||||
,content: value
|
||||
,tplData: data
|
||||
}));
|
||||
td.data('content', value);
|
||||
} else if(templet){ //更新所有其他列的模板
|
||||
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}
|
||||
,content: content
|
||||
,tplData: data
|
||||
}));
|
||||
thisTd.data('content', content);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}, sets);
|
||||
|
@ -1645,8 +1676,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
});
|
||||
othis.siblings(ELEM_CELL).html(function(value){
|
||||
return parseTempData.call(that, {
|
||||
templet: templet
|
||||
}, value, data);
|
||||
item3: {templet: templet}
|
||||
,content: value
|
||||
,tplData: data
|
||||
});
|
||||
}(thisElem.value));
|
||||
othis.parent().data('content', thisElem.value);
|
||||
othis.remove();
|
||||
|
@ -1904,7 +1937,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
,data = table.cache[id] || [];
|
||||
//计算全选个数
|
||||
layui.each(data, function(i, item){
|
||||
if(layui._typeof(item) === 'array'){
|
||||
if(layui.type(item) === 'array'){
|
||||
invalidNum++; //无效数据,或已删除的
|
||||
return;
|
||||
}
|
||||
|
@ -1924,7 +1957,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
var arr = []
|
||||
,data = table.cache[id] || [];
|
||||
layui.each(data, function(i, item){
|
||||
if(layui._typeof(item) === 'array'){
|
||||
if(layui.type(item) === 'array'){
|
||||
return;
|
||||
};
|
||||
arr.push(table.clearCacheKey(item));
|
||||
|
@ -1950,7 +1983,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
if(device.ie) return hint.error('IE_NOT_SUPPORT_EXPORTS');
|
||||
|
||||
alink.href = 'data:'+ textType +';charset=utf-8,\ufeff'+ encodeURIComponent(function(){
|
||||
var dataTitle = [], dataMain = [], dataTotal = [];
|
||||
var dataTitle = []
|
||||
,dataMain = []
|
||||
,dataTotal = []
|
||||
,fieldsIsHide = {};
|
||||
|
||||
//表头和表体
|
||||
layui.each(data, function(i1, item1){
|
||||
|
@ -1964,12 +2000,30 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
});
|
||||
} else {
|
||||
table.eachCols(id, function(i3, item3){
|
||||
if(item3.field && item3.type == 'normal' && !item3.hide){
|
||||
var content = item1[item3.field];
|
||||
if(item3.field && item3.type == 'normal'){
|
||||
//不导出隐藏列
|
||||
if(item3.hide){
|
||||
if(i1 == 0) fieldsIsHide[item3.field] = true; //记录隐藏列
|
||||
return;
|
||||
}
|
||||
|
||||
var content = item1[item3.field]
|
||||
,td = that.layBody.find('tr[data-index="'+ i1 +'"]>td');
|
||||
|
||||
if(content === undefined || content === null) content = '';
|
||||
|
||||
i1 == 0 && dataTitle.push(item3.title || '');
|
||||
vals.push('"'+ parseTempData.call(thatTable, item3, content, item1, 'text') + '"');
|
||||
vals.push('"'+ parseTempData.call(thatTable, {
|
||||
item3: item3
|
||||
,content: content
|
||||
,tplData: item1
|
||||
,text: 'text'
|
||||
,obj: thatTable.commonMember.call(td.eq(0), {
|
||||
td: function(field){
|
||||
return td.filter('[data-field="'+ field +'"]');
|
||||
}
|
||||
})
|
||||
}) + '"');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1978,7 +2032,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
|
|||
|
||||
//表合计
|
||||
layui.each(that.dataTotal, function(key, value){
|
||||
dataTotal.push(value);
|
||||
fieldsIsHide[key] || dataTotal.push(value);
|
||||
});
|
||||
|
||||
return dataTitle.join(',') + '\r\n' + dataMain.join('\r\n') + '\r\n' + dataTotal.join(',');
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
/**
|
||||
|
||||
@Name:transfer 穿梭框组件
|
||||
@License:MIT
|
||||
|
||||
* transfer 穿梭框组件
|
||||
*/
|
||||
|
||||
layui.define(['laytpl', 'form'], function(exports){
|
||||
|
@ -171,7 +168,11 @@ layui.define(['laytpl', 'form'], function(exports){
|
|||
});
|
||||
that.layData.css({
|
||||
height: function(){
|
||||
return options.height - that.layHeader.outerHeight() - that.laySearch.outerHeight() - 2
|
||||
var height = options.height - that.layHeader.outerHeight();
|
||||
if(options.showSearch){
|
||||
height -= that.laySearch.outerHeight();
|
||||
}
|
||||
return height - 2;
|
||||
}()
|
||||
});
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
/**
|
||||
|
||||
@Name:tree 树组件
|
||||
@License:MIT
|
||||
|
||||
* tree 树组件
|
||||
*/
|
||||
|
||||
layui.define('form', function(exports){
|
||||
|
@ -101,7 +98,7 @@ layui.define('form', function(exports){
|
|||
var that = this;
|
||||
|
||||
layui.each(options, function(key, item){
|
||||
if(layui._typeof(item) === 'array') delete that.config[key];
|
||||
if(layui.type(item) === 'array') delete that.config[key];
|
||||
});
|
||||
|
||||
that.config = $.extend(true, {}, that.config, options);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
/*!
|
||||
* upload 文件上传组件
|
||||
* MIT Licensed
|
||||
/**
|
||||
* upload
|
||||
* 文件上传组件
|
||||
*/
|
||||
|
||||
layui.define('layer' , function(exports){
|
||||
|
@ -63,6 +62,7 @@ layui.define('layer' , function(exports){
|
|||
,auto: true //是否选完文件后自动上传
|
||||
,bindAction: '' //手动上传触发的元素
|
||||
,url: '' //上传地址
|
||||
,force: '' //强制规定返回的数据格式,目前只支持是否强制 json
|
||||
,field: 'file' //文件字段名
|
||||
,acceptMime: '' //筛选出的文件类型,默认为所有文件
|
||||
,method: 'post' //请求上传的 http 类型
|
||||
|
@ -218,9 +218,9 @@ layui.define('layer' , function(exports){
|
|||
allDone();
|
||||
}
|
||||
//异常回调
|
||||
,error: function(){
|
||||
,error: function(e){
|
||||
aborted++;
|
||||
that.msg('请求上传接口出现异常');
|
||||
that.msg('Request URL is abnormal: '+ (e.statusText || 'error'));
|
||||
error(index);
|
||||
allDone();
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ layui.define('layer' , function(exports){
|
|||
try {
|
||||
res = iframeBody.text();
|
||||
} catch(e) {
|
||||
that.msg('获取上传后的响应信息出现异常');
|
||||
that.msg('Cross-domain requests are not supported');
|
||||
clearInterval(Class.timer);
|
||||
error();
|
||||
}
|
||||
|
@ -272,14 +272,18 @@ layui.define('layer' , function(exports){
|
|||
,done = function(index, res){
|
||||
that.elemFile.next('.'+ ELEM_CHOOSE).remove();
|
||||
elemFile.value = '';
|
||||
if(typeof res !== 'object'){
|
||||
try {
|
||||
res = JSON.parse(res);
|
||||
} catch(e){
|
||||
res = {};
|
||||
return that.msg('请对上传接口返回有效JSON');
|
||||
|
||||
if(options.force === 'json'){
|
||||
if(typeof res !== 'object'){
|
||||
try {
|
||||
res = JSON.parse(res);
|
||||
} catch(e){
|
||||
res = {};
|
||||
return that.msg('Please return JSON data format');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typeof options.done === 'function' && options.done(res, index || 0, function(files){
|
||||
that.upload(files);
|
||||
});
|
||||
|
@ -352,6 +356,14 @@ layui.define('layer' , function(exports){
|
|||
|
||||
ajaxSend();
|
||||
}
|
||||
|
||||
//文件类型名称
|
||||
,typeName = ({
|
||||
file: '文件'
|
||||
,images: '图片'
|
||||
,video: '视频'
|
||||
,audio: '音频'
|
||||
})[options.accept] || '文件';
|
||||
|
||||
//校验文件格式
|
||||
value = value.length === 0
|
||||
|
@ -359,39 +371,45 @@ layui.define('layer' , function(exports){
|
|||
: value;
|
||||
|
||||
if(value.length === 0) return;
|
||||
|
||||
|
||||
//根据文件类型校验
|
||||
switch(options.accept){
|
||||
case 'file': //一般文件
|
||||
if(exts && !RegExp('\\w\\.('+ exts +')$', 'i').test(escape(value))){
|
||||
that.msg('选择的文件中包含不支持的格式');
|
||||
return elemFile.value = '';
|
||||
}
|
||||
layui.each(value, function(i, item){
|
||||
if(exts && !RegExp('.\\.('+ exts +')$', 'i').test(escape(item))){
|
||||
return check = true;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'video': //视频文件
|
||||
if(!RegExp('\\w\\.('+ (exts || 'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(value))){
|
||||
that.msg('选择的视频中包含不支持的格式');
|
||||
return elemFile.value = '';
|
||||
}
|
||||
layui.each(value, function(i, item){
|
||||
if(!RegExp('.\\.('+ (exts || 'avi|mp4|wma|rmvb|rm|flash|3gp|flv') +')$', 'i').test(escape(item))){
|
||||
return check = true;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'audio': //音频文件
|
||||
if(!RegExp('\\w\\.('+ (exts || 'mp3|wav|mid') +')$', 'i').test(escape(value))){
|
||||
that.msg('选择的音频中包含不支持的格式');
|
||||
return elemFile.value = '';
|
||||
}
|
||||
layui.each(value, function(i, item){
|
||||
if(!RegExp('.\\.('+ (exts || 'mp3|wav|mid') +')$', 'i').test(escape(item))){
|
||||
return check = true;
|
||||
}
|
||||
});
|
||||
break;
|
||||
default: //图片文件
|
||||
layui.each(value, function(i, item){
|
||||
if(!RegExp('\\w\\.('+ (exts || 'jpg|png|gif|bmp|jpeg$') +')', 'i').test(escape(item))){
|
||||
check = true;
|
||||
if(!RegExp('.\\.('+ (exts || 'jpg|png|gif|bmp|jpeg') +')$', 'i').test(escape(item))){
|
||||
return check = true;
|
||||
}
|
||||
});
|
||||
if(check){
|
||||
that.msg('选择的图片中包含不支持的格式');
|
||||
return elemFile.value = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//校验失败提示
|
||||
if(check){
|
||||
that.msg('选择的'+ typeName +'中包含不支持的格式');
|
||||
return elemFile.value = '';
|
||||
}
|
||||
|
||||
//检验文件数量
|
||||
that.fileLength = function(){
|
||||
var length = 0
|
||||
|
@ -401,8 +419,9 @@ layui.define('layer' , function(exports){
|
|||
});
|
||||
return length;
|
||||
}();
|
||||
|
||||
if(options.number && that.fileLength > options.number){
|
||||
return that.msg('同时最多只能上传的数量为:'+ options.number);
|
||||
return that.msg('同时最多只能选择 '+ options.number + ' 个文件');
|
||||
}
|
||||
|
||||
//检验文件大小
|
||||
|
@ -417,7 +436,7 @@ layui.define('layer' , function(exports){
|
|||
limitSize = size;
|
||||
}
|
||||
});
|
||||
if(limitSize) return that.msg('文件不能超过'+ limitSize);
|
||||
if(limitSize) return that.msg('文件大小不能超过 '+ limitSize);
|
||||
}
|
||||
send();
|
||||
};
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
/*!
|
||||
/**
|
||||
* util 工具组件
|
||||
*/
|
||||
*/
|
||||
|
||||
layui.define('jquery', function(exports){
|
||||
"use strict";
|
||||
|
@ -172,14 +171,18 @@ layui.define('jquery', function(exports){
|
|||
|
||||
//转义 html,防 xss 攻击
|
||||
,escape: function(html){
|
||||
return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&')
|
||||
if(html === undefined || html === null) html = '';
|
||||
html += '';
|
||||
return html.replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&')
|
||||
.replace(/</g, '<').replace(/>/g, '>')
|
||||
.replace(/'/g, ''').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
//还原转义的 html
|
||||
,unescape: function(str){
|
||||
return String(str || '').replace(/\&/g, '&')
|
||||
if(html === undefined || html === null) html = '';
|
||||
html += '';
|
||||
return html.replace(/\&/g, '&')
|
||||
.replace(/\</g, '<').replace(/\>/g, '>')
|
||||
.replace(/\'/, '\'').replace(/\"/, '"');
|
||||
}
|
||||
|
@ -237,6 +240,8 @@ layui.define('jquery', function(exports){
|
|||
return obj;
|
||||
}
|
||||
};
|
||||
|
||||
util.on = util.event;
|
||||
|
||||
// DOM 尺寸变化,该创意来自:http://benalman.com/projects/jquery-resize-plugin/
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue