纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
10 KiB

3 years ago
  1. /*
  2. * My97 DatePicker 4.8 Beta1
  3. * License: http://www.my97.net/dp/license.asp
  4. */
  5. var $dp, WdatePicker; (function () {
  6. var $ = {
  7. $langList: [{
  8. name: "en", charset: "UTF-8"
  9. },
  10. { name: "zh-cn", charset: "gb2312" },
  11. { name: "zh-tw", charset: "GBK" }
  12. ],
  13. $skinList: [
  14. { name: "default", charset: "gb2312" },
  15. { name: "whyGreen", charset: "gb2312" }
  16. ],
  17. $wdate: true,
  18. $crossFrame: true,
  19. $preLoad: false,
  20. doubleCalendar: false,
  21. enableKeyboard: true,
  22. enableInputMask: true,
  23. autoUpdateOnChanged: null,
  24. whichDayIsfirstWeek: 4,
  25. position: {},
  26. lang: "auto",
  27. skin: "default",
  28. dateFmt: "yyyy-MM-dd",
  29. realDateFmt: "yyyy-MM-dd",
  30. realTimeFmt: "HH:mm:ss",
  31. realFullFmt: "%Date %Time",
  32. minDate: "1900-01-01 00:00:00",
  33. maxDate: "2099-12-31 23:59:59",
  34. startDate: "",
  35. alwaysUseStartDate: false,
  36. yearOffset: 1911,
  37. firstDayOfWeek: 0,
  38. isShowWeek: false,
  39. highLineWeekDay: true,
  40. isShowClear: true,
  41. isShowToday: true,
  42. isShowOK: true,
  43. isShowOthers: true,
  44. readOnly: false,
  45. errDealMode: 0,
  46. autoPickDate: null,
  47. qsEnabled: true,
  48. autoShowQS: false,
  49. specialDates: null, specialDays: null, disabledDates: null, disabledDays: null, opposite: false, errMsg: "", quickSel: [], has: {}, getRealLang: function () { var _ = $.$langList; for (var A = 0; A < _.length; A++) if (_[A].name == this.lang) return _[A]; return _[0] }
  50. }; WdatePicker = T; var X = window, S = { innerHTML: "" }, M = "document", H = "documentElement", C = "getElementsByTagName", U, A, R, G, a, W = navigator.appName; if (W == "Microsoft Internet Explorer") R = true; else if (W == "Opera") a = true; else G = true; A = J(); if ($.$wdate) K(A + "skin/WdatePicker.css"); U = X; if ($.$crossFrame) { try { while (U.parent && U.parent[M] != U[M] && U.parent[M][C]("frameset").length == 0) U = U.parent } catch (N) { } } if (!U.$dp) U.$dp = { ff: G, ie: R, opera: a, status: 0, defMinDate: $.minDate, defMaxDate: $.maxDate }; B(); if ($.$preLoad && $dp.status == 0) E(X, "onload", function () { T(null, true) }); if (!X[M].docMD) { E(X[M], "onmousedown", D); X[M].docMD = true } if (!U[M].docMD) { E(U[M], "onmousedown", D); U[M].docMD = true } E(X, "onunload", function () { if ($dp.dd) O($dp.dd, "none") }); function B() { U.$dp = U.$dp || {}; obj = { $: function ($) { return (typeof $ == "string") ? X[M].getElementById($) : $ }, $D: function ($, _) { return this.$DV(this.$($).value, _) }, $DV: function (_, $) { if (_ != "") { this.dt = $dp.cal.splitDate(_, $dp.cal.dateFmt); if ($) for (var B in $) if (this.dt[B] === undefined) this.errMsg = "invalid property:" + B; else { this.dt[B] += $[B]; if (B == "M") { var C = $["M"] > 0 ? 1 : 0, A = new Date(this.dt["y"], this.dt["M"], 0).getDate(); this.dt["d"] = Math.min(A + C, this.dt["d"]) } } if (this.dt.refresh()) return this.dt } return "" }, show: function () { var A = U[M].getElementsByTagName("div"), $ = 100000; for (var B = 0; B < A.length; B++) { var _ = parseInt(A[B].style.zIndex); if (_ > $) $ = _ } this.dd.style.zIndex = $ + 2; O(this.dd, "block") }, hide: function () { O(this.dd, "none") }, attachEvent: E }; for (var $ in obj) U.$dp[$] = obj[$]; $dp = U.$dp } function E(A, $, _) { if (R) A.attachEvent($, _); else if (_) { var B = $.replace(/on/, ""); _._ieEmuEventHandler = function ($) { return _($) }; A.addEventListener(B, _._ieEmuEventHandler, false) } } function J() { var _, A, $ = X[M][C]("script"); for (var B = 0; B < $.length; B++) { _ = $[B].getAttribute("src"); _ = _.substr(0, _.toLowerCase().indexOf("wdatepicker.js")); A = _.lastIndexOf("/"); if (A > 0) _ = _.substring(0, A + 1); if (_) break } return _ } function K(A, $, B) { var D = X[M][C]("HEAD").item(0), _ = X[M].createElement("link"); if (D) { _.href = A; _.rel = "stylesheet"; _.type = "text/css"; if ($) _.title = $; if (B) _.charset = B; D.appendChild(_) } } function F($) { $ = $ || U; var A = 0, _ = 0; while ($ != U) { var D = $.parent[M][C]("iframe"); for (var F = 0; F < D.length; F++) { try { if (D[F].contentWindow == $) { var E = V(D[F]); A += E.left; _ += E.top; break } } catch (B) { } } $ = $.parent } return { "leftM": A, "topM": _ } } function V(F) { if (F.getBoundingClientRect) return F.getBoundingClientRect(); else { var A = { ROOT_TAG: /^body|html$/i, OP_SCROLL: /^(?:inline|table-row)$/i }, E = false, H = null, _ = F.offsetTop, G = F.offsetLeft, D = F.offsetWidth, B = F.offsetHeight, C = F.offsetParent; if (C != F) while (C) { G += C.offsetLeft; _ += C.offsetTop; if (Q(C, "position").toLowerCase() == "fixed") E = true; else if (C.tagName.toLowerCase() == "body") H = C.ownerDocument.defaultView; C = C.offsetParent } C = F.parentNode; while (C.tagName && !A.ROOT_TAG.test(C.tagName)) { if (C.scrollTop || C.scrollLeft) if (!A.OP_SCROLL.test(O(C))) if (!a || C.style.overflow !== "visible") { G -= C.scrollLeft; _ -= C.scrollTop } C = C.parentNode } if (!E) { var $ = Z(H); G -= $.left; _ -= $.top } D += G; B += _; return { "left": G, "top": _, "right": D, "bottom": B } } } function L($) { $ = $ || U; var B = $[M], A = ($.innerWidth) ? $.innerWidth : (B[H] && B[H].clientWidth) ? B[H].clientWidth : B.body.offsetWidth, _ = ($.innerHeight) ? $.innerHeight : (B[H] && B[H].clientHeight) ? B[H].clientHeight : B.body.offsetHeight; return { "width": A, "height": _ } } function Z($) { $ = $ || U; var B = $[M], A = B[H], _ = B.body; B = (A && A.scrollTop != null && (A.scrollTop > _.scrollTop || A.scrollLeft > _.scrollLeft)) ? A : _; return { "top": B.scrollTop, "left": B
  51. })()