/* * my97 datepicker 4.8 beta4 * license: http://www.my97.net/dp/license.asp * http://www.my97.net/dp/demo/index.htm */ var $dp,wdatepicker;(function(){var $={ $langlist:[ {name:"en",charset:"utf-8"}, {name:"zh-cn",charset:"gb2312"}, {name:"zh-tw",charset:"gbk"}], $skinlist:[ {name:"default",charset:"gb2312"}, {name:"whygreen",charset:"gb2312"}, {name:"blue",charset:"gb2312"}, {name:"green",charset:"gb2312"}, {name:"simple",charset:"gb2312"}, {name:"ext",charset:"gb2312"}, {name:"bluefresh",charset:"gb2312"}, {name:"twoer",charset:"gb2312"}, {name:"ycloudred",charset:"gb2312"}], $wdate:true, $crossframe:true, $preload:false, $dppath:"", doublecalendar:false, enablekeyboard:true, enableinputmask:true, autoupdateonchanged:null, weekmethod:"iso8601", position:{}, lang:"auto", skin:"default", datefmt:"yyyy-mm-dd", realdatefmt:"yyyy-mm-dd", realtimefmt:"hh:mm:ss", realfullfmt:"%date %time", mindate:"1900-01-01 00:00:00", maxdate:"2099-12-31 23:59:59", startdate:"", alwaysusestartdate:false, yearoffset:1911, firstdayofweek:0, isshowweek:false, highlineweekday:true, isshowclear:true, isshowtoday:true, isshowok:true, isshowothers:true, readonly:false, errdealmode:0, autopickdate:null, qsenabled:true, autoshowqs:false, opposite:false, hmsmenucfg:{h:[1,6],m:[5,6],s:[15,4]}, opposite:false, specialdates: null, specialdays: null, disableddates: null, disableddays: null, onpicking: null, onpicked: null, onclearing: null, oncleared: null, ychanging: null, ychanged: null, mchanging: null, mchanged: null, dchanging: null, dchanged: null, hchanging: null, hchanged: null, mchanging: null, mchanged: null, schanging: null, schanged: null, econt: null, vel: null, elprop: "", errmsg: "", quicksel: [], has: {}, getreallang: function () { var _ = $.$langlist; for (var a = 0; a < _.length; a++) if (_[a].name == this.lang) return _[a]; return _[0] } }; wdatepicker = u; var y = window, t = { innerhtml: "" }, n = "document", h = "documentelement", c = "getelementsbytagname", v, a, s, g, c, x = navigator.appname; if (x == "microsoft internet explorer") s = true; else if (x == "opera") c = true; else g = true; a = $.$dppath || j(); if ($.$wdate) k(a + "skin/wdatepicker.css"); v = y; if ($.$crossframe) { try { while (v.parent != v && v.parent[n][c]("frameset").length == 0) v = v.parent } catch (o) { } } if (!v.$dp) v.$dp = { ff: g, ie: s, opera: c, status: 0, defmindate: $.mindate, defmaxdate: $.maxdate }; b(); if ($.$preload && $dp.status == 0) e(y, "onload", function () { u(null, true) }); if (!y[n].docmd) { e(y[n], "onmousedown", d, true); y[n].docmd = true } if (!v[n].docmd) { e(v[n], "onmousedown", d, true); v[n].docmd = true } e(y, "onunload", function () { if ($dp.dd) p($dp.dd, "none") }); function b() { try { v[n], v.$dp = v.$dp || {} } catch ($) { v = y; $dp = $dp || {} } var a = { win: y, $: function ($) { return (typeof $ == "string") ? y[n].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 = v[n].getelementsbytagname("div"), $ = 100000; for (var b = 0; b < a.length; b++) { var _ = parseint(a[b].style.zindex); if (_ > $) $ = _ } this.dd.style.zindex = $ + 2; p(this.dd, "block"); p(this.dd.firstchild, "") }, unbind: function ($) { $ = this.$($); if ($.initcfg) { l($, "onclick", function () { u($.initcfg) }); l($, "onfocus", function () { u($.initcfg) }) } }, hide: function () { p(this.dd, "none") }, attachevent: e }; for (var _ in a) v.$dp[_] = a[_]; $dp = v.$dp } function e(b, _, a, $) { if (b.addeventlistener) { var c = _.replace(/on/, ""); a._ieemueventhandler = function ($) { return a($) }; b.addeventlistener(c, a._ieemueventhandler, $) } else b.attachevent(_, a) } function l(a, $, _) { if (a.removeeventlistener) { var b = $.replace(/on/, ""); _._ieemueventhandler = function ($) { return _($) }; a.removeeventlistener(b, _._ieemueventhandler, false) } else a.detachevent($, _) } function a(_, $, a) { if (typeof _ != typeof $) return false; if (typeof _ == "object") { if (!a) for (var b in _) { if (typeof $[b] == "undefined") return false; if (!a(_[b], $[b], true)) return false } return true } else if (typeof _ == "function" && typeof $ == "function") return _.tostring() == $.tostring(); else return _ == $ } function j() { var _, a, $ = y[n][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 = y[n][c]("head").item(0), _ = y[n].createelement("link"); if (d) { _.href = a; _.rel = "stylesheet"; _.type = "text/css"; if ($) _.title = $; if (b) _.charset = b; d.appendchild(_) } } function f($) { $ = $ || v; var a = 0, _ = 0; while ($ != v) { var d = $.parent[n][c]("iframe"); for (var f = 0; f < d.length; f++) { try { if (d[f].contentwindow == $) { var e = w(d[f]); a += e.left; _ += e.top; break } } catch (b) { } } $ = $.parent } return { "leftm": a, "topm": _ } } function w(g, f) { if (g.getboundingclientrect) return g.getboundingclientrect(); else { var a = { root_tag: /^body|html$/i, op_scroll: /^(?:inline|table-row)$/i }, e = false, i = null, _ = g.offsettop, h = g.offsetleft, d = g.offsetwidth, b = g.offsetheight, c = g.offsetparent; if (c != g) while (c) { h += c.offsetleft; _ += c.offsettop; if (r(c, "position").tolowercase() == "fixed") e = true; else if (c.tagname.tolowercase() == "body") i = c.ownerdocument.defaultview; c = c.offsetparent } c = g.parentnode; while (c.tagname && !a.root_tag.test(c.tagname)) { if (c.scrolltop || c.scrollleft) if (!a.op_scroll.test(p(c))) if (!c || c.style.overflow !== "visible") { h -= c.scrollleft; _ -= c.scrolltop } c = c.parentnode } if (!e) { var $ = b(i); h -= $.left; _ -= $.top } d += h; b += _; return { "left": h, "top": _, "right": d, "bottom": b } } } function m($) { $ = $ || v; var b = $[n], 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 b($) { $ = $ || v; var b = $[n], a = b[h], _ = b.body; b = (a && a.scrolltop != null && (a.scrolltop > _.scrolltop || a.scrollleft > _.scrollleft)) ? a : _; return { "top": b.scrolltop, "left": b.scrollleft } } function d($) { try { var _ = $ ? ($.srcelement || $.target) : null; if ($dp.cal && !$dp.econt && $dp.dd && _ != $dp.el && $dp.dd.style.display == "block") $dp.cal.close() } catch ($) { } } function z() { $dp.status = 2 } var q, _; function u(k, c) { if (!$dp) return; b(); var l = {}; for (var h in k) l[h] = k[h]; for (h in $) if (h.substring(0, 1) != "$" && l[h] === undefined) l[h] = $[h]; if (c) { if (!j()) { _ = _ || setinterval(function () { if (v[n].readystate == "complete") clearinterval(_); u(null, true) }, 50); return } if ($dp.status == 0) { $dp.status = 1; l.el = t; i(l, true) } else return } else if (l.econt) { l.econt = $dp.$(l.econt); l.el = t; l.autopickdate = true; l.qsenabled = false; i(l) } else { if ($.$preload && $dp.status != 2) return; var f = d(); if (y.event === f || f) { l.srcel = f.srcelement || f.target; f.cancelbubble = true } l.el = l.el = $dp.$(l.el || l.srcel); if (!l.el || l.el["my97mark"] === true || l.el.disabled || ($dp.dd && p($dp.dd) != "none" && $dp.dd.style.left != "-970px")) { try { if (l.el["my97mark"]) l.el["my97mark"] = false } catch (a) { } return } if (f && l.el.nodetype == 1 && !a(l.el.initcfg, k)) { $dp.unbind(l.el); e(l.el, f.type == "focus" ? "onclick" : "onfocus", function () { u(k) }); l.el.initcfg = k } i(l) } function j() { if (s && v != y && v[n].readystate != "complete") return false; return true } function d() { if (g) { func = d.caller; while (func != null) { var $ = func.arguments[0]; if ($ && ($ + "").indexof("event") >= 0) return $; func = func.caller } return null } return event } } function r(_, $) { return _.currentstyle ? _.currentstyle[$] : document.defaultview.getcomputedstyle(_, false)[$] } function p(_, $) { if (_) if ($ != null) _.style.display = $; else return r(_, "display") } function i(g, _) { var d = g.el ? g.el.nodename : "input"; if (_ || g.econt || new regexp(/input|textarea|div|span|p|a/ig).test(d)) g.elprop = d == "input" ? "value" : "innerhtml"; else return; if (g.lang == "auto") g.lang = s ? navigator.browserlanguage.tolowercase() : navigator.language.tolowercase(); if (!g.econt) for (var c in g) $dp[c] = g[c]; if (!$dp.dd || g.econt || ($dp.dd && (g.getreallang().name != $dp.dd.lang || g.skin != $dp.dd.skin))) { if (g.econt) e(g.econt, g); else { $dp.dd = v[n].createelement("div"); $dp.dd.style.csstext = "position:absolute"; v[n].body.appendchild($dp.dd); e($dp.dd, g); if (_) $dp.dd.style.left = $dp.dd.style.top = "-970px"; else { $dp.show(); b($dp) } } } else if ($dp.cal) { $dp.show(); $dp.cal.init(); if (!$dp.econt) b($dp) } function e(k, j) { var i = v[n].domain, f = false, g = ""; k.innerhtml = g; var _ = $.$langlist, d = $.$skinlist, h; try { h = k.lastchild.contentwindow[n] } catch (e) { f = true; k.removechild(k.lastchild); var l = v[n].createelement("iframe"); l.hidefocus = true; l.frameborder = 0; l.scrolling = "no"; l.src = "javascript:(function(){var d=document;d.open();d.domain='" + i + "';})()"; k.appendchild(l); settimeout(function () { h = k.lastchild.contentwindow[n]; c() }, 97); return } c(); function c() { var _ = j.getreallang(); k.lang = _.name; k.skin = j.skin; var $ = [""]; if (f) $[1] = "document.domain=\"" + i + "\";"; for (var c = 0; c < d.length; c++) if (d[c].name == j.skin) $.push(""); $.push(""); $.push(""); $.push(""); j.setpos = b; j.onload = z; h.write(""); h.cfg = j; h.write($.join("")); h.close() } } function b(j) { var h = j.position.left, c = j.position.top, d = j.el; if (d == t) return; if (d != j.srcel && (p(d) == "none" || d.type == "hidden")) d = j.srcel; var i = w(d), $ = f(y), e = m(v), b = b(v), g = $dp.dd.offsetheight, a = $dp.dd.offsetwidth; if (isnan(c)) c = 0; if (($.topm + i.bottom + g > e.height) && ($.topm + i.top - g > 0)) c += b.top + $.topm + i.top - g - 2; else { c += b.top + $.topm + i.bottom; var _ = c - b.top + g - e.height; if (_ > 0) c -= _ } if (isnan(h)) h = 0; h += b.left + math.min($.leftm + i.left, e.width - a - 5) - (s ? 2 : 0); j.dd.style.top = c + "px"; j.dd.style.left = h + "px" } } })() $(function () { $(document).on( 'focus.datepicker.data-api click.datepicker.data-api', '[data-provide="datepicker"]', function (e) { var data = $(this).data(); wdatepicker(data); e.preventdefault(); }); })