You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
530 lines
38 KiB
JavaScript
530 lines
38 KiB
JavaScript
var calendar={lunarInfo:[0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,0x06ca0,0x0b550,0x15355,0x04da0,0x0a5b0,0x14573,0x052b0,0x0a9a8,0x0e950,0x06aa0,0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b6a0,0x195a6,0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0,0x14b63,0x09370,0x049f8,0x04970,0x064b0,0x168a6,0x0ea50,0x06b20,0x1a6c4,0x0aae0,0x0a2e0,0x0d2e3,0x0c960,0x0d557,0x0d4a0,0x0da50,0x05d55,0x056a0,0x0a6d0,0x055d4,0x052d0,0x0a9b8,0x0a950,0x0b4a0,0x0b6a6,0x0ad50,0x055a0,0x0aba4,0x0a5b0,0x052b0,0x0b273,0x06930,0x07337,0x06aa0,0x0ad50,0x14b55,0x04b60,0x0a570,0x054e4,0x0d160,0x0e968,0x0d520,0x0daa0,0x16aa6,0x056d0,0x04ae0,0x0a9d4,0x0a2d0,0x0d150,0x0f252,0x0d520],solarMonth:[31,28,31,30,31,30,31,31,30,31,30,31],Gan:["\u7532","\u4e59","\u4e19","\u4e01","\u620a","\u5df1","\u5e9a","\u8f9b","\u58ec","\u7678"],Zhi:["\u5b50","\u4e11","\u5bc5","\u536f","\u8fb0","\u5df3","\u5348","\u672a","\u7533","\u9149","\u620c","\u4ea5"],Animals:["\u9f20","\u725b","\u864e","\u5154","\u9f99","\u86c7","\u9a6c","\u7f8a","\u7334","\u9e21","\u72d7","\u732a"],solarTerm:["\u5c0f\u5bd2","\u5927\u5bd2","\u7acb\u6625","\u96e8\u6c34","\u60ca\u86f0","\u6625\u5206","\u6e05\u660e","\u8c37\u96e8","\u7acb\u590f","\u5c0f\u6ee1","\u8292\u79cd","\u590f\u81f3","\u5c0f\u6691","\u5927\u6691","\u7acb\u79cb","\u5904\u6691","\u767d\u9732","\u79cb\u5206","\u5bd2\u9732","\u971c\u964d","\u7acb\u51ac","\u5c0f\u96ea","\u5927\u96ea","\u51ac\u81f3"],sTermInfo:['9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c3598082c95f8c965cc920f','97bd0b06bdb0722c965ce1cfcc920f','b027097bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c359801ec95f8c965cc920f','97bd0b06bdb0722c965ce1cfcc920f','b027097bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c359801ec95f8c965cc920f','97bd0b06bdb0722c965ce1cfcc920f','b027097bd097c36b0b6fc9274c91aa','9778397bd19801ec9210c965cc920e','97b6b97bd19801ec95f8c965cc920f','97bd09801d98082c95f8e1cfcc920f','97bd097bd097c36b0b6fc9210c8dc2','9778397bd197c36c9210c9274c91aa','97b6b97bd19801ec95f8c965cc920e','97bd09801d98082c95f8e1cfcc920f','97bd097bd097c36b0b6fc9210c8dc2','9778397bd097c36c9210c9274c91aa','97b6b97bd19801ec95f8c965cc920e','97bcf97c3598082c95f8e1cfcc920f','97bd097bd097c36b0b6fc9210c8dc2','9778397bd097c36c9210c9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c3598082c95f8c965cc920f','97bd097bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c3598082c95f8c965cc920f','97bd097bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c359801ec95f8c965cc920f','97bd097bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c359801ec95f8c965cc920f','97bd097bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf97c359801ec95f8c965cc920f','97bd097bd07f595b0b6fc920fb0722','9778397bd097c36b0b6fc9210c8dc2','9778397bd19801ec9210c9274c920e','97b6b97bd19801ec95f8c965cc920f','97bd07f5307f595b0b0bc920fb0722','7f0e397bd097c36b0b6fc9210c8dc2','9778397bd097c36c9210c9274c920e','97b6b97bd19801ec95f8c965cc920f','97bd07f5307f595b0b0bc920fb0722','7f0e397bd097c36b0b6fc9210c8dc2','9778397bd097c36c9210c9274c91aa','97b6b97bd19801ec9210c965cc920e','97bd07f1487f595b0b0bc920fb0722','7f0e397bd097c36b0b6fc9210c8dc2','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf7f1487f595b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf7f1487f595b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf7f1487f531b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c965cc920e','97bcf7f1487f531b0b0bb0b6fb0722','7f0e397bd07f595b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b97bd19801ec9210c9274c920e','97bcf7f0e47f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','9778397bd097c36b0b6fc9210c91aa','97b6b97bd197c36c9210c9274c920e','97bcf7f0e47f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','9778397bd097c36b0b6fc9210c8dc2','9778397bd097c36c9210c9274c920e','97b6b7f0e47f531b0723b0b6fb0722','7f0e37f5307f595b0b0bc920fb0722','7f0e397bd097c36b0b6fc9210c8dc2','9778397bd097c36b0b70c9274c91aa','97b6b7f0e47f531b0723b0b6fb0721','7f0e37f1487f595b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc9210c8dc2','9778397bd097c36b0b6fc9274c91aa','97b6b7f0e47f531b0723b0b6fb0721','7f0e27f1487f595b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','9778397bd097c36b0b6fc9274c91aa','97b6b7f0e47f531b0723b0787b0721','7f0e27f0e47f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','9778397bd097c36b0b6fc9210c91aa','97b6b7f0e47f149b0723b0787b0721','7f0e27f0e47f531b0723b0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','9778397bd097c36b0b6fc9210c8dc2','977837f0e37f149b0723b0787b0721','7f07e7f0e47f531b0723b0b6fb0722','7f0e37f5307f595b0b0bc920fb0722','7f0e397bd097c35b0b6fc9210c8dc2','977837f0e37f14998082b0787b0721','7f07e7f0e47f531b0723b0b6fb0721','7f0e37f1487f595b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc9210c8dc2','977837f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','977837f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd097c35b0b6fc920fb0722','977837f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','977837f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','977837f0e37f14998082b0787b06bd','7f07e7f0e47f149b0723b0787b0721','7f0e27f0e47f531b0b0bb0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','977837f0e37f14998082b0723b06bd','7f07e7f0e37f149b0723b0787b0721','7f0e27f0e47f531b0723b0b6fb0722','7f0e397bd07f595b0b0bc920fb0722','977837f0e37f14898082b0723b02d5','7ec967f0e37f14998082b0787b0721','7f07e7f0e47f531b0723b0b6fb0722','7f0e37f1487f595b0b0bb0b6fb0722','7f0e37f0e37f14898082b0723b02d5','7ec967f0e37f14998082b0787b0721','7f07e7f0e47f531b0723b0b6fb0722','7f0e37f1487f531b0b0bb0b6fb0722','7f0e37f0e37f14898082b0723b02d5','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e37f1487f531b0b0bb0b6fb0722','7f0e37f0e37f14898082b072297c35','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e37f0e37f14898082b072297c35','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e37f0e366aa89801eb072297c35','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f149b0723b0787b0721','7f0e27f1487f531b0b0bb0b6fb0722','7f0e37f0e366aa89801eb072297c35','7ec967f0e37f14998082b0723b06bd','7f07e7f0e47f149b0723b0787b0721','7f0e27f0e47f531b0723b0b6fb0722','7f0e37f0e366aa89801eb072297c35','7ec967f0e37f14998082b0723b06bd','7f07e7f0e37f14998083b0787b0721','7f0e27f0e47f531b0723b0b6fb0722','7f0e37f0e366aa89801eb072297c35','7ec967f0e37f14898082b0723b02d5','7f07e7f0e37f14998082b0787b0721','7f07e7f0e47f531b0723b0b6fb0722','7f0e36665b66aa89801e9808297c35','665f67f0e37f14898082b0723b02d5','7ec967f0e37f14998082b0787b0721','7f07e7f0e47f531b0723b0b6fb0722','7f0e36665b66a449801e9808297c35','665f67f0e37f14898082b0723b02d5','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e36665b66a449801e9808297c35','665f67f0e37f14898082b072297c35','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e26665b66a449801e9808297c35','665f67f0e37f1489801eb072297c35','7ec967f0e37f14998082b0787b06bd','7f07e7f0e47f531b0723b0b6fb0721','7f0e27f1487f531b0b0bb0b6fb0722'],nStr1:["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341"],nStr2:["\u521d","\u5341","\u5eff","\u5345"],nStr3:["\u6b63","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341","\u51ac","\u814a"],lYearDays:function(y){var i,sum=348;for(i=0x8000;i>0x8;i>>=1){sum+=(calendar.lunarInfo[y-1900]&i)?1:0}return(sum+calendar.leapDays(y))},leapMonth:function(y){return(calendar.lunarInfo[y-1900]&0xf)},leapDays:function(y){if(calendar.leapMonth(y)){return((calendar.lunarInfo[y-1900]&0x10000)?30:29)}return(0)},monthDays:function(y,m){if(m>12||m<1){return-1}return((calendar.lunarInfo[y-1900]&(0x10000>>m))?30:29)},solarDays:function(y,m){if(m>12||m<1){return-1}var ms=m-1;if(ms==1){return(((y%4==0)&&(y%100!=0)||(y%400==0))?29:28)}else{return(calendar.solarMonth[ms])}},toGanZhi:function(offset){return(calendar.Gan[offset%10]+calendar.Zhi[offset%12])},getTerm:function(y,n){if(y<1900||y>2100){return-1}if(n<1||n>24){return-1}var _table=calendar.sTermInfo[y-1900];var _info=[parseInt('0x'+_table.substr(0,5)).toString(),parseInt('0x'+_table.substr(5,5)).toString(),parseInt('0x'+_table.substr(10,5)).toString(),parseInt('0x'+_table.substr(15,5)).toString(),parseInt('0x'+_table.substr(20,5)).toString(),parseInt('0x'+_table.substr(25,5)).toString()];var _calday=[_info[0].substr(0,1),_info[0].substr(1,2),_info[0].substr(3,1),_info[0].substr(4,2),_info[1].substr(0,1),_info[1].substr(1,2),_info[1].substr(3,1),_info[1].substr(4,2),_info[2].substr(0,1),_info[2].substr(1,2),_info[2].substr(3,1),_info[2].substr(4,2),_info[3].substr(0,1),_info[3].substr(1,2),_info[3].substr(3,1),_info[3].substr(4,2),_info[4].substr(0,1),_info[4].substr(1,2),_info[4].substr(3,1),_info[4].substr(4,2),_info[5].substr(0,1),_info[5].substr(1,2),_info[5].substr(3,1),_info[5].substr(4,2),];return parseInt(_calday[n-1])},toChinaMonth:function(m){if(m>12||m<1){return-1}var s=calendar.nStr3[m-1];s+="\u6708";return s},toChinaDay:function(d){var s;switch(d){case 10:s='\u521d\u5341';break;case 20:s='\u4e8c\u5341';break;break;case 30:s='\u4e09\u5341';break;break;default:s=calendar.nStr2[Math.floor(d/10)];s+=calendar.nStr1[d%10]}return(s)},getAnimal:function(y){return calendar.Animals[(y-4)%12]},solar2lunar:function(y,m,d){if(y<1900||y>2100){return-1}if(y==1900&&m==1&&d<31){return-1}if(!y){var objDate=new Date()}else{var objDate=new Date(y,parseInt(m)-1,d)}var i,leap=0,temp=0;var y=objDate.getFullYear(),m=objDate.getMonth()+1,d=objDate.getDate();var offset=(Date.UTC(objDate.getFullYear(),objDate.getMonth(),objDate.getDate())-Date.UTC(1900,0,31))/86400000;for(i=1900;i<2101&&offset>0;i++){temp=calendar.lYearDays(i);offset-=temp}if(offset<0){offset+=temp;i--}var isTodayObj=new Date(),isToday=false;if(isTodayObj.getFullYear()==y&&isTodayObj.getMonth()+1==m&&isTodayObj.getDate()==d){isToday=true}var nWeek=objDate.getDay(),cWeek=calendar.nStr1[nWeek];if(nWeek==0){nWeek=7}var year=i;var leap=calendar.leapMonth(i);var isLeap=false;for(i=1;i<13&&offset>0;i++){if(leap>0&&i==(leap+1)&&isLeap==false){--i;isLeap=true;temp=calendar.leapDays(year)}else{temp=calendar.monthDays(year,i)}if(isLeap==true&&i==(leap+1)){isLeap=false}offset-=temp}if(offset==0&&leap>0&&i==leap+1)if(isLeap){isLeap=false}else{isLeap=true;--i}if(offset<0){offset+=temp;--i}var month=i;var day=offset+1;var sm=m-1;var term3=calendar.getTerm(year,3);var gzY=calendar.toGanZhi(year-4);if(sm<2&&d<term3){gzY=calendar.toGanZhi(year-5)}else{gzY=calendar.toGanZhi(year-4)}var firstNode=calendar.getTerm(y,(m*2-1));var secondNode=calendar.getTerm(y,(m*2));var gzM=calendar.toGanZhi((y-1900)*12+m+11);if(d>=firstNode){gzM=calendar.toGanZhi((y-1900)*12+m+12)}var isTerm=false;var Term=null;if(firstNode==d){isTerm=true;Term=calendar.solarTerm[m*2-2]}if(secondNode==d){isTerm=true;Term=calendar.solarTerm[m*2-1]}var dayCyclical=Date.UTC(y,sm,1,0,0,0,0)/86400000+25567+10;var gzD=calendar.toGanZhi(dayCyclical+d-1);return{'lYear':year,'lMonth':month,'lDay':day,'Animal':calendar.getAnimal(year),'IMonthCn':(isLeap?"\u95f0":'')+calendar.toChinaMonth(month),'IDayCn':calendar.toChinaDay(day),'cYear':y,'cMonth':m,'cDay':d,'gzYear':gzY,'gzMonth':gzM,'gzDay':gzD,'isToday':isToday,'isLeap':isLeap,'nWeek':nWeek,'ncWeek':"\u661f\u671f"+cWeek,'isTerm':isTerm,'Term':Term}}};
|
|
(function($) {
|
|
var __FILE__ = $('script');
|
|
var lyydate_lang = {
|
|
en: {
|
|
week_array: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
month_array: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
|
lunar_festival: ["1.1.春节", "1.15.元宵", "5.5.端午", "7.7.七夕", "8.15.中秋", "9.9.重阳"],
|
|
solar_festival: ["1.1.元旦", "2.14.情人", "3.8.妇女", "4.1.愚人", "5.1.劳动", "6.1.儿童", "9.10.教师", "10.1.国庆", "12.25.圣诞"]
|
|
},
|
|
zh: {
|
|
week_array: ["日", "一", "二", "三", "四", "五", "六"],
|
|
month_array: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
|
|
lunar_festival: ["1.1.春节", "1.15.元宵", "5.5.端午", "7.7.七夕", "8.15.中秋", "9.9.重阳"],
|
|
solar_festival: ["1.1.元旦", "2.14.情人", "3.8.妇女", "4.1.愚人", "5.1.劳动", "6.1.儿童", "9.10.教师", "10.1.国庆", "12.25.圣诞"]
|
|
}
|
|
};
|
|
if(!Array.indexOf){
|
|
Array.prototype.indexOf = function(obj){
|
|
for(var i=0; i<this.length; i++){
|
|
if(this[i]==obj){
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
}
|
|
var lyy = function(that, options) {
|
|
this.obj = that;
|
|
this.month_lastday = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
this.addons = ["lyydatepicker_box", "laydate_void", "laydate_click", "LayDateSkin", "skins/", "/laydate.css"];
|
|
lyyobj = this;
|
|
options.event == "static" ? this.run($(that), options) : $(that).on(options.event, function() {
|
|
lyyobj.run($(that), options)
|
|
})
|
|
};
|
|
lyy.prototype = {
|
|
run: function($this, options) {
|
|
$("#lyydatepicker_box").remove();
|
|
this.elem_obj = $this;
|
|
this.options = options;
|
|
this.lang = lyydate_lang[this.get_options('language')];
|
|
this.mins = this.get_options('startDate').match(/\d+/g);
|
|
this.maxs = this.get_options('endDate').match(/\d+/g);
|
|
this.mouseflag = false;
|
|
this.elem_mouseflag = true;
|
|
this.elemv = /textarea|input/.test(this.elem_obj[0].tagName.toLocaleLowerCase()) ? "val" : "html";
|
|
$('body').append('<div id="lyydatepicker_box"></div>');
|
|
$('body').addClass('laydate_body');
|
|
this.box = $("#lyydatepicker_box")[0];
|
|
for (var i = 0; i < this.options.numberOfMonths; i++) {
|
|
this.inittable(i);
|
|
this.orien(this.box);
|
|
if(this.winarea(1)<568){break;}
|
|
};
|
|
},
|
|
inittable:function(i){
|
|
var laydateid="laydate_box"+i;
|
|
this.laydateid="#"+laydateid;
|
|
this.date_no=i;
|
|
var lyydate_html = '<div id="'+laydateid+'" data-dateno="'+this.date_no+'" class="laydate_box" name="laydate-v">';
|
|
lyydate_html += '<div class="laydate_top" id="laydate_top'+this.date_no+'"><a class="laydate_choose laydate_chprev laydate_tab"><</a><a class="laydate_choose laydate_chnext laydate_tab">></a><div class="laydate_ym laydate_y" id="laydate_YY'+this.date_no+'"><input id="laydate_y'+this.date_no+'" readonly><label></label><div class="laydate_yms" id="laydate_yys'+this.date_no+'"><a class="laydate_tab laydate_chtop"><</a><ul id="laydate_ys'+this.date_no+'"></ul><a class="laydate_tab laydate_chdown">></a></div></div><div class="laydate_ym laydate_m" id="laydate_MM'+this.date_no+'"><input id="laydate_m'+this.date_no+'" readonly><label></label><div class="laydate_yms" id="laydate_ms'+this.date_no+'">';
|
|
var that = this;
|
|
this.each(new Array(12), function(b) {
|
|
lyydate_html += '<span m="' + b + '">' + that.lang.month_array[b] + "</span>"
|
|
});
|
|
lyydate_html += "</div></div></div>" + this.viewtb() + '<div class="laydate_bottom"><ul id="laydate_hms'+this.date_no+'"><li class="laydate_sj">时间</li>' + '<li><input readonly>:</li>' + "<li><input readonly>:</li>" + "<li><input readonly></li>" + "</ul>" + '<div class="laydate_time" id="laydate_time'+this.date_no+'"></div>' + '<div class="laydate_btn">' + '<a id="laydate_today'+this.date_no+'">今天</a>' + '<a id="laydate_ok'+this.date_no+'">确认</a>' + "</div>" + '<div class="lyydate_description">'+this.options.date_description+'</div></div>';
|
|
lyydate_html += '</div>';
|
|
$('#lyydatepicker_box').append(lyydate_html);
|
|
this.options.date_description?$(".lyydate_description").css({"display":"block"}):"";
|
|
this.initDate();
|
|
this.iswrite();
|
|
this.triggers()
|
|
},
|
|
viewtb: function() {
|
|
var view_html = '<table class="laydate_table" id="laydate_table'+this.date_no+'"><thead>';
|
|
var that = this;
|
|
this.each(new Array(7), function(k) {
|
|
view_html += '<th>' + that.lang.week_array[k] + '</th>'
|
|
});
|
|
view_html += '</tr></thead><tbody>';
|
|
this.each(new Array(6), function(i) {
|
|
view_html += '<tr>';
|
|
that.each(new Array(7), function(j) {
|
|
view_html += '<td style="height:'+that.options.row_height+'px;"></td>'
|
|
});
|
|
view_html += '</tr>'
|
|
});
|
|
view_html += '</tbody></table>';
|
|
return view_html
|
|
},
|
|
initDate: function() {
|
|
var d = new Date,
|
|
obj = this.elem_obj,
|
|
e = (this.elemv == 'val' ? this.elem_obj.val().match(/\d+/g) : this.elem_obj.html().match(/\d+/g)) || this.get_options('defaultDate').match(/\d+/g) || [];
|
|
e.length < 3 && (e = [d.getFullYear(), d.getMonth() + 1, d.getDate()]);
|
|
e[2].length > 2 && (y = e[2], e[2] = e[1], e[1] = e[0], e[0] = y);
|
|
this.inymd = e;
|
|
this.viewDate(e[0], e[1] - 1 + this.date_no, e[2]);
|
|
},
|
|
viewDate: function(y, m, d) {
|
|
var f = {},g = new Date;
|
|
var thismonth=g.getMonth();
|
|
var default_e = (this.elemv == 'val' ? this.elem_obj.val().match(/\d+/g) : this.elem_obj.html().match(/\d+/g)) || this.get_options('defaultDate').match(/\d+/g) || [];
|
|
y < (0 | this.mins[0]) && (y = 0 | this.mins[0]);
|
|
y > (0 | this.maxs[0]) && (y = 0 | this.maxs[0]);
|
|
g.setFullYear(y, m, d);
|
|
f.ymd = [g.getFullYear(), g.getMonth(), g.getDate()];
|
|
this.month_lastday[1] = this.isleap(f.ymd[0]) ? 29 : 28;
|
|
g.setFullYear(f.ymd[0], f.ymd[1], 1);
|
|
f.FDay = g.getDay();
|
|
f.PDay = this.month_lastday[0 === m ? 11 : m - 1] - f.FDay + 1;
|
|
f.NDay = 1;
|
|
$obj = this;
|
|
thismonth=default_e.length==0?thismonth:this.date_no>0?thismonth:f.ymd[1];
|
|
$("#laydate_table"+this.date_no+" td").each(function(i, ele) {
|
|
var g, that = $(this),
|
|
y = f.ymd[0],
|
|
m = f.ymd[1] + 1;
|
|
that.attr('class', '');
|
|
i < f.FDay ? (that.html(i + f.PDay), g = i + f.PDay, that.addClass("laydate_nothis"), 1 === m && (y -= 1), m = 1 === m ? 12 : m - 1) : i >= f.FDay && i < f.FDay + $obj.month_lastday[f.ymd[1]] ? (that.html(i - f.FDay + 1), g = i - f.FDay + 1, i - f.FDay + 1 === f.ymd[2] && (thismonth==f.ymd[1] && (that.addClass($obj.addons[2]), f.thisDay = that))) : (that.html(f.NDay), g = f.NDay++, that.addClass("laydate_nothis"), 12 === m && (y += 1), m = 12 === m ? 1 : m + 1);
|
|
$obj.checkVoid(y, m, g)[0] && that.addClass($obj.addons[1]);
|
|
$obj.setlunar(that, y, m, g);
|
|
i >= f.FDay && i < f.FDay + $obj.month_lastday[f.ymd[1]] ? (i % 7) == 0 ? that.addClass("laydate_td_bg") : ((i + 1) % 7) == 0 ? that.addClass("laydate_td_bg") : "" : "";
|
|
ele.setAttribute("y", y);
|
|
ele.setAttribute("m", m);
|
|
ele.setAttribute("d", g);
|
|
y = m = g = null
|
|
});
|
|
thisDay = f.thisDay;
|
|
this.valid = thisDay?thisDay.hasClass(this.addons[1]):false;
|
|
this.ymd = f.ymd;
|
|
$("#laydate_y"+this.date_no).val(this.ymd[0]);
|
|
$("#laydate_m"+this.date_no).val(this.lang.month_array[this.ymd[1]]);
|
|
$("#laydate_ms"+this.date_no+" span").each(function(k, ele) {
|
|
var d = $obj.checkVoid($obj.ymd[0], (0 | ele.getAttribute("m")) + 1);
|
|
"y" === d[0] || "m" === d[0] ? $(this).addClass($obj.addons[1]) : $(this).removeClass($obj.addons[1]);
|
|
$(this).removeClass($obj.addons[2]);
|
|
d = null
|
|
});
|
|
$("#laydate_ms"+this.date_no+" span").eq([this.ymd[1]]).addClass(this.addons[2]);
|
|
f.times = [0 | this.inymd[3] || 0, 0 | this.inymd[4] || 0, 0 | this.inymd[5] || 0];
|
|
var lyyobj=this;
|
|
this.each(new Array(3), function(a) {
|
|
$("#laydate_hms"+lyyobj.date_no+" input")[a].value = $obj.digit($obj.timeVoid(f.times[a], a) ? 0 | $obj.mins[a + 3] : 0 | f.times[a])
|
|
})
|
|
},
|
|
viewYears: function(a,date_no) {
|
|
d = "";
|
|
thisobj = this;
|
|
this.each(new Array(25), function(b) {
|
|
d += 12 === b ? "<li " + (parseInt($("#laydate_y"+date_no).val()) === a ? 'class="' + thisobj.addons[2] + '"' : "") + ' y="' + a + '">' + a + "</li>" : '<li y="' + (a - 12 + b) + '">' + (a - 12 + b) + "</li>"
|
|
});
|
|
$("#laydate_ys"+date_no).html(d);
|
|
$("#laydate_ys"+date_no+" li").each(function(a, b) {
|
|
"y" === thisobj.checkVoid(b.getAttribute("y"))[0] ? $(this).addClass(thisobj.addons[1]) : ""
|
|
});
|
|
this.orien_y(date_no);
|
|
this.get_options('changeYear') && $("#laydate_ys"+date_no+" li").on('click', function(event) {
|
|
var that = $(this),
|
|
b = that[0];
|
|
thisobj.stopmp(event);
|
|
thisobj.date_no=date_no;
|
|
var mm=thisobj.lang.month_array.indexOf($("#laydate_m"+thisobj.date_no).val());
|
|
that.hasClass(thisobj.addons[1]) || (thisobj.viewDate(0 | this.getAttribute("y"), mm, thisobj.ymd[2]), thisobj.reshow())
|
|
});
|
|
},
|
|
setlunar: function($ele, y, m, d) {
|
|
var text = $ele.html();
|
|
var remarktext='';
|
|
if (this.options.festival) {
|
|
var lunar = calendar.solar2lunar(y, m, d);
|
|
for (var i = this.lang.solar_festival.length - 1; i >= 0; i--) {
|
|
var lunar_arr = this.lang.solar_festival[i].split('.');
|
|
if (lunar_arr[0] == lunar.cMonth && lunar_arr[1] == lunar.cDay) {
|
|
this.options.festival_replace_date?text = lunar_arr[2]:remarktext=lunar_arr[2];
|
|
$ele.addClass('laydate_td_bg');
|
|
break;
|
|
}
|
|
};
|
|
for (var i = this.lang.lunar_festival.length - 1; i >= 0; i--) {
|
|
var lunar_arr = this.lang.lunar_festival[i].split('.');
|
|
if (lunar_arr[0] == lunar.lMonth && lunar_arr[1] == lunar.lDay) {
|
|
this.options.festival_replace_date?text = lunar_arr[2]:remarktext=lunar_arr[2];
|
|
$ele.addClass('laydate_td_bg');
|
|
break;
|
|
}
|
|
};
|
|
//remarktext=lunar.IDayCn;
|
|
};
|
|
var remark_flag = false,
|
|
remark_link = false,
|
|
onlyremarkdate_css=this.options.onlyremarkdate?$ele.addClass('laydate_void'):"";
|
|
if (this.get_options('remarks') != false) {
|
|
var obj = eval(this.get_options('remarks'));
|
|
!remark_flag && obj[0].date == "default" ? remarktext = obj[0].remark : remarktext;
|
|
var lyyobj=this;
|
|
$(obj).each(function(i) {
|
|
var val = obj[i];
|
|
var ymd = val.date.split('-');
|
|
if (ymd[0] == y && ymd[1] == m && ymd[2] == d) {
|
|
lyyobj.options.onlyremarkdate?$ele.removeClass('laydate_void'):"";
|
|
remark_link = val.link ? val.link : false;
|
|
remarktext = val.remark?val.remark:remarktext;
|
|
$ele.addClass('laydate_td_bg');
|
|
remark_flag = true;
|
|
val.title?$ele[0].setAttribute("title", val.title):"";
|
|
return false
|
|
}
|
|
});
|
|
};
|
|
|
|
if (this.options.disable_date != false) {
|
|
var disabledate = this.get_options('disable_date');
|
|
var disabledate_arr=disabledate.split(',');
|
|
var datenum=disabledate_arr.length;
|
|
for (var i = 0; i < datenum; i++) {
|
|
var ymd=disabledate_arr[i].split('-');
|
|
if (ymd[0] == y && ymd[1] == m && ymd[2] == d) {
|
|
$ele.addClass('laydate_void');
|
|
return false
|
|
}
|
|
};
|
|
};
|
|
|
|
text = remark_link ? '<a href="' + remark_link + '">' + text + '<br><div class="lunar">' + remarktext + '</div>' + '</a>' : text + '<br><div class="lunar">' + remarktext + '</div>';
|
|
$ele.html(text);
|
|
},
|
|
digit: function(a) {
|
|
return 10 > a ? "0" + (0 | a) : a
|
|
},
|
|
shde: function(a, b) {
|
|
a.style.display = b ? "none" : "block"
|
|
},
|
|
each: function(a, b) {
|
|
for (var c = 0, d = a.length; d > c && b(c, a[c]) !== !1; c++) {}
|
|
},
|
|
isleap: function(a) {
|
|
return 0 === a % 4 && 0 !== a % 100 || 0 === a % 400
|
|
},
|
|
checkVoid: function(a, b, d) {
|
|
var e = [];
|
|
return a = 0 | a, b = 0 | b, d = 0 | d, a < this.mins[0] ? e = ["y"] : a > this.maxs[0] ? e = ["y", 1] : a >= this.mins[0] && a <= this.maxs[0] && (a == this.mins[0] && (b < this.mins[1] ? e = ["m"] : b == this.mins[1] && d <= this.mins[2] && (e = ["d"])), a == this.maxs[0] && (b > this.maxs[1] ? e = ["m", 1] : b == this.maxs[1] && d > this.maxs[2] && (e = ["d", 1]))), e
|
|
},
|
|
timeVoid: function(a, b) {
|
|
if (this.ymd[1] + 1 == this.mins[1] && this.ymd[2] == this.mins[2]) {
|
|
if (0 === b && a < this.mins[3]) return 1;
|
|
if (1 === b && a < this.mins[4]) return 1;
|
|
if (2 === b && a < this.mins[5]) return 1
|
|
} else if (this.ymd[1] + 1 == this.maxs[1] && this.ymd[2] == this.maxs[2]) {
|
|
if (0 === b && a > this.maxs[3]) return 1;
|
|
if (1 === b && a > this.maxs[4]) return 1;
|
|
if (2 === b && a > this.maxs[5]) return 1
|
|
};
|
|
return a > (b ? 59 : 23) ? 1 : void 0
|
|
},
|
|
creation: function(a, b) {
|
|
var nextday = new Date(a[0]+'/'+a[1]+'/'+a[2]),
|
|
nexttime = nextday.getTime(),
|
|
nexttime = Number(nexttime)+Number(24*60*60*1000);
|
|
nextday.setTime(nexttime);
|
|
next_d = nextday.getFullYear()+'/'+(nextday.getMonth() + 1)+'/'+nextday.getDate();
|
|
|
|
var e = $("#laydate_hms"+this.date_no+" input"),
|
|
f = this.parse(a, [e[0].value, e[1].value, e[2].value]);
|
|
this.elemv == 'val' ? this.elem_obj.val(f) : this.elem_obj.html(f);
|
|
this.ymd[0]=a[0];
|
|
this.ymd[1]=a[1]-1;
|
|
this.ymd[2]=a[2];
|
|
b || (this.remove(), "function" == typeof this.get_options('onSelect') && this.get_options('onSelect')(f,next_d))
|
|
},
|
|
parse: function(a, d, e) {
|
|
a = a.concat(d);
|
|
e = e || this.get_options('format');
|
|
e.indexOf("yyyy") != -1 ? e = e.replace('yyyy', a[0]) : e = e.replace('yy', String(a[0]).substr(2, 2));
|
|
e.indexOf("mm") != -1 ? e = e.replace('mm', this.digit(a[1])) : e = e.replace('m', a[1]);
|
|
e.indexOf("dd") != -1 ? e = e.replace('dd', this.digit(a[2])) : e = e.replace('d', a[2]);
|
|
e = e.replace('h', a[3]);
|
|
e = e.replace('i', a[4]);
|
|
e = e.replace('s', a[5]);
|
|
return e
|
|
},
|
|
remove: function() {
|
|
this.get_options('event') != "static" && $("#" + this.addons[0]).remove();
|
|
},
|
|
stopmp: function(e) {
|
|
return e = e || this.event, e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0, this
|
|
},
|
|
reshow: function() {
|
|
$("#" + this.addons[0] + " .laydate_show").each(function(a, b) {
|
|
$(this).removeClass("laydate_show")
|
|
});
|
|
return this
|
|
},
|
|
datenow: function(a, b) {
|
|
var d = new Date(0 | a ?
|
|
function(a) {
|
|
return 864e5 > a ? +new Date + 864e5 * a : a
|
|
}(parseInt(a)) : +new Date);
|
|
datee=this.parse([d.getFullYear(), d.getMonth() + 1, d.getDate()], [d.getHours(), d.getMinutes(), d.getSeconds()], b);
|
|
return datee;
|
|
},
|
|
iswrite: function() {
|
|
this.shde($("#laydate_hms"+this.date_no)[0], !this.get_options('istime'));
|
|
this.shde($("#laydate_today"+this.date_no)[0], !("todayBtn" in this.options ? this.options.todayBtn : 1));
|
|
this.shde($("#laydate_ok"+this.date_no)[0], ("autoclose" in this.options ? this.options.autoclose : 1));
|
|
if (this.get_options('date_description') || this.get_options('todayBtn') || !this.get_options('autoclose') || this.get_options('istime') || this.get_options('remarks')) {
|
|
$("#laydate_box"+this.date_no+">.laydate_bottom").css({"display":"block"});
|
|
};
|
|
},
|
|
orien: function(a) {
|
|
var laydate_left = 0;
|
|
$("#" + this.addons[0]).css({"max-width":this.options.max_width+"px"});
|
|
if (this.winarea(1) > 568) {
|
|
var d, e = this.elem_obj[0].getBoundingClientRect();
|
|
laydate_left = (this.winarea(1) - e.left - this.scroll(1)) < this.options.max_width ? e.left - (this.options.max_width - (this.winarea(1) - e.left - this.scroll(1))) : e.left + this.scroll(1);
|
|
a.style.left = laydate_left + "px";
|
|
a.style.top = e.bottom + this.scroll() + "px";
|
|
this.options.numberOfMonths<2 && $("#laydate_box" + this.date_no).css({"width":"100%"});
|
|
} else {
|
|
a.style.left = 0, a.style.top = 0, $(a).css({
|
|
"max-width": "100%",
|
|
"height": "100%"
|
|
});
|
|
a.style.top = this.scroll()+"px";
|
|
$("#laydate_box" + this.date_no).css({"width":"100%"});
|
|
};
|
|
var datewidth = $("#laydate_box" + this.date_no).width() - 2;
|
|
var laydate_MM_left = $("#laydate_MM"+this.date_no)[0].getBoundingClientRect().left + this.scroll(1) - laydate_left-(this.date_no*$(".laydate_box").width());
|
|
$("#laydate_ms"+this.date_no).css({
|
|
"width": datewidth,
|
|
"left": "-" + laydate_MM_left + "px"
|
|
});
|
|
this.options.changeMonth?"":$("#laydate_MM"+this.date_no).children("label").hide();
|
|
this.options.changeYear?"":$("#laydate_YY"+this.date_no).children("label").hide();
|
|
},
|
|
orien_y:function(date_no){
|
|
var laydate_left = 0;
|
|
if (this.winarea(1) > 568) {
|
|
laydate_left=$("#lyydatepicker_box").offset().left+(date_no*$(".laydate_box").width());
|
|
};
|
|
var datewidth = $("#laydate_box" + date_no).width() - 2;
|
|
var laydate_YY_left = $("#laydate_YY"+date_no)[0].getBoundingClientRect().left + this.scroll(1) - laydate_left;
|
|
$("#laydate_yys"+date_no).css({
|
|
"width": datewidth,
|
|
"left": "-" + laydate_YY_left + "px"
|
|
});
|
|
},
|
|
scroll: function(a) {
|
|
return a = a ? "scrollLeft" : "scrollTop", document.body[a] | document.documentElement[a]
|
|
},
|
|
winarea: function(a) {
|
|
return document.documentElement[a ? "clientWidth" : "clientHeight"]
|
|
},
|
|
get_options: function(name) {
|
|
this.options[name] = this.elem_obj.data(name) ? this.elem_obj.data(name) : this.options[name];
|
|
return this.options[name]
|
|
},
|
|
set_dateno:function(that){
|
|
if ($(that).parents(".laydate_box").length==0) {
|
|
return false;
|
|
};
|
|
var date_no=$(that).parents(".laydate_box").attr("data-dateno");
|
|
this.date_no=date_no;
|
|
},
|
|
triggers: function() {
|
|
var thisobj = this;
|
|
/*头部左右切换月份*/
|
|
$("#laydate_top"+thisobj.date_no+">.laydate_choose").on("click", function(event) {
|
|
thisobj.stopmp(event).reshow();
|
|
thisobj.set_dateno(this);
|
|
if (!thisobj.options.changeMonth) {
|
|
//return false
|
|
};
|
|
var datepicker_num=$(".laydate_box").length;
|
|
//for (var i = 0; i < datepicker_num; i++) {
|
|
//thisobj.date_no=i;
|
|
thisobj.ymd[1]=thisobj.lang.month_array.indexOf($("#laydate_m"+thisobj.date_no).val());
|
|
var yyyy=$("#laydate_y"+thisobj.date_no).val();
|
|
$(this).hasClass("laydate_chnext")? (thisobj.ymd[1] = thisobj.ymd[1] + 1, 12 === thisobj.ymd[1] && (yyyy++, thisobj.ymd[1] = 0)) : (thisobj.ymd[1]--, -1 === thisobj.ymd[1] && (yyyy--, thisobj.ymd[1] = 11));
|
|
thisobj.viewDate(yyyy, thisobj.ymd[1], thisobj.ymd[2]);
|
|
//};
|
|
});
|
|
/*年月下拉菜单*/
|
|
$("#laydate_YY"+this.date_no).on("click",function(event){
|
|
thisobj.stopmp(event);
|
|
thisobj.set_dateno(this);
|
|
if (!thisobj.options.changeYear) {
|
|
$(this).children("label").css({
|
|
"display": "none"
|
|
});
|
|
return false;
|
|
};
|
|
if ($(this).find('div.laydate_yms').eq(0).hasClass('laydate_show')) {
|
|
thisobj.reshow()
|
|
} else {
|
|
$(this).next(".laydate_MM"+thisobj.date_no).find('div.laydate_yms').eq(0).hasClass('laydate_show') && thisobj.reshow();
|
|
$(this).find('div.laydate_yms').eq(0).addClass('laydate_show');
|
|
thisobj.viewYears(parseInt($("#laydate_y"+thisobj.date_no).val()),thisobj.date_no);
|
|
}
|
|
});
|
|
$("#laydate_MM"+this.date_no).on('click', function(event) {
|
|
thisobj.stopmp(event);
|
|
thisobj.set_dateno(this);
|
|
if (!thisobj.options.changeMonth) {
|
|
$(this).children("label").css({
|
|
"display": "none"
|
|
});
|
|
return false
|
|
}
|
|
if ($(this).find('div.laydate_yms').eq(0).hasClass('laydate_show')) {
|
|
thisobj.reshow()
|
|
} else {
|
|
$(this).prev(".laydate_YY"+thisobj.date_no).find('div.laydate_yms').eq(0).hasClass('laydate_show') && thisobj.reshow();
|
|
$(this).find('div.laydate_yms').eq(0).addClass('laydate_show');
|
|
}
|
|
});
|
|
/*左右切换年份*/
|
|
$("#laydate_yys"+this.date_no+">.laydate_tab").on('click', function(event) {
|
|
thisobj.stopmp(event);
|
|
thisobj.set_dateno(this);
|
|
var end_y = Number($("#laydate_ys"+thisobj.date_no+">li").last().attr('y')) + 13,
|
|
first_y = Number($("#laydate_ys"+thisobj.date_no+">li").eq(0).attr('y')) - 13;
|
|
$(this).hasClass('laydate_chtop') && thisobj.viewYears(parseInt(first_y),thisobj.date_no);
|
|
$(this).hasClass('laydate_chdown') && thisobj.viewYears(parseInt(end_y),thisobj.date_no)
|
|
});
|
|
/*点击面板隐藏年月下拉菜单*/
|
|
$("#" + this.addons[0]).click(function() {
|
|
thisobj.set_dateno(this);
|
|
thisobj.mm_drown = thisobj.yy_drown = false;
|
|
thisobj.reshow()
|
|
});
|
|
/*从下拉菜单选择月份*/
|
|
$("#laydate_ms"+this.date_no+" span").on('click', function(event) {
|
|
thisobj.stopmp(event);
|
|
thisobj.set_dateno(this);
|
|
var that = $(this),
|
|
b = that[0];
|
|
var yyyy=$("#laydate_y"+thisobj.date_no).val();
|
|
that.hasClass(thisobj.addons[1]) || (thisobj.viewDate(yyyy, 0 | b.getAttribute("m"), thisobj.ymd[2]), thisobj.reshow())
|
|
});
|
|
/*选择日期*/
|
|
$("#laydate_table"+this.date_no+" td").on('click', function(event) {
|
|
var that = $(this),
|
|
b = that[0];
|
|
thisobj.set_dateno(this);
|
|
b.getAttribute("title")?($(".lyydate_description").text(b.getAttribute("title")),$(".lyydate_description").css({"display":"block"})):thisobj.options.date_description?$(".lyydate_description").text(thisobj.options.date_description):$(".lyydate_description").text('');
|
|
that.hasClass(thisobj.addons[1]) || (thisobj.stopmp(event).reshow(), thisobj.creation([0 | b.getAttribute("y"), 0 | b.getAttribute("m"), 0 | b.getAttribute("d")],!thisobj.options.autoclose),$(".laydate_table td").removeClass(thisobj.addons[2]),that.addClass(thisobj.addons[2]))
|
|
});
|
|
/*选择今天*/
|
|
$("#laydate_today"+this.date_no).on("click", function(event) {
|
|
thisobj.set_dateno(this);
|
|
var f = thisobj.datenow(0, thisobj.options.format);
|
|
thisobj.elemv == 'val' ? thisobj.elem_obj.val(f) : thisobj.elem_obj.html(f);
|
|
var d = new Date,
|
|
e = [d.getFullYear(), d.getMonth() + 1, d.getDate()];
|
|
thisobj.inymd = e;
|
|
thisobj.viewDate(e[0], e[1] - 1, e[2]);
|
|
//thisobj.remove();
|
|
});
|
|
/*需要确认才会关闭日历*/
|
|
$("#laydate_ok"+this.date_no).on('click', function() {
|
|
thisobj.set_dateno(this);
|
|
thisobj.creation([thisobj.ymd[0], thisobj.ymd[1] + 1, thisobj.ymd[2]])
|
|
});
|
|
/*点击日历以外的地方关闭日历*/
|
|
$("#" + this.addons[0]).mouseover(function(event) {
|
|
thisobj.mouseflag = true
|
|
}).mouseout(function(event) {
|
|
thisobj.mouseflag = false
|
|
});
|
|
this.elem_obj.mouseover(function(event) {
|
|
thisobj.elem_mouseflag = true
|
|
}).mouseout(function(event) {
|
|
thisobj.elem_mouseflag = false
|
|
});
|
|
$(document).bind('click', function(event) {
|
|
$("#" + thisobj.addons[0]).length > 0 ? (!thisobj.mouseflag && !thisobj.elem_mouseflag) ? thisobj.remove() : "" : ""
|
|
})
|
|
}
|
|
};
|
|
$.fn.lyydatepicker = function(options) {
|
|
var defaults = {
|
|
event: "click",
|
|
format: 'yyyy/mm/dd',
|
|
startDate: '1900-01-01',
|
|
endDate: '2100-12-31',
|
|
defaultDate: '',
|
|
language: 'en',
|
|
date_description:'',
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
todayBtn: false,
|
|
autoclose: true,
|
|
festival: false,
|
|
festival_replace_date:true,
|
|
istime: false,
|
|
remarks: false,
|
|
disable_date:false,
|
|
onlyremarkdate:false,
|
|
numberOfMonths:1,
|
|
max_width:360,
|
|
row_height:45,
|
|
onSelect: ''
|
|
};
|
|
var result,argument_arr = arguments,
|
|
h = Array.prototype.slice.call(arguments, 1);
|
|
this.each(function() {
|
|
var $this = $(this),
|
|
dateobj = $this.data("datetimepicker"),
|
|
k = typeof options == "object" && options;
|
|
if (!dateobj) {
|
|
dateobj = $this.data("datetimepicker", new lyy(this, $.extend(defaults, k)))
|
|
} else if (typeof argument_arr[0] == "string" && typeof dateobj[argument_arr[0]] == "function") {
|
|
result=dateobj[argument_arr[0]].apply(dateobj, h);
|
|
if (result !== undefined) {
|
|
return false;
|
|
};
|
|
} else {
|
|
$.error("Method " + argument_arr[0] + " does not exist on jQuery.pluginName");
|
|
return false;
|
|
}
|
|
});
|
|
if (result !== undefined) {
|
|
return result;
|
|
}else{
|
|
return this;
|
|
}
|
|
}
|
|
})(jQuery); |