diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9435309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +*.iml +.idea/ +.ipr +.iws +*~ +~* +*.diff +*.patch +*.bak +.DS_Store +Thumbs.db +.svn/ +*.swp +.nojekyll +.project +.settings/ +node_modules/ +_site/ +release/ +.npmignore diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1696a86 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ + +# [更新日志](http://www.layui.com/laydate/changelog.html) + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..be179b1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 layui + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 2514449..ace881f 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,9 @@ -## 说明 -1. laydate.js是压缩后的核心代码,laydate.dev.js是开发版的源代码。 -1. need目录存放着核心css -1. skins是皮肤目录 -1. 将laydate pull到你的本地后,将其存放到您js相关目录下的laydate目录,不要改动laydate的结构,否则无法正常运行。 -## 简要 -她基于原生JavaScript精心雕琢,兼容了包括IE6在内的所有主流浏览器。她具备优雅的内部代码,良好的性能体验,和完善的皮肤体系,并且完全开源,你可以任意获取开发版源代码,一扫某些传统日期控件的封闭与狭隘。layDate本着资源共享的开发者精神和对网页日历交互无穷的追求,延续了layui一贯的简单与易用。她遵循LGPL协议,您可以免费将她用于任何个人项目。 +## 概要 +一款被广泛使用的高级 Web 日历组件,颜值与功能兼备,足以应对日期相关的各种业务场景。其中主要以:年选择器、年月选择器、日期选择器、时间选择器、日期时间选择五种类型的选择方式为基本核心,并且均支持范围选择(即双控件)。内置强劲的自定义日期格式解析和合法校正机制,含中文版和国际版,主题简约却又不失灵活多样。内部采用是零依赖的原生 JavaScript 编写,可作为独立组件使用。 -## 更新日志 +## 官网 +[http://www.layui.com/laydate/](http://www.layui.com/laydate/) -1.1 - -1. layer.now(timestamp,format)支持多类型参数。timestamp支持今天的前若干天,和今天的后若干天,并且如果是一个有效的时间戳,则返回该时间戳对应的日期。如果什么都没传入,则返回当前时间日期。format为日期格式,为空时则采用默认的“-”分割。 -2. 优化核心代码。 -3. 分和秒的选择改成10列*6行。 -4. 修复星期未居中对齐的样式问题 -5. 修复在页面加载完毕事件中,调用laydate所造成的立即执行的bug -6. 皮肤包新增[墨绿]。 - -## 备注 -[官网](http://laydate.layui.com/)、[社区](http://fly.layui.com/) +## 相关 +[文档](http://www.layui.com/doc/modules/laydate.html) \ No newline at end of file diff --git a/dist/laydate.js b/dist/laydate.js new file mode 100644 index 0000000..98a1e6a --- /dev/null +++ b/dist/laydate.js @@ -0,0 +1,3 @@ +/*! layDate v5.3.1 | 日期与时间组件 | MIT Licensed */ + ;!function(e){"use strict";var t=e.document,n={modules:{},status:{},timeout:10,event:{}},a=function(){this.v="2.6.7"},r=e.LAYUI_GLOBAL||{},i=function(){var e=t.currentScript?t.currentScript.src:function(){for(var e,n=t.scripts,a=n.length-1,r=a;r>0;r--)if("interactive"===n[r].readyState){e=n[r].src;break}return e||n[a].src}();return n.dir=r.dir||e.substring(0,e.lastIndexOf("/")+1)}(),o=function(t,n){n=n||"log",e.console&&console[n]&&console[n]("layui error hint: "+t)},l="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),s=n.builtin={lay:"lay",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",all:"all","layui.all":"layui.all"};a.prototype.cache=n,a.prototype.define=function(e,t){var a=this,r="function"==typeof e,i=function(){var e=function(e,t){u[e]=t,n.status[e]=!0};return"function"==typeof t&&t(function(a,r){e(a,r),n.callback[a]=function(){t(e)}}),this};return r&&(t=e,e=[]),a.use(e,i,null,"define"),a},a.prototype.use=function(a,r,c,y){function d(e,t){var a="PLaySTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/;("load"===e.type||a.test((e.currentTarget||e.srcElement).readyState))&&(n.modules[g]=t,p.removeChild(w),function r(){return++v>1e3*n.timeout/4?o(g+" is not a valid module","error"):void(n.status[g]?m():setTimeout(r,4))}())}function m(){c.push(u[g]),a.length>1?f.use(a.slice(1),r,c,y):"function"==typeof r&&function(){return u.jquery&&"function"==typeof u.jquery&&"define"!==y?u.jquery(function(){r.apply(u,c)}):void r.apply(u,c)}()}var f=this,h=n.dir=n.dir?n.dir:i,p=t.getElementsByTagName("head")[0];a=function(){return"string"==typeof a?[a]:"function"==typeof a?(r=a,["all"]):a}(),e.jQuery&&jQuery.fn.on&&(f.each(a,function(e,t){"jquery"===t&&a.splice(e,1)}),u.jquery=u.$=jQuery);var g=a[0],v=0;if(c=c||[],n.host=n.host||(h.match(/\/\/([\s\S]+?)\//)||["//"+location.host+"/"])[0],0===a.length||u["layui.all"]&&s[g])return m(),f;var T=(s[g]?h+"modules/":/^\{\/\}/.test(f.modules[g])?"":n.base||"")+(f.modules[g]||g)+".js";if(T=T.replace(/^\{\/\}/,""),!n.modules[g]&&u[g]&&(n.modules[g]=T),n.modules[g])!function D(){return++v>1e3*n.timeout/4?o(g+" is not a valid module","error"):void("string"==typeof n.modules[g]&&n.status[g]?m():setTimeout(D,4))}();else{var w=t.createElement("script");w.async=!0,w.charset="utf-8",w.src=T+function(){var e=n.version===!0?n.v||(new Date).getTime():n.version||"";return e?"?v="+e:""}(),p.appendChild(w),!w.attachEvent||w.attachEvent.toString&&w.attachEvent.toString().indexOf("[native code")<0||l?w.addEventListener("load",function(e){d(e,T)},!1):w.attachEvent("onreadystatechange",function(e){d(e,T)}),n.modules[g]=T}return f},a.prototype.getStyle=function(t,n){var a=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return a[a.getPropertyValue?"getPropertyValue":"getAttribute"](n)},a.prototype.link=function(e,a,r){var i=this,l=t.getElementsByTagName("head")[0],s=t.createElement("link");"string"==typeof a&&(r=a);var c=(r||e).replace(/\.|\//g,""),u=s.id="layuicss-"+c,y="creating",d=0;return s.rel="stylesheet",s.href=e+(n.debug?"?v="+(new Date).getTime():""),s.media="all",t.getElementById(u)||l.appendChild(s),"function"!=typeof a?i:(function m(r){var l=100,s=t.getElementById(u);return++d>1e3*n.timeout/l?o(e+" timeout"):void(1989===parseInt(i.getStyle(s,"width"))?(r===y&&s.removeAttribute("lay-status"),s.getAttribute("lay-status")===y?setTimeout(m,l):a()):(s.setAttribute("lay-status",y),setTimeout(function(){m(y)},l)))}(),i)},a.prototype.addcss=function(e,t,a){return u.link(n.dir+"css/"+e,t,a)},n.callback={},a.prototype.factory=function(e){if(u[e])return"function"==typeof n.callback[e]?n.callback[e]:null},a.prototype.img=function(e,t,n){var a=new Image;return a.src=e,a.complete?t(a):(a.onload=function(){a.onload=null,"function"==typeof t&&t(a)},void(a.onerror=function(e){a.onerror=null,"function"==typeof n&&n(e)}))},a.prototype.config=function(e){e=e||{};for(var t in e)n[t]=e[t];return this},a.prototype.modules=function(){var e={};for(var t in s)e[t]=s[t];return e}(),a.prototype.extend=function(e){var t=this;e=e||{};for(var n in e)t[n]||t.modules[n]?o(n+" Module already exists","error"):t.modules[n]=e[n];return t},a.prototype.router=function(e){var t=this,e=e||location.hash,n={path:[],search:{},hash:(e.match(/[^#](#.*$)/)||[])[1]||""};return/^#\//.test(e)?(e=e.replace(/^#\//,""),n.href="/"+e,e=e.replace(/([^#])(#.*$)/,"$1").split("/")||[],t.each(e,function(e,t){/^\w+=/.test(t)?function(){t=t.split("="),n.search[t[0]]=t[1]}():n.path.push(t)}),n):n},a.prototype.url=function(e){var t=this,n={pathname:function(){var t=e?function(){var t=(e.match(/\.[^.]+?\/.+/)||[])[0]||"";return t.replace(/^[^\/]+/,"").replace(/\?.+/,"")}():location.pathname;return t.replace(/^\//,"").split("/")}(),search:function(){var n={},a=(e?function(){var t=(e.match(/\?.+/)||[])[0]||"";return t.replace(/\#.+/,"")}():location.search).replace(/^\?+/,"").split("&");return t.each(a,function(e,t){var a=t.indexOf("="),r=function(){return a<0?t.substr(0,t.length):0!==a&&t.substr(0,a)}();r&&(n[r]=a>0?t.substr(a+1):null)}),n}(),hash:t.router(function(){return e?(e.match(/#.+/)||[])[0]||"/":location.hash}())};return n},a.prototype.data=function(t,n,a){if(t=t||"layui",a=a||localStorage,e.JSON&&e.JSON.parse){if(null===n)return delete a[t];n="object"==typeof n?n:{key:n};try{var r=JSON.parse(a[t])}catch(i){var r={}}return"value"in n&&(r[n.key]=n.value),n.remove&&delete r[n.key],a[t]=JSON.stringify(r),n.key?r[n.key]:r}},a.prototype.sessionData=function(e,t){return this.data(e,t,sessionStorage)},a.prototype.device=function(t){var n=navigator.userAgent.toLowerCase(),a=function(e){var t=new RegExp(e+"/([^\\s\\_\\-]+)");return e=(n.match(t)||[])[1],e||!1},r={os:function(){return/windows/.test(n)?"windows":/linux/.test(n)?"linux":/iphone|ipod|ipad|ios/.test(n)?"ios":/mac/.test(n)?"mac":void 0}(),ie:function(){return!!(e.ActiveXObject||"ActiveXObject"in e)&&((n.match(/msie\s(\d+)/)||[])[1]||"11")}(),weixin:a("micromessenger")};return t&&!r[t]&&(r[t]=a(t)),r.android=/android/.test(n),r.ios="ios"===r.os,r.mobile=!(!r.android&&!r.ios),r},a.prototype.hint=function(){return{error:o}},a.prototype._typeof=function(e){return null===e?String(e):"object"==typeof e||"function"==typeof e?function(){var t=Object.prototype.toString.call(e).match(/\s(.+)\]$/)||[],n="Function|Array|Date|RegExp|Object|Error|Symbol";return t=t[1]||"Object",new RegExp("\\b("+n+")\\b").test(t)?t.toLowerCase():"object"}():typeof e},a.prototype._isArray=function(t){var n,a=this,r=a._typeof(t);return!(!t||"object"!=typeof t||t===e)&&(n="length"in t&&t.length,"array"===r||0===n||"number"==typeof n&&n>0&&n-1 in t)},a.prototype.each=function(e,t){var n,a=this,r=function(e,n){return t.call(n[e],e,n[e])};if("function"!=typeof t)return a;if(e=e||[],a._isArray(e))for(n=0;n(window.innerHeight||d.documentElement.clientHeight)},m.position=function(e,t,n){if(t){n=n||{},e!==d&&e!==m("body")[0]||(n.clickType="right");var a="right"===n.clickType?function(){var e=n.e||window.event||{};return{left:e.clientX,top:e.clientY,right:e.clientX,bottom:e.clientY}}():e.getBoundingClientRect(),r=t.offsetWidth,i=t.offsetHeight,o=function(e){return e=e?"scrollLeft":"scrollTop",d.body[e]|d.documentElement[e]},l=function(e){return d.documentElement[e?"clientWidth":"clientHeight"]},s=5,c=a.left,u=a.bottom;c+r+s>l("width")&&(c=l("width")-r-s),u+i+s>l()&&(a.top>i+s?u=a.top-i-2*s:"right"===n.clickType&&(u=l()-i-2*s,u<0&&(u=0)));var y=n.position;if(y&&(t.style.position=y),t.style.left=c+("fixed"===y?0:o(1))+"px",t.style.top=u+("fixed"===y?0:o())+"px",!m.hasScrollbar()){var f=t.getBoundingClientRect();!n.SYSTEM_RELOAD&&f.bottom+s>l()&&(n.SYSTEM_RELOAD=!0,setTimeout(function(){m.position(e,t,n)},50))}}},m.options=function(e,t){var n=m(e),a=t||"lay-options";try{return new Function("return "+(n.attr(a)||"{}"))()}catch(r){return hint.error("parseerror\uff1a"+r,"error"),{}}},m.isTopElem=function(e){var t=[d,m("body")[0]],n=!1;return m.each(t,function(t,a){if(a===e)return n=!0}),n},f.addStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),m.each(t,function(t,n){new RegExp("\\b"+n+"\\b").test(e)||(e=e+" "+n)}),e.replace(/^\s|\s$/,"")},f.removeStr=function(e,t){return e=e.replace(/\s+/," "),t=t.replace(/\s+/," ").split(" "),m.each(t,function(t,n){var a=new RegExp("\\b"+n+"\\b");a.test(e)&&(e=e.replace(a,""))}),e.replace(/\s+/," ").replace(/^\s|\s$/,"")},f.prototype.find=function(e){var t=this,n=0,a=[],r="object"==typeof e;return this.each(function(i,o){for(var l=r?o.contains(e):o.querySelectorAll(e||null);n0)return n[0].style[e]}():n.each(function(n,r){"object"==typeof e?m.each(e,function(e,t){r.style[e]=a(t)}):r.style[e]=a(t)})},f.prototype.width=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].offsetWidth}():t.each(function(n,a){t.css("width",e)})},f.prototype.height=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].offsetHeight}():t.each(function(n,a){t.css("height",e)})},f.prototype.attr=function(e,t){var n=this;return void 0===t?function(){if(n.length>0)return n[0].getAttribute(e)}():n.each(function(n,a){a.setAttribute(e,t)})},f.prototype.removeAttr=function(e){return this.each(function(t,n){n.removeAttribute(e)})},f.prototype.html=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].innerHTML}():this.each(function(t,n){n.innerHTML=e})},f.prototype.val=function(e){var t=this;return void 0===e?function(){if(t.length>0)return t[0].value}():this.each(function(t,n){n.value=e})},f.prototype.append=function(e){return this.each(function(t,n){"object"==typeof e?n.appendChild(e):n.innerHTML=n.innerHTML+e})},f.prototype.remove=function(e){return this.each(function(t,n){e?n.removeChild(e):n.parentNode.removeChild(n)})},f.prototype.on=function(e,t){return this.each(function(n,a){a.attachEvent?a.attachEvent("on"+e,function(e){e.target=e.srcElement,t.call(a,e)}):a.addEventListener(e,t,!1)})},f.prototype.off=function(e,t){return this.each(function(n,a){a.detachEvent?a.detachEvent("on"+e,t):a.removeEventListener(e,t,!1)})},window.lay=m,window.layui&&u.define&&u.define(function(e){e(y,m)})}(window,window.document),!function(e,t){"use strict";var n=e.layui&&layui.define,a={getPath:e.lay&&lay.getPath?lay.getPath:"",link:function(t,n,a){i.path&&e.lay&&lay.layui&&lay.layui.link(i.path+t,n,a)}},r=e.LAYUI_GLOBAL||{},i={v:"5.3.1",config:{},index:e.laydate&&e.laydate.v?1e5:0,path:r.laydate_dir||a.getPath,set:function(e){var t=this;return t.config=lay.extend({},t.config,e),t},ready:function(e){var t="laydate",r="",o=(n?"modules/laydate/":"theme/")+"default/laydate.css?v="+i.v+r;return n?layui.addcss(o,e,t):a.link(o,e,t),this}},o=function(){var e=this,t=e.config,n=t.id;return o.that[n]=e,{hint:function(t){e.hint.call(e,t)},config:e.config}},l="laydate",s=".layui-laydate",c="layui-this",u="laydate-disabled",y=[100,2e5],d="layui-laydate-static",m="layui-laydate-list",f="layui-laydate-hint",h="layui-laydate-footer",p=".laydate-btns-confirm",g="laydate-time-text",v="laydate-btns-time",T="layui-laydate-preview",w=function(e){var t=this;t.index=++i.index,t.config=lay.extend({},t.config,i.config,e),e=t.config,e.id="id"in e?e.id:t.index,i.ready(function(){t.init()})},D="yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s";o.formatArr=function(e){return(e||"").match(new RegExp(D+"|.","g"))||[]},w.isLeapYear=function(e){return e%4===0&&e%100!==0||e%400===0},w.prototype.config={type:"date",range:!1,format:"yyyy-MM-dd",value:null,isInitValue:!0,min:"1900-1-1",max:"2099-12-31",trigger:"click",show:!1,showBottom:!0,isPreview:!0,btns:["clear","now","confirm"],lang:"cn",theme:"default",position:null,calendar:!1,mark:{},zIndex:null,done:null,change:null},w.prototype.lang=function(){var e=this,t=e.config,n={cn:{weeks:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d"],time:["\u65f6","\u5206","\u79d2"],timeTips:"\u9009\u62e9\u65f6\u95f4",startTime:"\u5f00\u59cb\u65f6\u95f4",endTime:"\u7ed3\u675f\u65f6\u95f4",dateTips:"\u8fd4\u56de\u65e5\u671f",month:["\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u5341\u4e00","\u5341\u4e8c"],tools:{confirm:"\u786e\u5b9a",clear:"\u6e05\u7a7a",now:"\u73b0\u5728"},timeout:"\u7ed3\u675f\u65f6\u95f4\u4e0d\u80fd\u65e9\u4e8e\u5f00\u59cb\u65f6\u95f4
\u8bf7\u91cd\u65b0\u9009\u62e9",invalidDate:"\u4e0d\u5728\u6709\u6548\u65e5\u671f\u6216\u65f6\u95f4\u8303\u56f4\u5185",formatError:["\u65e5\u671f\u683c\u5f0f\u4e0d\u5408\u6cd5
\u5fc5\u987b\u9075\u5faa\u4e0b\u8ff0\u683c\u5f0f\uff1a
","
\u5df2\u4e3a\u4f60\u91cd\u7f6e"],preview:"\u5f53\u524d\u9009\u4e2d\u7684\u7ed3\u679c"},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"},timeout:"End time cannot be less than start Time
Please re-select",invalidDate:"Invalid date",formatError:["The date format error
Must be followed\uff1a
","
It has been reset"],preview:"The selected result"}};return n[t.lang]||n.cn},w.prototype.init=function(){var t=this,n=t.config,a="static"===n.position,r={year:"yyyy",month:"yyyy-MM",date:"yyyy-MM-dd",time:"HH:mm:ss",datetime:"yyyy-MM-dd HH:mm:ss"};n.elem=lay(n.elem),n.eventElem=lay(n.eventElem),n.elem[0]&&(t.rangeStr=n.range?"string"==typeof n.range?n.range:"-":"",n.range&&n.range.constructor===Array&&(t.rangeElem=[lay(n.range[0]),lay(n.range[1])]),r[n.type]||(e.console&&console.error&&console.error("laydate type error:'"+n.type+"' is not supported"),n.type="date"),n.format===r.date&&(n.format=r[n.type]||r.date),t.format=o.formatArr(n.format),t.EXP_IF="",t.EXP_SPLIT="",lay.each(t.format,function(e,n){var a=new RegExp(D).test(n)?"\\d{"+function(){return new RegExp(D).test(t.format[0===e?e+1:e-1]||"")?/^yyyy|y$/.test(n)?4:n.length:/^yyyy$/.test(n)?"1,4":/^y$/.test(n)?"1,308":"1,2"}()+"}":"\\"+n;t.EXP_IF=t.EXP_IF+a,t.EXP_SPLIT=t.EXP_SPLIT+"("+a+")"}),t.EXP_IF_ONE=new RegExp("^"+t.EXP_IF+"$"),t.EXP_IF=new RegExp("^"+(n.range?t.EXP_IF+"\\s\\"+t.rangeStr+"\\s"+t.EXP_IF:t.EXP_IF)+"$"),t.EXP_SPLIT=new RegExp("^"+t.EXP_SPLIT+"$",""),t.isInput(n.elem[0])||"focus"===n.trigger&&(n.trigger="click"),n.elem.attr("lay-key")||(n.elem.attr("lay-key",t.index),n.eventElem.attr("lay-key",t.index)),n.mark=lay.extend({},n.calendar&&"cn"===n.lang?{"0-1-1":"\u5143\u65e6","0-2-14":"\u60c5\u4eba","0-3-8":"\u5987\u5973","0-3-12":"\u690d\u6811","0-4-1":"\u611a\u4eba","0-5-1":"\u52b3\u52a8","0-5-4":"\u9752\u5e74","0-6-1":"\u513f\u7ae5","0-9-10":"\u6559\u5e08","0-9-18":"\u56fd\u803b","0-10-1":"\u56fd\u5e86","0-12-25":"\u5723\u8bde"}:{},n.mark),lay.each(["min","max"],function(e,t){var a=[],r=[];if("number"==typeof n[t]){var i=n[t],o=(new Date).getTime(),l=864e5,s=new Date(i?i0)return!0;var t=lay.elem("div",{"class":"layui-laydate-header"}),r=[function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-prev-y"});return e.innerHTML="",e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-prev-m"});return e.innerHTML="",e}(),function(){var e=lay.elem("div",{"class":"laydate-set-ym"}),t=lay.elem("span"),n=lay.elem("span");return e.appendChild(t),e.appendChild(n),e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-next-m"});return e.innerHTML="",e}(),function(){var e=lay.elem("i",{"class":"layui-icon laydate-icon laydate-next-y"});return e.innerHTML="",e}()],i=lay.elem("div",{"class":"layui-laydate-content"}),o=lay.elem("table"),y=lay.elem("thead"),d=lay.elem("tr");lay.each(r,function(e,n){t.appendChild(n)}),y.appendChild(d),lay.each(new Array(6),function(e){var t=o.insertRow(0);lay.each(new Array(7),function(n){if(0===e){var r=lay.elem("th");r.innerHTML=a.weeks[n],d.appendChild(r)}t.insertCell(n)})}),o.insertBefore(y,o.children[0]),i.appendChild(o),l[e]=lay.elem("div",{"class":"layui-laydate-main laydate-main-list-"+e}),l[e].appendChild(t),l[e].appendChild(i),s.push(r),c.push(i),u.push(o)}),lay(y).html(function(){var e=[],t=[];return"datetime"===n.type&&e.push(''+a.timeTips+""),(n.range||"datetime"!==n.type)&&e.push(''),lay.each(n.btns,function(e,i){var o=a.tools[i]||"btn";n.range&&"now"===i||(r&&"clear"===i&&(o="cn"===n.lang?"\u91cd\u7f6e":"Reset"),t.push(''+o+""))}),e.push('"),e.join("")}()),lay.each(l,function(e,t){o.appendChild(t)}),n.showBottom&&o.appendChild(y),/^#/.test(n.theme)){var m=lay.elem("style"),f=["#{{id}} .layui-laydate-header{background-color:{{theme}};}","#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g,e.elemID).replace(/{{theme}}/g,n.theme);"styleSheet"in m?(m.setAttribute("type","text/css"),m.styleSheet.cssText=f):m.innerHTML=f,lay(o).addClass("laydate-theme-molv"),o.appendChild(m)}i.thisId=n.id,e.remove(w.thisElemDate),r?n.elem.append(o):(t.body.appendChild(o),e.position()),e.checkDate().calendar(null,0,"init"),e.changeEvent(),w.thisElemDate=e.elemID,"function"==typeof n.ready&&n.ready(lay.extend({},n.dateTime,{month:n.dateTime.month+1})),e.preview()},w.prototype.remove=function(e){var t=this,n=(t.config,lay("#"+(e||t.elemID)));return n[0]?(n.hasClass(d)||t.checkDate(function(){n.remove()}),t):t},w.prototype.position=function(){var e=this,t=e.config;return lay.position(e.bindElem||t.elem[0],e.elem,{position:t.position}),e},w.prototype.hint=function(e){var t=this,n=(t.config,lay.elem("div",{"class":f}));t.elem&&(n.innerHTML=e||"",lay(t.elem).find("."+f).remove(),t.elem.appendChild(n),clearTimeout(t.hinTimer),t.hinTimer=setTimeout(function(){lay(t.elem).find("."+f).remove()},3e3))},w.prototype.getAsYM=function(e,t,n){return n?t--:t++,t<0&&(t=11,e--),t>11&&(t=0,e++),[e,t]},w.prototype.systemDate=function(e){var t=e||new Date;return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),hours:e?e.getHours():0,minutes:e?e.getMinutes():0,seconds:e?e.getSeconds():0}},w.prototype.checkDate=function(e){var t,n,a=this,r=(new Date,a.config),o=a.lang(),l=r.dateTime=r.dateTime||a.systemDate(),s=a.bindElem||r.elem[0],c=(a.isInput(s)?"val":"html",function(){if(a.rangeElem){var e=[a.rangeElem[0].val(),a.rangeElem[1].val()];if(e[0]&&e[1])return e.join(" "+a.rangeStr+" ")}return a.isInput(s)?s.value:"static"===r.position?"":lay(s).attr("lay-date")}()),u=function(e){e.year>y[1]&&(e.year=y[1],n=!0),e.month>11&&(e.month=11,n=!0),e.hours>23&&(e.hours=0,n=!0),e.minutes>59&&(e.minutes=0,e.hours++,n=!0),e.seconds>59&&(e.seconds=0,e.minutes++,n=!0),t=i.getEndDate(e.month+1,e.year),e.date>t&&(e.date=t,n=!0)},d=function(e,t,i){var o=["startTime","endTime"];t=(t.match(a.EXP_SPLIT)||[]).slice(1),i=i||0,r.range&&(a[o[i]]=a[o[i]]||{}),lay.each(a.format,function(l,s){var c=parseFloat(t[l]);t[l].lengthf(r.max)||f(l)f(r.max))&&(a.endDate=lay.extend({},r.max)),e&&e(),a},w.prototype.mark=function(e,t){var n,a=this,r=a.config;return lay.each(r.mark,function(e,a){var r=e.split("-");r[0]!=t[0]&&0!=r[0]||r[1]!=t[1]&&0!=r[1]||r[2]!=t[2]||(n=a||t[2])}),n&&e.html(''+n+""),a},w.prototype.limit=function(e,t,n,a){var r,i=this,o=i.config,l={},s=o[n>41?"endDate":"dateTime"],c=lay.extend({},s,t||{});return lay.each({now:c,min:o.min,max:o.max},function(e,t){l[e]=i.newDate(lay.extend({year:t.year,month:t.month,date:t.date},function(){var e={};return lay.each(a,function(n,a){e[a]=t[a]}),e}())).getTime()}),r=l.nowl.max,e&&e[r?"addClass":"removeClass"](u),r},w.prototype.thisDateTime=function(e){var t=this,n=t.config;return e?t.endDate:n.dateTime},w.prototype.calendar=function(e,t,n){var a,r,o,l=this,s=l.config,t=t?1:0,u=e||l.thisDateTime(t),d=new Date,m=l.lang(),f="date"!==s.type&&"datetime"!==s.type,h=lay(l.table[t]).find("td"),g=lay(l.elemHeader[t][2]).find("span");return u.yeary[1]&&(u.year=y[1],l.hint(m.invalidDate)),l.firstDate||(l.firstDate=lay.extend({},u)),d.setFullYear(u.year,u.month,1),a=d.getDay(),r=i.getEndDate(u.month||12,u.year),o=i.getEndDate(u.month+1,u.year),lay.each(h,function(e,t){var n=[u.year,u.month],i=0;t=lay(t),t.removeAttr("class"),e=a&&e=n.firstDate.year&&(i.month=a.max.month,i.date=a.max.date),n.limit(lay(r),i,t),E++}),lay(y[h?0:1]).attr("lay-ym",E-8+"-"+w[1]).html(x+T+" - "+(E-1+T))}else if("month"===e)lay.each(new Array(12),function(e){var r=lay.elem("li",{"lay-ym":e}),o={year:w[0],month:e};e+1==w[1]&&lay(r).addClass(c),r.innerHTML=i.month[e]+(h?"\u6708":""),l.appendChild(r),w[0]=n.firstDate.year&&(o.date=a.max.date),n.limit(lay(r),o,t)}),lay(y[h?0:1]).attr("lay-ym",w[0]+"-"+w[1]).html(w[0]+T);else if("time"===e){var C=function(){lay(l).find("ol").each(function(e,a){lay(a).find("li").each(function(a,r){n.limit(lay(r),[{hours:a},{hours:n[b].hours,minutes:a},{hours:n[b].hours,minutes:n[b].minutes,seconds:a}][e],t,[["hours"],["hours","minutes"],["hours","minutes","seconds"]][e])})}),a.range||n.limit(lay(n.footer).find(p),n[b],0,["hours","minutes","seconds"])};a.range?n[b]||(n[b]="startTime"===b?r:n.endDate):n[b]=r,lay.each([24,60,60],function(e,t){var a=lay.elem("li"),r=["

"+i.time[e]+"

    "];lay.each(new Array(t),function(t){r.push(""+lay.digit(t,2)+"")}),a.innerHTML=r.join("")+"
",l.appendChild(a)}),C()}if(f&&d.removeChild(f),d.appendChild(l),"year"===e||"month"===e)lay(n.elemMain[t]).addClass("laydate-ym-show"),lay(l).find("li").on("click",function(){var i=0|lay(this).attr("lay-ym");if(!lay(this).hasClass(u)){0===t?(r[e]=i,n.limit(lay(n.footer).find(p),null,0)):n.endDate[e]=i;var s="year"===a.type||"month"===a.type;s?(lay(l).find("."+c).removeClass(c),lay(this).addClass(c),"month"===a.type&&"year"===e&&(n.listYM[t][0]=i,o&&((t?n.endDate:r).year=i),n.list("month",t))):(n.checkDate("limit").calendar(null,t),n.closeList()),n.setBtnStatus(),a.range||("month"===a.type&&"month"===e||"year"===a.type&&"year"===e)&&n.setValue(n.parse()).remove().done(),n.done(null,"change"),lay(n.footer).find("."+v).removeClass(u)}});else{var M=lay.elem("span",{"class":g}),S=function(){lay(l).find("ol").each(function(e){var t=this,a=lay(t).find("li");t.scrollTop=30*(n[b][D[e]]-2),t.scrollTop<=0&&a.each(function(e,n){if(!lay(this).hasClass(u))return t.scrollTop=30*(e-2),!0})})},k=lay(s[2]).find("."+g);S(),M.innerHTML=a.range?[i.startTime,i.endTime][t]:i.timeTips,lay(n.elemMain[t]).addClass("laydate-time-show"),k[0]&&k.remove(),s[2].appendChild(M),lay(l).find("ol").each(function(e){var t=this;lay(t).find("li").on("click",function(){var i=0|this.innerHTML;lay(this).hasClass(u)||(a.range?n[b][D[e]]=i:r[D[e]]=i,lay(t).find("."+c).removeClass(c),lay(this).addClass(c),C(),S(),(n.endDate||"time"===a.type)&&n.done(null,"change"),n.setBtnStatus())})})}return n},w.prototype.listYM=[],w.prototype.closeList=function(){var e=this;e.config;lay.each(e.elemCont,function(t,n){lay(this).find("."+m).remove(),lay(e.elemMain[t]).removeClass("laydate-ym-show laydate-time-show")}),lay(e.elem).find("."+g).remove()},w.prototype.setBtnStatus=function(e,t,n){var a,r=this,i=r.config,o=r.lang(),l=lay(r.footer).find(p);i.range&&"time"!==i.type&&(t=t||i.dateTime,n=n||r.endDate,a=r.newDate(t).getTime()>r.newDate(n).getTime(),r.limit(null,t)||r.limit(null,n)?l.addClass(u):l[a?"addClass":"removeClass"](u),e&&a&&r.hint("string"==typeof e?o.timeout.replace(/\u65e5\u671f/g,e):o.timeout))},w.prototype.parse=function(e,t){var n=this,a=n.config,r=t||("end"==e?lay.extend({},n.endDate,n.endTime):a.range?lay.extend({},a.dateTime,n.startTime):a.dateTime),o=i.parse(r,n.format,1);return a.range&&void 0===e?o+" "+n.rangeStr+" "+n.parse("end"):o},w.prototype.newDate=function(e){return e=e||{},new Date(e.year||1,e.month||0,e.date||1,e.hours||0,e.minutes||0,e.seconds||0)},w.prototype.setValue=function(e){var t=this,n=t.config,a=t.bindElem||n.elem[0];return"static"===n.position?t:(e=e||"",t.isInput(a)?lay(a).val(e):t.rangeElem?(t.rangeElem[0].val(e?t.parse("start"):""),t.rangeElem[1].val(e?t.parse("end"):"")):(0===lay(a).find("*").length&&lay(a).html(e),lay(a).attr("lay-date",e)),t)},w.prototype.preview=function(){var e=this,t=e.config;if(t.isPreview){var n=lay(e.elem).find("."+T),a=t.range?e.endDate?e.parse():"":e.parse();n.html(a).css({color:"#5FB878","font-size":"14px;"}),setTimeout(function(){ +n.css({color:"#666","font-size":"12px;"})},300)}},w.prototype.done=function(e,t){var n=this,a=n.config,r=lay.extend({},lay.extend(a.dateTime,n.startTime)),i=lay.extend({},lay.extend(n.endDate,n.endTime));return lay.each([r,i],function(e,t){"month"in t&&lay.extend(t,{month:t.month+1})}),n.preview(),e=e||[n.parse(),r,i],"function"==typeof a[t||"done"]&&a[t||"done"].apply(a,e),n},w.prototype.choose=function(e,t){var n=this,a=n.config,r=n.thisDateTime(t),i=(lay(n.elem).find("td"),e.attr("lay-ymd").split("-"));i={year:0|i[0],month:(0|i[1])-1,date:0|i[2]},e.hasClass(u)||(lay.extend(r,i),a.range?(lay.each(["startTime","endTime"],function(e,t){n[t]=n[t]||{hours:0,minutes:0,seconds:0}}),n.calendar(null,t).done(null,"change")):"static"===a.position?n.calendar().done().done(null,"change"):"date"===a.type?n.setValue(n.parse()).remove().done():"datetime"===a.type&&n.calendar().done(null,"change"))},w.prototype.tool=function(e,t){var n=this,a=n.config,r=n.lang(),i=a.dateTime,o="static"===a.position,l={datetime:function(){lay(e).hasClass(u)||(n.list("time",0),a.range&&n.list("time",1),lay(e).attr("lay-type","date").html(n.lang().dateTips))},date:function(){n.closeList(),lay(e).attr("lay-type","datetime").html(n.lang().timeTips)},clear:function(){o&&(lay.extend(i,n.firstDate),n.calendar()),a.range&&(delete a.dateTime,delete n.endDate,delete n.startTime,delete n.endTime),n.setValue("").remove(),n.done(["",{},{}])},now:function(){var e=new Date;lay.extend(i,n.systemDate(),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()}),n.setValue(n.parse()).remove(),o&&n.calendar(),n.done()},confirm:function(){if(a.range){if(lay(e).hasClass(u))return n.hint("time"===a.type?r.timeout.replace(/\u65e5\u671f/g,"\u65f6\u95f4"):r.timeout)}else if(lay(e).hasClass(u))return n.hint(r.invalidDate);n.done(),n.setValue(n.parse()).remove()}};l[t]&&l[t]()},w.prototype.change=function(e){var t=this,n=t.config,a=t.thisDateTime(e),r=n.range&&("year"===n.type||"month"===n.type),i=t.elemCont[e||0],o=t.listYM[e],l=function(l){var s=lay(i).find(".laydate-year-list")[0],c=lay(i).find(".laydate-month-list")[0];return s&&(o[0]=l?o[0]-15:o[0]+15,t.list("year",e)),c&&(l?o[0]--:o[0]++,t.list("month",e)),(s||c)&&(lay.extend(a,{year:o[0]}),r&&(a.year=o[0]),n.range||t.done(null,"change"),n.range||t.limit(lay(t.footer).find(p),{year:o[0]})),t.setBtnStatus(),s||c};return{prevYear:function(){l("sub")||(a.year--,t.checkDate("limit").calendar(null,e),t.done(null,"change"))},prevMonth:function(){var n=t.getAsYM(a.year,a.month,"sub");lay.extend(a,{year:n[0],month:n[1]}),t.checkDate("limit").calendar(null,e),t.done(null,"change")},nextMonth:function(){var n=t.getAsYM(a.year,a.month);lay.extend(a,{year:n[0],month:n[1]}),t.checkDate("limit").calendar(null,e),t.done(null,"change")},nextYear:function(){l()||(a.year++,t.checkDate("limit").calendar(null,e),t.done(null,"change"))}}},w.prototype.changeEvent=function(){var e=this;e.config;lay(e.elem).on("click",function(e){lay.stope(e)}).on("mousedown",function(e){lay.stope(e)}),lay.each(e.elemHeader,function(t,n){lay(n[0]).on("click",function(n){e.change(t).prevYear()}),lay(n[1]).on("click",function(n){e.change(t).prevMonth()}),lay(n[2]).find("span").on("click",function(n){var a=lay(this),r=a.attr("lay-ym"),i=a.attr("lay-type");r&&(r=r.split("-"),e.listYM[t]=[0|r[0],0|r[1]],e.list(i,t),lay(e.footer).find("."+v).addClass(u))}),lay(n[3]).on("click",function(n){e.change(t).nextMonth()}),lay(n[4]).on("click",function(n){e.change(t).nextYear()})}),lay.each(e.table,function(t,n){var a=lay(n).find("td");a.on("click",function(){e.choose(lay(this),t)})}),lay(e.footer).find("span").on("click",function(){var t=lay(this).attr("lay-type");e.tool(this,t)})},w.prototype.isInput=function(e){return/input|textarea/.test(e.tagName.toLocaleLowerCase())},w.prototype.events=function(){var e=this,t=e.config,n=function(n,a){n.on(t.trigger,function(){a&&(e.bindElem=this),e.render()})};t.elem[0]&&!t.elem[0].eventHandler&&(n(t.elem,"bind"),n(t.eventElem),t.elem[0].eventHandler=!0)},o.that={},o.getThis=function(e){var t=o.that[e];return t||hint.error(e?l+" instance with ID '"+e+"' not found":"ID argument required"),t},a.run=function(n){n(t).on("mousedown",function(e){if(i.thisId){var t=o.getThis(i.thisId);if(t){var a=t.config;e.target!==a.elem[0]&&e.target!==a.eventElem[0]&&e.target!==n(a.closeStop)[0]&&t.remove()}}}).on("keydown",function(e){if(i.thisId){var t=o.getThis(i.thisId);t&&13===e.keyCode&&n("#"+t.elemID)[0]&&t.elemID===w.thisElemDate&&(e.preventDefault(),n(t.footer).find(p)[0].click())}}),n(e).on("resize",function(){if(i.thisId){var e=o.getThis(i.thisId);if(e)return!(!e.elem||!n(s)[0])&&void e.position()}})},i.render=function(e){var t=new w(e);return o.call(t)},i.parse=function(e,t,n){return e=e||{},"string"==typeof t&&(t=o.formatArr(t)),t=(t||[]).concat(),lay.each(t,function(a,r){/yyyy|y/.test(r)?t[a]=lay.digit(e.year,r.length):/MM|M/.test(r)?t[a]=lay.digit(e.month+(n||0),r.length):/dd|d/.test(r)?t[a]=lay.digit(e.date,r.length):/HH|H/.test(r)?t[a]=lay.digit(e.hours,r.length):/mm|m/.test(r)?t[a]=lay.digit(e.minutes,r.length):/ss|s/.test(r)&&(t[a]=lay.digit(e.seconds,r.length))}),t.join("")},i.getEndDate=function(e,t){var n=new Date;return n.setFullYear(t||n.getFullYear(),e||n.getMonth()+1,1),new Date(n.getTime()-864e5).getDate()},n?(i.ready(),layui.define("lay",function(e){i.path=layui.cache.dir,a.run(lay),e(l,i)})):"function"==typeof define&&define.amd?define(function(){return a.run(lay),i}):function(){i.ready(),a.run(e.lay),e.laydate=i}()}(window,window.document); \ No newline at end of file diff --git a/dist/theme/default/font/iconfont.eot b/dist/theme/default/font/iconfont.eot new file mode 100644 index 0000000..c861caa Binary files /dev/null and b/dist/theme/default/font/iconfont.eot differ diff --git a/dist/theme/default/font/iconfont.svg b/dist/theme/default/font/iconfont.svg new file mode 100644 index 0000000..1e04218 --- /dev/null +++ b/dist/theme/default/font/iconfont.svg @@ -0,0 +1,45 @@ + + + + + +Created by iconfont + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dist/theme/default/font/iconfont.ttf b/dist/theme/default/font/iconfont.ttf new file mode 100644 index 0000000..0bd6c4a Binary files /dev/null and b/dist/theme/default/font/iconfont.ttf differ diff --git a/dist/theme/default/font/iconfont.woff b/dist/theme/default/font/iconfont.woff new file mode 100644 index 0000000..bfe5599 Binary files /dev/null and b/dist/theme/default/font/iconfont.woff differ diff --git a/dist/theme/default/laydate.css b/dist/theme/default/laydate.css new file mode 100644 index 0000000..507b007 --- /dev/null +++ b/dist/theme/default/laydate.css @@ -0,0 +1 @@ +.laydate-set-ym,.layui-laydate,.layui-laydate *,.layui-laydate-list{box-sizing:border-box}@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}html #layuicss-laydate{display:none;position:absolute;width:1989px}.layui-laydate *{margin:0;padding:0}.layui-laydate{position:absolute;z-index:66666666;margin:5px 0;border-radius:2px;font-size:14px;-webkit-animation-duration:.2s;animation-duration:.2s;-webkit-animation-fill-mode:both;animation-fill-mode:both;animation-name:laydate-downbit}.layui-laydate-main{width:272px}.layui-laydate-content td,.layui-laydate-header *,.layui-laydate-list li{transition-duration:.3s;-webkit-transition-duration:.3s}@keyframes laydate-downbit{0%{opacity:.3;transform:translate3d(0,-5px,0)}100%{opacity:1;transform:translate3d(0,0,0)}}.layui-laydate-static{position:relative;z-index:0;display:inline-block;margin:0;-webkit-animation:none;animation:none}.laydate-ym-show .laydate-next-m,.laydate-ym-show .laydate-prev-m{display:none!important}.laydate-ym-show .laydate-next-y,.laydate-ym-show .laydate-prev-y{display:inline-block!important}.laydate-time-show .laydate-set-ym span[lay-type=month],.laydate-time-show .laydate-set-ym span[lay-type=year],.laydate-time-show .layui-laydate-header .layui-icon,.laydate-ym-show .laydate-set-ym span[lay-type=month]{display:none!important}.layui-laydate-header{position:relative;line-height:30px;padding:10px 70px 5px}.layui-laydate-header *{display:inline-block;vertical-align:bottom}.layui-laydate-header i{position:absolute;top:10px;padding:0 5px;color:#999;font-size:18px;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;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.laydate-set-ym span{padding:0 10px;cursor:pointer}.laydate-time-text{cursor:default!important}.layui-laydate-content{position:relative;padding:10px;-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 td,.layui-laydate-content th{width:36px;height:30px;padding:5px;text-align:center}.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:46px;line-height:26px;padding:10px}.layui-laydate-footer span{display:inline-block;vertical-align:top;height:26px;line-height:24px;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-list>li,.layui-laydate-range .layui-laydate-main{display:inline-block;vertical-align:middle}.layui-laydate-footer span:hover{color:#5FB878}.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:10px;top:10px}.laydate-footer-btns span{margin:0 0 0 -1px}.layui-laydate-list{position:absolute;left:0;top:0;width:100%;height:100%;padding:10px;background-color:#fff}.layui-laydate-list>li{position:relative;width:33.3%;height:36px;line-height:36px;margin:3px 0;text-align:center;cursor:pointer}.laydate-month-list>li{width:25%;margin:17px 0}.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:33px;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}.layui-laydate-range{width:546px}.layui-laydate-range .laydate-main-list-1 .layui-laydate-content,.layui-laydate-range .laydate-main-list-1 .layui-laydate-header{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:#5FB878}.layui-laydate-content{border-top:none 0;border-bottom:none 0}.layui-laydate-content th{font-weight:400;color:#333}.layui-laydate-content td{color:#666}.layui-laydate-content td.laydate-selected{background-color:#B5FFF8}.laydate-selected:hover{background-color:#00F7DE!important}.layui-laydate-content td:hover,.layui-laydate-list li:hover{background-color:#eee;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:0 0}.layui-laydate-content .laydate-day-next,.layui-laydate-content .laydate-day-prev{color:#d2d2d2}.laydate-selected.laydate-day-next,.laydate-selected.laydate-day-prev{background-color:#f8f8f8!important}.layui-laydate-footer{border-top:1px solid #e2e2e2}.layui-laydate-hint{color:#FF5722}.laydate-day-mark::after{background-color:#5FB878}.layui-laydate-content td.layui-this .laydate-day-mark::after{display:none}.layui-laydate-footer span[lay-type=date]{color:#5FB878}.layui-laydate .layui-this{background-color:#009688!important;color:#fff!important}.layui-laydate .laydate-disabled,.layui-laydate .laydate-disabled:hover{background:0 0!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-grid .laydate-month-list>li,.laydate-theme-grid .laydate-year-list>li,.laydate-theme-grid .layui-laydate-content td,.laydate-theme-grid .layui-laydate-content thead,.laydate-theme-molv .layui-laydate-footer{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-next,.laydate-theme-grid .laydate-selected.laydate-day-prev{color:#d2d2d2!important}.laydate-theme-grid .laydate-month-list,.laydate-theme-grid .laydate-year-list{margin:1px 0 0 1px}.laydate-theme-grid .laydate-month-list>li,.laydate-theme-grid .laydate-year-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} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..7eea768 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,72 @@ + +/*! + * laydate build + */ + +var pkg = require('./package.json'); + +var gulp = require('gulp'); +var uglify = require('gulp-uglify'); +var minify = require('gulp-minify-css'); +var rename = require('gulp-rename'); +var header = require('gulp-header'); +var del = require('del'); + +//发行版本目录 +var releaseDir = './release/zip/layDate-v' + pkg.version; +var release = releaseDir + '/laydate'; + +var task = { + laydate: function() { + gulp.src('./src/**/*.css') + .pipe(minify({ + compatibility: 'ie7' + })) + .pipe(gulp.dest('./dist')); + + return gulp.src('./src/laydate.js').pipe(uglify({ + output: { + ascii_only: true //escape Unicode characters in strings and regexps + } + })) + .pipe(header('/*! <%= pkg.realname %> v<%= pkg.version %> | <%= pkg.description %> | <%= pkg.license %> Licensed */\n ;', {pkg: pkg})) + .pipe(gulp.dest('./dist')); + + } + ,other: function(){ + gulp.src('./src/**/font/*').pipe(rename({})) + .pipe(gulp.dest('./dist')); + } +}; + + +gulp.task('clear', function(cb){ //清理 + return del(['./dist/*'], cb); +}); +gulp.task('laydate', task.minjs); //压缩PC版本 +gulp.task('other', task.other); //移动一些配件 + +//打包发行版 +gulp.task('clearZip', function(cb){ //清理 + return del(['./release/zip/layDate-v'+ pkg.version], cb); +}); +gulp.task('r', ['clearZip'], function(){ + gulp.src('./release/doc/**/*') + .pipe(gulp.dest(releaseDir)) + + return gulp.src('./dist/**/*') + .pipe(gulp.dest(releaseDir + '/laydate')) +}); + +//全部 +gulp.task('default', ['clear'], function(){ + for(var key in task){ + task[key](); + } +}); + + + + + + diff --git a/laydate.dev.js b/laydate.dev.js deleted file mode 100755 index 7af7992..0000000 --- a/laydate.dev.js +++ /dev/null @@ -1,932 +0,0 @@ -/** - - @Name : layDate v1.1 日期控件 - @Author: 贤心 - @Date: 2014-06-25 - @QQ群:176047195 - @Site:http://sentsin.com/layui/laydate - - */ - -;!function(win){ - -//全局配置,如果采用默认均不需要改动 -var config = { - path: '', //laydate所在路径 - skin: 'default', //初始化皮肤 - format: 'YYYY-MM-DD', //日期格式 - min: '1900-01-01 00:00:00', //最小日期 - max: '2099-12-31 23:59:59', //最大日期 - isv: false, - init: true -}; - -var Dates = {}, doc = document, creat = 'createElement', byid = 'getElementById', tags = 'getElementsByTagName'; -var as = ['laydate_box', 'laydate_void', 'laydate_click', 'LayDateSkin', 'skins/', '/laydate.css']; - - -//主接口 -win.laydate = function(options){ - options = options || {}; - try{ - as.event = win.event ? win.event : laydate.caller.arguments[0]; - } catch(e){}; - Dates.run(options); - return laydate; -}; - -laydate.v = '1.1'; - -//获取组件存放路径 -Dates.getPath = (function(){ - var js = document.scripts, jsPath = js[js.length - 1].src; - return config.path ? config.path : jsPath.substring(0, jsPath.lastIndexOf("/") + 1); -}()); - -Dates.use = function(lib, id){ - var link = doc[creat]('link'); - link.type = 'text/css'; - link.rel = 'stylesheet'; - link.href = Dates.getPath + lib + as[5]; - id && (link.id = id); - doc[tags]('head')[0].appendChild(link); - link = null; -}; - -Dates.trim = function(str){ - str = str || ''; - return str.replace(/^\s|\s$/g, '').replace(/\s+/g, ' '); -}; - -//补齐数位 -Dates.digit = function(num){ - return num < 10 ? '0' + (num|0) : num; -}; - -Dates.stopmp = function(e){ - e = e || win.event; - e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; - return this; -}; - -Dates.each = function(arr, fn){ - var i = 0, len = arr.length; - for(; i < len; i++){ - if(fn(i, arr[i]) === false){ - break - } - } -}; - -Dates.hasClass = function(elem, cls){ - elem = elem || {}; - return new RegExp('\\b' + cls +'\\b').test(elem.className); -}; - -Dates.addClass = function(elem, cls){ - elem = elem || {}; - Dates.hasClass(elem, cls) || (elem.className += ' ' + cls); - elem.className = Dates.trim(elem.className); - return this; -}; - -Dates.removeClass = function(elem, cls) { - elem = elem || {}; - if (Dates.hasClass(elem, cls)) { - var reg = new RegExp('\\b' + cls +'\\b'); - elem.className = elem.className.replace(reg, ''); - } - return this; -}; - -//清除css属性 -Dates.removeCssAttr = function(elem, attr){ - var s = elem.style; - if(s.removeProperty){ - s.removeProperty(attr); - } else { - s.removeAttribute(attr); - } -}; - -//显示隐藏 -Dates.shde = function(elem, type){ - elem.style.display = type ? 'none' : 'block'; -}; - -//简易选择器 -Dates.query = function(node){ - if(node && node.nodeType === 1){ - if(node.tagName.toLowerCase() !== 'input'){ - throw new Error('选择器elem错误'); - } - return node; - } - - var node = (Dates.trim(node)).split(' '), elemId = doc[byid](node[0].substr(1)), arr; - if(!elemId){ - return; - } else if(!node[1]){ - return elemId; - } else if(/^\./.test(node[1])){ - var find, child = node[1].substr(1), exp = new RegExp('\\b' + child +'\\b'); - arr = [] - find = doc.getElementsByClassName ? elemId.getElementsByClassName(child) : elemId[tags]('*'); - Dates.each(find, function(ii, that){ - exp.test(that.className) && arr.push(that); - }); - return arr[0] ? arr : ''; - } else { - arr = elemId[tags](node[1]); - return arr[0] ? elemId[tags](node[1]) : ''; - } -}; - -//事件监听器 -Dates.on = function(elem, even, fn){ - elem.attachEvent ? elem.attachEvent('on'+ even, function(){ - fn.call(elem, win.even); - }) : elem.addEventListener(even, fn, false); - return Dates; -}; - -//阻断mouseup -Dates.stopMosup = function(evt, elem){ - if(evt !== 'mouseup'){ - Dates.on(elem, 'mouseup', function(ev){ - Dates.stopmp(ev); - }); - } -}; - -Dates.run = function(options){ - var S = Dates.query, elem, devt, even = as.event, target; - try { - target = even.target || even.srcElement || {}; - } catch(e){ - target = {}; - } - elem = options.elem ? S(options.elem) : target; - - as.elemv = /textarea|input/.test(elem.tagName.toLocaleLowerCase()) ? 'value' : 'innerHTML'; - if (('init' in options ? options.init : config.init) && (!elem[as.elemv])) elem[as.elemv] = laydate.now(null, options.format || config.format); - - if(even && target.tagName){ - if(!elem || elem === Dates.elem){ - return; - } - Dates.stopMosup(even.type, elem); - Dates.stopmp(even); - Dates.view(elem, options); - Dates.reshow(); - } else { - devt = options.event || 'click'; - Dates.each((elem.length|0) > 0 ? elem : [elem], function(ii, that){ - Dates.stopMosup(devt, that); - Dates.on(that, devt, function(ev){ - Dates.stopmp(ev); - if(that !== Dates.elem){ - Dates.view(that, options); - Dates.reshow(); - } - }); - }); - } - - chgSkin(options.skin || config.skin) -}; - -Dates.scroll = function(type){ - type = type ? 'scrollLeft' : 'scrollTop'; - return doc.body[type] | doc.documentElement[type]; -}; - -Dates.winarea = function(type){ - return document.documentElement[type ? 'clientWidth' : 'clientHeight'] -}; - -//判断闰年 -Dates.isleap = function(year){ - return (year%4 === 0 && year%100 !== 0) || year%400 === 0; -}; - -//检测是否在有效期 -Dates.checkVoid = function(YY, MM, DD){ - var back = []; - YY = YY|0; - MM = MM|0; - DD = DD|0; - if(YY < Dates.mins[0]){ - back = ['y']; - } else if(YY > Dates.maxs[0]){ - back = ['y', 1]; - } else if(YY >= Dates.mins[0] && YY <= Dates.maxs[0]){ - if(YY == Dates.mins[0]){ - if(MM < Dates.mins[1]){ - back = ['m']; - } else if(MM == Dates.mins[1]){ - if(DD < Dates.mins[2]){ - back = ['d']; - } - } - } - if(YY == Dates.maxs[0]){ - if(MM > Dates.maxs[1]){ - back = ['m', 1]; - } else if(MM == Dates.maxs[1]){ - if(DD > Dates.maxs[2]){ - back = ['d', 1]; - } - } - } - } - return back; -}; - -//时分秒的有效检测 -Dates.timeVoid = function(times, index){ - if(Dates.ymd[1]+1 == Dates.mins[1] && Dates.ymd[2] == Dates.mins[2]){ - if(index === 0 && (times < Dates.mins[3])){ - return 1; - } else if(index === 1 && times < Dates.mins[4]){ - return 1; - } else if(index === 2 && times < Dates.mins[5]){ - return 1; - } - } else if(Dates.ymd[1]+1 == Dates.maxs[1] && Dates.ymd[2] == Dates.maxs[2]){ - if(index === 0 && times > Dates.maxs[3]){ - return 1; - } else if(index === 1 && times > Dates.maxs[4]){ - return 1; - } else if(index === 2 && times > Dates.maxs[5]){ - return 1; - } - } - if(times > (index ? 59 : 23)){ - return 1; - } -}; - -//检测日期是否合法 -Dates.check = function(){ - var reg = Dates.options.format.replace(/YYYY|MM|DD|hh|mm|ss/g,'\\d+\\').replace(/\\$/g, ''); - var exp = new RegExp(reg), value = Dates.elem[as.elemv]; - var arr = value.match(/\d+/g) || [], isvoid = Dates.checkVoid(arr[0], arr[1], arr[2]); - if(value.replace(/\s/g, '') !== ''){ - if(!exp.test(value)){ - Dates.elem[as.elemv] = ''; - Dates.msg('日期不符合格式,请重新选择。'); - return 1; - } else if(isvoid[0]){ - Dates.elem[as.elemv] = ''; - Dates.msg('日期不在有效期内,请重新选择。'); - return 1; - } else { - isvoid.value = Dates.elem[as.elemv].match(exp).join(); - arr = isvoid.value.match(/\d+/g); - if(arr[1] < 1){ - arr[1] = 1; - isvoid.auto = 1; - } else if(arr[1] > 12){ - arr[1] = 12; - isvoid.auto = 1; - } else if(arr[1].length < 2){ - isvoid.auto = 1; - } - if(arr[2] < 1){ - arr[2] = 1; - isvoid.auto = 1; - } else if(arr[2] > Dates.months[(arr[1]|0)-1]){ - arr[2] = 31; - isvoid.auto = 1; - } else if(arr[2].length < 2){ - isvoid.auto = 1; - } - if(arr.length > 3){ - if(Dates.timeVoid(arr[3], 0)){ - isvoid.auto = 1; - }; - if(Dates.timeVoid(arr[4], 1)){ - isvoid.auto = 1; - }; - if(Dates.timeVoid(arr[5], 2)){ - isvoid.auto = 1; - }; - } - if(isvoid.auto){ - Dates.creation([arr[0], arr[1]|0, arr[2]|0], 1); - } else if(isvoid.value !== Dates.elem[as.elemv]){ - Dates.elem[as.elemv] = isvoid.value; - } - } - } -}; - -//生成日期 -Dates.months = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; -Dates.viewDate = function(Y, M, D){ - var S = Dates.query, log = {}, De = new Date(); - Y < (Dates.mins[0]|0) && (Y = (Dates.mins[0]|0)); - Y > (Dates.maxs[0]|0) && (Y = (Dates.maxs[0]|0)); - - De.setFullYear(Y, M, D); - log.ymd = [De.getFullYear(), De.getMonth(), De.getDate()]; - - Dates.months[1] = Dates.isleap(log.ymd[0]) ? 29 : 28; - - De.setFullYear(log.ymd[0], log.ymd[1], 1); - log.FDay = De.getDay(); - - log.PDay = Dates.months[M === 0 ? 11 : M - 1] - log.FDay + 1; - log.NDay = 1; - - //渲染日 - Dates.each(as.tds, function(i, elem){ - var YY = log.ymd[0], MM = log.ymd[1] + 1, DD; - elem.className = ''; - if(i < log.FDay){ - elem.innerHTML = DD = i + log.PDay; - Dates.addClass(elem, 'laydate_nothis'); - MM === 1 && (YY -= 1); - MM = MM === 1 ? 12 : MM - 1; - } else if(i >= log.FDay && i < log.FDay + Dates.months[log.ymd[1]]){ - elem.innerHTML = DD = i - log.FDay + 1; - if(i - log.FDay + 1 === log.ymd[2]){ - Dates.addClass(elem, as[2]); - log.thisDay = elem; - } - } else { - elem.innerHTML = DD = log.NDay++; - Dates.addClass(elem, 'laydate_nothis'); - MM === 12 && (YY += 1); - MM = MM === 12 ? 1 : MM + 1; - } - - if(Dates.checkVoid(YY, MM, DD)[0]){ - Dates.addClass(elem, as[1]); - } - - Dates.options.festival && Dates.festival(elem, MM + '.' + DD); - elem.setAttribute('y', YY); - elem.setAttribute('m', MM); - elem.setAttribute('d', DD); - YY = MM = DD = null; - }); - - Dates.valid = !Dates.hasClass(log.thisDay, as[1]); - Dates.ymd = log.ymd; - - //锁定年月 - as.year.value = Dates.ymd[0] + '年'; - as.month.value = Dates.digit(Dates.ymd[1] + 1) + '月'; - - //定位月 - Dates.each(as.mms, function(i, elem){ - var getCheck = Dates.checkVoid(Dates.ymd[0], (elem.getAttribute('m')|0) + 1); - if(getCheck[0] === 'y' || getCheck[0] === 'm'){ - Dates.addClass(elem, as[1]); - } else { - Dates.removeClass(elem, as[1]); - } - Dates.removeClass(elem, as[2]); - getCheck = null - }); - Dates.addClass(as.mms[Dates.ymd[1]], as[2]); - - //定位时分秒 - log.times = [ - Dates.inymd[Dates.elemIndexMap.hour]|0 || 0, - Dates.inymd[Dates.elemIndexMap.minute]|0 || 0, - Dates.inymd[Dates.elemIndexMap.second]|0 || 0 - ]; - Dates.each(new Array(3), function(i){ - Dates.hmsin[i].value = Dates.digit(Dates.timeVoid(log.times[i], i) ? Dates.mins[i+3]|0 : log.times[i]|0); - }); - - //确定按钮状态 - Dates[Dates.valid ? 'removeClass' : 'addClass'](as.ok, as[1]); -}; - -//节日 -Dates.festival = function(td, md){ - var str; - switch(md){ - case '1.1': - str = '元旦'; - break; - case '3.8': - str = '妇女'; - break; - case '4.5': - str = '清明'; - break; - case '5.1': - str = '劳动'; - break; - case '6.1': - str = '儿童'; - break; - case '9.10': - str = '教师'; - break; - case '10.1': - str = '国庆'; - break; - }; - str && (td.innerHTML = str); - str = null; -}; - -//生成年列表 -Dates.viewYears = function(YY){ - var S = Dates.query, str = ''; - Dates.each(new Array(14), function(i){ - if(i === 7) { - str += '
  • '+ YY +'年
  • '; - } else { - str += '
  • '+ (YY-7+i) +'年
  • '; - } - }); - S('#laydate_ys').innerHTML = str; - Dates.each(S('#laydate_ys li'), function(i, elem){ - if(Dates.checkVoid(elem.getAttribute('y'))[0] === 'y'){ - Dates.addClass(elem, as[1]); - } else { - Dates.on(elem, 'click', function(ev){ - Dates.stopmp(ev).reshow(); - Dates.viewDate(this.getAttribute('y')|0, Dates.ymd[1], Dates.ymd[2]); - }); - } - }); -}; - -Dates.getEachElementIndex = function(format) { - var components = {}; - var currentIndex = 0; - format.replace(/YYYY|MM|DD|hh|mm|ss/g, function(str, index){ - if (str === 'YYYY') { - components['year'] = currentIndex++; - } else if (str === 'MM') { - components['month'] = currentIndex++; - } else if (str === 'DD') { - components['day'] = currentIndex++; - } else if (str === 'hh') { - components['hour'] = currentIndex++; - } else if (str === 'mm') { - components['minute'] = currentIndex++; - } else if (str === 'ss') { - components['second'] = currentIndex++; - } - return ""; - }); - return components; -}; - -//初始化面板数据 -Dates.initDate = function(format){ - var S = Dates.query, log = {}, De = new Date(); - var ymd = Dates.elem[as.elemv].match(/\d+/g) || []; - var elemIndexMap = Dates.getEachElementIndex(format); - Dates.elemIndexMap = elemIndexMap; - if(ymd.length < 3){ - ymd = Dates.options.start.match(/\d+/g) || []; - if(ymd.length < 3){ - ymd = [De.getFullYear(), De.getMonth()+1, De.getDate()]; - } - } - Dates.inymd = ymd; - Dates.viewDate(ymd[elemIndexMap.year], ymd[elemIndexMap.month] - 1, ymd[elemIndexMap.day]); -}; - -//是否显示零件 -Dates.iswrite = function(){ - var S = Dates.query, log = { - time: S('#laydate_hms') - }; - Dates.shde(log.time, !Dates.options.istime); - Dates.shde(as.oclear, !('isclear' in Dates.options ? Dates.options.isclear : 1)); - Dates.shde(as.otoday, !('istoday' in Dates.options ? Dates.options.istoday : 1)); - Dates.shde(as.ok, !('issure' in Dates.options ? Dates.options.issure : 1)); -}; - -//方位辨别 -Dates.orien = function(obj, pos){ - var tops, rect = Dates.elem.getBoundingClientRect(); - obj.style.left = rect.left + (pos ? 0 : Dates.scroll(1)) + 'px'; - if(rect.bottom + obj.offsetHeight/1.5 <= Dates.winarea()){ - tops = rect.bottom - 1; - } else { - tops = rect.top > obj.offsetHeight/1.5 ? rect.top - obj.offsetHeight + 1 : Dates.winarea() - obj.offsetHeight; - } - obj.style.top = Math.max(tops + (pos ? 0 : Dates.scroll()),1) + 'px'; -}; - -//吸附定位 -Dates.follow = function(obj){ - if(Dates.options.fixed){ - obj.style.position = 'fixed'; - Dates.orien(obj, 1); - } else { - obj.style.position = 'absolute'; - Dates.orien(obj); - } -}; - -//生成表格 -Dates.viewtb = (function(){ - var tr, view = [], weeks = [ '日', '一', '二', '三', '四', '五', '六']; - var log = {}, table = doc[creat]('table'), thead = doc[creat]('thead'); - thead.appendChild(doc[creat]('tr')); - log.creath = function(i){ - var th = doc[creat]('th'); - th.innerHTML = weeks[i]; - thead[tags]('tr')[0].appendChild(th); - th = null; - }; - - Dates.each(new Array(6), function(i){ - view.push([]); - tr = table.insertRow(0); - Dates.each(new Array(7), function(j){ - view[i][j] = 0; - i === 0 && log.creath(j); - tr.insertCell(j); - }); - }); - - table.insertBefore(thead, table.children[0]); - table.id = table.className = 'laydate_table'; - tr = view = null; - return table.outerHTML.toLowerCase(); -}()); - -//渲染控件骨架 -Dates.view = function(elem, options){ - var S = Dates.query, div, log = {}; - options = options || elem; - - Dates.elem = elem; - Dates.options = options; - Dates.options.format || (Dates.options.format = config.format); - Dates.options.start = Dates.options.start || ''; - Dates.mm = log.mm = [Dates.options.min || config.min, Dates.options.max || config.max]; - Dates.mins = log.mm[0].match(/\d+/g); - Dates.maxs = log.mm[1].match(/\d+/g); - - if(!Dates.box){ - div = doc[creat]('div'); - div.id = as[0]; - div.className = as[0]; - div.style.cssText = 'position: absolute;'; - div.setAttribute('name', 'laydate-v'+ laydate.v); - - div.innerHTML = log.html = '
    ' - +'
    ' - +'' - +'' - +'' - +'
    ' - +'' - +'
      ' - +'' - +'
      ' - +'
      ' - +'
      ' - +'' - +'' - +'' - +'
      '+ function(){ - var str = ''; - Dates.each(new Array(12), function(i){ - str += ''+ Dates.digit(i+1) +'月'; - }); - return str; - }() +'
      ' - +'
      ' - +'
      ' - - + Dates.viewtb - - +'
      ' - +'
        ' - +'
      • 时间
      • ' - +'
      • :
      • ' - +'
      • :
      • ' - +'
      • ' - +'
      ' - +'
      ' - +'
      ' - +'清空' - +'今天' - +'确认' - +'
      ' - +(config.isv ? 'laydate-v'+ laydate.v +'' : '') - +'
      '; - doc.body.appendChild(div); - Dates.box = S('#'+as[0]); - Dates.events(); - div = null; - } else { - Dates.shde(Dates.box); - } - Dates.follow(Dates.box); - options.zIndex ? Dates.box.style.zIndex = options.zIndex : Dates.removeCssAttr(Dates.box, 'z-index'); - Dates.stopMosup('click', Dates.box); - - Dates.initDate(options.format); - Dates.iswrite(); - Dates.check(); -}; - -//隐藏内部弹出元素 -Dates.reshow = function(){ - Dates.each(Dates.query('#'+ as[0] +' .laydate_show'), function(i, elem){ - Dates.removeClass(elem, 'laydate_show'); - }); - return this; -}; - -//关闭控件 -Dates.close = function(){ - Dates.reshow(); - Dates.shde(Dates.query('#'+ as[0]), 1); - Dates.elem = null; -}; - -//转换日期格式 -Dates.parse = function(ymd, hms, format){ - ymd = ymd.concat(hms); // [year, month, day, hour, minute, second] - format = format || (Dates.options ? Dates.options.format : config.format); - return format.replace(/YYYY|MM|DD|hh|mm|ss/g, function(str, index){ - var pos = -1; - if (str === 'YYYY') { - pos = 0; - } else if (str === 'MM') { - pos = 1; - } else if (str === 'DD') { - pos = 2; - } else if (str === 'hh') { - pos = 3; - } else if (str === 'mm') { - pos = 4; - } else if (str === 'ss') { - pos = 5; - } - return Dates.digit(ymd[pos]); - }); -}; - -//返回最终日期 -Dates.creation = function(ymd, hide){ - var S = Dates.query, hms = Dates.hmsin; - var getDates = Dates.parse(ymd, [hms[0].value, hms[1].value, hms[2].value]); - Dates.elem[as.elemv] = getDates; - if(!hide){ - Dates.close(); - typeof Dates.options.choose === 'function' && Dates.options.choose(getDates); - } -}; - -//事件 -Dates.events = function(){ - var S = Dates.query, log = { - box: '#'+as[0] - }; - - Dates.addClass(doc.body, 'laydate_body'); - - as.tds = S('#laydate_table td'); - as.mms = S('#laydate_ms span'); - as.year = S('#laydate_y'); - as.month = S('#laydate_m'); - - //显示更多年月 - Dates.each(S(log.box + ' .laydate_ym'), function(i, elem){ - Dates.on(elem, 'click', function(ev){ - Dates.stopmp(ev).reshow(); - Dates.addClass(this[tags]('div')[0], 'laydate_show'); - if(!i){ - log.YY = parseInt(as.year.value); - Dates.viewYears(log.YY); - } - }); - }); - - Dates.on(S(log.box), 'click', function(){ - Dates.reshow(); - }); - - //切换年 - log.tabYear = function(type){ - if(type === 0){ - Dates.ymd[0]--; - } else if(type === 1) { - Dates.ymd[0]++; - } else if(type === 2) { - log.YY -= 14; - } else { - log.YY += 14; - } - if(type < 2){ - Dates.viewDate(Dates.ymd[0], Dates.ymd[1], Dates.ymd[2]); - Dates.reshow(); - } else { - Dates.viewYears(log.YY); - } - }; - Dates.each(S('#laydate_YY .laydate_tab'), function(i, elem){ - Dates.on(elem, 'click', function(ev){ - Dates.stopmp(ev); - log.tabYear(i); - }); - }); - - - //切换月 - log.tabMonth = function(type){ - if(type){ - Dates.ymd[1]++; - if(Dates.ymd[1] === 12){ - Dates.ymd[0]++; - Dates.ymd[1] = 0; - } - } else { - Dates.ymd[1]--; - if(Dates.ymd[1] === -1){ - Dates.ymd[0]--; - Dates.ymd[1] = 11; - } - } - Dates.viewDate(Dates.ymd[0], Dates.ymd[1], Dates.ymd[2]); - }; - Dates.each(S('#laydate_MM .laydate_tab'), function(i, elem){ - Dates.on(elem, 'click', function(ev){ - Dates.stopmp(ev).reshow(); - log.tabMonth(i); - }); - }); - - //选择月 - Dates.each(S('#laydate_ms span'), function(i, elem){ - Dates.on(elem, 'click', function(ev){ - Dates.stopmp(ev).reshow(); - if(!Dates.hasClass(this, as[1])){ - Dates.viewDate(Dates.ymd[0], this.getAttribute('m')|0, Dates.ymd[2]); - } - }); - }); - - //选择日 - Dates.each(S('#laydate_table td'), function(i, elem){ - Dates.on(elem, 'click', function(ev){ - if(!Dates.hasClass(this, as[1])){ - Dates.stopmp(ev); - if(Dates.options.istime){ - + Dates.viewDate([this.getAttribute('y')|0, (this.getAttribute('m')|0)-1, this.getAttribute('d')|0]); - + }else{ - + Dates.creation([this.getAttribute('y')|0, this.getAttribute('m')|0, this.getAttribute('d')|0]); - + } - } - }); - }); - - //清空 - as.oclear = S('#laydate_clear'); - Dates.on(as.oclear, 'click', function(){ - Dates.elem[as.elemv] = ''; - Dates.close(); - }); - - //今天 - as.otoday = S('#laydate_today'); - Dates.on(as.otoday, 'click', function(){ - var now = new Date(); - // 2016-09-23 18:20:54 修复选中今天choose方法得不到数据 - // Dates.creation([now.getFullYear(), now.getMonth() + 1, now.getDate()]); - - // 2016-09-26 10:49:25 修复选中今天 如果YYYY-MM-DD hh:mm:ss格式,获取当前的时分秒 - var hms = Dates.hmsin; - var date = new Date(); - // 获取当前时间小时 - hms[0].value = date.getHours(); - // 获取当前时间分钟 - hms[1].value = date.getMinutes(); - // 获取当前时间秒 - hms[2].value = date.getSeconds(); - Dates.creation([Dates.ymd[0], Dates.ymd[1]+1, Dates.ymd[2]]); - }); - - //确认 - as.ok = S('#laydate_ok'); - Dates.on(as.ok, 'click', function(){ - if(Dates.valid){ - Dates.creation([Dates.ymd[0], Dates.ymd[1]+1, Dates.ymd[2]]); - } - }); - - //选择时分秒 - log.times = S('#laydate_time'); - Dates.hmsin = log.hmsin = S('#laydate_hms input'); - log.hmss = ['小时', '分钟', '秒数']; - log.hmsarr = []; - - //生成时分秒或警告信息 - Dates.msg = function(i, title){ - var str = '
      '+ (title || '提示') +'×
      '; - if(typeof i === 'string'){ - str += '

      '+ i +'

      '; - Dates.shde(S('#'+as[0])); - Dates.removeClass(log.times, 'laydate_time1').addClass(log.times, 'laydate_msg'); - } else { - if(!log.hmsarr[i]){ - str += '
      '; - Dates.each(new Array(i === 0 ? 24 : 60), function(i){ - str += ''+ i +''; - }); - str += '
      ' - log.hmsarr[i] = str; - } else { - str = log.hmsarr[i]; - } - Dates.removeClass(log.times, 'laydate_msg'); - Dates[i=== 0 ? 'removeClass' : 'addClass'](log.times, 'laydate_time1'); - } - Dates.addClass(log.times, 'laydate_show'); - log.times.innerHTML = str; - }; - - log.hmson = function(input, index){ - var span = S('#laydate_hmsno span'), set = Dates.valid ? null : 1; - Dates.each(span, function(i, elem){ - if(set){ - Dates.addClass(elem, as[1]); - } else if(Dates.timeVoid(i, index)){ - Dates.addClass(elem, as[1]); - } else { - Dates.on(elem, 'click', function(ev){ - if(!Dates.hasClass(this, as[1])){ - input.value = Dates.digit(this.innerHTML|0); - } - }); - } - }); - Dates.addClass(span[input.value|0], 'laydate_click'); - }; - - //展开选择 - Dates.each(log.hmsin, function(i, elem){ - Dates.on(elem, 'click', function(ev){ - Dates.stopmp(ev).reshow(); - Dates.msg(i, log.hmss[i]); - log.hmson(this, i); - }); - }); - - Dates.on(doc, 'mouseup', function(){ - var box = S('#'+as[0]); - if(box && box.style.display !== 'none'){ - Dates.check() || Dates.close(); - } - }).on(doc, 'keydown', function(event){ - event = event || win.event; - var codes = event.keyCode; - - //如果在日期显示的时候按回车 - if(codes === 13 && Dates.elem){ - Dates.creation([Dates.ymd[0], Dates.ymd[1]+1, Dates.ymd[2]]); - } - }); -}; - -Dates.init = (function(){ - Dates.use('need'); - Dates.use(as[4] + config.skin, as[3]); - Dates.skinLink = Dates.query('#'+as[3]); -}()); - -//重置定位 -laydate.reset = function(){ - (Dates.box && Dates.elem) && Dates.follow(Dates.box); -}; - -//返回指定日期 -laydate.now = function(timestamp, format){ - var De = new Date((timestamp|0) ? function(tamp){ - return tamp < 86400000 ? (+new Date + tamp*86400000) : tamp; - }(parseInt(timestamp)) : +new Date); - return Dates.parse( - [De.getFullYear(), De.getMonth()+1, De.getDate()], - [De.getHours(), De.getMinutes(), De.getSeconds()], - format - ); -}; - -//皮肤选择 -laydate.skin = chgSkin; - -//内部函数 -function chgSkin(lib) { - Dates.skinLink.href = Dates.getPath + as[4] + lib + as[5]; -}; - -}(window); diff --git a/laydate.js b/laydate.js deleted file mode 100644 index 52ef670..0000000 --- a/laydate.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - - @Name : layDate v1.1 日期控件 - @Author: 贤心 - @Date: 2014-06-25 - @QQ群:176047195 - @Site:http://sentsin.com/layui/laydate - - */ - -;!function(a){var b={path:"",defSkin:"default",format:"YYYY-MM-DD",min:"1900-01-01 00:00:00",max:"2099-12-31 23:59:59",isv:!1},c={},d=document,e="createElement",f="getElementById",g="getElementsByTagName",h=["laydate_box","laydate_void","laydate_click","LayDateSkin","skins/","/laydate.css"];a.laydate=function(b){b=b||{};try{h.event=a.event?a.event:laydate.caller.arguments[0]}catch(d){}return c.run(b),laydate},laydate.v="1.1",c.getPath=function(){var a=document.scripts,c=a[a.length-1].src;return b.path?b.path:c.substring(0,c.lastIndexOf("/")+1)}(),c.use=function(a,b){var f=d[e]("link");f.type="text/css",f.rel="stylesheet",f.href=c.getPath+a+h[5],b&&(f.id=b),d[g]("head")[0].appendChild(f),f=null},c.trim=function(a){return a=a||"",a.replace(/^\s|\s$/g,"").replace(/\s+/g," ")},c.digit=function(a){return 10>a?"0"+(0|a):a},c.stopmp=function(b){return b=b||a.event,b.stopPropagation?b.stopPropagation():b.cancelBubble=!0,this},c.each=function(a,b){for(var c=0,d=a.length;d>c&&b(c,a[c])!==!1;c++);},c.hasClass=function(a,b){return a=a||{},new RegExp("\\b"+b+"\\b").test(a.className)},c.addClass=function(a,b){return a=a||{},c.hasClass(a,b)||(a.className+=" "+b),a.className=c.trim(a.className),this},c.removeClass=function(a,b){if(a=a||{},c.hasClass(a,b)){var d=new RegExp("\\b"+b+"\\b");a.className=a.className.replace(d,"")}return this},c.removeCssAttr=function(a,b){var c=a.style;c.removeProperty?c.removeProperty(b):c.removeAttribute(b)},c.shde=function(a,b){a.style.display=b?"none":"block"},c.query=function(a){var e,b,h,i,j;return a=c.trim(a).split(" "),b=d[f](a[0].substr(1)),b?a[1]?/^\./.test(a[1])?(i=a[1].substr(1),j=new RegExp("\\b"+i+"\\b"),e=[],h=d.getElementsByClassName?b.getElementsByClassName(i):b[g]("*"),c.each(h,function(a,b){j.test(b.className)&&e.push(b)}),e[0]?e:""):(e=b[g](a[1]),e[0]?b[g](a[1]):""):b:void 0},c.on=function(b,d,e){return b.attachEvent?b.attachEvent("on"+d,function(){e.call(b,a.even)}):b.addEventListener(d,e,!1),c},c.stopMosup=function(a,b){"mouseup"!==a&&c.on(b,"mouseup",function(a){c.stopmp(a)})},c.run=function(a){var d,e,g,b=c.query,f=h.event;try{g=f.target||f.srcElement||{}}catch(i){g={}}if(d=a.elem?b(a.elem):g,f&&g.tagName){if(!d||d===c.elem)return;c.stopMosup(f.type,d),c.stopmp(f),c.view(d,a),c.reshow()}else e=a.event||"click",c.each((0|d.length)>0?d:[d],function(b,d){c.stopMosup(e,d),c.on(d,e,function(b){c.stopmp(b),d!==c.elem&&(c.view(d,a),c.reshow())})})},c.scroll=function(a){return a=a?"scrollLeft":"scrollTop",d.body[a]|d.documentElement[a]},c.winarea=function(a){return document.documentElement[a?"clientWidth":"clientHeight"]},c.isleap=function(a){return 0===a%4&&0!==a%100||0===a%400},c.checkVoid=function(a,b,d){var e=[];return a=0|a,b=0|b,d=0|d,ac.maxs[0]?e=["y",1]:a>=c.mins[0]&&a<=c.maxs[0]&&(a==c.mins[0]&&(bc.maxs[1]?e=["m",1]:b==c.maxs[1]&&d>c.maxs[2]&&(e=["d",1]))),e},c.timeVoid=function(a,b){if(c.ymd[1]+1==c.mins[1]&&c.ymd[2]==c.mins[2]){if(0===b&&ac.maxs[3])return 1;if(1===b&&a>c.maxs[4])return 1;if(2===b&&a>c.maxs[5])return 1}return a>(b?59:23)?1:void 0},c.check=function(){var a=c.options.format.replace(/YYYY|MM|DD|hh|mm|ss/g,"\\d+\\").replace(/\\$/g,""),b=new RegExp(a),d=c.elem[h.elemv],e=d.match(/\d+/g)||[],f=c.checkVoid(e[0],e[1],e[2]);if(""!==d.replace(/\s/g,"")){if(!b.test(d))return c.elem[h.elemv]="",c.msg("日期不符合格式,请重新选择。"),1;if(f[0])return c.elem[h.elemv]="",c.msg("日期不在有效期内,请重新选择。"),1;f.value=c.elem[h.elemv].match(b).join(),e=f.value.match(/\d+/g),e[1]<1?(e[1]=1,f.auto=1):e[1]>12?(e[1]=12,f.auto=1):e[1].length<2&&(f.auto=1),e[2]<1?(e[2]=1,f.auto=1):e[2]>c.months[(0|e[1])-1]?(e[2]=31,f.auto=1):e[2].length<2&&(f.auto=1),e.length>3&&(c.timeVoid(e[3],0)&&(f.auto=1),c.timeVoid(e[4],1)&&(f.auto=1),c.timeVoid(e[5],2)&&(f.auto=1)),f.auto?c.creation([e[0],0|e[1],0|e[2]],1):f.value!==c.elem[h.elemv]&&(c.elem[h.elemv]=f.value)}},c.months=[31,null,31,30,31,30,31,31,30,31,30,31],c.viewDate=function(a,b,d){var f=(c.query,{}),g=new Date;a<(0|c.mins[0])&&(a=0|c.mins[0]),a>(0|c.maxs[0])&&(a=0|c.maxs[0]),g.setFullYear(a,b,d),f.ymd=[g.getFullYear(),g.getMonth(),g.getDate()],c.months[1]=c.isleap(f.ymd[0])?29:28,g.setFullYear(f.ymd[0],f.ymd[1],1),f.FDay=g.getDay(),f.PDay=c.months[0===b?11:b-1]-f.FDay+1,f.NDay=1,c.each(h.tds,function(a,b){var g,d=f.ymd[0],e=f.ymd[1]+1;b.className="",a=f.FDay&&a'+a+"年":'
    • '+(a-7+b)+"年
    • "}),b("#laydate_ys").innerHTML=d,c.each(b("#laydate_ys li"),function(a,b){"y"===c.checkVoid(b.getAttribute("y"))[0]?c.addClass(b,h[1]):c.on(b,"click",function(a){c.stopmp(a).reshow(),c.viewDate(0|this.getAttribute("y"),c.ymd[1],c.ymd[2])})})},c.initDate=function(){var d=(c.query,new Date),e=c.elem[h.elemv].match(/\d+/g)||[];e.length<3&&(e=c.options.start.match(/\d+/g)||[],e.length<3&&(e=[d.getFullYear(),d.getMonth()+1,d.getDate()])),c.inymd=e,c.viewDate(e[0],e[1]-1,e[2])},c.iswrite=function(){var a=c.query,b={time:a("#laydate_hms")};c.shde(b.time,!c.options.istime),c.shde(h.oclear,!("isclear"in c.options?c.options.isclear:1)),c.shde(h.otoday,!("istoday"in c.options?c.options.istoday:1)),c.shde(h.ok,!("issure"in c.options?c.options.issure:1))},c.orien=function(a,b){var d,e=c.elem.getBoundingClientRect();a.style.left=e.left+(b?0:c.scroll(1))+"px",d=e.bottom+a.offsetHeight/1.5<=c.winarea()?e.bottom-1:e.top>a.offsetHeight/1.5?e.top-a.offsetHeight+1:c.winarea()-a.offsetHeight,a.style.top=d+(b?0:c.scroll())+"px"},c.follow=function(a){c.options.fixed?(a.style.position="fixed",c.orien(a,1)):(a.style.position="absolute",c.orien(a))},c.viewtb=function(){var a,b=[],f=["日","一","二","三","四","五","六"],h={},i=d[e]("table"),j=d[e]("thead");return j.appendChild(d[e]("tr")),h.creath=function(a){var b=d[e]("th");b.innerHTML=f[a],j[g]("tr")[0].appendChild(b),b=null},c.each(new Array(6),function(d){b.push([]),a=i.insertRow(0),c.each(new Array(7),function(c){b[d][c]=0,0===d&&h.creath(c),a.insertCell(c)})}),i.insertBefore(j,i.children[0]),i.id=i.className="laydate_table",a=b=null,i.outerHTML.toLowerCase()}(),c.view=function(a,f){var i,g=c.query,j={};f=f||a,c.elem=a,c.options=f,c.options.format||(c.options.format=b.format),c.options.start=c.options.start||"",c.mm=j.mm=[c.options.min||b.min,c.options.max||b.max],c.mins=j.mm[0].match(/\d+/g),c.maxs=j.mm[1].match(/\d+/g),h.elemv=/textarea|input/.test(c.elem.tagName.toLocaleLowerCase())?"value":"innerHTML",c.box?c.shde(c.box):(i=d[e]("div"),i.id=h[0],i.className=h[0],i.style.cssText="position: absolute;",i.setAttribute("name","laydate-v"+laydate.v),i.innerHTML=j.html='
        '+function(){var a="";return c.each(new Array(12),function(b){a+=''+c.digit(b+1)+"月"}),a}()+"
        "+"
        "+"
        "+c.viewtb+'
        '+'
          '+'
        • 时间
        • '+"
        • :
        • "+"
        • :
        • "+"
        • "+"
        "+'
        '+'
        '+'清空'+'今天'+'确认'+"
        "+(b.isv?'laydate-v'+laydate.v+"":"")+"
        ",d.body.appendChild(i),c.box=g("#"+h[0]),c.events(),i=null),c.follow(c.box),f.zIndex?c.box.style.zIndex=f.zIndex:c.removeCssAttr(c.box,"z-index"),c.stopMosup("click",c.box),c.initDate(),c.iswrite(),c.check()},c.reshow=function(){return c.each(c.query("#"+h[0]+" .laydate_show"),function(a,b){c.removeClass(b,"laydate_show")}),this},c.close=function(){c.reshow(),c.shde(c.query("#"+h[0]),1),c.elem=null},c.parse=function(a,d,e){return a=a.concat(d),e=e||(c.options?c.options.format:b.format),e.replace(/YYYY|MM|DD|hh|mm|ss/g,function(){return a.index=0|++a.index,c.digit(a[a.index])})},c.creation=function(a,b){var e=(c.query,c.hmsin),f=c.parse(a,[e[0].value,e[1].value,e[2].value]);c.elem[h.elemv]=f,b||(c.close(),"function"==typeof c.options.choose&&c.options.choose(f))},c.events=function(){var b=c.query,e={box:"#"+h[0]};c.addClass(d.body,"laydate_body"),h.tds=b("#laydate_table td"),h.mms=b("#laydate_ms span"),h.year=b("#laydate_y"),h.month=b("#laydate_m"),c.each(b(e.box+" .laydate_ym"),function(a,b){c.on(b,"click",function(b){c.stopmp(b).reshow(),c.addClass(this[g]("div")[0],"laydate_show"),a||(e.YY=parseInt(h.year.value),c.viewYears(e.YY))})}),c.on(b(e.box),"click",function(){c.reshow()}),e.tabYear=function(a){0===a?c.ymd[0]--:1===a?c.ymd[0]++:2===a?e.YY-=14:e.YY+=14,2>a?(c.viewDate(c.ymd[0],c.ymd[1],c.ymd[2]),c.reshow()):c.viewYears(e.YY)},c.each(b("#laydate_YY .laydate_tab"),function(a,b){c.on(b,"click",function(b){c.stopmp(b),e.tabYear(a)})}),e.tabMonth=function(a){a?(c.ymd[1]++,12===c.ymd[1]&&(c.ymd[0]++,c.ymd[1]=0)):(c.ymd[1]--,-1===c.ymd[1]&&(c.ymd[0]--,c.ymd[1]=11)),c.viewDate(c.ymd[0],c.ymd[1],c.ymd[2])},c.each(b("#laydate_MM .laydate_tab"),function(a,b){c.on(b,"click",function(b){c.stopmp(b).reshow(),e.tabMonth(a)})}),c.each(b("#laydate_ms span"),function(a,b){c.on(b,"click",function(a){c.stopmp(a).reshow(),c.hasClass(this,h[1])||c.viewDate(c.ymd[0],0|this.getAttribute("m"),c.ymd[2])})}),c.each(b("#laydate_table td"),function(a,b){c.on(b,"click",function(a){c.hasClass(this,h[1])||(c.stopmp(a),c.creation([0|this.getAttribute("y"),0|this.getAttribute("m"),0|this.getAttribute("d")]))})}),h.oclear=b("#laydate_clear"),c.on(h.oclear,"click",function(){c.elem[h.elemv]="",c.close()}),h.otoday=b("#laydate_today"),c.on(h.otoday,"click",function(){var hms=c.hmsin;var date=new Date();hms[0].value=date.getHours();hms[1].value=date.getMinutes();hms[2].value=date.getSeconds();c.creation([c.ymd[0],c.ymd[1]+1,c.ymd[2]]),c.close()}),h.ok=b("#laydate_ok"),c.on(h.ok,"click",function(){c.valid&&c.creation([c.ymd[0],c.ymd[1]+1,c.ymd[2]])}),e.times=b("#laydate_time"),c.hmsin=e.hmsin=b("#laydate_hms input"),e.hmss=["小时","分钟","秒数"],e.hmsarr=[],c.msg=function(a,d){var f='
        '+(d||"提示")+"×
        ";"string"==typeof a?(f+="

        "+a+"

        ",c.shde(b("#"+h[0])),c.removeClass(e.times,"laydate_time1").addClass(e.times,"laydate_msg")):(e.hmsarr[a]?f=e.hmsarr[a]:(f+='
        ',c.each(new Array(0===a?24:60),function(a){f+=""+a+""}),f+="
        ",e.hmsarr[a]=f),c.removeClass(e.times,"laydate_msg"),c[0===a?"removeClass":"addClass"](e.times,"laydate_time1")),c.addClass(e.times,"laydate_show"),e.times.innerHTML=f},e.hmson=function(a,d){var e=b("#laydate_hmsno span"),f=c.valid?null:1;c.each(e,function(b,e){f?c.addClass(e,h[1]):c.timeVoid(b,d)?c.addClass(e,h[1]):c.on(e,"click",function(){c.hasClass(this,h[1])||(a.value=c.digit(0|this.innerHTML))})}),c.addClass(e[0|a.value],"laydate_click")},c.each(e.hmsin,function(a,b){c.on(b,"click",function(b){c.stopmp(b).reshow(),c.msg(a,e.hmss[a]),e.hmson(this,a)})}),c.on(d,"mouseup",function(){var a=b("#"+h[0]);a&&"none"!==a.style.display&&(c.check()||c.close())}).on(d,"keydown",function(b){b=b||a.event;var d=b.keyCode;13===d&&c.creation([c.ymd[0],c.ymd[1]+1,c.ymd[2]])})},c.init=function(){c.use("need"),c.use(h[4]+b.defSkin,h[3]),c.skinLink=c.query("#"+h[3])}(),laydate.reset=function(){c.box&&c.elem&&c.follow(c.box)},laydate.now=function(a,b){var d=new Date(0|a?function(a){return 864e5>a?+new Date+864e5*a:a}(parseInt(a)):+new Date);return c.parse([d.getFullYear(),d.getMonth()+1,d.getDate()],[d.getHours(),d.getMinutes(),d.getSeconds()],b)},laydate.skin=function(a){c.skinLink.href=c.getPath+h[4]+a+h[5]}}(window); \ No newline at end of file diff --git a/need/laydate.css b/need/laydate.css deleted file mode 100644 index 2eb0a5b..0000000 --- a/need/laydate.css +++ /dev/null @@ -1,73 +0,0 @@ -/** - - @Name: laydate 核心样式 - @Author:贤心 - @Site:http://sentsin.com/layui/laydate - -**/ - -html{_background-image:url(about:blank); _background-attachment:fixed;} -.laydate_body .laydate_box, .laydate_body .laydate_box *{margin:0; padding:0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box;} -.laydate-icon, -.laydate-icon-default, -.laydate-icon-danlan, -.laydate-icon-dahong, -.laydate-icon-molv{height:22px; line-height:22px; padding-right:20px; border:1px solid #C6C6C6; background-repeat:no-repeat; background-position:right center; background-color:#fff; outline:0;} -.laydate-icon-default{ background-image:url(../skins/default/icon.png)} -.laydate-icon-danlan{border:1px solid #B1D2EC; background-image:url(../skins/danlan/icon.png)} -.laydate-icon-dahong{background-image:url(../skins/dahong/icon.png)} -.laydate-icon-molv{background-image:url(../skins/molv/icon.png)} -.laydate_body .laydate_box{width:240px; font:12px '\5B8B\4F53'; z-index:99999999; *margin:-2px 0 0 -2px; *overflow:hidden; _margin:0; _position:absolute!important; background-color:#fff;} -.laydate_body .laydate_box li{list-style:none;} -.laydate_body .laydate_box .laydate_void{cursor:text!important;} -.laydate_body .laydate_box a, .laydate_body .laydate_box a:hover{text-decoration:none; blr:expression(this.onFocus=this.blur()); cursor:pointer;} -.laydate_body .laydate_box a:hover{text-decoration:none;} -.laydate_body .laydate_box cite, .laydate_body .laydate_box label{position:absolute; width:0; height:0; border-width:5px; border-style:dashed; border-color:transparent; overflow:hidden; cursor:pointer;} -.laydate_body .laydate_box .laydate_yms, .laydate_body .laydate_box .laydate_time{display:none;} -.laydate_body .laydate_box .laydate_show{display:block;} -.laydate_body .laydate_box input{outline:0; font-size:14px; background-color:#fff;} -.laydate_body .laydate_top{position:relative; height:26px; padding:5px; *width:100%; z-index:99;} -.laydate_body .laydate_ym{position:relative; float:left; height:24px; cursor:pointer;} -.laydate_body .laydate_ym input{float:left; height:24px; line-height:24px; text-align:center; border:none; cursor:pointer;} -.laydate_body .laydate_ym .laydate_yms{position:absolute; left: -1px; top: 24px; height:181px;} -.laydate_body .laydate_y{width:121px; margin-right:6px;} -.laydate_body .laydate_y input{width:64px; margin-right:15px;} -.laydate_body .laydate_y .laydate_yms{width:121px; text-align:center;} -.laydate_body .laydate_y .laydate_yms a{position:relative; display:block; height:20px;} -.laydate_body .laydate_y .laydate_yms ul{height:139px; padding:0; *overflow:hidden;} -.laydate_body .laydate_y .laydate_yms ul li{float:left; width:60px; height:20px; line-height: 20px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;} -.laydate_body .laydate_m{width:99px;} -.laydate_body .laydate_m .laydate_yms{width:99px; padding:0;} -.laydate_body .laydate_m input{width:42px; margin-right:15px;} -.laydate_body .laydate_m .laydate_yms span{display:block; float:left; width:42px; margin: 5px 0 0 5px; line-height:24px; text-align:center; _display:inline;} -.laydate_body .laydate_choose{display:block; float:left; position:relative; width:20px; height:24px;} -.laydate_body .laydate_choose cite, .laydate_body .laydate_tab cite{left:50%; top:50%;} -.laydate_body .laydate_chtop cite{margin:-7px 0 0 -5px; border-bottom-style:solid;} -.laydate_body .laydate_chdown cite, .laydate_body .laydate_ym label{top:50%; margin:-2px 0 0 -5px; border-top-style:solid;} -.laydate_body .laydate_chprev cite{margin:-5px 0 0 -7px;} -.laydate_body .laydate_chnext cite{margin:-5px 0 0 -2px;} -.laydate_body .laydate_ym label{right:28px;} -.laydate_body .laydate_table{ width:230px; margin:0 5px; border-collapse:collapse; border-spacing:0px; } -.laydate_body .laydate_table td{width:31px; height:19px; line-height:19px; text-align: center; cursor:pointer; font-size: 12px;} -.laydate_body .laydate_table thead{height:22px; line-height:22px;} -.laydate_body .laydate_table thead th{font-weight:400; font-size:12px; text-align:center;} -.laydate_body .laydate_bottom{position:relative; height:22px; line-height:20px; padding:5px; font-size:12px;} -.laydate_body .laydate_bottom #laydate_hms{position: relative; z-index: 1; float:left; } -.laydate_body .laydate_time{ position:absolute; left:5px; bottom: 26px; width:129px; height:125px; *overflow:hidden;} -.laydate_body .laydate_time .laydate_hmsno{ padding:5px 0 0 5px;} -.laydate_body .laydate_time .laydate_hmsno span{display:block; float:left; width:24px; height:19px; line-height:19px; text-align:center; cursor:pointer; *margin-bottom:-5px;} -.laydate_body .laydate_time1{width:228px; height:154px;} -.laydate_body .laydate_time1 .laydate_hmsno{padding: 6px 0 0 8px;} -.laydate_body .laydate_time1 .laydate_hmsno span{width:21px; height:20px; line-height:20px;} -.laydate_body .laydate_msg{left:49px; bottom:67px; width:141px; height:auto; overflow: hidden;} -.laydate_body .laydate_msg p{padding:5px 10px;} -.laydate_body .laydate_bottom li{float:left; height:20px; line-height:20px; border-right:none; font-weight:900;} -.laydate_body .laydate_bottom .laydate_sj{width:33px; text-align:center; font-weight:400;} -.laydate_body .laydate_bottom input{float:left; width:21px; height:20px; line-height:20px; border:none; text-align:center; cursor:pointer; font-size:12px; font-weight:400;} -.laydate_body .laydate_bottom .laydte_hsmtex{height:20px; line-height:20px; text-align:center;} -.laydate_body .laydate_bottom .laydte_hsmtex span{position:absolute; width:20px; top:0; right:0px; cursor:pointer;} -.laydate_body .laydate_bottom .laydte_hsmtex span:hover{font-size:14px;} -.laydate_body .laydate_bottom .laydate_btn{position:absolute; right:5px; top:5px;} -.laydate_body .laydate_bottom .laydate_btn a{float:left; height:20px; padding:0 6px; _padding:0 5px;} -.laydate_body .laydate_bottom .laydate_v{position:absolute; left:10px; top:6px; font-family:Courier; z-index:0;} - diff --git a/package.json b/package.json new file mode 100644 index 0000000..b5eebd7 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "name": "layui-laydate", + "realname": "layDate", + "version": "5.3.1", + "description": "日期与时间组件", + "main": "src/laydate.js", + "license": "MIT", + "scripts": { + "run": "gulp" + }, + "repository": { + "type": "https", + "url": "git+https://github.com/sentsin/laydate.git" + }, + "devDependencies": { + "gulp": "^3.9.0", + "gulp-minify-css": "^1.2.4", + "gulp-uglify": "^1.5.4", + "gulp-rename": "^1.2.2", + "gulp-header": "^1.8.8", + "del": "^2.2.2" + }, + "bugs": { + "url": "https://github.com/sentsin/laydate/issues" + }, + "directories": { + "test": "test" + }, + "dependencies": {}, + "keywords": [ + "laydate", + "date", + "time", + "datetime", + "datepicker", + "calendar" + ], + "homepage": "https://github.com/sentsin/laydate#readme", + "author": "" +} diff --git a/skins/dahong/icon.png b/skins/dahong/icon.png deleted file mode 100644 index dfd870d..0000000 Binary files a/skins/dahong/icon.png and /dev/null differ diff --git a/skins/dahong/laydate.css b/skins/dahong/laydate.css deleted file mode 100644 index 82047c7..0000000 --- a/skins/dahong/laydate.css +++ /dev/null @@ -1,58 +0,0 @@ -/** - - @Name: laydate皮肤:大红 - @Author:贤心 - @Site:http://sentsin.com/layui/laydate - -**/ - -.laydate-icon{border:1px solid #ccc; background-image:url(icon.png)} - -.laydate_body .laydate_bottom #laydate_hms, -.laydate_body .laydate_time{border:1px solid #ccc;} - -.laydate_body .laydate_box, -.laydate_body .laydate_time{box-shadow: 2px 2px 5px rgba(0,0,0,.1);} - -.laydate_body .laydate_box{border-top:none; border-bottom:none; background-color:#fff; color:#333;} -.laydate_body .laydate_box input{background:none!important; color:#fff;} -.laydate_body .laydate_box .laydate_void{color:#ccc!important;} -.laydate_body .laydate_box a, .laydate_body .laydate_box a:hover{color:#333;} -.laydate_body .laydate_box a:hover{color:#666;} -.laydate_body .laydate_click{background-color:#F32043!important; color:#fff!important;} -.laydate_body .laydate_top{border-top:1px solid #D91600; background-color:#D91600} -.laydate_body .laydate_ym{border:1px solid #D91600; background-color:#D91600;} -.laydate_body .laydate_ym .laydate_yms{border:1px solid #D91600; background-color:#D91600; color:#fff;} -.laydate_body .laydate_y .laydate_yms a{border-bottom:1px solid #D91600;} -.laydate_body .laydate_y .laydate_yms .laydate_chdown{border-top:1px solid #D91600; border-bottom:none;} -.laydate_body .laydate_choose{border-left:1px solid #D91600;} -.laydate_body .laydate_chprev{border-left:none; border-right:1px solid #D91600;} -.laydate_body .laydate_choose:hover, -.laydate_body .laydate_y .laydate_yms a:hover{background-color:#F54766;} -.laydate_body .laydate_chtop cite{border-bottom-color:#fff;} -.laydate_body .laydate_chdown cite, .laydate_body .laydate_ym label{border-top-color:#fff;} -.laydate_body .laydate_chprev cite{border-right-style:solid; border-right-color:#fff;} -.laydate_body .laydate_chnext cite{border-left-style:solid; border-left-color:#fff;} -.laydate_body .laydate_table{width: 240px!important; margin: 0!important; border:1px solid #ccc; border-top:none; border-bottom:none;} -.laydate_body .laydate_table td{border:none; height:21px!important; line-height:21px!important; background-color:#fff; color:#333;} -.laydate_body .laydate_table .laydate_nothis{color:#999;} -.laydate_body .laydate_table thead{border-bottom:1px solid #ccc; height:21px!important; line-height:21px!important;} -.laydate_body .laydate_table thead th{} -.laydate_body .laydate_bottom{border:1px solid #ccc; border-top:none;} -.laydate_body .laydate_bottom #laydate_hms{background-color:#fff;} -.laydate_body .laydate_time{background-color:#fff;} -.laydate_body .laydate_time1{width: 226px!important; height: 152px!important;} -.laydate_body .laydate_bottom .laydate_sj{width:31px!important; border-right:1px solid #ccc; background-color:#fff;} -.laydate_body .laydate_bottom input{background-color:#fff; color:#333;} -.laydate_body .laydate_bottom .laydte_hsmtex{border-bottom:1px solid #ccc;} -.laydate_body .laydate_bottom .laydate_btn{border-right:1px solid #ccc;} -.laydate_body .laydate_bottom .laydate_v{color:#999} -.laydate_body .laydate_bottom .laydate_btn a{border: 1px solid #ccc; border-right:none; background-color:#fff;} -.laydate_body .laydate_bottom .laydate_btn a:hover{background-color:#F6F6F6; color:#333;} - -.laydate_body .laydate_m .laydate_yms span:hover, -.laydate_body .laydate_time .laydate_hmsno span:hover, -.laydate_body .laydate_y .laydate_yms ul li:hover, -.laydate_body .laydate_table td:hover{background-color:#F54766; color:#fff;} - - diff --git a/skins/danlan/icon.png b/skins/danlan/icon.png deleted file mode 100644 index 1d75693..0000000 Binary files a/skins/danlan/icon.png and /dev/null differ diff --git a/skins/danlan/laydate.css b/skins/danlan/laydate.css deleted file mode 100644 index c0d9e9f..0000000 --- a/skins/danlan/laydate.css +++ /dev/null @@ -1,67 +0,0 @@ -/** - - @Name: laydate皮肤:淡蓝 - @Author:贤心 - @Site:http://sentsin.com/layui/laydate - -**/ - -.laydate-icon{border:1px solid #B1D2EC; background-image:url(icon.png)} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_table, -.laydate_body .laydate_table td, -.laydate_body .laydate_bottom #laydate_hms, -.laydate_body .laydate_time, -.laydate_body .laydate_bottom .laydate_btn a{border:1px solid #B1D2EC;} - -.laydate_body .laydate_y .laydate_yms a, -.laydate_body .laydate_choose, -.laydate_body .laydate_table thead{background-color:#DEECF8;} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_time{box-shadow: 2px 2px 5px rgba(0,0,0,.1);} - -.laydate_body .laydate_box{border-top:none; border-bottom:none; background-color:#fff; color:#1F547E;} -.laydate_body .laydate_box input{color:#1F547E;} -.laydate_body .laydate_box .laydate_void{color:#BDD8EE!important;} -.laydate_body .laydate_box .laydate_void:hover{background-color:#fff!important} -.laydate_body .laydate_box a, .laydate_body .laydate_box a:hover{color:#1F547E;} -.laydate_body .laydate_click{background-color:#DEECF8!important;} -.laydate_body .laydate_top{border-top:1px solid #B1D2EC;} -.laydate_body .laydate_ym .laydate_yms{background-color:#fff;} -.laydate_body .laydate_y .laydate_yms a{border-bottom:1px solid #B1D2EC;} -.laydate_body .laydate_y .laydate_yms .laydate_chdown{border-top:1px solid #B1D2EC; border-bottom:none;} -.laydate_body .laydate_y .laydate_yms ul li:hover, -.laydate_body .laydate_m .laydate_yms span:hover{color:#000;} -.laydate_body .laydate_choose{border-left:1px solid #B1D2EC;} -.laydate_body .laydate_chprev{border-left:none; border-right:1px solid #B1D2EC;} -.laydate_body .laydate_chtop cite{border-bottom-color:#3081C2;} -.laydate_body .laydate_chdown cite, .laydate_body .laydate_ym label{border-top-color:#3081C2;} -.laydate_body .laydate_chprev cite{border-right-style:solid; border-right-color:#3081C2;} -.laydate_body .laydate_chnext cite{border-left-style:solid; border-left-color:#3081C2;} -.laydate_body .laydate_table td{background-color:#fff; color:#1F547E;} -.laydate_body .laydate_table .laydate_nothis{color:#60A2D7;} -.laydate_body .laydate_table thead{color:#163A58;} -.laydate_body .laydate_bottom{border-bottom:1px solid #B1D2EC;} -.laydate_body .laydate_bottom #laydate_hms{background-color:#fff;} -.laydate_body .laydate_time{background-color:#fff;} -.laydate_body .laydate_bottom .laydate_sj{border-right:1px solid #B1D2EC; background-color:#ECF4FB;} -.laydate_body .laydate_bottom input{background-color:#fff;} -.laydate_body .laydate_bottom .laydte_hsmtex{border-bottom:1px solid #B1D2EC;} -.laydate_body .laydate_bottom .laydate_btn{border-right:1px solid #B1D2EC;} -.laydate_body .laydate_bottom .laydate_v{color:#75AEDD} -.laydate_body .laydate_bottom .laydate_btn a{ border-right:none; background-color:#ECF4FB;} -.laydate_body .laydate_bottom .laydate_btn a:hover{ background-color:#fff;} - -.laydate_body .laydate_y .laydate_yms ul li:hover, -.laydate_body .laydate_m .laydate_yms span:hover, -.laydate_body .laydate_choose:hover, -.laydate_body .laydate_y .laydate_yms a:hover, -.laydate_body .laydate_table td:hover, -.laydate_body .laydate_bottom .laydate_time span:hover, -.laydate_body .laydate_bottom .laydte_hsmtex{background-color:#ECF4FB} - diff --git a/skins/default/icon.png b/skins/default/icon.png deleted file mode 100644 index 5a50673..0000000 Binary files a/skins/default/icon.png and /dev/null differ diff --git a/skins/default/laydate.css b/skins/default/laydate.css deleted file mode 100644 index 39bdadd..0000000 --- a/skins/default/laydate.css +++ /dev/null @@ -1,68 +0,0 @@ -/** - - @Name: laydate皮肤:默认 - @Author:贤心 - @Site:http://sentsin.com/layui/laydate - -**/ - -.laydate-icon{border:1px solid #C6C6C6; background-image:url(icon.png)} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_table, -.laydate_body .laydate_table td, -.laydate_body .laydate_bottom #laydate_hms, -.laydate_body .laydate_time, -.laydate_body .laydate_bottom .laydate_btn a{border:1px solid #ccc;} - -.laydate_body .laydate_y .laydate_yms a, -.laydate_body .laydate_choose, -.laydate_body .laydate_table thead, -.laydate_body .laydate_bottom .laydte_hsmtex{background-color:#F6F6F6;} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_time{box-shadow: 2px 2px 5px rgba(0,0,0,.1);} - -.laydate_body .laydate_box{border-top:none; border-bottom:none; background-color:#fff; color:#333;} -.laydate_body .laydate_box input{color:#333;} -.laydate_body .laydate_box .laydate_void{color:#ccc!important; /*text-decoration:line-through;*/} -.laydate_body .laydate_box .laydate_void:hover{background-color:#fff!important} -.laydate_body .laydate_box a, .laydate_body .laydate_box a:hover{color:#333;} -.laydate_body .laydate_box a:hover{color:#666;} -.laydate_body .laydate_click{background-color:#eee!important;} -.laydate_body .laydate_top{border-top:1px solid #C6C6C6;} -.laydate_body .laydate_ym .laydate_yms{border:1px solid #C6C6C6; background-color:#fff;} -.laydate_body .laydate_y .laydate_yms a{border-bottom:1px solid #C6C6C6;} -.laydate_body .laydate_y .laydate_yms .laydate_chdown{border-top:1px solid #C6C6C6; border-bottom:none;} -.laydate_body .laydate_choose{border-left:1px solid #C6C6C6;} -.laydate_body .laydate_chprev{border-left:none; border-right:1px solid #C6C6C6;} -.laydate_body .laydate_choose:hover, -.laydate_body .laydate_y .laydate_yms a:hover{background-color:#fff;} -.laydate_body .laydate_chtop cite{border-bottom-color:#666;} -.laydate_body .laydate_chdown cite, .laydate_body .laydate_ym label{border-top-color:#666;} -.laydate_body .laydate_chprev cite{border-right-style:solid; border-right-color:#666;} -.laydate_body .laydate_chnext cite{border-left-style:solid; border-left-color:#666;} -.laydate_body .laydate_table td{border:none; height:21px!important; line-height:21px!important; background-color:#fff;} -.laydate_body .laydate_table .laydate_nothis{color:#999;} -.laydate_body .laydate_table thead{height:21px!important; line-height:21px!important;} -.laydate_body .laydate_table thead th{border-bottom:1px solid #ccc;} -.laydate_body .laydate_bottom{border-bottom:1px solid #C6C6C6;} -.laydate_body .laydate_bottom #laydate_hms{background-color:#fff;} -.laydate_body .laydate_time{background-color:#fff;} -.laydate_body .laydate_bottom .laydate_sj{border-right:1px solid #C6C6C6; background-color:#F6F6F6;} -.laydate_body .laydate_bottom input{background-color:#fff;} -.laydate_body .laydate_bottom .laydte_hsmtex{border-bottom:1px solid #C6C6C6;} -.laydate_body .laydate_bottom .laydate_btn{border-right:1px solid #C6C6C6;} -.laydate_body .laydate_bottom .laydate_v{color:#999} -.laydate_body .laydate_bottom .laydate_btn a{border-right:none; background-color:#F6F6F6;} -.laydate_body .laydate_bottom .laydate_btn a:hover{color:#000; background-color:#fff;} - -.laydate_body .laydate_m .laydate_yms span:hover, -.laydate_body .laydate_y .laydate_yms ul li:hover, -.laydate_body .laydate_table td:hover, -.laydate_body .laydate_time .laydate_hmsno span:hover{background-color:#F3F3F3} - - diff --git a/skins/molv/icon.png b/skins/molv/icon.png deleted file mode 100644 index 948660f..0000000 Binary files a/skins/molv/icon.png and /dev/null differ diff --git a/skins/molv/laydate.css b/skins/molv/laydate.css deleted file mode 100644 index 8877b21..0000000 --- a/skins/molv/laydate.css +++ /dev/null @@ -1,59 +0,0 @@ -/** - - @Name: laydate皮肤:墨绿 - @Author:贤心 - @Site:http://sentsin.com/layui/laydate - -**/ - -.laydate-icon{border:1px solid #ccc; background-image:url(icon.png)} - -.laydate_body .laydate_bottom #laydate_hms, -.laydate_body .laydate_time{border:1px solid #ccc;} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_time{box-shadow: 2px 2px 5px rgba(0,0,0,.1);} - -.laydate_body .laydate_box{border-top:none; border-bottom:none; background-color:#fff; color:#00625A;} -.laydate_body .laydate_box input{background:none!important; color:#fff;} -.laydate_body .laydate_box .laydate_void{color:#00E8D7!important;} -.laydate_body .laydate_box a, .laydate_body .laydate_box a:hover{color:#00625A;} -.laydate_body .laydate_box a:hover{color:#666;} -.laydate_body .laydate_click{background-color:#009F95!important; color:#fff!important;} -.laydate_body .laydate_top{border-top:1px solid #009F95; background-color:#009F95} -.laydate_body .laydate_ym{border:1px solid #009F95; background-color:#009F95;} -.laydate_body .laydate_ym .laydate_yms{border:1px solid #009F95; background-color:#009F95; color:#fff;} -.laydate_body .laydate_y .laydate_yms a{border-bottom:1px solid #009F95;} -.laydate_body .laydate_y .laydate_yms .laydate_chdown{border-top:1px solid #009F95; border-bottom:none;} -.laydate_body .laydate_choose{border-left:1px solid #009F95;} -.laydate_body .laydate_chprev{border-left:none; border-right:1px solid #009F95;} -.laydate_body .laydate_choose:hover, -.laydate_body .laydate_y .laydate_yms a:hover{background-color:#00C1B3;} -.laydate_body .laydate_chtop cite{border-bottom-color:#fff;} -.laydate_body .laydate_chdown cite, .laydate_body .laydate_ym label{border-top-color:#fff;} -.laydate_body .laydate_chprev cite{border-right-style:solid; border-right-color:#fff;} -.laydate_body .laydate_chnext cite{border-left-style:solid; border-left-color:#fff;} -.laydate_body .laydate_table{width: 240px!important; margin: 0!important; border:1px solid #ccc; border-top:none; border-bottom:none;} -.laydate_body .laydate_table td{border:none; height:21px!important; line-height:21px!important; background-color:#fff; color:#00625A;} -.laydate_body .laydate_table .laydate_nothis{color:#999;} -.laydate_body .laydate_table thead{border-bottom:1px solid #ccc; height:21px!important; line-height:21px!important;} -.laydate_body .laydate_table thead th{} -.laydate_body .laydate_bottom{border:1px solid #ccc; border-top:none;} -.laydate_body .laydate_bottom #laydate_hms{background-color:#fff;} -.laydate_body .laydate_time{background-color:#fff;} -.laydate_body .laydate_time1{width: 226px!important; height: 152px!important;} -.laydate_body .laydate_bottom .laydate_sj{width:31px!important; border-right:1px solid #ccc; background-color:#fff;} -.laydate_body .laydate_bottom input{background-color:#fff; color:#00625A;} -.laydate_body .laydate_bottom .laydte_hsmtex{border-bottom:1px solid #ccc;} -.laydate_body .laydate_bottom .laydate_btn{border-right:1px solid #ccc;} -.laydate_body .laydate_bottom .laydate_v{color:#999} -.laydate_body .laydate_bottom .laydate_btn a{border: 1px solid #ccc; border-right:none; background-color:#fff;} -.laydate_body .laydate_bottom .laydate_btn a:hover{background-color:#F6F6F6; color:#00625A;} - -.laydate_body .laydate_m .laydate_yms span:hover, -.laydate_body .laydate_time .laydate_hmsno span:hover, -.laydate_body .laydate_y .laydate_yms ul li:hover, -.laydate_body .laydate_table td:hover{background-color:#00C1B3; color:#fff;} - - diff --git a/skins/qianhuang/icon.png b/skins/qianhuang/icon.png deleted file mode 100644 index 598d52b..0000000 Binary files a/skins/qianhuang/icon.png and /dev/null differ diff --git a/skins/qianhuang/laydate.css b/skins/qianhuang/laydate.css deleted file mode 100644 index 0fd067e..0000000 --- a/skins/qianhuang/laydate.css +++ /dev/null @@ -1,70 +0,0 @@ -/** - - @Name: laydate皮肤:浅黄 - @Author:贤心 - @Site:http://sentsin.com/layui/laydate - -**/ - -.laydate-icon{border:1px solid #E7D7CB; background-image:url(icon.png)} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_table, -.laydate_body .laydate_table td, -.laydate_body .laydate_bottom #laydate_hms, -.laydate_body .laydate_time, -.laydate_body .laydate_bottom .laydate_btn a{border:1px solid #DEC8B8;} - -.laydate_body .laydate_y .laydate_yms a, -.laydate_body .laydate_ym, -.laydate_body .laydate_choose, -.laydate_body .laydate_table thead{background-color:#fff;} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_time{box-shadow: 2px 2px 5px rgba(0,0,0,.1);} - -.laydate_body .laydate_box{border-top:none; border-bottom:none; background-color: #F7F4ED!important; color:#8B743F;} -.laydate_body .laydate_box input{color:#8B743F;} -.laydate_body .laydate_box .laydate_void{color:#CBB98D!important;} -.laydate_body .laydate_box .laydate_void:hover{background-color:#fff!important;} -.laydate_body .laydate_box a, .laydate_body .laydate_box a:hover{color:#8B743F;} -.laydate_body .laydate_box a:hover{color:#8B743F;} -.laydate_body .laydate_click{background-color:#DEC8B8!important;} -.laydate_body .laydate_top{border-top:1px solid #DEC8B8;} -.laydate_body .laydate_ym .laydate_yms{background-color:#fff;} -.laydate_body .laydate_y .laydate_yms a{border-bottom:1px solid #DEC8B8;} -.laydate_body .laydate_y .laydate_yms .laydate_chdown{border-top:1px solid #DEC8B8; border-bottom:none;} -.laydate_body .laydate_y .laydate_yms ul li:hover, -.laydate_body .laydate_m .laydate_yms span:hover{color:#8B743F;} -.laydate_body .laydate_choose{border-left:1px solid #DEC8B8;} -.laydate_body .laydate_chprev{border-left:none; border-right:1px solid #DEC8B8;} -.laydate_body .laydate_chtop cite{border-bottom-color:#8B743F;} -.laydate_body .laydate_chdown cite, .laydate_body .laydate_ym label{border-top-color:#8B743F;} -.laydate_body .laydate_chprev cite{border-right-style:solid; border-right-color:#8B743F;} -.laydate_body .laydate_chnext cite{border-left-style:solid; border-left-color:#8B743F;} -.laydate_body .laydate_table td{background-color:#F4F0E6; color:#8B743F;} -.laydate_body .laydate_table .laydate_nothis{background-color:#fff; color:#C0AA76;} -.laydate_body .laydate_table thead{color:#163A58;} -.laydate_body .laydate_bottom{border-bottom:1px solid #DEC8B8;} -.laydate_body .laydate_bottom #laydate_hms{background-color:#fff;} -.laydate_body .laydate_time{background-color:#fff;} -.laydate_body .laydate_bottom .laydate_sj{border-right:1px solid #DEC8B8;} -.laydate_body .laydate_bottom input{background-color:#fff;} -.laydate_body .laydate_bottom .laydte_hsmtex{border-bottom:1px solid #DEC8B8;} -.laydate_body .laydate_bottom .laydate_btn{border-right:1px solid #DEC8B8;} -.laydate_body .laydate_bottom .laydate_btn a{ border-right:none; background-color:#fff;} -.laydate_body .laydate_bottom .laydate_btn a:hover{color:#163A58;} - -.laydate_body .laydate_y .laydate_yms ul li:hover, -.laydate_body .laydate_m .laydate_yms span:hover, -.laydate_body .laydate_choose:hover, -.laydate_body .laydate_y .laydate_yms a:hover, -.laydate_body .laydate_table td:hover, -.laydate_body .laydate_bottom .laydate_sj, -.laydate_body .laydate_bottom .laydate_time span:hover, -.laydate_body .laydate_bottom .laydte_hsmtex, -.laydate_body .laydate_bottom .laydate_btn a:hover{background-color:#F7F4ED} - diff --git a/skins/yahui/icon.png b/skins/yahui/icon.png deleted file mode 100644 index 5a50673..0000000 Binary files a/skins/yahui/icon.png and /dev/null differ diff --git a/skins/yahui/laydate.css b/skins/yahui/laydate.css deleted file mode 100644 index 7e95356..0000000 --- a/skins/yahui/laydate.css +++ /dev/null @@ -1,68 +0,0 @@ -/** - - @Name: laydate皮肤:雅灰 - @Author:贤心 - @Site:http://sentsin.com/layui/laydate - -**/ - -.laydate-icon{border:1px solid #C6C6C6; background-image:url(icon.png)} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_table, -.laydate_body .laydate_table td, -.laydate_body .laydate_bottom #laydate_hms, -.laydate_body .laydate_time, -.laydate_body .laydate_bottom .laydate_btn a{border:1px solid #C6C6C6;} - -.laydate_body .laydate_y .laydate_yms a, -.laydate_body .laydate_choose, -.laydate_body .laydate_table thead, -.laydate_body .laydate_bottom .laydte_hsmtex{background-color:#F0F0F0;} - -.laydate_body .laydate_box, -.laydate_body .laydate_ym .laydate_yms, -.laydate_body .laydate_time{box-shadow: 2px 2px 5px rgba(0,0,0,.1);} - -.laydate_body .laydate_box{border-top:none; border-bottom:none; background-color:#fff; color:#333;} -.laydate_body .laydate_box input{color:#333;} -.laydate_body .laydate_box .laydate_void{color:#ccc!important; /*text-decoration:line-through;*/} -.laydate_body .laydate_box .laydate_void:hover{background-color:#fff!important} -.laydate_body .laydate_box a, .laydate_body .laydate_box a:hover{color:#333;} -.laydate_body .laydate_box a:hover{color:#666;} -.laydate_body .laydate_click{background-color:#E9E9E9!important;} -.laydate_body .laydate_top{border-top:1px solid #C6C6C6;} -.laydate_body .laydate_ym .laydate_yms{border:1px solid #C6C6C6; background-color:#fff;} -.laydate_body .laydate_y .laydate_yms a{border-bottom:1px solid #C6C6C6;} -.laydate_body .laydate_y .laydate_yms .laydate_chdown{border-top:1px solid #C6C6C6; border-bottom:none;} -.laydate_body .laydate_y .laydate_yms ul li:hover{background-color:#F1F1F1; color:#000;} -.laydate_body .laydate_m .laydate_yms span:hover{background-color:#F1F1F1; color:#000;} -.laydate_body .laydate_choose{border-left:1px solid #C6C6C6;} -.laydate_body .laydate_chprev{border-left:none; border-right:1px solid #C6C6C6;} -.laydate_body .laydate_choose:hover, -.laydate_body .laydate_y .laydate_yms a:hover{background-color:#F6F6F6;} -.laydate_body .laydate_chtop cite{border-bottom-color:#666;} -.laydate_body .laydate_chdown cite, .laydate_body .laydate_ym label{border-top-color:#666;} -.laydate_body .laydate_chprev cite{border-right-style:solid; border-right-color:#666;} -.laydate_body .laydate_chnext cite{border-left-style:solid; border-left-color:#666;} -.laydate_body .laydate_table td{border:1px solid #C6C6C6; color:#333;} -.laydate_body .laydate_table .laydate_nothis{color:#999;} -.laydate_body .laydate_table thead{ background-color:#E3E3E3; color:#000;} -.laydate_body .laydate_table thead th{} -.laydate_body .laydate_bottom{border-bottom:1px solid #C6C6C6;} -.laydate_body .laydate_bottom #laydate_hms{background-color:#fff;} -.laydate_body .laydate_time{background-color:#fff;} -.laydate_body .laydate_bottom .laydate_sj{border-right:1px solid #C6C6C6; background-color:#F3F3F3;} -.laydate_body .laydate_bottom input{background-color:#fff;} -.laydate_body .laydate_bottom .laydte_hsmtex{border-bottom:1px solid #C6C6C6;} -.laydate_body .laydate_bottom .laydate_btn{border-right:1px solid #C6C6C6;} -.laydate_body .laydate_bottom .laydate_v{color:#999} -.laydate_body .laydate_bottom .laydate_btn a{border-right:none; background-color:#F0F0F0;} -.laydate_body .laydate_bottom .laydate_btn a:hover{color:#000; background-color:#fff;} - -.laydate_body .laydate_table td:hover, -.laydate_body .laydate_bottom .laydate_time span:hover{background-color:#F2F2F2} - - diff --git a/skins/yalan/icon.png b/skins/yalan/icon.png deleted file mode 100644 index 659ad71..0000000 Binary files a/skins/yalan/icon.png and /dev/null differ diff --git a/skins/yalan/laydate.css b/skins/yalan/laydate.css deleted file mode 100644 index 6b31c81..0000000 --- a/skins/yalan/laydate.css +++ /dev/null @@ -1,58 +0,0 @@ -/** - - @Name: laydate皮肤:雅兰 - @Author:贤心 - @Site:http://sentsin.com/layui/laydate - -**/ - -.laydate-icon{border:1px solid #34AADC; background-image:url(icon.png)} - -.laydate_body .laydate_box, -.laydate_body .laydate_table, -.laydate_body .laydate_table td, -.laydate_body .laydate_bottom #laydate_hms, -.laydate_body .laydate_time, -.laydate_body .laydate_bottom .laydate_btn a{border:1px solid #34AADC;} - -.laydate_body .laydate_box{box-shadow: 2px 2px 5px rgba(0,0,0,.1);} - -.laydate_body .laydate_box{background-color:#34AADC!important; color:#fff;} -.laydate_body .laydate_box input{background:none!important; color:#fff;} -.laydate_body .laydate_box .laydate_void{color:#fff!important; background:none!important;} -.laydate_body .laydate_box a, .laydate_body .laydate_box a:hover{color:#333;} -.laydate_body .laydate_box a:hover{color:#666;} -.laydate_body .laydate_click{background-color:#67BFE4!important; color:#fff!important;} -.laydate_body .laydate_top{} -.laydate_body .laydate_ym{background-color:#50B5E0; border:1px solid #50B5E0;} -.laydate_body .laydate_ym .laydate_yms{border:1px solid #2293C4; background-color:#2293C4;} -.laydate_body .laydate_y .laydate_yms a{border-bottom:1px solid #50B5E0; background-color:#50B5E0;} -.laydate_body .laydate_y .laydate_yms .laydate_chdown{border-top:1px solid #50B5E0; border-bottom:none;} -.laydate_body .laydate_choose{} -.laydate_body .laydate_chprev{border-left:none; border-right:1px solid #50B5E0;} -.laydate_body .laydate_choose:hover, -.laydate_body .laydate_y .laydate_yms a:hover{background-color:#61BBE2;} -.laydate_body .laydate_chtop cite{border-bottom-color:#C7E8F5;} -.laydate_body .laydate_chdown cite, .laydate_body .laydate_ym label{border-top-color:#C7E8F5;} -.laydate_body .laydate_chprev cite{border-right-style:solid; border-right-color:#C7E8F5;} -.laydate_body .laydate_chnext cite{border-left-style:solid; border-left-color:#C7E8F5;} -.laydate_body .laydate_table td{border:none; height:21px!important; line-height:21px!important; background-color:#50B5E0; color:#fff;} -.laydate_body .laydate_table .laydate_nothis{background:none;} -.laydate_body .laydate_table thead{height:21px!important; line-height:21px!important;} -.laydate_body .laydate_table thead th{} -.laydate_body .laydate_bottom{border-bottom:1px solid #34AADC; color:#fff;} -.laydate_body .laydate_bottom #laydate_hms{background-color:#50B5E0;} -.laydate_body .laydate_time{background-color:#2293C4;} -.laydate_body .laydate_bottom .laydate_sj{border-right:1px solid #50B5E0; background-color:#50B5E0; color:#fff;} -.laydate_body .laydate_bottom .laydte_hsmtex{border-bottom:1px solid #67BFE4; background-color:#2293C4;} -.laydate_body .laydate_bottom .laydate_btn{border-right:1px solid #34AADC;} -.laydate_body .laydate_bottom .laydate_v{color:#ccc} -.laydate_body .laydate_bottom .laydate_btn a{border-right:none; background-color:#50B5E0; color:#fff;} -.laydate_body .laydate_bottom .laydate_btn a:hover{background-color:#6BC0E4;} - -.laydate_body .laydate_m .laydate_yms span:hover, -.laydate_body .laydate_y .laydate_yms ul li:hover, -.laydate_body .laydate_table td:hover, -.laydate_body .laydate_time .laydate_hmsno span:hover{background-color:#87CBE9; color:#fff;} - - diff --git a/src/laydate.js b/src/laydate.js new file mode 100644 index 0000000..0c04177 --- /dev/null +++ b/src/laydate.js @@ -0,0 +1,2813 @@ + +/*! + * layDate 日期与时间组件(单独版) + * MIT Licensed + */ + + +/*! + * Layui + * Classic modular Front-End UI library + * MIT Licensed + */ + +;!function(win){ + "use strict"; + + var doc = win.document, config = { + modules: {} //记录模块物理路径 + ,status: {} //记录模块加载状态 + ,timeout: 10 //符合规范的模块请求最长等待秒数 + ,event: {} //记录模块自定义事件 + } + + ,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; + }(); + + 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; + } + + //添加事件 + 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; + } + + //执行事件回调 + layui.each(config.event[eventName], function(key, item){ + //执行当前模块的全部事件 + if(filterName === '{*}'){ + layui.each(item, callback); + return; + } + + //执行指定事件 + 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); + } + + //DOM构造器 + ,LAY = function(selector){ + var index = 0 + ,nativeDOM = typeof selector === 'object' ? [selector] : ( + this.selector = selector + ,document.querySelectorAll(selector || null) + ); + for(; index < nativeDOM.length; index++){ + this.push(nativeDOM[index]); + } + }; + + /* + lay 对象操作 + */ + + LAY.prototype = []; + LAY.prototype.constructor = LAY; + + //普通对象深度扩展 + lay.extend = function(){ + var ai = 1, args = arguments + ,clone = function(target, obj){ + target = target || (obj.constructor === Array ? [] : {}); + for(var i in obj){ + //如果值为对象,则进入递归,继续深度合并 + target[i] = (obj[i] && (obj[i].constructor === Object)) + ? clone(target[i], obj[i]) + : obj[i]; + } + return target; + } + + args[0] = typeof args[0] === 'object' ? args[0] : {}; + + for(; ai < args.length; ai++){ + if(typeof args[ai] === 'object'){ + clone(args[0], args[ai]) + } + } + 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 的标识 + ) : false; + }(); + + + + + + + /** + * 获取 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.digit = function(num, length, end){ + var str = ''; + num = String(num); + length = length || 2; + for(var i = num.length; i < length; i++){ + str += '0'; + } + return num < Math.pow(10, length) ? str + (num|0) : num; + }; + + //创建元素 + lay.elem = function(elemName, attr){ + var elem = document.createElement(elemName); + lay.each(attr || {}, function(key, value){ + elem.setAttribute(key, value); + }); + 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){ + str = str.replace(/\s+/, ' '); + new_str = new_str.replace(/\s+/, ' ').split(' '); + lay.each(new_str, function(ii, item){ + if(!new RegExp('\\b'+ item + '\\b').test(str)){ + str = str + ' ' + item; + } + }); + return str.replace(/^\s|\s$/, ''); + }; + + //移除值 + LAY.removeStr = function(str, new_str){ + str = str.replace(/\s+/, ' '); + new_str = new_str.replace(/\s+/, ' ').split(' '); + lay.each(new_str, function(ii, item){ + var exp = new RegExp('\\b'+ item + '\\b') + if(exp.test(str)){ + str = str.replace(exp, ''); + } + }); + return str.replace(/\s+/, ' ').replace(/^\s|\s$/, ''); + }; + + //查找子元素 + LAY.prototype.find = function(selector){ + var that = this; + var index = 0, arr = [] + ,isObject = typeof selector === 'object'; + + this.each(function(i, item){ + var nativeDOM = isObject ? item.contains(selector) : item.querySelectorAll(selector || null); + for(; index < nativeDOM.length; index++){ + arr.push(nativeDOM[index]); + } + that.shift(); + }); + + if(!isObject){ + that.selector = (that.selector ? that.selector + ' ' : '') + selector + } + + lay.each(arr, function(i, item){ + that.push(item); + }); + + return that; + }; + + //DOM遍历 + LAY.prototype.each = function(fn){ + return lay.each.call(this, this, fn); + }; + + //添加css类 + LAY.prototype.addClass = function(className, type){ + return this.each(function(index, item){ + item.className = LAY[type ? 'removeStr' : 'addStr'](item.className, className) + }); + }; + + //移除 css 类 + LAY.prototype.removeClass = function(className){ + return this.addClass(className, true); + }; + + //是否包含 css 类 + LAY.prototype.hasClass = function(className){ + var has = false; + this.each(function(index, item){ + if(new RegExp('\\b'+ className +'\\b').test(item.className)){ + has = true; + } + }); + 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; + return value === undefined ? function(){ + if(that.length > 0) return that[0].getAttribute(key); + }() : that.each(function(index, item){ + item.setAttribute(key, value); + }); + }; + + //移除属性 + LAY.prototype.removeAttr = function(key){ + return this.each(function(index, item){ + item.removeAttribute(key); + }); + }; + + //设置或获取 HTML 内容 + LAY.prototype.html = function(html){ + 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){ + var that = this; + return value === undefined ? function(){ + if(that.length > 0) return that[0].value; + }() : this.each(function(index, item){ + item.value = value; + }); + }; + + //追加内容 + LAY.prototype.append = function(elem){ + return this.each(function(index, item){ + typeof elem === 'object' + ? item.appendChild(elem) + : item.innerHTML = item.innerHTML + elem; + }); + }; + + //移除内容 + LAY.prototype.remove = function(elem){ + return this.each(function(index, item){ + elem ? item.removeChild(elem) : item.parentNode.removeChild(item); + }); + }; + + //事件绑定 + LAY.prototype.on = function(eventName, fn){ + return this.each(function(index, item){ + item.attachEvent ? item.attachEvent('on' + eventName, function(e){ + e.target = e.srcElement; + fn.call(item, e); + }) : item.addEventListener(eventName, fn, false); + }); + }; + + //解除事件 + LAY.prototype.off = function(eventName, fn){ + return this.each(function(index, item){ + item.detachEvent + ? item.detachEvent('on'+ eventName, fn) + : item.removeEventListener(eventName, fn, false); + }); + }; + + //暴露 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; + }; + + //默认配置 + Class.prototype.config = { + type: 'date' //控件类型,支持:year/month/date/time/datetime + ,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,则默认直接显示控件 + ,showBottom: true //是否显示底部栏 + ,isPreview: true //是否显示值预览 + ,btns: ['clear', 'now', 'confirm'] //右下角显示的按钮,会按照数组顺序排列 + ,lang: 'cn' //语言,只支持cn/en,即中文和英文 + ,theme: 'default' //主题 + ,position: null //控件定位方式定位, 默认absolute,支持:fixed/absolute/static + ,calendar: false //是否开启公历重要节日,仅支持中文版 + ,mark: {} //日期备注,如重要事件或活动标记 + ,zIndex: null //控件层叠顺序 + ,done: null //控件选择完毕后的回调,点击清空/现在/确定也均会触发 + ,change: null //日期时间改变后的回调 + }; + + //多语言 + Class.prototype.lang = function(){ + var that = this + ,options = that.config + ,text = { + 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' + } + ,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['cn']; + }; + + //初始准备 + Class.prototype.init = function(){ + var that = this + ,options = that.config + ,isStatic = options.position === 'static' + ,format = { + year: 'yyyy' + ,month: 'yyyy-MM' + ,date: 'yyyy-MM-dd' + ,time: 'HH:mm:ss' + ,datetime: 'yyyy-MM-dd HH:mm:ss' + }; + + options.elem = lay(options.elem); + options.eventElem = lay(options.eventElem); + + if(!options.elem[0]) return; + + //日期范围分隔符 + that.rangeStr = options.range ? (typeof options.range === 'string' ? options.range : '-') : ''; + + //若 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] || format.date; + } + + //将日期格式转化成数组 + that.format = thisModule.formatArr(options.format); + + //生成正则表达式 + that.EXP_IF = ''; + that.EXP_SPLIT = ''; + lay.each(that.format, function(i, item){ + var EXP = new RegExp(dateType).test(item) + ? '\\d{'+ function(){ + if(new RegExp(dateType).test(that.format[i === 0 ? i + 1 : i - 1]||'')){ + if(/^yyyy|y$/.test(item)) return 4; + return item.length; + } + if(/^yyyy$/.test(item)) return '1,4'; + if(/^y$/.test(item)) return '1,308'; + return '1,2'; + }() +'}' + : '\\' + item; + 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\\'+ that.rangeStr + '\\s' + that.EXP_IF + : that.EXP_IF + ) +'$'); + that.EXP_SPLIT = new RegExp('^'+ that.EXP_SPLIT +'$', ''); + + //如果不是input|textarea元素,则默认采用click事件 + if(!that.isInput(options.elem[0])){ + if(options.trigger === 'focus'){ + options.trigger = 'click'; + } + } + + //设置唯一KEY + if(!options.elem.attr('lay-key')){ + options.elem.attr('lay-key', that.index); + options.eventElem.attr('lay-key', that.index); + } + + //记录重要日期 + options.mark = lay.extend({}, (options.calendar && options.lang === 'cn') ? { + '0-1-1': '元旦' + ,'0-2-14': '情人' + ,'0-3-8': '妇女' + ,'0-3-12': '植树' + ,'0-4-1': '愚人' + ,'0-5-1': '劳动' + ,'0-5-4': '青年' + ,'0-6-1': '儿童' + ,'0-9-10': '教师' + ,'0-9-18': '国耻' + ,'0-10-1': '国庆' + ,'0-12-25': '圣诞' + } : {}, options.mark); + + //获取限制内日期 + lay.each(['min', 'max'], function(i, item){ + var ymd = [], hms = []; + if(typeof options[item] === 'number'){ //如果为数字 + var day = options[item] + ,time = new Date().getTime() + ,STAMP = 86400000 //代表一天的毫秒数 + ,thisDate = new Date( + day ? ( + day < STAMP ? time + day*STAMP : day //如果数字小于一天的毫秒数,则数字为天数,否则为毫秒数 + ) : time + ); + ymd = [thisDate.getFullYear(), thisDate.getMonth() + 1, thisDate.getDate()]; + day < STAMP || (hms = [thisDate.getHours(), thisDate.getMinutes(), thisDate.getSeconds()]); + } else { + ymd = (options[item].match(/\d+-\d+-\d+/) || [''])[0].split('-'); + hms = (options[item].match(/\d+:\d+:\d+/) || [''])[0].split(':'); + } + options[item] = { + year: ymd[0] | 0 || new Date().getFullYear() + ,month: ymd[1] ? (ymd[1] | 0) - 1 : new Date().getMonth() + ,date: ymd[2] | 0 || new Date().getDate() + ,hours: hms[0] | 0 + ,minutes: hms[1] | 0 + ,seconds: hms[2] | 0 + }; + }); + + that.elemID = 'layui-laydate'+ options.elem.attr('lay-key'); + + if(options.show || isStatic) that.render(); + isStatic || that.events(); + + //默认赋值 + if(options.value && options.isInitValue){ + if(options.value.constructor === Date){ + that.setValue(that.parse(0, that.systemDate(options.value))); + } else { + that.setValue(options.value); + } + } + }; + + //控件主体渲染 + Class.prototype.render = function(){ + var that = this + ,options = that.config + ,lang = that.lang() + ,isStatic = options.position === 'static' + + //主面板 + ,elem = that.elem = lay.elem('div', { + id: that.elemID + ,'class': [ + 'layui-laydate' + ,options.range ? ' layui-laydate-range' : '' + ,isStatic ? (' '+ ELEM_STATIC) : '' + ,options.theme && options.theme !== 'default' && !/^#/.test(options.theme) ? (' laydate-theme-' + options.theme) : '' + ].join('') + }) + + //主区域 + ,elemMain = that.elemMain = [] + ,elemHeader = that.elemHeader = [] + ,elemCont = that.elemCont = [] + ,elemTable = that.table = [] + + //底部区域 + ,divFooter = that.footer = lay.elem('div', { + 'class': ELEM_FOOTER + }); + + if(options.zIndex) elem.style.zIndex = options.zIndex; + + //单双日历区域 + lay.each(new Array(2), function(i){ + if(!options.range && i > 0){ + return true; + } + + //头部区域 + var divHeader = lay.elem('div', { + 'class': 'layui-laydate-header' + }) + + //左右切换 + ,headerChild = [function(){ //上一年 + var elem = lay.elem('i', { + 'class': 'layui-icon laydate-icon laydate-prev-y' + }); + elem.innerHTML = ''; + return elem; + }(), function(){ //上一月 + var elem = lay.elem('i', { + 'class': 'layui-icon laydate-icon laydate-prev-m' + }); + elem.innerHTML = ''; + return elem; + }(), function(){ //年月选择 + var elem = lay.elem('div', { + 'class': 'laydate-set-ym' + }), spanY = lay.elem('span'), spanM = lay.elem('span'); + elem.appendChild(spanY); + elem.appendChild(spanM); + return elem; + }(), function(){ //下一月 + var elem = lay.elem('i', { + 'class': 'layui-icon laydate-icon laydate-next-m' + }); + elem.innerHTML = ''; + return elem; + }(), function(){ //下一年 + var elem = lay.elem('i', { + 'class': 'layui-icon laydate-icon laydate-next-y' + }); + elem.innerHTML = ''; + return elem; + }()] + + //日历内容区域 + ,divContent = lay.elem('div', { + 'class': 'layui-laydate-content' + }) + ,table = lay.elem('table') + ,thead = lay.elem('thead'), theadTr = lay.elem('tr'); + + //生成年月选择 + lay.each(headerChild, function(i, item){ + divHeader.appendChild(item); + }); + + //生成表格 + thead.appendChild(theadTr); + lay.each(new Array(6), function(i){ //表体 + var tr = table.insertRow(0); + lay.each(new Array(7), function(j){ + if(i === 0){ + var th = lay.elem('th'); + th.innerHTML = lang.weeks[j]; + theadTr.appendChild(th); + } + tr.insertCell(j); + }); + }); + table.insertBefore(thead, table.children[0]); //表头 + divContent.appendChild(table); + + elemMain[i] = lay.elem('div', { + 'class': 'layui-laydate-main laydate-main-list-'+ i + }); + + elemMain[i].appendChild(divHeader); + elemMain[i].appendChild(divContent); + + elemHeader.push(headerChild); + elemCont.push(divContent); + elemTable.push(table); + }); + + //生成底部栏 + lay(divFooter).html(function(){ + var html = [], btns = []; + if(options.type === 'datetime'){ + 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 === 'cn' ? '重置' : 'Reset'; + btns.push(''+ title +''); + }); + html.push(''); + return html.join(''); + }()); + + //插入到主区域 + lay.each(elemMain, function(i, main){ + elem.appendChild(main); + }); + options.showBottom && elem.appendChild(divFooter); + + //生成自定义主题 + if(/^#/.test(options.theme)){ + var style = lay.elem('style') + ,styleText = [ + '#{{id}} .layui-laydate-header{background-color:{{theme}};}' + ,'#{{id}} .layui-this{background-color:{{theme}} !important;}' + ].join('').replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, options.theme); + + if('styleSheet' in style){ + style.setAttribute('type', 'text/css'); + style.styleSheet.cssText = styleText; + } else { + style.innerHTML = styleText; + } + + lay(elem).addClass('laydate-theme-molv'); + elem.appendChild(style); + } + + //记录当前执行的实例索引 + laydate.thisId = options.id; + + //移除上一个控件 + that.remove(Class.thisElemDate); + + //如果是静态定位,则插入到指定的容器中,否则,插入到body + isStatic ? options.elem.append(elem) : ( + document.body.appendChild(elem) + ,that.position() //定位 + ); + + that.checkDate().calendar(null, 0, 'init'); //初始校验 + that.changeEvent(); //日期切换 + + Class.thisElemDate = that.elemID; + + typeof options.ready === 'function' && options.ready(lay.extend({}, options.dateTime, { + month: options.dateTime.month + 1 + })); + + that.preview(); + }; + + //控件移除 + Class.prototype.remove = function(prev){ + 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; + }; + + //定位算法 + Class.prototype.position = function(){ + var that = this + ,options = that.config; + lay.position(that.bindElem || options.elem[0], that.elem, { + position: options.position + }); + return that; + }; + + //提示 + Class.prototype.hint = function(content){ + var that = this + ,options = that.config + ,div = lay.elem('div', { + 'class': ELEM_HINT + }); + + if(!that.elem) return; + + div.innerHTML = content || ''; + lay(that.elem).find('.'+ ELEM_HINT).remove(); + that.elem.appendChild(div); + + clearTimeout(that.hinTimer); + that.hinTimer = setTimeout(function(){ + lay(that.elem).find('.'+ ELEM_HINT).remove(); + }, 3000); + }; + + //获取递增/减后的年月 + Class.prototype.getAsYM = function(Y, M, type){ + type ? M-- : M++; + if(M < 0){ + M = 11; + Y--; + } + if(M > 11){ + M = 0; + Y++; + } + return [Y, M]; + }; + + //系统日期 + Class.prototype.systemDate = function(newDate){ + var thisDate = newDate || new Date(); + return { + year: thisDate.getFullYear() //年 + ,month: thisDate.getMonth() //月 + ,date: thisDate.getDate() //日 + ,hours: newDate ? newDate.getHours() : 0 //时 + ,minutes: newDate ? newDate.getMinutes() : 0 //分 + ,seconds: newDate ? newDate.getSeconds() : 0 //秒 + } + }; + + //日期校验 + Class.prototype.checkDate = function(fn){ + 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 = 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){ + if(dateTime.year > LIMIT_YEAR[1]) dateTime.year = LIMIT_YEAR[1], error = true; //不能超过20万年 + if(dateTime.month > 11) dateTime.month = 11, error = true; + if(dateTime.hours > 23) dateTime.hours = 0, error = true; + if(dateTime.minutes > 59) dateTime.minutes = 0, dateTime.hours++, error = true; + if(dateTime.seconds > 59) dateTime.seconds = 0, dateTime.minutes++, error = true; + + //计算当前月的最后一天 + thisMaxDate = laydate.getEndDate(dateTime.month + 1, dateTime.year); + if(dateTime.date > thisMaxDate) dateTime.date = thisMaxDate, error = true; + } + + //获得初始化日期值 + ,initDate = function(dateTime, value, index){ + var startEnd = ['startTime', 'endTime']; + value = (value.match(that.EXP_SPLIT) || []).slice(1); + index = index || 0; + + if(options.range){ + that[startEnd[index]] = that[startEnd[index]] || {}; + } + lay.each(that.format, function(i, item){ + var thisv = parseFloat(value[i]); + if(value[i].length < item.length) error = true; + if(/yyyy|y/.test(item)){ //年 + if(thisv < LIMIT_YEAR[0]) thisv = LIMIT_YEAR[0], error = true; //年不能低于100年 + dateTime.year = thisv; + } else if(/MM|M/.test(item)){ //月 + if(thisv < 1) thisv = 1, error = true; + dateTime.month = thisv - 1; + } else if(/dd|d/.test(item)){ //日 + if(thisv < 1) thisv = 1, error = true; + dateTime.date = thisv; + } else if(/HH|H/.test(item)){ //时 + if(thisv < 1) thisv = 0, error = true; + dateTime.hours = thisv; + options.range && (that[startEnd[index]].hours = thisv); + } else if(/mm|m/.test(item)){ //分 + if(thisv < 1) thisv = 0, error = true; + dateTime.minutes = thisv; + options.range && (that[startEnd[index]].minutes = thisv); + } else if(/ss|s/.test(item)){ //秒 + if(thisv < 1) thisv = 0, error = true; + dateTime.seconds = thisv; + options.range && (that[startEnd[index]].seconds = thisv); + } + }); + checkValid(dateTime); + }; + + if(fn === 'limit') return checkValid(dateTime), that; + + value = value || options.value; + if(typeof value === 'string'){ + value = value.replace(/\s+/g, ' ').replace(/^\s|\s$/g, ''); + } + + //如果开启范围,则计算结束日期 + 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(' '+ that.rangeStr +' '); + lay.each([options.dateTime, that.endDate], function(i, item){ + initDate(item, value[i], i); + }); + } else { + initDate(dateTime, value); + } + } else { + //格式不合法 + 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.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; + }; + + //公历重要日期与自定义备注 + Class.prototype.mark = function(td, YMD){ + var that = this + ,mark, options = that.config; + lay.each(options.mark, function(key, title){ + var keys = key.split('-'); + if((keys[0] == YMD[0] || keys[0] == 0) //每年的每月 + && (keys[1] == YMD[1] || keys[1] == 0) //每月的每日 + && keys[2] == YMD[2]){ //特定日 + mark = title || YMD[2]; + } + }); + mark && td.html(''+ mark +''); + + return that; + }; + + //无效日期范围的标记 + Class.prototype.limit = function(elem, date, index, time){ + var that = this + ,options = that.config, timestrap = {} + ,dateTime = options[index > 41 ? 'endDate' : 'dateTime'] + ,isOut, thisDateTime = lay.extend({}, dateTime, date || {}); + + lay.each({ + now: thisDateTime + ,min: options.min + ,max: options.max + }, function(key, item){ + timestrap[key] = that.newDate(lay.extend({ + year: item.year + ,month: item.month + ,date: item.date + }, function(){ + var hms = {}; + lay.each(time, function(i, keys){ + hms[keys] = item[keys]; + }); + return hms; + }())).getTime(); //time:是否比较时分秒 + }); + + isOut = timestrap.now < timestrap.min || timestrap.now > timestrap.max; + elem && elem[isOut ? 'addClass' : 'removeClass'](DISABLED); + return isOut; + }; + + //当前日期对象 + Class.prototype.thisDateTime = function(index){ + var that = this + ,options = that.config; + return index ? that.endDate: options.dateTime; + }; + + //日历表 + Class.prototype.calendar = function(value, index, type){ + var that = this + ,options = that.config + ,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' + ,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(lang.invalidDate); + if(dateTime.year > LIMIT_YEAR[1]) dateTime.year = LIMIT_YEAR[1], that.hint(lang.invalidDate); + + //记录初始值 + if(!that.firstDate){ + that.firstDate = lay.extend({}, dateTime); + } + + //计算当前月第一天的星期 + thisDate.setFullYear(dateTime.year, dateTime.month, 1); + startWeek = thisDate.getDay(); + + prevMaxDate = laydate.getEndDate(dateTime.month || 12, dateTime.year); //计算上个月的最后一天 + thisMaxDate = laydate.getEndDate(dateTime.month + 1, dateTime.year); //计算当前月的最后一天 + + //赋值日 + 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_; + item.addClass('laydate-day-prev'); + YMD = that.getAsYM(dateTime.year, dateTime.month, 'sub'); + } else if(index_ >= startWeek && index_ < thisMaxDate + startWeek){ + st = index_ - startWeek; + st + 1 === dateTime.date && item.addClass(THIS); + } else { + st = index_ - thisMaxDate - startWeek; + item.addClass('laydate-day-next'); + YMD = that.getAsYM(dateTime.year, dateTime.month); + } + YMD[1]++; + YMD[2] = st + 1; + item.attr('lay-ymd', YMD.join('-')).html(YMD[2]); + that.mark(item, YMD).limit(item, { + year: YMD[0] + ,month: YMD[1] - 1 + ,date: YMD[2] + }, 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 === '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(options.range){ + if(value){ + that.listYM = [ + [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); + } + } else { + that.listYM = [[dateTime.year, dateTime.month + 1]]; + that.list(options.type, 0); + } + } + + //初始赋值双日历 + 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']); + + //同步按钮可点状态 + that.setBtnStatus(); + + return that; + }; + + //生成年月时分秒列表 + Class.prototype.list = function(type, index){ + var that = this + ,options = that.config + ,dateTime = options.dateTime + ,lang = that.lang() + ,isAlone = options.range && options.type !== 'date' && options.type !== 'datetime' //独立范围选择器 + + ,ul = lay.elem('ul', { + 'class': ELEM_LIST + ' ' + ({ + year: 'laydate-year-list' + ,month: 'laydate-month-list' + ,time: 'laydate-time-list' + })[type] + }) + ,elemHeader = that.elemHeader[index] + ,elemYM = lay(elemHeader[2]).find('span') + ,elemCont = that.elemCont[index || 0] + ,haveList = lay(elemCont).find('.'+ ELEM_LIST)[0] + ,isCN = options.lang === 'cn' + ,text = isCN ? '年' : '' + + ,listYM = that.listYM[index] || {} + ,hms = ['hours', 'minutes', 'seconds'] + ,startEnd = ['startTime', 'endTime'][index]; + + if(listYM[0] < 1) listYM[0] = 1; + + //生成年列表 + if(type === 'year'){ + var yearNum, startY = yearNum = listYM[0] - 7; + if(startY < 1) startY = yearNum = 1; + lay.each(new Array(15), function(i){ + var li = lay.elem('li', { + 'lay-ym': yearNum + }), ymd = {year: yearNum}; + yearNum == listYM[0] && lay(li).addClass(THIS); + li.innerHTML = yearNum + text; + ul.appendChild(li); + if(yearNum < that.firstDate.year){ + ymd.month = options.min.month; + ymd.date = options.min.date; + } else if(yearNum >= that.firstDate.year){ + ymd.month = options.max.month; + ymd.date = options.max.date; + } + that.limit(lay(li), ymd, index); + yearNum++; + }); + lay(elemYM[isCN ? 0 : 1]).attr('lay-ym', (yearNum - 8) + '-' + listYM[1]) + .html((startY + text) + ' - ' + (yearNum - 1 + text)); + } + + //生成月列表 + else if(type === 'month'){ + lay.each(new Array(12), function(i){ + var li = lay.elem('li', { + 'lay-ym': i + }), ymd = {year: listYM[0], month: i}; + i + 1 == listYM[1] && lay(li).addClass(THIS); + li.innerHTML = lang.month[i] + (isCN ? '月' : ''); + ul.appendChild(li); + if(listYM[0] < that.firstDate.year){ + ymd.date = options.min.date; + } else if(listYM[0] >= that.firstDate.year){ + ymd.date = options.max.date; + } + that.limit(lay(li), ymd, index); + }); + lay(elemYM[isCN ? 0 : 1]).attr('lay-ym', listYM[0] + '-' + listYM[1]) + .html(listYM[0] + text); + } + + //生成时间列表 + else if(type === 'time'){ + //检测时分秒状态是否在有效日期时间范围内 + var setTimeStatus = function(){ + lay(ul).find('ol').each(function(i, ol){ + lay(ol).find('li').each(function(ii, li){ + that.limit(lay(li), [{ + hours: ii + }, { + hours: that[startEnd].hours + ,minutes: ii + }, { + hours: that[startEnd].hours + ,minutes: that[startEnd].minutes + ,seconds: ii + }][i], index, [['hours'], ['hours', 'minutes'], ['hours', 'minutes', 'seconds']][i]); + }); + }); + if(!options.range) that.limit(lay(that.footer).find(ELEM_CONFIRM), that[startEnd], 0, ['hours', 'minutes', 'seconds']); + }; + + //初始化时间对象 + if(options.range){ + 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){ + childUL.push(''+ lay.digit(ii, 2) +''); + }); + li.innerHTML = childUL.join('') + '
        '; + ul.appendChild(li); + }); + setTimeStatus(); + } + + //插入容器 + if(haveList) elemCont.removeChild(haveList); + elemCont.appendChild(ul); + + //年月面板 - 选择事件 + if(type === 'year' || type === 'month'){ + //显示切换箭头 + lay(that.elemMain[index]).addClass('laydate-ym-show'); + + //选中 + lay(ul).find('li').on('click', function(){ + var ym = lay(this).attr('lay-ym') | 0; + if(lay(this).hasClass(DISABLED)) return; + + if(index === 0){ + dateTime[type] = ym; + that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0); + } else { //范围选择 + that.endDate[type] = ym; + } + + //当为年选择器或者年月选择器 + 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 && ((index ? that.endDate : dateTime).year = ym); + that.list('month', index); + } + } else { + that.checkDate('limit').calendar(null, index); + that.closeList(); + } + + that.setBtnStatus(); //同步按钮可点状态 + + //若为月选择器,只有当选择月份时才自动关闭; + //若为年选择器,选择年份即自动关闭 + //且在范围未开启时 + 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 { //时间选择面板 - 选择事件 + var span = lay.elem('span', { + 'class': ELEM_TIME_TEXT + }) + + //滚动条定位 + ,scroll = function(){ + lay(ul).find('ol').each(function(i){ + var ol = this + ,li = lay(ol).find('li') + ol.scrollTop = 30*(that[startEnd][hms[i]] - 2); + if(ol.scrollTop <= 0){ + li.each(function(ii, item){ + if(!lay(this).hasClass(DISABLED)){ + ol.scrollTop = 30*(ii - 2); + return true; + } + }); + } + }); + } + ,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); + + lay(ul).find('ol').each(function(i){ + var ol = this; + //选择时分秒 + 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 { + dateTime[hms[i]] = value; + } + lay(ol).find('.'+ THIS).removeClass(THIS); + lay(this).addClass(THIS); + + setTimeStatus(); + scroll(); + (that.endDate || options.type === 'time') && that.done(null, 'change'); + + //同步按钮可点状态 + that.setBtnStatus(); + }); + }); + } + + return that; + }; + + //记录列表切换后的年月 + Class.prototype.listYM = []; + + //关闭列表 + Class.prototype.closeList = function(){ + var that = this + ,options = that.config; + + lay.each(that.elemCont, function(index, item){ + lay(this).find('.'+ ELEM_LIST).remove(); + lay(that.elemMain[index]).removeClass('laydate-ym-show laydate-time-show'); + }); + lay(that.elem).find('.'+ ELEM_TIME_TEXT).remove(); + }; + + //检测结束日期是否超出开始日期 + Class.prototype.setBtnStatus = function(tips, start, end){ + var that = this + ,options = that.config + ,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(); + + //如果不在有效日期内,直接禁用按钮,否则比较开始和结束日期 + (that.limit(null, start) || that.limit(null, end)) + ? elemBtn.addClass(DISABLED) + : elemBtn[isOut ? 'addClass' : 'removeClass'](DISABLED); + + //是否异常提示 + if(tips && isOut) that.hint( + typeof tips === 'string' ? lang.timeout.replace(/日期/g, tips) : lang.timeout + ); + } + }; + + //转义为规定格式的日期字符 + Class.prototype.parse = function(state, date){ + var that = this + ,options = that.config + ,dateTime = date || (state == 'end' + ? lay.extend({}, that.endDate, that.endTime) + : (options.range ? lay.extend({}, options.dateTime, that.startTime) : options.dateTime)) + ,format = laydate.parse(dateTime, that.format, 1); + + //返回日期范围字符 + if(options.range && state === undefined){ + return format + ' '+ that.rangeStr +' ' + that.parse('end'); + } + + return format; + }; + + //创建指定日期时间对象 + Class.prototype.newDate = function(dateTime){ + dateTime = dateTime || {}; + return new Date( + dateTime.year || 1 + ,dateTime.month || 0 + ,dateTime.date || 1 + ,dateTime.hours || 0 + ,dateTime.minutes || 0 + ,dateTime.seconds || 0 + ); + }; + + //赋值 + Class.prototype.setValue = function(value){ + var that = this + ,options = that.config + ,elem = that.bindElem || options.elem[0]; + + //静态展现则不作默认赋值 + 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.preview = function(){ + var that = this + ,options = that.config; + + if(!options.isPreview) return; + + var elemPreview = lay(that.elem).find('.'+ ELEM_PREVIEW) + ,value = options.range ? (that.endDate ? that.parse() : '') : that.parse(); + + //显示预览 + elemPreview.html(value).css({ + 'color': '#5FB878' + ,'font-size': '14px;' + }); + setTimeout(function(){ + elemPreview.css({ + 'color': '#666' + ,'font-size': '12px;' + }); + }, 300); + }; + + //执行 done/change 回调 + Class.prototype.done = function(param, type){ + var that = this + ,options = that.config + ,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){ + if(!('month' in item)) return; + lay.extend(item, { + month: item.month + 1 + }); + }); + + that.preview(); + + param = param || [that.parse(), start, end]; + typeof options[type || 'done'] === 'function' && options[type || 'done'].apply(options, param); + + return that; + }; + + //选择日期 + Class.prototype.choose = function(td, index){ + var that = this + ,options = that.config + ,dateTime = that.thisDateTime(index) + + ,tds = lay(that.elem).find('td') + ,YMD = td.attr('lay-ymd').split('-'); + + YMD = { + year: YMD[0] | 0 + ,month: (YMD[1] | 0) - 1 + ,date: YMD[2] | 0 + }; + + 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 + ,minutes: 0 + ,seconds: 0 + }; + }); + that.calendar(null, index).done(null, 'change'); + } else if(options.position === 'static'){ //直接嵌套的选中 + that.calendar().done().done(null, 'change'); //同时执行 done 和 change 回调 + } else if(options.type === 'date'){ + that.setValue(that.parse()).remove().done(); + } else if(options.type === 'datetime'){ + that.calendar().done(null, 'change'); + } + }; + + //底部按钮 + Class.prototype.tool = function(btn, type){ + var that = this + ,options = that.config + ,lang = that.lang() + ,dateTime = options.dateTime + ,isStatic = options.position === 'static' + ,active = { + //选择时间 + datetime: function(){ + if(lay(btn).hasClass(DISABLED)) return; + that.list('time', 0); + options.range && that.list('time', 1); + lay(btn).attr('lay-type', 'date').html(that.lang().dateTips); + } + + //选择日期 + ,date: function(){ + that.closeList(); + lay(btn).attr('lay-type', 'datetime').html(that.lang().timeTips); + } + + //清空、重置 + ,clear: function(){ + isStatic && ( + lay.extend(dateTime, that.firstDate) + ,that.calendar() + ) + options.range && ( + delete options.dateTime + ,delete that.endDate + ,delete that.startTime + ,delete that.endTime + ); + that.setValue('').remove(); + that.done(['', {}, {}]); + } + + //现在 + ,now: function(){ + var thisDate = new Date(); + lay.extend(dateTime, that.systemDate(), { + hours: thisDate.getHours() + ,minutes: thisDate.getMinutes() + ,seconds: thisDate.getSeconds() + }); + that.setValue(that.parse()).remove(); + isStatic && that.calendar(); + that.done(); + } + + //确定 + ,confirm: function(){ + if(options.range){ + if(lay(btn).hasClass(DISABLED)) return that.hint( + options.type === 'time' ? lang.timeout.replace(/日期/g, '时间') : lang.timeout + ); + } else { + if(lay(btn).hasClass(DISABLED)) return that.hint(lang.invalidDate); + } + that.done(); + that.setValue(that.parse()).remove() + } + }; + active[type] && active[type](); + }; + + //统一切换处理 + Class.prototype.change = function(index){ + var that = this + ,options = that.config + ,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 isYear = lay(elemCont).find('.laydate-year-list')[0] + ,isMonth = lay(elemCont).find('.laydate-month-list')[0]; + + //切换年列表 + if(isYear){ + listYM[0] = type ? listYM[0] - 15 : listYM[0] + 15; + that.list('year', index); + } + + if(isMonth){ //切换月面板中的年 + type ? listYM[0]-- : listYM[0]++; + that.list('month', index); + } + + if(isYear || isMonth){ + lay.extend(dateTime, { + year: listYM[0] + }); + 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; + }; + + return { + prevYear: function(){ + if(addSubYeay('sub')) return; + dateTime.year--; + that.checkDate('limit').calendar(null, index); + that.done(null, 'change'); + } + ,prevMonth: function(){ + var YM = that.getAsYM(dateTime.year, dateTime.month, 'sub'); + lay.extend(dateTime, { + year: YM[0] + ,month: YM[1] + }); + that.checkDate('limit').calendar(null, index); + that.done(null, 'change'); + } + ,nextMonth: function(){ + var YM = that.getAsYM(dateTime.year, dateTime.month); + lay.extend(dateTime, { + year: YM[0] + ,month: YM[1] + }); + that.checkDate('limit').calendar(null, index); + that.done(null, 'change'); + } + ,nextYear: function(){ + if(addSubYeay()) return; + dateTime.year++ + that.checkDate('limit').calendar(null, index); + that.done(null, 'change'); + } + }; + }; + + //日期切换事件 + Class.prototype.changeEvent = function(){ + var that = this + ,options = that.config; + + //日期选择事件 + lay(that.elem).on('click', function(e){ + lay.stope(e); + }).on('mousedown', function(e){ + lay.stope(e); + }); + + //年月切换 + lay.each(that.elemHeader, function(i, header){ + //上一年 + lay(header[0]).on('click', function(e){ + that.change(i).prevYear(); + }); + + //上一月 + lay(header[1]).on('click', function(e){ + that.change(i).prevMonth(); + }); + + //选择年月 + lay(header[2]).find('span').on('click', function(e){ + var othis = lay(this) + ,layYM = othis.attr('lay-ym') + ,layType = othis.attr('lay-type'); + + if(!layYM) return; + + layYM = layYM.split('-'); + + that.listYM[i] = [layYM[0] | 0, layYM[1] | 0]; + that.list(layType, i); + lay(that.footer).find('.'+ ELEM_TIME_BTN).addClass(DISABLED); + }); + + //下一月 + lay(header[3]).on('click', function(e){ + that.change(i).nextMonth(); + }); + + //下一年 + lay(header[4]).on('click', function(e){ + that.change(i).nextYear(); + }); + }); + + //点击日期 + lay.each(that.table, function(i, table){ + var tds = lay(table).find('td'); + tds.on('click', function(){ + that.choose(lay(this), i); + }); + }); + + //点击底部按钮 + lay(that.footer).find('span').on('click', function(){ + var type = lay(this).attr('lay-type'); + that.tool(this, type); + }); + }; + + //是否输入框 + Class.prototype.isInput = function(elem){ + return /input|textarea/.test(elem.tagName.toLocaleLowerCase()); + }; + + //绑定的元素事件处理 + Class.prototype.events = function(){ + var that = this + ,options = that.config + + //绑定呼出控件事件 + ,showEvent = function(elem, bind){ + elem.on(options.trigger, function(){ + bind && (that.bindElem = this); + that.render(); + }); + }; + + if(!options.elem[0] || options.elem[0].eventHandler) return; + + 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('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.thisElemDate){ + e.preventDefault(); + lay(that.footer).find(ELEM_CONFIRM)[0].click(); + } + } + }); + + //自适应定位 + 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(); + }); + }; + + //核心接口 + laydate.render = function(options){ + var inst = new Class(options); + 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(''); + }; + + //得到某月的最后一天 + laydate.getEndDate = function(month, year){ + var thisDate = new Date(); + //设置日期为下个月的第一天 + thisDate.setFullYear( + year || thisDate.getFullYear() + ,month || (thisDate.getMonth() + 1) + ,1); + //减去一天,得到当前月最后一天 + return new Date(thisDate.getTime() - 1000*60*60*24).getDate(); + }; + + //加载方式 + isLayui ? ( + laydate.ready() + ,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 加载 + ready.run(lay); + return laydate; + }) : function(){ //普通 script 标签加载 + laydate.ready(); + ready.run(window.lay); + window.laydate = laydate; + }() + ); + +}(window, window.document); + diff --git a/src/theme/default/font/iconfont.eot b/src/theme/default/font/iconfont.eot new file mode 100644 index 0000000..c861caa Binary files /dev/null and b/src/theme/default/font/iconfont.eot differ diff --git a/src/theme/default/font/iconfont.svg b/src/theme/default/font/iconfont.svg new file mode 100644 index 0000000..1e04218 --- /dev/null +++ b/src/theme/default/font/iconfont.svg @@ -0,0 +1,45 @@ + + + + + +Created by iconfont + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/theme/default/font/iconfont.ttf b/src/theme/default/font/iconfont.ttf new file mode 100644 index 0000000..0bd6c4a Binary files /dev/null and b/src/theme/default/font/iconfont.ttf differ diff --git a/src/theme/default/font/iconfont.woff b/src/theme/default/font/iconfont.woff new file mode 100644 index 0000000..bfe5599 Binary files /dev/null and b/src/theme/default/font/iconfont.woff differ diff --git a/src/theme/default/laydate.css b/src/theme/default/laydate.css new file mode 100644 index 0000000..63b4497 --- /dev/null +++ b/src/theme/default/laydate.css @@ -0,0 +1,169 @@ +/** 图标字体 **/ +@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: 272px;} +.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:30px; padding: 10px 70px 5px;} +.layui-laydate-header *{display: inline-block; vertical-align: bottom;} +.layui-laydate-header i{position: absolute; top: 10px; padding: 0 5px; color: #999; font-size: 18px; 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 10px; cursor: pointer;} +.laydate-time-text{cursor: default !important;} + +/* 主体结构 */ +.layui-laydate-content{position: relative; padding: 10px; -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: 46px; line-height: 26px; padding: 10px;} +.layui-laydate-footer span{display: inline-block; vertical-align: top; height: 26px; line-height: 24px; 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: #5FB878;} +.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: 10px; top: 10px;} +.laydate-footer-btns span{margin: 0 0 0 -1px;} + +/* 年月列表 */ +.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: 33px; 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: #5FB878;} +.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: #B5FFF8;} +.laydate-selected:hover{background-color: #00F7DE !important;} +.layui-laydate-content td:hover, +.layui-laydate-list li:hover{background-color: #eee; 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: #5FB878;} +.layui-laydate-content td.layui-this .laydate-day-mark::after{display: none;} +.layui-laydate-footer span[lay-type="date"]{color: #5FB878;} +.layui-laydate .layui-this{background-color: #009688 !important; color: #fff !important;} +.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/test/demo1.html b/test/demo1.html deleted file mode 100644 index 4fdc3be..0000000 --- a/test/demo1.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Demo1 - - - - -
        -
        - 方本框: -
        - -
        - 按钮触发: -
        - - -
        - -
        - -
        - 直接传dom: -
        - - - - - - \ No newline at end of file diff --git a/test/demo2.html b/test/demo2.html deleted file mode 100644 index f23889a..0000000 --- a/test/demo2.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Demo2 for Seajs - - -
        - - - - - - - - - \ No newline at end of file diff --git a/test/demo2.js b/test/demo2.js deleted file mode 100644 index 216b946..0000000 --- a/test/demo2.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function(){ - 'use strict'; - - laydate({ - elem: '#J-xl' - }); -}); \ No newline at end of file diff --git a/test/test.url b/test/test.url new file mode 100644 index 0000000..8587d37 --- /dev/null +++ b/test/test.url @@ -0,0 +1,6 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,2 +[InternetShortcut] +URL=http://www.layui.com/laydate/ +IDList= +HotKey=0