|
@@ -1,672 +1,1223 @@
|
|
|
/**
|
|
/**
|
|
|
- @Name : jeDate v2.0 日期控件
|
|
|
|
|
- @Author: chne guojun
|
|
|
|
|
- @Date: 2015-12-28
|
|
|
|
|
|
|
+ @Name : jeDate v3.8.5 日期控件
|
|
|
|
|
+ @Author: chen guojun
|
|
|
|
|
+ @Date: 2017-06-18
|
|
|
@QQ群:516754269
|
|
@QQ群:516754269
|
|
|
- @Site:https://github.com/singod/jeDate
|
|
|
|
|
- @download by:www.sucaijiayuan.com
|
|
|
|
|
|
|
+ @官网:http://www.jemui.com/ 或 https://github.com/singod/jeDate
|
|
|
*/
|
|
*/
|
|
|
-(function(win) {
|
|
|
|
|
- var jeDt = {}, doc = document, Cell = "#jedatebox";
|
|
|
|
|
- /* (tag), (#id), (.className) ,(tag > .className) ,(tag > tag) ,(#id > tag.className) ,
|
|
|
|
|
- (.className tag) ,(tag, tag, #id) ,(tag#id.className) ,(span > * > b) ,(input[name=radio])
|
|
|
|
|
- */
|
|
|
|
|
- var QD = jeDt.query =function(){function r(c,g){g=g||document;if(!/^[\w\-_#]+$/.test(c)&&g.querySelectorAll)return m(g.querySelectorAll(c));if(-1<c.indexOf(",")){for(var d=c.split(/,/g),a=[],b=0,e=d.length;b<e;++b)a=a.concat(r(d[b],g));return y(a)}var d=c.match(z),a=d.pop(),e=(a.match(t)||k)[1],f=!e&&(a.match(u)||k)[1],b=!e&&(a.match(v)||k)[1],a=c.match(/\[(?:[\w\-_][^=]+)=(?:[\'\[\]\w\-_]+)\]/g);if(f&&!a&&!b&&g.getElementsByClassName)b=m(g.getElementsByClassName(f));else{b=!e&&m(g.getElementsByTagName(b||"*"));f&&(b=w(b,"className",RegExp("(^|\\s)"+f+"(\\s|$)")));if(e)return(d=g.getElementById(e))?[d]:[];if(a)for(e=0;e<a.length;e++)var f=(a[e].match(x)||k)[1],h=(a[e].match(x)||k)[2],h=h.replace(/\'/g,"").replace(/\-/g,"\\-").replace(/\[/g,"\\[").replace(/\]/g,"\\]"),b=w(b,f,RegExp("(^"+h+"$)"))}return d[0]&&b[0]?p(d,b):b}function m(c){try{return Array.prototype.slice.call(c)}catch(g){for(var d=[],a=0,b=c.length;a<b;++a)d[a]=c[a];return d}}function p(c,g,d){var a=c.pop();if("\x3e"===a)return p(c,g,!0);for(var b=[],e=-1,f=(a.match(t)||k)[1],h=!f&&(a.match(u)||k)[1],a=!f&&(a.match(v)||k)[1],m=-1,q,l,n,a=a&&a.toLowerCase();q=g[++m];){l=q.parentNode;do if(n=(n=(n=!a||"*"===a||a===l.nodeName.toLowerCase())&&(!f||l.id===f))&&(!h||RegExp("(^|\\s)"+h+"(\\s|$)").test(l.className)),d||n)break;while(l=l.parentNode);n&&(b[++e]=q)}return c[0]&&b[0]?p(c,b):b}function w(c,g,d){for(var a=-1,b,e=-1,f=[];b=c[++a];)d.test(b.getAttribute(g))&&(f[++e]=b);return f}var z=/(?:[\*\w\-\\.#]+)+(?:\[(?:[\w\-_][^=]+)=(?:[\'\[\]\w\-_]+)\])*|\*|>/gi,u=/^(?:[\w\-_]+)?\.([\w\-_]+)/,t=/^(?:[\w\-_]+)?#([\w\-_]+)/,v=/^([\w\*\-_]+)/,k=[null,null,null],x=/\[([\w\-_][^=]+)=([\'\[\]\w\-_]+)\]/,y=function(){var c=+new Date,g=function(){var d=1;return function(a){var b=a[c],e=d++;return b?!1:(a[c]=e,!0)}}();return function(d){for(var a=d.length,b=[],e=-1,f=0,h;f<a;++f)h=d[f],g(h)&&(b[++e]=h);c+=1;return b}}();return r}();
|
|
|
|
|
-
|
|
|
|
|
- jeDt.each = function(arr, fn) {
|
|
|
|
|
- var i = 0, len = arr.length;
|
|
|
|
|
- for (;i < len; i++) {
|
|
|
|
|
- if (fn(i, arr[i]) === false) {
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.extend = function() {
|
|
|
|
|
- var _extend = function me(dest, source) {
|
|
|
|
|
- for (var name in dest) {
|
|
|
|
|
- if (dest.hasOwnProperty(name)) {
|
|
|
|
|
- //当前属性是否为对象,如果为对象,则进行递归
|
|
|
|
|
- if (dest[name] instanceof Object && source[name] instanceof Object) {
|
|
|
|
|
- me(dest[name], source[name]);
|
|
|
|
|
- }
|
|
|
|
|
- //检测该属性是否存在
|
|
|
|
|
- if (source.hasOwnProperty(name)) {
|
|
|
|
|
- continue;
|
|
|
|
|
- } else {
|
|
|
|
|
- source[name] = dest[name];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+;(function(root, factory) {
|
|
|
|
|
+ //amd
|
|
|
|
|
+ if (typeof define === 'function' && define.amd) {
|
|
|
|
|
+ define(['jquery'], factory);
|
|
|
|
|
+ } else if (typeof exports === 'object') { //umd
|
|
|
|
|
+ module.exports = factory();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ root.jeDate = factory(window.jQuery || $);
|
|
|
|
|
+ }
|
|
|
|
|
+})(this, function($) {
|
|
|
|
|
+ var jet = {}, doc = document, regymdzz = "YYYY|MM|DD|hh|mm|ss|zz",
|
|
|
|
|
+ regymd = "YYYY|MM|DD|hh|mm|ss|zz".replace("|zz",""),
|
|
|
|
|
+ parseInt = function (n) { return window.parseInt(n, 10);},
|
|
|
|
|
+ config = {
|
|
|
|
|
+ skinCell:"jedateblue",
|
|
|
|
|
+ language:{
|
|
|
|
|
+ name : "cn",
|
|
|
|
|
+ month : ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
|
|
|
|
|
+ weeks : [ "日", "一", "二", "三", "四", "五", "六" ],
|
|
|
|
|
+ times : ["小时","分钟","秒数"],
|
|
|
|
|
+ clear : "清空",
|
|
|
|
|
+ today : "今天",
|
|
|
|
|
+ yes : "确定",
|
|
|
|
|
+ close : "关闭"
|
|
|
|
|
+ },
|
|
|
|
|
+ trigger:"click",
|
|
|
|
|
+ format:"YYYY-MM-DD hh:mm:ss", //日期格式
|
|
|
|
|
+ minDate:"1900-01-01 00:00:00", //最小日期
|
|
|
|
|
+ maxDate:"2099-12-31 23:59:59" //最大日期
|
|
|
};
|
|
};
|
|
|
- var _result = {}, arr = arguments;
|
|
|
|
|
- //遍历属性,至后向前
|
|
|
|
|
- if (!arr.length) return {};
|
|
|
|
|
- for (var i = arr.length - 1; i >= 0; i--) {
|
|
|
|
|
- _extend(arr[i], _result);
|
|
|
|
|
- }
|
|
|
|
|
- arr[0] = _result;
|
|
|
|
|
- return _result;
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.trim = function(str) {
|
|
|
|
|
- str = str || "";
|
|
|
|
|
- return str.replace(/^\s|\s$/g, "").replace(/\s+/g, " ");
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.attr = function(elem, key, val) {
|
|
|
|
|
- if (typeof key === "string" && typeof val === 'undefined') {
|
|
|
|
|
- return elem.getAttribute(key);
|
|
|
|
|
- } else {
|
|
|
|
|
- elem.setAttribute(key, val);
|
|
|
|
|
- }
|
|
|
|
|
- return this;
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.stopmp = function(e) {
|
|
|
|
|
- e = e || win.event;
|
|
|
|
|
- e.stopPropagation ? e.stopPropagation() :e.cancelBubble = true;
|
|
|
|
|
- return this;
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.getCss = function(obj, name) {
|
|
|
|
|
- if (obj.currentStyle) {
|
|
|
|
|
- return obj.currentStyle[name];
|
|
|
|
|
- } else if (window.getComputedStyle) {
|
|
|
|
|
- return document.defaultView.getComputedStyle(obj)[name];
|
|
|
|
|
- }
|
|
|
|
|
- return null;
|
|
|
|
|
- };
|
|
|
|
|
- //查询样式是否存在
|
|
|
|
|
- jeDt.hasClass = function(elem, cls) {
|
|
|
|
|
- elem = elem || {};
|
|
|
|
|
- return new RegExp("\\b" + cls + "\\b").test(elem.className);
|
|
|
|
|
- };
|
|
|
|
|
- //添加样式
|
|
|
|
|
- jeDt.addClass = function(elem, cls) {
|
|
|
|
|
- elem = elem || {};
|
|
|
|
|
- jeDt.hasClass(elem, cls) || (elem.className += " " + cls);
|
|
|
|
|
- elem.className = jeDt.trim(elem.className);
|
|
|
|
|
- return this;
|
|
|
|
|
- };
|
|
|
|
|
- //删除样式
|
|
|
|
|
- jeDt.removeClass = function(elem, cls) {
|
|
|
|
|
- elem = elem || {};
|
|
|
|
|
- if (jeDt.hasClass(elem, cls)) {
|
|
|
|
|
- elem.className = elem.className.replace(new RegExp("(\\s|^)" + cls + "(\\s|$)"), "");
|
|
|
|
|
- }
|
|
|
|
|
- return this;
|
|
|
|
|
- };
|
|
|
|
|
- //事件监听器
|
|
|
|
|
- jeDt.on = function(obj, type, fn) {
|
|
|
|
|
- if (obj.addEventListener) {
|
|
|
|
|
- obj.addEventListener(type, fn, false);
|
|
|
|
|
- } else if (obj.attachEvent) {
|
|
|
|
|
- obj.attachEvent("on" + type, fn);
|
|
|
|
|
- } else {
|
|
|
|
|
- obj["on" + type] = fn;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $.fn.jeDate = function(options){
|
|
|
|
|
+ return this.each(function(){
|
|
|
|
|
+ return new jeDate($(this),options||{});
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
- //阻断mouseup
|
|
|
|
|
- jeDt.stopMosup = function(evt, elem) {
|
|
|
|
|
- if (evt !== "mouseup") {
|
|
|
|
|
- jeDt.on(elem, "mouseup", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
|
|
+ $.extend({
|
|
|
|
|
+ jeDate:function(elem, options){
|
|
|
|
|
+ return $(elem).each(function(){
|
|
|
|
|
+ return new jeDate($(this),options||{});
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ });
|
|
|
|
|
+ jet.isObj = function (obj){
|
|
|
|
|
+ for(var i in obj){return true;}
|
|
|
|
|
+ return false;
|
|
|
};
|
|
};
|
|
|
- jeDt.html = function(elem, value) {
|
|
|
|
|
- if (typeof value != "undefined" || value !== undefined && elem.nodeType === 1) {
|
|
|
|
|
- elem.innerHTML = value;
|
|
|
|
|
- } else {
|
|
|
|
|
- return elem.innerHTML;
|
|
|
|
|
- }
|
|
|
|
|
- return this;
|
|
|
|
|
|
|
+ jet.reMacth = function (str) {
|
|
|
|
|
+ return str.match(/\w+|d+/g);
|
|
|
};
|
|
};
|
|
|
- jeDt.text = function(elem, value) {
|
|
|
|
|
- if (value !== undefined && elem.nodeType === 1) {
|
|
|
|
|
- document.all ? elem.innerText = value :elem.textContent = value;
|
|
|
|
|
- } else {
|
|
|
|
|
- var emText = document.all ? elem.innerText :elem.textContent;
|
|
|
|
|
- return emText;
|
|
|
|
|
- }
|
|
|
|
|
- return this;
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.val = function(elem, value) {
|
|
|
|
|
- if (value !== undefined && elem.nodeType === 1) {
|
|
|
|
|
- elem.value = value;
|
|
|
|
|
- } else {
|
|
|
|
|
- return elem.value;
|
|
|
|
|
- }
|
|
|
|
|
- return this;
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.scroll = function(type) {
|
|
|
|
|
|
|
+ jet.docScroll = function(type) {
|
|
|
type = type ? "scrollLeft" :"scrollTop";
|
|
type = type ? "scrollLeft" :"scrollTop";
|
|
|
return doc.body[type] | doc.documentElement[type];
|
|
return doc.body[type] | doc.documentElement[type];
|
|
|
};
|
|
};
|
|
|
- jeDt.winarea = function(type) {
|
|
|
|
|
|
|
+ jet.winarea = function(type) {
|
|
|
return doc.documentElement[type ? "clientWidth" :"clientHeight"];
|
|
return doc.documentElement[type ? "clientWidth" :"clientHeight"];
|
|
|
};
|
|
};
|
|
|
|
|
+ //判断是否闰年
|
|
|
|
|
+ jet.isLeap = function(y) {
|
|
|
|
|
+ return (y % 100 !== 0 && y % 4 === 0) || (y % 400 === 0);
|
|
|
|
|
+ };
|
|
|
|
|
+ //获取本月的总天数
|
|
|
|
|
+ jet.getDaysNum = function(y, m) {
|
|
|
|
|
+ var num = 31;
|
|
|
|
|
+ switch (parseInt(m)) {
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ num = jet.isLeap(y) ? 29 : 28; break;
|
|
|
|
|
+ case 4: case 6: case 9: case 11:
|
|
|
|
|
+ num = 30; break;
|
|
|
|
|
+ }
|
|
|
|
|
+ return num;
|
|
|
|
|
+ };
|
|
|
|
|
+ //获取月与年
|
|
|
|
|
+ jet.getYM = function(y, m, n) {
|
|
|
|
|
+ var nd = new Date(y, m - 1);
|
|
|
|
|
+ nd.setMonth(m - 1 + n);
|
|
|
|
|
+ return {
|
|
|
|
|
+ y: nd.getFullYear(),
|
|
|
|
|
+ m: nd.getMonth() + 1
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取上个月
|
|
|
|
|
+ jet.getPrevMonth = function(y, m, n) {
|
|
|
|
|
+ return jet.getYM(y, m, 0 - (n || 1));
|
|
|
|
|
+ };
|
|
|
|
|
+ //获取下个月
|
|
|
|
|
+ jet.getNextMonth = function(y, m, n) {
|
|
|
|
|
+ return jet.getYM(y, m, n || 1);
|
|
|
|
|
+ };
|
|
|
|
|
+ //补齐数位
|
|
|
|
|
+ jet.digit = function(num) {
|
|
|
|
|
+ return num < 10 ? "0" + (num | 0) :num;
|
|
|
|
|
+ };
|
|
|
|
|
+ //判断是否为数字
|
|
|
|
|
+ jet.IsNum = function(value){
|
|
|
|
|
+ return /^[+-]?\d*\.?\d*$/.test(value) ? true : false;
|
|
|
|
|
+ };
|
|
|
//转换日期格式
|
|
//转换日期格式
|
|
|
- jeDt.parse = function(ymd, hms, format) {
|
|
|
|
|
|
|
+ jet.parse = function(ymd, hms, format) {
|
|
|
ymd = ymd.concat(hms);
|
|
ymd = ymd.concat(hms);
|
|
|
- var format = format, _this = this;
|
|
|
|
|
- return format.replace(/YYYY|MM|DD|hh|mm|ss/g, function(str, index) {
|
|
|
|
|
- ymd.index = ++ymd.index | 0;
|
|
|
|
|
- return jeDt.digit(ymd[ymd.index]);
|
|
|
|
|
|
|
+ var ymdObj = {}, mat = regymdzz.split("|");
|
|
|
|
|
+ $.each(ymd,function (i,val) {
|
|
|
|
|
+ ymdObj[mat[i]] = parseInt(val);
|
|
|
|
|
+ });
|
|
|
|
|
+ return format.replace(new RegExp(regymdzz,"g"), function(str, index) {
|
|
|
|
|
+ return str == "zz" ? "00":jet.digit(ymdObj[str]);
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+ jet.checkFormat = function(format) {
|
|
|
|
|
+ var ymdhms = [];
|
|
|
|
|
+ format.replace(new RegExp(regymdzz,"g"), function(str, index) {
|
|
|
|
|
+ ymdhms.push(str);
|
|
|
});
|
|
});
|
|
|
|
|
+ return ymdhms.join("-");
|
|
|
};
|
|
};
|
|
|
- //初始化日期
|
|
|
|
|
- jeDt.nowDate = function(timestamp, format) {
|
|
|
|
|
- var De = new Date(timestamp | 0 ? function(tamp) {
|
|
|
|
|
- return tamp < 864e5 ? +new Date() + tamp * 864e5 :tamp;
|
|
|
|
|
- }(parseInt(timestamp)) :+new Date());
|
|
|
|
|
- return jeDt.parse([ De.getFullYear(), De.getMonth() + 1, De.getDate() ], [ De.getHours(), De.getMinutes(), De.getSeconds() ], format);
|
|
|
|
|
|
|
+ jet.parseMatch = function(str) {
|
|
|
|
|
+ var timeArr = str.split(" ");
|
|
|
|
|
+ return jet.reMacth(timeArr[0]);
|
|
|
};
|
|
};
|
|
|
- jeDt.montharr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ];
|
|
|
|
|
- //判断元素类型
|
|
|
|
|
- jeDt.isValHtml = function(that) {
|
|
|
|
|
- return /textarea|input/.test(that.tagName.toLocaleLowerCase());
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.weeks = [ "日", "一", "二", "三", "四", "五", "六" ];
|
|
|
|
|
- //节日
|
|
|
|
|
- jeDt.festival = function(md, n) {
|
|
|
|
|
- var str = "";
|
|
|
|
|
- switch (md) {
|
|
|
|
|
- case "01.01": str = "元旦"; break;
|
|
|
|
|
- case "02.14": str = "情人"; break;
|
|
|
|
|
- case "03.08": str = "妇女"; break;
|
|
|
|
|
- case "04.05": str = "清明"; break;
|
|
|
|
|
- case "05.01": str = "劳动"; break;
|
|
|
|
|
- case "06.01": str = "儿童"; break;
|
|
|
|
|
- case "08.01": str = "建军"; break;
|
|
|
|
|
- case "09.10": str = "教师"; break;
|
|
|
|
|
- case "10.01": str = "国庆"; break;
|
|
|
|
|
- case "12.24": str = "平安"; break;
|
|
|
|
|
- case "12.25": str = "圣诞"; break;
|
|
|
|
|
- default: str = n; break;
|
|
|
|
|
|
|
+ jet.testFormat = function(format,conformat) {
|
|
|
|
|
+ var mat = ["YYYY","MM","DD"],ymdhms = [],mats = [];
|
|
|
|
|
+ format.replace(new RegExp(regymdzz,"g"), function(str, index) {
|
|
|
|
|
+ ymdhms.push(str);
|
|
|
|
|
+ });
|
|
|
|
|
+ $.each(mat,function (m,d) {
|
|
|
|
|
+ $.each(ymdhms,function (i,f) {
|
|
|
|
|
+ if (d == f) mats.push(f);
|
|
|
|
|
+ })
|
|
|
|
|
+ });
|
|
|
|
|
+ var reformat = format.substring(0, 2) == "hh" ? ymdhms.join("-") : mats.join("-");
|
|
|
|
|
+ var remat = reformat == conformat ? true : false;
|
|
|
|
|
+ return remat;
|
|
|
|
|
+ };
|
|
|
|
|
+ //验证日期
|
|
|
|
|
+ jet.checkDate = function (date) {
|
|
|
|
|
+ var dateArr = jet.reMacth(date);
|
|
|
|
|
+ if (isNaN(dateArr[0]) || isNaN(dateArr[1]) || isNaN(dateArr[2])) return false;
|
|
|
|
|
+ if (dateArr[1] > 12 || dateArr[1] < 1) return false;
|
|
|
|
|
+ if (dateArr[2] < 1 || dateArr[2] > 31) return false;
|
|
|
|
|
+ if ((dateArr[1] == 4 || dateArr[1] == 6 || dateArr[1] == 9 || dateArr[1] == 11) && dateArr[2] > 30) return false;
|
|
|
|
|
+ if (dateArr[1] == 2) {
|
|
|
|
|
+ if (dateArr[2] > 29) return false;
|
|
|
|
|
+ if ((dateArr[0] % 100 == 0 && dateArr[0] % 400 != 0 || dateArr[0] % 4 != 0) && dateArr[2] > 28) return false;
|
|
|
}
|
|
}
|
|
|
- return str;
|
|
|
|
|
|
|
+ return true;
|
|
|
};
|
|
};
|
|
|
- //补齐数位
|
|
|
|
|
- jeDt.digit = function(num) {
|
|
|
|
|
- return num < 10 ? "0" + (num | 0) :num;
|
|
|
|
|
|
|
+ //返回日期
|
|
|
|
|
+ jet.returnDate = function(obj, format, dateval) {
|
|
|
|
|
+ format = format || 'YYYY-MM-DD hh:mm:ss';
|
|
|
|
|
+ var undate = (dateval == undefined || dateval == "" || dateval == []), darr = undate ? [] : jet.reMacth(dateval), sparr = [];
|
|
|
|
|
+ if(!undate){
|
|
|
|
|
+ darr[1] -= 1;
|
|
|
|
|
+ darr[1] = darr[1] == -1 ? 12 : darr[1];
|
|
|
|
|
+ }
|
|
|
|
|
+ var myDate = darr.length > 0 ? new Date(darr[0],darr[1],(darr[2]||00),(darr[3]||00),(darr[4]||00),(darr[5]||00)) : new Date(),
|
|
|
|
|
+ myMM = myDate.getMonth(), myDD = myDate.getDate(),
|
|
|
|
|
+ narr = [myDate.getFullYear(), myMM, myDD, myDate.getHours(), myDate.getMinutes(), myDate.getSeconds()];
|
|
|
|
|
+ $.each(regymd.split("|"),function (i,val) {
|
|
|
|
|
+ sparr.push(obj[val]||"");
|
|
|
|
|
+ });
|
|
|
|
|
+ var mday = jet.getDaysNum(narr[0], narr[1]+1),
|
|
|
|
|
+ isDay31 = mday == 31 && jet.digit(new Date().getDate()) == 31,
|
|
|
|
|
+ parnaVal = narr[2]+parseInt(sparr[2]||00), gday, reday;
|
|
|
|
|
+ //判断今天是否为31号
|
|
|
|
|
+ gday = isDay31 ? (parnaVal - 1) : parnaVal;
|
|
|
|
|
+ //重新设置日期,必须要用new Date来设置,否则就会有问题
|
|
|
|
|
+ var setdate = new Date(narr[0]+parseInt(sparr[0]||00), narr[1]+parseInt(sparr[1]||00), gday, narr[3]+parseInt(sparr[3]||00), narr[4]+parseInt(sparr[4]||00), narr[5]+parseInt(sparr[4]||00));
|
|
|
|
|
+ reday = isDay31 ? jet.digit(parseInt(setdate.getDate())+1) : jet.digit(setdate.getDate());
|
|
|
|
|
+ //获取重新设置后的日期
|
|
|
|
|
+ var reDate = jet.parse([ setdate.getFullYear(), parseInt(setdate.getMonth())+1, reday ], [ jet.digit(setdate.getHours()), jet.digit(setdate.getMinutes()), jet.digit(setdate.getSeconds()) ], format);
|
|
|
|
|
+ return reDate;
|
|
|
};
|
|
};
|
|
|
- //显示隐藏层
|
|
|
|
|
- jeDt.shdeCell = function(type) {
|
|
|
|
|
- type ? QD(Cell)[0].style.display = "none" :QD(Cell)[0].style.display = "block";
|
|
|
|
|
|
|
+ //判断元素类型
|
|
|
|
|
+ jet.isValHtml = function(that) {
|
|
|
|
|
+ return /textarea|input/.test(that[0].tagName.toLocaleLowerCase());
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
- var config = {
|
|
|
|
|
- dateCell:"#dateval",
|
|
|
|
|
- format:"YYYY-MM-DD hh:mm:ss", //日期格式
|
|
|
|
|
- minDate:"1900-01-01 00:00:00", //最小日期
|
|
|
|
|
- maxDate:"2099-12-31 23:59:59", //最大日期
|
|
|
|
|
- isinitVal:false, //是否初始化时间
|
|
|
|
|
- isTime:false, //是否开启时间选择
|
|
|
|
|
- isClear:true, //是否显示清空
|
|
|
|
|
- festival:false, //是否显示节日
|
|
|
|
|
- zIndex:999, //弹出层的层级高度
|
|
|
|
|
- choosefun:function(val) {}, //选中日期后的回调
|
|
|
|
|
- clearfun:function(val) {}, //清除日期后的回调
|
|
|
|
|
- okfun:function(val) {} //点击确定后的回调
|
|
|
|
|
- }, InitDate = function(options) {
|
|
|
|
|
- var that = this, newConf = JSON.parse(JSON.stringify(config));
|
|
|
|
|
- that.config = jeDt.extend(newConf, options);
|
|
|
|
|
- that.init();
|
|
|
|
|
- };
|
|
|
|
|
- var jeDate = function(options) {
|
|
|
|
|
- return new InitDate(options || {});
|
|
|
|
|
- };
|
|
|
|
|
- InitDate.prototype = {
|
|
|
|
|
- init:function() {
|
|
|
|
|
- var that = this, opts = that.config, self = QD(opts.dateCell)[0], elem, devt, even = window.event, target;
|
|
|
|
|
- var dateDiv = doc.createElement("div");
|
|
|
|
|
- if (!QD(Cell)[0]) {
|
|
|
|
|
- dateDiv.className = dateDiv.id = Cell.replace("#", "");
|
|
|
|
|
- dateDiv.style.zIndex = opts.zIndex;
|
|
|
|
|
- doc.body.appendChild(dateDiv);
|
|
|
|
|
- }
|
|
|
|
|
- try {
|
|
|
|
|
- target = even.target || even.srcElement || {};
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- target = {};
|
|
|
|
|
|
|
+ jet.isBool = function(obj){ return (obj == undefined || obj == true ? true : false); };
|
|
|
|
|
+ jet.sortDate = function (time,format) {
|
|
|
|
|
+ var timeObj = {}, newtime = [], mats = regymd.split("|"),
|
|
|
|
|
+ subhh = jet.checkFormat(format).substring(0, 2) == "hh" ? true :false,
|
|
|
|
|
+ numArr = jet.IsNum(time) ? (jet.reMacth(subhh ? time.replace(/(.{2})/g,"$1,") : time.substr(0,4).replace(/^(\d{4})/g,"$1,") + time.substr(4).replace(/(.{2})/g,"$1,"))) : jet.reMacth(time),
|
|
|
|
|
+ matArr = jet.IsNum(time) ? (jet.reMacth(subhh ? format.replace(/(.{2})/g,"$1,") : format.substr(0,4).replace(/^(\w{4})/g,"$1,") + format.substr(4).replace(/(.{2})/g,"$1,"))) : jet.reMacth(format);
|
|
|
|
|
+ $.each(numArr,function (i,val) {
|
|
|
|
|
+ timeObj[matArr[i]] = val;
|
|
|
|
|
+ });
|
|
|
|
|
+ $.each(numArr,function (i,val) {
|
|
|
|
|
+ var mathh = subhh ? mats[3+i] : mats[i];
|
|
|
|
|
+ newtime.push(timeObj[mathh]);
|
|
|
|
|
+ });
|
|
|
|
|
+ return (jet.IsNum(time)) ? (jet.reMacth(subhh ? time.replace(/(.{2})/g,"$1,") : time.substr(0,4).replace(/^(\d{4})/g,"$1,") + time.substr(4).replace(/(.{2})/g,"$1,"))) : newtime;
|
|
|
|
|
+ };
|
|
|
|
|
+ var searandom = function (){
|
|
|
|
|
+ var str = "",arr = [1,2,3,4,5,6,7,8,9,0];
|
|
|
|
|
+ for(var i=0; i<8; i++) str += arr[Math.round(Math.random() * (arr.length-1))];
|
|
|
|
|
+ return str;
|
|
|
|
|
+ };
|
|
|
|
|
+ function jeDate(elem, opts){
|
|
|
|
|
+ this.opts = opts;
|
|
|
|
|
+ this.valCell = elem;
|
|
|
|
|
+ this.init();
|
|
|
|
|
+ }
|
|
|
|
|
+ var jedfn = jeDate.prototype, jefix = "jefixed";
|
|
|
|
|
+ jedfn.init = function(){
|
|
|
|
|
+ var that = this, opts = that.opts, newDate = new Date(),
|
|
|
|
|
+ jetrigger = opts.trigger != undefined ? opts.trigger : config.trigger,
|
|
|
|
|
+ zIndex = opts.zIndex == undefined ? 2099 : opts.zIndex,
|
|
|
|
|
+ isinitVal = (opts.isinitVal == undefined || opts.isinitVal == false) ? false : true;
|
|
|
|
|
+ jet.fixed = jet.isBool(opts.fixed);
|
|
|
|
|
+ var fixedCell = (opts.fixedCell == undefined || opts.fixedCell == "") ? "" : "#"+this.opts.fixedCell;
|
|
|
|
|
+ var arrayContain = function(array, obj){
|
|
|
|
|
+ for (var i = 0; i < array.length; i++){
|
|
|
|
|
+ if (array[i] == obj) return true;
|
|
|
}
|
|
}
|
|
|
- elem = opts.dateCell ? QD(opts.dateCell)[0] :target;
|
|
|
|
|
- var nowDateVal = jeDt.nowDate(null, opts.format);
|
|
|
|
|
- if (opts.isinitVal) {
|
|
|
|
|
- (jeDt.val(self) || jeDt.text(self)) == "" ? jeDt.isValHtml(self) ? jeDt.val(self, nowDateVal) :jeDt.text(self, nowDateVal) :jeDt.isValHtml(self) ? jeDt.val(self) :jeDt.text(self);
|
|
|
|
|
|
|
+ return false;
|
|
|
|
|
+ };
|
|
|
|
|
+ var initVals = function(objCell) {
|
|
|
|
|
+ var jeformat = opts.format || config.format,jeaddDate,
|
|
|
|
|
+ inaddVal = opts.initAddVal || {},
|
|
|
|
|
+ hmsset = opts.hmsSetVal || {};
|
|
|
|
|
+ //判断时间为20170430这样类型的
|
|
|
|
|
+ //var isnosepYMD = arrayContain(["YYYYMM","YYYYMMDD","YYYYMMDDhh","YYYYMMDDhhmm","YYYYMMDDhhmmss"],jeformat);
|
|
|
|
|
+ if (jet.isObj(hmsset)){
|
|
|
|
|
+ jeaddDate = jet.parse([ newDate.getFullYear(), jet.digit(newDate.getMonth() + 1), jet.digit(newDate.getDate()) ], [ jet.digit(hmsset.hh), jet.digit(hmsset.mm), jet.digit(hmsset.ss) ], jeformat);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ jeaddDate = jet.returnDate(inaddVal, jeformat);
|
|
|
}
|
|
}
|
|
|
- if (even && target.tagName) {
|
|
|
|
|
- if (!elem || elem === jeDt.elem) return;
|
|
|
|
|
- jeDt.stopMosup(even.type, elem);
|
|
|
|
|
- jeDt.stopmp(even);
|
|
|
|
|
- that.setHtml(opts, self);
|
|
|
|
|
- } else {
|
|
|
|
|
- devt = opts.event || "click";
|
|
|
|
|
- jeDt.each((elem.length | 0) > 0 ? elem :[ elem ], function(ii, cel) {
|
|
|
|
|
- jeDt.stopMosup(devt, that);
|
|
|
|
|
- jeDt.on(cel, devt, function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- if (cel !== jeDt.elem) that.setHtml(opts, self);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+
|
|
|
|
|
+ (objCell.val() || objCell.text()) == "" ? jet.isValHtml(objCell) ? objCell.val(jeaddDate) :objCell.text(jeaddDate) :jet.isValHtml(objCell) ? objCell.val() : objCell.text();
|
|
|
|
|
+ };
|
|
|
|
|
+ var formatDate = function (cls,boxcell) {
|
|
|
|
|
+ var dateDiv = $("<div/>",{"id":boxcell.replace(/\#/g,""),"class":"jedatebox "+(opts.skinCell || config.skinCell)}),
|
|
|
|
|
+ reabsfix = $(fixedCell).length > 0 ? "relative" : (jet.fixed == true ? "absolute" :"fixed");
|
|
|
|
|
+ dateDiv.attr("author","chen guojun").css({"z-index": boxcell != "#jedatebox" ? "" : zIndex ,"position":reabsfix,"display":"block"});
|
|
|
|
|
+ if(boxcell != "#jedatebox") dateDiv.attr({"jeformat":opts.format || config.format,"jefixed":fixedCell});
|
|
|
|
|
+ jet.minDate = opts.minDate || config.minDate;
|
|
|
|
|
+ jet.maxDate = opts.maxDate || config.maxDate;
|
|
|
|
|
+ $(cls).append(dateDiv);
|
|
|
|
|
+ that.setHtml(opts,boxcell);
|
|
|
|
|
+ };
|
|
|
|
|
+ //为开启初始化的时间设置值
|
|
|
|
|
+ if (isinitVal && jetrigger != false) {
|
|
|
|
|
+ that.valCell.each(function() {
|
|
|
|
|
+ initVals($(this));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ //判断固定元素是否存在
|
|
|
|
|
+ if($(fixedCell).length > 0){
|
|
|
|
|
+ var randomCell = "#jedatebox"+searandom();
|
|
|
|
|
+ formatDate(fixedCell,randomCell);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ //insTrigger的值为true时内部默认点击事件
|
|
|
|
|
+ var jd = ["body","#jedatebox"];
|
|
|
|
|
+ if (jetrigger != false) {
|
|
|
|
|
+ that.valCell.on(jetrigger, function (ev) {
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ if ($(jd[1]).length > 0) return;
|
|
|
|
|
+ formatDate(jd[0],jd[1]);
|
|
|
});
|
|
});
|
|
|
|
|
+ }else {
|
|
|
|
|
+ formatDate(jd[0],jd[1]);
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- setHtml:function(opts, self) {
|
|
|
|
|
- var that = this, weekHtml = "", date = new Date(), nowDateVal = jeDt.nowDate(null, opts.format), isformat = opts.format.match(/\w+|d+/g).join("-") == "YYYY-MM" ? true :false;
|
|
|
|
|
- var initVal = opts.isinitVal ? jeDt.isValHtml(self) ? jeDt.val(self) :jeDt.text(self) :(jeDt.val(self) || jeDt.text(self)) == "" ? nowDateVal :jeDt.isValHtml(self) ? jeDt.val(self) :jeDt.text(self);
|
|
|
|
|
- if (jeDt.val(self) != "" || jeDt.text(self) != "") {
|
|
|
|
|
- var arrTime = initVal.match(/\d+/g);
|
|
|
|
|
- } else {
|
|
|
|
|
- var arrTime = [ date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds() ];
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ //布局控件骨架
|
|
|
|
|
+ jedfn.setHtml = function(opts,boxcls){
|
|
|
|
|
+ jet.boxelem = $($(boxcls).attr(jefix)).length > 0 ? boxcls : "#jedatebox";
|
|
|
|
|
+ jet.format = $($(boxcls).attr(jefix)).length > 0 ? $(jet.boxelem).attr("jeformat") : (opts.format || config.format);
|
|
|
|
|
+ jet.formatType = jet.checkFormat(jet.format);
|
|
|
|
|
+ var that = this, boxCell = $(jet.boxelem),
|
|
|
|
|
+ isYYMM = jet.testFormat(jet.format,"YYYY-MM"),isYY = jet.testFormat(jet.format,"YYYY");
|
|
|
|
|
+ var doudStrHtml = '<div class="jedatetop"></div>' +
|
|
|
|
|
+ '<div class="jedatetopym" style="display: none;"><ul class="ymdropul"></ul></div>' +
|
|
|
|
|
+ '<ol class="jedaol"></ol><ul class="'+((isYYMM || isYY) ? (isYY ? "jedayy":"jedaym"):"jedaul")+'"></ul>' +
|
|
|
|
|
+ '<div class="jedateprophms"></div>' +
|
|
|
|
|
+ '<div class="jedatebot"></div>';
|
|
|
|
|
+ boxCell.empty().append(doudStrHtml);
|
|
|
|
|
+ that.generateHtml(opts,boxCell);
|
|
|
|
|
+ };
|
|
|
|
|
+ jedfn.isContainhh = function (format) {
|
|
|
|
|
+ var gethms = jet.checkFormat(format),
|
|
|
|
|
+ rearr = jet.reMacth("hh-"+gethms.split("hh")[1]);
|
|
|
|
|
+ return rearr;
|
|
|
|
|
+ };
|
|
|
|
|
+ jedfn.generateHtml = function(opts,boxCell){
|
|
|
|
|
+ var that = this, objCell = that.valCell, weekHtml = "", tmsArr,
|
|
|
|
|
+ date = new Date(), lang = opts.language || config.language,
|
|
|
|
|
+ isYYMM = jet.testFormat(jet.format,"YYYY-MM"),
|
|
|
|
|
+ isYY = jet.testFormat(jet.format,"YYYY"),
|
|
|
|
|
+ subhh = jet.format.substring(0, 2) == "hh",
|
|
|
|
|
+ topCell = boxCell.find(".jedatetop"),
|
|
|
|
|
+ topymCell = boxCell.find(".jedatetopym"),
|
|
|
|
|
+ olCell = boxCell.find(".jedaol"),
|
|
|
|
|
+ hmsCell = boxCell.find(".jedateprophms"),
|
|
|
|
|
+ botCell = boxCell.find(".jedatebot");
|
|
|
|
|
+ if ((objCell.val() || objCell.text()) == "") {
|
|
|
|
|
+ //目标为空值则获取当前日期时间
|
|
|
|
|
+ tmsArr = [ date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds() ];
|
|
|
|
|
+ jet.currDate = new Date(tmsArr[0], parseInt(tmsArr[1])-1, tmsArr[2], tmsArr[3], tmsArr[4], tmsArr[5]);
|
|
|
|
|
+ jet.ymdDate = tmsArr[0] + "-" + jet.digit(tmsArr[1]) + "-" + jet.digit(tmsArr[2]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var initVal = jet.isValHtml(objCell) ? objCell.val() : objCell.text();
|
|
|
|
|
+ var inVals = jet.sortDate(initVal,jet.format);
|
|
|
|
|
+ if(subhh){
|
|
|
|
|
+ tmsArr = [ date.getFullYear(), date.getMonth() + 1, date.getDate(), inVals[0], inVals[1]||date.getMinutes(), inVals[2]||date.getSeconds() ];
|
|
|
|
|
+ jet.currDate = new Date(date.getFullYear(), date.getMonth()-1, date.getDate());
|
|
|
|
|
+ }else{
|
|
|
|
|
+ tmsArr = [ inVals[0], inVals[1] == undefined ? date.getMonth() + 1 : inVals[1], inVals[2] == undefined ? date.getDate() : inVals[2], inVals[3] == undefined ? date.getHours() : inVals[3], inVals[4] == undefined ? date.getMinutes() : inVals[4], inVals[5] == undefined ? date.getSeconds() :inVals[5] ];
|
|
|
|
|
+ jet.currDate = new Date(tmsArr[0], parseInt(tmsArr[1])-1, tmsArr[2], tmsArr[3], tmsArr[4], tmsArr[5]);
|
|
|
|
|
+ jet.ymdDate = tmsArr[0] + "-" + jet.digit(tmsArr[1]) + "-" + jet.digit(tmsArr[2]);
|
|
|
}
|
|
}
|
|
|
- var topymSty = !isformat ? '<div class="jedateym" style="width:50%;"><i class="prev triangle yearprev"></i><span class="jedateyy" data-ym="24"><em class="jedateyear"></em><em class="pndrop"></em></span><i class="next triangle yearnext"></i></div>' + '<div class="jedateym" style="width:50%;"><i class="prev triangle monthprev"></i><span class="jedatemm" data-ym="12"><em class="jedatemonth"></em><em class="pndrop"></em></span><i class="next triangle monthnext"></i></div>' :'<div class="jedateym" style="width:100%;"><i class="prev triangle ymprev"></i><span class="jedateyy"><em class="jedateyearmonth"></em></span><i class="next triangle ymnext"></i></div>';
|
|
|
|
|
- var datetopStr = '<div class="jedatetop">' + topymSty + "</div>";
|
|
|
|
|
- var dateymList = !isformat ? '<div class="jedatetopym" style="display: none;">' + '<ul class="ymdropul"></ul><p><span class="jedateymchle">←</span><span class="jedateymchri">→</span><span class="jedateymchok">关闭</span></p>' + "</div>" :'<ul class="jedaym"></ul>';
|
|
|
|
|
- var dateriList = '<ol class="jedaol"></ol><ul class="jedaul"></ul>';
|
|
|
|
|
- var bothmsStr = !isformat ? '<ul class="botflex jedatehms"><li><em data-hms="24"></em><i>:</i></li><li><em data-hms="60"></em><i>:</i></li><li><em data-hms="60"></em></li></ul>' + '<div class="botflex jedatebtn"><span class="jedateclear" style="width:31%;">清空</span><span class="jedatetodaymonth" style="width:31%;">今天</span><span class="jedateok" style="width:31%;">确认</span></div>' :'<div class="botflex jedatebtn"><span class="jedateclear" style="width:31%;">清空</span><span class="jedatetodaymonth" style="width:31%;">本月</span><span class="jedateok" style="width:31%;">确认</span></div>';
|
|
|
|
|
- var datebotStr = '<div class="jedatebot">' + bothmsStr + "</div>";
|
|
|
|
|
- var dateHtmStr = isformat ? datetopStr + dateymList + datebotStr :datetopStr + dateymList + dateriList + datebotStr + '<div class="jedateprophms"></div>';
|
|
|
|
|
- jeDt.html(QD(Cell)[0], dateHtmStr);
|
|
|
|
|
- opts.isClear ? "" :QD(Cell + " .jedatebot .jedateclear")[0].style.display = "none";
|
|
|
|
|
- if (opts.isTime) {
|
|
|
|
|
- var dhmsArr = jeDt.val(self) != "" || jeDt.text(self) != "" ? [ arrTime[3], arrTime[4], arrTime[5] ] :[ date.getHours(), date.getMinutes() + 1, date.getSeconds() ];
|
|
|
|
|
- jeDt.each(QD(Cell + " .jedatebot .jedatehms em"), function(i, cls) {
|
|
|
|
|
- jeDt.html(cls, jeDt.digit(dhmsArr[i]));
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ //设置date的html片段
|
|
|
|
|
+ var topStrHtml = '<div class="jedateym" style="width:50%;"><i class="prev triangle monthprev"></i><span class="jedatemm" ym="12"><em class="jedatemonth"></em><em class="pndrop"></em></span><i class="next triangle monthnext"></i></div>' +
|
|
|
|
|
+ '<div class="jedateym" style="width:50%;"><i class="prev triangle yearprev"></i><span class="jedateyy" ym="24"><em class="jedateyear"></em><em class="pndrop"></em></span><i class="next triangle yearnext"></i></div>';
|
|
|
|
|
+
|
|
|
|
|
+ var hmsStrHtml = '<div class="jedatepropcon"><div class="jedatehmstitle">'+(lang.name == "cn" ? "\u65F6\u95F4\u9009\u62E9":"Time to choose")+'<div class="jedatehmsclose">×</div></div>' +
|
|
|
|
|
+ '<div class="jedateproptext">'+lang.times[0]+'</div><div class="jedateproptext">'+lang.times[1]+'</div><div class="jedateproptext">'+lang.times[2]+'</div>' +
|
|
|
|
|
+ '<div class="jedatehmscon jedateprophours"></div><div class="jedatehmscon jedatepropminutes"></div><div class="jedatehmscon jedatepropseconds"></div></div>';
|
|
|
|
|
+
|
|
|
|
|
+ var botStrHtml = '<div class="botflex jedatehmsshde"><ul class="jedatehms"><li><input type="text" maxlength="2" numval="23" hms="0"></li><i>:</i><li><input type="text" maxlength="2" numval="59" hms="1"></li><i>:</i><li><input type="text" maxlength="2" numval="59" hms="2"></li></ul></div>' +
|
|
|
|
|
+ '<div class="botflex jedatebtn"><span class="jedateok">'+lang.yes+'</span><span class="jedatetodaymonth">'+lang.today+'</span><span class="jedateclear">'+lang.clear+'</span></div>';
|
|
|
|
|
+
|
|
|
|
|
+ var ymBtnHtml = '<p><span class="jedateymchle"><<</span><span class="jedateymchri">>></span><span class="jedateymchok">'+lang.close+'</span></p>';
|
|
|
|
|
+ //设置html到对应的DOM中
|
|
|
|
|
+ if (subhh){
|
|
|
|
|
+ boxCell.children(".jedatetop,.jedatetopym,.jedaol,.jedaul").remove();
|
|
|
|
|
+ }else {
|
|
|
|
|
+ topCell.append(topStrHtml);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isYYMM || isYY){
|
|
|
|
|
+ boxCell.children(".jedatetopym,.jedaol").remove();
|
|
|
|
|
+ //设置格式为 YYYY-MM 类型的
|
|
|
|
|
+ botCell.find(".jedatetodaymonth").hide();
|
|
|
|
|
+ topCell.children().css({"width": "100%"}).first().remove();
|
|
|
|
|
+ topCell.children().find(".pndrop").remove();
|
|
|
|
|
+ boxCell.find(isYYMM ? ".jedaym" : ".jedayy").append(that.eachYM(opts,tmsArr[0], tmsArr[1],boxCell));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ topymCell.append(ymBtnHtml);
|
|
|
|
|
+ olCell.append(function () {
|
|
|
|
|
+ //设置周显示
|
|
|
|
|
+ $.each(lang.weeks, function(i, week) {
|
|
|
|
|
+ weekHtml += '<li class="weeks" data-week="' + week + '">' + week + "</li>";
|
|
|
});
|
|
});
|
|
|
- } else {
|
|
|
|
|
- if (!isformat) QD(Cell + " .jedatebot .jedatehms")[0].style.display = "none";
|
|
|
|
|
- QD(Cell + " .jedatebot .jedatebtn")[0].style.width = "100%";
|
|
|
|
|
- }
|
|
|
|
|
- if (!isformat) {
|
|
|
|
|
- for (var i = 0; i < jeDt.weeks.length; i++) {
|
|
|
|
|
- weekHtml += '<li class="weeks" data-week="' + jeDt.weeks[i] + '">' + jeDt.weeks[i] + "</li>";
|
|
|
|
|
- }
|
|
|
|
|
- jeDt.html(QD(Cell + " .jedaol")[0], weekHtml);
|
|
|
|
|
- that.getDateStr(arrTime[0], arrTime[1], arrTime[2]);
|
|
|
|
|
- that.YearAndMonth(that, opts, self, arrTime);
|
|
|
|
|
- } else {
|
|
|
|
|
- jeDt.html(QD(Cell + " .jedaym")[0], that.onlyYMStr(arrTime[0], arrTime[1]));
|
|
|
|
|
- jeDt.text(QD(Cell + " .jedateym .jedateyearmonth")[0], arrTime[0] + "年" + jeDt.digit(arrTime[1]) + "月");
|
|
|
|
|
- that.onlyYMevents(that, opts, self, arrTime);
|
|
|
|
|
- }
|
|
|
|
|
- jeDt.shdeCell(false);
|
|
|
|
|
- that.orien(QD(Cell)[0], self);
|
|
|
|
|
- that.events(that, opts, self, arrTime);
|
|
|
|
|
- },
|
|
|
|
|
- onlyYMStr:function(y, m) {
|
|
|
|
|
- var onlyYM = "";
|
|
|
|
|
- jeDt.each(jeDt.montharr, function(i, val) {
|
|
|
|
|
- onlyYM += "<li " + (m == val ? 'class="action"' :"") + ' data-onym="' + y + "-" + jeDt.digit(val) + '">' + y + "年" + jeDt.digit(val) + "月</li>";
|
|
|
|
|
|
|
+ return weekHtml;
|
|
|
});
|
|
});
|
|
|
- return onlyYM;
|
|
|
|
|
- },
|
|
|
|
|
- onlyYMevents:function(that, opts, self, arrTime) {
|
|
|
|
|
- var ymPre = QD(Cell + " .jedateym .ymprev")[0], ymNext = QD(Cell + " .jedateym .ymnext")[0], ony = parseInt(arrTime[0]), onm = parseInt(arrTime[1]);
|
|
|
|
|
- jeDt.each([ ymPre, ymNext ], function(i, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- var ym = cls == ymPre ? ony -= 1 :ony += 1;
|
|
|
|
|
- jeDt.html(QD(Cell + " .jedaym")[0], that.onlyYMStr(ym, onm));
|
|
|
|
|
- that.events(that, opts, self, arrTime);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ botCell.append(botStrHtml);
|
|
|
|
|
+ //是否显示清除按钮
|
|
|
|
|
+ jet.isBool(opts.isClear) ? "" : botCell.find(".jedateclear").hide();
|
|
|
|
|
+ //是否显示今天按钮
|
|
|
|
|
+ (isYYMM || isYY || subhh) ? botCell.find(".jedatetodaymonth").hide() : (jet.isBool(opts.isToday) ? "" : botCell.find(".jedatetodaymonth").hide());
|
|
|
|
|
+
|
|
|
|
|
+ //是否显示确认按钮
|
|
|
|
|
+ jet.isBool(opts.isok) ? "" : botCell.find(".jedateok").hide();
|
|
|
|
|
+
|
|
|
|
|
+ //开始循环创建日期--天
|
|
|
|
|
+ if(/\DD/.test(jet.format)){
|
|
|
|
|
+ that.createDaysHtml(tmsArr[0], tmsArr[1], opts,boxCell);
|
|
|
|
|
+ }
|
|
|
|
|
+ //设置时分秒
|
|
|
|
|
+ if(/\hh/.test(jet.format)) {
|
|
|
|
|
+ hmsCell.append(hmsStrHtml).addClass(subhh ? "jedatepropfix" :"jedateproppos").css({"display": subhh ? "block" : "none"});
|
|
|
|
|
+ var hmsarr = that.isContainhh(jet.format),hmsset = opts.hmsSetVal||{},
|
|
|
|
|
+ hmsobj = ((objCell.val() || objCell.text()) == "" && jet.isObj(hmsset)) ? hmsset : {"hh":tmsArr[3], "mm":tmsArr[4], "ss":tmsArr[5]};
|
|
|
|
|
+ $.each(["hh", "mm", "ss"], function (i, hms) {
|
|
|
|
|
+ var undezz = (hmsarr[i] == undefined || hmsarr[i] == "zz"),
|
|
|
|
|
+ inphms = botCell.find('input[hms=' + i + ']');
|
|
|
|
|
+ inphms.val(undezz ? "00":jet.digit(hmsobj[hms])).attr("readOnly",jet.isBool(opts.ishmsVal) ? false:true);
|
|
|
|
|
+ if (hmsarr.length != 0 && undezz) inphms.attr("disabled", true);
|
|
|
});
|
|
});
|
|
|
- },
|
|
|
|
|
- //方位辨别
|
|
|
|
|
- orien:function(obj, self, pos) {
|
|
|
|
|
- var tops, rect = self.getBoundingClientRect();
|
|
|
|
|
- obj.style.left = rect.left + (pos ? 0 :jeDt.scroll(1)) + "px";
|
|
|
|
|
- tops = (rect.bottom + obj.offsetHeight / 1.5 <= jeDt.winarea()) ?
|
|
|
|
|
- rect.bottom - 1 : rect.top > obj.offsetHeight / 1.5 ? rect.top - obj.offsetHeight + 1 :jeDt.winarea() - obj.offsetHeight;
|
|
|
|
|
- obj.style.top = Math.max(tops + (pos ? 0 :jeDt.scroll()) + 1, 1) + "px";
|
|
|
|
|
- },
|
|
|
|
|
- getDateStr:function(y, m, d) {
|
|
|
|
|
- var that = this, opts = that.config, dayStr = "", m = jeDt.digit(m);
|
|
|
|
|
- jeDt.text(QD(Cell + " .jedateyear")[0], y + "年").attr(QD(Cell + " .jedateyear")[0], "data-year", y);
|
|
|
|
|
- jeDt.text(QD(Cell + " .jedatemonth")[0], m + "月").attr(QD(Cell + " .jedatemonth")[0], "data-month", m);
|
|
|
|
|
- //是否显示节日
|
|
|
|
|
- var isfestival = function(day, n) {
|
|
|
|
|
- return opts.festival ? jeDt.festival(day, n) :n;
|
|
|
|
|
- };
|
|
|
|
|
- var parseArr = function(str) {
|
|
|
|
|
- var timeArr = str.split(" ");
|
|
|
|
|
- return timeArr[0].split("-");
|
|
|
|
|
- };
|
|
|
|
|
- //先得到当前月第一天是星期几.
|
|
|
|
|
- var date = setMonthDays(y, m), weekday = new Date(y, parseInt(m) - 1, 1).getDay();
|
|
|
|
|
- //根据这个星期算前面几天的上个月最后几天.
|
|
|
|
|
- var pervLastDay = weekday != 0 ? weekday :weekday + 7;
|
|
|
|
|
- //得到上个月最后一天;
|
|
|
|
|
- var pervMonthlastDay = getPervMonthLastDay(y, m), currentMonthDays = getPervMonthLastDay(y, parseInt(m) + 1);
|
|
|
|
|
- //上月最后几天循环
|
|
|
|
|
- var lastdays = pervMonthlastDay - pervLastDay;
|
|
|
|
|
- //判断是否超出允许的日期范围
|
|
|
|
|
- var startDay = 1, minArr = parseArr(opts.minDate), maxArr = parseArr(opts.maxDate), endDay = currentMonthDays, thisDate = new Date(y, m, d), firstDate = new Date(y, m, 1), lastDate = new Date(y, m, currentMonthDays), minTime = new Date(minArr[0], minArr[1], minArr[2]), maxTime = new Date(maxArr[0], maxArr[1], maxArr[2]), minDateDay = minTime.getDate();
|
|
|
|
|
- if (minTime > lastDate) {
|
|
|
|
|
- startDay = parseInt(currentMonthDays) + 1;
|
|
|
|
|
- } else if (minTime >= firstDate && minTime <= lastDate) {
|
|
|
|
|
- startDay = minDateDay;
|
|
|
|
|
- } else if (minTime >= firstDate) {}
|
|
|
|
|
- if (maxTime) {
|
|
|
|
|
- var maxDateDay = maxTime.getDate();
|
|
|
|
|
- if (maxTime < firstDate) {
|
|
|
|
|
- endDay = startDay;
|
|
|
|
|
- } else if (maxTime >= firstDate && maxTime <= lastDate) {
|
|
|
|
|
- endDay = maxDateDay;
|
|
|
|
|
|
|
+ }else {
|
|
|
|
|
+ botCell.find(".jedatehmsshde").hide();
|
|
|
|
|
+ botCell.find(".jedatebtn").css({width:"100%"});
|
|
|
|
|
+ }
|
|
|
|
|
+ //是否开启时间选择
|
|
|
|
|
+ if(!jet.isBool(opts.isTime)){
|
|
|
|
|
+ botCell.find(".botflex").css({width:"100%"});
|
|
|
|
|
+ botCell.find(".jedatehmsshde").hide();
|
|
|
|
|
+ }
|
|
|
|
|
+ //绑定各个事件
|
|
|
|
|
+ that.eventsDate(opts,boxCell);
|
|
|
|
|
+ if($($(jet.boxelem).attr(jefix)).length == 0){
|
|
|
|
|
+ var datepos = opts.position||[];
|
|
|
|
|
+ datepos.length > 0 ? boxCell.css({"top":datepos[0],"left":datepos[1]}) : that.orien(boxCell, objCell);
|
|
|
|
|
+ }
|
|
|
|
|
+ setTimeout(function () {
|
|
|
|
|
+ opts.success && opts.success(objCell);
|
|
|
|
|
+ }, 50);
|
|
|
|
|
+ };
|
|
|
|
|
+ //循环生成日历
|
|
|
|
|
+ jedfn.createDaysHtml = function(ys, ms, opts, boxCell){
|
|
|
|
|
+ var that = this, year = parseInt(ys), month = parseInt(ms), dateHtml = "",
|
|
|
|
|
+ count = 0,lang = opts.language || config.language, ends = opts.isvalid||[],
|
|
|
|
|
+ minArr = jet.reMacth(jet.minDate), minNum = minArr[0] + minArr[1] + minArr[2],
|
|
|
|
|
+ maxArr = jet.reMacth(jet.maxDate), maxNum = maxArr[0] + maxArr[1] + maxArr[2],
|
|
|
|
|
+ firstWeek = new Date(year, month - 1, 1).getDay() || 7,
|
|
|
|
|
+ daysNum = jet.getDaysNum(year, month), prevM = jet.getPrevMonth(year, month),
|
|
|
|
|
+ prevDaysNum = jet.getDaysNum(year, prevM.m), nextM = jet.getNextMonth(year, month),
|
|
|
|
|
+ currOne = jet.currDate.getFullYear() + "-" + jet.digit(jet.currDate.getMonth() + 1) + "-" + jet.digit(1),
|
|
|
|
|
+ thisOne = year + "-" + jet.digit(month) + "-" + jet.digit(1);
|
|
|
|
|
+ boxCell.find(".jedateyear").attr("year", year).text(year+(lang.name == "cn" ? "\u5e74":""));
|
|
|
|
|
+ boxCell.find(".jedatemonth").attr("month", month).text(month+(lang.name == "cn" ? "\u6708":""));
|
|
|
|
|
+ //设置时间标注
|
|
|
|
|
+ var mark = function (my, mm, md) {
|
|
|
|
|
+ var Marks = opts.marks, contains = function(arr, obj) {
|
|
|
|
|
+ var len = arr.length;
|
|
|
|
|
+ while (len--) {
|
|
|
|
|
+ if (arr[len] === obj) return true;
|
|
|
}
|
|
}
|
|
|
|
|
+ return false;
|
|
|
|
|
+ };
|
|
|
|
|
+ return $.isArray(Marks) && Marks.length > 0 && contains(Marks, my + "-" + jet.digit(mm) + "-" + jet.digit(md)) ? '<i class="marks"></i>' :"";
|
|
|
|
|
+ };
|
|
|
|
|
+ //是否显示节日
|
|
|
|
|
+ var isfestival = function(y, m ,d) {
|
|
|
|
|
+ var festivalStr;
|
|
|
|
|
+ if(opts.festival == true && lang.name == "cn"){
|
|
|
|
|
+ var lunar = jeLunar(y, m - 1, d), feslunar = (lunar.solarFestival || lunar.lunarFestival),
|
|
|
|
|
+ lunartext = (feslunar && lunar.jieqi) != "" ? feslunar : (lunar.jieqi || lunar.showInLunar);
|
|
|
|
|
+ festivalStr = '<p><span class="solar">' + d + '</span><span class="lunar">' + lunartext + '</span></p>';
|
|
|
|
|
+ }else{
|
|
|
|
|
+ festivalStr = '<p class="nolunar">' + d + '</p>';
|
|
|
}
|
|
}
|
|
|
- //循环上月剩余的天数
|
|
|
|
|
- for (var p = pervLastDay - 1; p >= 0; p--) {
|
|
|
|
|
- var py, pm, preCls, preDays = jeDt.digit(pervMonthlastDay - p);
|
|
|
|
|
- m == 1 ? (py = parseInt(y) - 1, pm = 13) :(py = y, pm = m);
|
|
|
|
|
- var thatpretm = parseInt(py.toString() + jeDt.digit(parseInt(pm) - 1).toString() + preDays.toString()), minpretm = parseInt(minArr[0].toString() + jeDt.digit(minArr[1]).toString() + jeDt.digit(minArr[2]).toString()), maxnexttm = parseInt(maxArr[0].toString() + jeDt.digit(maxArr[1]).toString() + jeDt.digit(maxArr[2]).toString());
|
|
|
|
|
- preCls = thatpretm >= minpretm && thatpretm <= maxnexttm ? "prevdate" :preCls = "disabled";
|
|
|
|
|
- dayStr += "<li class='" + preCls + "' data-y='" + py + "' data-m='" + (parseInt(pm) - 1) + "' data-d='" + preDays + "'>" + isfestival(parseInt(pm) - 1 + "." + preDays, preDays) + "</li>";
|
|
|
|
|
- }
|
|
|
|
|
- //循环本月的天数,将日期按允许的范围分三段拼接
|
|
|
|
|
- for (var i = 1; i < startDay; i++) {
|
|
|
|
|
- i = jeDt.digit(i);
|
|
|
|
|
- dayStr += '<li class="disabled" data-y="' + y + '" data-m="' + m + '" data-d="' + i + '">' + isfestival(m + "." + i, i) + "</li>";
|
|
|
|
|
|
|
+ return festivalStr;
|
|
|
|
|
+ };
|
|
|
|
|
+ //判断是否在限制的日期之中
|
|
|
|
|
+ var dateOfLimit = function(Y, M, D, isMonth){
|
|
|
|
|
+ var thatNum = (Y + "-" + jet.digit(M) + "-" + jet.digit(D)).replace(/\-/g, '');
|
|
|
|
|
+ if(isMonth){
|
|
|
|
|
+ if (parseInt(thatNum) >= parseInt(minNum) && parseInt(thatNum) <= parseInt(maxNum)) return true;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ if (parseInt(minNum) > parseInt(thatNum) || parseInt(maxNum) < parseInt(thatNum)) return true;
|
|
|
}
|
|
}
|
|
|
- for (var j = startDay; j <= endDay; j++) {
|
|
|
|
|
- var current = "";
|
|
|
|
|
- j = jeDt.digit(j);
|
|
|
|
|
- if (/*y==value.year && m==value.month+1&& */ d == j) {
|
|
|
|
|
- current = "action";
|
|
|
|
|
|
|
+ };
|
|
|
|
|
+ //判断禁用启用是长度,并设置成正则
|
|
|
|
|
+ if(ends.length > 0){
|
|
|
|
|
+ var dayreg = new RegExp(ends[0].replace(/,/g,"|"));
|
|
|
|
|
+ }
|
|
|
|
|
+ //上一月剩余天数
|
|
|
|
|
+ for (var p = prevDaysNum - firstWeek + 1; p <= prevDaysNum; p++, count++) {
|
|
|
|
|
+ var pmark = mark(prevM.y,prevM.m,p), pCls;
|
|
|
|
|
+ if(ends.length > 0){
|
|
|
|
|
+ if (dateOfLimit(prevM.y, prevM.m, p, false)){
|
|
|
|
|
+ pCls = "disabled";
|
|
|
|
|
+ }else {
|
|
|
|
|
+ if(dayreg.test(p)){
|
|
|
|
|
+ pCls = ends[1] == true ? "other" : "disabled";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ pCls = ends[1] == true ? "disabled" : "other";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- dayStr += '<li class="' + current + '" data-y="' + y + '" data-m="' + m + '" data-d="' + j + '">' + isfestival(m + "." + j, j) + "</li>";
|
|
|
|
|
- }
|
|
|
|
|
- for (var k = endDay + 1; k <= currentMonthDays; k++) {
|
|
|
|
|
- k = jeDt.digit(k);
|
|
|
|
|
- dayStr += '<li class="disabled" data-y="' + y + '" data-m="' + m + '" data-d="' + k + '">' + isfestival(m + "." + k, k) + "</li>";
|
|
|
|
|
|
|
+ }else {
|
|
|
|
|
+ pCls = dateOfLimit(prevM.y, prevM.m, p, false) ? "disabled" : "other";
|
|
|
}
|
|
}
|
|
|
- //循环补上下个月的开始几天
|
|
|
|
|
- var nextDayArr = [], nextMonthStartDays = 42 - pervLastDay - setMonthDays(y, m);
|
|
|
|
|
- for (var n = 1; n <= nextMonthStartDays; n++) {
|
|
|
|
|
- var ny, nm, nextCls;
|
|
|
|
|
- n = jeDt.digit(n);
|
|
|
|
|
- m >= 12 ? (ny = parseInt(y) + 1, nm = 0) :(ny = y, nm = m);
|
|
|
|
|
- var thatnexttm = parseInt(ny.toString() + jeDt.digit(parseInt(nm) + 1).toString() + jeDt.digit(n).toString()), minnexttm = parseInt(minArr[0].toString() + jeDt.digit(minArr[1]).toString() + jeDt.digit(minArr[2]).toString()), maxnexttm = parseInt(maxArr[0].toString() + jeDt.digit(maxArr[1]).toString() + jeDt.digit(maxArr[2]).toString());
|
|
|
|
|
- nextCls = thatnexttm <= maxnexttm && thatnexttm >= minnexttm ? "nextdate" :nextCls = "disabled";
|
|
|
|
|
- dayStr += "<li class='" + nextCls + "' data-y='" + ny + "' data-m='" + (parseInt(nm) + 1) + "' data-d='" + n + "'>" + isfestival(parseInt(nm) + 1 + "." + n, n) + "</li>";
|
|
|
|
|
- }
|
|
|
|
|
- jeDt.html(QD(Cell + " .jedaul")[0], dayStr);
|
|
|
|
|
- jeDt.attr(QD(Cell + " .monthprev")[0], "data-y", jeDt.digit(parseInt(m) - 1));
|
|
|
|
|
- jeDt.attr(QD(Cell + " .monthnext")[0], "data-y", jeDt.digit(parseInt(m) + 1));
|
|
|
|
|
- //计算某年某月有多少天,如果是二月,闰年28天否则29天
|
|
|
|
|
- function setMonthDays(year, month) {
|
|
|
|
|
- var er = year % 4 == 0 && year % 100 != 0 || year % 400 == 0 ? 29 :28;
|
|
|
|
|
- return [ 31, er, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ][month - 1];
|
|
|
|
|
|
|
+ dateHtml += '<li data-ymd="'+prevM.y+'-'+prevM.m+'-'+p+'" class='+pCls+'>'+(isfestival(prevM.y,prevM.m,p) + pmark)+'</li>';
|
|
|
|
|
+ }
|
|
|
|
|
+ //本月的天数
|
|
|
|
|
+ for(var b = 1; b <= daysNum; b++, count++){
|
|
|
|
|
+ var bCls = "", bmark = mark(year,month,b),
|
|
|
|
|
+ thisDate = (year + "-" + jet.digit(month) + "-" + jet.digit(b)); //本月当前日期
|
|
|
|
|
+ //判断日期是否在限制范围中,并高亮选中的日期
|
|
|
|
|
+ if(dateOfLimit(year, month, b, true)){
|
|
|
|
|
+ if(ends.length > 0){
|
|
|
|
|
+ if (jet.ymdDate == thisDate){
|
|
|
|
|
+ bCls = jet.ymdDate == thisDate ? "action" : (currOne != thisOne && thisOne == thisDate ? "action" : "");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ if(dayreg.test(b)){
|
|
|
|
|
+ bCls = ends[1] == true ? "" : "disabled";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ bCls = ends[1] == true ? "disabled":"";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ bCls = jet.ymdDate == thisDate ? "action" : (currOne != thisOne && thisOne == thisDate ? "action" : "");
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ bCls = "disabled";
|
|
|
}
|
|
}
|
|
|
- //得到指定月的上个月最后一天传进来按 12月算
|
|
|
|
|
- function getPervMonthLastDay(year, month) {
|
|
|
|
|
- //当月就是 yue-1 也就是计算机里面的0-11月份,那么算上个月的最后一天就是当月的0天
|
|
|
|
|
- return parseInt(new Date(year, month - 1, 0).getDate());
|
|
|
|
|
|
|
+ if (bCls == "action") boxCell.children("ul").attr("dateval",year+'-'+month+'-'+b);
|
|
|
|
|
+ dateHtml += '<li data-ymd="'+year+'-'+month+'-'+b+'" class='+(bCls != "" ? bCls : "")+'>'+(isfestival(year,month,b) + bmark)+'</li>';
|
|
|
|
|
+ }
|
|
|
|
|
+ //下一月开始天数
|
|
|
|
|
+ for(var n = 1, nlen = 42 - count; n <= nlen; n++){
|
|
|
|
|
+ var nmark = mark(nextM.y,nextM.m,n), nCls;
|
|
|
|
|
+ if(ends.length > 0){
|
|
|
|
|
+ if (dateOfLimit(nextM.y, nextM.m, n, false)){
|
|
|
|
|
+ nCls = "disabled";
|
|
|
|
|
+ }else {
|
|
|
|
|
+ if(dayreg.test(n)){
|
|
|
|
|
+ nCls = ends[1] == true ? "other" : "disabled";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ nCls = ends[1] == true ? "disabled":"other";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ nCls = dateOfLimit(nextM.y, nextM.m, n, false) ? "disabled" : "other";
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- events:function(that, opts, self, arrTime) {
|
|
|
|
|
- var yearPre = QD(Cell + " .yearprev")[0], yearNext = QD(Cell + " .yearnext")[0], monthPre = QD(Cell + " .monthprev")[0], monthNext = QD(Cell + " .monthnext")[0], newDate = new Date(), jedateyear = QD(Cell + " .jedateyear")[0], jedatemonth = QD(Cell + " .jedatemonth")[0], isformat = opts.format.match(/\w+|d+/g).join("-") == "YYYY-MM" ? true :false;
|
|
|
|
|
- if (!isformat) {
|
|
|
|
|
- //切换年
|
|
|
|
|
- jeDt.each([ yearPre, yearNext ], function(i, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- var y = parseInt(jeDt.attr(jedateyear, "data-year")), m = parseInt(jeDt.attr(jedatemonth, "data-month"));
|
|
|
|
|
- cls == yearPre ? y -= 1 :y += 1;
|
|
|
|
|
- var d = newDate.toLocaleDateString() == y + "/" + m + "/" + newDate.getDate() ? arrTime[2] :1;
|
|
|
|
|
- that.getDateStr(y, m, d);
|
|
|
|
|
- that.clickLiDays(that, opts, self);
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- //切换月
|
|
|
|
|
- jeDt.each([ monthPre, monthNext ], function(i, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- var y = parseInt(jeDt.attr(jedateyear, "data-year")), m = parseInt(jeDt.attr(jedatemonth, "data-month"));
|
|
|
|
|
- if (cls == monthPre) {
|
|
|
|
|
- m == 1 ? (y -= 1, m = 12) :m -= 1;
|
|
|
|
|
|
|
+ dateHtml += '<li data-ymd="'+nextM.y+'-'+nextM.m+'-'+n+'" class='+nCls+'>'+(isfestival(nextM.y,nextM.m,n) + nmark)+'</li>';
|
|
|
|
|
+ }
|
|
|
|
|
+ //把日期拼接起来并插入
|
|
|
|
|
+ boxCell.find(".jedaul").empty().html(dateHtml);
|
|
|
|
|
+ that.chooseDays(opts,boxCell);
|
|
|
|
|
+ };
|
|
|
|
|
+ jedfn.eachStrhms = function(opts,boxCell) {
|
|
|
|
|
+ var that = this, hmsArr = [],
|
|
|
|
|
+ minDates = jet.minDate.split(" "), maxDates = jet.maxDate.split(" "),
|
|
|
|
|
+ mins = minDates[1] == undefined ? "00:00:00" : minDates[1],
|
|
|
|
|
+ maxs = maxDates[1] == undefined ? "00:00:00" : maxDates[1],
|
|
|
|
|
+ minDate = minDates[0], maxDate = maxDates[0],
|
|
|
|
|
+ minhms = jet.reMacth(mins), maxhms = jet.reMacth(maxs);
|
|
|
|
|
+ //生成时分秒
|
|
|
|
|
+ $.each([ 24, 60, 60 ], function(i, len) {
|
|
|
|
|
+ var hmsStr = "", hmsCls = "", hmsarr = that.isContainhh(jet.format),
|
|
|
|
|
+ inputs = boxCell.find(".jedatehms input"),
|
|
|
|
|
+ textem = inputs.eq(i).val();
|
|
|
|
|
+ for (var h = 0; h < len; h++) {
|
|
|
|
|
+ h = jet.digit(h);
|
|
|
|
|
+ if (jet.isBool(opts.hmsLimit)) {
|
|
|
|
|
+ hmsCls = (hmsarr.length != 0 && (hmsarr[i] == undefined || hmsarr[i] == "zz")) ? "disabled" : (textem == h ? "action" : "");
|
|
|
|
|
+ if (hmsarr.length != 0 && (hmsarr[i] == undefined || hmsarr[i] == "zz")) {
|
|
|
|
|
+ hmsCls = "disabled";
|
|
|
|
|
+ }else {
|
|
|
|
|
+ var current = jet.ymdDate + " ", min = minDate + " ", max = maxDate + " ";
|
|
|
|
|
+ for (var j = 0; j <= i; j++) {
|
|
|
|
|
+ if (j == i) {
|
|
|
|
|
+ current += h + ":";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ current += inputs.eq(j).val() + ":";
|
|
|
|
|
+ }
|
|
|
|
|
+ min += minhms[j] + ":";
|
|
|
|
|
+ max += maxhms[j] + ":";
|
|
|
|
|
+ }
|
|
|
|
|
+ current = new Date(current);
|
|
|
|
|
+ min = new Date(min);
|
|
|
|
|
+ max = new Date(max);
|
|
|
|
|
+
|
|
|
|
|
+ if (current < min || current > max) {
|
|
|
|
|
+ hmsCls = h == textem ? "disabled action" :"disabled";
|
|
|
} else {
|
|
} else {
|
|
|
- m == 12 ? (y += 1, m = 1) :m += 1;
|
|
|
|
|
|
|
+ hmsCls = h == textem ? "action" :"";
|
|
|
}
|
|
}
|
|
|
- var d = newDate.toLocaleDateString() == y + "/" + m + "/" + newDate.getDate() ? arrTime[2] :1;
|
|
|
|
|
- that.getDateStr(y, m, d);
|
|
|
|
|
- that.clickLiDays(that, opts, self);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ //判断限制时间范围的状态
|
|
|
|
|
+ if (h < minhms[i] || h > maxhms[i]){
|
|
|
|
|
+ hmsCls = h == textem ? "disabled action" : "disabled";
|
|
|
|
|
+ }else {
|
|
|
|
|
+ hmsCls = h == textem ? "action" :"";
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ hmsStr += '<p class="' + hmsCls + '">' + h + "</p>";
|
|
|
|
|
+ }
|
|
|
|
|
+ hmsArr.push(hmsStr);
|
|
|
|
|
+ });
|
|
|
|
|
+ return hmsArr;
|
|
|
|
|
+ };
|
|
|
|
|
+ //循环生成年或月
|
|
|
|
|
+ jedfn.eachYM = function(opts,y, m,boxCell) {
|
|
|
|
|
+ var ymStr = "",lang = opts.language || config.language,ymtext,
|
|
|
|
|
+ objCell = this.valCell, date = new Date();
|
|
|
|
|
+ if (jet.testFormat(jet.format,"YYYY")){
|
|
|
|
|
+ jet.yearArr = new Array(15);
|
|
|
|
|
+ $.each(jet.yearArr, function(i) {
|
|
|
|
|
+ var minArr = jet.parseMatch(jet.minDate), maxArr = jet.parseMatch(jet.maxDate),
|
|
|
|
|
+ minY = minArr[0], maxY = maxArr[0], year = y - 7 + i,
|
|
|
|
|
+ objyear = jet.reMacth(jet.isValHtml(objCell) ? objCell.val() : objCell.text()),
|
|
|
|
|
+ getyear = ((objCell.val() || objCell.text()) == "") ? date.getFullYear() : objyear[0];
|
|
|
|
|
+ if (year < minY || year > maxY) {
|
|
|
|
|
+ ymStr += "<li class='disabled' yy='" + year + "'>" + year + "</li>";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ymStr += "<li class='"+(parseInt(getyear) == year ? "action" :"")+"' yy='" + year + "'>" + year + "</li>";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(parseInt(getyear) == year) boxCell.children("ul").attr("dateval",year);
|
|
|
|
|
+ });
|
|
|
|
|
+ ymtext = y ;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ $.each(lang.month, function(i, val) {
|
|
|
|
|
+ var minArr = jet.parseMatch(jet.minDate), maxArr = jet.parseMatch(jet.maxDate),
|
|
|
|
|
+ thisDate = new Date(y, jet.digit(val), "01"), minTime = new Date(minArr[0], minArr[1], minArr[2]), maxTime = new Date(maxArr[0], maxArr[1], maxArr[2]);
|
|
|
|
|
+ if (thisDate < minTime || thisDate > maxTime) {
|
|
|
|
|
+ ymStr += "<li class='disabled' ym='" + y + "-" + jet.digit(val) + "'>" + y + "-" + jet.digit(val) + "</li>";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ymStr += "<li class='"+(m == val ? "action" :"")+"' ym='" + y + "-" + jet.digit(val) + "'>" + y + "-" + jet.digit(val) + "</li>";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(m == val) boxCell.children("ul").attr("dateval",y + "-" + jet.digit(val));
|
|
|
|
|
+ });
|
|
|
|
|
+ ymtext = y + "-" + jet.digit(m);
|
|
|
|
|
+ }
|
|
|
|
|
+ boxCell.find(".jedatetop .jedateyear").text(ymtext);
|
|
|
|
|
+ return ymStr;
|
|
|
|
|
+ };
|
|
|
|
|
+ //方位辨别
|
|
|
|
|
+ jedfn.orien = function(obj, self, pos) {
|
|
|
|
|
+ var tops, leris, ortop, orleri, rect = jet.fixed ? self[0].getBoundingClientRect() : obj[0].getBoundingClientRect();
|
|
|
|
|
+ if(jet.fixed) {
|
|
|
|
|
+ //根据目标元素计算弹层位置
|
|
|
|
|
+ leris = rect.right + obj.outerWidth() / 1.5 >= jet.winarea(1) ? rect.right - obj.outerWidth() : rect.left + (pos ? 0 : jet.docScroll(1));
|
|
|
|
|
+ tops = rect.bottom + obj.outerHeight() / 1 <= jet.winarea() ? rect.bottom - 1 : rect.top > obj.outerHeight() / 1.5 ? rect.top - obj.outerHeight() - 1 : jet.winarea() - obj.outerHeight();
|
|
|
|
|
+ ortop = Math.max(tops + (pos ? 0 :jet.docScroll()) + 1, 1) + "px", orleri = leris + "px";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ //弹层位置位于页面上下左右居中
|
|
|
|
|
+ ortop = "50%", orleri = "50%";
|
|
|
|
|
+ obj.css({"margin-top":-(rect.height / 2),"margin-left":-(rect.width / 2)});
|
|
|
|
|
+ }
|
|
|
|
|
+ obj.css({"top":ortop,"left":orleri});
|
|
|
|
|
+ };
|
|
|
|
|
+ //农历方位辨别
|
|
|
|
|
+ jedfn.lunarOrien = function(obj, self, pos) {
|
|
|
|
|
+ var tops, leris, ortop, orleri, rect =self[0].getBoundingClientRect();
|
|
|
|
|
+ leris = rect.right + obj[0].offsetWidth / 1.5 >= jet.winarea(1) ? rect.right - obj[0].offsetWidth : rect.left + (pos ? 0 : jet.docScroll(1));
|
|
|
|
|
+ tops = rect.bottom + obj[0].offsetHeight / 1 <= jet.winarea() ? rect.bottom - 1 : rect.top > obj[0].offsetHeight / 1.5 ? rect.top - obj[0].offsetHeight - 1 : jet.winarea() - obj[0].offsetHeight;
|
|
|
|
|
+ ortop = Math.max(tops + (pos ? 0 :jet.docScroll()) + 1, 1) + "px", orleri = leris + "px";
|
|
|
|
|
+ return {top: ortop, left: orleri }
|
|
|
|
|
+ };
|
|
|
|
|
+ //关闭层
|
|
|
|
|
+ jedfn.dateClose = function() {
|
|
|
|
|
+ if($($(jet.boxelem).attr(jefix)).length == 0) {
|
|
|
|
|
+ $(jet.boxelem).remove();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ // 提示层
|
|
|
|
|
+ jedfn.notice = function(text, boxCell) {
|
|
|
|
|
+ var container = boxCell.find('.jedatenotice');
|
|
|
|
|
+ container.html(text);
|
|
|
|
|
+ container.show();
|
|
|
|
|
+ setTimeout(function() {
|
|
|
|
|
+ container.hide();
|
|
|
|
|
+ }, 2000);
|
|
|
|
|
+ };
|
|
|
|
|
+ //为日期绑定各类事件
|
|
|
|
|
+ jedfn.eventsDate = function(opts,boxCell) {
|
|
|
|
|
+ var that = this, elemCell = that.valCell, lang = opts.language || config.language,
|
|
|
|
|
+ ishhmat = jet.checkFormat(jet.format).substring(0, 2) == "hh";
|
|
|
|
|
+ if (!ishhmat) {
|
|
|
|
|
+ that.chooseYearMonth(opts, boxCell);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (jet.testFormat(jet.format,"YYYY") || jet.testFormat(jet.format,"YYYY-MM")){
|
|
|
|
|
+ that.preNextYearMonth(opts,boxCell);
|
|
|
|
|
+ that.onlyYMevents(opts,boxCell);
|
|
|
|
|
+ }
|
|
|
|
|
+ //判断日期格式中是否包小时(hh)
|
|
|
|
|
+ if(/\hh/.test(jet.format)){
|
|
|
|
|
+ var hsCls = boxCell.find(".jedateprophours"),
|
|
|
|
|
+ msCls = boxCell.find(".jedatepropminutes"),
|
|
|
|
|
+ ssCls = boxCell.find(".jedatepropseconds"),
|
|
|
|
|
+ prophms = boxCell.find(".jedateprophms"),
|
|
|
|
|
+ screlTopNum = 155;
|
|
|
|
|
+ var sethmsStrHtml = function () {
|
|
|
|
|
+ var hmsStr = that.eachStrhms(opts, boxCell), hmsarr = that.isContainhh(jet.format);
|
|
|
|
|
+ prophms.css("display","block");
|
|
|
|
|
+ $.each([ hsCls, msCls, ssCls ], function(i, hmsCls) {
|
|
|
|
|
+ if (hmsCls.html() == "") hmsCls.html(hmsStr[i]);
|
|
|
});
|
|
});
|
|
|
- //生成定位时分秒
|
|
|
|
|
- jeDt.each(QD(Cell + " .jedatebot .jedatehms em"), function(i, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function() {
|
|
|
|
|
- var hmsStr = "", acton, hmscell = QD(Cell + " .jedateprophms")[0], hmslen = jeDt.attr(cls, "data-hms"), hmsstxt = [ "小时", "分钟", "秒数" ], removeEmpty = function() {
|
|
|
|
|
- jeDt.removeClass(hmscell, hmslen == 24 ? "jedateh" :"jedatems");
|
|
|
|
|
- jeDt.html(hmscell, "");
|
|
|
|
|
- };
|
|
|
|
|
- hmsStr += '<div class="jedatehmstitle">' + hmsstxt[i] + '<div class="jedatehmsclose">×</div></div>';
|
|
|
|
|
- for (var h = 0; h < hmslen; h++) {
|
|
|
|
|
- h = jeDt.digit(h);
|
|
|
|
|
- acton = jeDt.text(cls) == h ? "action" :"";
|
|
|
|
|
- hmsStr += '<p class="' + acton + '">' + h + "</p>";
|
|
|
|
|
- }
|
|
|
|
|
- jeDt.removeClass(hmscell, hmslen == 24 ? "jedatems" :"jedateh").addClass(hmscell, hmslen == 24 ? "jedateh" :"jedatems");
|
|
|
|
|
- jeDt.html(hmscell, hmsStr);
|
|
|
|
|
- jeDt.each(QD(Cell + " .jedateprophms p"), function(i, p) {
|
|
|
|
|
- jeDt.on(p, "click", function() {
|
|
|
|
|
- jeDt.html(cls, jeDt.digit(jeDt.text(p)));
|
|
|
|
|
- removeEmpty();
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- jeDt.each(QD(Cell + " .jedateprophms .jedatehmstitle"), function(i, c) {
|
|
|
|
|
- jeDt.on(c, "click", function() {
|
|
|
|
|
- removeEmpty();
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ //计算当前时分秒的位置
|
|
|
|
|
+ $.each([ "hours", "minutes", "seconds" ], function(i, hms) {
|
|
|
|
|
+ var hmsCls = boxCell.find(".jedateprop" + hms),
|
|
|
|
|
+ achmsCls = hmsCls.find(".action"),
|
|
|
|
|
+ onhmsPCls = hmsCls.find("p");
|
|
|
|
|
+ if(hmsarr.length != 0 && (hmsarr[i] != undefined && hmsarr[i] != "zz")) {
|
|
|
|
|
+ hmsCls[0].scrollTop = achmsCls[0].offsetTop - screlTopNum;
|
|
|
|
|
+ }
|
|
|
|
|
+ onhmsPCls.on("click", function() {
|
|
|
|
|
+ var _this = $(this);
|
|
|
|
|
+ if (_this.hasClass("disabled")) return;
|
|
|
|
|
+ _this.addClass('action').siblings().removeClass('action');
|
|
|
|
|
+ boxCell.find(".jedatebot .jedatehms input").eq(i).val(jet.digit(_this.text()));
|
|
|
|
|
+ if (!ishhmat) boxCell.find(".jedateprophms").hide();
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
- //今天
|
|
|
|
|
- jeDt.on(QD(Cell + " .jedatebot .jedatetodaymonth")[0], "click", function() {
|
|
|
|
|
- var toTime = [ newDate.getFullYear(), newDate.getMonth() + 1, newDate.getDate(), newDate.getHours(), newDate.getMinutes(), newDate.getSeconds() ];
|
|
|
|
|
- var gettoDate = jeDt.parse([ toTime[0], toTime[1], toTime[2] ], [ toTime[3], toTime[4], toTime[5] ], opts.format);
|
|
|
|
|
- that.getDateStr(toTime[0], toTime[1], toTime[2]);
|
|
|
|
|
- jeDt.isValHtml(self) ? jeDt.val(self, gettoDate) :jeDt.text(self, gettoDate);
|
|
|
|
|
- jeDt.html(QD(Cell)[0], "");
|
|
|
|
|
- jeDt.shdeCell(true);
|
|
|
|
|
- if (opts.choosefun === "function" || opts.choosefun != null) opts.choosefun(gettoDate);
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- jeDt.each(QD(Cell + " .jedaym li"), function(i, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- var atYM = jeDt.attr(cls, "data-onym").match(/\w+|d+/g);
|
|
|
|
|
- var getYMDate = jeDt.parse([ atYM[0], atYM[1], 1 ], [ 0, 0, 0 ], opts.format);
|
|
|
|
|
- jeDt.isValHtml(self) ? jeDt.val(self, getYMDate) :jeDt.text(self, getYMDate);
|
|
|
|
|
- jeDt.html(QD(Cell)[0], "");
|
|
|
|
|
- jeDt.shdeCell(true);
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+ //如果日期格式中前2个否包小时(hh),就直接显示,否则点击显示
|
|
|
|
|
+ if(ishhmat){
|
|
|
|
|
+ sethmsStrHtml();
|
|
|
|
|
+ prophms.find(".jedatehmsclose").css("display","none");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ boxCell.find(".jedatehms").on("click", function() {
|
|
|
|
|
+ sethmsStrHtml();
|
|
|
|
|
+ //关闭时分秒层
|
|
|
|
|
+ !ishhmat && prophms.find(".jedatehmsclose").on("click", function() {
|
|
|
|
|
+ prophms.css("display","none");
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
- //本月
|
|
|
|
|
- jeDt.on(QD(Cell + " .jedatebot .jedatetodaymonth")[0], "click", function() {
|
|
|
|
|
- var ymTime = [ newDate.getFullYear(), newDate.getMonth() + 1, newDate.getDate()],
|
|
|
|
|
- thisYMDate = jeDt.parse([ ymTime[0], ymTime[1], 0 ], [ 0, 0, 0 ], opts.format);
|
|
|
|
|
- jeDt.isValHtml(self) ? jeDt.val(self, thisYMDate) :jeDt.text(self, thisYMDate);
|
|
|
|
|
- jeDt.html(QD(Cell)[0], "");
|
|
|
|
|
- jeDt.shdeCell(true);
|
|
|
|
|
- if (opts.choosefun === "function" || opts.choosefun != null) opts.choosefun(thisYMDate);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- //清空
|
|
|
|
|
- jeDt.on(QD(Cell + " .jedatebot .jedateclear")[0], "click", function() {
|
|
|
|
|
- var clearVal = jeDt.isValHtml(self) ? jeDt.val(self) :jeDt.text(self);
|
|
|
|
|
- jeDt.isValHtml(self) ? jeDt.val(self, "") :jeDt.text(self, "");
|
|
|
|
|
- jeDt.html(QD(Cell)[0], "");
|
|
|
|
|
- jeDt.shdeCell(true);
|
|
|
|
|
- if(clearVal != ""){
|
|
|
|
|
- if (opts.clearfun === "function" || opts.clearfun != null) opts.clearfun(clearVal);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ //检查时间输入值,并对应到相应位置
|
|
|
|
|
+ boxCell.find(".jedatehms input").on("keyup", function() {
|
|
|
|
|
+ var _this = $(this), thatval = _this.val(),
|
|
|
|
|
+ hmsarr = that.isContainhh(jet.format),
|
|
|
|
|
+ hmsVal = parseInt(_this.attr("numval")),
|
|
|
|
|
+ thatitem = parseInt(_this.attr("hms"));
|
|
|
|
|
+ _this.val(thatval.replace(/\D/g,""));
|
|
|
|
|
+ //判断输入值是否大于所设值
|
|
|
|
|
+ if(thatval > hmsVal){
|
|
|
|
|
+ _this.val(hmsVal);
|
|
|
|
|
+ var onval = lang.name == "cn" ? "\u8F93\u5165\u503C\u4E0D\u80FD\u5927\u4E8E " : "The input value is not greater than ";
|
|
|
|
|
+ alert(onval+hmsVal);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(thatval == "") _this.val("00");
|
|
|
|
|
+ boxCell.find(".jedatehmscon").eq(thatitem).children().each(function(){
|
|
|
|
|
+ $(this).removeClass("action");
|
|
|
});
|
|
});
|
|
|
- //确认
|
|
|
|
|
- jeDt.on(QD(Cell + " .jedatebot .jedateok")[0], "click", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- var jedCell = isformat ? QD(Cell + " .jedaym li") :QD(Cell + " .jedaul li")
|
|
|
|
|
- if (!isformat) {
|
|
|
|
|
- var okTimeArr = [], okTime = [ parseInt(jeDt.attr(jedateyear, "data-year")), parseInt(jeDt.attr(jedatemonth, "data-month")), arrTime[2] ];
|
|
|
|
|
- jeDt.each(QD(Cell + " .jedatehms em"), function(l, tval) {
|
|
|
|
|
- okTimeArr.push(jeDt.text(tval));
|
|
|
|
|
- });
|
|
|
|
|
- var okVal = jeDt.val(self) != "" || jeDt.text(self) != "" ? jeDt.parse([ okTime[0], okTime[1], okTime[2] ], [ okTimeArr[0], okTimeArr[1], okTimeArr[2] ], opts.format) :"";
|
|
|
|
|
- that.getDateStr(okTime[0], okTime[1], okTime[2]);
|
|
|
|
|
- }else{
|
|
|
|
|
- var jedYM = jeDt.val(self) != "" || jeDt.text(self) != "" ? jeDt.attr(QD(Cell + " .jedaym .action")[0], "data-onym").match(/\w+|d+/g) :"",
|
|
|
|
|
- okVal = jeDt.val(self) != "" || jeDt.text(self) != "" ? jeDt.parse([ jedYM[0], jedYM[1], 1 ], [ 0, 0, 0 ], opts.format) :""
|
|
|
|
|
- }
|
|
|
|
|
- jeDt.each(jedCell, function(i, cls) {
|
|
|
|
|
- if (jeDt.attr(cls, "class") == "action") {
|
|
|
|
|
- jeDt.isValHtml(self) ? jeDt.val(self, okVal) :jeDt.text(self, okVal);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- jeDt.html(QD(Cell)[0], "");
|
|
|
|
|
- jeDt.shdeCell(true);
|
|
|
|
|
- if(okVal != ""){
|
|
|
|
|
- if (opts.okfun === "function" || opts.okfun != null) opts.okfun(okVal);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ boxCell.find(".jedatehmscon").eq(thatitem).children().eq(parseInt(_this.val().replace(/^0/g,''))).addClass("action");
|
|
|
|
|
+ $.each([ "hours", "minutes", "seconds" ], function(i, hms) {
|
|
|
|
|
+ var hmsCls = boxCell.find(".jedateprop" + hms),
|
|
|
|
|
+ achmsCls = hmsCls.find(".action");
|
|
|
|
|
+ if(hmsarr.length != 0 && hmsarr[i] != undefined) {
|
|
|
|
|
+ hmsCls[0].scrollTop = achmsCls[0].offsetTop - screlTopNum;
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
- //点击空白处隐藏
|
|
|
|
|
- jeDt.on(document, "click", function() {
|
|
|
|
|
- jeDt.shdeCell(true);
|
|
|
|
|
- jeDt.html(QD(Cell)[0], "");
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ //清空按钮清空日期时间
|
|
|
|
|
+ boxCell.find(".jedatebot .jedateclear").on("click", function(ev) {
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ var clearVal = jet.isValHtml(elemCell) ? elemCell.val() :elemCell.text();
|
|
|
|
|
+ jet.isValHtml(elemCell) ? elemCell.val("") :elemCell.text("");
|
|
|
|
|
+ that.dateClose();
|
|
|
|
|
+ if (clearVal != "") {
|
|
|
|
|
+ if (jet.isBool(opts.clearRestore)){
|
|
|
|
|
+ jet.minDate = opts.startMin || jet.minDate;
|
|
|
|
|
+ jet.maxDate = opts.startMax || jet.maxDate;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($.isFunction(opts.clearfun) || opts.clearfun != null) opts.clearfun(elemCell,clearVal);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ //今天按钮设置日期时间
|
|
|
|
|
+ boxCell.find(".jedatebot .jedatetodaymonth").on("click", function() {
|
|
|
|
|
+ var newDate = new Date(), toTime = [ newDate.getFullYear(), newDate.getMonth() + 1, newDate.getDate(), newDate.getHours(), newDate.getMinutes(), newDate.getSeconds() ],
|
|
|
|
|
+ gettoDate = jet.parse([ toTime[0], toTime[1], toTime[2] ], [ toTime[3], toTime[4], toTime[5] ], jet.format),
|
|
|
|
|
+ toDate = newDate.getFullYear()+"-"+jet.digit(newDate.getMonth() + 1)+"-"+jet.digit(newDate.getDate())+" "+jet.digit(newDate.getHours())+":"+jet.digit(newDate.getMinutes())+":"+jet.digit(newDate.getSeconds());
|
|
|
|
|
+
|
|
|
|
|
+ jet.isValHtml(elemCell) ? elemCell.val(gettoDate) :jet.text(gettoDate);
|
|
|
|
|
+ if($(boxCell.attr(jefix)).length > 0){
|
|
|
|
|
+ var fixCell = "#"+boxCell.attr("id");
|
|
|
|
|
+ that.setHtml(opts,fixCell);
|
|
|
|
|
+ }
|
|
|
|
|
+ that.dateClose();
|
|
|
|
|
+ if ($.isFunction(opts.choosefun) || opts.choosefun != null) opts.choosefun(elemCell,gettoDate,toDate);
|
|
|
|
|
+ });
|
|
|
|
|
+ //确认按钮设置日期时间
|
|
|
|
|
+ boxCell.find(".jedatebot .jedateok").on("click", function(ev) {
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ var date = new Date(),
|
|
|
|
|
+ okhms = (function() {
|
|
|
|
|
+ var hmsArr = [];
|
|
|
|
|
+ boxCell.find(".jedatehms input").each(function() {
|
|
|
|
|
+ var disattr = $(this).attr('disabled');
|
|
|
|
|
+ if(typeof(disattr) == "undefined") hmsArr.push($(this).val());
|
|
|
|
|
+ });
|
|
|
|
|
+ return hmsArr;
|
|
|
|
|
+ })(),
|
|
|
|
|
+ datevalue = boxCell.children("ul").attr("dateval");
|
|
|
|
|
+ var okymd = ishhmat ? [date.getFullYear(),date.getMonth() + 1,date.getDate()] : jet.reMacth(datevalue),
|
|
|
|
|
+ okformat = $($(jet.boxelem).attr(jefix)).length > 0 ? boxCell.attr("jeformat") : jet.format,
|
|
|
|
|
+ okVal = jet.parse([parseInt(okymd[0]), parseInt(okymd[1]), parseInt(okymd[2])], [okhms[0]||00, okhms[1]||00, okhms[2]||00], okformat),
|
|
|
|
|
+ okdate = (okymd[0]||date.getFullYear())+"-"+jet.digit(okymd[1]||date.getMonth() + 1)+"-"+jet.digit(okymd[2]||date.getDate())+" "+jet.digit(okhms[0]||00)+":"+jet.digit(okhms[1]||00)+":"+jet.digit(okhms[2]||00);
|
|
|
|
|
+
|
|
|
|
|
+ jet.isValHtml(elemCell) ? elemCell.val(okVal) :elemCell.text(okVal);
|
|
|
|
|
+ that.dateClose();
|
|
|
|
|
+ if ($.isFunction(opts.okfun) || opts.okfun != null) opts.okfun(elemCell,okVal,okdate);
|
|
|
|
|
+ });
|
|
|
|
|
+ //点击空白处隐藏
|
|
|
|
|
+ $(document).on("mouseup scroll", function(ev) {
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ if (ev.type === 'scroll' && !jet.isBool(opts.isdocScroll)) return;
|
|
|
|
|
+ if (jet.boxelem == "#jedatebox"){
|
|
|
|
|
+ var box = $(jet.boxelem);
|
|
|
|
|
+ if (box && box.css("display") !== "none") box.remove();
|
|
|
|
|
+ if($("#jedatetipscon").length > 0) $("#jedatetipscon").remove();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ $(jet.boxelem).on("mouseup", function(ev) {
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+ //选择日期
|
|
|
|
|
+ jedfn.chooseDays = function(opts,boxCell) {
|
|
|
|
|
+ var that = this, objCell = that.valCell, date = new Date(), lang = opts.language || config.language;
|
|
|
|
|
+ boxCell.find(".jedaul li").on("click", function(ev) {
|
|
|
|
|
+ var thisformat = $(boxCell.attr(jefix)).length > 0 ? boxCell.attr("jeformat") : jet.format;
|
|
|
|
|
+ var _that = $(this), liTms = [];
|
|
|
|
|
+ if (_that.hasClass("disabled")) return;
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ //获取时分秒的集合
|
|
|
|
|
+ boxCell.find(".jedatehms input").each(function() {
|
|
|
|
|
+ liTms.push($(this).val());
|
|
|
});
|
|
});
|
|
|
- jeDt.on(QD(Cell)[0], "click", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
|
|
+ var dateArr = jet.reMacth(_that.attr("data-ymd")),
|
|
|
|
|
+ getDateVal = jet.parse([ dateArr[0], dateArr[1], dateArr[2] ], [ liTms[0], liTms[1], liTms[2] ], thisformat),
|
|
|
|
|
+ wdate = (dateArr[0]||date.getFullYear())+"-"+jet.digit(dateArr[1]||date.getMonth() + 1)+"-"+jet.digit(dateArr[2]||date.getDate())+" "+jet.digit(liTms[0])+":"+jet.digit(liTms[1])+":"+jet.digit(liTms[2]);
|
|
|
|
|
+ jet.isValHtml(objCell) ? objCell.val(getDateVal) :objCell.text(getDateVal);
|
|
|
|
|
+ if($(boxCell.attr(jefix)).length > 0){
|
|
|
|
|
+ var fixCell = "#"+boxCell.attr("id");
|
|
|
|
|
+ that.setHtml(opts,fixCell);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ that.dateClose();
|
|
|
|
|
+ }
|
|
|
|
|
+ opts.festival && $("#jedatetipscon").remove();
|
|
|
|
|
+ if ($.isFunction(opts.choosefun) || opts.choosefun != null){
|
|
|
|
|
+ opts.choosefun && opts.choosefun(objCell,getDateVal,wdate);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if(opts.festival && lang.name == "cn") {
|
|
|
|
|
+ //鼠标进入提示框出现
|
|
|
|
|
+ boxCell.find(".jedaul li").on("mouseover", function () {
|
|
|
|
|
+ var _this = $(this), atlunar = jet.reMacth(_this.attr("data-ymd")),
|
|
|
|
|
+ tipDiv = $("<div/>",{"id":"jedatetipscon","class":"jedatetipscon"}),
|
|
|
|
|
+ lunar = jeLunar(parseInt(atlunar[0]), parseInt(atlunar[1]) - 1, parseInt(atlunar[2]));
|
|
|
|
|
+ var tiphtml = '<p>' + lunar.solarYear + '\u5E74' + lunar.solarMonth + '\u6708' + lunar.solarDate + '\u65E5 ' + lunar.inWeekDays + '</p><p class="red">\u519C\u5386:' + lunar.shengxiao + '\u5E74 ' + lunar.lnongMonth + '\u6708' + lunar.lnongDate + '</p><p>' + lunar.ganzhiYear + '\u5E74 ' + lunar.ganzhiMonth + '\u6708 ' + lunar.ganzhiDate + '\u65E5</p>';
|
|
|
|
|
+ var Fesjieri = (lunar.solarFestival || lunar.lunarFestival) != "" ? '<p class="red">' + ("\u8282\u65E5:"+lunar.solarFestival + lunar.lunarFestival) + '</p>' : "";
|
|
|
|
|
+ var Fesjieqi = lunar.jieqi != "" ? '<p class="red">'+(lunar.jieqi != "" ? "\u8282\u6C14:"+lunar.jieqi : "") + '</p>': "";
|
|
|
|
|
+ var tiptext = (lunar.solarFestival || lunar.lunarFestival || lunar.jieqi) != "" ? (Fesjieri + Fesjieqi) : "";
|
|
|
|
|
+ //生成提示框到文档中
|
|
|
|
|
+ $("body").append(tipDiv);
|
|
|
|
|
+ tipDiv.html(tiphtml + tiptext);
|
|
|
|
|
+ //获取并设置农历提示框出现的位置
|
|
|
|
|
+ var tipPos = jedfn.lunarOrien(tipDiv, _this);
|
|
|
|
|
+ tipDiv.css({"z-index": (opts.zIndex == undefined ? 2099 + 5 : opts.zIndex + 5),top:tipPos.top,left:tipPos.left,position:"absolute",display:"block"});
|
|
|
|
|
+ }).on( "mouseout", function () { //鼠标移除提示框消失
|
|
|
|
|
+ if($("#jedatetipscon").length > 0) $("#jedatetipscon").remove();
|
|
|
});
|
|
});
|
|
|
- that.clickLiDays(that, opts, self);
|
|
|
|
|
- },
|
|
|
|
|
- //下拉选择年和月
|
|
|
|
|
- YearAndMonth:function(that, opts, self, arrTime) {
|
|
|
|
|
- var jetopym = QD(Cell + " .jedatetopym")[0], jedateyy = QD(Cell + " .jedateyy")[0], jedatemm = QD(Cell + " .jedatemm")[0], jedateyear = QD(Cell + " .jedateyy .jedateyear")[0], jedatemonth = QD(Cell + " .jedatemm .jedatemonth")[0], mchri = QD(Cell + " .jedateymchri")[0], mchle = QD(Cell + " .jedateymchle")[0];
|
|
|
|
|
- function eachYears(YY) {
|
|
|
|
|
- var eachStr = "";
|
|
|
|
|
- jeDt.each(new Array(15), function(i) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ //切换年月 与 下拉选择年月的事件
|
|
|
|
|
+ jedfn.chooseYearMonth = function (opts,boxCell) {
|
|
|
|
|
+ var that = this, yPre = boxCell.find(".yearprev"), yNext = boxCell.find(".yearnext"),
|
|
|
|
|
+ mPre = boxCell.find(".monthprev"), mNext = boxCell.find(".monthnext"),
|
|
|
|
|
+ jetopym = boxCell.find(".jedatetopym"), jedateyy = boxCell.find(".jedateyy"),
|
|
|
|
|
+ jedatemm = boxCell.find(".jedatemm"), jedateyear = boxCell.find(".jedateyy .jedateyear"),
|
|
|
|
|
+ jedatemonth = boxCell.find(".jedatemm .jedatemonth"),lang = opts.language || config.language,
|
|
|
|
|
+ mchri = boxCell.find(".jedateymchri"), mchle = boxCell.find(".jedateymchle");
|
|
|
|
|
+ var minArr = jet.reMacth(jet.minDate), minNum = minArr[0] + minArr[1],
|
|
|
|
|
+ maxArr = jet.reMacth(jet.maxDate), maxNum = maxArr[0] + maxArr[1];
|
|
|
|
|
+ //循环生成年
|
|
|
|
|
+ var eachYears = function(YY) {
|
|
|
|
|
+ var eachStr = "", ycls;
|
|
|
|
|
+ $.each(new Array(15), function(i,v) {
|
|
|
if (i === 7) {
|
|
if (i === 7) {
|
|
|
- var getyear = jeDt.attr(jedateyear, "data-year");
|
|
|
|
|
- eachStr += "<li " + (getyear == YY ? 'class="action"' :"") + ' data-y="' + YY + '">' + YY + "年</li>";
|
|
|
|
|
|
|
+ var getyear = jedateyear.attr("year");
|
|
|
|
|
+ ycls = (parseInt(YY) >= parseInt(minArr[0]) && parseInt(YY) <= parseInt(maxArr[0])) ? (getyear == YY ? 'class="action"' :"") : 'class="disabled"';
|
|
|
|
|
+ eachStr += "<li " + ycls + ' yy="' + YY + '">' + (YY+(lang.name == "cn" ? "\u5e74":"")) + "</li>";
|
|
|
} else {
|
|
} else {
|
|
|
- eachStr += '<li data-y="' + (YY - 7 + i) + '">' + (YY - 7 + i) + "年</li>";
|
|
|
|
|
|
|
+ ycls = (parseInt(YY - 7 + i) >= parseInt(minArr[0]) && parseInt(YY - 7 + i) <= parseInt(maxArr[0])) ? "" : 'class="disabled"';
|
|
|
|
|
+ eachStr += '<li ' + ycls + ' yy="' + (YY - 7 + i) + '">' + (YY - 7 + i+(lang.name == "cn" ? "\u5e74":"")) + "</li>";
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
return eachStr;
|
|
return eachStr;
|
|
|
- }
|
|
|
|
|
- function setYearMonth(YY, ymlen) {
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ //循环生成月
|
|
|
|
|
+ eachYearMonth =function (YY, ymlen) {
|
|
|
var ymStr = "";
|
|
var ymStr = "";
|
|
|
if (ymlen == 12) {
|
|
if (ymlen == 12) {
|
|
|
- jeDt.each(jeDt.montharr, function(i, val) {
|
|
|
|
|
- var getmonth = jeDt.attr(jedatemonth, "data-month"), val = jeDt.digit(val);
|
|
|
|
|
- ymStr += "<li " + (getmonth == val ? 'class="action"' :"") + ' data-m="' + val + '">' + val + "月</li>";
|
|
|
|
|
|
|
+ $.each(lang.month, function(i, val) {
|
|
|
|
|
+ var getmonth = jedatemonth.attr("month"), val = jet.digit(val);
|
|
|
|
|
+ var mcls = (parseInt(jedateyear.attr("year") + val) >= parseInt(minNum) && parseInt(jedateyear.attr("year") + val) <= parseInt(maxNum)) ? (jet.digit(getmonth) == val ? "action" :"") : "disabled";
|
|
|
|
|
+ ymStr += "<li class='"+ mcls +"' mm='" + val + "'>" + (val+(lang.name == "cn" ? "\u6708":"")) + "</li>";
|
|
|
});
|
|
});
|
|
|
- jeDt.each([ mchri, mchle ], function(c, cls) {
|
|
|
|
|
- cls.style.display = "none";
|
|
|
|
|
|
|
+ $.each([ mchri, mchle ], function(c, cls) {
|
|
|
|
|
+ cls.hide();
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
ymStr = eachYears(YY);
|
|
ymStr = eachYears(YY);
|
|
|
- jeDt.each([ mchri, mchle ], function(c, cls) {
|
|
|
|
|
- cls.style.display = "block";
|
|
|
|
|
|
|
+ $.each([ mchri, mchle ], function(c, cls) {
|
|
|
|
|
+ cls.show();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- jeDt.removeClass(jetopym, ymlen == 12 ? "jedatesety" :"jedatesetm").addClass(jetopym, ymlen == 12 ? "jedatesetm" :"jedatesety");
|
|
|
|
|
- jeDt.html(QD(Cell + " .jedatetopym .ymdropul")[0], ymStr);
|
|
|
|
|
- jetopym.style.display = "block";
|
|
|
|
|
- }
|
|
|
|
|
- function clickLiYears(year) {
|
|
|
|
|
- jeDt.each(QD(Cell + " .ymdropul li"), function(i, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function(ev) {
|
|
|
|
|
- var Years = jeDt.attr(this, "data-y"), Months = jeDt.attr(jedatemonth, "data-month");
|
|
|
|
|
- jeDt.attr(year, "data-year", Years);
|
|
|
|
|
- jeDt.html(year, Years);
|
|
|
|
|
- jetopym.style.display = "none";
|
|
|
|
|
- that.getDateStr(Years, Months, arrTime[2]);
|
|
|
|
|
- that.clickLiDays(that, opts, self);
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- //下拉选择年
|
|
|
|
|
- jeDt.on(jedateyy, "click", function() {
|
|
|
|
|
- var YMlen = parseInt(jeDt.attr(jedateyy, "data-ym")), yearAttr = parseInt(jeDt.attr(jedateyear, "data-year"));
|
|
|
|
|
- setYearMonth(yearAttr, YMlen);
|
|
|
|
|
- clickLiYears(jedateyear);
|
|
|
|
|
- });
|
|
|
|
|
- //下拉选择月
|
|
|
|
|
- jeDt.on(jedatemm, "click", function() {
|
|
|
|
|
- var YMlen = parseInt(jeDt.attr(jedatemm, "data-ym")), yearAttr = parseInt(jeDt.attr(jedateyear, "data-year"));
|
|
|
|
|
- setYearMonth(yearAttr, YMlen);
|
|
|
|
|
- jeDt.each(QD(Cell + " .ymdropul li"), function(i, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function(ev) {
|
|
|
|
|
- var Years = jeDt.attr(jedateyear, "data-year"), Months = jeDt.attr(this, "data-m");
|
|
|
|
|
- jeDt.attr(jedatemonth, "data-month", Months);
|
|
|
|
|
- jeDt.html(jedatemonth, Months);
|
|
|
|
|
- jetopym.style.display = "none";
|
|
|
|
|
- that.getDateStr(Years, Months, arrTime[2]);
|
|
|
|
|
- that.clickLiDays(that, opts, self);
|
|
|
|
|
- });
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ jetopym.removeClass( ymlen == 12 ? "jedatesety" :"jedatesetm").addClass(ymlen == 12 ? "jedatesetm" :"jedatesety");
|
|
|
|
|
+ boxCell.find(".jedatetopym .ymdropul").html(ymStr);
|
|
|
|
|
+ jetopym.show();
|
|
|
|
|
+ };
|
|
|
|
|
+ //切换年
|
|
|
|
|
+ $.each([ yPre, yNext ], function(i, cls) {
|
|
|
|
|
+ cls.on("click", function(ev) {
|
|
|
|
|
+ if(boxCell.find(".jedatetopym").css("display") == "block") return;
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ var year = parseInt(jedateyear.attr("year")), month = parseInt(jedatemonth.attr("month")),
|
|
|
|
|
+ pnYear = cls == yPre ? --year : ++year;
|
|
|
|
|
+ that.createDaysHtml(pnYear, month, opts, boxCell);
|
|
|
});
|
|
});
|
|
|
- //关闭下拉选择
|
|
|
|
|
- jeDt.on(QD(Cell + " .jedateymchok")[0], "click", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- jetopym.style.display = "none";
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ //切换月
|
|
|
|
|
+ $.each([ mPre, mNext ], function(i, cls) {
|
|
|
|
|
+ cls.on("click", function(ev) {
|
|
|
|
|
+ if(boxCell.find(".jedatetopym").css("display") == "block") return;
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ var year = parseInt(jedateyear.attr("year")), month = parseInt(jedatemonth.attr("month")),
|
|
|
|
|
+ PrevYM = jet.getPrevMonth(year, month), NextYM = jet.getNextMonth(year, month);
|
|
|
|
|
+ cls == mPre ? that.createDaysHtml(PrevYM.y, PrevYM.m, opts, boxCell) : that.createDaysHtml(NextYM.y, NextYM.m, opts, boxCell);
|
|
|
});
|
|
});
|
|
|
- var yearMch = parseInt(jeDt.attr(jedateyear, "data-year"));
|
|
|
|
|
- jeDt.each([ mchle, mchri ], function(lr, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function(ev) {
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- lr == 0 ? yearMch -= 15 :yearMch += 15;
|
|
|
|
|
- var mchStr = eachYears(yearMch);
|
|
|
|
|
- jeDt.html(QD(Cell + " .jedatetopym .ymdropul")[0], mchStr);
|
|
|
|
|
- clickLiYears(jedateyear);
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ //下拉选择 年或月
|
|
|
|
|
+ $.each([ jedateyy, jedatemm ], function(i, cls) {
|
|
|
|
|
+ cls.on("click",function () {
|
|
|
|
|
+ var clsthat = $(this), ymVal = clsthat.attr("ym"),
|
|
|
|
|
+ yearAttr = parseInt(jedateyear.attr("year")),
|
|
|
|
|
+ dropchoose = function () {
|
|
|
|
|
+ boxCell.find(".ymdropul li").on("click", function(ev) {
|
|
|
|
|
+ var _this = $(this), Years = jedateyy == cls ? parseInt(_this.attr("yy")) : parseInt(jedateyear.attr("year")),
|
|
|
|
|
+ Months = jedateyy == cls ? parseInt(jedatemonth.attr("month")) : jet.digit(parseInt(_this.attr("mm")));
|
|
|
|
|
+ if (_this.hasClass("disabled")) return;
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ if(jedateyy == cls){
|
|
|
|
|
+ jedateyear.attr("year", Years).html(Years + (lang.name == "cn" ? "\u5e74":""));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ jedatemonth.attr("month", Months).html(Months + (lang.name == "cn" ? "\u6708":""));
|
|
|
|
|
+ }
|
|
|
|
|
+ jetopym.hide();
|
|
|
|
|
+ that.createDaysHtml(Years, Months, opts, boxCell);
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+ eachYearMonth(yearAttr, ymVal);
|
|
|
|
|
+ dropchoose();
|
|
|
|
|
+ //关闭下拉选择
|
|
|
|
|
+ boxCell.find(".jedateymchok").on("click", function(ev) {
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ jetopym.hide();
|
|
|
});
|
|
});
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- //选择日
|
|
|
|
|
- clickLiDays:function(that, opts, self) {
|
|
|
|
|
- jeDt.each(QD(Cell + " .jedaul li"), function(i, cls) {
|
|
|
|
|
- jeDt.on(cls, "click", function(ev) {
|
|
|
|
|
- if (jeDt.hasClass(cls, "disabled")) return;
|
|
|
|
|
- jeDt.stopmp(ev);
|
|
|
|
|
- var liTms = [];
|
|
|
|
|
- jeDt.each(QD(Cell + " .jedatehms em"), function(l, tval) {
|
|
|
|
|
- liTms.push(jeDt.text(tval));
|
|
|
|
|
|
|
+ $.each([ mchle, mchri ], function(d, mcls) {
|
|
|
|
|
+ mcls.on("click", function(ev) {
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ d == 0 ? yearAttr -= 15 :yearAttr += 15;
|
|
|
|
|
+ var mchStr = eachYears(yearAttr);
|
|
|
|
|
+ boxCell.find(".jedatetopym .ymdropul").html(mchStr);
|
|
|
|
|
+ dropchoose();
|
|
|
});
|
|
});
|
|
|
- var aty = parseInt(jeDt.attr(cls, "data-y")) | 0, atm = parseInt(jeDt.attr(cls, "data-m")) | 0, atd = parseInt(jeDt.attr(cls, "data-d")) | 0;
|
|
|
|
|
- var getParDate = jeDt.parse([ aty, atm, atd ], [ liTms[0], liTms[1], liTms[2] ], opts.format);
|
|
|
|
|
- that.getDateStr(aty, atm, atd);
|
|
|
|
|
- jeDt.isValHtml(self) ? jeDt.val(self, getParDate) :jeDt.text(self, getParDate);
|
|
|
|
|
- jeDt.html(QD(Cell)[0], "");
|
|
|
|
|
- jeDt.shdeCell(true);
|
|
|
|
|
- if (opts.choosefun === "function" || opts.choosefun != null) {
|
|
|
|
|
- opts.choosefun(getParDate);
|
|
|
|
|
- }
|
|
|
|
|
});
|
|
});
|
|
|
|
|
+ })
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+ //年月情况下的事件绑定
|
|
|
|
|
+ jedfn.preNextYearMonth = function(opts,boxCell){
|
|
|
|
|
+ var that = this, elemCell = that.valCell,
|
|
|
|
|
+ newDate = new Date(), isYY = jet.testFormat(jet.format,"YYYY"),
|
|
|
|
|
+ ymCls = boxCell.find(isYY ? ".jedayy li" : ".jedaym li");
|
|
|
|
|
+ //选择年月
|
|
|
|
|
+ ymCls.on("click", function (ev) {
|
|
|
|
|
+ if ($(this).hasClass("disabled")) return; //判断是否为禁选状态
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ var atYM = isYY ? jet.reMacth($(this).attr("yy")) : jet.reMacth($(this).attr("ym")),
|
|
|
|
|
+ getYMDate = isYY ? jet.parse([atYM[0], newDate.getMonth() + 1, 1], [0, 0, 0], jet.format) : jet.parse([atYM[0], atYM[1], 1], [0, 0, 0], jet.format);
|
|
|
|
|
+ jet.isValHtml(elemCell) ? elemCell.val(getYMDate) : elemCell.text(getYMDate);
|
|
|
|
|
+ that.dateClose();
|
|
|
|
|
+ if ($.isFunction(opts.choosefun) || opts.choosefun != null) opts.choosefun(elemCell, getYMDate);
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+ //仅年月情况下的点击
|
|
|
|
|
+ jedfn.onlyYMevents = function(opts,boxCell) {
|
|
|
|
|
+ var that = this, ymVal,newDate = new Date(),
|
|
|
|
|
+ isYY = jet.testFormat(jet.format,"YYYY"),
|
|
|
|
|
+ ymPre = boxCell.find(".jedateym .prev"),
|
|
|
|
|
+ ymNext = boxCell.find(".jedateym .next"),
|
|
|
|
|
+ onymVal = jet.reMacth(boxCell.children("ul").attr("dateval")),
|
|
|
|
|
+ ony = parseInt(onymVal[0]), onm = parseInt(onymVal[1]);
|
|
|
|
|
+ $.each([ ymPre, ymNext ], function(i, cls) {
|
|
|
|
|
+ cls.on("click", function(ev) {
|
|
|
|
|
+ ev.stopPropagation();
|
|
|
|
|
+ if(isYY){
|
|
|
|
|
+ ymVal = cls == ymPre ? boxCell.find(".jedayy li").eq(0).attr("yy") : boxCell.find(".jedayy li").eq(jet.yearArr.length-1).attr("yy");
|
|
|
|
|
+ boxCell.find(".jedayy").html(that.eachYM(opts,ymVal, newDate.getMonth() + 1,boxCell));
|
|
|
|
|
+ }else{
|
|
|
|
|
+ ymVal = cls == ymPre ? ony -= 1 : ony += 1;
|
|
|
|
|
+ boxCell.find(".jedaym").html(that.eachYM(opts,ymVal, onm, boxCell));
|
|
|
|
|
+ }
|
|
|
|
|
+ that.preNextYearMonth(opts,boxCell);
|
|
|
});
|
|
});
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
- jeDt.getPath = (function(){
|
|
|
|
|
- var js = document.scripts, jsPath = js[js.length - 1].src;
|
|
|
|
|
- return jsPath.substring(0, jsPath.lastIndexOf("/") + 1);
|
|
|
|
|
- }());
|
|
|
|
|
- jeDt.creatlink = function(lib){
|
|
|
|
|
- var link = document.createElement('link');
|
|
|
|
|
- link.type = 'text/css';
|
|
|
|
|
- link.rel = 'stylesheet';
|
|
|
|
|
- link.href = jeDt.getPath +'skin/'+ lib + '.css';
|
|
|
|
|
- link.id = 'jeDateSkin';
|
|
|
|
|
- QD('head')[0].appendChild(link);
|
|
|
|
|
- link = null;
|
|
|
|
|
- };
|
|
|
|
|
- jeDt.creatlink('jedate');
|
|
|
|
|
- jeDate.skin = function(lib){
|
|
|
|
|
- QD('#jeDateSkin')[0].parentNode.removeChild(QD('#jeDateSkin')[0]);
|
|
|
|
|
- jeDt.creatlink(lib);
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ //日期控件版本
|
|
|
|
|
+ $.dateVer = "3.8.5";
|
|
|
//返回指定日期
|
|
//返回指定日期
|
|
|
- jeDate.now = function(num) {
|
|
|
|
|
- var dd = new Date();
|
|
|
|
|
- dd.setDate(dd.getDate() + num);
|
|
|
|
|
- var y = dd.getFullYear(), m = dd.getMonth() + 1, d = dd.getDate();
|
|
|
|
|
- return y + "-" + m + "-" + d;
|
|
|
|
|
- };
|
|
|
|
|
- "function" === typeof define ? define(function() {
|
|
|
|
|
- return jeDate;
|
|
|
|
|
- }) :window.jeDate = jeDate;
|
|
|
|
|
-})(window);
|
|
|
|
|
|
|
+ $.nowDate = function (str,format,date) {
|
|
|
|
|
+ format = format || 'YYYY-MM-DD hh:mm:ss';
|
|
|
|
|
+ date = date || [];
|
|
|
|
|
+ if (typeof(str) === 'number') {
|
|
|
|
|
+ str = {DD: str};
|
|
|
|
|
+ }
|
|
|
|
|
+ return jet.returnDate(str, format, date);
|
|
|
|
|
+ };
|
|
|
|
|
+ $.timeStampDate = function (date,bool,format) {
|
|
|
|
|
+ format = format || 'YYYY-MM-DD hh:mm:ss';
|
|
|
|
|
+ if(bool == true){ //将时间戳转换成日期
|
|
|
|
|
+ var setdate = new Date(parseInt(date.substring(0,10)) * 1e3);
|
|
|
|
|
+ return jet.parse([ setdate.getFullYear(), jet.digit(setdate.getMonth() + 1), jet.digit(setdate.getDate()) ], [ jet.digit(setdate.getHours()), jet.digit(setdate.getMinutes()), jet.digit(setdate.getSeconds()) ], format);
|
|
|
|
|
+ }else { //将日期转换成时间戳
|
|
|
|
|
+ var tmsArr = jet.reMacth(date),
|
|
|
|
|
+ newdate = new Date(tmsArr[0],tmsArr[1],tmsArr[2],tmsArr[3],tmsArr[4],tmsArr[5]),
|
|
|
|
|
+ timeStr = newdate.getTime().toString();
|
|
|
|
|
+ return timeStr.substr(0, 10);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ //分解时间
|
|
|
|
|
+ $.splitDate = function (str) {
|
|
|
|
|
+ var sdate = str.match(/\w+|d+/g);
|
|
|
|
|
+ return {
|
|
|
|
|
+ YYYY:parseInt(sdate[0]),MM:parseInt(sdate[1])||00,DD:parseInt(sdate[2])||00,
|
|
|
|
|
+ hh:parseInt(sdate[3])||00,mm:parseInt(sdate[4])||00,ss:parseInt(sdate[5])||00
|
|
|
|
|
+ };
|
|
|
|
|
+ };
|
|
|
|
|
+ //获取年月日星期
|
|
|
|
|
+ $.getLunar = function(time){
|
|
|
|
|
+ if(/\YYYY-MM-DD/.test(jet.formatType)){
|
|
|
|
|
+ //如果为数字类型的日期对获取到日期的进行替换
|
|
|
|
|
+ var nocharDate = time.substr(0,4).replace(/^(\d{4})/g,"$1,") + time.substr(4).replace(/(.{2})/g,"$1,"),
|
|
|
|
|
+ warr = jet.IsNum(time) ? jet.reMacth(nocharDate) : jet.reMacth(time),
|
|
|
|
|
+ lunars = jeLunar(warr[0], warr[1] - 1, warr[2]);
|
|
|
|
|
+ return{
|
|
|
|
|
+ nMonth: lunars.lnongMonth, //农历月
|
|
|
|
|
+ nDays: lunars.lnongDate, //农历日
|
|
|
|
|
+ yYear: parseInt(lunars.solarYear), //阳历年
|
|
|
|
|
+ yMonth: parseInt(lunars.solarMonth), //阳历月
|
|
|
|
|
+ yDays: parseInt(lunars.solarDate), //阳历日
|
|
|
|
|
+ cWeek: lunars.inWeekDays, //汉字星期几
|
|
|
|
|
+ nWeek: lunars.solarWeekDay //数字星期几
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ return jeDate;
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+//农历数据
|
|
|
|
|
+;(function(root, factory) {
|
|
|
|
|
+ root.jeLunar = factory(root.jeLunar);
|
|
|
|
|
+})(this, function(jeLunar) {
|
|
|
|
|
+ var lunarInfo=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448],
|
|
|
|
|
+ sTermInfo = [ 0, 21208, 43467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758 ];
|
|
|
|
|
+ var Gan = "甲乙丙丁戊己庚辛壬癸", Zhi = "子丑寅卯辰巳午未申酉戌亥", Animals = "鼠牛虎兔龙蛇马羊猴鸡狗猪";
|
|
|
|
|
+ var solarTerm = [ "小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满",
|
|
|
|
|
+ "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至" ];
|
|
|
|
|
+ var nStr1 = "日一二三四五六七八九十", nStr2 = "初十廿卅", nStr3 = [ "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"],
|
|
|
|
|
+ sFtv1 = {
|
|
|
|
|
+ "0101" : "*1元旦节", "0202" : "湿地日",
|
|
|
|
|
+ "0214" : "情人节", "0308" : "妇女节",
|
|
|
|
|
+ "0312" : "植树节", "0315" : "消费者权益日",
|
|
|
|
|
+ "0401" : "愚人节", "0422" : "地球日",
|
|
|
|
|
+ "0501" : "*1劳动节", "0504" : "青年节",
|
|
|
|
|
+ "0512" : "护士节", "0518" : "博物馆日",
|
|
|
|
|
+ "0520" : "母亲节", "0601" : "儿童节",
|
|
|
|
|
+ "0623" : "奥林匹克日", "0630" : "父亲节",
|
|
|
|
|
+ "0701" : "建党节", "0801" : "建军节",
|
|
|
|
|
+ "0903" : "抗战胜利日", "0910" : "教师节",
|
|
|
|
|
+ "1001" : "*3国庆节", "1201" : "艾滋病日",
|
|
|
|
|
+ "1224" : "平安夜", "1225" : "圣诞节"
|
|
|
|
|
+ },
|
|
|
|
|
+ sFtv2 = {
|
|
|
|
|
+ "0100" : "除夕", "0101" : "*2春节",
|
|
|
|
|
+ "0115" : "元宵节", "0505" : "*1端午节",
|
|
|
|
|
+ "0707" : "七夕节", "0715" : "中元节",
|
|
|
|
|
+ "0815" : "*1中秋节", "0909" : "*1重阳节",
|
|
|
|
|
+ "1015" : "下元节", "1208" : "腊八节",
|
|
|
|
|
+ "1223" : "小年"
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+ function flunar(Y) {
|
|
|
|
|
+ var sTerm = function (j, i) {
|
|
|
|
|
+ var h = new Date((31556925974.7 * (j - 1900) + sTermInfo[i] * 60000) + Date.UTC(1900, 0, 6, 2, 5));
|
|
|
|
|
+ return (h.getUTCDate())
|
|
|
|
|
+ },
|
|
|
|
|
+ d = function (k) {
|
|
|
|
|
+ var h, j = 348;
|
|
|
|
|
+ for (h = 32768; h > 8; h >>= 1) {
|
|
|
|
|
+ j += (lunarInfo[k - 1900] & h) ? 1 : 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ return (j + b(k))
|
|
|
|
|
+ },
|
|
|
|
|
+ ymdCyl = function (h) {
|
|
|
|
|
+ return (Gan.charAt(h % 10) + Zhi.charAt(h % 12))
|
|
|
|
|
+ },
|
|
|
|
|
+ b =function (h) {
|
|
|
|
|
+ var islp = (g(h)) ? ((lunarInfo[h - 1900] & 65536) ? 30 : 29) : (0);
|
|
|
|
|
+ return islp
|
|
|
|
|
+ },
|
|
|
|
|
+ g = function (h) {
|
|
|
|
|
+ return (lunarInfo[h - 1900] & 15)
|
|
|
|
|
+ },
|
|
|
|
|
+ e = function (i, h) {
|
|
|
|
|
+ return ((lunarInfo[i - 1900] & (65536 >> h)) ? 30 : 29)
|
|
|
|
|
+ },
|
|
|
|
|
+ newymd = function (m) {
|
|
|
|
|
+ var k, j = 0, h = 0, l = new Date(1900, 0, 31), n = (m - l) / 86400000;
|
|
|
|
|
+ this.dayCyl = n + 40;
|
|
|
|
|
+ this.monCyl = 14;
|
|
|
|
|
+ for (k = 1900; k<2050&&n>0; k++) {
|
|
|
|
|
+ h = d(k); n -= h;
|
|
|
|
|
+ this.monCyl += 12;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (n < 0) {
|
|
|
|
|
+ n += h; k--;
|
|
|
|
|
+ this.monCyl -= 12;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.year = k;
|
|
|
|
|
+ this.yearCyl = k - 1864;
|
|
|
|
|
+ j = g(k);
|
|
|
|
|
+ this.isLeap = false;
|
|
|
|
|
+ for (k = 1; k<13&&n>0; k++) {
|
|
|
|
|
+ if (j > 0 && k == (j + 1) && this.isLeap == false) {
|
|
|
|
|
+ --k;
|
|
|
|
|
+ this.isLeap = true;
|
|
|
|
|
+ h = b(this.year);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ h = e(this.year, k);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.isLeap == true && k == (j + 1)) {
|
|
|
|
|
+ this.isLeap = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ n -= h;
|
|
|
|
|
+ if (this.isLeap == false) this.monCyl++;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (n == 0 && j > 0 && k == j + 1) {
|
|
|
|
|
+ if (this.isLeap) {
|
|
|
|
|
+ this.isLeap = false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.isLeap = true;
|
|
|
|
|
+ --k;
|
|
|
|
|
+ --this.monCyl;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (n < 0) {
|
|
|
|
|
+ n += h; --k;
|
|
|
|
|
+ --this.monCyl
|
|
|
|
|
+ }
|
|
|
|
|
+ this.month = k;
|
|
|
|
|
+ this.day = n + 1;
|
|
|
|
|
+ },
|
|
|
|
|
+ digit = function (num) {
|
|
|
|
|
+ return num < 10 ? "0" + (num | 0) :num;
|
|
|
|
|
+ },
|
|
|
|
|
+ reymd = function (i, j) {
|
|
|
|
|
+ var h = i;
|
|
|
|
|
+ return j.replace(/dd?d?d?|MM?M?M?|yy?y?y?/g, function(k) {
|
|
|
|
|
+ switch (k) {
|
|
|
|
|
+ case "yyyy":
|
|
|
|
|
+ var l = "000" + h.getFullYear();
|
|
|
|
|
+ return l.substring(l.length - 4);
|
|
|
|
|
+ case "dd": return digit(h.getDate());
|
|
|
|
|
+ case "d": return h.getDate().toString();
|
|
|
|
|
+ case "MM": return digit((h.getMonth() + 1));
|
|
|
|
|
+ case "M": return h.getMonth() + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ lunarMD = function (i, h) {
|
|
|
|
|
+ var j;
|
|
|
|
|
+ switch (i, h) {
|
|
|
|
|
+ case 10: j = "初十"; break;
|
|
|
|
|
+ case 20: j = "二十"; break;
|
|
|
|
|
+ case 30: j = "三十"; break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ j = nStr2.charAt(Math.floor(h / 10));
|
|
|
|
|
+ j += nStr1.charAt(h % 10);
|
|
|
|
|
+ }
|
|
|
|
|
+ return (j)
|
|
|
|
|
+ };
|
|
|
|
|
+ this.isToday = false;
|
|
|
|
|
+ this.isRestDay = false;
|
|
|
|
|
+ this.solarYear = reymd(Y, "yyyy");
|
|
|
|
|
+ this.solarMonth = reymd(Y, "M");
|
|
|
|
|
+ this.solarDate = reymd(Y, "d");
|
|
|
|
|
+ this.solarWeekDay = Y.getDay();
|
|
|
|
|
+ this.inWeekDays = "星期" + nStr1.charAt(this.solarWeekDay);
|
|
|
|
|
+ var X = new newymd(Y);
|
|
|
|
|
+ this.lunarYear = X.year;
|
|
|
|
|
+ this.shengxiao = Animals.charAt((this.lunarYear - 4) % 12);
|
|
|
|
|
+ this.lunarMonth = X.month;
|
|
|
|
|
+ this.lunarIsLeapMonth = X.isLeap;
|
|
|
|
|
+ this.lnongMonth = this.lunarIsLeapMonth ? "闰" + nStr3[X.month - 1] : nStr3[X.month - 1];
|
|
|
|
|
+ this.lunarDate = X.day;
|
|
|
|
|
+ this.showInLunar = this.lnongDate = lunarMD(this.lunarMonth, this.lunarDate);
|
|
|
|
|
+ if (this.lunarDate == 1) {
|
|
|
|
|
+ this.showInLunar = this.lnongMonth + "月";
|
|
|
|
|
+ }
|
|
|
|
|
+ this.ganzhiYear = ymdCyl(X.yearCyl);
|
|
|
|
|
+ this.ganzhiMonth = ymdCyl(X.monCyl);
|
|
|
|
|
+ this.ganzhiDate = ymdCyl(X.dayCyl++);
|
|
|
|
|
+ this.jieqi = "";
|
|
|
|
|
+ this.restDays = 0;
|
|
|
|
|
+ if (sTerm(this.solarYear, (this.solarMonth - 1) * 2) == reymd(Y, "d")) {
|
|
|
|
|
+ this.showInLunar = this.jieqi = solarTerm[(this.solarMonth - 1) * 2];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sTerm(this.solarYear, (this.solarMonth - 1) * 2 + 1) == reymd(Y, "d")) {
|
|
|
|
|
+ this.showInLunar = this.jieqi = solarTerm[(this.solarMonth - 1) * 2 + 1];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.showInLunar == "清明") {
|
|
|
|
|
+ this.showInLunar = "清明节";
|
|
|
|
|
+ this.restDays = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.solarFestival = sFtv1[reymd(Y, "MM") + reymd(Y, "dd")];
|
|
|
|
|
+ if (typeof this.solarFestival == "undefined") {
|
|
|
|
|
+ this.solarFestival = "";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (/\*(\d)/.test(this.solarFestival)) {
|
|
|
|
|
+ this.restDays = parseInt(RegExp.$1);
|
|
|
|
|
+ this.solarFestival = this.solarFestival.replace(/\*\d/, "");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ this.showInLunar = (this.solarFestival == "") ? this.showInLunar : this.solarFestival;
|
|
|
|
|
+ this.lunarFestival = sFtv2[this.lunarIsLeapMonth ? "00" : digit(this.lunarMonth) + digit(this.lunarDate)];
|
|
|
|
|
+ if (typeof this.lunarFestival == "undefined") {
|
|
|
|
|
+ this.lunarFestival = "";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (/\*(\d)/.test(this.lunarFestival)) {
|
|
|
|
|
+ this.restDays = (this.restDays > parseInt(RegExp.$1)) ? this.restDays : parseInt(RegExp.$1);
|
|
|
|
|
+ this.lunarFestival = this.lunarFestival.replace(/\*\d/, "");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.lunarMonth == 12 && this.lunarDate == e(this.lunarYear, 12)) {
|
|
|
|
|
+ this.lunarFestival = sFtv2["0100"];
|
|
|
|
|
+ this.restDays = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.showInLunar = (this.lunarFestival == "") ? this.showInLunar : this.lunarFestival;
|
|
|
|
|
+ }
|
|
|
|
|
+ var jeLunar = function(y,m,d) {
|
|
|
|
|
+ return new flunar(new Date(y,m,d));
|
|
|
|
|
+ };
|
|
|
|
|
+ return jeLunar;
|
|
|
|
|
+});
|