laydate.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. /**
  2. @Name : layDate v1.1 日期控件
  3. @Author: 贤心
  4. @Date: 2014-06-25
  5. @QQ群:176047195
  6. @Site:http://sentsin.com/layui/laydate
  7. */
  8. ;!
  9. function(a) {
  10. var b = {
  11. path: "",
  12. defSkin: "default",
  13. format: "YYYY-MM-DD",
  14. min: "1900-01-01 00:00:00",
  15. max: "2099-12-31 23:59:59",
  16. isv: !1
  17. },
  18. c = {},
  19. d = document,
  20. e = "createElement",
  21. f = "getElementById",
  22. g = "getElementsByTagName",
  23. h = ["laydate_box", "laydate_void", "laydate_click", "LayDateSkin", "skins/", "/laydate.css"];
  24. a.laydate = function(b) {
  25. b = b || {};
  26. try {
  27. h.event = a.event ? a.event: laydate.caller.arguments[0]
  28. } catch(d) {}
  29. return c.run(b),
  30. laydate
  31. },
  32. laydate.v = "1.1",
  33. c.getPath = function() {
  34. var a = document.scripts,
  35. c = a[a.length - 1].src;
  36. return b.path ? b.path: c.substring(0, c.lastIndexOf("/") + 1)
  37. } (),
  38. c.use = function(a, b) {
  39. var f = d[e]("link");
  40. f.type = "text/css",
  41. f.rel = "stylesheet",
  42. f.href = c.getPath + a + h[5],
  43. b && (f.id = b),
  44. d[g]("head")[0].appendChild(f),
  45. f = null
  46. },
  47. c.trim = function(a) {
  48. return a = a || "",
  49. a.replace(/^\s|\s$/g, "").replace(/\s+/g, " ")
  50. },
  51. c.digit = function(a) {
  52. return 10 > a ? "0" + (0 | a) : a
  53. },
  54. c.stopmp = function(b) {
  55. return b = b || a.event,
  56. b.stopPropagation ? b.stopPropagation() : b.cancelBubble = !0,
  57. this
  58. },
  59. c.each = function(a, b) {
  60. for (var c = 0,
  61. d = a.length; d > c && b(c, a[c]) !== !1; c++);
  62. },
  63. c.hasClass = function(a, b) {
  64. return a = a || {},
  65. new RegExp("\\b" + b + "\\b").test(a.className)
  66. },
  67. c.addClass = function(a, b) {
  68. return a = a || {},
  69. c.hasClass(a, b) || (a.className += " " + b),
  70. a.className = c.trim(a.className),
  71. this
  72. },
  73. c.removeClass = function(a, b) {
  74. if (a = a || {},
  75. c.hasClass(a, b)) {
  76. var d = new RegExp("\\b" + b + "\\b");
  77. a.className = a.className.replace(d, "")
  78. }
  79. return this
  80. },
  81. c.removeCssAttr = function(a, b) {
  82. var c = a.style;
  83. c.removeProperty ? c.removeProperty(b) : c.removeAttribute(b)
  84. },
  85. c.shde = function(a, b) {
  86. a.style.display = b ? "none": "block"
  87. },
  88. c.query = function(a) {
  89. var e, b, h, i, j;
  90. return a = c.trim(a).split(" "),
  91. b = d[f](a[0].substr(1)),
  92. 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,
  93. function(a, b) {
  94. j.test(b.className) && e.push(b)
  95. }), e[0] ? e: "") : (e = b[g](a[1]), e[0] ? b[g](a[1]) : "") : b: void 0
  96. },
  97. c.on = function(b, d, e) {
  98. return b.attachEvent ? b.attachEvent("on" + d,
  99. function() {
  100. e.call(b, a.even)
  101. }) : b.addEventListener(d, e, !1),
  102. c
  103. },
  104. c.stopMosup = function(a, b) {
  105. "mouseup" !== a && c.on(b, "mouseup",
  106. function(a) {
  107. c.stopmp(a)
  108. })
  109. },
  110. c.run = function(a) {
  111. var d, e, g, b = c.query,
  112. f = h.event;
  113. try {
  114. g = f.target || f.srcElement || {}
  115. } catch(i) {
  116. g = {}
  117. }
  118. if (d = a.elem ? b(a.elem) : g, f && g.tagName) {
  119. if (!d || d === c.elem) return;
  120. c.stopMosup(f.type, d),
  121. c.stopmp(f),
  122. c.view(d, a),
  123. c.reshow()
  124. } else e = a.event || "click",
  125. c.each((0 | d.length) > 0 ? d: [d],
  126. function(b, d) {
  127. c.stopMosup(e, d),
  128. c.on(d, e,
  129. function(b) {
  130. c.stopmp(b),
  131. d !== c.elem && (c.view(d, a), c.reshow())
  132. })
  133. })
  134. },
  135. c.scroll = function(a) {
  136. return a = a ? "scrollLeft": "scrollTop",
  137. d.body[a] | d.documentElement[a]
  138. },
  139. c.winarea = function(a) {
  140. return document.documentElement[a ? "clientWidth": "clientHeight"]
  141. },
  142. c.isleap = function(a) {
  143. return 0 === a % 4 && 0 !== a % 100 || 0 === a % 400
  144. },
  145. c.checkVoid = function(a, b, d) {
  146. var e = [];
  147. return a = 0 | a,
  148. b = 0 | b,
  149. d = 0 | d,
  150. a < c.mins[0] ? e = ["y"] : a > c.maxs[0] ? e = ["y", 1] : a >= c.mins[0] && a <= c.maxs[0] && (a == c.mins[0] && (b < c.mins[1] ? e = ["m"] : b == c.mins[1] && d < c.mins[2] && (e = ["d"])), a == c.maxs[0] && (b > c.maxs[1] ? e = ["m", 1] : b == c.maxs[1] && d > c.maxs[2] && (e = ["d", 1]))),
  151. e
  152. },
  153. c.timeVoid = function(a, b) {
  154. if (c.ymd[1] + 1 == c.mins[1] && c.ymd[2] == c.mins[2]) {
  155. if (0 === b && a < c.mins[3]) return 1;
  156. if (1 === b && a < c.mins[4]) return 1;
  157. if (2 === b && a < c.mins[5]) return 1
  158. } else if (c.ymd[1] + 1 == c.maxs[1] && c.ymd[2] == c.maxs[2]) {
  159. if (0 === b && a > c.maxs[3]) return 1;
  160. if (1 === b && a > c.maxs[4]) return 1;
  161. if (2 === b && a > c.maxs[5]) return 1
  162. }
  163. return a > (b ? 59 : 23) ? 1 : void 0
  164. },
  165. c.check = function() {
  166. var a = c.options.format.replace(/YYYY|MM|DD|hh|mm|ss/g, "\\d+\\").replace(/\\$/g, ""),
  167. b = new RegExp(a),
  168. d = c.elem[h.elemv],
  169. e = d.match(/\d+/g) || [],
  170. f = c.checkVoid(e[0], e[1], e[2]);
  171. if ("" !== d.replace(/\s/g, "")) {
  172. if (!b.test(d)) return c.elem[h.elemv] = "",
  173. c.msg("日期不符合格式,请重新选择。"),
  174. 1;
  175. if (f[0]) return c.elem[h.elemv] = "",
  176. c.msg("日期不在有效期内,请重新选择。"),
  177. 1;
  178. f.value = c.elem[h.elemv].match(b).join(),
  179. e = f.value.match(/\d+/g),
  180. 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),
  181. 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),
  182. 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)),
  183. 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)
  184. }
  185. },
  186. c.months = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
  187. c.viewDate = function(a, b, d) {
  188. var f = (c.query, {}),
  189. g = new Date;
  190. a < (0 | c.mins[0]) && (a = 0 | c.mins[0]),
  191. a > (0 | c.maxs[0]) && (a = 0 | c.maxs[0]),
  192. g.setFullYear(a, b, d),
  193. f.ymd = [g.getFullYear(), g.getMonth(), g.getDate()],
  194. c.months[1] = c.isleap(f.ymd[0]) ? 29 : 28,
  195. g.setFullYear(f.ymd[0], f.ymd[1], 1),
  196. f.FDay = g.getDay(),
  197. f.PDay = c.months[0 === b ? 11 : b - 1] - f.FDay + 1,
  198. f.NDay = 1,
  199. c.each(h.tds,
  200. function(a, b) {
  201. var g, d = f.ymd[0],
  202. e = f.ymd[1] + 1;
  203. b.className = "",
  204. a < f.FDay ? (b.innerHTML = g = a + f.PDay, c.addClass(b, "laydate_nothis"), 1 === e && (d -= 1), e = 1 === e ? 12 : e - 1) : a >= f.FDay && a < f.FDay + c.months[f.ymd[1]] ? (b.innerHTML = g = a - f.FDay + 1, a - f.FDay + 1 === f.ymd[2] && (c.addClass(b, h[2]), f.thisDay = b)) : (b.innerHTML = g = f.NDay++, c.addClass(b, "laydate_nothis"), 12 === e && (d += 1), e = 12 === e ? 1 : e + 1),
  205. c.checkVoid(d, e, g)[0] && c.addClass(b, h[1]),
  206. c.options.festival && c.festival(b, e + "." + g),
  207. b.setAttribute("y", d),
  208. b.setAttribute("m", e),
  209. b.setAttribute("d", g),
  210. d = e = g = null
  211. }),
  212. c.valid = !c.hasClass(f.thisDay, h[1]),
  213. c.ymd = f.ymd,
  214. h.year.value = c.ymd[0],
  215. h.month.value = c.digit(c.ymd[1] + 1),
  216. c.each(h.mms,
  217. function(a, b) {
  218. var d = c.checkVoid(c.ymd[0], (0 | b.getAttribute("m")) + 1);
  219. "y" === d[0] || "m" === d[0] ? c.addClass(b, h[1]) : c.removeClass(b, h[1]),
  220. c.removeClass(b, h[2]),
  221. d = null
  222. }),
  223. c.addClass(h.mms[c.ymd[1]], h[2]),
  224. f.times = [0 | c.inymd[3] || 0, 0 | c.inymd[4] || 0, 0 | c.inymd[5] || 0],
  225. c.each(new Array(3),
  226. function(a) {
  227. c.hmsin[a].value = c.digit(c.timeVoid(f.times[a], a) ? 0 | c.mins[a + 3] : 0 | f.times[a])
  228. }),
  229. c[c.valid ? "removeClass": "addClass"](h.ok, h[1])
  230. },
  231. c.festival = function(a, b) {
  232. var c;
  233. switch (b) {
  234. case "1.1":
  235. c = "元旦";
  236. break;
  237. case "3.8":
  238. c = "妇女";
  239. break;
  240. case "4.5":
  241. c = "清明";
  242. break;
  243. case "5.1":
  244. c = "劳动";
  245. break;
  246. case "6.1":
  247. c = "儿童";
  248. break;
  249. case "9.10":
  250. c = "教师";
  251. break;
  252. case "10.1":
  253. c = "国庆"
  254. }
  255. c && (a.innerHTML = c),
  256. c = null
  257. },
  258. c.viewYears = function(a) {
  259. var b = c.query,
  260. d = "";
  261. c.each(new Array(14),
  262. function(b) {
  263. d += 7 === b ? "<li " + (parseInt(h.year.value) === a ? 'class="' + h[2] + '"': "") + ' y="' + a + '">' + a + "</li>": '<li y="' + (a - 7 + b) + '">' + (a - 7 + b) + "</li>"
  264. }),
  265. b("#laydate_ys").innerHTML = d,
  266. c.each(b("#laydate_ys li"),
  267. function(a, b) {
  268. "y" === c.checkVoid(b.getAttribute("y"))[0] ? c.addClass(b, h[1]) : c.on(b, "click",
  269. function(a) {
  270. c.stopmp(a).reshow(),
  271. c.viewDate(0 | this.getAttribute("y"), c.ymd[1], c.ymd[2])
  272. })
  273. })
  274. },
  275. c.initDate = function() {
  276. var d = (c.query, new Date),
  277. e = c.elem[h.elemv].match(/\d+/g) || [];
  278. e.length < 3 && (e = c.options.start.match(/\d+/g) || [], e.length < 3 && (e = [d.getFullYear(), d.getMonth() + 1, d.getDate()])),
  279. c.inymd = e,
  280. c.viewDate(e[0], e[1] - 1, e[2])
  281. },
  282. c.iswrite = function() {
  283. var a = c.query,
  284. b = {
  285. time: a("#laydate_hms")
  286. };
  287. c.shde(b.time, !c.options.istime),
  288. c.shde(h.oclear, !("isclear" in c.options ? c.options.isclear: 1)),
  289. c.shde(h.otoday, !("istoday" in c.options ? c.options.istoday: 1)),
  290. c.shde(h.ok, !("issure" in c.options ? c.options.issure: 1))
  291. },
  292. c.orien = function(a, b) {
  293. var d, e = c.elem.getBoundingClientRect();
  294. a.style.left = e.left + (b ? 0 : c.scroll(1)) + "px",
  295. 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,
  296. a.style.top = d + (b ? 0 : c.scroll()) + "px"
  297. },
  298. c.follow = function(a) {
  299. c.options.fixed ? (a.style.position = "fixed", c.orien(a, 1)) : (a.style.position = "absolute", c.orien(a))
  300. },
  301. c.viewtb = function() {
  302. var a, b = [],
  303. f = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  304. h = {},
  305. i = d[e]("table"),
  306. j = d[e]("thead");
  307. return j.appendChild(d[e]("tr")),
  308. h.creath = function(a) {
  309. var b = d[e]("th");
  310. b.innerHTML = f[a],
  311. j[g]("tr")[0].appendChild(b),
  312. b = null
  313. },
  314. c.each(new Array(6),
  315. function(d) {
  316. b.push([]),
  317. a = i.insertRow(0),
  318. c.each(new Array(7),
  319. function(c) {
  320. b[d][c] = 0,
  321. 0 === d && h.creath(c),
  322. a.insertCell(c)
  323. })
  324. }),
  325. i.insertBefore(j, i.children[0]),
  326. i.id = i.className = "laydate_table",
  327. a = b = null,
  328. i.outerHTML
  329. } (),
  330. c.view = function(a, f) {
  331. var i, g = c.query,
  332. j = {};
  333. f = f || a,
  334. c.elem = a,
  335. c.options = f,
  336. c.options.format || (c.options.format = b.format),
  337. c.options.start = c.options.start || "",
  338. c.mm = j.mm = [c.options.min || b.min, c.options.max || b.max],
  339. c.mins = j.mm[0].match(/\d+/g),
  340. c.maxs = j.mm[1].match(/\d+/g),
  341. h.elemv = /textarea|input/.test(c.elem.tagName.toLocaleLowerCase()) ? "value": "innerHTML",
  342. 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 = '<div class="laydate_top"><div class="laydate_ym laydate_y" id="laydate_YY"><a class="laydate_choose laydate_chprev laydate_tab"><cite></cite></a><input id="laydate_y" readonly><label></label><a class="laydate_choose laydate_chnext laydate_tab"><cite></cite></a><div class="laydate_yms"><a class="laydate_tab laydate_chtop"><cite></cite></a><ul id="laydate_ys"></ul><a class="laydate_tab laydate_chdown"><cite></cite></a></div></div><div class="laydate_ym laydate_m" id="laydate_MM"><a class="laydate_choose laydate_chprev laydate_tab"><cite></cite></a><input id="laydate_m" readonly><label></label><a class="laydate_choose laydate_chnext laydate_tab"><cite></cite></a><div class="laydate_yms" id="laydate_ms">' +
  343. function() {
  344. var a = "";
  345. return c.each(new Array(12),
  346. function(b) {
  347. a += '<span m="' + b + '">' + c.digit(b + 1) + "</span>"
  348. }),
  349. a
  350. } () + "</div>" + "</div>" + "</div>" + c.viewtb + '<div class="laydate_bottom">' + '<ul id="laydate_hms">' + '<li class="laydate_sj">Time</li>' + "<li><input readonly>:</li>" + "<li><input readonly></li>" + "<li hidden='hidden'><input readonly></li>" + "</ul>" + '<div class="laydate_time" id="laydate_time"></div>' + '<div class="laydate_btn">' + '<a id="laydate_clear">Clear</a>' + '<a id="laydate_today">Today</a>' + '<a id="laydate_ok">OK</a>' + "</div>" + (b.isv ? '<a href="http://sentsin.com/layui/laydate/" class="laydate_v" target="_blank">laydate-v' + laydate.v + "</a>": "") + "</div>", d.body.appendChild(i), c.box = g("#" + h[0]), c.events(), i = null),
  351. c.follow(c.box),
  352. f.zIndex ? c.box.style.zIndex = f.zIndex: c.removeCssAttr(c.box, "z-index"),
  353. c.stopMosup("click", c.box),
  354. c.initDate(),
  355. c.iswrite(),
  356. c.check()
  357. },
  358. c.reshow = function() {
  359. return c.each(c.query("#" + h[0] + " .laydate_show"),
  360. function(a, b) {
  361. c.removeClass(b, "laydate_show")
  362. }),
  363. this
  364. },
  365. c.close = function() {
  366. c.reshow(),
  367. c.shde(c.query("#" + h[0]), 1),
  368. c.elem = null
  369. },
  370. c.parse = function(a, d, e) {
  371. return a = a.concat(d),
  372. e = e || (c.options ? c.options.format: b.format),
  373. e.replace(/YYYY|MM|DD|hh|mm|ss/g,
  374. function() {
  375. return a.index = 0 | ++a.index,
  376. c.digit(a[a.index])
  377. })
  378. },
  379. c.creation = function(a, b) {
  380. var e = (c.query, c.hmsin),
  381. f = c.parse(a, [e[0].value, e[1].value, e[2].value]);
  382. c.elem[h.elemv] = f,
  383. b || (c.close(), "function" == typeof c.options.choose && c.options.choose(f))
  384. },
  385. c.events = function() {
  386. var b = c.query,
  387. e = {
  388. box: "#" + h[0]
  389. };
  390. c.addClass(d.body, "laydate_body"),
  391. h.tds = b("#laydate_table td"),
  392. h.mms = b("#laydate_ms span"),
  393. h.year = b("#laydate_y"),
  394. h.month = b("#laydate_m"),
  395. c.each(b(e.box + " .laydate_ym"),
  396. function(a, b) {
  397. c.on(b, "click",
  398. function(b) {
  399. c.stopmp(b).reshow(),
  400. c.addClass(this[g]("div")[0], "laydate_show"),
  401. a || (e.YY = parseInt(h.year.value), c.viewYears(e.YY))
  402. })
  403. }),
  404. c.on(b(e.box), "click",
  405. function() {
  406. c.reshow()
  407. }),
  408. e.tabYear = function(a) {
  409. 0 === a ? c.ymd[0]--:1 === a ? c.ymd[0]++:2 === a ? e.YY -= 14 : e.YY += 14,
  410. 2 > a ? (c.viewDate(c.ymd[0], c.ymd[1], c.ymd[2]), c.reshow()) : c.viewYears(e.YY)
  411. },
  412. c.each(b("#laydate_YY .laydate_tab"),
  413. function(a, b) {
  414. c.on(b, "click",
  415. function(b) {
  416. c.stopmp(b),
  417. e.tabYear(a)
  418. })
  419. }),
  420. e.tabMonth = function(a) {
  421. 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)),
  422. c.viewDate(c.ymd[0], c.ymd[1], c.ymd[2])
  423. },
  424. c.each(b("#laydate_MM .laydate_tab"),
  425. function(a, b) {
  426. c.on(b, "click",
  427. function(b) {
  428. c.stopmp(b).reshow(),
  429. e.tabMonth(a)
  430. })
  431. }),
  432. c.each(b("#laydate_ms span"),
  433. function(a, b) {
  434. c.on(b, "click",
  435. function(a) {
  436. c.stopmp(a).reshow(),
  437. c.hasClass(this, h[1]) || c.viewDate(c.ymd[0], 0 | this.getAttribute("m"), c.ymd[2])
  438. })
  439. }),
  440. c.each(b("#laydate_table td"),
  441. function(a, b) {
  442. c.on(b, "click",
  443. function(a) {
  444. c.hasClass(this, h[1]) || (c.stopmp(a), c.creation([0 | this.getAttribute("y"), 0 | this.getAttribute("m"), 0 | this.getAttribute("d")]))
  445. })
  446. }),
  447. h.oclear = b("#laydate_clear"),
  448. c.on(h.oclear, "click",
  449. function() {
  450. c.elem[h.elemv] = "",
  451. c.close()
  452. }),
  453. h.otoday = b("#laydate_today"),
  454. c.on(h.otoday, "click",
  455. function() {
  456. c.elem[h.elemv] = laydate.now(0, c.options.format),
  457. c.close()
  458. }),
  459. h.ok = b("#laydate_ok"),
  460. c.on(h.ok, "click",
  461. function() {
  462. c.valid && c.creation([c.ymd[0], c.ymd[1] + 1, c.ymd[2]])
  463. }),
  464. e.times = b("#laydate_time"),
  465. c.hmsin = e.hmsin = b("#laydate_hms input"),
  466. e.hmss = ["Hours", "Minutes", "Seconds"],
  467. e.hmsarr = [],
  468. c.msg = function(a, d) {
  469. var f = '<div class="laydte_hsmtex">' + (d || "提示") + "<span>×</span></div>";
  470. "string" == typeof a ? (f += "<p>" + a + "</p>", c.shde(b("#" + h[0])), c.removeClass(e.times, "laydate_time1").addClass(e.times, "laydate_msg")) : (e.hmsarr[a] ? f = e.hmsarr[a] : (f += '<div id="laydate_hmsno" class="laydate_hmsno">', c.each(new Array(0 === a ? 24 : 60),
  471. function(a) {
  472. f += "<span>" + a + "</span>"
  473. }), f += "</div>", e.hmsarr[a] = f), c.removeClass(e.times, "laydate_msg"), c[0 === a ? "removeClass": "addClass"](e.times, "laydate_time1")),
  474. c.addClass(e.times, "laydate_show"),
  475. e.times.innerHTML = f
  476. },
  477. e.hmson = function(a, d) {
  478. var e = b("#laydate_hmsno span"),
  479. f = c.valid ? null: 1;
  480. c.each(e,
  481. function(b, e) {
  482. f ? c.addClass(e, h[1]) : c.timeVoid(b, d) ? c.addClass(e, h[1]) : c.on(e, "click",
  483. function() {
  484. c.hasClass(this, h[1]) || (a.value = c.digit(0 | this.innerHTML))
  485. })
  486. }),
  487. c.addClass(e[0 | a.value], "laydate_click")
  488. },
  489. c.each(e.hmsin,
  490. function(a, b) {
  491. c.on(b, "click",
  492. function(b) {
  493. c.stopmp(b).reshow(),
  494. c.msg(a, e.hmss[a]),
  495. e.hmson(this, a)
  496. })
  497. }),
  498. c.on(d, "mouseup",
  499. function() {
  500. var a = b("#" + h[0]);
  501. a && "none" !== a.style.display && (c.check() || c.close())
  502. }).on(d, "keydown",
  503. function(b) {
  504. b = b || a.event;
  505. var d = b.keyCode;
  506. 13 === d && c.creation([c.ymd[0], c.ymd[1] + 1, c.ymd[2]])
  507. })
  508. },
  509. c.init = function() {
  510. c.use("need"),
  511. c.use(h[4] + b.defSkin, h[3]),
  512. c.skinLink = c.query("#" + h[3])
  513. } (),
  514. laydate.reset = function() {
  515. c.box && c.elem && c.follow(c.box)
  516. },
  517. laydate.now = function(a, b) {
  518. var d = new Date(0 | a ?
  519. function(a) {
  520. return 864e5 > a ? +new Date + 864e5 * a: a
  521. } (parseInt(a)) : +new Date);
  522. return c.parse([d.getFullYear(), d.getMonth() + 1, d.getDate()], [d.getHours(), d.getMinutes(), d.getSeconds()], b)
  523. }
  524. } (window);