laydate.js 21 KB

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