diff --git a/common/src/main/resources/static/laydate/5.0/theme/default/laydate.css b/common/src/main/resources/static/laydate/5.0/theme/default/laydate.css
deleted file mode 100644
index 30417d03..00000000
--- a/common/src/main/resources/static/laydate/5.0/theme/default/laydate.css
+++ /dev/null
@@ -1,174 +0,0 @@
-/** 图标字体 **/
-@font-face {font-family:'laydate-icon';
- src:url('./font/iconfont.eot');
- src:url('./font/iconfont.eot#iefix') format('embedded-opentype'),
- url('./font/iconfont.svg#iconfont') format('svg'),
- url('./font/iconfont.woff') format('woff'),
- url('./font/iconfont.ttf') format('truetype');
-}
-
-.laydate-icon{
- font-family:"laydate-icon"!important;
- font-size:16px;
- font-style:normal;
- -webkit-font-smoothing:antialiased;
- -moz-osx-font-smoothing:grayscale;
-}
-
-/**
-
- @Name:laydata
- @Author:贤心
-
- **/
-
-html #layuicss-laydate{display:none;position:absolute;width:1989px;}
-
-/* 初始化 */
-.layui-laydate *{margin:0;padding:0;}
-
-/* 主体结构 */
-.layui-laydate, .layui-laydate *{box-sizing:border-box;}
-.layui-laydate{position:absolute;z-index:66666666;margin:5px 0;border-radius:2px;font-size:14px;-webkit-animation-duration:0.3s;animation-duration:0.3s;-webkit-animation-fill-mode:both;animation-fill-mode:both;}
-.layui-laydate-main{width:260px;}
-.layui-laydate-header *,
-.layui-laydate-content td,
-.layui-laydate-list li{transition-duration:.3s;-webkit-transition-duration:.3s;}
-
-@-webkit-keyframes laydate-upbit{ /* 微微往上滑入 */
- from {-webkit-transform:translate3d(0, 20px, 0);opacity:0.3;}
- to {-webkit-transform:translate3d(0, 0, 0); opacity:1;}
-}
-@keyframes laydate-upbit{
- from {transform:translate3d(0, 20px, 0); opacity:0.3;}
- to {transform:translate3d(0, 0, 0); opacity:1;}
-}
-.layui-laydate{-webkit-animation-name:laydate-upbit;animation-name:laydate-upbit;}
-.layui-laydate-static{ position:relative;z-index:0;display:inline-block;margin:0;-webkit-animation:none;animation:none;}
-
-/* 展开年月列表时 */
-.laydate-ym-show .laydate-prev-m,
-.laydate-ym-show .laydate-next-m{display:none!important;}
-.laydate-ym-show .laydate-prev-y,
-.laydate-ym-show .laydate-next-y{display:inline-block!important;}
-.laydate-ym-show .laydate-set-ym span[lay-type="month"]{display:none!important;}
-
-/* 展开时间列表时 */
-.laydate-time-show .layui-laydate-header .layui-icon,
-.laydate-time-show .laydate-set-ym span[lay-type="year"],
-.laydate-time-show .laydate-set-ym span[lay-type="month"]{display:none!important;}
-
-/* 头部结构 */
-.layui-laydate-header{position:relative;line-height:22px;padding:6px 50px 5px;}
-.layui-laydate-header *{display:inline-block;vertical-align:bottom;}
-.layui-laydate-header i{position:absolute;top:6px;padding:0 2px;color:#999;font-size:14px;cursor:pointer;}
-.layui-laydate-header i.laydate-prev-y{left:15px;}
-.layui-laydate-header i.laydate-prev-m{left:45px;}
-.layui-laydate-header i.laydate-next-y{right:15px;}
-.layui-laydate-header i.laydate-next-m{right:45px;}
-.laydate-set-ym{width:100%;text-align:center;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;}
-.laydate-set-ym span{padding:0 5px;cursor:pointer;}
-.laydate-time-text{cursor:default!important;}
-
-/* 主体结构 */
-.layui-laydate-content{position:relative;padding:5px;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;}
-.layui-laydate-content table{border-collapse:collapse;border-spacing:0;}
-.layui-laydate-content th,
-.layui-laydate-content td{width:36px;height:30px;padding:0px;text-align:center;}
-.layui-laydate-content th{font-weight:400;}
-.layui-laydate-content td{position:relative;cursor:pointer;}
-.laydate-day-mark{position:absolute;left:0;top:0;width:100%;height:100%;line-height:30px;font-size:12px;overflow:hidden;}
-.laydate-day-mark::after{position:absolute;content:'';right:2px;top:2px;width:5px;height:5px;border-radius:50%;}
-
-/* 底部结构 */
-.layui-laydate-footer{position:relative;height:36px;line-height:22px;padding:6px 15px;}
-.layui-laydate-footer span{margin-right:15px;display:inline-block;cursor:pointer;font-size:12px;}
-.layui-laydate-footer span:hover{color:#08c;}
-.laydate-footer-btns{position:absolute;right:5px;top:5px;}
-.laydate-footer-btns span{margin:0 0 0 3px;padding:0 8px;border:1px solid #C9C9C9;background-color:#fff; white-space:nowrap;vertical-align:top;border-radius:4px;}
-
-/* 年月列表 */
-.layui-laydate-list{position:absolute;left:0;top:0;width:100%;height:100%;padding:10px;box-sizing:border-box;background-color:#fff;}
-.layui-laydate-list>li{position:relative;display:inline-block;width:33.3%;height:36px;line-height:36px;margin:3px 0;vertical-align:middle;text-align:center;cursor:pointer;}
-.laydate-month-list>li{width:25%;margin:17px 0;}
-.laydate-time-list{}
-.laydate-time-list>li{height:100%;margin:0;line-height:normal;cursor:default;}
-.laydate-time-list p{position:relative;top:-4px;line-height:29px;}
-.laydate-time-list ol{height:181px;overflow:hidden;}
-.laydate-time-list>li:hover ol{overflow-y:auto;}
-.laydate-time-list ol li{width:130%;padding-left:27px;line-height:30px;text-align:left;cursor:pointer;}
-
-/* 提示 */
-.layui-laydate-hint{position:absolute;top:115px;left:50%;width:250px;margin-left:-125px;line-height:20px;padding:15px;text-align:center;font-size:12px;color:#FF5722;}
-
-
-/* 双日历 */
-.layui-laydate-range{width:523px;}
-.layui-laydate-range .layui-laydate-main{display:inline-block;vertical-align:middle;}
-.layui-laydate-range .laydate-main-list-0 .laydate-next-m,
-.layui-laydate-range .laydate-main-list-0 .laydate-next-y,
-.layui-laydate-range .laydate-main-list-1 .laydate-prev-y,
-.layui-laydate-range .laydate-main-list-1 .laydate-prev-m{display:none;}
-.layui-laydate-range .laydate-main-list-1 .layui-laydate-content{border-left:1px solid #e2e2e2;}
-
-
-/* 默认简约主题 */
-.layui-laydate, .layui-laydate-hint{border:1px solid #d2d2d2;box-shadow:0 2px 4px rgba(0,0,0,.12);border-radius:5px;background-color:#fff;color:#666;}
-.layui-laydate-header{border-bottom:1px solid #e2e2e2;}
-.layui-laydate-header i:hover,
-.layui-laydate-header span:hover{color:#08c;}
-.layui-laydate-content{border-top:none 0;border-bottom:none 0;}
-.layui-laydate-content th{color:#333;}
-.layui-laydate-content td{color:#666;}
-.layui-laydate-content td.laydate-selected{background-color:#c2eaff;}
-.laydate-selected:hover{background-color:#c2eaff!important;}
-.layui-laydate-content td:hover,
-.layui-laydate-list li:hover{background-color:#eaeaea;color:#333;}
-.laydate-time-list li ol{margin:0;padding:0;border:1px solid #e2e2e2;border-left-width:0;}
-.laydate-time-list li:first-child ol{border-left-width:1px;}
-.laydate-time-list>li:hover{background:none;}
-.layui-laydate-content .laydate-day-prev,
-.layui-laydate-content .laydate-day-next{color:#d2d2d2;}
-.laydate-selected.laydate-day-prev,
-.laydate-selected.laydate-day-next{background-color:#f8f8f8!important;}
-.layui-laydate-footer{border-top:1px solid #e2e2e2;}
-.layui-laydate-hint{color:#FF5722;}
-.laydate-day-mark::after{background-color:#08c;}
-.layui-laydate-content td.layui-this .laydate-day-mark::after{display:none;}
-.layui-laydate-footer span[lay-type="date"]{color:#08c;}
-.layui-laydate .layui-this{background-color:#08c!important;color:#fff!important;}
-.layui-laydate .laydate-btns-confirm{background-color:#139ce0;border:1px solid #139ce0;color:#fff;}
-.layui-laydate .laydate-btns-confirm:hover{background-color:#08c;color:#fff;}
-.layui-laydate .laydate-disabled,
-.layui-laydate .laydate-disabled:hover{background:none!important;color:#d2d2d2!important;border-color:#d2d2d2;cursor:not-allowed!important;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;}
-
-
-/* 墨绿/自定义背景色主题 */
-.laydate-theme-molv{border:none;}
-.laydate-theme-molv.layui-laydate-range{width:548px}
-.laydate-theme-molv .layui-laydate-main{width:274px;}
-.laydate-theme-molv .layui-laydate-header{border:none;background-color:#009688;}
-.laydate-theme-molv .layui-laydate-header i,
-.laydate-theme-molv .layui-laydate-header span{color:#f6f6f6;}
-.laydate-theme-molv .layui-laydate-header i:hover,
-.laydate-theme-molv .layui-laydate-header span:hover{color:#fff;}
-.laydate-theme-molv .layui-laydate-content{border:1px solid #e2e2e2;border-top:none;border-bottom:none;}
-.laydate-theme-molv .laydate-main-list-1 .layui-laydate-content{border-left:none;}
-.laydate-theme-molv .layui-laydate-footer{border:1px solid #e2e2e2;}
-
-/* 格子主题 */
-.laydate-theme-grid .layui-laydate-content td,
-.laydate-theme-grid .layui-laydate-content thead,
-.laydate-theme-grid .laydate-year-list>li,
-.laydate-theme-grid .laydate-month-list>li{border:1px solid #e2e2e2;}
-.laydate-theme-grid .laydate-selected,
-.laydate-theme-grid .laydate-selected:hover{background-color:#f2f2f2!important;color:#009688!important;}
-.laydate-theme-grid .laydate-selected.laydate-day-prev,
-.laydate-theme-grid .laydate-selected.laydate-day-next{color:#d2d2d2!important;}
-.laydate-theme-grid .laydate-year-list,
-.laydate-theme-grid .laydate-month-list{margin:1px 0 0 1px;}
-.laydate-theme-grid .laydate-year-list>li,
-.laydate-theme-grid .laydate-month-list>li{margin:0 -1px -1px 0;}
-.laydate-theme-grid .laydate-year-list>li{height:43px;line-height:43px;}
-.laydate-theme-grid .laydate-month-list>li{height:71px;line-height:71px;}
-
diff --git a/common/src/main/resources/static/laydate/5.0/laydate.js b/common/src/main/resources/static/laydate/5.3/laydate.js
similarity index 51%
rename from common/src/main/resources/static/laydate/5.0/laydate.js
rename to common/src/main/resources/static/laydate/5.3/laydate.js
index 60a90a20..a84f5a45 100644
--- a/common/src/main/resources/static/laydate/5.0/laydate.js
+++ b/common/src/main/resources/static/laydate/5.3/laydate.js
@@ -1,118 +1,739 @@
-/**
-
- @Name : layDate 5.0.9 日期时间控件
- @Author: 贤心
- @Site:http://www.layui.com/laydate/
- @License:MIT
-
- */
-;!function(){
+/*!
+ * layDate 5.3.1 日期与时间组件(单独版)
+ * MIT Licensed
+ */
+
+
+/*!
+ * Layui
+ * Classic modular Front-End UI library
+ * MIT Licensed
+ */
+
+;!function(win){
"use strict";
- var isLayui = window.layui && layui.define, ready = {
- getPath: function(){
- var jsPath = document.currentScript ? document.currentScript.src : function(){
- var js = document.scripts
- ,last = js.length - 1
- ,src;
- for(var i = last; i > 0; i--){
- if(js[i].readyState === 'interactive'){
- src = js[i].src;
- break;
- }
- }
- return src || js[last].src;
- }();
- return jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
- }()
-
- //获取节点的style属性值
- ,getStyle: function(node, name){
- var style = node.currentStyle ? node.currentStyle : window.getComputedStyle(node, null);
- return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name);
- }
-
- //载入CSS配件
- ,link: function(href, fn, cssname){
-
- //未设置路径,则不主动加载css
- if(!laydate.path) return;
-
- var head = document.getElementsByTagName("head")[0], link = document.createElement('link');
- if(typeof fn === 'string') cssname = fn;
- var app = (cssname || href).replace(/\.|\//g, '');
- var id = 'layuicss-'+ app, timeout = 0;
-
- link.rel = 'stylesheet';
- link.href = laydate.path + href;
- link.id = id;
-
- if(!document.getElementById(id)){
- head.appendChild(link);
- }
-
- if(typeof fn !== 'function') return;
-
- //轮询css是否加载完毕
- (function poll() {
- if(++timeout > 8 * 1000 / 100){
- return window.console && console.error('laydate.css: Invalid');
- };
- parseInt(ready.getStyle(document.getElementById(id), 'width')) === 1989 ? fn() : setTimeout(poll, 100);
- }());
- }
+ var doc = win.document, config = {
+ modules: {} //记录模块物理路径
+ ,status: {} //记录模块加载状态
+ ,timeout: 10 //符合规范的模块请求最长等待秒数
+ ,event: {} //记录模块自定义事件
}
- ,laydate = {
- v: '5.0.9'
- ,config: {} //全局配置项
- ,index: (window.laydate && window.laydate.v) ? 100000 : 0
- ,path: ready.getPath
+ ,Layui = function(){
+ this.v = '2.6.7'; // layui 版本号
+ }
+
+ //识别预先可能定义的指定全局对象
+ ,GLOBAL = win.LAYUI_GLOBAL || {}
+
+ //获取 layui 所在目录
+ ,getPath = function(){
+ var jsPath = doc.currentScript ? doc.currentScript.src : function(){
+ var js = doc.scripts
+ ,last = js.length - 1
+ ,src;
+ for(var i = last; i > 0; i--){
+ if(js[i].readyState === 'interactive'){
+ src = js[i].src;
+ break;
+ }
+ }
+ return src || js[last].src;
+ }();
- //设置全局项
- ,set: function(options){
- var that = this;
- that.config = lay.extend({}, that.config, options);
+ return config.dir = GLOBAL.dir || jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
+ }()
+
+ //异常提示
+ ,error = function(msg, type){
+ type = type || 'log';
+ win.console && console[type] && console[type]('layui error hint: ' + msg);
+ }
+
+ ,isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]'
+
+ //内置模块
+ ,modules = config.builtin = {
+ lay: 'lay' //基础 DOM 操作
+ ,layer: 'layer' //弹层
+ ,laydate: 'laydate' //日期
+ ,laypage: 'laypage' //分页
+ ,laytpl: 'laytpl' //模板引擎
+ ,layedit: 'layedit' //富文本编辑器
+ ,form: 'form' //表单集
+ ,upload: 'upload' //上传
+ ,dropdown: 'dropdown' //下拉菜单
+ ,transfer: 'transfer' //穿梭框
+ ,tree: 'tree' //树结构
+ ,table: 'table' //表格
+ ,element: 'element' //常用元素操作
+ ,rate: 'rate' //评分组件
+ ,colorpicker: 'colorpicker' //颜色选择器
+ ,slider: 'slider' //滑块
+ ,carousel: 'carousel' //轮播
+ ,flow: 'flow' //流加载
+ ,util: 'util' //工具块
+ ,code: 'code' //代码修饰器
+ ,jquery: 'jquery' //DOM 库(第三方)
+
+ ,all: 'all'
+ ,'layui.all': 'layui.all' //聚合标识(功能性的,非真实模块)
+ };
+
+ //记录基础数据
+ Layui.prototype.cache = config;
+
+ //定义模块
+ Layui.prototype.define = function(deps, factory){
+ var that = this
+ ,type = typeof deps === 'function'
+ ,callback = function(){
+ var setApp = function(app, exports){
+ layui[app] = exports;
+ config.status[app] = true;
+ };
+ typeof factory === 'function' && factory(function(app, exports){
+ setApp(app, exports);
+ config.callback[app] = function(){
+ factory(setApp);
+ }
+ });
+ return this;
+ };
+
+ type && (
+ factory = deps,
+ deps = []
+ );
+
+ that.use(deps, callback, null, 'define');
+ return that;
+ };
+
+ //使用特定模块
+ Layui.prototype.use = function(apps, callback, exports, from){
+ var that = this
+ ,dir = config.dir = config.dir ? config.dir : getPath
+ ,head = doc.getElementsByTagName('head')[0];
+
+ apps = function(){
+ if(typeof apps === 'string'){
+ return [apps];
+ }
+ //当第一个参数为 function 时,则自动加载所有内置模块,且执行的回调即为该 function 参数;
+ else if(typeof apps === 'function'){
+ callback = apps;
+ return ['all'];
+ }
+ return apps;
+ }();
+
+ //如果页面已经存在 jQuery 1.7+ 库且所定义的模块依赖 jQuery,则不加载内部 jquery 模块
+ if(win.jQuery && jQuery.fn.on){
+ that.each(apps, function(index, item){
+ if(item === 'jquery'){
+ apps.splice(index, 1);
+ }
+ });
+ layui.jquery = layui.$ = jQuery;
+ }
+
+ var item = apps[0]
+ ,timeout = 0;
+ exports = exports || [];
+
+ //静态资源host
+ config.host = config.host || (dir.match(/\/\/([\s\S]+?)\//)||['//'+ location.host +'/'])[0];
+
+ //加载完毕
+ function onScriptLoad(e, url){
+ var readyRegExp = navigator.platform === 'PLaySTATION 3' ? /^complete$/ : /^(complete|loaded)$/
+ if (e.type === 'load' || (readyRegExp.test((e.currentTarget || e.srcElement).readyState))) {
+ config.modules[item] = url;
+ head.removeChild(node);
+ (function poll() {
+ if(++timeout > config.timeout * 1000 / 4){
+ return error(item + ' is not a valid module', 'error');
+ };
+ config.status[item] ? onCallback() : setTimeout(poll, 4);
+ }());
+ }
+ }
+
+ //回调
+ function onCallback(){
+ exports.push(layui[item]);
+ apps.length > 1 ?
+ that.use(apps.slice(1), callback, exports, from)
+ : ( typeof callback === 'function' && function(){
+ //保证文档加载完毕再执行回调
+ if(layui.jquery && typeof layui.jquery === 'function' && from !== 'define'){
+ return layui.jquery(function(){
+ callback.apply(layui, exports);
+ });
+ }
+ callback.apply(layui, exports);
+ }() );
+ }
+
+ //如果引入了聚合板,内置的模块则不必重复加载
+ if( apps.length === 0 || (layui['layui.all'] && modules[item]) ){
+ return onCallback(), that;
+ }
+
+ //获取加载的模块 URL
+ //如果是内置模块,则按照 dir 参数拼接模块路径
+ //如果是扩展模块,则判断模块路径值是否为 {/} 开头,
+ //如果路径值是 {/} 开头,则模块路径即为后面紧跟的字符。
+ //否则,则按照 base 参数拼接模块路径
+
+ var url = ( modules[item] ? (dir + 'modules/')
+ : (/^\{\/\}/.test(that.modules[item]) ? '' : (config.base || ''))
+ ) + (that.modules[item] || item) + '.js';
+ url = url.replace(/^\{\/\}/, '');
+
+ //如果扩展模块(即:非内置模块)对象已经存在,则不必再加载
+ if(!config.modules[item] && layui[item]){
+ config.modules[item] = url; //并记录起该扩展模块的 url
+ }
+
+ //首次加载模块
+ if(!config.modules[item]){
+ var node = doc.createElement('script');
+
+ node.async = true;
+ node.charset = 'utf-8';
+ node.src = url + function(){
+ var version = config.version === true
+ ? (config.v || (new Date()).getTime())
+ : (config.version||'');
+ return version ? ('?v=' + version) : '';
+ }();
+
+ head.appendChild(node);
+
+ if(node.attachEvent && !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && !isOpera){
+ node.attachEvent('onreadystatechange', function(e){
+ onScriptLoad(e, url);
+ });
+ } else {
+ node.addEventListener('load', function(e){
+ onScriptLoad(e, url);
+ }, false);
+ }
+
+ config.modules[item] = url;
+ } else { //缓存
+ (function poll() {
+ if(++timeout > config.timeout * 1000 / 4){
+ return error(item + ' is not a valid module', 'error');
+ };
+ (typeof config.modules[item] === 'string' && config.status[item])
+ ? onCallback()
+ : setTimeout(poll, 4);
+ }());
+ }
+
+ return that;
+ };
+
+ //获取节点的 style 属性值
+ Layui.prototype.getStyle = function(node, name){
+ var style = node.currentStyle ? node.currentStyle : win.getComputedStyle(node, null);
+ return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name);
+ };
+
+ //css外部加载器
+ Layui.prototype.link = function(href, fn, cssname){
+ var that = this
+ ,head = doc.getElementsByTagName('head')[0]
+ ,link = doc.createElement('link');
+
+ if(typeof fn === 'string') cssname = fn;
+
+ var app = (cssname || href).replace(/\.|\//g, '')
+ ,id = link.id = 'layuicss-'+ app
+ ,STAUTS_NAME = 'creating'
+ ,timeout = 0;
+
+ link.rel = 'stylesheet';
+ link.href = href + (config.debug ? '?v='+new Date().getTime() : '');
+ link.media = 'all';
+
+ if(!doc.getElementById(id)){
+ head.appendChild(link);
+ }
+
+ if(typeof fn !== 'function') return that;
+
+ //轮询 css 是否加载完毕
+ (function poll(status) {
+ var delay = 100
+ ,getLinkElem = doc.getElementById(id); //获取动态插入的 link 元素
+
+ //如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范
+ if(++timeout > config.timeout * 1000 / delay){
+ return error(href + ' timeout');
+ };
+
+ //css 加载就绪
+ if(parseInt(that.getStyle(getLinkElem, 'width')) === 1989){
+ //如果参数来自于初始轮询(即未加载就绪时的),则移除 link 标签状态
+ if(status === STAUTS_NAME) getLinkElem.removeAttribute('lay-status');
+ //如果 link 标签的状态仍为「创建中」,则继续进入轮询,直到状态改变,则执行回调
+ getLinkElem.getAttribute('lay-status') === STAUTS_NAME ? setTimeout(poll, delay) : fn();
+ } else {
+ getLinkElem.setAttribute('lay-status', STAUTS_NAME);
+ setTimeout(function(){
+ poll(STAUTS_NAME);
+ }, delay);
+ }
+ }());
+
+ //轮询css是否加载完毕
+ /*
+ (function poll() {
+ if(++timeout > config.timeout * 1000 / 100){
+ return error(href + ' timeout');
+ };
+ parseInt(that.getStyle(doc.getElementById(id), 'width')) === 1989 ? function(){
+ fn();
+ }() : setTimeout(poll, 100);
+ }());
+ */
+
+ return that;
+ };
+
+ //css 内部加载器
+ Layui.prototype.addcss = function(firename, fn, cssname){
+ return layui.link(config.dir + 'css/' + firename, fn, cssname);
+ };
+
+ //存储模块的回调
+ config.callback = {};
+
+ //重新执行模块的工厂函数
+ Layui.prototype.factory = function(modName){
+ if(layui[modName]){
+ return typeof config.callback[modName] === 'function'
+ ? config.callback[modName]
+ : null;
+ }
+ };
+
+ //图片预加载
+ Layui.prototype.img = function(url, callback, error) {
+ var img = new Image();
+ img.src = url;
+ if(img.complete){
+ return callback(img);
+ }
+ img.onload = function(){
+ img.onload = null;
+ typeof callback === 'function' && callback(img);
+ };
+ img.onerror = function(e){
+ img.onerror = null;
+ typeof error === 'function' && error(e);
+ };
+ };
+
+ //全局配置
+ Layui.prototype.config = function(options){
+ options = options || {};
+ for(var key in options){
+ config[key] = options[key];
+ }
+ return this;
+ };
+
+ //记录全部模块
+ Layui.prototype.modules = function(){
+ var clone = {};
+ for(var o in modules){
+ clone[o] = modules[o];
+ }
+ return clone;
+ }();
+
+ //拓展模块
+ Layui.prototype.extend = function(options){
+ var that = this;
+
+ //验证模块是否被占用
+ options = options || {};
+ for(var o in options){
+ if(that[o] || that.modules[o]){
+ error(o+ ' Module already exists', 'error');
+ } else {
+ that.modules[o] = options[o];
+ }
+ }
+
+ return that;
+ };
+
+ // location.hash 路由解析
+ Layui.prototype.router = function(hash){
+ var that = this
+ ,hash = hash || location.hash
+ ,data = {
+ path: []
+ ,search: {}
+ ,hash: (hash.match(/[^#](#.*$)/) || [])[1] || ''
+ };
+
+ if(!/^#\//.test(hash)) return data; //禁止非路由规范
+ hash = hash.replace(/^#\//, '');
+ data.href = '/' + hash;
+ hash = hash.replace(/([^#])(#.*$)/, '$1').split('/') || [];
+
+ //提取 Hash 结构
+ that.each(hash, function(index, item){
+ /^\w+=/.test(item) ? function(){
+ item = item.split('=');
+ data.search[item[0]] = item[1];
+ }() : data.path.push(item);
+ });
+
+ return data;
+ };
+
+ //URL 解析
+ Layui.prototype.url = function(href){
+ var that = this
+ ,data = {
+ //提取 url 路径
+ pathname: function(){
+ var pathname = href
+ ? function(){
+ var str = (href.match(/\.[^.]+?\/.+/) || [])[0] || '';
+ return str.replace(/^[^\/]+/, '').replace(/\?.+/, '');
+ }()
+ : location.pathname;
+ return pathname.replace(/^\//, '').split('/');
+ }()
+
+ //提取 url 参数
+ ,search: function(){
+ var obj = {}
+ ,search = (href
+ ? function(){
+ var str = (href.match(/\?.+/) || [])[0] || '';
+ return str.replace(/\#.+/, '');
+ }()
+ : location.search
+ ).replace(/^\?+/, '').split('&'); //去除 ?,按 & 分割参数
+
+ //遍历分割后的参数
+ that.each(search, function(index, item){
+ var _index = item.indexOf('=')
+ ,key = function(){ //提取 key
+ if(_index < 0){
+ return item.substr(0, item.length);
+ } else if(_index === 0){
+ return false;
+ } else {
+ return item.substr(0, _index);
+ }
+ }();
+ //提取 value
+ if(key){
+ obj[key] = _index > 0 ? item.substr(_index + 1) : null;
+ }
+ });
+
+ return obj;
+ }()
+
+ //提取 Hash
+ ,hash: that.router(function(){
+ return href
+ ? ((href.match(/#.+/) || [])[0] || '/')
+ : location.hash;
+ }())
+ };
+
+ return data;
+ };
+
+ //本地持久性存储
+ Layui.prototype.data = function(table, settings, storage){
+ table = table || 'layui';
+ storage = storage || localStorage;
+
+ if(!win.JSON || !win.JSON.parse) return;
+
+ //如果settings为null,则删除表
+ if(settings === null){
+ return delete storage[table];
+ }
+
+ settings = typeof settings === 'object'
+ ? settings
+ : {key: settings};
+
+ try{
+ var data = JSON.parse(storage[table]);
+ } catch(e){
+ var data = {};
+ }
+
+ if('value' in settings) data[settings.key] = settings.value;
+ if(settings.remove) delete data[settings.key];
+ storage[table] = JSON.stringify(data);
+
+ return settings.key ? data[settings.key] : data;
+ };
+
+ //本地会话性存储
+ Layui.prototype.sessionData = function(table, settings){
+ return this.data(table, settings, sessionStorage);
+ }
+
+ //设备信息
+ Layui.prototype.device = function(key){
+ var agent = navigator.userAgent.toLowerCase()
+
+ //获取版本号
+ ,getVersion = function(label){
+ var exp = new RegExp(label + '/([^\\s\\_\\-]+)');
+ label = (agent.match(exp)||[])[1];
+ return label || false;
+ }
+
+ //返回结果集
+ ,result = {
+ os: function(){ //底层操作系统
+ if(/windows/.test(agent)){
+ return 'windows';
+ } else if(/linux/.test(agent)){
+ return 'linux';
+ } else if(/iphone|ipod|ipad|ios/.test(agent)){
+ return 'ios';
+ } else if(/mac/.test(agent)){
+ return 'mac';
+ }
+ }()
+ ,ie: function(){ //ie版本
+ return (!!win.ActiveXObject || "ActiveXObject" in win) ? (
+ (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识
+ ) : false;
+ }()
+ ,weixin: getVersion('micromessenger') //是否微信
+ };
+
+ //任意的key
+ if(key && !result[key]){
+ result[key] = getVersion(key);
+ }
+
+ //移动设备
+ result.android = /android/.test(agent);
+ result.ios = result.os === 'ios';
+ result.mobile = (result.android || result.ios) ? true : false;
+
+ return result;
+ };
+
+ //提示
+ Layui.prototype.hint = function(){
+ return {
+ error: error
+ };
+ };
+
+
+ //typeof 类型细分 -> string/number/boolean/undefined/null、object/array/function/…
+ Layui.prototype._typeof = function(operand){
+ if(operand === null) return String(operand);
+
+ //细分引用类型
+ return (typeof operand === 'object' || typeof operand === 'function') ? function(){
+ var type = Object.prototype.toString.call(operand).match(/\s(.+)\]$/) || [] //匹配类型字符
+ ,classType = 'Function|Array|Date|RegExp|Object|Error|Symbol'; //常见类型字符
+
+ type = type[1] || 'Object';
+
+ //除匹配到的类型外,其他对象均返回 object
+ return new RegExp('\\b('+ classType + ')\\b').test(type)
+ ? type.toLowerCase()
+ : 'object';
+ }() : typeof operand;
+ };
+
+ //对象是否具备数组结构(此处为兼容 jQuery 对象)
+ Layui.prototype._isArray = function(obj){
+ var that = this
+ ,len
+ ,type = that._typeof(obj);
+
+ if(!obj || (typeof obj !== 'object') || obj === win) return false;
+
+ len = 'length' in obj && obj.length; //兼容 ie
+ return type === 'array' || len === 0 || (
+ typeof len === 'number' && len > 0 && (len - 1) in obj //兼容 jQuery 对象
+ );
+ };
+
+ //遍历
+ Layui.prototype.each = function(obj, fn){
+ var key
+ ,that = this
+ ,callFn = function(key, obj){ //回调
+ return fn.call(obj[key], key, obj[key])
+ };
+
+ if(typeof fn !== 'function') return that;
+ obj = obj || [];
+
+ //优先处理数组结构
+ if(that._isArray(obj)){
+ for(key = 0; key < obj.length; key++){
+ if(callFn(key, obj)) break;
+ }
+ } else {
+ for(key in obj){
+ if(callFn(key, obj)) break;
+ }
+ }
+
+ return that;
+ };
+
+ //将数组中的对象按其某个成员排序
+ Layui.prototype.sort = function(obj, key, desc){
+ var clone = JSON.parse(
+ JSON.stringify(obj || [])
+ );
+
+ if(!key) return clone;
+
+ //如果是数字,按大小排序;如果是非数字,则按字典序排序
+ clone.sort(function(o1, o2){
+ var isNum = /^-?\d+$/
+ ,v1 = o1[key]
+ ,v2 = o2[key];
+
+ if(isNum.test(v1)) v1 = parseFloat(v1);
+ if(isNum.test(v2)) v2 = parseFloat(v2);
+
+ return v1 - v2;
+
+ /*
+ 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(); //倒序
+ return clone;
+ };
+
+ //阻止事件冒泡
+ Layui.prototype.stope = function(thisEvent){
+ thisEvent = thisEvent || win.event;
+ try { thisEvent.stopPropagation() } catch(e){
+ thisEvent.cancelBubble = true;
+ }
+ };
+
+ //字符常理
+ var EV_REMOVE = 'LAYUI-EVENT-REMOVE';
+
+ //自定义模块事件
+ Layui.prototype.onevent = function(modName, events, callback){
+ if(typeof modName !== 'string'
+ || typeof callback !== 'function') return this;
+
+ return Layui.event(modName, events, null, callback);
+ };
+
+ //执行自定义模块事件
+ Layui.prototype.event = Layui.event = function(modName, events, params, fn){
+ var that = this
+ ,result = null
+ ,filter = (events || '').match(/\((.*)\)$/)||[] //提取事件过滤器字符结构,如:select(xxx)
+ ,eventName = (modName + '.'+ events).replace(filter[0], '') //获取事件名称,如:form.select
+ ,filterName = filter[1] || '' //获取过滤器名称,,如:xxx
+ ,callback = function(_, item){
+ var res = item && item.call(that, params);
+ res === false && result === null && (result = false);
+ };
+
+ //如果参数传入特定字符,则执行移除事件
+ if(params === EV_REMOVE){
+ delete (that.cache.event[eventName] || {})[filterName];
return that;
}
- //主体CSS等待事件
- ,ready: function(fn){
- var cssname = 'laydate', ver = ''
- ,path = (isLayui ? 'modules/laydate/' : 'theme/') + 'default/laydate.css?v='+ laydate.v + ver;
- isLayui ? layui.addcss(path, fn, cssname) : ready.link(path, fn, cssname);
+ //添加事件
+ if(fn){
+ config.event[eventName] = config.event[eventName] || {};
+
+ //这里不再对重复事件做支持
+ //config.event[eventName][filterName] ? config.event[eventName][filterName].push(fn) :
+ config.event[eventName][filterName] = [fn];
return this;
}
- }
-
- //操作当前实例
- ,thisDate = function(){
- var that = this;
- return {
- //提示框
- hint: function(content){
- that.hint.call(that, content);
+
+ //执行事件回调
+ layui.each(config.event[eventName], function(key, item){
+ //执行当前模块的全部事件
+ if(filterName === '{*}'){
+ layui.each(item, callback);
+ return;
}
- ,config: that.config
- };
- }
-
- //字符常量
- ,MOD_NAME = 'laydate', ELEM = '.layui-laydate', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'laydate-disabled', TIPS_OUT = '开始日期超出了结束日期
建议重新选择', LIMIT_YEAR = [100, 200000]
-
- ,ELEM_STATIC = 'layui-laydate-static', ELEM_LIST = 'layui-laydate-list', ELEM_SELECTED = 'laydate-selected', ELEM_HINT = 'layui-laydate-hint', ELEM_PREV = 'laydate-day-prev', ELEM_NEXT = 'laydate-day-next', ELEM_FOOTER = 'layui-laydate-footer', ELEM_CONFIRM = '.laydate-btns-confirm', ELEM_TIME_TEXT = 'laydate-time-text', ELEM_TIME_BTN = '.laydate-btns-time'
-
- //组件构造器
- ,Class = function(options){
- var that = this;
- that.index = ++laydate.index;
- that.config = lay.extend({}, that.config, laydate.config, options);
- laydate.ready(function(){
- that.init();
+
+ //执行指定事件
+ key === '' && layui.each(item, callback);
+ (filterName && key === filterName) && layui.each(item, callback);
});
+
+ return result;
+ };
+
+ //新增模块事件
+ Layui.prototype.on = function(events, modName, callback){
+ var that = this;
+ return that.onevent.call(that, modName, events, callback);
}
+ //移除模块事件
+ Layui.prototype.off = function(events, modName){
+ var that = this;
+ return that.event.call(that, modName, events, EV_REMOVE);
+ };
+
+ //exports layui
+ var layui = new Layui();
+
+
+
+
+/*! lay 基础 DOM 操作 | MIT Licensed */
+
+
+ "use strict";
+
+ var MOD_NAME = 'lay' //模块名
+ ,document = window.document
+
//DOM查找
,lay = function(selector){
return new LAY(selector);
@@ -130,9 +751,8 @@
}
};
-
/*
- lay对象操作
+ lay 对象操作
*/
LAY.prototype = [];
@@ -162,39 +782,37 @@
return args[0];
};
+ //lay 模块版本
+ lay.v = '1.0.7';
+
//ie版本
lay.ie = function(){
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;
}();
- //中止冒泡
- lay.stope = function(e){
- e = e || window.event;
- e.stopPropagation
- ? e.stopPropagation()
- : e.cancelBubble = true;
+
+
+
+
+
+ /**
+ * 获取 layui 常见方法,以便用于组件单独版
+ */
+
+ lay.layui = layui;
+ lay.getPath = layui.cache.dir; //获取当前 JS 所在目录
+ lay.stope = layui.stope; //中止冒泡
+ lay.each = function(){ //遍历
+ layui.each.apply(layui, arguments);
+ return this;
};
- //对象遍历
- lay.each = function(obj, fn){
- var key
- ,that = this;
- if(typeof fn !== 'function') return that;
- obj = obj || [];
- if(obj.constructor === Object){
- for(key in obj){
- if(fn.call(obj[key], key, obj[key])) break;
- }
- } else {
- for(key = 0; key < obj.length; key++){
- if(fn.call(obj[key], key, obj[key])) break;
- }
- }
- return that;
- };
+
+
+
//数字前置补零
lay.digit = function(num, length, end){
@@ -215,6 +833,109 @@
});
return elem;
};
+
+ //当前页面是否存在滚动条
+ lay.hasScrollbar = function(){
+ return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight);
+ };
+
+ //元素定位
+ lay.position = function(elem, elemView, obj){
+ if(!elemView) return;
+ obj = obj || {};
+
+ //如果绑定的是 document 或 body 元素,则直接获取鼠标坐标
+ if(elem === document || elem === lay('body')[0]){
+ obj.clickType = 'right';
+ }
+
+ //绑定绑定元素的坐标
+ var rect = obj.clickType === 'right' ? function(){
+ var e = obj.e || window.event || {};
+ return {
+ left: e.clientX
+ ,top: e.clientY
+ ,right: e.clientX
+ ,bottom: e.clientY
+ }
+ }() : elem.getBoundingClientRect()
+ ,elemWidth = elemView.offsetWidth //控件的宽度
+ ,elemHeight = elemView.offsetHeight //控件的高度
+
+ //滚动条高度
+ ,scrollArea = function(type){
+ type = type ? 'scrollLeft' : 'scrollTop';
+ return document.body[type] | document.documentElement[type];
+ }
+
+ //窗口宽高
+ ,winArea = function(type){
+ return document.documentElement[type ? 'clientWidth' : 'clientHeight']
+ }, margin = 5, left = rect.left, top = rect.bottom;
+
+ //判断右侧是否超出边界
+ if(left + elemWidth + margin > winArea('width')){
+ left = winArea('width') - elemWidth - margin; //如果超出右侧,则将面板向右靠齐
+ }
+
+ //判断底部和顶部是否超出边界
+ if(top + elemHeight + margin > winArea()){
+ //优先顶部是否有足够区域显示完全
+ if(rect.top > elemHeight + margin){
+ top = rect.top - elemHeight - margin*2; //顶部有足够的区域显示
+ } else {
+ //如果面板是鼠标右键弹出,且顶部没有足够区域显示,则将面板向底部靠齐
+ if(obj.clickType === 'right'){
+ top = winArea() - elemHeight - margin*2;
+ if(top < 0) top = 0; //不能溢出窗口顶部
+ }
+ }
+ }
+
+ //定位类型
+ var position = obj.position;
+ if(position) elemView.style.position = position;
+
+ //设置坐标
+ elemView.style.left = left + (position === 'fixed' ? 0 : scrollArea(1)) + 'px';
+ elemView.style.top = top + (position === 'fixed' ? 0 : scrollArea()) + 'px';
+
+ //防止页面无滚动条时,又因为弹出面板而出现滚动条导致的坐标计算偏差
+ if(!lay.hasScrollbar()){
+ var rect1 = elemView.getBoundingClientRect();
+ //如果弹出面板的溢出窗口底部,则表示将出现滚动条,此时需要重新计算坐标
+ if(!obj.SYSTEM_RELOAD && (rect1.bottom + margin) > winArea()){
+ obj.SYSTEM_RELOAD = true;
+ setTimeout(function(){
+ lay.position(elem, elemView, obj);
+ }, 50);
+ }
+ }
+ };
+
+ //获取元素上的参数配置上
+ lay.options = function(elem, attr){
+ var othis = lay(elem)
+ ,attrName = attr || 'lay-options';
+ try {
+ return new Function('return '+ (othis.attr(attrName) || '{}'))();
+ } catch(ev) {
+ hint.error('parseerror:'+ ev, 'error');
+ return {};
+ }
+ };
+
+ //元素是否属于顶级元素(document 或 body)
+ lay.isTopElem = function(elem){
+ var topElems = [document, lay('body')[0]]
+ ,matched = false;
+ lay.each(topElems, function(index, item){
+ if(item === elem){
+ return matched = true
+ }
+ });
+ return matched;
+ };
//追加字符
LAY.addStr = function(str, new_str){
@@ -248,7 +969,7 @@
,isObject = typeof selector === 'object';
this.each(function(i, item){
- var nativeDOM = isObject ? [selector] : item.querySelectorAll(selector || null);
+ var nativeDOM = isObject ? item.contains(selector) : item.querySelectorAll(selector || null);
for(; index < nativeDOM.length; index++){
arr.push(nativeDOM[index]);
}
@@ -278,12 +999,12 @@
});
};
- //移除css类
+ //移除 css 类
LAY.prototype.removeClass = function(className){
return this.addClass(className, true);
};
- //是否包含css类
+ //是否包含 css 类
LAY.prototype.hasClass = function(className){
var has = false;
this.each(function(index, item){
@@ -294,6 +1015,41 @@
return has;
};
+ //添加或获取 css style
+ LAY.prototype.css = function(key, value){
+ var that = this
+ ,parseValue = function(v){
+ return isNaN(v) ? v : (v +'px');
+ };
+ return (typeof key === 'string' && value === undefined) ? function(){
+ if(that.length > 0) return that[0].style[key];
+ }() : that.each(function(index, item){
+ typeof key === 'object' ? lay.each(key, function(thisKey, thisValue){
+ item.style[thisKey] = parseValue(thisValue);
+ }) : item.style[key] = parseValue(value);
+ });
+ };
+
+ //添加或获取宽度
+ LAY.prototype.width = function(value){
+ var that = this;
+ return value === undefined ? function(){
+ if(that.length > 0) return that[0].offsetWidth; //此处还需做兼容
+ }() : that.each(function(index, item){
+ that.css('width', value);
+ });
+ };
+
+ //添加或获取高度
+ LAY.prototype.height = function(value){
+ var that = this;
+ return value === undefined ? function(){
+ if(that.length > 0) return that[0].offsetHeight; //此处还需做兼容
+ }() : that.each(function(index, item){
+ that.css('height', value);
+ });
+ };
+
//添加或获取属性
LAY.prototype.attr = function(key, value){
var that = this;
@@ -311,17 +1067,23 @@
});
};
- //设置HTML内容
+ //设置或获取 HTML 内容
LAY.prototype.html = function(html){
- return this.each(function(index, item){
+ var that = this;
+ return html === undefined ? function(){
+ if(that.length > 0) return that[0].innerHTML;
+ }() : this.each(function(index, item){
item.innerHTML = html;
});
};
- //设置值
+ //设置或获取值
LAY.prototype.val = function(value){
- return this.each(function(index, item){
- item.value = value;
+ var that = this;
+ return value === undefined ? function(){
+ if(that.length > 0) return that[0].value;
+ }() : this.each(function(index, item){
+ item.value = value;
});
};
@@ -360,12 +1122,116 @@
});
};
+ //暴露 lay 到全局作用域
+ window.lay = lay;
+
+ //如果在 layui 体系中
+ if(window.layui && layui.define){
+ layui.define(function(exports){ //layui 加载
+ exports(MOD_NAME, lay);
+ });
+ }
+
+}(window, window.document);
+
+
+/*! layDate 日期与时间控件 | MIT Licensed */
+
+;!function(window, document){
+ "use strict";
+
+ var isLayui = window.layui && layui.define, ready = {
+ getPath: (window.lay && lay.getPath) ? lay.getPath : ''
+
+ //载入 CSS 依赖
+ ,link: function(href, fn, cssname){
+
+ //未设置路径,则不主动加载 css
+ if(!laydate.path) return;
+
+ //加载 css
+ if(window.lay && lay.layui){
+ lay.layui.link(laydate.path + href, fn, cssname);
+ }
+ }
+ }
+
+ //识别预先可能定义的指定全局对象
+ ,GLOBAL = window.LAYUI_GLOBAL || {}
+
+ //外部调用
+ ,laydate = {
+ v: '5.3.1' //layDate 版本号
+ ,config: {} //全局配置项
+ ,index: (window.laydate && window.laydate.v) ? 100000 : 0
+ ,path: GLOBAL.laydate_dir || ready.getPath
+
+ //设置全局项
+ ,set: function(options){
+ var that = this;
+ that.config = lay.extend({}, that.config, options);
+ return that;
+ }
+
+ //主体CSS等待事件
+ ,ready: function(fn){
+ var cssname = 'laydate', ver = ''
+ ,path = (isLayui ? 'modules/laydate/' : 'theme/') + 'default/laydate.css?v='+ laydate.v + ver;
+ isLayui ? layui.addcss(path, fn, cssname) : ready.link(path, fn, cssname);
+ return this;
+ }
+ }
+
+ //操作当前实例
+ ,thisModule = function(){
+ var that = this
+ ,options = that.config
+ ,id = options.id;
+
+ thisModule.that[id] = that; //记录当前实例对象
+
+ return {
+ //提示框
+ hint: function(content){
+ that.hint.call(that, content);
+ }
+ ,config: that.config
+ };
+ }
+
+ //字符常量
+ ,MOD_NAME = 'laydate', ELEM = '.layui-laydate', THIS = 'layui-this', SHOW = 'layui-show', HIDE = 'layui-hide', DISABLED = 'laydate-disabled', LIMIT_YEAR = [100, 200000]
+
+ ,ELEM_STATIC = 'layui-laydate-static', ELEM_LIST = 'layui-laydate-list', ELEM_SELECTED = 'laydate-selected', ELEM_HINT = 'layui-laydate-hint', ELEM_PREV = 'laydate-day-prev', ELEM_NEXT = 'laydate-day-next', ELEM_FOOTER = 'layui-laydate-footer', ELEM_CONFIRM = '.laydate-btns-confirm', ELEM_TIME_TEXT = 'laydate-time-text', ELEM_TIME_BTN = 'laydate-btns-time', ELEM_PREVIEW = 'layui-laydate-preview'
+
+ //组件构造器
+ ,Class = function(options){
+ var that = this;
+ that.index = ++laydate.index;
+ that.config = lay.extend({}, that.config, laydate.config, options);
+
+ //初始化 id 参数
+ options = that.config;
+ options.id = ('id' in options) ? options.id : that.index;
+
+ //初始化
+ laydate.ready(function(){
+ that.init();
+ });
+ }
+
+ //日期格式字符
+ ,dateType = 'yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s';
+
+ //将日期格式字符转换为数组
+ thisModule.formatArr = function(format){
+ return (format || '').match(new RegExp(dateType + '|.', 'g')) || []
+ };
/*
组件操作
*/
-
//是否闰年
Class.isLeapYear = function(year){
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
@@ -377,13 +1243,15 @@
,range: false //是否开启范围选择,即双控件
,format: 'yyyy-MM-dd' //默认日期格式
,value: null //默认日期,支持传入new Date(),或者符合format参数设定的日期格式字符
+ ,isInitValue: true //用于控制是否自动向元素填充初始值(需配合 value 参数使用)
,min: '1900-1-1' //有效最小日期,年月日必须用“-”分割,时分秒必须用“:”分割。注意:它并不是遵循 format 设定的格式。
,max: '2099-12-31' //有效最大日期,同上
,trigger: 'click' //呼出控件的事件
- ,show: false //是否直接显示,如果设置true,则默认直接显示控件
+ ,show: false //是否直接显示,如果设置 true,则默认直接显示控件
,showBottom: true //是否显示底部栏
+ ,isPreview: true //是否显示值预览
,btns: ['clear', 'now', 'confirm'] //右下角显示的按钮,会按照数组顺序排列
- ,lang: window.lang || 'zh_CN' //语言,只支持cn/en,即中文和英文
+ ,lang: 'cn' //语言,只支持cn/en,即中文和英文
,theme: 'default' //主题
,position: null //控件定位方式定位, 默认absolute,支持:fixed/absolute/static
,calendar: false //是否开启公历重要节日,仅支持中文版
@@ -398,57 +1266,50 @@
var that = this
,options = that.config
,text = {
- zh_CN: {
- weeks: ['日', '一', '二', '三', '四', '五', '六']
- ,time: ['时', '分', '秒']
- ,timeTips: '选择时间'
- ,startTime: '开始时间'
- ,endTime: '结束时间'
- ,dateTips: '返回日期'
- ,month: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二']
- ,tools: {
- confirm: '确定'
- ,clear: '清空'
- ,now: '现在'
- }
+ cn: {
+ weeks: ['日', '一', '二', '三', '四', '五', '六']
+ ,time: ['时', '分', '秒']
+ ,timeTips: '选择时间'
+ ,startTime: '开始时间'
+ ,endTime: '结束时间'
+ ,dateTips: '返回日期'
+ ,month: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二']
+ ,tools: {
+ confirm: '确定'
+ ,clear: '清空'
+ ,now: '现在'
+ }
+ ,timeout: '结束时间不能早于开始时间
请重新选择'
+ ,invalidDate: '不在有效日期或时间范围内'
+ ,formatError: ['日期格式不合法
必须遵循下述格式:
', '
已为你重置']
+ ,preview: '当前选中的结果'
}
,en: {
- weeks: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
- ,time: ['Hours', 'Minutes', 'Seconds']
- ,timeTips: 'Select Time'
- ,startTime: 'Start Time'
- ,endTime: 'End Time'
- ,dateTips: 'Select Date'
- ,month: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
- ,tools: {
- confirm: 'Confirm'
- ,clear: 'Clear'
- ,now: 'Now'
- }
- }
- ,ja_JP: {
- weeks: ["\u65e5", "\u6708", "\u706b", "\u6c34", "\u6728", "\u91d1", "\u571f"]
- ,time: ['時', '分', '秒']
- ,timeTips: '選択時間'
- ,startTime: '開始時刻'
- ,endTime: '終了時刻'
- ,dateTips: '選択デート'
- ,month: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]
- ,tools: {
- confirm: '確認'
- ,clear: '明確'
- ,now: '今'
- }
- }
+ weeks: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
+ ,time: ['Hours', 'Minutes', 'Seconds']
+ ,timeTips: 'Select Time'
+ ,startTime: 'Start Time'
+ ,endTime: 'End Time'
+ ,dateTips: 'Select Date'
+ ,month: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+ ,tools: {
+ confirm: 'Confirm'
+ ,clear: 'Clear'
+ ,now: 'Now'
+ }
+ ,timeout: 'End time cannot be less than start Time
Please re-select'
+ ,invalidDate: 'Invalid date'
+ ,formatError: ['The date format error
Must be followed:
', '
It has been reset']
+ ,preview: 'The selected result'
+ }
};
- return text[options.lang] || text['zh_CN'];
+ return text[options.lang] || text['cn'];
};
//初始准备
Class.prototype.init = function(){
var that = this
,options = that.config
- ,dateType = 'yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s'
,isStatic = options.position === 'static'
,format = {
year: 'yyyy'
@@ -464,15 +1325,29 @@
if(!options.elem[0]) return;
//日期范围分隔符
- if(options.range === true) options.range = '-';
+ that.rangeStr = options.range ? (typeof options.range === 'string' ? options.range : '-') : '';
- //根据不同type,初始化默认format
+ //若 range 参数为数组,则表示为开始日期和结束日期的 input 对象
+ if(options.range && options.range.constructor === Array){
+ that.rangeElem = [
+ lay(options.range[0]),
+ lay(options.range[1])
+ ];
+ }
+
+ //若 type 设置非法,则初始化为 date 类型
+ if(!format[options.type]){
+ window.console && console.error && console.error('laydate type error:\''+ options.type + '\' is not supported')
+ options.type = 'date';
+ }
+
+ //根据不同 type,初始化默认 format
if(options.format === format.date){
- options.format = format[options.type];
+ options.format = format[options.type] || format.date;
}
//将日期格式转化成数组
- that.format = options.format.match(new RegExp(dateType + '|.', 'g')) || [];
+ that.format = thisModule.formatArr(options.format);
//生成正则表达式
that.EXP_IF = '';
@@ -492,9 +1367,11 @@
that.EXP_IF = that.EXP_IF + EXP;
that.EXP_SPLIT = that.EXP_SPLIT + '(' + EXP + ')';
});
+ //验证日期格式正则
+ that.EXP_IF_ONE = new RegExp('^'+ that.EXP_IF +'$'); //验证单个日期格式
that.EXP_IF = new RegExp('^'+ (
options.range ?
- that.EXP_IF + '\\s\\'+ options.range + '\\s' + that.EXP_IF
+ that.EXP_IF + '\\s\\'+ that.rangeStr + '\\s' + that.EXP_IF
: that.EXP_IF
) +'$');
that.EXP_SPLIT = new RegExp('^'+ that.EXP_SPLIT +'$', '');
@@ -513,7 +1390,7 @@
}
//记录重要日期
- options.mark = lay.extend({}, (options.calendar && options.lang === 'zh_CN') ? {
+ options.mark = lay.extend({}, (options.calendar && options.lang === 'cn') ? {
'0-1-1': '元旦'
,'0-2-14': '情人'
,'0-3-8': '妇女'
@@ -534,10 +1411,10 @@
if(typeof options[item] === 'number'){ //如果为数字
var day = options[item]
,time = new Date().getTime()
- ,STAMP = 86400000 //代表一天的时间戳
+ ,STAMP = 86400000 //代表一天的毫秒数
,thisDate = new Date(
day ? (
- day < STAMP ? time + day*STAMP : day //如果数字小于一天的时间戳,则数字为天数,否则为时间戳
+ day < STAMP ? time + day*STAMP : day //如果数字小于一天的毫秒数,则数字为天数,否则为毫秒数
) : time
);
ymd = [thisDate.getFullYear(), thisDate.getMonth() + 1, thisDate.getDate()];
@@ -562,7 +1439,7 @@
isStatic || that.events();
//默认赋值
- if(options.value){
+ if(options.value && options.isInitValue){
if(options.value.constructor === Date){
that.setValue(that.parse(0, that.systemDate(options.value)));
} else {
@@ -691,12 +1568,16 @@
lay(divFooter).html(function(){
var html = [], btns = [];
if(options.type === 'datetime'){
- html.push(''+ lang.timeTips +'');
+ html.push(''+ lang.timeTips +'');
}
+ if(!(!options.range && options.type === 'datetime')){
+ html.push('')
+ }
+
lay.each(options.btns, function(i, item){
var title = lang.tools[item] || 'btn';
if(options.range && item === 'now') return;
- if(isStatic && item === 'clear') title = options.lang === 'zh_CN' ? '重置' : 'Reset';
+ if(isStatic && item === 'clear') title = options.lang === 'cn' ? '重置' : 'Reset';
btns.push(''+ title +'');
});
html.push('
'+ lang.time[i] +'