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(''); @@ -728,6 +1609,9 @@ elem.appendChild(style); } + //记录当前执行的实例索引 + laydate.thisId = options.id; + //移除上一个控件 that.remove(Class.thisElemDate); @@ -737,7 +1621,7 @@ ,that.position() //定位 ); - that.checkDate().calendar(); //初始校验 + that.checkDate().calendar(null, 0, 'init'); //初始校验 that.changeEvent(); //日期切换 Class.thisElemDate = that.elemID; @@ -745,6 +1629,8 @@ typeof options.ready === 'function' && options.ready(lay.extend({}, options.dateTime, { month: options.dateTime.month + 1 })); + + that.preview(); }; //控件移除 @@ -752,9 +1638,13 @@ var that = this ,options = that.config ,elem = lay('#'+ (prev || that.elemID)); + if(!elem[0]) return that; + if(!elem.hasClass(ELEM_STATIC)){ that.checkDate(function(){ elem.remove(); + //delete options.dateTime; + //delete that.endDate; }); } return that; @@ -763,39 +1653,11 @@ //定位算法 Class.prototype.position = function(){ var that = this - ,options = that.config - ,elem = that.bindElem || options.elem[0] - ,rect = elem.getBoundingClientRect() //绑定元素的坐标 - ,elemWidth = that.elem.offsetWidth //控件的宽度 - ,elemHeight = that.elem.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()){ - top = rect.top > elemHeight //顶部是否有足够区域显示完全 - ? rect.top - elemHeight - : winArea() - elemHeight; - top = top - margin*2; - } - - if(options.position){ - that.elem.style.position = options.position; - } - that.elem.style.left = left + (options.position === 'fixed' ? 0 : scrollArea(1)) + 'px'; - that.elem.style.top = top + (options.position === 'fixed' ? 0 : scrollArea()) + 'px'; + ,options = that.config; + lay.position(that.bindElem || options.elem[0], that.elem, { + position: options.position + }); + return that; }; //提示 @@ -806,11 +1668,11 @@ 'class': ELEM_HINT }); + if(!that.elem) return; + div.innerHTML = content || ''; lay(that.elem).find('.'+ ELEM_HINT).remove(); - if (that.elem){ // ThinkGem 可能会为空 - that.elem.appendChild(div); - } + that.elem.appendChild(div); clearTimeout(that.hinTimer); that.hinTimer = setTimeout(function(){ @@ -832,7 +1694,7 @@ return [Y, M]; }; - //系统消息 + //系统日期 Class.prototype.systemDate = function(newDate){ var thisDate = newDate || new Date(); return { @@ -850,12 +1712,22 @@ var that = this ,thisDate = new Date() ,options = that.config + ,lang = that.lang() ,dateTime = options.dateTime = options.dateTime || that.systemDate() ,thisMaxDate, error ,elem = that.bindElem || options.elem[0] ,valType = that.isInput(elem) ? 'val' : 'html' - ,value = that.isInput(elem) ? elem.value : (options.position === 'static' ? '' : elem.innerHTML) + ,value = function(){ + //如果传入了开始和结束日期的 input 对象,则将其拼接为日期范围字符 + if(that.rangeElem){ + var vals = [that.rangeElem[0].val(), that.rangeElem[1].val()]; + if(vals[0] && vals[1]){ + return vals.join(' ' + that.rangeStr + ' '); + } + } + return that.isInput(elem) ? elem.value : (options.position === 'static' ? '' : lay(elem).attr('lay-date')); + }() //校验日期有效数字 ,checkValid = function(dateTime){ @@ -875,6 +1747,7 @@ var startEnd = ['startTime', 'endTime']; value = (value.match(that.EXP_SPLIT) || []).slice(1); index = index || 0; + if(options.range){ that[startEnd[index]] = that[startEnd[index]] || {}; } @@ -904,7 +1777,7 @@ options.range && (that[startEnd[index]].seconds = thisv); } }); - checkValid(dateTime) + checkValid(dateTime); }; if(fn === 'limit') return checkValid(dateTime), that; @@ -913,51 +1786,106 @@ if(typeof value === 'string'){ value = value.replace(/\s+/g, ' ').replace(/^\s|\s$/g, ''); } - - //如果点击了开始,单未选择结束就关闭,则重新选择开始 - if(that.startState && !that.endState){ - delete that.startState; - that.endState = true; - }; + //如果开启范围,则计算结束日期 + var getEndDate = function(){ + if(options.range){ + that.endDate = that.endDate || lay.extend({}, options.dateTime, function(){ + var obj = {} + ,dateTime = options.dateTime + ,EYM = that.getAsYM(dateTime.year, dateTime.month); + + //初始右侧面板的年月 + if(options.type === 'year'){ + obj.year = dateTime.year + 1; + } else if(options.type !== 'time'){ + obj.year = EYM[0]; + obj.month = EYM[1]; + } + + //初始右侧面板的时间 + if(options.type === 'datetime' || options.type === 'time'){ + obj.hours = 23; + obj.minutes = obj.seconds = 59; + } + + return obj; + }()); + } + }; + getEndDate(); + if(typeof value === 'string' && value){ if(that.EXP_IF.test(value)){ //校验日期格式 if(options.range){ - value = value.split(' '+ options.range +' '); - that.startDate = that.startDate || that.systemDate(); - that.endDate = that.endDate || that.systemDate(); - options.dateTime = lay.extend({}, that.startDate); - lay.each([that.startDate, that.endDate], function(i, item){ + value = value.split(' '+ that.rangeStr +' '); + lay.each([options.dateTime, that.endDate], function(i, item){ initDate(item, value[i], i); }); } else { - initDate(dateTime, value) + initDate(dateTime, value); } } else { - that.hint('日期格式不合法
必须遵循下述格式:
'+ ( - options.range ? (options.format + ' '+ options.range +' ' + options.format) : options.format - ) + '
已为你重置'); + //格式不合法 + that.hint(lang.formatError[0] + ( + options.range ? (options.format + ' '+ that.rangeStr +' ' + options.format) : options.format + ) + lang.formatError[1]); error = true; } } else if(value && value.constructor === Date){ //如果值为日期对象时 options.dateTime = that.systemDate(value); } else { + //重置开始日期 options.dateTime = that.systemDate(); - delete that.startState; - delete that.endState; - delete that.startDate; - delete that.endDate; delete that.startTime; + + //重置结束日期 + delete that.endDate; //删除原有的结束日期 + getEndDate(); //并重新获得新的结束日期 delete that.endTime; } - + + //从日期范围表单中获取初始值 + (function(){ + if(that.rangeElem){ + var vals = [that.rangeElem[0].val(), that.rangeElem[1].val()] + ,arrDate = [options.dateTime, that.endDate]; + lay.each(vals, function(_i, _v){ + if(that.EXP_IF_ONE.test(_v)){ //校验日期格式 + initDate(arrDate[_i], _v, _i); + } + }); + } + })(); + + //校验日期有效数字 checkValid(dateTime); - + if(options.range) checkValid(that.endDate); + + //如果初始值格式错误,则纠正初始值 if(error && value){ that.setValue( options.range ? (that.endDate ? that.parse() : '') : that.parse() ); } + + //如果当前日期不在设定的最大小日期区间,则自动纠正在可选区域 + var getDateTime = function(obj){ + return that.newDate(obj).getTime(); + }; + + //校验主面板是否在可选日期区间 + if(getDateTime(dateTime) > getDateTime(options.max) || getDateTime(dateTime) < getDateTime(options.min)){ + dateTime = options.dateTime = lay.extend({}, options.min); + } + + //校验右侧面板是否在可选日期区间 + if(options.range){ + if(getDateTime(that.endDate) < getDateTime(options.min) || getDateTime(that.endDate) > getDateTime(options.max)){ + that.endDate = lay.extend({}, options.max); + } + } + fn && fn(); return that; }; @@ -985,6 +1913,7 @@ ,options = that.config, timestrap = {} ,dateTime = options[index > 41 ? 'endDate' : 'dateTime'] ,isOut, thisDateTime = lay.extend({}, dateTime, date || {}); + lay.each({ now: thisDateTime ,min: options.min @@ -1008,21 +1937,28 @@ return isOut; }; + //当前日期对象 + Class.prototype.thisDateTime = function(index){ + var that = this + ,options = that.config; + return index ? that.endDate: options.dateTime; + }; + //日历表 - Class.prototype.calendar = function(value){ + Class.prototype.calendar = function(value, index, type){ var that = this ,options = that.config - ,dateTime = value || options.dateTime + ,index = index ? 1 : 0 + ,dateTime = value || that.thisDateTime(index) ,thisDate = new Date(), startWeek, prevMaxDate, thisMaxDate ,lang = that.lang() ,isAlone = options.type !== 'date' && options.type !== 'datetime' - ,index = value ? 1 : 0 ,tds = lay(that.table[index]).find('td') ,elemYM = lay(that.elemHeader[index][2]).find('span'); - if(dateTime.year < LIMIT_YEAR[0]) dateTime.year = LIMIT_YEAR[0], that.hint('最低只能支持到公元'+ LIMIT_YEAR[0] +'年'); - if(dateTime.year > LIMIT_YEAR[1]) dateTime.year = LIMIT_YEAR[1], that.hint('最高只能支持到公元'+ LIMIT_YEAR[1] +'年'); + if(dateTime.year < LIMIT_YEAR[0]) dateTime.year = LIMIT_YEAR[0], that.hint(lang.invalidDate); + if(dateTime.year > LIMIT_YEAR[1]) dateTime.year = LIMIT_YEAR[1], that.hint(lang.invalidDate); //记录初始值 if(!that.firstDate){ @@ -1037,21 +1973,19 @@ thisMaxDate = laydate.getEndDate(dateTime.month + 1, dateTime.year); //计算当前月的最后一天 //赋值日 - lay.each(tds, function(index, item){ + lay.each(tds, function(index_, item){ var YMD = [dateTime.year, dateTime.month], st = 0; item = lay(item); item.removeAttr('class'); - if(index < startWeek){ - st = prevMaxDate - startWeek + index; + if(index_ < startWeek){ + st = prevMaxDate - startWeek + index_; item.addClass('laydate-day-prev'); YMD = that.getAsYM(dateTime.year, dateTime.month, 'sub'); - } else if(index >= startWeek && index < thisMaxDate + startWeek){ - st = index - startWeek; - if(!options.range){ - st + 1 === dateTime.date && item.addClass(THIS); - } + } else if(index_ >= startWeek && index_ < thisMaxDate + startWeek){ + st = index_ - startWeek; + st + 1 === dateTime.date && item.addClass(THIS); } else { - st = index - thisMaxDate - startWeek; + st = index_ - thisMaxDate - startWeek; item.addClass('laydate-day-next'); YMD = that.getAsYM(dateTime.year, dateTime.month); } @@ -1062,64 +1996,55 @@ year: YMD[0] ,month: YMD[1] - 1 ,date: YMD[2] - }, index); + }, index_); }); //同步头部年月 lay(elemYM[0]).attr('lay-ym', dateTime.year + '-' + (dateTime.month + 1)); lay(elemYM[1]).attr('lay-ym', dateTime.year + '-' + (dateTime.month + 1)); - if(options.lang === 'zh_CN'){ - lay(elemYM[0]).attr('lay-type', 'year').html(dateTime.year + '年') - lay(elemYM[1]).attr('lay-type', 'month').html((dateTime.month + 1) + '月'); + if(options.lang === 'cn'){ + lay(elemYM[0]).attr('lay-type', 'year').html(dateTime.year + ' 年') + lay(elemYM[1]).attr('lay-type', 'month').html((dateTime.month + 1) + ' 月'); } else { lay(elemYM[0]).attr('lay-type', 'month').html(lang.month[dateTime.month]); lay(elemYM[1]).attr('lay-type', 'year').html(dateTime.year); } //初始默认选择器 - if(isAlone){ + if(isAlone){ //年、月等独立选择器 if(options.range){ - value ? that.endDate = (that.endDate || { - year: dateTime.year + (options.type === 'year' ? 1 : 0) - ,month: dateTime.month + (options.type === 'month' ? 0 : -1) - }) : (that.startDate = that.startDate || { - year: dateTime.year - ,month: dateTime.month - }); if(value){ that.listYM = [ - [that.startDate.year, that.startDate.month + 1] + [options.dateTime.year, options.dateTime.month + 1] ,[that.endDate.year, that.endDate.month + 1] ]; that.list(options.type, 0).list(options.type, 1); + //同步按钮可点状态 options.type === 'time' ? that.setBtnStatus('时间' ,lay.extend({}, that.systemDate(), that.startTime) ,lay.extend({}, that.systemDate(), that.endTime) ) : that.setBtnStatus(true); } - } - if(!options.range){ + } else { that.listYM = [[dateTime.year, dateTime.month + 1]]; that.list(options.type, 0); } } - //赋值双日历 - if(options.range && !value){ - var EYM = that.getAsYM(dateTime.year, dateTime.month) - that.calendar(lay.extend({}, dateTime, { - year: EYM[0] - ,month: EYM[1] - })); + //初始赋值双日历 + if(options.range && type === 'init' && !value){ + //执行渲染第二个日历 + that.calendar(that.endDate, 1); } //通过检测当前有效日期,来设定确定按钮是否可点 if(!options.range) that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0, ['hours', 'minutes', 'seconds']); - //标记选择范围 - if(options.range && value && !isAlone) that.stampRange(); + //同步按钮可点状态 + that.setBtnStatus(); + return that; }; @@ -1142,7 +2067,7 @@ ,elemYM = lay(elemHeader[2]).find('span') ,elemCont = that.elemCont[index || 0] ,haveList = lay(elemCont).find('.'+ ELEM_LIST)[0] - ,isCN = options.lang === 'zh_CN' + ,isCN = options.lang === 'cn' ,text = isCN ? '年' : '' ,listYM = that.listYM[index] || {} @@ -1151,7 +2076,8 @@ if(listYM[0] < 1) listYM[0] = 1; - if(type === 'year'){ //年列表 + //生成年列表 + if(type === 'year'){ var yearNum, startY = yearNum = listYM[0] - 7; if(startY < 1) startY = yearNum = 1; lay.each(new Array(15), function(i){ @@ -1173,7 +2099,10 @@ }); lay(elemYM[isCN ? 0 : 1]).attr('lay-ym', (yearNum - 8) + '-' + listYM[1]) .html((startY + text) + ' - ' + (yearNum - 1 + text)); - } else if(type === 'month'){ //月列表 + } + + //生成月列表 + else if(type === 'month'){ lay.each(new Array(12), function(i){ var li = lay.elem('li', { 'lay-ym': i @@ -1190,7 +2119,10 @@ }); lay(elemYM[isCN ? 0 : 1]).attr('lay-ym', listYM[0] + '-' + listYM[1]) .html(listYM[0] + text); - } else if(type === 'time'){ //时间列表 + } + + //生成时间列表 + else if(type === 'time'){ //检测时分秒状态是否在有效日期时间范围内 var setTimeStatus = function(){ lay(ul).find('ol').each(function(i, ol){ @@ -1209,15 +2141,17 @@ }); if(!options.range) that.limit(lay(that.footer).find(ELEM_CONFIRM), that[startEnd], 0, ['hours', 'minutes', 'seconds']); }; + + //初始化时间对象 if(options.range){ - if(!that[startEnd]) that[startEnd] = { - hours: 0 - ,minutes: 0 - ,seconds: 0 - }; + if(!that[startEnd]){ + that[startEnd] = startEnd === 'startTime' ? dateTime : that.endDate; + } } else { that[startEnd] = dateTime; } + + //生成时分秒 lay.each([24, 60, 60], function(i, item){ var li = lay.elem('li'), childUL = ['

'+ lang.time[i] +'

    ']; lay.each(new Array(item), function(ii){ @@ -1233,7 +2167,7 @@ if(haveList) elemCont.removeChild(haveList); elemCont.appendChild(ul); - //年月 + //年月面板 - 选择事件 if(type === 'year' || type === 'month'){ //显示切换箭头 lay(that.elemMain[index]).addClass('laydate-ym-show'); @@ -1245,45 +2179,49 @@ if(index === 0){ dateTime[type] = ym; - if(isAlone) that.startDate[type] = ym; that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0); } else { //范围选择 - if(isAlone){ //非date/datetime类型 - that.endDate[type] = ym; - } else { //date/datetime类型 - var YM = type === 'year' - ? that.getAsYM(ym, listYM[1] - 1, 'sub') - : that.getAsYM(listYM[0], ym, 'sub'); - lay.extend(dateTime, { - year: YM[0] - ,month: YM[1] - }); - } + that.endDate[type] = ym; } - if(options.type === 'year' || options.type === 'month'){ + //当为年选择器或者年月选择器 + var isYearOrMonth = options.type === 'year' || options.type === 'month'; + if(isYearOrMonth){ lay(ul).find('.'+ THIS).removeClass(THIS); lay(this).addClass(THIS); //如果为年月选择器,点击了年列表,则切换到月选择器 if(options.type === 'month' && type === 'year'){ that.listYM[index][0] = ym; - isAlone && (that[['startDate', 'endDate'][index]].year = ym); + isAlone && ((index ? that.endDate : dateTime).year = ym); that.list('month', index); } } else { - that.checkDate('limit').calendar(); + that.checkDate('limit').calendar(null, index); that.closeList(); } that.setBtnStatus(); //同步按钮可点状态 - options.range || that.done(null, 'change'); - lay(that.footer).find(ELEM_TIME_BTN).removeClass(DISABLED); + + //若为月选择器,只有当选择月份时才自动关闭; + //若为年选择器,选择年份即自动关闭 + //且在范围未开启时 + if(!options.range){ + if((options.type === 'month' && type === 'month') || (options.type === 'year' && type === 'year')){ + that.setValue(that.parse()).remove().done(); + } + } + + that.done(null, 'change'); + lay(that.footer).find('.'+ ELEM_TIME_BTN).removeClass(DISABLED); }); - } else { + } else { //时间选择面板 - 选择事件 var span = lay.elem('span', { 'class': ELEM_TIME_TEXT - }), scroll = function(){ //滚动条定位 + }) + + //滚动条定位 + ,scroll = function(){ lay(ul).find('ol').each(function(i){ var ol = this ,li = lay(ol).find('li') @@ -1297,10 +2235,13 @@ }); } }); - }, haveSpan = lay(elemHeader[2]).find('.'+ ELEM_TIME_TEXT); - scroll() - span.innerHTML = options.range ? [lang.startTime,lang.endTime][index] : lang.timeTips + } + ,haveSpan = lay(elemHeader[2]).find('.'+ ELEM_TIME_TEXT); + + scroll(); + span.innerHTML = options.range ? [lang.startTime,lang.endTime][index] : lang.timeTips; lay(that.elemMain[index]).addClass('laydate-time-show'); + if(haveSpan[0]) haveSpan.remove(); elemHeader[2].appendChild(span); @@ -1310,6 +2251,7 @@ lay(ol).find('li').on('click', function(){ var value = this.innerHTML | 0; if(lay(this).hasClass(DISABLED)) return; + if(options.range){ that[startEnd][hms[i]] = value; } else { @@ -1350,10 +2292,10 @@ Class.prototype.setBtnStatus = function(tips, start, end){ var that = this ,options = that.config - ,isOut, elemBtn = lay(that.footer).find(ELEM_CONFIRM) - ,isAlone = options.range && options.type !== 'date' && options.type !== 'time'; - if(isAlone){ - start = start || that.startDate; + ,lang = that.lang() + ,isOut, elemBtn = lay(that.footer).find(ELEM_CONFIRM); + if(options.range && options.type !== 'time'){ + start = start || options.dateTime; end = end || that.endDate; isOut = that.newDate(start).getTime() > that.newDate(end).getTime(); @@ -1364,7 +2306,7 @@ //是否异常提示 if(tips && isOut) that.hint( - typeof tips === 'string' ? TIPS_OUT.replace(/日期/g, tips) : TIPS_OUT + typeof tips === 'string' ? lang.timeout.replace(/日期/g, tips) : lang.timeout ); } }; @@ -1373,34 +2315,17 @@ Class.prototype.parse = function(state, date){ var that = this ,options = that.config - ,dateTime = date || (state + ,dateTime = date || (state == 'end' ? lay.extend({}, that.endDate, that.endTime) - : (options.range ? lay.extend({}, that.startDate, that.startTime) : options.dateTime)) - ,format = that.format.concat(); - - //转义为规定格式 - lay.each(format, function(i, item){ - if(/yyyy|y/.test(item)){ //年 - format[i] = lay.digit(dateTime.year, item.length); - } else if(/MM|M/.test(item)){ //月 - format[i] = lay.digit(dateTime.month + 1, item.length); - } else if(/dd|d/.test(item)){ //日 - format[i] = lay.digit(dateTime.date, item.length); - } else if(/HH|H/.test(item)){ //时 - format[i] = lay.digit(dateTime.hours, item.length); - } else if(/mm|m/.test(item)){ //分 - format[i] = lay.digit(dateTime.minutes, item.length); - } else if(/ss|s/.test(item)){ //秒 - format[i] = lay.digit(dateTime.seconds, item.length); - } - }); + : (options.range ? lay.extend({}, options.dateTime, that.startTime) : options.dateTime)) + ,format = laydate.parse(dateTime, that.format, 1); //返回日期范围字符 - if(options.range && !state){ - return format.join('') + ' '+ options.range +' ' + that.parse(1); + if(options.range && state === undefined){ + return format + ' '+ that.rangeStr +' ' + that.parse('end'); } - return format.join(''); + return format; }; //创建指定日期时间对象 @@ -1420,63 +2345,60 @@ Class.prototype.setValue = function(value){ var that = this ,options = that.config - ,elem = that.bindElem || options.elem[0] - ,valType = that.isInput(elem) ? 'val' : 'html' + ,elem = that.bindElem || options.elem[0]; - options.position === 'static' || lay(elem)[valType](value || ''); - return this; + //静态展现则不作默认赋值 + if(options.position === 'static') return that; + + value = value || ''; + + //绑定的元素是否为 input + if(that.isInput(elem)){ + lay(elem).val(value); + } else { + //如果 range 传入了开始和结束的 input 对象,则分别对其赋值 + if(that.rangeElem){ + that.rangeElem[0].val(value ? that.parse('start') : ''); + that.rangeElem[1].val(value ? that.parse('end') : ''); + } else { + if(lay(elem).find('*').length === 0){ + lay(elem).html(value); + } + lay(elem).attr('lay-date', value); + } + } + + return that; }; - //标记范围内的日期 - Class.prototype.stampRange = function(){ + //预览 + Class.prototype.preview = function(){ var that = this - ,options = that.config - ,startTime, endTime - ,tds = lay(that.elem).find('td'); + ,options = that.config; - if(options.range && !that.endDate) lay(that.footer).find(ELEM_CONFIRM).addClass(DISABLED); - if(!that.endDate) return; - - startTime = that.newDate({ - year: that.startDate.year - ,month: that.startDate.month - ,date: that.startDate.date - }).getTime(); + if(!options.isPreview) return; - endTime = that.newDate({ - year: that.endDate.year - ,month: that.endDate.month - ,date: that.endDate.date - }).getTime(); + var elemPreview = lay(that.elem).find('.'+ ELEM_PREVIEW) + ,value = options.range ? (that.endDate ? that.parse() : '') : that.parse(); - if(startTime > endTime) return that.hint(TIPS_OUT); - - lay.each(tds, function(i, item){ - var ymd = lay(item).attr('lay-ymd').split('-') - ,thisTime = that.newDate({ - year: ymd[0] - ,month: ymd[1] - 1 - ,date: ymd[2] - }).getTime(); - lay(item).removeClass(ELEM_SELECTED + ' ' + THIS); - if(thisTime === startTime || thisTime === endTime){ - lay(item).addClass( - lay(item).hasClass(ELEM_PREV) || lay(item).hasClass(ELEM_NEXT) - ? ELEM_SELECTED - : THIS - ); - } - if(thisTime > startTime && thisTime < endTime){ - lay(item).addClass(ELEM_SELECTED); - } + //显示预览 + elemPreview.html(value).css({ + 'color': '#08c' + ,'font-size': '14px;' }); + setTimeout(function(){ + elemPreview.css({ + 'color': '#666' + ,'font-size': '12px;' + }); + }, 300); }; - //执行done/change回调 + //执行 done/change 回调 Class.prototype.done = function(param, type){ var that = this ,options = that.config - ,start = lay.extend({}, that.startDate ? lay.extend(that.startDate, that.startTime) : options.dateTime) + ,start = lay.extend({}, lay.extend(options.dateTime, that.startTime)) ,end = lay.extend({}, lay.extend(that.endDate, that.endTime)) lay.each([start, end], function(i, item){ @@ -1486,6 +2408,8 @@ }); }); + that.preview(); + param = param || [that.parse(), start, end]; typeof options[type || 'done'] === 'function' && options[type || 'done'].apply(options, param); @@ -1493,28 +2417,13 @@ }; //选择日期 - Class.prototype.choose = function(td){ + Class.prototype.choose = function(td, index){ var that = this ,options = that.config - ,dateTime = options.dateTime + ,dateTime = that.thisDateTime(index) ,tds = lay(that.elem).find('td') - ,YMD = td.attr('lay-ymd').split('-') - - ,setDateTime = function(one){ - var thisDate = new Date(); - - //同步dateTime - one && lay.extend(dateTime, YMD); - - //记录开始日期 - if(options.range){ - that.startDate ? lay.extend(that.startDate, YMD) : ( - that.startDate = lay.extend({}, YMD, that.startTime) - ); - that.startYMD = YMD; - } - }; + ,YMD = td.attr('lay-ymd').split('-'); YMD = { year: YMD[0] | 0 @@ -1523,10 +2432,12 @@ }; if(td.hasClass(DISABLED)) return; + + lay.extend(dateTime, YMD); //同步 dateTime //范围选择 if(options.range){ - + //补充时分秒 lay.each(['startTime', 'endTime'], function(i, item){ that[item] = that[item] || { hours: 0 @@ -1534,54 +2445,12 @@ ,seconds: 0 }; }); - - if(that.endState){ //重新选择 - setDateTime(); - delete that.endState; - delete that.endDate; - that.startState = true; - tds.removeClass(THIS + ' ' + ELEM_SELECTED); - td.addClass(THIS); - } else if(that.startState){ //选中截止 - td.addClass(THIS); - - that.endDate ? lay.extend(that.endDate, YMD) : ( - that.endDate = lay.extend({}, YMD, that.endTime) - ); - - //判断是否顺时或逆时选择 - if(that.newDate(YMD).getTime() < that.newDate(that.startYMD).getTime()){ - var startDate = lay.extend({}, that.endDate, { - hours: that.startDate.hours - ,minutes: that.startDate.minutes - ,seconds: that.startDate.seconds - }); - lay.extend(that.endDate, that.startDate, { - hours: that.endDate.hours - ,minutes: that.endDate.minutes - ,seconds: that.endDate.seconds - }); - that.startDate = startDate; - } - - options.showBottom || that.done(); - that.stampRange(); //标记范围内的日期 - that.endState = true; - that.done(null, 'change'); - } else { //选中开始 - td.addClass(THIS); - setDateTime(); - that.startState = true; - } - lay(that.footer).find(ELEM_CONFIRM)[that.endDate ? 'removeClass' : 'addClass'](DISABLED); + that.calendar(null, index).done(null, 'change'); } else if(options.position === 'static'){ //直接嵌套的选中 - setDateTime(true); - that.calendar().done().done(null, 'change'); + that.calendar().done().done(null, 'change'); //同时执行 done 和 change 回调 } else if(options.type === 'date'){ - setDateTime(true); that.setValue(that.parse()).remove().done(); } else if(options.type === 'datetime'){ - setDateTime(true); that.calendar().done(null, 'change'); } }; @@ -1590,6 +2459,7 @@ Class.prototype.tool = function(btn, type){ var that = this ,options = that.config + ,lang = that.lang() ,dateTime = options.dateTime ,isStatic = options.position === 'static' ,active = { @@ -1609,18 +2479,17 @@ //清空、重置 ,clear: function(){ - that.setValue('').remove(); isStatic && ( lay.extend(dateTime, that.firstDate) ,that.calendar() ) options.range && ( - delete that.startState - ,delete that.endState + delete options.dateTime ,delete that.endDate ,delete that.startTime ,delete that.endTime ); + that.setValue('').remove(); that.done(['', {}, {}]); } @@ -1640,13 +2509,13 @@ //确定 ,confirm: function(){ if(options.range){ - if(!that.endDate) return that.hint('请先选择日期范围'); if(lay(btn).hasClass(DISABLED)) return that.hint( - options.type === 'time' ? TIPS_OUT.replace(/日期/g, '时间') : TIPS_OUT + options.type === 'time' ? lang.timeout.replace(/日期/g, '时间') : lang.timeout ); } else { - if(lay(btn).hasClass(DISABLED)) return that.hint('不在有效日期或时间范围内'); + if(lay(btn).hasClass(DISABLED)) return that.hint(lang.invalidDate); } + // ThinkGem 当下一个日期弹出前,可能上一个还未设置,导致选择不上的问题(下面2行调换顺序) that.setValue(that.parse()).remove() that.done(); } @@ -1658,14 +2527,13 @@ Class.prototype.change = function(index){ var that = this ,options = that.config - ,dateTime = options.dateTime + ,dateTime = that.thisDateTime(index) ,isAlone = options.range && (options.type === 'year' || options.type === 'month') ,elemCont = that.elemCont[index || 0] ,listYM = that.listYM[index] ,addSubYeay = function(type){ - var startEnd = ['startDate', 'endDate'][index] - ,isYear = lay(elemCont).find('.laydate-year-list')[0] + var isYear = lay(elemCont).find('.laydate-year-list')[0] ,isMonth = lay(elemCont).find('.laydate-month-list')[0]; //切换年列表 @@ -1683,13 +2551,14 @@ lay.extend(dateTime, { year: listYM[0] }); - if(isAlone) that[startEnd].year = listYM[0]; - options.range || that.done(null, 'change'); - that.setBtnStatus(); + if(isAlone) dateTime.year = listYM[0]; + options.range || that.done(null, 'change'); options.range || that.limit(lay(that.footer).find(ELEM_CONFIRM), { year: listYM[0] }); } + + that.setBtnStatus(); return isYear || isMonth; }; @@ -1697,8 +2566,8 @@ prevYear: function(){ if(addSubYeay('sub')) return; dateTime.year--; - that.checkDate('limit').calendar(); - options.range || that.done(null, 'change'); + that.checkDate('limit').calendar(null, index); + that.done(null, 'change'); } ,prevMonth: function(){ var YM = that.getAsYM(dateTime.year, dateTime.month, 'sub'); @@ -1706,8 +2575,8 @@ year: YM[0] ,month: YM[1] }); - that.checkDate('limit').calendar(); - options.range || that.done(null, 'change'); + that.checkDate('limit').calendar(null, index); + that.done(null, 'change'); } ,nextMonth: function(){ var YM = that.getAsYM(dateTime.year, dateTime.month); @@ -1715,14 +2584,14 @@ year: YM[0] ,month: YM[1] }); - that.checkDate('limit').calendar(); - options.range || that.done(null, 'change'); + that.checkDate('limit').calendar(null, index); + that.done(null, 'change'); } ,nextYear: function(){ if(addSubYeay()) return; dateTime.year++ - that.checkDate('limit').calendar(); - options.range || that.done(null, 'change'); + that.checkDate('limit').calendar(null, index); + that.done(null, 'change'); } }; }; @@ -1735,6 +2604,8 @@ //日期选择事件 lay(that.elem).on('click', function(e){ lay.stope(e); + }).on('mousedown', function(e){ + lay.stope(e); }); //年月切换 @@ -1761,7 +2632,7 @@ that.listYM[i] = [layYM[0] | 0, layYM[1] | 0]; that.list(layType, i); - lay(that.footer).find(ELEM_TIME_BTN).addClass(DISABLED); + lay(that.footer).find('.'+ ELEM_TIME_BTN).addClass(DISABLED); }); //下一月 @@ -1779,7 +2650,7 @@ lay.each(that.table, function(i, table){ var tds = lay(table).find('td'); tds.on('click', function(){ - that.choose(lay(this)); + that.choose(lay(this), i); }); }); @@ -1819,17 +2690,44 @@ showEvent(options.elem, 'bind'); showEvent(options.eventElem); + options.elem[0].eventHandler = true; + }; + + //记录所有实例 + 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; + }; + + //初始执行 + ready.run = function(lay){ //绑定关闭控件事件 - lay(document).on('click', function(e){ - if(e.target === options.elem[0] - || e.target === options.eventElem[0] - || e.target === lay(options.closeStop)[0]){ - return; - } + lay(document).on('mousedown', function(e){ + if(!laydate.thisId) return; + var that = thisModule.getThis(laydate.thisId); + if(!that) return; + + var options = that.config; + + if( + e.target === options.elem[0] || + e.target === options.eventElem[0] || + e.target === lay(options.closeStop)[0] + ) return; + that.remove(); + }).on('keydown', function(e){ + if(!laydate.thisId) return; + var that = thisModule.getThis(laydate.thisId); + if(!that) return; + if(e.keyCode === 13){ - if(lay('#'+ that.elemID)[0] && that.elemID === Class.thisElem){ + if(lay('#'+ that.elemID)[0] && that.elemID === Class.thisElemDate){ e.preventDefault(); lay(that.footer).find(ELEM_CONFIRM)[0].click(); } @@ -1838,20 +2736,53 @@ //自适应定位 lay(window).on('resize', function(){ + if(!laydate.thisId) return; + var that = thisModule.getThis(laydate.thisId); + if(!that) return; + if(!that.elem || !lay(ELEM)[0]){ return false; } + that.position(); }); - - options.elem[0].eventHandler = true; }; - //核心接口 laydate.render = function(options){ var inst = new Class(options); - return thisDate.call(inst); + return thisModule.call(inst); + }; + + //将指定对象转化为日期值 + laydate.parse = function(dateTime, format, one){ + dateTime = dateTime || {}; + + //如果 format 是字符型,则转换为数组格式 + if(typeof format === 'string'){ + format = thisModule.formatArr(format); + } + + format = (format || []).concat(); + + //转义为规定格式 + lay.each(format, function(i, item){ + if(/yyyy|y/.test(item)){ //年 + format[i] = lay.digit(dateTime.year, item.length); + } else if(/MM|M/.test(item)){ //月 + format[i] = lay.digit(dateTime.month + (one || 0), item.length); + } else if(/dd|d/.test(item)){ //日 + format[i] = lay.digit(dateTime.date, item.length); + } else if(/HH|H/.test(item)){ //时 + format[i] = lay.digit(dateTime.hours, item.length); + } else if(/mm|m/.test(item)){ //分 + format[i] = lay.digit(dateTime.minutes, item.length); + } else if(/ss|s/.test(item)){ //秒 + format[i] = lay.digit(dateTime.seconds, item.length); + } + }); + + return format.join(''); }; //得到某月的最后一天 @@ -1866,23 +2797,24 @@ return new Date(thisDate.getTime() - 1000*60*60*24).getDate(); }; - //暴露lay - window.lay = window.lay || lay; - //加载方式 isLayui ? ( laydate.ready() - ,layui.define(function(exports){ //layui加载 + ,layui.define('lay', function(exports){ //layui 加载 laydate.path = layui.cache.dir; + ready.run(lay); exports(MOD_NAME, laydate); }) ) : ( - (typeof define === 'function' && define.amd) ? define(function(){ //requirejs加载 + (typeof define === 'function' && define.amd) ? define(function(){ //requirejs 加载 + ready.run(lay); return laydate; - }) : function(){ //普通script标签加载 + }) : function(){ //普通 script 标签加载 laydate.ready(); - window.laydate = laydate + ready.run(window.lay); + window.laydate = laydate; }() ); -}(); \ No newline at end of file +}(window, window.document); + diff --git a/common/src/main/resources/static/laydate/5.0/test.html b/common/src/main/resources/static/laydate/5.3/test.html similarity index 100% rename from common/src/main/resources/static/laydate/5.0/test.html rename to common/src/main/resources/static/laydate/5.3/test.html diff --git a/common/src/main/resources/static/laydate/5.0/theme/default/font/iconfont.eot b/common/src/main/resources/static/laydate/5.3/theme/default/font/iconfont.eot similarity index 100% rename from common/src/main/resources/static/laydate/5.0/theme/default/font/iconfont.eot rename to common/src/main/resources/static/laydate/5.3/theme/default/font/iconfont.eot diff --git a/common/src/main/resources/static/laydate/5.0/theme/default/font/iconfont.svg b/common/src/main/resources/static/laydate/5.3/theme/default/font/iconfont.svg similarity index 100% rename from common/src/main/resources/static/laydate/5.0/theme/default/font/iconfont.svg rename to common/src/main/resources/static/laydate/5.3/theme/default/font/iconfont.svg diff --git a/common/src/main/resources/static/laydate/5.0/theme/default/font/iconfont.ttf b/common/src/main/resources/static/laydate/5.3/theme/default/font/iconfont.ttf similarity index 100% rename from common/src/main/resources/static/laydate/5.0/theme/default/font/iconfont.ttf rename to common/src/main/resources/static/laydate/5.3/theme/default/font/iconfont.ttf diff --git a/common/src/main/resources/static/laydate/5.0/theme/default/font/iconfont.woff b/common/src/main/resources/static/laydate/5.3/theme/default/font/iconfont.woff similarity index 100% rename from common/src/main/resources/static/laydate/5.0/theme/default/font/iconfont.woff rename to common/src/main/resources/static/laydate/5.3/theme/default/font/iconfont.woff diff --git a/common/src/main/resources/static/laydate/5.3/theme/default/laydate.css b/common/src/main/resources/static/laydate/5.3/theme/default/laydate.css new file mode 100644 index 00000000..8fddab20 --- /dev/null +++ b/common/src/main/resources/static/laydate/5.3/theme/default/laydate.css @@ -0,0 +1,171 @@ +/** 图标字体 **/ +@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 + + **/ + + +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.2s; animation-duration: 0.2s; -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;} + +/* 微微往下滑入 */ +@keyframes laydate-downbit { + 0% {opacity: 0.3; transform: translate3d(0, -5px, 0);} + 100% {opacity: 1; transform: translate3d(0, 0, 0);} +} + +.layui-laydate{animation-name: laydate-downbit;} +.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: 5px; 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%; 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{display: inline-block; vertical-align: top; height: 24px; line-height: 22px; padding: 0 10px; border: 1px solid #C9C9C9; border-radius: 2px; background-color: #fff; font-size: 12px; cursor: pointer; white-space: nowrap; transition: all .3s;} +.layui-laydate-footer span:hover{color: #08c;} +.layui-laydate-footer span.layui-laydate-preview{cursor: default; border-color: transparent !important;} +.layui-laydate-footer span.layui-laydate-preview:hover{color: #666;} +.layui-laydate-footer span:first-child.layui-laydate-preview{padding-left: 0;} +.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; height: 30px; 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: 546px;} +.layui-laydate-range .layui-laydate-main{display: inline-block; vertical-align: middle;} +.layui-laydate-range .laydate-main-list-1 .layui-laydate-header, +.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); 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; 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/modules/cms/src/main/resources/views/modules/cmsfront/themes/default/search.html b/modules/cms/src/main/resources/views/modules/cmsfront/themes/default/search.html index 03192892..a93a9765 100644 --- a/modules/cms/src/main/resources/views/modules/cmsfront/themes/default/search.html +++ b/modules/cms/src/main/resources/views/modules/cmsfront/themes/default/search.html @@ -1,5 +1,5 @@ <% layout('layouts/default.html', {title: '全站搜索', libs: []}){ %> - +