LRR/css/jquery.datetimepicker.min.js

1 line
14 KiB
JavaScript
Raw Permalink Normal View History

2021-10-18 21:39:16 +08:00
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(window.jQuery)}(function(e){function a(a,t){var n,s,d,r={},l=e.fn.datetimepicker.CONSTS,o=l.NAV,i=l.I18N[t.language]?l.I18N[t.language]:l.I18N.en,c={showYear:null,showMonth:null},u=function(e){return new Date(e.getTime())},p=t.date instanceof Date?u(t.date):new Date,v=t.date instanceof Date?u(t.date):null,h=t.firstDayOfWeek,m=e(a),D=function(e,a){var t=e.getFullYear();return null==a&&(a=e.getMonth()),0!=t%4||0==t%100&&0!=t%400||1!==a?[31,28,31,30,31,30,31,31,30,31,30,31][a]:29},M=function(e){return""===e||null==e},f=function(a,t,n,s){return e.isFunction(t)?t.apply(a,n||[]):s},g=function(e,a,t){var n=e+"";for(t||(t=" ");n.length<a;)n=t+n;return n.toString()},b=function(e,a){var t=e.str,n=e.len;switch(e.char){case"E":t=l.DN[a.getDay()];break;case"y":t=n<=3?(a.getFullYear()+"").slice(2,4):a.getFullYear();break;case"M":t=n>2?l.MN[a.getMonth()]:n<2?a.getMonth()+1:g(a.getMonth()+1,2,"0");break;case"d":t=n>1?g(a.getDate(),2,"0"):a.getDate();break;case"h":var s=a.getHours()%12;0===s&&(s=12),t=n>1?g(s,2,"0"):s;break;case"H":t=n>1?g(a.getHours(),2,"0"):a.getHours();break;case"m":t=n>1?g(a.getMinutes(),2,"0"):a.getMinutes();break;case"s":t=n>1?g(a.getSeconds(),2,"0"):a.getSeconds();break;case"a":t=a.getHours()<12?"am":"pm";break;default:t=e.str}return t},y=function(a,t,n,s,d){var r=e("<td/>").attr("colspan",n).html(t).appendTo(a);return s&&r.data("nav",s),r.addClass(d),r},Y=function(){var e=t.startDate,a=c.showMonth,n=c.showYear;e?n>e.getFullYear()?a>0?k(a-1):(p.setFullYear(n-1),k(11)):n==e.getFullYear()&&a>e.getMonth()&&a>0&&(k(a-1),p<e&&(p=u(e))):a>0?k(a-1):(p.setFullYear(n-1),k(11))},C=function(){var e=t.endDate,a=c.showMonth,n=c.showYear;e?n<e.getFullYear()?a<11?k(a+1):(p.setFullYear(n+1),k(0)):n==e.getFullYear()&&a<e.getMonth()&&(k(a+1),p>e&&(p=u(e))):a<11?k(a+1):(p.setFullYear(n+1),k(0))},k=function(e){var a=p.getDate(),n=t.endDate,s=t.startDate,d=D(p,e);a>d&&p.setDate(d),p.setMonth(e),n&&p>n&&p.setDate(n.getDate()),s&&p<s&&p.setDate(s.getDate())},w=function(e,a){if(a instanceof Date){var n=(a=u(a)).getFullYear(),s=a.getMonth(),d=a.getDate(),r=new Date,p=r.getFullYear(),m=r.getMonth(),M=r.getDate();c.showYear=n,c.showMonth=s;var f=t.startDate,g=t.endDate;e.$title.text(i.MN[s]+", "+n);var b=u(a);b.setDate(D(b,null)+1),g&&b>g||b.getFullYear()>l.MAXYEAR?e.$nextm.addClass("disabled").removeClass("hover").data("disabled",!0):e.$nextm.removeClass("disabled").data("disabled",!1);var y=u(a);y.setDate(0),f&&y<f||y.getFullYear()<l.MINYEAR?e.$prevm.addClass("disabled").removeClass("hover").data("disabled",!0):e.$prevm.removeClass("disabled").data("disabled",!1),a.setDate(1);var Y=(a.getDay()-h)%7;a.setDate(0-Y),a.setDate(a.getDate()+1);for(var C=e.find("tbody").children().eq(0),k=0;k<6&&C.length;k++){for(var w,T=C.children(),E=0;E<7;++E,a.setDate(w+1)){var A=T.eq(E);if(A.removeClass().data("nav",o.day),!A.length)break;w=a.getDate(),A.text(w);var N=!1;if(a.getMonth()==s?null!=f&&f>a||null!=g&&g<a?(A.addClass("day disabled"),N=!0):A.addClass("day"):A.addClass("oday"),A.data("disabled",N),!N&&v){v.getMonth()==s&&w==d&&(c.selectedDate&&c.selectedDate.removeClass("selected"),A.addClass("selected"),c.selectedDate=A,c.showDay=w),a.getFullYear()==p&&a.getMonth()==m&&w==M&&A.addClass("today");var x=a.getDay();0!==x&&6!==x||A.addClass("weekend")}}C=C.next()}}},T=function(a,n){if(n){var s=n.getFullYear(),d=n.getMonth(),r=e(a).data("midYear");r?s>r+5?r+=10:s<r-4&&(r-=10):r=s,e(a).data("midYear",r);var u,p,v,h,m=[r-4,r-3,r-2,r-1,r,r+1,r+2,r+3,r+4,r+5],D=e("td.year",a),f=e("td.month",a),g=t.endDate,b=t.startDate;g&&g&&s==(u=g.getFullYear())&&(p=g.getMonth()),(!u||u>l.MAXYEAR)&&(u=l.MAXYEAR),b&&b&&s==(v=b.getFullYear())&&(h=b.getMonth()),(!v||v<l.MINYEAR)&&(v=l.MINYEAR);for(var y=0;y<12;y++){var Y=f.eq(y).text(i.MN[y]).data("nav",o.month).data("month",y);if(y==d&&(c.selectedMonth&&c.selectedMonth.removeClass("selected"),Y.addClass("selected"),c.selectedMonth=Y),!M(h)&&y<h||!M(p)&&y>p?Y.addClass("disabled").data("disabled",!0):Y.removeClass("disabled").data("disabled",!1),y<10){