Merge branch 'layui:2.x' into 2.x
This commit is contained in:
commit
c50b1197b6
2
dist/layui.js
vendored
2
dist/layui.js
vendored
File diff suppressed because one or more lines are too long
@ -12,21 +12,21 @@ toc: true
|
||||
<pre class="layui-code" lay-options="{preview: true, layout: ['preview', 'code']}">
|
||||
<textarea>
|
||||
<div class="layui-btn-container">
|
||||
<button type="button" class="layui-btn layui-btn-primary">原始按钮</button>
|
||||
<button type="button" class="layui-btn">默认按钮</button>
|
||||
<button type="button" class="layui-btn layui-btn-normal">百搭按钮</button>
|
||||
<button type="button" class="layui-btn layui-btn-warm">暖色按钮</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger">警告按钮</button>
|
||||
<button type="button" class="layui-btn layui-bg-blue">蓝色按钮</button>
|
||||
<button type="button" class="layui-btn layui-bg-orange">橙色按钮</button>
|
||||
<button type="button" class="layui-btn layui-bg-red">红色按钮</button>
|
||||
<button type="button" class="layui-btn layui-bg-purple">紫色按钮</button>
|
||||
<button type="button" class="layui-btn layui-btn-disabled">禁用按钮</button>
|
||||
</div>
|
||||
|
||||
<div class="layui-btn-container">
|
||||
<button class="layui-btn layui-btn-primary layui-border">原始按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-green">主色按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-blue">百搭按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-orange">暖色按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-red">警告按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-black">深色按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-blue">蓝色按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-orange">橙色按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-red">红色按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border-purple">紫色按钮</button>
|
||||
<button class="layui-btn layui-btn-primary layui-border">普通按钮</button>
|
||||
</div>
|
||||
</textarea>
|
||||
</pre>
|
||||
|
@ -266,6 +266,7 @@ click: function(data, othis){
|
||||
/*
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
```
|
||||
|
||||
用法详见:[#示例](#examples)
|
||||
@ -273,4 +274,4 @@ click: function(data, othis){
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
@ -61,8 +61,8 @@ toc: true
|
||||
- 通过 `class="layui-form"` 定义一个表单域,通常设置在`<form>`标签上, 或普通`<div>` 标签亦可。
|
||||
- 通过 `class="layui-form-item"` 定义一个块级元素的表单项容器
|
||||
- 通过 `class="layui-form-label"` 定义标签
|
||||
- 通过 `class="layui-form-block"` 定义表单项父容器为块级元素
|
||||
- 通过 `class="layui-form-inline"` 或 `class="layui-inline"` 定义表单项父容器为行内块元素
|
||||
- 通过 `class="layui-input-block"` 定义表单项父容器为块级元素
|
||||
- 通过 `class="layui-input-inline"` 或 `class="layui-inline"` 定义表单项父容器为行内块元素
|
||||
|
||||
即必须按照规定的层级定义相应的 `class`。
|
||||
|
||||
@ -408,7 +408,7 @@ form.on('select(test)', function(data){
|
||||
| 属性名 | 描述 | 类型 | 默认值 |
|
||||
| --- | --- | --- | --- |
|
||||
| autocomplete | 设置 input 框的 `autocomplete` 属性初始值 | string | - |
|
||||
| verIncludelRequired <sup>2.8.4+</sup> | 验证规则中是否同时包含必填。 form 组件在 `2.8.3` 版本中调整了内置校验规则,即:仅当非空时进行校验,避免强制携带必填的校验规则。如需保留之前的验证规则(即同时校验必填),可将该属性设置为 `true`。但一般还是建议将必填项放置在 `lay-verify` 属性上,如: `lay-verify="required\|number"` | boolean | `false` |
|
||||
| verIncludeRequired <sup>2.8.4+</sup> | 验证规则中是否同时包含必填。 form 组件在 `2.8.3` 版本中调整了内置校验规则,即:仅当非空时进行校验,避免强制携带必填的校验规则。如需保留之前的验证规则(即同时校验必填),可将该属性设置为 `true`。但一般还是建议将必填项放置在 `lay-verify` 属性上,如: `lay-verify="required\|number"` | boolean | `false` |
|
||||
|
||||
该方法用于对 form 组件进行全局设置。
|
||||
|
||||
|
@ -114,7 +114,7 @@ toc: true
|
||||
数字输入框 <sup>2.8.9+</sup>
|
||||
</h3>
|
||||
|
||||
一般搭配 `<input type="number">` 使用,用于替代原生输入框,可继承 `step,min,max` 等原生属性。
|
||||
一般搭配 `<input type="number">` 使用,用于替代原生数字输入框,可继承 `step,min,max` 等原生属性。
|
||||
|
||||
<pre class="layui-code" lay-options="{preview: true, layout: ['preview', 'code'], done: function(obj){
|
||||
obj.render();
|
||||
@ -130,9 +130,12 @@ toc: true
|
||||
<div class="layui-col-xs6">
|
||||
<input type="number" lay-affix="number" placeholder="设置 step,min,max" step="10" min="0" max="100" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-col-xs12">
|
||||
<input type="number" lay-affix="number" disabled placeholder="禁用状态" value="0" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<input type="number" lay-affix="number" readonly placeholder="不允许输入状态" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<input type="number" lay-affix="number" disabled placeholder="禁用状态" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -24,7 +24,7 @@ toc: true
|
||||
- 通过 `<li></li>` 放置菜单列表项
|
||||
- 属性:
|
||||
- 追加 `className` 为 `layui-menu-item-group` 可设置当前菜单为菜单组,即子菜单为纵向层级。
|
||||
- 或追加 `className` 为 `layui-menu-item-parent` 可这支当前菜单为父级菜单,即子菜单为横向层级。
|
||||
- 或追加 `className` 为 `layui-menu-item-parent` 可设置当前菜单为父级菜单,即子菜单为横向层级。
|
||||
- 追加 `className` 为 `layui-menu-item-divider` 可设置分隔线。
|
||||
- 追加 `className` 为 `layui-menu-item-up` 或 `layui-menu-item-down` 可设置子菜单默认收缩或展开。
|
||||
- 追加 `className` 为 `layui-menu-item-checked` 可设置当前菜单为选中状态
|
||||
@ -59,4 +59,4 @@ toc: true
|
||||
|
||||
## 贴士
|
||||
|
||||
基础菜单相当于是 `dropdown` 组件的一种静态化呈现,因此在事件等动态操作上需借助 `dropdown` 组件的 API 来完成。
|
||||
基础菜单相当于是 `dropdown` 组件的一种静态化呈现,因此在事件等动态操作上需借助 `dropdown` 组件的 API 来完成。
|
||||
|
@ -19,7 +19,7 @@ layui.use(function(){
|
||||
var util = layui.util;
|
||||
|
||||
// 模拟数据
|
||||
var data = [{title:'一级1',id:1,field:'name1',checked:true,spread:true,children:[{title:'二级1-1 可允许跳转',id:3,field:'name11',href:'',children:[{title:'三级1-1-3',id:23,field:'',children:[{title:'四级1-1-3-1',id:24,field:'',children:[{title:'五级1-1-3-1-1',id:30,field:''},{title:'五级1-1-3-1-2',id:31,field:''}]}]},{title:'三级1-1-1',id:7,field:'',children:[{title:'四级1-1-1-1 可允许跳转',id:15,field:'',href:''}]},{title:'三级1-1-2',id:8,field:'',children:[{title:'四级1-1-2-1',id:32,field:''}]}]},{title:'二级1-2',id:4,spread:true,children:[{title:'三级1-2-1',id:9,field:'',disabled:true},{title:'三级1-2-2',id:10,field:''}]},{title:'二级1-3',id:20,field:'',children:[{title:'三级1-3-1',id:21,field:''},{title:'三级1-3-2',id:22,field:''}]}]},{title:'一级2',id:2,field:'',spread:true,children:[{title:'二级2-1',id:5,field:'',spread:true,children:[{title:'三级2-1-1',id:11,field:''},{title:'三级2-1-2',id:12,field:''}]},{title:'二级2-2',id:6,field:'',children:[{title:'三级2-2-1',id:13,field:''},{title:'三级2-2-2',id:14,field:'',disabled:true}]}]},{title:'一级3',id:16,field:'',children:[{title:'二级3-1',id:17,field:'',fixed:true,children:[{title:'三级3-1-1',id:18,field:''},{title:'三级3-1-2',id:19,field:''}]},{title:'二级3-2',id:27,field:'',children:[{title:'三级3-2-1',id:28,field:''},{title:'三级3-2-2',id:29,field:''}]}]}];
|
||||
var data = [{title:'A-1',id:1,field:'name1',checked:true,spread:true,children:[{title:'B-1-1 可允许跳转',id:3,field:'name11',href:'',children:[{title:'C-1-1-3',id:23,field:'',children:[{title:'D-1-1-3-1',id:24,field:'',children:[{title:'E-1-1-3-1-1',id:30,field:''},{title:'E-1-1-3-1-2',id:31,field:''}]}]},{title:'C-1-1-1',id:7,field:'',children:[{title:'D-1-1-1-1 可允许跳转',id:15,field:'',href:''}]},{title:'C-1-1-2',id:8,field:'',children:[{title:'D-1-1-2-1',id:32,field:''}]}]},{title:'B-1-2',id:4,spread:true,children:[{title:'C-1-2-1',id:9,field:'',disabled:true},{title:'C-1-2-2',id:10,field:''}]},{title:'B-1-3',id:20,field:'',children:[{title:'C-1-3-1',id:21,field:''},{title:'C-1-3-2',id:22,field:''}]}]},{title:'A-2',id:2,field:'',spread:true,children:[{title:'B-2-1',id:5,field:'',spread:true,children:[{title:'C-2-1-1',id:11,field:''},{title:'C-2-1-2',id:12,field:''}]},{title:'B-2-2',id:6,field:'',children:[{title:'C-2-2-1',id:13,field:''},{title:'C-2-2-2',id:14,field:'',disabled:true}]}]},{title:'A-3',id:16,field:'',children:[{title:'B-3-1',id:17,field:'',fixed:true,children:[{title:'C-3-1-1',id:18,field:''},{title:'C-3-1-2',id:19,field:''}]},{title:'B-3-2',id:27,field:'',children:[{title:'C-3-2-1',id:28,field:''},{title:'C-3-2-2',id:29,field:''}]}]}];
|
||||
|
||||
// 渲染
|
||||
tree.render({
|
||||
|
@ -11,6 +11,28 @@ toc: true
|
||||
|
||||
> 导读:📑 [Layui 2.8 《升级指南》](/notes/2.8/upgrade-guide.html) · 📑 [Layui 新版文档站上线初衷](/notes/2.8/news.html)
|
||||
|
||||
|
||||
<h2 id="2.8.11" class="ws-anchor">
|
||||
2.8.11
|
||||
<span class="layui-badge-rim">2023-07-13</span>
|
||||
</h2>
|
||||
|
||||
- #### form
|
||||
- 修复 `radio` 标题模板中若存在图标,选中时该图标被强制更改的问题 # I7IERB
|
||||
- 优化 `input` 数字输入框的精度问题 # I7I7J2
|
||||
- 修正 `verIncludelRequired` 属性名为 `verIncludeRequired` # 1305
|
||||
- #### table
|
||||
- 修复 导出统计行中若存在逗号出现的内容分隔异常问题 # I7IDA3
|
||||
- 修复 当点击筛选显示隐藏固定列时出现的未对齐的问题 # I7KQ0O
|
||||
- #### menu
|
||||
- 修复 `menu` 标题项自定义图标在展开收缩后被强制更改的问题 # 1303/I7JAPU
|
||||
- #### tree
|
||||
- 修复 点击复选框时未将对应的数据中的 `checked` 属性值进行同步的问题
|
||||
|
||||
### 下载: [layui-v2.8.11.zip](https://gitee.com/layui/layui/attach_files/1464525/download)
|
||||
|
||||
---
|
||||
|
||||
<h2 id="2.8.10" class="ws-anchor">
|
||||
2.8.10
|
||||
<span class="layui-badge-rim">2023-07-03</span>
|
||||
|
@ -120,6 +120,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md3">
|
||||
<input type="number" value="1.1" name="arr[]" required placeholder="数字输入框" lay-affix="number" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-col-md3">
|
||||
<input type="number" step="0.01" min="0" max="10" name="arr[]" required placeholder="数字输入框" lay-affix="number" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
@ -341,17 +344,13 @@
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">单选框</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="sex" value="男" title="男">
|
||||
<input type="radio" name="sex" value="女" title="女" checked>
|
||||
<input type="radio" name="sex" value="中型" title="中" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">单选框</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="sex.id" value="男" title="男">
|
||||
<input type="radio" name="sex.id" value="女" title="女" checked>
|
||||
<input type="radio" name="sex.id" value="中型" title="中">
|
||||
<input type="radio" name="sex" value="1" title="男">
|
||||
<input type="radio" name="sex" value="0" title="女" checked>
|
||||
<input type="radio" name="sex" value="-1">
|
||||
<div lay-radio>
|
||||
保密 <i class="layui-icon layui-icon-user"></i>
|
||||
</div>
|
||||
<input type="radio" name="sex" value="" title="禁用" disabled>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-form-text">
|
||||
@ -436,7 +435,7 @@
|
||||
,'interest': 3
|
||||
,'like[write]': true
|
||||
//,'open': false
|
||||
,'sex': '男'
|
||||
,'sex': '0'
|
||||
,'desc': 'form 是我们非常看重的一块'
|
||||
,xxxxxxxxx: 123
|
||||
});
|
||||
|
@ -1,18 +1,10 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>树组件 - layui</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="format-detection" content="telephone=no">
|
||||
|
||||
<link rel="stylesheet" href="../src/css/layui.css" media="all">
|
||||
|
||||
<title>树组件 - layui</title>
|
||||
<link rel="stylesheet" href="../src/css/layui.css" media="all">
|
||||
<style>
|
||||
body{padding: 100px;}
|
||||
#test1,#test2{margin-bottom: 100px; width: 400px;}
|
||||
@ -48,118 +40,118 @@
|
||||
|
||||
//数据源
|
||||
var data1 = [{
|
||||
title: '一级1'
|
||||
title: 'A-1'
|
||||
,id: 1
|
||||
,children: [{
|
||||
title: '二级1-1'
|
||||
title: 'B-1-1'
|
||||
,id: 3
|
||||
,href: 'https://www.layui.com/doc/'
|
||||
,children: [{
|
||||
title: '三级1-1-3'
|
||||
title: 'C-1-1-3'
|
||||
,id: 23
|
||||
,children: [{
|
||||
title: '四级1-1-3-1'
|
||||
title: 'D-1-1-3-1'
|
||||
,id: 24
|
||||
,children: [{
|
||||
title: '五级1-1-3-1-1'
|
||||
title: 'E-1-1-3-1-1'
|
||||
,id: 30
|
||||
},{
|
||||
title: '五级1-1-3-1-2'
|
||||
title: 'E-1-1-3-1-2'
|
||||
,id: 31
|
||||
}]
|
||||
}]
|
||||
},{
|
||||
title: '三级1-1-1'
|
||||
title: 'C-1-1-1'
|
||||
,id: 7
|
||||
,checked: true
|
||||
,children: [{
|
||||
title: '四级1-1-1-1'
|
||||
title: 'D-1-1-1-1'
|
||||
,id: 15
|
||||
//,checked: true
|
||||
,href: 'https://www.layui.com/doc/base/infrastructure.html'
|
||||
}]
|
||||
},{
|
||||
title: '三级1-1-2'
|
||||
title: 'C-1-1-2'
|
||||
,id: 8
|
||||
,children: [{
|
||||
title: '四级1-1-2-1'
|
||||
title: 'D-1-1-2-1'
|
||||
,id: 32
|
||||
}]
|
||||
}]
|
||||
},{
|
||||
title: '二级1-2'
|
||||
title: 'B-1-2'
|
||||
,id: 4
|
||||
,spread: true
|
||||
,children: [{
|
||||
title: '三级1-2-1'
|
||||
title: 'C-1-2-1'
|
||||
,id: 9
|
||||
,checked: true
|
||||
,disabled: true
|
||||
},{
|
||||
title: '三级1-2-2'
|
||||
title: 'C-1-2-2'
|
||||
,id: 10
|
||||
}]
|
||||
},{
|
||||
title: '二级1-3'
|
||||
title: 'B-1-3'
|
||||
,id: 20
|
||||
,children: [{
|
||||
title: '三级1-3-1'
|
||||
title: 'C-1-3-1'
|
||||
,id: 21
|
||||
},{
|
||||
title: '三级1-3-2'
|
||||
title: 'C-1-3-2'
|
||||
,id: 22
|
||||
}]
|
||||
}]
|
||||
},{
|
||||
title: '一级2'
|
||||
title: 'A-2'
|
||||
,id: 2
|
||||
,spread: true
|
||||
,children: [{
|
||||
title: '二级2-1'
|
||||
title: 'B-2-1'
|
||||
,id: 5
|
||||
,spread: true
|
||||
,children: [{
|
||||
title: '三级2-1-1'
|
||||
title: 'C-2-1-1'
|
||||
,id: 11
|
||||
},{
|
||||
title: '三级2-1-2'
|
||||
title: 'C-2-1-2'
|
||||
,id: 12
|
||||
}]
|
||||
},{
|
||||
title: '二级2-2'
|
||||
title: 'B-2-2'
|
||||
,id: 6
|
||||
,checked: true
|
||||
,children: [{
|
||||
title: '三级2-2-1'
|
||||
title: 'C-2-2-1'
|
||||
,id: 13
|
||||
},{
|
||||
title: '三级2-2-2'
|
||||
title: 'C-2-2-2'
|
||||
,id: 14
|
||||
,disabled: true
|
||||
}]
|
||||
}]
|
||||
},{
|
||||
title: '一级3'
|
||||
title: 'A-3'
|
||||
,id: 16
|
||||
,children: [{
|
||||
title: '二级3-1'
|
||||
title: 'B-3-1'
|
||||
,id: 17
|
||||
,fixed: true
|
||||
,children: [{
|
||||
title: '三级3-1-1'
|
||||
title: 'C-3-1-1'
|
||||
,id: 18
|
||||
},{
|
||||
title: '三级3-1-2'
|
||||
title: 'C-3-1-2'
|
||||
,id: 19
|
||||
}]
|
||||
},{
|
||||
title: '二级3-2'
|
||||
title: 'B-3-2'
|
||||
,id: 27
|
||||
,children: [{
|
||||
title: '三级3-2-1'
|
||||
title: 'C-3-2-1'
|
||||
,id: 28
|
||||
},{
|
||||
title: '三级3-2-2'
|
||||
title: 'C-3-2-2'
|
||||
,id: 29
|
||||
}]
|
||||
}]
|
||||
@ -222,7 +214,7 @@
|
||||
console.log(checkedData);
|
||||
}
|
||||
,setChecked: function(){
|
||||
tree.setChecked('demoId1', [1000, 1001, 1002]);
|
||||
tree.setChecked('demoId1', [11,12]);
|
||||
}
|
||||
,reload: function(){
|
||||
tree.reload('demoId1', {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "layui",
|
||||
"version": "2.8.10",
|
||||
"version": "2.8.11",
|
||||
"description": "Classic modular Front-End UI library",
|
||||
"main": "dist/layui.js",
|
||||
"license": "MIT",
|
||||
|
@ -16,7 +16,7 @@
|
||||
};
|
||||
|
||||
var Layui = function(){
|
||||
this.v = '2.8.10'; // Layui 版本号
|
||||
this.v = '2.8.11'; // Layui 版本号
|
||||
};
|
||||
|
||||
// 识别预先可能定义的指定全局对象
|
||||
|
@ -6,86 +6,99 @@
|
||||
layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.$
|
||||
,laytpl = layui.laytpl
|
||||
,hint = layui.hint()
|
||||
,device = layui.device()
|
||||
,clickOrMousedown = (device.mobile ? 'touchstart' : 'mousedown')
|
||||
var $ = layui.$;
|
||||
var laytpl = layui.laytpl;
|
||||
var hint = layui.hint();
|
||||
var device = layui.device();
|
||||
var clickOrMousedown = (device.mobile ? 'touchstart' : 'mousedown');
|
||||
|
||||
//模块名
|
||||
,MOD_NAME = 'dropdown'
|
||||
,MOD_INDEX = 'layui_'+ MOD_NAME +'_index' //模块索引名
|
||||
// 模块名
|
||||
var MOD_NAME = 'dropdown';
|
||||
var MOD_INDEX = 'layui_'+ MOD_NAME +'_index'; // 模块索引名
|
||||
|
||||
//外部接口
|
||||
,dropdown = {
|
||||
config: {}
|
||||
,index: layui[MOD_NAME] ? (layui[MOD_NAME].index + 10000) : 0
|
||||
// 外部接口
|
||||
var dropdown = {
|
||||
config: {},
|
||||
index: layui[MOD_NAME] ? (layui[MOD_NAME].index + 10000) : 0,
|
||||
|
||||
//设置全局项
|
||||
,set: function(options){
|
||||
// 设置全局项
|
||||
set: function(options){
|
||||
var that = this;
|
||||
that.config = $.extend({}, that.config, options);
|
||||
return that;
|
||||
}
|
||||
},
|
||||
|
||||
//事件
|
||||
,on: function(events, callback){
|
||||
// 事件
|
||||
on: function(events, callback){
|
||||
return layui.onevent.call(this, MOD_NAME, events, callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//操作当前实例
|
||||
,thisModule = function(){
|
||||
// 操作当前实例
|
||||
var thisModule = function(){
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
var id = options.id;
|
||||
|
||||
thisModule.that[id] = that; //记录当前实例对象
|
||||
thisModule.that[id] = that; // 记录当前实例对象
|
||||
|
||||
return {
|
||||
config: options
|
||||
//重置实例
|
||||
,reload: function(options){
|
||||
config: options,
|
||||
// 重置实例
|
||||
reload: function(options){
|
||||
that.reload.call(that, options);
|
||||
}
|
||||
,reloadData: function(options){
|
||||
},
|
||||
reloadData: function(options){
|
||||
dropdown.reloadData(id, options);
|
||||
}
|
||||
,close: function () {
|
||||
},
|
||||
close: function () {
|
||||
that.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//字符常量
|
||||
,STR_ELEM = 'layui-dropdown', STR_HIDE = 'layui-hide', STR_DISABLED = 'layui-disabled', STR_NONE = 'layui-none'
|
||||
,STR_ITEM_UP = 'layui-menu-item-up', STR_ITEM_DOWN = 'layui-menu-item-down', STR_MENU_TITLE = 'layui-menu-body-title', STR_ITEM_GROUP = 'layui-menu-item-group', STR_ITEM_PARENT = 'layui-menu-item-parent', STR_ITEM_DIV = 'layui-menu-item-divider', STR_ITEM_CHECKED = 'layui-menu-item-checked', STR_ITEM_CHECKED2 = 'layui-menu-item-checked2', STR_MENU_PANEL = 'layui-menu-body-panel', STR_MENU_PANEL_L = 'layui-menu-body-panel-left', STR_ELEM_SHADE = 'layui-dropdown-shade'
|
||||
// 字符常量
|
||||
var STR_ELEM = 'layui-dropdown';
|
||||
var STR_HIDE = 'layui-hide';
|
||||
var STR_DISABLED = 'layui-disabled';
|
||||
var STR_NONE = 'layui-none';
|
||||
var STR_ITEM_UP = 'layui-menu-item-up';
|
||||
var STR_ITEM_DOWN = 'layui-menu-item-down';
|
||||
var STR_MENU_TITLE = 'layui-menu-body-title';
|
||||
var STR_ITEM_GROUP = 'layui-menu-item-group';
|
||||
var STR_ITEM_PARENT = 'layui-menu-item-parent';
|
||||
var STR_ITEM_DIV = 'layui-menu-item-divider';
|
||||
var STR_ITEM_CHECKED = 'layui-menu-item-checked';
|
||||
var STR_ITEM_CHECKED2 = 'layui-menu-item-checked2';
|
||||
var STR_MENU_PANEL = 'layui-menu-body-panel';
|
||||
var STR_MENU_PANEL_L = 'layui-menu-body-panel-left';
|
||||
var STR_ELEM_SHADE = 'layui-dropdown-shade';
|
||||
|
||||
,STR_GROUP_TITLE = '.'+ STR_ITEM_GROUP + '>.'+ STR_MENU_TITLE
|
||||
var STR_GROUP_TITLE = '.'+ STR_ITEM_GROUP + '>.'+ STR_MENU_TITLE;
|
||||
|
||||
//构造器
|
||||
,Class = function(options){
|
||||
// 构造器
|
||||
var Class = function(options){
|
||||
var that = this;
|
||||
that.index = ++dropdown.index;
|
||||
that.config = $.extend({}, that.config, dropdown.config, options);
|
||||
that.init();
|
||||
};
|
||||
|
||||
//默认配置
|
||||
// 默认配置
|
||||
Class.prototype.config = {
|
||||
trigger: 'click' //事件类型
|
||||
,content: '' //自定义菜单内容
|
||||
,className: '' //自定义样式类名
|
||||
,style: '' //设置面板 style 属性
|
||||
,show: false //是否初始即显示菜单面板
|
||||
,isAllowSpread: true //是否允许菜单组展开收缩
|
||||
,isSpreadItem: true //是否初始展开子菜单
|
||||
,data: [] //菜单数据结构
|
||||
,delay: 300 //延迟关闭的毫秒数,若 trigger 为 hover 时才生效
|
||||
,shade: 0 // 遮罩
|
||||
trigger: 'click', // 事件类型
|
||||
content: '', // 自定义菜单内容
|
||||
className: '', // 自定义样式类名
|
||||
style: '', // 设置面板 style 属性
|
||||
show: false, // 是否初始即显示菜单面板
|
||||
isAllowSpread: true, // 是否允许菜单组展开收缩
|
||||
isSpreadItem: true, // 是否初始展开子菜单
|
||||
data: [], // 菜单数据结构
|
||||
delay: 300, // 延迟关闭的毫秒数,若 trigger 为 hover 时才生效
|
||||
shade: 0 // 遮罩
|
||||
};
|
||||
|
||||
//重载实例
|
||||
// 重载实例
|
||||
Class.prototype.reload = function(options, type){
|
||||
var that = this;
|
||||
that.config = $.extend({}, that.config, options);
|
||||
@ -240,19 +253,19 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
views.append(viewLi);
|
||||
});
|
||||
return views;
|
||||
}
|
||||
};
|
||||
|
||||
//主模板
|
||||
,TPL_MAIN = ['<div class="layui-dropdown layui-border-box layui-panel layui-anim layui-anim-downbit" lay-id="' + options.id + '">'
|
||||
// 主模板
|
||||
var TPL_MAIN = ['<div class="layui-dropdown layui-border-box layui-panel layui-anim layui-anim-downbit" lay-id="' + options.id + '">'
|
||||
,'</div>'].join('');
|
||||
|
||||
//如果是右键事件,则每次触发事件时,将允许重新渲染
|
||||
// 如果是右键事件,则每次触发事件时,将允许重新渲染
|
||||
if(options.trigger === 'contextmenu' || lay.isTopElem(options.elem[0])) rerender = true;
|
||||
|
||||
//判断是否已经打开了下拉菜单面板
|
||||
// 判断是否已经打开了下拉菜单面板
|
||||
if(!rerender && options.elem.data(MOD_INDEX +'_opened')) return;
|
||||
|
||||
//记录模板对象
|
||||
// 记录模板对象
|
||||
that.elemView = $('.' + STR_ELEM + '[lay-id="' + options.id + '"]');
|
||||
if (type === 'reloadData' && that.elemView.length) {
|
||||
that.elemView.html(options.content || getDefaultView());
|
||||
@ -260,23 +273,23 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
that.elemView = $(TPL_MAIN);
|
||||
that.elemView.append(options.content || getDefaultView());
|
||||
|
||||
//初始化某些属性
|
||||
// 初始化某些属性
|
||||
if(options.className) that.elemView.addClass(options.className);
|
||||
if(options.style) that.elemView.attr('style', options.style);
|
||||
|
||||
//记录当前执行的实例索引
|
||||
// 记录当前执行的实例索引
|
||||
dropdown.thisId = options.id;
|
||||
|
||||
//插入视图
|
||||
that.remove(); //移除非当前绑定元素的面板
|
||||
// 插入视图
|
||||
that.remove(); // 移除非当前绑定元素的面板
|
||||
elemBody.append(that.elemView);
|
||||
options.elem.data(MOD_INDEX +'_opened', true);
|
||||
|
||||
//遮罩
|
||||
// 遮罩
|
||||
var shade = options.shade ? ('<div class="'+ STR_ELEM_SHADE +'" style="'+ ('z-index:'+ (that.elemView.css('z-index')-1) +'; background-color: ' + (options.shade[1] || '#000') + '; opacity: ' + (options.shade[0] || options.shade)) +'"></div>') : '';
|
||||
that.elemView.before(shade);
|
||||
|
||||
//如果是鼠标移入事件,则鼠标移出时自动关闭
|
||||
// 如果是鼠标移入事件,则鼠标移出时自动关闭
|
||||
if(options.trigger === 'mouseenter'){
|
||||
that.elemView.on('mouseenter', function(){
|
||||
clearTimeout(thisModule.timer);
|
||||
@ -286,17 +299,17 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
}
|
||||
}
|
||||
|
||||
//坐标定位
|
||||
// 坐标定位
|
||||
that.position();
|
||||
thisModule.prevElem = that.elemView; //记录当前打开的元素,以便在下次关闭
|
||||
thisModule.prevElem.data('prevElem', options.elem); //将当前绑定的元素,记录在打开元素的 data 对象中
|
||||
thisModule.prevElem = that.elemView; // 记录当前打开的元素,以便在下次关闭
|
||||
thisModule.prevElem.data('prevElem', options.elem); // 将当前绑定的元素,记录在打开元素的 data 对象中
|
||||
|
||||
//阻止全局事件
|
||||
// 阻止全局事件
|
||||
that.elemView.find('.layui-menu').on(clickOrMousedown, function(e){
|
||||
layui.stope(e);
|
||||
});
|
||||
|
||||
//触发菜单列表事件
|
||||
// 触发菜单列表事件
|
||||
that.elemView.find('.layui-menu li').on('click', function(e){
|
||||
var othis = $(this);
|
||||
var data = othis.data('item') || {};
|
||||
@ -316,7 +329,7 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
}
|
||||
});
|
||||
|
||||
//触发菜单组展开收缩
|
||||
// 触发菜单组展开收缩
|
||||
that.elemView.find(STR_GROUP_TITLE).on('click', function(e){
|
||||
var othis = $(this)
|
||||
,elemGroup = othis.parent()
|
||||
@ -334,26 +347,26 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
);
|
||||
};
|
||||
|
||||
//位置定位
|
||||
// 位置定位
|
||||
Class.prototype.position = function(obj){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
lay.position(options.elem[0], that.elemView[0], {
|
||||
position: options.position
|
||||
,e: that.e
|
||||
,clickType: options.trigger === 'contextmenu' ? 'right' : null
|
||||
,align: options.align || null
|
||||
position: options.position,
|
||||
e: that.e,
|
||||
clickType: options.trigger === 'contextmenu' ? 'right' : null,
|
||||
align: options.align || null
|
||||
});
|
||||
};
|
||||
|
||||
//删除视图
|
||||
// 删除视图
|
||||
Class.prototype.remove = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,elemPrev = thisModule.prevElem;
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
var elemPrev = thisModule.prevElem;
|
||||
|
||||
//若存在已打开的面板元素,则移除
|
||||
// 若存在已打开的面板元素,则移除
|
||||
if(elemPrev){
|
||||
elemPrev.data('prevElem') && (
|
||||
elemPrev.data('prevElem').data(MOD_INDEX +'_opened', false)
|
||||
@ -363,10 +376,10 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
lay('.' + STR_ELEM_SHADE).remove();
|
||||
};
|
||||
|
||||
//延迟删除视图
|
||||
// 延迟删除视图
|
||||
Class.prototype.delayRemove = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
clearTimeout(thisModule.timer);
|
||||
|
||||
thisModule.timer = setTimeout(function(){
|
||||
@ -374,18 +387,18 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
}, options.delay);
|
||||
};
|
||||
|
||||
//事件
|
||||
// 事件
|
||||
Class.prototype.events = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
//如果传入 hover,则解析为 mouseenter
|
||||
// 若传入 hover,则解析为 mouseenter
|
||||
if(options.trigger === 'hover') options.trigger = 'mouseenter';
|
||||
|
||||
//解除上一个事件
|
||||
// 解除上一个事件
|
||||
if(that.prevElem) that.prevElem.off(options.trigger, that.prevElemCallback);
|
||||
|
||||
//记录被绑定的元素及回调
|
||||
// 记录被绑定的元素及回调
|
||||
that.prevElem = options.elem;
|
||||
that.prevElemCallback = function(e){
|
||||
clearTimeout(thisModule.timer);
|
||||
@ -394,47 +407,48 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
//触发元素事件
|
||||
// 触发元素事件
|
||||
options.elem.on(options.trigger, that.prevElemCallback);
|
||||
|
||||
//如果是鼠标移入事件
|
||||
// 如果是鼠标移入事件
|
||||
if(options.trigger === 'mouseenter'){
|
||||
//直行鼠标移出事件
|
||||
// 直行鼠标移出事件
|
||||
options.elem.on('mouseleave', function(){
|
||||
that.delayRemove();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//记录所有实例
|
||||
thisModule.that = {}; //记录所有实例对象
|
||||
// 记录所有实例
|
||||
thisModule.that = {}; // 记录所有实例对象
|
||||
|
||||
//获取当前实例对象
|
||||
// 获取当前实例对象
|
||||
thisModule.getThis = function(id){
|
||||
var that = thisModule.that[id];
|
||||
if(!that) hint.error(id ? (MOD_NAME +' instance with ID \''+ id +'\' not found') : 'ID argument required');
|
||||
return that;
|
||||
};
|
||||
|
||||
//设置菜单组展开和收缩状态
|
||||
// 设置菜单组展开和收缩状态
|
||||
thisModule.spread = function(othis){
|
||||
//菜单组展开和收缩
|
||||
var elemIcon = othis.children('.'+ STR_MENU_TITLE).find('.layui-icon');
|
||||
if(othis.hasClass(STR_ITEM_UP)){
|
||||
// 菜单组展开和收缩
|
||||
var needSpread = othis.hasClass(STR_ITEM_UP);
|
||||
var elemIcon = othis.children('.'+ STR_MENU_TITLE).find('.layui-icon-' + (needSpread ? 'down' : 'up'));
|
||||
if(needSpread){
|
||||
othis.removeClass(STR_ITEM_UP).addClass(STR_ITEM_DOWN);
|
||||
elemIcon.removeClass('layui-icon-down').addClass('layui-icon-up');
|
||||
} else {
|
||||
othis.removeClass(STR_ITEM_DOWN).addClass(STR_ITEM_UP);
|
||||
elemIcon.removeClass('layui-icon-up').addClass('layui-icon-down')
|
||||
elemIcon.removeClass('layui-icon-up').addClass('layui-icon-down');
|
||||
}
|
||||
};
|
||||
|
||||
//全局事件
|
||||
;!function(){
|
||||
var _WIN = $(window)
|
||||
,_DOC = $(document);
|
||||
// 全局事件
|
||||
(function(){
|
||||
var _WIN = $(window);
|
||||
var _DOC = $(document);
|
||||
|
||||
//自适应定位
|
||||
// 自适应定位
|
||||
_WIN.on('resize', function(){
|
||||
if(!dropdown.thisId) return;
|
||||
var that = thisModule.getThis(dropdown.thisId);
|
||||
@ -455,7 +469,7 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
|
||||
|
||||
|
||||
//点击任意处关闭
|
||||
// 点击任意处关闭
|
||||
_DOC.on(clickOrMousedown, function(e){
|
||||
if(!dropdown.thisId) return;
|
||||
var that = thisModule.getThis(dropdown.thisId)
|
||||
@ -463,8 +477,8 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
|
||||
var options = that.config;
|
||||
|
||||
//如果触发的是绑定的元素,或者属于绑定元素的子元素,则不关闭
|
||||
//满足条件:当前绑定的元素不是 body document,或者不是鼠标右键事件
|
||||
// 若触发的是绑定的元素,或者属于绑定元素的子元素,则不关闭
|
||||
// 满足条件:当前绑定的元素不是 body document,或者不是鼠标右键事件
|
||||
if(!(lay.isTopElem(options.elem[0]) || options.trigger === 'contextmenu')){
|
||||
if(
|
||||
e.target === options.elem[0] ||
|
||||
@ -477,76 +491,76 @@ layui.define(['jquery', 'laytpl', 'lay'], function(exports){
|
||||
that.remove();
|
||||
});
|
||||
|
||||
//基础菜单的静态元素事件
|
||||
// 基础菜单的静态元素事件
|
||||
var ELEM_LI = '.layui-menu:not(.layui-dropdown-menu) li';
|
||||
_DOC.on('click', ELEM_LI, function(e){
|
||||
var othis = $(this)
|
||||
,parent = othis.parents('.layui-menu').eq(0)
|
||||
,isChild = othis.hasClass(STR_ITEM_GROUP) || othis.hasClass(STR_ITEM_PARENT)
|
||||
,filter = parent.attr('lay-filter') || parent.attr('id')
|
||||
,options = lay.options(this);
|
||||
var othis = $(this);
|
||||
var parent = othis.parents('.layui-menu').eq(0);
|
||||
var isChild = othis.hasClass(STR_ITEM_GROUP) || othis.hasClass(STR_ITEM_PARENT);
|
||||
var filter = parent.attr('lay-filter') || parent.attr('id');
|
||||
var options = lay.options(this);
|
||||
|
||||
//非触发元素
|
||||
// 非触发元素
|
||||
if(othis.hasClass(STR_ITEM_DIV)) return;
|
||||
|
||||
//非菜单组
|
||||
// 非菜单组
|
||||
if(!isChild){
|
||||
//选中
|
||||
parent.find('.'+ STR_ITEM_CHECKED).removeClass(STR_ITEM_CHECKED); //清除选中样式
|
||||
parent.find('.'+ STR_ITEM_CHECKED2).removeClass(STR_ITEM_CHECKED2); //清除父级菜单选中样式
|
||||
// 选中
|
||||
parent.find('.'+ STR_ITEM_CHECKED).removeClass(STR_ITEM_CHECKED); // 清除选中样式
|
||||
parent.find('.'+ STR_ITEM_CHECKED2).removeClass(STR_ITEM_CHECKED2); // 清除父级菜单选中样式
|
||||
othis.addClass(STR_ITEM_CHECKED); //添加选中样式
|
||||
othis.parents('.'+ STR_ITEM_PARENT).addClass(STR_ITEM_CHECKED2); //添加父级菜单选中样式
|
||||
othis.parents('.'+ STR_ITEM_PARENT).addClass(STR_ITEM_CHECKED2); // 添加父级菜单选中样式
|
||||
|
||||
options.title = options.title || $.trim(othis.children('.'+ STR_MENU_TITLE).text());
|
||||
|
||||
//触发事件
|
||||
// 触发事件
|
||||
layui.event.call(this, MOD_NAME, 'click('+ filter +')', options);
|
||||
}
|
||||
});
|
||||
|
||||
//基础菜单的展开收缩事件
|
||||
// 基础菜单的展开收缩事件
|
||||
_DOC.on('click', (ELEM_LI + STR_GROUP_TITLE), function(e){
|
||||
var othis = $(this)
|
||||
,elemGroup = othis.parents('.'+ STR_ITEM_GROUP +':eq(0)')
|
||||
,options = lay.options(elemGroup[0]);
|
||||
var othis = $(this);
|
||||
var elemGroup = othis.parents('.'+ STR_ITEM_GROUP +':eq(0)');
|
||||
var options = lay.options(elemGroup[0]);
|
||||
|
||||
if(('isAllowSpread' in options) ? options.isAllowSpread : true){
|
||||
thisModule.spread(elemGroup);
|
||||
}
|
||||
});
|
||||
|
||||
//判断子级菜单是否超出屏幕
|
||||
// 判断子级菜单是否超出屏幕
|
||||
var ELEM_LI_PAR = '.layui-menu .'+ STR_ITEM_PARENT
|
||||
_DOC.on('mouseenter', ELEM_LI_PAR, function(e){
|
||||
var othis = $(this)
|
||||
,elemPanel = othis.find('.'+ STR_MENU_PANEL);
|
||||
var othis = $(this);
|
||||
var elemPanel = othis.find('.'+ STR_MENU_PANEL);
|
||||
|
||||
if(!elemPanel[0]) return;
|
||||
var rect = elemPanel[0].getBoundingClientRect();
|
||||
|
||||
//是否超出右侧屏幕
|
||||
// 是否超出右侧屏幕
|
||||
if(rect.right > _WIN.width()){
|
||||
elemPanel.addClass(STR_MENU_PANEL_L);
|
||||
//不允许超出左侧屏幕
|
||||
// 不允许超出左侧屏幕
|
||||
rect = elemPanel[0].getBoundingClientRect();
|
||||
if(rect.left < 0){
|
||||
elemPanel.removeClass(STR_MENU_PANEL_L);
|
||||
}
|
||||
}
|
||||
|
||||
//是否超出底部屏幕
|
||||
// 是否超出底部屏幕
|
||||
if(rect.bottom > _WIN.height()){
|
||||
elemPanel.eq(0).css('margin-top', -(rect.bottom - _WIN.height() + 5));
|
||||
}
|
||||
}).on('mouseleave', ELEM_LI_PAR, function(e){
|
||||
var othis = $(this)
|
||||
,elemPanel = othis.children('.'+ STR_MENU_PANEL);
|
||||
var elemPanel = othis.children('.'+ STR_MENU_PANEL);
|
||||
|
||||
elemPanel.removeClass(STR_MENU_PANEL_L);
|
||||
elemPanel.css('margin-top', 0);
|
||||
});
|
||||
|
||||
}();
|
||||
})();
|
||||
|
||||
// 关闭面板
|
||||
dropdown.close = function(id){
|
||||
|
@ -46,7 +46,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||
'请输入正确的身份证号'
|
||||
]
|
||||
},
|
||||
verIncludelRequired: false, // 验证规则是否包含必填 --- 为兼容旧版的验证机制
|
||||
verIncludeRequired: false, // 验证规则是否包含必填 --- 为兼容旧版的验证机制
|
||||
autocomplete: null // 全局 autocomplete 状态。 null 表示不干预
|
||||
};
|
||||
};
|
||||
@ -277,10 +277,11 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||
value: ['up', 'down'],
|
||||
split: true,
|
||||
className: 'layui-input-number',
|
||||
disabled: disabled, // 跟随输入框禁用状态
|
||||
disabled: othis.is('[disabled]'), // 跟随输入框禁用状态
|
||||
click: function(elem){
|
||||
var index = $(this).index();
|
||||
var value = elem.val();
|
||||
var rawValue = value;
|
||||
var step = Number(elem.attr('step')) || 1; // 加减的数字间隔
|
||||
var min = Number(elem.attr('min'));
|
||||
var max = Number(elem.attr('max'));
|
||||
@ -294,11 +295,15 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||
if(value < min) value = min;
|
||||
if(value > max) value = max;
|
||||
|
||||
// 小数点后保留位数
|
||||
var fixed = function(step){
|
||||
var decimals = (step.match(/\.(\d+$)/) || [])[1] || '';
|
||||
// 获取小数点后位数
|
||||
var decimals = function(step){
|
||||
var decimals = (step.toString().match(/\.(\d+$)/) || [])[1] || '';
|
||||
return decimals.length;
|
||||
}(step.toString());
|
||||
};
|
||||
|
||||
// 位数比较
|
||||
var fixed = Math.max(decimals(step), decimals(rawValue));
|
||||
|
||||
if(fixed) value = value.toFixed(fixed);
|
||||
|
||||
elem.val(value);
|
||||
@ -386,7 +391,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||
// 如果是第一项,且文本值等于 placeholder,则清空初始值
|
||||
if(selectedIndex === 0 && initValue === input.attr('placeholder')){
|
||||
initValue = '';
|
||||
};
|
||||
}
|
||||
|
||||
// 如果有选中值,则将输入框纠正为该值。否则清空输入框
|
||||
input.val(initValue || '');
|
||||
@ -576,7 +581,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||
// 如果是第一项,且文本值等于 placeholder,则清空初始值
|
||||
if(selectedIndex === 0 && initValue === input.attr('placeholder')){
|
||||
initValue = '';
|
||||
};
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
notOption(input.val(), function(none){
|
||||
@ -807,12 +812,12 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||
var next = $(this).next('.' + CLASS);
|
||||
this.checked = false;
|
||||
next.removeClass(CLASS + 'ed');
|
||||
next.find('.layui-icon').removeClass(ANIM + ' ' + ICON[0]).addClass(ICON[1]);
|
||||
next.children('.layui-icon').removeClass(ANIM + ' ' + ICON[0]).addClass(ICON[1]);
|
||||
});
|
||||
|
||||
radio[0].checked = true;
|
||||
reElem.addClass(CLASS + 'ed');
|
||||
reElem.find('.layui-icon').addClass(ANIM + ' ' + ICON[0]);
|
||||
reElem.children('.layui-icon').addClass(ANIM + ' ' + ICON[0]);
|
||||
|
||||
layui.event.call(radio[0], MOD_NAME, 'radio('+ filter +')', {
|
||||
elem: radio[0],
|
||||
@ -928,7 +933,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||
|
||||
// 匹配验证规则
|
||||
if(rule){
|
||||
var isTrue = typeof rule === 'function'
|
||||
isTrue = typeof rule === 'function'
|
||||
? errorText = rule(value, item)
|
||||
: !rule[0].test(value);
|
||||
|
||||
@ -946,7 +951,7 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||
|
||||
// 若为必填项或者非空命中校验,则阻止提交,弹出提示
|
||||
if(isTrue && (
|
||||
options.verIncludelRequired || (
|
||||
options.verIncludeRequired || (
|
||||
thisVer === 'required' || (
|
||||
value && thisVer !== 'required'
|
||||
)
|
||||
|
@ -6,12 +6,15 @@
|
||||
;!function(window, undefined){
|
||||
"use strict";
|
||||
|
||||
var isLayui = window.layui && layui.define, $, win, ready = {
|
||||
var isLayui = window.layui && layui.define;
|
||||
var $;
|
||||
var win;
|
||||
var ready = {
|
||||
getPath: function(){
|
||||
var jsPath = document.currentScript ? document.currentScript.src : function(){
|
||||
var js = document.scripts
|
||||
,last = js.length - 1
|
||||
,src;
|
||||
var js = document.scripts;
|
||||
var last = js.length - 1;
|
||||
var src;
|
||||
for(var i = last; i > 0; i--){
|
||||
if(js[i].readyState === 'interactive'){
|
||||
src = js[i].src;
|
||||
@ -19,8 +22,8 @@ var isLayui = window.layui && layui.define, $, win, ready = {
|
||||
}
|
||||
}
|
||||
return src || js[last].src;
|
||||
}()
|
||||
,GLOBAL = window.LAYUI_GLOBAL || {};
|
||||
}();
|
||||
var GLOBAL = window.LAYUI_GLOBAL || {};
|
||||
return GLOBAL.layer_dir || jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
|
||||
}(),
|
||||
config: {
|
||||
@ -32,29 +35,29 @@ var isLayui = window.layui && layui.define, $, win, ready = {
|
||||
minStackArr: [],
|
||||
btn: ['确定', '取消'],
|
||||
|
||||
//五种原始层模式
|
||||
// 五种原始层模式
|
||||
type: ['dialog', 'page', 'iframe', 'loading', 'tips'],
|
||||
|
||||
//获取节点的style属性值
|
||||
// 获取节点的 style 属性值
|
||||
getStyle: function(node, name){
|
||||
var style = node.currentStyle ? node.currentStyle : window.getComputedStyle(node, null);
|
||||
return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name);
|
||||
},
|
||||
|
||||
//载入 CSS 依赖
|
||||
// 载入 CSS 依赖
|
||||
link: function(href, fn, cssname){
|
||||
//未设置路径,则不主动加载css
|
||||
// 未设置路径,则不主动加载 css
|
||||
if(!layer.path) return;
|
||||
|
||||
var head = document.getElementsByTagName("head")[0]
|
||||
,link = document.createElement('link');
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
var link = document.createElement('link');
|
||||
|
||||
if(typeof fn === 'string') cssname = fn;
|
||||
|
||||
var app = (cssname || href).replace(/\.|\//g, '');
|
||||
var id = 'layuicss-'+ app
|
||||
,STATUS_NAME = 'creating'
|
||||
,timeout = 0;
|
||||
var id = 'layuicss-'+ app;
|
||||
var STATUS_NAME = 'creating'
|
||||
var timeout = 0;
|
||||
|
||||
link.rel = 'stylesheet';
|
||||
link.href = layer.path + href;
|
||||
@ -66,21 +69,21 @@ var isLayui = window.layui && layui.define, $, win, ready = {
|
||||
|
||||
if(typeof fn !== 'function') return;
|
||||
|
||||
//轮询 css 是否加载完毕
|
||||
// 轮询 css 是否加载完毕
|
||||
(function poll(status) {
|
||||
var delay = 100
|
||||
,getLinkElem = document.getElementById(id); //获取动态插入的 link 元素
|
||||
var delay = 100;
|
||||
var getLinkElem = document.getElementById(id); // 获取动态插入的 link 元素
|
||||
|
||||
//如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范
|
||||
// 如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范
|
||||
if(++timeout > 10 * 1000 / delay){
|
||||
return window.console && console.error(app +'.css: Invalid');
|
||||
}
|
||||
|
||||
//css 加载就绪
|
||||
// css 加载就绪
|
||||
if(parseInt(ready.getStyle(getLinkElem, 'width')) === 1989){
|
||||
//如果参数来自于初始轮询(即未加载就绪时的),则移除 link 标签状态
|
||||
// 如果参数来自于初始轮询(即未加载就绪时的),则移除 link 标签状态
|
||||
if(status === STATUS_NAME) getLinkElem.removeAttribute('lay-status');
|
||||
//如果 link 标签的状态仍为「创建中」,则继续进入轮询,直到状态改变,则执行回调
|
||||
// 如果 link 标签的状态仍为「创建中」,则继续进入轮询,直到状态改变,则执行回调
|
||||
getLinkElem.getAttribute('lay-status') === STATUS_NAME ? setTimeout(poll, delay) : fn();
|
||||
} else {
|
||||
getLinkElem.setAttribute('lay-status', STATUS_NAME);
|
||||
@ -89,19 +92,19 @@ var isLayui = window.layui && layui.define, $, win, ready = {
|
||||
}, delay);
|
||||
}
|
||||
|
||||
//parseInt(ready.getStyle(document.getElementById(id), 'width')) === 1989 ? fn() : setTimeout(poll, 1000);
|
||||
// parseInt(ready.getStyle(document.getElementById(id), 'width')) === 1989 ? fn() : setTimeout(poll, 1000);
|
||||
}());
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//默认内置方法。
|
||||
// 默认内置方法。
|
||||
var layer = {
|
||||
v: '3.6.0',
|
||||
ie: function(){ //ie 版本
|
||||
v: '3.7.0',
|
||||
ie: function(){ // ie 版本
|
||||
var agent = navigator.userAgent.toLowerCase();
|
||||
return (!!window.ActiveXObject || "ActiveXObject" in window) ? (
|
||||
(agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于 ie11 并没有 msie 的标识
|
||||
(agent.match(/msie\s(\d+)/) || [])[1] || '11' // 由于 ie11 并没有 msie 的标识
|
||||
) : false;
|
||||
}(),
|
||||
index: (window.layer && window.layer.v) ? 100000 : 0,
|
||||
@ -112,12 +115,12 @@ var layer = {
|
||||
layer.path = ready.config.path || layer.path;
|
||||
typeof options.extend === 'string' && (options.extend = [options.extend]);
|
||||
|
||||
//如果设置了路径,则加载样式
|
||||
// 如果设置了路径,则加载样式
|
||||
if(ready.config.path) layer.ready();
|
||||
|
||||
if(!options.extend) return this;
|
||||
|
||||
//加载 css
|
||||
// 加载 css
|
||||
isLayui
|
||||
? layui.addcss('modules/layer/' + options.extend)
|
||||
: ready.link('css/' + options.extend);
|
||||
@ -140,7 +143,7 @@ var layer = {
|
||||
return this;
|
||||
},
|
||||
|
||||
//各种快捷引用
|
||||
// 各种快捷引用
|
||||
alert: function(content, options, yes){
|
||||
var type = typeof options === 'function';
|
||||
if(type) yes = options;
|
||||
@ -164,7 +167,7 @@ var layer = {
|
||||
}, type ? {} : options));
|
||||
},
|
||||
|
||||
msg: function(content, options, end){ //最常用提示层
|
||||
msg: function(content, options, end){ // 最常用提示层
|
||||
var type = typeof options === 'function', rskin = ready.config.skin;
|
||||
var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg';
|
||||
var anim = doms.anim.length - 1;
|
||||
@ -222,7 +225,7 @@ var Class = function(setings){
|
||||
that.creat();
|
||||
};
|
||||
that.index = ++layer.index;
|
||||
that.config.maxWidth = $(win).width() - 15*2; //初始最大宽度:当前屏幕宽,左右留 15px 边距
|
||||
that.config.maxWidth = $(win).width() - 15*2; // 初始最大宽度:当前屏幕宽,左右留 15px 边距
|
||||
that.config = $.extend({}, that.config, ready.config, setings);
|
||||
document.body ? creat() : setTimeout(function(){
|
||||
creat();
|
||||
@ -231,7 +234,7 @@ var Class = function(setings){
|
||||
|
||||
Class.pt = Class.prototype;
|
||||
|
||||
//缓存常用字符
|
||||
// 缓存常用字符
|
||||
var doms = ['layui-layer', '.layui-layer-title', '.layui-layer-main', '.layui-layer-dialog', 'layui-layer-iframe', 'layui-layer-content', 'layui-layer-btn', 'layui-layer-close'];
|
||||
|
||||
// 内置动画类
|
||||
@ -278,7 +281,7 @@ Class.pt.config = {
|
||||
tips: 2
|
||||
};
|
||||
|
||||
//容器
|
||||
// 容器
|
||||
Class.pt.vessel = function(conType, callback){
|
||||
var that = this, times = that.index, config = that.config;
|
||||
var zIndex = config.zIndex + times, titype = typeof config.title === 'object';
|
||||
@ -454,7 +457,7 @@ Class.pt.creat = function(){
|
||||
break;
|
||||
}
|
||||
|
||||
//建立容器
|
||||
// 建立容器
|
||||
that.vessel(conType, function(html, titleHTML, moveElem){
|
||||
body.append(html[0]);
|
||||
conType ? function(){
|
||||
@ -475,7 +478,7 @@ Class.pt.creat = function(){
|
||||
config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times);
|
||||
}).auto(times);
|
||||
|
||||
//遮罩
|
||||
// 遮罩
|
||||
that.shadeo.css({
|
||||
'background-color': config.shade[1] || '#000'
|
||||
,'opacity': config.shade[0] || config.shade
|
||||
@ -483,10 +486,10 @@ Class.pt.creat = function(){
|
||||
|
||||
config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]);
|
||||
|
||||
//坐标自适应浏览器窗口尺寸
|
||||
// 坐标自适应浏览器窗口尺寸
|
||||
config.type == 4 ? that.tips() : function(){
|
||||
that.offset()
|
||||
//首次弹出时,若 css 尚未加载,则等待 css 加载完毕后,重新设定尺寸
|
||||
// 首次弹出时,若 css 尚未加载,则等待 css 加载完毕后,重新设定尺寸
|
||||
parseInt(ready.getStyle(document.getElementById(doms.MOVE), 'z-index')) || function(){
|
||||
that.layero.css('visibility', 'hidden');
|
||||
layer.ready(function(){
|
||||
@ -534,22 +537,22 @@ Class.pt.resize = function(){
|
||||
config.type == 4 && that.tips();
|
||||
};
|
||||
|
||||
//自适应
|
||||
// 自适应
|
||||
Class.pt.auto = function(index){
|
||||
var that = this, config = that.config, layero = $('#'+ doms[0] + index);
|
||||
|
||||
if(config.area[0] === '' && config.maxWidth > 0){
|
||||
//为了修复IE7下一个让人难以理解的bug
|
||||
// 适配 ie7
|
||||
if(layer.ie && layer.ie < 8 && config.btn){
|
||||
layero.width(layero.innerWidth());
|
||||
}
|
||||
layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth);
|
||||
}
|
||||
|
||||
var area = [layero.innerWidth(), layero.innerHeight()]
|
||||
,titHeight = layero.find(doms[1]).outerHeight() || 0
|
||||
,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0
|
||||
,setHeight = function(elem){
|
||||
var area = [layero.innerWidth(), layero.innerHeight()];
|
||||
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
||||
var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
|
||||
var setHeight = function(elem){
|
||||
elem = layero.find(elem);
|
||||
elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding-top'))|0));
|
||||
};
|
||||
@ -576,7 +579,7 @@ Class.pt.auto = function(index){
|
||||
return that;
|
||||
};
|
||||
|
||||
//计算坐标
|
||||
// 计算坐标
|
||||
Class.pt.offset = function(){
|
||||
var that = this, config = that.config, layero = that.layero;
|
||||
var area = [layero.outerWidth(), layero.outerHeight()];
|
||||
@ -589,24 +592,24 @@ Class.pt.offset = function(){
|
||||
that.offsetLeft = config.offset[1]||that.offsetLeft;
|
||||
} else if(config.offset !== 'auto'){
|
||||
|
||||
if(config.offset === 't'){ //上
|
||||
if(config.offset === 't'){ // 上
|
||||
that.offsetTop = 0;
|
||||
} else if(config.offset === 'r'){ //右
|
||||
} else if(config.offset === 'r'){ // 右
|
||||
that.offsetLeft = win.width() - area[0];
|
||||
} else if(config.offset === 'b'){ //下
|
||||
} else if(config.offset === 'b'){ // 下
|
||||
that.offsetTop = win.height() - area[1];
|
||||
} else if(config.offset === 'l'){ //左
|
||||
} else if(config.offset === 'l'){ // 左
|
||||
that.offsetLeft = 0;
|
||||
} else if(config.offset === 'lt'){ //左上角
|
||||
} else if(config.offset === 'lt'){ // 左上
|
||||
that.offsetTop = 0;
|
||||
that.offsetLeft = 0;
|
||||
} else if(config.offset === 'lb'){ //左下角
|
||||
} else if(config.offset === 'lb'){ // 左下
|
||||
that.offsetTop = win.height() - area[1];
|
||||
that.offsetLeft = 0;
|
||||
} else if(config.offset === 'rt'){ //右上角
|
||||
} else if(config.offset === 'rt'){ // 右上
|
||||
that.offsetTop = 0;
|
||||
that.offsetLeft = win.width() - area[0];
|
||||
} else if(config.offset === 'rb'){ //右下角
|
||||
} else if(config.offset === 'rb'){ // 右下
|
||||
that.offsetTop = win.height() - area[1];
|
||||
that.offsetLeft = win.width() - area[0];
|
||||
} else {
|
||||
@ -639,7 +642,7 @@ Class.pt.offset = function(){
|
||||
});
|
||||
};
|
||||
|
||||
//Tips
|
||||
// Tips
|
||||
Class.pt.tips = function(){
|
||||
var that = this, config = that.config, layero = that.layero;
|
||||
var layArea = [layero.outerWidth(), layero.outerHeight()], follow = $(config.follow);
|
||||
@ -663,20 +666,20 @@ Class.pt.tips = function(){
|
||||
}
|
||||
};
|
||||
|
||||
//辨别tips的方位
|
||||
goal.where = [function(){ //上
|
||||
// 辨别 tips 的方位
|
||||
goal.where = [function(){ // 上
|
||||
goal.autoLeft();
|
||||
goal.tipTop = goal.top - layArea[1] - 10;
|
||||
tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]);
|
||||
}, function(){ //右
|
||||
}, function(){ // 右
|
||||
goal.tipLeft = goal.left + goal.width + 10;
|
||||
goal.tipTop = goal.top;
|
||||
tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]);
|
||||
}, function(){ //下
|
||||
}, function(){ // 下
|
||||
goal.autoLeft();
|
||||
goal.tipTop = goal.top + goal.height + 10;
|
||||
tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]);
|
||||
}, function(){ //左
|
||||
}, function(){ // 左
|
||||
goal.tipLeft = goal.left - layArea[0] - 10;
|
||||
goal.tipTop = goal.top;
|
||||
tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]);
|
||||
@ -704,31 +707,31 @@ Class.pt.tips = function(){
|
||||
});
|
||||
}
|
||||
|
||||
//拖拽层
|
||||
// 拖拽层
|
||||
Class.pt.move = function(){
|
||||
var that = this
|
||||
,config = that.config
|
||||
,_DOC = $(document)
|
||||
,layero = that.layero
|
||||
,DATA_NAME = ['LAY_MOVE_DICT', 'LAY_RESIZE_DICT']
|
||||
,moveElem = layero.find(config.move)
|
||||
,resizeElem = layero.find('.layui-layer-resize');
|
||||
var that = this;
|
||||
var config = that.config;
|
||||
var _DOC = $(document);
|
||||
var layero = that.layero;
|
||||
var DATA_NAME = ['LAY_MOVE_DICT', 'LAY_RESIZE_DICT'];
|
||||
var moveElem = layero.find(config.move);
|
||||
var resizeElem = layero.find('.layui-layer-resize');
|
||||
|
||||
//给指定元素添加拖动光标
|
||||
// 给指定元素添加拖动光标
|
||||
if(config.move) moveElem.css('cursor', 'move');
|
||||
|
||||
//按下拖动元素
|
||||
// 按下拖动元素
|
||||
moveElem.on('mousedown', function(e){
|
||||
if (e.button) {return;} // 不是左键不处理
|
||||
var othis = $(this)
|
||||
,dict = {};
|
||||
var othis = $(this);
|
||||
var dict = {};
|
||||
|
||||
if(config.move){
|
||||
dict.layero = layero;
|
||||
dict.config = config;
|
||||
dict.offset = [
|
||||
e.clientX - parseFloat(layero.css('left'))
|
||||
,e.clientY - parseFloat(layero.css('top'))
|
||||
e.clientX - parseFloat(layero.css('left')),
|
||||
e.clientY - parseFloat(layero.css('top'))
|
||||
];
|
||||
|
||||
othis.data(DATA_NAME[0], dict);
|
||||
@ -739,10 +742,10 @@ Class.pt.move = function(){
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
//按下右下角拉伸
|
||||
// 按下右下角拉伸
|
||||
resizeElem.on('mousedown', function(e){
|
||||
var othis = $(this)
|
||||
,dict = {};
|
||||
var othis = $(this);
|
||||
var dict = {};
|
||||
|
||||
if(config.resize){
|
||||
dict.layero = layero;
|
||||
@ -762,52 +765,52 @@ Class.pt.move = function(){
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
//拖动元素,避免多次调用实例造成事件叠加
|
||||
// 拖动元素,避免多次调用实例造成事件叠加
|
||||
if(ready.docEvent) return that;
|
||||
_DOC.on('mousemove', function(e){
|
||||
//拖拽移动
|
||||
// 拖拽移动
|
||||
if(ready.eventMoveElem){
|
||||
var dict = ready.eventMoveElem.data(DATA_NAME[0]) || {}
|
||||
,layero = dict.layero
|
||||
,config = dict.config;
|
||||
|
||||
var X = e.clientX - dict.offset[0]
|
||||
,Y = e.clientY - dict.offset[1]
|
||||
,fixed = layero.css('position') === 'fixed';
|
||||
var X = e.clientX - dict.offset[0];
|
||||
var Y = e.clientY - dict.offset[1];
|
||||
var fixed = layero.css('position') === 'fixed';
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
dict.stX = fixed ? 0 : win.scrollLeft();
|
||||
dict.stY = fixed ? 0 : win.scrollTop();
|
||||
|
||||
//控制元素不被拖出窗口外
|
||||
// 控制元素不被拖出窗口外
|
||||
if(!config.moveOut){
|
||||
var setRig = win.width() - layero.outerWidth() + dict.stX
|
||||
,setBot = win.height() - layero.outerHeight() + dict.stY;
|
||||
var setRig = win.width() - layero.outerWidth() + dict.stX;
|
||||
var setBot = win.height() - layero.outerHeight() + dict.stY;
|
||||
X < dict.stX && (X = dict.stX);
|
||||
X > setRig && (X = setRig);
|
||||
Y < dict.stY && (Y = dict.stY);
|
||||
Y > setBot && (Y = setBot);
|
||||
}
|
||||
|
||||
//拖动时跟随鼠标位置
|
||||
// 拖动时跟随鼠标位置
|
||||
layero.css({
|
||||
left: X
|
||||
,top: Y
|
||||
left: X,
|
||||
top: Y
|
||||
});
|
||||
}
|
||||
|
||||
//Resize
|
||||
// Resize
|
||||
if(ready.eventResizeElem){
|
||||
var dict = ready.eventResizeElem.data(DATA_NAME[1]) || {}
|
||||
,config = dict.config;
|
||||
var dict = ready.eventResizeElem.data(DATA_NAME[1]) || {};
|
||||
var config = dict.config;
|
||||
|
||||
var X = e.clientX - dict.offset[0]
|
||||
,Y = e.clientY - dict.offset[1];
|
||||
var X = e.clientX - dict.offset[0];
|
||||
var Y = e.clientY - dict.offset[1];
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
//拉伸宽高
|
||||
// 拉伸宽高
|
||||
layer.style(dict.index, {
|
||||
width: dict.area[0] + X
|
||||
,height: dict.area[1] + Y
|
||||
@ -817,8 +820,8 @@ Class.pt.move = function(){
|
||||
}
|
||||
}).on('mouseup', function(e){
|
||||
if(ready.eventMoveElem){
|
||||
var dict = ready.eventMoveElem.data(DATA_NAME[0]) || {}
|
||||
,config = dict.config;
|
||||
var dict = ready.eventMoveElem.data(DATA_NAME[0]) || {};
|
||||
var config = dict.config;
|
||||
|
||||
ready.eventMoveElem.removeData(DATA_NAME[0]);
|
||||
delete ready.eventMoveElem;
|
||||
@ -832,7 +835,7 @@ Class.pt.move = function(){
|
||||
}
|
||||
});
|
||||
|
||||
ready.docEvent = true; //已给 document 执行全局事件
|
||||
ready.docEvent = true; // 已给 document 执行全局事件
|
||||
return that;
|
||||
};
|
||||
|
||||
@ -850,7 +853,7 @@ Class.pt.callback = function(){
|
||||
}
|
||||
layer.ie == 6 && that.IE6(layero);
|
||||
|
||||
//按钮
|
||||
// 按钮
|
||||
layero.find('.'+ doms[6]).children('a').on('click', function(){
|
||||
var index = $(this).index();
|
||||
if(index === 0){
|
||||
@ -867,29 +870,29 @@ Class.pt.callback = function(){
|
||||
}
|
||||
});
|
||||
|
||||
//取消
|
||||
// 取消
|
||||
function cancel(){
|
||||
var close = config.cancel && config.cancel(that.index, layero, that);
|
||||
close === false || layer.close(that.index);
|
||||
}
|
||||
|
||||
//右上角关闭回调
|
||||
// 右上角关闭回调
|
||||
layero.find('.'+ doms[7]).on('click', cancel);
|
||||
|
||||
//点遮罩关闭
|
||||
// 点遮罩关闭
|
||||
if(config.shadeClose){
|
||||
that.shadeo.on('click', function(){
|
||||
layer.close(that.index);
|
||||
});
|
||||
}
|
||||
|
||||
//最小化
|
||||
// 最小化
|
||||
layero.find('.layui-layer-min').on('click', function(){
|
||||
var min = config.min && config.min(layero, that.index, that);
|
||||
min === false || layer.min(that.index, config);
|
||||
});
|
||||
|
||||
//全屏/还原
|
||||
// 全屏/还原
|
||||
layero.find('.layui-layer-max').on('click', function(){
|
||||
if($(this).hasClass('layui-layer-maxmin')){
|
||||
layer.restore(that.index);
|
||||
@ -905,7 +908,7 @@ Class.pt.callback = function(){
|
||||
config.end && (ready.end[that.index] = config.end);
|
||||
};
|
||||
|
||||
//for ie6 恢复select
|
||||
// for ie6 恢复 select
|
||||
ready.reselect = function(){
|
||||
$.each($('select'), function(index , value){
|
||||
var sthis = $(this);
|
||||
@ -917,7 +920,7 @@ ready.reselect = function(){
|
||||
};
|
||||
|
||||
Class.pt.IE6 = function(layero){
|
||||
//隐藏select
|
||||
// 隐藏select
|
||||
$('select').each(function(index , value){
|
||||
var sthis = $(this);
|
||||
if(!sthis.parents('.'+doms[0])[0]){
|
||||
@ -927,11 +930,11 @@ Class.pt.IE6 = function(layero){
|
||||
});
|
||||
};
|
||||
|
||||
//需依赖原型的对外方法
|
||||
// 需依赖原型的对外方法
|
||||
Class.pt.openLayer = function(){
|
||||
var that = this;
|
||||
|
||||
//置顶当前窗口
|
||||
// 置顶当前窗口
|
||||
layer.zIndex = that.config.zIndex;
|
||||
layer.setTop = function(layero){
|
||||
var setZindex = function(){
|
||||
@ -972,18 +975,18 @@ ready.rescollbar = function(index){
|
||||
|
||||
window.layer = layer;
|
||||
|
||||
//获取子iframe的DOM
|
||||
// 获取子 iframe 的 DOM
|
||||
layer.getChildFrame = function(selector, index){
|
||||
index = index || $('.'+doms[4]).attr('times');
|
||||
return $('#'+ doms[0] + index).find('iframe').contents().find(selector);
|
||||
};
|
||||
|
||||
//得到当前iframe层的索引,子iframe时使用
|
||||
// 得到当前 iframe 层的索引,子 iframe 时使用
|
||||
layer.getFrameIndex = function(name){
|
||||
return $('#'+ name).parents('.'+doms[4]).attr('times');
|
||||
};
|
||||
|
||||
//iframe层自适应宽高
|
||||
// iframe 层自适应宽高
|
||||
layer.iframeAuto = function(index){
|
||||
if(!index) return;
|
||||
var heg = layer.getChildFrame('html', index).outerHeight();
|
||||
@ -994,7 +997,7 @@ layer.iframeAuto = function(index){
|
||||
layero.find('iframe').css({height: heg});
|
||||
};
|
||||
|
||||
//重置iframe url
|
||||
// 重置 iframe url
|
||||
layer.iframeSrc = function(index, url){
|
||||
$('#'+ doms[0] + index).find('iframe').attr('src', url);
|
||||
};
|
||||
@ -1156,13 +1159,13 @@ layer.full = function(index){
|
||||
}, 100);
|
||||
};
|
||||
|
||||
//改变title
|
||||
// 改变 title
|
||||
layer.title = function(name, index){
|
||||
var title = $('#'+ doms[0] + (index || layer.index)).find(doms[1]);
|
||||
title.html(name);
|
||||
};
|
||||
|
||||
//关闭 layer 总方法
|
||||
// 关闭 layer 总方法
|
||||
layer.close = function(index, callback){
|
||||
var layero = function(){
|
||||
var closest = $('.'+ doms[0]).find('#'+ index).closest('.'+ doms[0]);
|
||||
@ -1257,7 +1260,7 @@ layer.close = function(index, callback){
|
||||
}
|
||||
};
|
||||
|
||||
//关闭所有层
|
||||
// 关闭所有层
|
||||
layer.closeAll = function(type, callback){
|
||||
if(typeof type === 'function'){
|
||||
callback = type;
|
||||
@ -1279,17 +1282,18 @@ layer.closeLast = function(type){
|
||||
layer.close($('.layui-layer-'+ type +':last').attr("times"));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
拓展模块,layui 开始合并在一起
|
||||
|
||||
/*
|
||||
* 拓展模块,layui 开始合并在一起
|
||||
*/
|
||||
|
||||
var cache = layer.cache||{}, skin = function(type){
|
||||
|
||||
var cache = layer.cache || {};
|
||||
var skin = function(type){
|
||||
return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : '');
|
||||
};
|
||||
|
||||
//仿系统prompt
|
||||
// 仿系统 prompt
|
||||
layer.prompt = function(options, yes){
|
||||
var style = '', placeholder = '';
|
||||
options = options || {};
|
||||
@ -1312,18 +1316,18 @@ layer.prompt = function(options, yes){
|
||||
delete options.success;
|
||||
|
||||
return layer.open($.extend({
|
||||
type: 1
|
||||
,btn: ['确定','取消']
|
||||
,content: content
|
||||
,skin: 'layui-layer-prompt' + skin('prompt')
|
||||
,maxWidth: win.width()
|
||||
,success: function(layero){
|
||||
type: 1,
|
||||
btn: ['确定','取消'],
|
||||
content: content,
|
||||
skin: 'layui-layer-prompt' + skin('prompt'),
|
||||
maxWidth: win.width(),
|
||||
success: function(layero){
|
||||
prompt = layero.find('.layui-layer-input');
|
||||
prompt.val(options.value || '').focus();
|
||||
typeof success === 'function' && success(layero);
|
||||
}
|
||||
,resize: false
|
||||
,yes: function(index){
|
||||
},
|
||||
resize: false,
|
||||
yes: function(index){
|
||||
var value = prompt.val();
|
||||
if(value.length > (options.maxlength||500)) {
|
||||
layer.tips('最多输入'+ (options.maxlength || 500) +'个字数', prompt, {tips: 1});
|
||||
@ -1334,7 +1338,7 @@ layer.prompt = function(options, yes){
|
||||
}, options));
|
||||
};
|
||||
|
||||
//tab层
|
||||
// tab 层
|
||||
layer.tab = function(options){
|
||||
options = options || {};
|
||||
|
||||
@ -1383,17 +1387,17 @@ layer.tab = function(options){
|
||||
}, options));
|
||||
};
|
||||
|
||||
//相册层
|
||||
// 相册层
|
||||
layer.photos = function(options, loop, key){
|
||||
var dict = {};
|
||||
options = options || {};
|
||||
if(!options.photos) return;
|
||||
|
||||
//若 photos 并非选择器或 jQuery 对象,则为普通 object
|
||||
var isObject = !(typeof options.photos === 'string' || options.photos instanceof $)
|
||||
,photos = isObject ? options.photos : {}
|
||||
,data = photos.data || []
|
||||
,start = photos.start || 0;
|
||||
// 若 photos 并非选择器或 jQuery 对象,则为普通 object
|
||||
var isObject = !(typeof options.photos === 'string' || options.photos instanceof $);
|
||||
var photos = isObject ? options.photos : {};
|
||||
var data = photos.data || [];
|
||||
var start = photos.start || 0;
|
||||
|
||||
dict.imgIndex = (start|0) + 1;
|
||||
options.img = options.img || 'img';
|
||||
@ -1401,8 +1405,8 @@ layer.photos = function(options, loop, key){
|
||||
var success = options.success;
|
||||
delete options.success;
|
||||
|
||||
//如果 options.photos 不是一个对象
|
||||
if(!isObject){ //页面直接获取
|
||||
// 若 options.photos 不是一个对象
|
||||
if(!isObject){ // 页面直接获取
|
||||
var parent = $(options.photos), pushData = function(){
|
||||
data = [];
|
||||
parent.find(options.img).each(function(index){
|
||||
@ -1434,14 +1438,14 @@ layer.photos = function(options, loop, key){
|
||||
}), true);
|
||||
});
|
||||
|
||||
//不直接弹出
|
||||
// 不直接弹出
|
||||
if(!loop) return;
|
||||
|
||||
} else if (data.length === 0){
|
||||
return layer.msg('没有图片');
|
||||
}
|
||||
|
||||
//上一张
|
||||
// 上一张
|
||||
dict.imgprev = function(key){
|
||||
dict.imgIndex--;
|
||||
if(dict.imgIndex < 1){
|
||||
@ -1450,7 +1454,7 @@ layer.photos = function(options, loop, key){
|
||||
dict.tabimg(key);
|
||||
};
|
||||
|
||||
//下一张
|
||||
// 下一张
|
||||
dict.imgnext = function(key,errorMsg){
|
||||
dict.imgIndex++;
|
||||
if(dict.imgIndex > data.length){
|
||||
@ -1460,7 +1464,7 @@ layer.photos = function(options, loop, key){
|
||||
dict.tabimg(key)
|
||||
};
|
||||
|
||||
//方向键
|
||||
// 方向键
|
||||
dict.keyup = function(event){
|
||||
if(!dict.end){
|
||||
var code = event.keyCode;
|
||||
@ -1475,7 +1479,7 @@ layer.photos = function(options, loop, key){
|
||||
}
|
||||
}
|
||||
|
||||
//切换
|
||||
// 切换
|
||||
dict.tabimg = function(key){
|
||||
if(data.length <= 1) return;
|
||||
photos.start = dict.imgIndex - 1;
|
||||
@ -1483,7 +1487,7 @@ layer.photos = function(options, loop, key){
|
||||
return layer.photos(options, true, key);
|
||||
}
|
||||
|
||||
//一些动作
|
||||
// 一些动作
|
||||
dict.event = function(){
|
||||
/*
|
||||
dict.bigimg.hover(function(){
|
||||
@ -1506,7 +1510,7 @@ layer.photos = function(options, loop, key){
|
||||
$(document).on('keyup', dict.keyup);
|
||||
};
|
||||
|
||||
//图片预加载
|
||||
// 图片预加载
|
||||
function loadImage(url, callback, error) {
|
||||
var img = new Image();
|
||||
img.src = url;
|
||||
@ -1533,10 +1537,10 @@ layer.photos = function(options, loop, key){
|
||||
|
||||
var alt = data[start].alt || '';
|
||||
|
||||
//切换图片时不出现动画
|
||||
// 切换图片时不出现动画
|
||||
if(key) options.anim = -1;
|
||||
|
||||
//弹出图片层
|
||||
// 弹出图片层
|
||||
dict.index = layer.open($.extend({
|
||||
type: 1,
|
||||
id: 'layui-layer-photos',
|
||||
@ -1544,10 +1548,10 @@ layer.photos = function(options, loop, key){
|
||||
var imgarea = [img.width, img.height];
|
||||
var winarea = [$(window).width() - 100, $(window).height() - 100];
|
||||
|
||||
//如果 实际图片的宽或者高比 屏幕大(那么进行缩放)
|
||||
// 若实际图片的宽或者高比 屏幕大(那么进行缩放)
|
||||
if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){
|
||||
var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例
|
||||
if(wh[0] > wh[1]){//取缩放比例最大的进行缩放
|
||||
var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];// 取宽度缩放比例、高度缩放比例
|
||||
if(wh[0] > wh[1]){// 取缩放比例最大的进行缩放
|
||||
imgarea[0] = imgarea[0]/wh[0];
|
||||
imgarea[1] = imgarea[1]/wh[0];
|
||||
} else if(wh[0] < wh[1]){
|
||||
@ -1620,7 +1624,7 @@ layer.photos = function(options, loop, key){
|
||||
});
|
||||
};
|
||||
|
||||
//主入口
|
||||
// 主入口
|
||||
ready.run = function(_$){
|
||||
$ = _$;
|
||||
win = $(window);
|
||||
@ -1631,22 +1635,22 @@ ready.run = function(_$){
|
||||
};
|
||||
};
|
||||
|
||||
//加载方式
|
||||
// 加载方式
|
||||
window.layui && layui.define ? (
|
||||
layer.ready()
|
||||
,layui.define('jquery', function(exports){ //layui 加载
|
||||
layer.ready(),
|
||||
layui.define('jquery', function(exports){ // layui
|
||||
layer.path = layui.cache.dir;
|
||||
ready.run(layui.$);
|
||||
|
||||
//暴露模块
|
||||
// export api
|
||||
window.layer = layer;
|
||||
exports('layer', layer);
|
||||
})
|
||||
) : (
|
||||
(typeof define === 'function' && define.amd) ? define(['jquery'], function(){ //requirejs 加载
|
||||
(typeof define === 'function' && define.amd) ? define(['jquery'], function(){ // requirejs
|
||||
ready.run(window.jQuery);
|
||||
return layer;
|
||||
}) : function(){ //普通 script 标签加载
|
||||
}) : function(){ // 普通 script 标签引入
|
||||
layer.ready();
|
||||
ready.run(window.jQuery);
|
||||
}()
|
||||
|
@ -552,18 +552,18 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
|
||||
};
|
||||
|
||||
//初始工具栏
|
||||
// 初始工具栏
|
||||
Class.prototype.renderToolbar = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
var options = that.config
|
||||
|
||||
//添加工具栏左侧模板
|
||||
// 添加工具栏左侧模板
|
||||
var leftDefaultTemp = [
|
||||
'<div class="layui-inline" lay-event="add"><i class="layui-icon layui-icon-add-1"></i></div>'
|
||||
,'<div class="layui-inline" lay-event="update"><i class="layui-icon layui-icon-edit"></i></div>'
|
||||
,'<div class="layui-inline" lay-event="delete"><i class="layui-icon layui-icon-delete"></i></div>'
|
||||
].join('')
|
||||
,elemToolTemp = that.layTool.find('.layui-table-tool-temp');
|
||||
'<div class="layui-inline" lay-event="add"><i class="layui-icon layui-icon-add-1"></i></div>',
|
||||
'<div class="layui-inline" lay-event="update"><i class="layui-icon layui-icon-edit"></i></div>',
|
||||
'<div class="layui-inline" lay-event="delete"><i class="layui-icon layui-icon-delete"></i></div>'
|
||||
].join('');
|
||||
var elemToolTemp = that.layTool.find('.layui-table-tool-temp');
|
||||
|
||||
if(options.toolbar === 'default'){
|
||||
elemToolTemp.html(leftDefaultTemp);
|
||||
@ -574,22 +574,22 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
);
|
||||
}
|
||||
|
||||
//添加工具栏右侧面板
|
||||
// 添加工具栏右侧面板
|
||||
var layout = {
|
||||
filter: {
|
||||
title: '筛选列'
|
||||
,layEvent: 'LAYTABLE_COLS'
|
||||
,icon: 'layui-icon-cols'
|
||||
}
|
||||
,exports: {
|
||||
title: '导出'
|
||||
,layEvent: 'LAYTABLE_EXPORT'
|
||||
,icon: 'layui-icon-export'
|
||||
}
|
||||
,print: {
|
||||
title: '打印'
|
||||
,layEvent: 'LAYTABLE_PRINT'
|
||||
,icon: 'layui-icon-print'
|
||||
title: '筛选列',
|
||||
layEvent: 'LAYTABLE_COLS',
|
||||
icon: 'layui-icon-cols'
|
||||
},
|
||||
exports: {
|
||||
title: '导出',
|
||||
layEvent: 'LAYTABLE_EXPORT',
|
||||
icon: 'layui-icon-export'
|
||||
},
|
||||
print: {
|
||||
title: '打印',
|
||||
layEvent: 'LAYTABLE_PRINT',
|
||||
icon: 'layui-icon-print'
|
||||
}
|
||||
}, iconElem = [];
|
||||
|
||||
@ -608,12 +608,12 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
|
||||
// 分页栏
|
||||
Class.prototype.renderPagebar = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
,layPagebar = that.layPagebar = $('<div class="layui-inline layui-table-pagebar"></div>')
|
||||
var layPagebar = that.layPagebar = $('<div class="layui-inline layui-table-pagebar"></div>');
|
||||
|
||||
//开启分页栏自定义模板
|
||||
// 开启分页栏自定义模板
|
||||
if(options.pagebar){
|
||||
var pagebarHtml = $(options.pagebar).html() || '';
|
||||
pagebarHtml && layPagebar.append(laytpl(pagebarHtml).render(options));
|
||||
@ -621,17 +621,17 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
}
|
||||
};
|
||||
|
||||
//同步表头父列的相关值
|
||||
// 同步表头父列的相关值
|
||||
Class.prototype.setParentCol = function(hide, parentKey){
|
||||
var that = this
|
||||
,options = that.config
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
,parentTh = that.layHeader.find('th[data-key="'+ parentKey +'"]') //获取父列元素
|
||||
,parentColspan = parseInt(parentTh.attr('colspan')) || 0;
|
||||
var parentTh = that.layHeader.find('th[data-key="'+ parentKey +'"]'); // 获取父列元素
|
||||
var parentColspan = parseInt(parentTh.attr('colspan')) || 0;
|
||||
|
||||
if(parentTh[0]){
|
||||
var arrParentKey = parentKey.split('-')
|
||||
,getThisCol = options.cols[arrParentKey[1]][arrParentKey[2]];
|
||||
var arrParentKey = parentKey.split('-');
|
||||
var getThisCol = options.cols[arrParentKey[1]][arrParentKey[2]];
|
||||
|
||||
hide ? parentColspan-- : parentColspan++;
|
||||
|
||||
@ -641,7 +641,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
getThisCol.colspan2 = parentColspan; // 更新实际的 colspan 数
|
||||
getThisCol.hide = parentColspan < 1; // 同步 hide 参数
|
||||
|
||||
//递归,继续往上查询是否有父列
|
||||
// 递归,继续往上查询是否有父列
|
||||
var nextParentKey = parentTh.data('parentkey');
|
||||
nextParentKey && that.setParentCol(hide, nextParentKey);
|
||||
}
|
||||
@ -855,9 +855,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
// 重置表格尺寸/结构
|
||||
Class.prototype.resize = function(){
|
||||
var that = this;
|
||||
that.fullSize(); //让表格铺满
|
||||
that.setColsWidth(); //自适应列宽
|
||||
that.scrollPatch(); //滚动条补丁
|
||||
that.fullSize(); // 让表格铺满
|
||||
that.setColsWidth(); // 自适应列宽
|
||||
that.scrollPatch(); // 滚动条补丁
|
||||
};
|
||||
|
||||
// 表格重载
|
||||
@ -1749,7 +1749,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
return width;
|
||||
};
|
||||
|
||||
//滚动条补丁
|
||||
// 滚动条补丁
|
||||
Class.prototype.scrollPatch = function(){
|
||||
var that = this;
|
||||
var layMainTable = that.layMain.children('table');
|
||||
@ -1784,7 +1784,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
that.layFixed.find(ELEM_BODY).css(
|
||||
'height',
|
||||
layMainTable.height() >= fixHeight ? fixHeight : 'auto'
|
||||
);
|
||||
).scrollTop(that.layMain.scrollTop()); // 固定列滚动条高度
|
||||
|
||||
// 表格宽度小于容器宽度时,隐藏固定列
|
||||
that.layFixRight[
|
||||
@ -2482,11 +2482,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
layui.stope(e);
|
||||
});
|
||||
|
||||
//同步滚动条
|
||||
// 同步滚动条
|
||||
that.layMain.on('scroll', function(){
|
||||
var othis = $(this)
|
||||
,scrollLeft = othis.scrollLeft()
|
||||
,scrollTop = othis.scrollTop();
|
||||
var othis = $(this);
|
||||
var scrollLeft = othis.scrollLeft();
|
||||
var scrollTop = othis.scrollTop();
|
||||
|
||||
that.layHeader.scrollLeft(scrollLeft);
|
||||
that.layTotal.scrollLeft(scrollLeft);
|
||||
@ -2495,7 +2495,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
layer.close(that.tipsIndex);
|
||||
});
|
||||
|
||||
//自适应
|
||||
// 适应
|
||||
_WIN.on('resize', function(){
|
||||
that.resize();
|
||||
});
|
||||
@ -2796,7 +2796,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||
|
||||
// 表合计
|
||||
thatTable && layui.each(thatTable.dataTotal, function(i, o){
|
||||
fieldsIsHide[o.field] || dataTotal.push(o.total);
|
||||
fieldsIsHide[o.field] || dataTotal.push('"' + (o.total || '') + '"');
|
||||
});
|
||||
|
||||
return dataTitle.join(',') + '\r\n' + dataMain.join('\r\n') + '\r\n' + dataTotal.join(',');
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1007,7 +1007,7 @@ layui.define(['table'], function (exports) {
|
||||
layui.stope(event);
|
||||
// 处理数据
|
||||
// var trElem = item.closest('tr');
|
||||
expandNode({trElem}, null, null, null, true);
|
||||
expandNode({trElem: trElem}, null, null, null, true);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user