1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00
invoiceninja/public/js/jquery.datetimepicker.min.js

4 lines
54 KiB
JavaScript
Raw Normal View History

2016-07-20 23:12:46 +02:00
var DateFormatter;!function(){"use strict";var e,t,a,n,r,o;r=864e5,o=3600,e=function(e,t){return"string"==typeof e&&"string"==typeof t&&e.toLowerCase()===t.toLowerCase()},t=function(e,a,n){var r=n||"0",o=e.toString();return o.length<a?t(r+o,a):o},a=function(e){var t,n;for(e=e||{},t=1;t<arguments.length;t++)if(n=arguments[t])for(var r in n)n.hasOwnProperty(r)&&("object"==typeof n[r]?a(e[r],n[r]):e[r]=n[r]);return e},n={dateSettings:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridiem:["AM","PM"],ordinal:function(e){var t=e%10,a={1:"st",2:"nd",3:"rd"};return 1!==Math.floor(e%100/10)&&a[t]?a[t]:"th"}},separators:/[ \-+\/\.T:@]/g,validParts:/[dDjlNSwzWFmMntLoYyaABgGhHisueTIOPZcrU]/g,intParts:/[djwNzmnyYhHgGis]/g,tzParts:/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,tzClip:/[^-+\dA-Z]/g},DateFormatter=function(e){var t=this,r=a(n,e);t.dateSettings=r.dateSettings,t.separators=r.separators,t.validParts=r.validParts,t.intParts=r.intParts,t.tzParts=r.tzParts,t.tzClip=r.tzClip},DateFormatter.prototype={constructor:DateFormatter,parseDate:function(t,a){var n,r,o,i,s,d,u,l,f,c,h=this,m=!1,g=!1,p=h.dateSettings,y={date:null,year:null,month:null,day:null,hour:0,min:0,sec:0};if(t){if(t instanceof Date)return t;if("number"==typeof t)return new Date(t);if("U"===a)return o=parseInt(t),o?new Date(1e3*o):t;if("string"!=typeof t)return"";if(n=a.match(h.validParts),!n||0===n.length)throw new Error("Invalid date format definition.");for(r=t.replace(h.separators,"\0").split("\0"),o=0;o<r.length;o++)switch(i=r[o],s=parseInt(i),n[o]){case"y":case"Y":f=i.length,2===f?y.year=parseInt((s<70?"20":"19")+i):4===f&&(y.year=s),m=!0;break;case"m":case"n":case"M":case"F":isNaN(i)?(d=p.monthsShort.indexOf(i),d>-1&&(y.month=d+1),d=p.months.indexOf(i),d>-1&&(y.month=d+1)):s>=1&&s<=12&&(y.month=s),m=!0;break;case"d":case"j":s>=1&&s<=31&&(y.day=s),m=!0;break;case"g":case"h":u=n.indexOf("a")>-1?n.indexOf("a"):n.indexOf("A")>-1?n.indexOf("A"):-1,c=r[u],u>-1?(l=e(c,p.meridiem[0])?0:e(c,p.meridiem[1])?12:-1,s>=1&&s<=12&&l>-1?y.hour=s+l-1:s>=0&&s<=23&&(y.hour=s)):s>=0&&s<=23&&(y.hour=s),g=!0;break;case"G":case"H":s>=0&&s<=23&&(y.hour=s),g=!0;break;case"i":s>=0&&s<=59&&(y.min=s),g=!0;break;case"s":s>=0&&s<=59&&(y.sec=s),g=!0}if(m===!0&&y.year&&y.month&&y.day)y.date=new Date(y.year,y.month-1,y.day,y.hour,y.min,y.sec,0);else{if(g!==!0)return!1;y.date=new Date(0,0,0,y.hour,y.min,y.sec,0)}return y.date}},guessDate:function(e,t){if("string"!=typeof e)return e;var a,n,r,o,i=this,s=e.replace(i.separators,"\0").split("\0"),d=/^[djmn]/g,u=t.match(i.validParts),l=new Date,f=0;if(!d.test(u[0]))return e;for(n=0;n<s.length;n++){switch(f=2,r=s[n],o=parseInt(r.substr(0,2)),n){case 0:"m"===u[0]||"n"===u[0]?l.setMonth(o-1):l.setDate(o);break;case 1:"m"===u[0]||"n"===u[0]?l.setDate(o):l.setMonth(o-1);break;case 2:a=l.getFullYear(),r.length<4?(l.setFullYear(parseInt(a.toString().substr(0,4-r.length)+r)),f=r.length):(l.setFullYear=parseInt(r.substr(0,4)),f=4);break;case 3:l.setHours(o);break;case 4:l.setMinutes(o);break;case 5:l.setSeconds(o)}r.substr(f).length>0&&s.splice(n+1,0,r.substr(f))}return l},parseFormat:function(e,a){var n,i=this,s=i.dateSettings,d=/\\?(.?)/gi,u=function(e,t){return n[e]?n[e]():t};return n={d:function(){return t(n.j(),2)},D:function(){return s.daysShort[n.w()]},j:function(){return a.getDate()},l:function(){return s.days[n.w()]},N:function(){return n.w()||7},w:function(){return a.getDay()},z:function(){var e=new Date(n.Y(),n.n()-1,n.j()),t=new Date(n.Y(),0,1);return Math.round((e-t)/r)},W:function(){var e=new Date(n.Y(),n.n()-1,n.j()-n.N()+3),a=new Date(e.getFullYear(),0,4);return t(1+Math.round((e-a)/r/7),2)},F:function(){return s.months[a.getMonth()]},m:function(){return t(n.n(),2)}
z.find("."+C.prev).css("visibility",C.prevButton?"visible":"hidden"),z.find("."+C.next).css("visibility",C.nextButton?"visible":"hidden"),C.mask&&(a.off("keydown.xdsoft"),C.mask===!0&&(C.mask=C.format.replace(/Y/g,"9999").replace(/F/g,"9999").replace(/m/g,"19").replace(/d/g,"39").replace(/H/g,"29").replace(/i/g,"59").replace(/s/g,"59")),"string"===e.type(C.mask)&&(d(C.mask,a.val())||(a.val(C.mask.replace(/[0-9]/g,"_")),s(a[0],0)),a.on("keydown.xdsoft",function(t){var n,r,o=this.value,u=t.which;if(u>=l&&u<=f||u>=c&&u<=h||u===v||u===g){for(n=i(this),r=u!==v&&u!==g?String.fromCharCode(c<=u&&u<=h?u-l:u):"_",u!==v&&u!==g||!n||(n-=1,r="_");/[^0-9_]/.test(C.mask.substr(n,1))&&n<C.mask.length&&n>0;)n+=u===v||u===g?-1:1;if(o=o.substr(0,n)+r+o.substr(n+1),""===e.trim(o))o=C.mask.replace(/[0-9]/g,"_");else if(n===C.mask.length)return t.preventDefault(),!1;for(n+=u===v||u===g?0:1;/[^0-9_]/.test(C.mask.substr(n,1))&&n<C.mask.length&&n>0;)n+=u===v||u===g?-1:1;d(C.mask,o)?(this.value=o,s(this,n)):""===e.trim(o)?this.value=C.mask.replace(/[0-9]/g,"_"):a.trigger("error_input.xdsoft")}else if([w,O,M,_,W].indexOf(u)!==-1&&F||[y,D,x,b,k,S,m,T,p].indexOf(u)!==-1)return!0;return t.preventDefault(),!1}))),C.validateOnBlur&&a.off("blur.xdsoft").on("blur.xdsoft",function(){if(C.allowBlank&&!e.trim(e(this).val()).length)e(this).val(null),j.data("xdsoft_datetime").empty();else if(n.parseDate(e(this).val(),C.format))j.data("xdsoft_datetime").setCurrentTime(e(this).val());else{var t=+[e(this).val()[0],e(this).val()[1]].join(""),a=+[e(this).val()[2],e(this).val()[3]].join("");!C.datepicker&&C.timepicker&&t>=0&&t<24&&a>=0&&a<60?e(this).val([t,a].map(function(e){return e>9?e:"0"+e}).join(":")):e(this).val(n.formatDate(Y.now(),C.format)),j.data("xdsoft_datetime").setCurrentTime(e(this).val())}j.trigger("changedatetime.xdsoft")}),C.dayOfWeekStartPrev=0===C.dayOfWeekStart?6:C.dayOfWeekStart-1,j.trigger("xchange.xdsoft").trigger("afterOpen.xdsoft")},j.data("options",C).on("touchstart mousedown.xdsoft",function(e){return e.stopPropagation(),e.preventDefault(),G.hide(),B.hide(),!1}),L.append(E),L.xdsoftScroller(),j.on("afterOpen.xdsoft",function(){L.xdsoftScroller()}),j.append(J).append(N),C.withoutCopyright!==!0&&j.append(H),J.append(z).append(I).append(R),e(C.parentID).append(j),s=function(){var t=this;t.now=function(e){var a,n,r=new Date;return!e&&C.defaultDate&&(a=t.strToDateTime(C.defaultDate),r.setFullYear(a.getFullYear()),r.setMonth(a.getMonth()),r.setDate(a.getDate())),C.yearOffset&&r.setFullYear(r.getFullYear()+C.yearOffset),!e&&C.defaultTime&&(n=t.strtotime(C.defaultTime),r.setHours(n.getHours()),r.setMinutes(n.getMinutes())),r},t.isValidDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)&&!isNaN(e.getTime())},t.setCurrentTime=function(e){t.currentTime="string"==typeof e?t.strToDateTime(e):t.isValidDate(e)?e:t.now(),j.trigger("xchange.xdsoft")},t.empty=function(){t.currentTime=null},t.getCurrentTime=function(e){return t.currentTime},t.nextMonth=function(){void 0!==t.currentTime&&null!==t.currentTime||(t.currentTime=t.now());var a,n=t.currentTime.getMonth()+1;return 12===n&&(t.currentTime.setFullYear(t.currentTime.getFullYear()+1),n=0),a=t.currentTime.getFullYear(),t.currentTime.setDate(Math.min(new Date(t.currentTime.getFullYear(),n+1,0).getDate(),t.currentTime.getDate())),t.currentTime.setMonth(n),C.onChangeMonth&&e.isFunction(C.onChangeMonth)&&C.onChangeMonth.call(j,Y.currentTime,j.data("input")),a!==t.currentTime.getFullYear()&&e.isFunction(C.onChangeYear)&&C.onChangeYear.call(j,Y.currentTime,j.data("input")),j.trigger("xchange.xdsoft"),n},t.prevMonth=function(){void 0!==t.currentTime&&null!==t.currentTime||(t.currentTime=t.now());var a=t.currentTime.getMonth()-1;return a===-1&&(t.currentTime.setFullYear(t.currentTime.getFullYear()-1),a=11),t.currentTime.setDate(Math.min(new Date(t.currentTime.getFullYear(),a+1,0).getDate(),t.currentTime.getDate())),t.currentTime.setMonth(a),C.onChangeMonth&&e.isFunction(C.onChangeMonth)&&C.onChangeMonth.call(j,Y.currentTime,j.data("input")),j.trigger("xchange.xdsoft"),a},t.getWeekOfYear=
//# sourceMappingURL=jquery.datetimepicker.min.js.map