Merge branch 'layui:main' into master

This commit is contained in:
Lawrence Peng 2022-06-17 14:24:21 +08:00 committed by GitHub
commit 89bc721fe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 1249 additions and 1090 deletions

11
.gitignore vendored
View File

@ -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/
/release/
/v/
package-lock.json

View File

@ -1,3 +1,3 @@
# 更新日志
https://github.com/sentsin/layui/releases
https://github.com/layui/layui/releases

14
DISCLAIMER.md Normal file
View File

@ -0,0 +1,14 @@
# Layui 《免责声明》
> 任何用户在使用由 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. 本团队有权随时对本声明条款及附件内容进行单方面的变更,并以消息推送、网页公告等方式予以公布,公布后立即自动生效,无需另行单独通知;若您在本声明内容公告变更后继续使用的,表示您已充分阅读、理解并接受修改后的声明内容。

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017 layui
Copyright (c) 2016 layui
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,88 +1,58 @@
<p align="center">
<a href="http://www.layui.com">
<img src="https://sentsin.gitee.io/res/images/layui/layui.png" alt="layui" width="360">
<a href="https://layui.github.io/">
<img src="https://unpkg.com/outeres@0.0.6/img/layui/icon-1.png" width="81" alt="Layui">
</a>
</p>
<h1 align="center">Layui</h1>
<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 定义为「经典模块化」,并非是自吹她自身有多优秀,而是有意避开当下 JS 社区的主流方案,试图以最简单的方式去诠释高效!<em>她的所谓经典,是在于对返璞归真的执念</em>,她以当前浏览器普通认可的方式去组织模块!我们认为,这恰是符合当下国内绝大多数程序员从旧时代过渡到未来新标准的最佳指引。所以 layui 本身也并不是完全遵循于 AMD 时代,准确地说,她试图建立自己的模式,所以你会看到:
```js
//layui 模块的定义
layui.define([mods], function(exports){
//……
exports('mod', api);
});
//layui模块的使用
layui.use(['mod1', 'mod2'], function(args){
var mod = layui.mod1;
//……
});
```
没错,她具备 AMD 的影子,又并非受限于 CommonJS 的那些条条框框layui 认为这种轻量的组织方式,比 WebPack 更符合绝大多数场景。所以她坚持采用经典模块化,也正是能让人避开工具的复杂配置,回归简单,安静高效地编织原生态的 HTML/CSS/JS。
但是 layui 又并非是 RequireJS 那样的模块加载器,而是一款 UI 解决方案,她与 Bootstrap 最大的不同恰恰在于她糅合了自身对经典模块化的理解。这使得你可以在 layui 组织的框架之内,以更具可维护性的代码、去更好的编织丰富的用户界面。
layui 是一套开源的 Web UI 组件库,采用自身经典的模块化规范,并遵循原生 HTML/CSS/JS 的开发方式极易上手拿来即用。其风格简约轻盈而组件优雅丰盈从源代码到使用方法的每一处细节都经过精心雕琢非常适合网页界面的快速开发。layui 区别于那些基于 MVVM 底层的前端框架,却并非逆道而行,而是信奉返璞归真之道。准确地说,它更多是面向后端开发者,你无需涉足前端的各种工具,只需面对浏览器本身,让一切你所需要的元素与交互,从这里信手拈来。
## 快速上手
获得 layui 后,将其完整地部署到你的静态资源项目目录,你只需要引入下述两个文件:
```
./layui/css/layui.css
./layui/layui.js
```
这是一个基本的入门页面:
```html
<!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="../layui/css/layui.css">
<link rel="stylesheet" href="./layui/css/layui.css">
</head>
<body>
<!-- 你的 HTML 代码 -->
<script src="../layui/layui.js"></script>
<script src="./layui/layui.js"></script>
<script>
//一般直接写在一个 js 文件中
layui.use(['layer', 'form'], function(){
var layer = layui.layer
,form = layui.form;
//欢迎语
layer.msg('Hello World');
});
</script>
@ -91,16 +61,15 @@ layui.use(['layer', 'form'], function(){
```
## 阅读文档
[**最新文档**](https://gitee.com/layui)
[**最新文档**](https://layui.github.io/)
愿 layui 能成为你得心应手的 Web 界面解决方案,化作你方寸屏幕前的亿万字节!
## 贡献者
> 大概是因为 layui 让开发者变得更懒,所以贡献者才如此之少。
[贡献者列表](https://github.com/sentsin/layui/graphs/contributors)
[贡献者列表](https://github.com/layui/layui/graphs/contributors)
## 相关
> layui 官网已于2021年10月13日下线。
## 破旧立新
layui 原官网已于2021年10月13日下线。详见
> 1. <a href="https://unpkg.com/outeres@0.0.7/img/layui/notice-2021.png" target="_blank">layui 原官网下线公告</a> 2. <a href="https://www.zhihu.com/question/488668647/answer/2159962082" target="_blank">layui 原官网为什么要下线?</a>
目前包括版本更新、文档等在内的所有日常维护,都以 Github 或 Gitee 项目主页为准
鉴于 layui 相对庞大的受众群体,从此 Github 和 Gitee 平台将支撑起 layui 的后续,**它将继续陪伴着仍然需要它的人**

2
dist/css/layui.css vendored

File diff suppressed because one or more lines are too long

View File

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

6
dist/layui.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +0,0 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
URL=https://gitee.com/sentsin/layui/
IDList=
HotKey=0

View File

@ -1,6 +0,0 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
URL=https://github.com/sentsin/layui/
IDList=
HotKey=0

View File

@ -1,9 +0,0 @@
# 注意事项:
* 页面的 HTML 代码必须是 `<!DOCTYPE html>` 开头
* 除 IE6、7 外,所有浏览器均支持
# 在线文档
[https://www.layui.com/doc/](https://www.layui.com/doc/)
# 仓库地址
[Github](https://github.com/sentsin/layui/) | [Gitee](https://gitee.com/sentsin/layui) | [NPM](https://www.npmjs.com/package/layui-src)

View File

@ -1,8 +0,0 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://www.layui.com/demo/
IDList=
HotKey=0
IconIndex=0
IconFile=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

View File

@ -1,8 +0,0 @@
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,2
[InternetShortcut]
URL=http://www.layui.com/doc/
IDList=
HotKey=0
IconIndex=0
IconFile=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

View File

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

View File

@ -131,8 +131,17 @@ body{padding:20px;}
<br><br>
<blockquote class="layui-elem-quote"> Layui 正是你苦苦寻找的前端UI框架</blockquote>
<blockquote class="layui-elem-quote layui-quote-nm"> Layui 正是你苦苦寻找的前端UI框架 Layui 正是你苦苦寻找的前端UI框架 Layui 正是你苦苦寻找的前端UI框架 Layui 正是你苦苦寻找的前端UI框架 Layui 正是你苦苦寻找的前端UI框架</blockquote>
<blockquote class="layui-elem-quote layui-text">
<p>Layui - 原生态模块化前端 UI 组件库</p>
<p>Layui - 原生态模块化前端 UI 组件库</p>
</blockquote>
<blockquote class="layui-elem-quote layui-quote-nm">
Layui - 原生态模块化前端 UI 组件库
Layui - 原生态模块化前端 UI 组件库
Layui - 原生态模块化前端 UI 组件库
Layui - 原生态模块化前端 UI 组件库
Layui - 原生态模块化前端 UI 组件库
</blockquote>
<fieldset class="layui-elem-field">
<legend>字段集区块 - 默认风格</legend>

View File

@ -8,8 +8,8 @@
,"data": [{
"id": "10001"
,"username": "杜甫"
,"email": "test@email.com"
,"sex": "男"
,"email": "test1@email.com"
,"sex": "<strong></strong>"
,"city": "浙江杭州"
,"sign": "鼠标移动到此处,可以通过点击单元格右侧的下拉图标,查看到被隐藏的全部内容。"
,"experience": 7
@ -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": "人生恰似一场修行"

View File

@ -1,5 +1,3 @@
<!DOCTYPE html>
<html>
<head>
@ -18,12 +16,31 @@ body{padding: 50px 100px;}
</head>
<body>
日期时间范围选择:
范围选择1
<div class="layui-inline">
<input type="text" class="layui-input" id="test1">
</div>
<br><br><hr><br>
<br><hr>
<div class="layui-form">
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">范围选择2</label>
<div class="layui-inline" id="test1-2">
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="test-startDate-1" class="layui-input" placeholder="开始日期">
</div>
<div class="layui-form-mid">-</div>
<div class="layui-input-inline">
<input type="text" autocomplete="off" id="test-endDate-1" class="layui-input" placeholder="结束日期">
</div>
</div>
</div>
</div>
</div>
<br><hr>
日期选择器:
<div class="layui-inline">
@ -97,7 +114,7 @@ body{padding: 50px 100px;}
<div class="layui-inline">
<input type="text" class="layui-input" id="test6">
</div>
<textarea></textarea>
<button class="layui-btn" id="test9">外部事件触发</button>
<div class="layui-inline">
<input type="text" class="layui-input" id="test8">
@ -118,7 +135,7 @@ layui.use('laydate', function(laydate){
//trigger: 'focus'
})
//双控件
//范围选择1
laydate.render({
elem: '#test1' //指定元素
,type: 'datetime'
@ -126,12 +143,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);
@ -139,6 +158,16 @@ layui.use('laydate', function(laydate){
});
//return;
//范围选择2
laydate.render({
elem: '#test1-2'
,type: 'date'
,range: ['#test-startDate-1', '#test-endDate-1']
//,value: ['2022-05-01', '2022-06-01']
//,value: '2022-05-01 - 2022-06-01'
});
//单控件
laydate.render({
@ -157,6 +186,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);
@ -169,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);
}
@ -183,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

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

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));
});
});
}

226
examples/laytpl.html Normal file
View File

@ -0,0 +1,226 @@
<!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>
<p>转义输出(HTML){{= d.desc }}</p>
<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=\"\" style=\"color:blue;\">一段描述</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>

View File

@ -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,10 @@
<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>
{{# } }}
<input type="checkbox" name="demoTableSwitch" lay-skin="switch" {{ d.demoTableSwitch }}>
</script>
<script type="text/html" id="usernameTpl">
@ -44,7 +53,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 +76,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 +101,7 @@ layui.use(['table', 'dropdown'], function(){
,title: '用户数据表'
,url: 'json/table/demo1.json'
//,size: 'lg'
//,skin: 'line'
//,autoSort: false //是否自动排序。如果否,则由服务端排序
//,loading: false
,totalRow: true
@ -102,22 +112,36 @@ layui.use(['table', 'dropdown'], function(){
,layEvent: 'LAYTABLE_TIPS'
,icon: 'layui-icon-tips'
}]
,cols: [[
//,escape: false
,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:'邮箱 <i class="layui-icon layui-icon-email"></i>', 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){
console.log(d)
return '<em>'+ d.email +'</em>'
,{field:'email', title:'邮箱 <i class="layui-icon layui-icon-email"></i>', hide: 0, width:150, edit: 'text', templet: function(d){
return '<em>'+ layui.util.escape(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}
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width: 180}
]]
,initSort1: {
@ -200,7 +224,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;
@ -209,7 +233,7 @@ layui.use(['table', 'dropdown'], function(){
case 'getData':
var getData = table.getData(obj.config.id);
console.log(getData);
layer.alert(JSON.stringify(getData));
layer.alert(layui.util.escape(JSON.stringify(getData)));
break;
case 'isAll':
layer.msg(checkStatus.isAll ? '全选': '未全选')
@ -254,12 +278,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>

View File

@ -15,37 +15,21 @@
</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">
<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>
@ -218,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'
@ -434,27 +235,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 +264,7 @@ layui.use(['table', 'dropdown'], function(){
console.log(obj)
});
//监听行工具事件
//触发行工具事件
table.on('tool(test)', function(obj){
var data = obj.data;
//console.log(obj)

View File

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

50
examples/text.md.html Normal file
View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>text for markdown - layui</title>
<link rel="stylesheet" href="../src/css/layui.css">
</head>
<body>
<div class="layui-container layui-row">
<div class="layui-col-md4 layui-text">
<h1>标题1</h1>
<h2>标题2</h2>
<h3>标题3</h3>
<h4>标题4</h4>
<h5>标题5</h5>
<h6>标题6</h6>
<p>段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1段落1 <sup class="footnote-ref"><a href="#ref-1">[1]</a></sup></p>
<p>段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2段落2</p>
<p>段落3段落3段落3段落3段落3段落3段落3段落3段落3段落3段落3段落3 <a href="">链接</a></p>
<ul>
<li>无序1</li>
<li>无序2</li>
<li>无序3</li>
</ul>
<ol>
<li>有序1</li>
<li>有序2</li>
<li>有序3</li>
</ol>
<br>
<blockquote>
<p>引用</p>
<blockquote>内嵌引用<blockquote>内嵌引用</blockquote></blockquote>
</blockquote>
<br>
<pre>
var cp = function(){
return gulp.src('./dist/**/*')
.pipe(gulp.dest(dest));
};</pre>
<p id="ref-1">REF-1</p>
</div>
</div>
</body>
</html>

View File

@ -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">
@ -89,7 +89,7 @@ hr{margin: 30px 0;}
绑定原始文件域:<input type="file" name="file" id="test9">
<script src="../src/layui.js"></script>
<script src="../src/layui.js" src1="https://cdn.staticfile.org/layui/2.6.8/layui.js"></script>
<script>
layui.use(['upload', 'element'], function(){
var $ = layui.jquery
@ -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
@ -123,16 +123,16 @@ layui.use(['upload', 'element'], function(){
layer.msg('不允许上传')
return false;
}
,done: function(res){
,done: function(res, index){
//如果上传失败
if(res.code > 0){
return layer.msg('上传失败');
}
//上传成功
console.log(res);
console.log(res, index);
}
,error: function(){
,error: function(index, upload){
this.item.html('重选上传');
//演示失败状态,并实现重传
@ -145,7 +145,7 @@ layui.use(['upload', 'element'], function(){
element.progress('demo', '0%');
}
,progress: function(n, elem, res, index){
console.log(n + '%', elem, res); //获取进度百分比
console.log(n + '%', elem, res, index); //获取进度百分比
element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
}
});
@ -158,19 +158,25 @@ layui.use(['upload', 'element'], function(){
//,size: 2
});
// 演示多图片上传
upload.render({
elem: '#test2'
,url: 'https://httpbin.org/post'
,multiple: true
,number: 3
,accept: 'images'
,number: 3 //同时上传的数量
,size: 1024
,before: function(obj){
//预读本地文件示例不支持ie8
obj.preview(function(index, file, result){
$('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
});
//this.files = obj.pushFile();
}
,done: function(res){
,done: function(res, index){
//上传完毕
//console.log(this.files)
}
,allDone: function(obj){
console.log(obj)
@ -181,7 +187,7 @@ layui.use(['upload', 'element'], function(){
var demoListView = $('#demoList');
var uploadListIns = upload.render({
elem: '#testList'
,url: 'http://httpbin.org/post'
,url: 'https://httpbin.org/post'
,accept: 'file'
,multiple: true
,number: 3
@ -189,9 +195,8 @@ layui.use(['upload', 'element'], function(){
,bindAction: '#testListAction'
,choose: function(obj){
var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
//读取本地文件
obj.preview(function(index, file, result){
obj.preview(function(index, file, result){
var tr = $(['<tr id="upload-'+ index +'">'
,'<td>'+ file.name +'</td>'
,'<td>'+ (file.size/1014).toFixed(1) +'kb</td>'
@ -300,11 +305,11 @@ layui.use(['upload', 'element'], function(){
,auto: false
//,multiple: true
,bindAction: '#test7'
,choose1: function(obj){
,choose: function(obj){
var that = this;
obj.preview(function(index, file){
console.log(file.name);
obj.resetFile(index, file, '123.jpg');
//obj.resetFile(index, file, '123.jpg');
});
}
,before: function(){
@ -317,7 +322,7 @@ layui.use(['upload', 'element'], function(){
upload.render({
elem: '#test8'
,url: 'http://httpbin.org/post'
,url: 'https://httpbin.org/post'
,done: function(res){
console.log(res);
}

View File

@ -1,187 +1,171 @@
/**
* Building Layui
*/
/*!
* layui Build
*/
const pkg = require('./package.json');
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const cleanCSS = require('gulp-clean-css');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const replace = require('gulp-replace');
const header = require('gulp-header');
const footer = require('gulp-footer');
const del = require('del');
const minimist = require('minimist');
const yargs = require('yargs');
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 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 argv = require('minimist')(process.argv.slice(2), {
default: {
ver: 'all'
}
})
//注释
,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));
}
// 基础配置
const 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,layedit,code'
};
//清理
gulp.task('clear', function(cb) {
return del(['./'+ (argv.rc ? 'rc' : 'dist') +'/*'], cb);
});
gulp.task('clearRelease', function(cb) {
return del([releaseDir], cb);
});
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);
//完整任务 gulp
gulp.task('default', ['clear'], function(){ //rc 版gulp --rc
for(var key in task){
task[key]();
// 获取参数
const argv = require('minimist')(process.argv.slice(2), {
default: {
version: pkg.version
}
});
//发行版 gulp rls
gulp.task('rls', ['clearRelease'], function(){ // gulp rls
for(var key in task){
task[key]('release');
}
});
// 前置目录
const dir = {
rls: './release/zip/layui-v' + pkg.version
};
//打包 layer 单独版
gulp.task('layer', function(){
var dir = './release/layer';
// 输出目录
const dest = ({
dist: './dist'
,rls: dir.rls + '/layui'
}[argv.dest || 'dist'] || argv.dest) + (argv.vs ? '/'+ pkg.version : '');
// js
const js = () => {
let 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
const css = () => {
let 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
const files = () => {
let src = ['./src/**/*.{eot,svg,ttf,woff,woff2,html,json,png,jpg,gif}'];
return gulp.src(src)
.pipe(gulp.dest(dest));
};
// cp
const cp = () => {
return gulp.src('./dist/**/*')
.pipe(gulp.dest(dest));
};
// release
const rls = () => {
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));
};
// clean
const clean = cb => {
return del([dest], {
force: true
});
};
const cleanRLS = cb => {
return del([dir.rls]);
};
// 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.cp = gulp.series(clean, cp);
exports.rls = gulp.series(cleanRLS, rls); //release task
// layer task
exports.layer = () => { // gulp layer
let 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 = () => { // gulp laydate
let dest = './release/laydate/'; // 发行目录
let 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'));
};
// helper
exports.help = () => {
let usage = '\nUsage: gulp [options] tasks';
let parser = yargs.usage(usage, {
dest: {
type: 'string'
,desc: '定义输出目录可选项dist默认、rls、任意路径'
}
,vs: {
type: 'boolean'
,desc: '生成一个带版本号的文件夹'
}
});
parser.showHelp(console.log);
console.log([
'Tasks:'
,' default 默认任务'
,' rls 发行任务'
,' cp 将 dist 目录复制一份到参数 --dest 指向的目录'
].join('\n'), '\n\nExamples:\n gulp cp --dest ./v --vs', '\n');
return gulp.src('./');
};

View File

@ -1,49 +1,39 @@
{
"name": "layui",
"realname": "layui",
"version": "2.6.8",
"version": "2.6.13",
"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"
]
}

View File

@ -1,4 +1,3 @@
/**
* Layui
* Classic modular Front-End UI library
@ -243,7 +242,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 +263,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 +301,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 +311,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 +346,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 +381,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;}
@ -472,7 +472,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-progress-bar{position: absolute; left: 0; top: 0; width: 0; max-width: 100%; height: 6px; border-radius: 20px; text-align: right; background-color: #5FB878; transition: all .3s; -webkit-transition: all .3s;}
.layui-progress-big,
.layui-progress-big .layui-progress-bar{height: 18px; line-height: 18px;}
.layui-progress-text{position: relative; top: -20px; line-height: 18px; font-size: 12px; color: #666}
.layui-progress-text{position: relative; top: -20px; line-height: 18px; font-size: 12px; color: #5F5F5F}
.layui-progress-big .layui-progress-text{position: static; padding: 0 10px; color: #fff;}
@ -489,7 +489,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-colla-content{border-top-width: 1px; border-top-style: solid;}
.layui-colla-item:first-child{border-top: none;}
.layui-colla-title{position: relative; height: 42px; line-height: 42px; padding: 0 15px 0 35px; color: #333; background-color: #FAFAFA; cursor: pointer; font-size: 14px; overflow: hidden;}
.layui-colla-content{display: none; padding: 10px 15px; line-height: 1.6; color: #666;}
.layui-colla-content{display: none; padding: 10px 15px; line-height: 1.6; color: #5F5F5F;}
.layui-colla-icon{position: absolute; left: 15px; top: 0; font-size: 14px;}
/* 卡片面板 */
@ -503,7 +503,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-card .layui-tab{margin: 0;}
/* 常规面板 */
.layui-panel{position: relative; border-width: 1px; border-style: solid; border-radius: 2px; box-shadow: 1px 1px 4px rgb(0 0 0 / 8%); background-color: #fff; color: #666;}
.layui-panel{position: relative; border-width: 1px; border-style: solid; border-radius: 2px; box-shadow: 1px 1px 4px rgb(0 0 0 / 8%); background-color: #fff; color: #5F5F5F;}
/* 窗口面板 */
.layui-panel-window{position: relative; padding: 15px; border-radius: 0; border-top: 5px solid #eee; background-color: #fff;}
@ -525,8 +525,8 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-bg-green{background-color: #009688!important; color: #fff!important;} /*绿*/
.layui-bg-cyan{background-color: #2F4056!important; color: #fff!important;} /*青*/
.layui-bg-blue{background-color: #1E9FFF!important; color: #fff!important;} /*蓝*/
.layui-bg-black{background-color: #393D49!important; color: #fff!important;} /**/
.layui-bg-gray{background-color: #FAFAFA!important; color: #666!important;} /*灰*/
.layui-bg-black{background-color: #393D49!important; color: #fff!important;} /**/
.layui-bg-gray{background-color: #FAFAFA!important; color: #5F5F5F!important;} /*浅*/
/* 边框 */
.layui-border,
@ -547,7 +547,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-form-pane .layui-form-item[pane],
.layui-layedit, .layui-layedit-tool{border-color: #eee;}
.layui-border{border-width: 1px; border-style: solid; color: #666!important;}
.layui-border{border-width: 1px; border-style: solid; color: #5F5F5F!important;}
.layui-border-red{border-width: 1px; border-style: solid; border-color: #FF5722!important; color: #FF5722!important;}
.layui-border-orange{border-width: 1px; border-style: solid; border-color: #FFB800!important; color: #FFB800!important;}
.layui-border-green{border-width: 1px; border-style: solid; border-color: #009688!important; color: #009688!important;}
@ -559,21 +559,32 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-timeline-item:before{background-color: #eee;}
/* 文本区域 */
.layui-text{line-height: 1.6; font-size: 14px; color: #666;}
.layui-text{line-height: 1.6; font-size: 14px; color: #5F5F5F;}
.layui-text h1,
.layui-text h2,
.layui-text h3{font-weight: 500; color: #333;}
.layui-text h1{font-size: 30px;}
.layui-text h3,
.layui-text h4,
.layui-text h5,
.layui-text h6{font-weight: 500; color: #333;}
.layui-text h1{font-size: 32px;}
.layui-text h2{font-size: 24px;}
.layui-text h3{font-size: 18px;}
.layui-text h4{font-size: 16px;}
.layui-text h5{font-size: 14px;}
.layui-text h6{font-size: 13px;}
.layui-text a:not(.layui-btn){color: #01AAED;}
.layui-text a:not(.layui-btn):hover{text-decoration: underline;}
.layui-text ul{padding: 5px 0 5px 15px;}
.layui-text ul,
.layui-text ol{padding: 5px 0 5px 15px;}
.layui-text ul li{margin-top: 5px; list-style-type: disc;}
.layui-text ol li{margin-top: 5px; list-style-type: decimal;}
.layui-text em,
.layui-word-aux{color: #999 !important; padding-left: 5px !important; padding-right: 5px !important;}
.layui-text p{margin: 10px 0;}
.layui-text p{margin: 15px 0;}
.layui-text p:first-child{margin-top: 0;}
.layui-text p:last-child{margin-bottom: 0;}
.layui-text blockquote:not(.layui-elem-quote){padding: 5px 15px; border-left: 5px solid #eee;}
.layui-text pre:not(.layui-code){padding: 15px; font-family: Lucida Console,Consolas,Courier New; background-color: #FAFAFA;}
/* 字体大小及颜色 */
.layui-font-12{font-size: 12px !important;;}
@ -613,7 +624,7 @@ a cite{font-style: normal; *cursor:pointer;}
/* 圆角 */.layui-btn-radius{border-radius: 100px;}
.layui-btn .layui-icon{padding: 0 2px; vertical-align: middle\0; vertical-align: bottom;}
/* 原始 */.layui-btn-primary{border-color: #d2d2d2; background: none; color: #666;}
/* 原始 */.layui-btn-primary{border-color: #d2d2d2; background: none; color: #5F5F5F;}
.layui-btn-primary:hover{border-color: #009688; color: #333;}
/* 百搭 */.layui-btn-normal{background-color: #1E9FFF;}
/* 暖色 */.layui-btn-warm{background-color: #FFB800;}
@ -704,7 +715,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-form-item .layui-form-checkbox{margin-top: 4px;}
/* 复选框-原始风格 */.layui-form-checkbox[lay-skin="primary"]{height: auto!important; line-height: normal!important; min-width: 18px; min-height: 18px; border: none!important; margin-right: 0; padding-left: 28px; padding-right: 0; background: none;}
.layui-form-checkbox[lay-skin="primary"] span{padding-left: 0; padding-right: 15px; line-height: 18px; background: none; color: #666;}
.layui-form-checkbox[lay-skin="primary"] span{padding-left: 0; padding-right: 15px; line-height: 18px; background: none; color: #5F5F5F;}
.layui-form-checkbox[lay-skin="primary"] i{right: auto; left: 0; width: 16px; height: 16px; line-height: 16px; border: 1px solid #d2d2d2; font-size: 12px; border-radius: 2px; background-color: #fff; -webkit-transition: .1s linear; transition: .1s linear;}
.layui-form-checkbox[lay-skin="primary"]:hover i{border-color: #5FB878; color: #fff;}
.layui-form-checked[lay-skin="primary"] i{border-color: #5FB878 !important; background-color: #5FB878; color: #fff;}
@ -838,7 +849,7 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-flow-more a i{font-size: 30px; color: #737383;}
/** 表格 **/
.layui-table{width: 100%; margin: 10px 0; background-color: #fff; color: #666;}
.layui-table{width: 100%; margin: 10px 0; background-color: #fff; color: #5F5F5F;}
.layui-table tr{transition: all .3s; -webkit-transition: all .3s;}
.layui-table th{text-align: left; font-weight: 400;}
@ -887,7 +898,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,
@ -922,9 +933,9 @@ a cite{font-style: normal; *cursor:pointer;}
.layui-table-sort{width: 10px; height: 20px; margin-left: 5px; cursor: pointer!important;}
.layui-table-sort .layui-edge{position: absolute; left: 5px; border-width: 5px;}
.layui-table-sort .layui-table-sort-asc{top: 3px; border-top: none; border-bottom-style: solid; border-bottom-color: #b2b2b2;}
.layui-table-sort .layui-table-sort-asc:hover{border-bottom-color: #666;}
.layui-table-sort .layui-table-sort-asc:hover{border-bottom-color: #5F5F5F;}
.layui-table-sort .layui-table-sort-desc{bottom: 5px; border-bottom: none; border-top-style: solid; border-top-color: #b2b2b2;}
.layui-table-sort .layui-table-sort-desc:hover{border-top-color: #666;}
.layui-table-sort .layui-table-sort-desc:hover{border-top-color: #5F5F5F;}
.layui-table-sort[lay-sort="asc"] .layui-table-sort-asc{border-bottom-color: #000;}
.layui-table-sort[lay-sort="desc"] .layui-table-sort-desc{border-top-color: #000;}
@ -987,8 +998,8 @@ select.layui-table-edit{padding: 0 0 0 10px; border-color: #d2d2d2;}
.layui-table-grid-down:hover{background-color: #fbfbfb;}
body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-shadow: 0 1px 6px rgba(0,0,0,.12);}
.layui-table-tips-main{margin: -44px 0 0 -1px; max-height: 150px; padding: 8px 15px; font-size: 14px; overflow-y: scroll; background-color: #fff; color: #666;}
.layui-table-tips-c{position: absolute; right: -3px; top: -13px; width: 20px; height: 20px; padding: 3px; cursor: pointer; background-color: #666; border-radius: 50%; color: #fff;}
.layui-table-tips-main{margin: -44px 0 0 -1px; max-height: 150px; padding: 8px 15px; font-size: 14px; overflow-y: scroll; background-color: #fff; color: #5F5F5F;}
.layui-table-tips-c{position: absolute; right: -3px; top: -13px; width: 20px; height: 20px; padding: 3px; cursor: pointer; background-color: #5F5F5F; border-radius: 50%; color: #fff;}
.layui-table-tips-c:hover{background-color: #777;}
.layui-table-tips-c:before{position: relative; right: -2px;}
@ -1061,7 +1072,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
/* 下拉菜单 */
.layui-dropdown{position: absolute; left: -999999px; top: -999999px; z-index: 66666666; margin: 5px 0; min-width: 100px;}
.layui-dropdown{position: absolute; left: -999999px; top: -999999px; z-index: 77777777; margin: 5px 0; min-width: 100px;}
.layui-dropdown:before{content:""; position: absolute; width: 100%; height: 6px; left: 0; top: -6px;}
@ -1087,7 +1098,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
.layui-nav-child{display: none; position: absolute; left: 0; top: 65px; min-width: 100%; line-height: 36px; padding: 5px 0; box-shadow: 0 2px 4px rgba(0,0,0,.12); border: 1px solid #eee; background-color: #fff; z-index: 100; border-radius: 2px; white-space: nowrap;}
.layui-nav .layui-nav-child a{color: #666; color: rgba(0,0,0,.8);}
.layui-nav .layui-nav-child a{color: #5F5F5F; color: rgba(0,0,0,.8);}
.layui-nav .layui-nav-child a:hover{background-color: #F6F6F6; color: rgba(0,0,0,.8);}
.layui-nav-child dd{margin: 1px 0; position: relative;}
.layui-nav-child dd.layui-this{background-color: #F6F6F6; color: #000;}
@ -1131,7 +1142,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
.layui-breadcrumb>*{font-size: 14px;}
.layui-breadcrumb a{color: #999 !important;}
.layui-breadcrumb a:hover{color: #5FB878 !important;}
.layui-breadcrumb a cite{color: #666; font-style: normal;}
.layui-breadcrumb a cite{color: #5F5F5F; font-style: normal;}
.layui-breadcrumb span[lay-separator]{margin: 0 10px; color: #999;}
/** Tab 选项卡 **/
@ -1189,7 +1200,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
.layui-badge-rim{position:relative; display: inline-block; padding: 0 6px; font-size: 12px; text-align: center; background-color: #FF5722; color: #fff; border-radius: 2px;}
.layui-badge{height: 18px; line-height: 18px;}
.layui-badge-dot{width: 8px; height: 8px; padding: 0; border-radius: 50%;}
.layui-badge-rim{height: 18px; line-height: 18px; border-width: 1px; border-style: solid; background-color: #fff; color: #666;}
.layui-badge-rim{height: 18px; line-height: 18px; border-width: 1px; border-style: solid; background-color: #fff; color: #5F5F5F;}
.layui-btn .layui-badge,
.layui-btn .layui-badge-dot{margin-left: 5px;}
@ -1266,7 +1277,7 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
/** 表情面板 **/
body .layui-util-face{border: none; background: none;}
body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; color:#666; box-shadow:none}
body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; color:#5F5F5F; box-shadow:none}
.layui-util-face .layui-layer-TipsG{display:none;}
.layui-util-face ul{position:relative; width:372px; padding:10px; border:1px solid #D9D9D9; background-color:#fff; box-shadow: 0 0 20px rgba(0,0,0,.2);}
.layui-util-face ul li{cursor: pointer; float: left; border: 1px solid #e8e8e8; height: 22px; width: 26px; overflow: hidden; margin: -1px 0 0 -1px; padding: 4px 2px; text-align: center;}
@ -1284,7 +1295,7 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
.layui-transfer-header{height: 38px; line-height: 38px; padding: 0 10px; border-bottom-width: 1px;}
.layui-transfer-search{position:relative; padding: 10px; border-bottom-width: 1px;}
.layui-transfer-search .layui-input{height: 32px; padding-left: 30px; font-size: 12px;}
.layui-transfer-search .layui-icon-search{position: absolute; left: 20px; top: 50%; margin-top: -8px; color: #666;}
.layui-transfer-search .layui-icon-search{position: absolute; left: 20px; top: 50%; margin-top: -8px; color: #5F5F5F;}
.layui-transfer-active{margin: 0 15px; display: inline-block; vertical-align: middle;}
.layui-transfer-active .layui-btn{display: block; margin: 0; padding: 0 15px; background-color: #5FB878; border-color: #5FB878; color: #fff;}
.layui-transfer-active .layui-btn-disabled{background-color: #FBFBFB; border-color: #eee; color: #d2d2d2;}
@ -1316,7 +1327,7 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
.layui-colorpicker-trigger-i{display: inline-block; color: #FFF; font-size: 12px;}
.layui-colorpicker-trigger-i.layui-icon-close{color: #999;}
.layui-colorpicker-main{position: absolute; left: -999999px; top: -999999px; z-index: 66666666; width: 280px; margin: 5px 0; padding: 7px; background: #FFF; border: 1px solid #d2d2d2; border-radius: 2px; box-shadow: 0 2px 4px rgba(0,0,0,.12);}
.layui-colorpicker-main{position: absolute; left: -999999px; top: -999999px; z-index: 77777777; width: 280px; margin: 5px 0; padding: 7px; background: #FFF; border: 1px solid #d2d2d2; border-radius: 2px; box-shadow: 0 2px 4px rgba(0,0,0,.12);}
.layui-colorpicker-main-wrapper{height: 180px; position: relative;}
.layui-colorpicker-basis{width: 260px; height: 100%; position: relative;}
.layui-colorpicker-basis-white{width: 100%; height: 100%; position: absolute; top: 0; left: 0; background: linear-gradient(90deg, #FFF, hsla(0,0%,100%,0));}
@ -1336,7 +1347,7 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
.layui-colorpicker-main-input{text-align: right; padding-top: 7px;}
.layui-colorpicker-main-input .layui-btn-container .layui-btn{margin: 0 0 0 10px;}
.layui-colorpicker-main-input div.layui-inline{float: left; margin-right: 10px; font-size: 14px;}
.layui-colorpicker-main-input input.layui-input{width: 150px; height: 30px; color: #666;}
.layui-colorpicker-main-input input.layui-input{width: 150px; height: 30px; color: #5F5F5F;}
/** 滑块 **/
.layui-slider{height: 4px; background: #eee; border-radius: 3px; position: relative; cursor: pointer;}
@ -1348,7 +1359,7 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
.layui-slider-wrap-btn:hover,
.layui-slider-wrap-btn.layui-slider-hover{transform: scale(1.2);}
.layui-slider-wrap-btn.layui-disabled:hover{transform: scale(1) !important;}
.layui-slider-tips{position: absolute; top: -42px; z-index: 66666666; white-space:nowrap; display: none; -webkit-transform: translateX(-50%); transform: translateX(-50%); color: #FFF; background: #000; border-radius: 3px; height: 25px; line-height: 25px; padding: 0 10px;}
.layui-slider-tips{position: absolute; top: -42px; z-index: 77777777; white-space:nowrap; display: none; -webkit-transform: translateX(-50%); transform: translateX(-50%); color: #FFF; background: #000; border-radius: 3px; height: 25px; line-height: 25px; padding: 0 10px;}
.layui-slider-tips:after{content: ""; position: absolute; bottom: -12px; left: 50%; margin-left: -6px; width: 0; height: 0; border-width: 6px; border-style: solid; border-color: #000 transparent transparent transparent;}
.layui-slider-input{width: 70px; height: 32px; border: 1px solid #eee; border-radius: 3px; font-size: 16px; line-height: 32px; position: absolute; right: 0; top: -14px;}
.layui-slider-input-btn{position: absolute; top: 0; right: 0; width: 20px; height: 100%; border-left: 1px solid #eee;}
@ -1388,12 +1399,12 @@ body .layui-util-face .layui-layer-content{padding:0; background-color:#fff; co
.layui-tree-iconClick{display: inline-block; vertical-align: middle; position: relative; height: 20px; line-height: 20px; margin: 0 10px; color: #c0c4cc;}
.layui-tree-icon{height: 12px; line-height: 12px; width: 12px; text-align: center; border: 1px solid #c0c4cc;}
.layui-tree-iconClick .layui-icon{font-size: 18px;}
.layui-tree-icon .layui-icon{font-size: 12px; color: #666;}
.layui-tree-icon .layui-icon{font-size: 12px; color: #5F5F5F;}
.layui-tree-iconArrow{padding: 0 5px;}
.layui-tree-iconArrow:after{content: ""; position: absolute; left: 4px; top: 3px; z-index: 100; width: 0; height: 0; border-width: 5px; border-style: solid; border-color: transparent transparent transparent #c0c4cc; transition: 0.5s;}
.layui-tree-spread>.layui-tree-entry .layui-tree-iconClick>.layui-tree-iconArrow:after{transform: rotate(90deg) translate(3px, 4px);}
.layui-tree-txt{display: inline-block; vertical-align: middle; color: #555;}
.layui-tree-search{margin-bottom: 15px; color: #666;}
.layui-tree-search{margin-bottom: 15px; color: #5F5F5F;}
.layui-tree-btnGroup{visibility: hidden; display: inline-block; vertical-align: middle; position: relative;}
.layui-tree-btnGroup .layui-icon{display: inline-block; vertical-align: middle; padding: 0 2px; cursor: pointer;}
.layui-tree-btnGroup .layui-icon:hover{color: #999; transition: 0.3s;}

View File

@ -1,7 +1,6 @@
/*!
/**
* Layui
* Classic modular Front-End UI library
* Classic modular front-end UI library
* MIT Licensed
*/
@ -16,7 +15,7 @@
}
,Layui = function(){
this.v = '2.6.8'; // layui 版本号
this.v = '2.6.13'; // 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;
};

View File

@ -1,5 +1,4 @@

/*!
/*!
* 用于加载所有内置模块
* MIT Licensed
*/

View File

@ -1,5 +1,4 @@
/*!
/**
* carousel 轮播模块
* MIT Licensed
*/

View File

@ -1,4 +1,3 @@
/**
* code 代码修饰器
* MIT Licensed

View File

@ -1,5 +1,4 @@
/*!
/**
* colorpicker
* 颜色选择组件
*/

View File

@ -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);

View File

@ -1,8 +1,6 @@
/**
@Namedropdown 下拉菜单组件
@LicenseMIT
* dropdown
* 下拉菜单组件
*/
layui.define(['jquery', 'laytpl', 'lay'], function(exports){

View File

@ -1,5 +1,4 @@
/*!
/**
* element 常用元素操作
* MIT Licensed
*/

View File

@ -1,8 +1,5 @@
/**
@Name flow 流加载组件
@LicenseMIT
* flow 流加载组件
*/

View File

@ -1,5 +1,4 @@
/*!
/**
* form 表单组件
* MIT Licensed
*/

View File

@ -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]);
}
@ -88,14 +91,16 @@
//数字前置补零
lay.digit = function(num, length, end){
lay.digit = function(num, length){
if(!(typeof num === 'string' || typeof num === 'number')) return '';
var str = '';
num = String(num);
length = length || 2;
for(var i = num.length; i < length; i++){
str += '0';
}
return num < Math.pow(10, length) ? str + (num|0) : num;
return num < Math.pow(10, length) ? str + num : num;
};
//创建元素

View File

@ -1,5 +1,4 @@
/*! layDate 日期与时间控件 | MIT Licensed */
/** layDate 日期与时间控件 | MIT Licensed */
;!function(window, document){
"use strict";
@ -189,10 +188,12 @@
if(!options.elem[0]) return;
//日期范围分隔符
that.rangeStr = options.range ? (typeof options.range === 'string' ? options.range : '-') : '';
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])
@ -240,7 +241,7 @@
) +'$');
that.EXP_SPLIT = new RegExp('^'+ that.EXP_SPLIT +'$', '');
//如果不是input|textarea元素则默认采用click事件
//如果不是 input|textarea 元素,则默认采用 click 事件
if(!that.isInput(options.elem[0])){
if(options.trigger === 'focus'){
options.trigger = 'click';
@ -264,7 +265,6 @@
,'0-5-4': '青年'
,'0-6-1': '儿童'
,'0-9-10': '教师'
,'0-9-18': '国耻'
,'0-10-1': '国庆'
,'0-12-25': '圣诞'
} : {}, options.mark);
@ -274,7 +274,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 +290,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 +312,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);
@ -472,13 +480,13 @@
lay(elem).addClass('laydate-theme-molv');
elem.appendChild(style);
}
//移除上一个控件
that.remove(Class.thisElemDate);
//记录当前执行的实例索引
laydate.thisId = options.id;
//移除上一个控件
that.remove(Class.thisElemDate);
//如果是静态定位则插入到指定的容器中否则插入到body
isStatic ? options.elem.append(elem) : (
document.body.appendChild(elem)
@ -509,6 +517,7 @@
elem.remove();
//delete options.dateTime;
//delete that.endDate;
delete laydate.thisId;
});
}
return that;
@ -586,11 +595,14 @@
//如果传入了开始和结束日期的 input 对象,则将其拼接为日期范围字符
if(that.rangeElem){
var vals = [that.rangeElem[0].val(), that.rangeElem[1].val()];
if(vals[0] && vals[1]){
return vals.join(' ' + that.rangeStr + ' ');
}
}
return that.isInput(elem) ? elem.value : (options.position === 'static' ? '' : lay(elem).attr('lay-date'));
return that.isInput(elem)
? elem.value
: (options.position === 'static' ? '' : lay(elem).attr('lay-date'));
}()
//校验日期有效数字
@ -696,7 +708,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 +751,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);
}
@ -904,7 +918,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();
@ -947,10 +963,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;
@ -958,9 +982,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));
}
@ -970,17 +997,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);
}
@ -1003,7 +1041,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']);
}
};
//初始化时间对象
@ -1040,7 +1080,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);
@ -1181,14 +1220,18 @@
,options = that.config
,dateTime = date || (state == 'end'
? lay.extend({}, that.endDate, that.endTime)
: (options.range ? lay.extend({}, options.dateTime, that.startTime) : options.dateTime))
: (
options.range
? lay.extend({}, options.dateTime, that.startTime)
: options.dateTime)
)
,format = laydate.parse(dateTime, that.format, 1);
//返回日期范围字符
if(options.range && state === undefined){
return format + ' '+ that.rangeStr +' ' + that.parse('end');
}
return format;
};
@ -1221,9 +1264,13 @@
lay(elem).val(value);
} else {
//如果 range 传入了开始和结束的 input 对象,则分别对其赋值
if(that.rangeElem){
that.rangeElem[0].val(value ? that.parse('start') : '');
that.rangeElem[1].val(value ? that.parse('end') : '');
var rangeElem = that.rangeElem;
if(rangeElem){
if(layui.type(value) !== 'array'){
value = value.split(' '+ that.rangeStr +' ');
}
rangeElem[0].val(value[0] || '');
rangeElem[1].val(value[1] || '');
} else {
if(lay(elem).find('*').length === 0){
lay(elem).html(value);
@ -1302,9 +1349,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 +1424,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]();
@ -1535,6 +1583,8 @@
//绑定呼出控件事件
,showEvent = function(elem, bind){
elem.on(options.trigger, function(){
//已经打开的面板避免重新渲染
if(laydate.thisId === options.id) return;
bind && (that.bindElem = this);
that.render();
});
@ -1581,6 +1631,8 @@
var that = thisModule.getThis(laydate.thisId);
if(!that) return;
// 回车触发确认
if(that.config.position === 'static') return;
if(e.keyCode === 13){
if(lay('#'+ that.elemID)[0] && that.elemID === Class.thisElemDate){
e.preventDefault();

View File

@ -1,8 +1,5 @@
/**
@Namelayedit 富文本编辑器
@LicenseMIT
* 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({

View File

@ -1,5 +1,4 @@

/*!
/**
* layer - 通用 Web 弹出层组件
* MIT Licensed
*/

View File

@ -1,8 +1,5 @@
/**
@Name : laypage 分页组件
@LicenseMIT
* laypage 分页组件
*/
layui.define(function(exports){

View File

@ -1,12 +1,8 @@
/**
@Name : laytpl 模板引擎
@LicenseMIT
* laytpl 模板引擎
*/
layui.define(function(exports){
"use strict";
var config = {
@ -27,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: ';
@ -64,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 = '"+_escape_(';
} else if(/^-/.test(str)){
str = str.replace(/^-/, '');
start = '"+(';
}
return start + str.replace(/\\(.)/g, '$1') + ')+"';
});
@ -87,8 +92,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 +103,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);
};

View File

@ -1,5 +1,4 @@

/*!
/**
* 用于打包聚合版该文件不会存在于构建后的目录
*/

View File

@ -1,8 +1,6 @@
/**
@Namelayui 移动模块入口 | 构建后则为移动模块集合
@LicenseMIT
* layui 移动模块入口
* 构建后则为移动模块集合
*/

View File

@ -1,8 +1,5 @@
/**
@Title: rate 评分评星组件
@LicenseMIT
* rate 评分评星组件
*/
layui.define('jquery',function(exports){

View File

@ -1,8 +1,5 @@
/**
@Title: slider 滑块组件
@LicenseMIT
* slider 滑块组件
*/
layui.define('jquery', function(exports){

View File

@ -1,7 +1,6 @@
/*!
/**
* layui.table
* 数据表格组件
* 表格组件
*/
layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
@ -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
//是否编码 HTML
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;
}
//字符常量
@ -93,11 +101,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
//thead区域模板
,TPL_HEADER = function(options){
var rowCols = '{{#if(item2.colspan){}} colspan="{{item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{item2.rowspan}}"{{#}}}';
var rowCols = '{{#if(item2.colspan){}} colspan="{{=item2.colspan}}"{{#} if(item2.rowspan){}} rowspan="{{=item2.rowspan}}"{{#}}}';
options = options || {};
return ['<table cellspacing="0" cellpadding="0" border="0" class="layui-table" '
,'{{# if(d.data.skin){ }}lay-skin="{{d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>'
,'{{# if(d.data.skin){ }}lay-skin="{{=d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{=d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>'
,'<thead>'
,'{{# layui.each(d.data.cols, function(i1, item1){ }}'
,'<tr>'
@ -114,21 +122,21 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
return '';
}()
,'{{# var isSort = !(item2.colGroup) && item2.sort; }}'
,'<th data-field="{{ item2.field||i2 }}" data-key="{{d.index}}-{{i1}}-{{i2}}" {{# if( item2.parentKey){ }}data-parentkey="{{ item2.parentKey }}"{{# } }} {{# if(item2.minWidth){ }}data-minwidth="{{item2.minWidth}}"{{# } }} '+ rowCols +' {{# if(item2.unresize || item2.colGroup){ }}data-unresize="true"{{# } }} class="{{# if(item2.hide){ }}layui-hide{{# } }}{{# if(isSort){ }} layui-unselect{{# } }}{{# if(!item2.field){ }} layui-table-col-special{{# } }}">'
,'<th data-field="{{= item2.field||i2 }}" data-key="{{=d.index}}-{{=i1}}-{{=i2}}" {{# if( item2.parentKey){ }}data-parentkey="{{= item2.parentKey }}"{{# } }} {{# if(item2.minWidth){ }}data-minwidth="{{=item2.minWidth}}"{{# } }} '+ rowCols +' {{# if(item2.unresize || item2.colGroup){ }}data-unresize="true"{{# } }} class="{{# if(item2.hide){ }}layui-hide{{# } }}{{# if(isSort){ }} layui-unselect{{# } }}{{# if(!item2.field){ }} layui-table-col-special{{# } }}">'
,'<div class="layui-table-cell laytable-cell-'
,'{{# if(item2.colGroup){ }}'
,'group'
,'{{# } else { }}'
,'{{d.index}}-{{i1}}-{{i2}}'
,'{{=d.index}}-{{=i1}}-{{=i2}}'
,'{{# if(item2.type !== "normal"){ }}'
,' laytable-cell-{{ item2.type }}'
,' laytable-cell-{{= item2.type }}'
,'{{# } }}'
,'{{# } }}'
,'" {{#if(item2.align){}}align="{{item2.align}}"{{#}}}>'
,'" {{#if(item2.align){}}align="{{=item2.align}}"{{#}}}>'
,'{{# if(item2.type === "checkbox"){ }}' //复选框
,'<input type="checkbox" name="layTableCheckbox" lay-skin="primary" lay-filter="layTableAllChoose" {{# if(item2[d.data.checkName]){ }}checked{{# }; }}>'
,'{{# } else { }}'
,'<span>{{item2.title||""}}</span>'
,'<span>{{-item2.title||""}}</span>'
,'{{# if(isSort){ }}'
,'<span class="layui-table-sort layui-inline"><i class="layui-edge layui-table-sort-asc" title="升序"></i><i class="layui-edge layui-table-sort-desc" title="降序"></i></span>'
,'{{# } }}'
@ -143,14 +151,14 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,'</table>'].join('');
}
//tbody区域模板
// tbody 区域模板
,TPL_BODY = ['<table cellspacing="0" cellpadding="0" border="0" class="layui-table" '
,'{{# if(d.data.skin){ }}lay-skin="{{d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>'
,'{{# if(d.data.skin){ }}lay-skin="{{=d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{=d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>'
,'<tbody></tbody>'
,'</table>'].join('')
//主模板
,TPL_MAIN = ['<div class="layui-form layui-border-box {{d.VIEW_CLASS}}{{# if(d.data.className){ }} {{ d.data.className }}{{# } }}" lay-filter="LAY-table-{{d.index}}" lay-id="{{ d.data.id }}" style="{{# if(d.data.width){ }}width:{{d.data.width}}px;{{# } }} {{# if(d.data.height){ }}height:{{d.data.height}}px;{{# } }}">'
,TPL_MAIN = ['<div class="layui-form layui-border-box {{=d.VIEW_CLASS}}{{# if(d.data.className){ }} {{= d.data.className }}{{# } }}" lay-filter="LAY-table-{{=d.index}}" lay-id="{{= d.data.id }}" style="{{# if(d.data.width){ }}width:{{=d.data.width}}px;{{# } }} {{# if(d.data.height){ }}height:{{=d.data.height}}px;{{# } }}">'
,'{{# if(d.data.toolbar){ }}'
,'<div class="layui-table-tool">'
@ -201,7 +209,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,'{{# if(d.data.totalRow){ }}'
,'<div class="layui-table-total">'
,'<table cellspacing="0" cellpadding="0" border="0" class="layui-table" '
,'{{# if(d.data.skin){ }}lay-skin="{{d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>'
,'{{# if(d.data.skin){ }}lay-skin="{{=d.data.skin}}"{{# } }} {{# if(d.data.size){ }}lay-size="{{=d.data.size}}"{{# } }} {{# if(d.data.even){ }}lay-even{{# } }}>'
,'<tbody><tr><td><div class="layui-table-cell" style="visibility: hidden;">Total</div></td></tr></tbody>'
, '</table>'
,'</div>'
@ -209,16 +217,16 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
,'{{# if(d.data.page){ }}'
,'<div class="layui-table-page">'
,'<div id="layui-table-page{{d.index}}"></div>'
,'<div id="layui-table-page{{=d.index}}"></div>'
,'</div>'
,'{{# } }}'
,'<style>'
,'{{# layui.each(d.data.cols, function(i1, item1){'
,'layui.each(item1, function(i2, item2){ }}'
,'.laytable-cell-{{d.index}}-{{i1}}-{{i2}}{ '
,'.laytable-cell-{{=d.index}}-{{=i1}}-{{=i2}}{ '
,'{{# if(item2.width){ }}'
,'width: {{item2.width}}px;'
,'width: {{=item2.width}}px;'
,'{{# } }}'
,' }'
,'{{# });'
@ -241,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 //是否前端自动排序。如果否,则需自主排序(通常为服务端处理好排序)
@ -388,7 +397,9 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
//初始化列参数
layui.each(options.cols, function(i1, item1){
layui.each(item1, function(i2, item2){
item2.colspan = item2.colspan || 1;
item2.rowspan = item2.rowspan || 1;
//如果列参数为空,则移除
if(!item2){
item1.splice(i2, 1);
@ -402,10 +413,10 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
//如果是组合列,则捕获对应的子列
if(item2.colGroup || item2.colspan > 1){
var childIndex = 0;
layui.each(options.cols[i1 + 1], function(i22, item22){
layui.each(options.cols[i1 + item2.rowspan], function(i22, item22){
//如果子列已经被标注为{HAS_PARENT},或者子列累计 colspan 数等于父列定义的 colspan则跳出当前子列循环
if(item22.HAS_PARENT || (childIndex > 1 && childIndex == item2.colspan)) return;
if(item22.HAS_PARENT || (childIndex >= 1 && childIndex == item2.colspan)) return;
item22.HAS_PARENT = true;
item22.parentKey = i1 + '-' + i2;
@ -650,7 +661,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 +755,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 +801,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 +821,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 +836,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 +871,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 +971,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
@ -990,7 +1004,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;
@ -1147,7 +1165,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;
};
@ -1199,7 +1217,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;
@ -1214,17 +1233,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);
@ -1336,7 +1355,7 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
var lis = [];
that.eachCols(function(i, item){
if(item.field && item.type == 'normal'){
lis.push('<li><input type="checkbox" name="'+ item.field +'" data-key="'+ item.key +'" data-parentkey="'+ (item.parentKey||'') +'" lay-skin="primary" '+ (item.hide ? '' : 'checked') +' title="'+ (item.title || item.field) +'" lay-filter="LAY_TABLE_TOOL_COLS"></li>');
lis.push('<li><input type="checkbox" name="'+ item.field +'" data-key="'+ item.key +'" data-parentkey="'+ (item.parentKey||'') +'" lay-skin="primary" '+ (item.hide ? '' : 'checked') +' title="'+ util.escape(item.title || item.field) +'" lay-filter="LAY_TABLE_TOOL_COLS"></li>');
}
});
return lis.join('');
@ -1381,8 +1400,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
openPanel({
list: function(){
return [
'<li data-type="csv">导出到 Csv 文件</li>'
,'<li data-type="xls">导出 Excel 文件</li>'
'<li data-type="csv">导出 csv 格式文件</li>'
,'<li data-type="xls">导出 xls 格式文件</li>'
].join('')
}()
,done: function(panel, list){
@ -1508,7 +1527,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 +'"]')
@ -1528,19 +1547,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){
//更新相应列视图
if(item3.field == key){
cell.html(parseTempData.call(that, {
item3: item3
,content: value
,tplData: data
}));
td.data('content', value);
item3.templet && that.renderForm();
} 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: item3
,content: content
,tplData: data
}));
thisTd.data('content', content);
that.renderForm();
}
});
});
}
}, sets);
@ -1637,7 +1671,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')
@ -1645,13 +1679,15 @@ 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, {
templet: templet
}, value, data);
item3: item3 || {}
,content: value
,tplData: data
});
}(thisElem.value));
othis.parent().data('content', thisElem.value);
othis.remove();
@ -1818,8 +1854,8 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
var row = $.extend({
title: th.text()
,colspan: th.attr('colspan') || 0 //列单元格
,rowspan: th.attr('rowspan') || 0 //行单元格
,colspan: th.attr('colspan') || 1 //列单元格
,rowspan: th.attr('rowspan') || 1 //行单元格
}, itemData);
if(row.colspan < 2) cols.push(row);
@ -1873,11 +1909,11 @@ layui.define(['laytpl', 'laypage', 'layer', 'form', 'util'], function(exports){
var childIndex = 0;
index++
item2.CHILD_COLS = [];
layui.each(cols[i1 + 1], function(i22, item22){
layui.each(cols[i1 + item2.rowspan], function(i22, item22){
//如果子列已经被标注为{PARENT_COL_INDEX},或者子列累计 colspan 数等于父列定义的 colspan则跳出当前子列循环
if(item22.PARENT_COL_INDEX || (childIndex > 1 && childIndex == item2.colspan)) return;
if(item22.PARENT_COL_INDEX || (childIndex >= 1 && childIndex == item2.colspan)) return;
item22.PARENT_COL_INDEX = index;
item2.CHILD_COLS.push(item22);
@ -1909,7 +1945,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;
}
@ -1929,7 +1965,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));
@ -1955,7 +1991,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){
@ -1969,12 +2008,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 +'"]');
}
})
}) + '"');
}
});
}
@ -1983,7 +2040,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(',');

View File

@ -1,8 +1,5 @@
/**
@Nametransfer 穿梭框组件
@LicenseMIT
* 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;
}()
});

View File

@ -1,8 +1,5 @@
/**
@Nametree 树组件
@LicenseMIT
* 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);

View File

@ -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 类型
@ -180,14 +180,14 @@ layui.define('layer' , function(exports){
//高级浏览器处理方式,支持跨域
,ajaxSend = function(){
var successful = 0, aborted = 0
var successful = 0, failed = 0
,items = files || that.files || that.chooseFiles || elemFile.files
,allDone = function(){ //多文件全部上传完毕的回调
if(options.multiple && successful + aborted === that.fileLength){
if(options.multiple && successful + failed === that.fileLength){
typeof options.allDone === 'function' && options.allDone({
total: that.fileLength
,successful: successful
,aborted: aborted
,failed: failed
});
}
};
@ -218,9 +218,9 @@ layui.define('layer' , function(exports){
allDone();
}
//异常回调
,error: function(){
aborted++;
that.msg('请求上传接口出现异常');
,error: function(e){
failed++;
that.msg('Request URL is abnormal: '+ (e.statusText || 'error'));
error(index);
allDone();
}
@ -243,7 +243,7 @@ layui.define('layer' , function(exports){
});
}
//低版本IE处理方式不支持跨域
//低版本 IE 处理方式,不支持跨域
,iframeSend = function(){
var iframe = $('#'+ ELEM_IFRAME);
@ -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);
});
@ -334,14 +338,6 @@ layui.define('layer' , function(exports){
//提交上传
,send = function(){
//选择文件的回调
if(type === 'choose' || options.auto){
options.choose && options.choose(args);
if(type === 'choose'){
return;
}
}
//上传前的回调 - 如果回调函数明确返回false则停止上传(#pulls55)
if(options.before && (options.before(args) === false)) return;
@ -352,6 +348,14 @@ layui.define('layer' , function(exports){
ajaxSend();
}
//文件类型名称
,typeName = ({
file: '文件'
,images: '图片'
,video: '视频'
,audio: '音频'
})[options.accept] || '文件';
//校验文件格式
value = value.length === 0
@ -359,39 +363,53 @@ 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 = '';
}
//选择文件的回调
if(type === 'choose' || options.auto){
options.choose && options.choose(args);
if(type === 'choose'){
return;
}
}
//检验文件数量
that.fileLength = function(){
var length = 0
@ -401,8 +419,12 @@ layui.define('layer' , function(exports){
});
return length;
}();
if(options.number && that.fileLength > options.number){
return that.msg('同时最多只能上传的数量为:'+ options.number);
return that.msg(
'同时最多只能上传: '+ options.number + ' 个文件'
+'<br>您当前已经选择了: '+ that.fileLength +' 个文件'
);
}
//检验文件大小
@ -417,8 +439,9 @@ layui.define('layer' , function(exports){
limitSize = size;
}
});
if(limitSize) return that.msg('文件不能超过'+ limitSize);
if(limitSize) return that.msg('文件大小不能超过 '+ limitSize);
}
send();
};
@ -502,12 +525,8 @@ layui.define('layer' , function(exports){
othis.removeAttr('lay-over');
setChooseFile(files);
if(options.auto){
that.upload(files);
} else {
setChooseText(files);
}
options.auto ? that.upload() : setChooseText(files); //是否自动触发上传
});
}

View File

@ -1,7 +1,6 @@
/*!
/**
* util 工具组件
*/
*/
layui.define('jquery', function(exports){
"use strict";
@ -170,18 +169,27 @@ layui.define('jquery', function(exports){
.replace(/ss/g, hms[2]);
}
//转义 html,防 xss 攻击
//转义 html
,escape: function(html){
return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&amp;')
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;');
}
//还原转义的 html
,unescape: function(str){
return String(str || '').replace(/\&amp;/g, '&')
,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;/, '"');
.replace(/\&#39;/g, '\'').replace(/\&quot;/g, '"');
}
//让指定的元素保持在可视区域
@ -237,12 +245,14 @@ layui.define('jquery', function(exports){
return obj;
}
};
util.on = util.event;
// DOM 尺寸变化该创意来自http://benalman.com/projects/jquery-resize-plugin/
/*
!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);
});