32 lines
43 KiB
JavaScript
32 lines
43 KiB
JavaScript
|
/*!
|
||
|
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2016
|
||
|
* @version 1.3.4
|
||
|
*
|
||
|
* Date formatter utility library that allows formatting date/time variables or Date objects using PHP DateTime format.
|
||
|
* @see http://php.net/manual/en/function.date.php
|
||
|
*
|
||
|
* For more JQuery plugins visit http://plugins.krajee.com
|
||
|
* For more Yii related demos visit http://demos.krajee.com
|
||
|
*/
|
||
|
var DateFormatter;!function(){"use strict";var t,e,n,r,a;t=function(t,e){return"string"==typeof t&&"string"==typeof e&&t.toLowerCase()===e.toLowerCase()},e=function(t,n,r){var a=r||"0",u=t.toString();return u.length<n?e(a+u,n):u},n=function(t){var e,r;for(t=t||{},e=1;e<arguments.length;e++)if(r=arguments[e])for(var a in r)r.hasOwnProperty(a)&&("object"==typeof r[a]?n(t[a],r[a]):t[a]=r[a]);return t},r=function(t,e){for(var n=0;n<e.length;n++)if(e[n].toLowerCase()===t.toLowerCase())return n;return-1},a={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(t){var e=t%10,n={1:"st",2:"nd",3:"rd"};return 1!==Math.floor(t%100/10)&&n[e]?n[e]:"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(t){var e=this,r=n(a,t);e.dateSettings=r.dateSettings,e.separators=r.separators,e.validParts=r.validParts,e.intParts=r.intParts,e.tzParts=r.tzParts,e.tzClip=r.tzClip}).prototype={constructor:DateFormatter,getMonth:function(t){var e;return 0===(e=r(t,this.dateSettings.monthsShort)+1)&&(e=r(t,this.dateSettings.months)+1),e},parseDate:function(e,n){var r,a,u,i,s,o,c,f,l,h,d=this,g=!1,m=!1,p=d.dateSettings,y={date:null,year:null,month:null,day:null,hour:0,min:0,sec:0};if(!e)return null;if(e instanceof Date)return e;if("U"===n)return(u=parseInt(e))?new Date(1e3*u):e;switch(typeof e){case"number":return new Date(e);case"string":break;default:return null}if(!(r=n.match(d.validParts))||0===r.length)throw new Error("Invalid date format definition.");for(a=e.replace(d.separators,"\0").split("\0"),u=0;u<a.length;u++)switch(i=a[u],s=parseInt(i),r[u]){case"y":case"Y":if(!s)return null;l=i.length,y.year=2===l?parseInt((70>s?"20":"19")+i):s,g=!0;break;case"m":case"n":case"M":case"F":if(isNaN(s)){if(!((o=d.getMonth(i))>0))return null;y.month=o}else{if(!(s>=1&&12>=s))return null;y.month=s}g=!0;break;case"d":case"j":if(!(s>=1&&31>=s))return null;y.day=s,g=!0;break;case"g":case"h":if(h=a[c=r.indexOf("a")>-1?r.indexOf("a"):r.indexOf("A")>-1?r.indexOf("A"):-1],c>-1)f=t(h,p.meridiem[0])?0:t(h,p.meridiem[1])?12:-1,s>=1&&12>=s&&f>-1?y.hour=s+f-1:s>=0&&23>=s&&(y.hour=s);else{if(!(s>=0&&23>=s))return null;y.hour=s}m=!0;break;case"G":case"H":if(!(s>=0&&23>=s))return null;y.hour=s,m=!0;break;case"i":if(!(s>=0&&59>=s))return null;y.min=s,m=!0;break;case"s":if(!(s>=0&&59>=s))return null;y.sec=s,m=!0}if(!0===g&&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(!0!==m)return null;y.date=new Date(0,0,0,y.hour,y.min,y.sec,0)}return y.date},guessDate:function(t,e){if("string"!=typeof t)return t;var n,r,a,u,i,s,o=t.replace(this.separators,"\0").split("\0"),c=e.match(this.validParts),f=new Date,l=0;if(!/^[djmn]/g.test(c[0]))return t;for(a=0;a<o.length;a++){if(l=2,i=o[a],s=parseInt(i.substr(0,2)),isNaN(s))return null;switch(a){case 0:"m"===c[0]||"n"===c[0]?f.setMonth(s-1):f.setDate(s);break;case 1:"m"===c[0]||"n"===c[0]?f.setDate(s):f.setMonth(s-1);break;case 2:if(r=f.getFullYear(),l=4>(n=i.length)?n:4,!(r=parseInt(4>n?r.toString().substr(0,4-n)+i:i.substr(0,4))))return null;f.setFullYear(r);break;case 3:f.setHours(s);break;case 4:f.setMinutes(s);break;case 5:f.setSeconds(s)}(u=i.substr(l)).length>0&&o.splice(a+1,0,u)}return f},parseFormat:function(t,n){var r,a=this,u=a.dateSettings,i=/\\?(.?)/gi,s=function(t,e){return r[t]?r[t]():e};return r={d:function(){return e(r.j(),2)},D:function(){return u.daysShort[r.w()]},j:function(){return n.getDate()},l:function(){return u.days[r.w()]},N:function(){return r.w()||7},w:function(){return n.getDay()},z:function(){v
|
||
|
|
||
|
/**
|
||
|
* @preserve jQuery DateTimePicker
|
||
|
* @homepage http://xdsoft.net/jqplugins/datetimepicker/
|
||
|
* @author Chupurnov Valeriy (<chupurnov@gmail.com>)
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* @param {jQuery} $
|
||
|
*/
|
||
|
var datetimepickerFactory=function(e){"use strict";var t={i18n:{en:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],dayOfWeekShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayOfWeek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},fr:{months:["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"],dayOfWeekShort:["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],dayOfWeek:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]}},ownerDocument:document,contentWindow:window,value:"",rtl:!1,format:"Y/m/d H:i",formatTime:"H:i",formatDate:"Y/m/d",startDate:!1,step:60,monthChangeSpinner:!0,closeOnDateSelect:!1,closeOnTimeSelect:!0,closeOnWithoutClick:!0,closeOnInputClick:!0,openOnFocus:!0,timepicker:!0,datepicker:!0,weeks:!1,defaultTime:!1,defaultDate:!1,minDate:!1,maxDate:!1,minTime:!1,maxTime:!1,minDateTime:!1,maxDateTime:!1,allowTimes:[],opened:!1,initTime:!0,inline:!1,theme:"",touchMovedThreshold:5,onSelectDate:function(){},onSelectTime:function(){},onChangeMonth:function(){},onGetWeekOfYear:function(){},onChangeYear:function(){},onChangeDateTime:function(){},onShow:function(){},onClose:function(){},onGenerate:function(){},withoutCopyright:!0,inverseButton:!1,hours12:!1,next:"xdsoft_next",prev:"xdsoft_prev",dayOfWeekStart:0,parentID:"body",timeHeightInTimePicker:25,timepickerScrollbar:!0,todayButton:!0,prevButton:!0,nextButton:!0,defaultSelect:!0,scrollMonth:!0,scrollTime:!0,scrollInput:!0,lazyInit:!1,mask:!1,validateOnBlur:!0,allowBlank:!0,yearStart:1950,yearEnd:2050,monthStart:0,monthEnd:11,style:"",id:"",fixed:!1,roundTime:"round",className:"",weekends:[],highlightedDates:[],highlightedPeriods:[],allowDates:[],allowDateRe:null,disabledDates:[],disabledWeekDays:[],yearOffset:0,beforeShowDay:null,enterLikeTab:!0,showApplyButton:!1,insideParent:!1},o=null,n=null,a="en",i={meridiem:["AM","PM"]},r=function(){var r=t.i18n[a],s={days:r.dayOfWeek,daysShort:r.dayOfWeekShort,months:r.months,monthsShort:e.map(r.months,function(e){return e.substring(0,3)})};"function"==typeof DateFormatter&&(o=n=new DateFormatter({dateSettings:e.extend({},i,s)}))},s={moment:{default_options:{format:"YYYY/MM/DD HH:mm",formatDate:"YYYY/MM/DD",formatTime:"HH:mm"},formatter:{parseDate:function(e,t){if(l(t))return n.parseDate(e,t);var o=moment(e,t);return!!o.isValid()&&o.toDate()},formatDate:function(e,t){return l(t)?n.formatDate(e,t):moment(e).format(t)},formatMask:function(e){return e.replace(/Y{4}/g,"9999").replace(/Y{2}/g,"99").replace(/M{2}/g,"19").replace(/D{2}/g,"39").replace(/H{2}/g,"29").replace(/m{2}/g,"59").replace(/s{2}/g,"59")}}}};e.datetimepicker={setLocale:function(e){var o=t.i18n[e]?e:"en";a!==o&&(a=o,r())},setDateFormatter:function(n){if("string"==typeof n&&s.hasOwnProperty(n)){var a=s[n];e.extend(t,a.default_options),o=a.formatter}else o=n}};var d={RFC_2822:"D, d M Y H:i:s O",ATOM:"Y-m-dTH:i:sP",ISO_8601:"Y-m-dTH:i:sO",RFC_822:"D, d M y H:i:s O",RFC_850:"l, d-M-y H:i:s T",RFC_1036:"D, d M y H:i:s O",RFC_1123:"D, d M Y H:i:s O",RSS:"D, d M Y H:i:s O",W3C:"Y-m-dTH:i:sP"},l=function(e){return-1!==Object.values(d).indexOf(e)};function u(e,t,o){this.date=e,this.desc=t,this.style=o}e.extend(e.datetimepicker,d),r(),window.getComputedStyle||(window.getComputedStyle=function(e){return this.el=e,this.getPropertyValue=function(t){var o=/(-([a-z]))/g;return"float"===t&&(t="styleFloat"),o.test(t)&&(t=t.replace(o,function(e,t,o){return o.toUpperCase()})),e.currentStyle[t]||null},this}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e,t){var o,n;for(o=t||0,n=this.length;o<n;o+=1)if(this[o]===e)return o;return-1}),Date.prototype.countDaysInMonth=function(){return new Date(this.getFullYear(),this.getMonth()+1,0).getDate()},e.fn.xdsoftScroller=function(t,o){return this.each(function(){var n,a,i,r,s,d=e(this),l=function(e){var t,o={x:0,y:0};return"touchstart"===e.type||"touchmove"===e.type||"touchend"===e.type||"touchcancel"===e.type?(t=e.originalEvent.touches[0]||e.originalEvent.cha
|
||
|
|
||
|
/*!
|
||
|
* jQuery Mousewheel 3.1.13
|
||
|
*
|
||
|
* Copyright jQuery Foundation and other contributors
|
||
|
* Released under the MIT license
|
||
|
* http://jquery.org/license
|
||
|
*/
|
||
|
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e:e(jQuery)}(function(e){var t,i,n=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],o="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],l=Array.prototype.slice;if(e.event.fixHooks)for(var s=n.length;s;)e.event.fixHooks[n[--s]]=e.event.mouseHooks;var a=e.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var t=o.length;t;)this.addEventListener(o[--t],h,!1);else this.onmousewheel=h;e.data(this,"mousewheel-line-height",a.getLineHeight(this)),e.data(this,"mousewheel-page-height",a.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var t=o.length;t;)this.removeEventListener(o[--t],h,!1);else this.onmousewheel=null;e.removeData(this,"mousewheel-line-height"),e.removeData(this,"mousewheel-page-height")},getLineHeight:function(t){var i=e(t),n=i["offsetParent"in e.fn?"offsetParent":"parent"]();return n.length||(n=e("body")),parseInt(n.css("fontSize"),10)||parseInt(i.css("fontSize"),10)||16},getPageHeight:function(t){return e(t).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};function h(n){var o,s=n||window.event,h=l.call(arguments,1),f=0,d=0,c=0,m=0,g=0;if((n=e.event.fix(s)).type="mousewheel","detail"in s&&(c=-1*s.detail),"wheelDelta"in s&&(c=s.wheelDelta),"wheelDeltaY"in s&&(c=s.wheelDeltaY),"wheelDeltaX"in s&&(d=-1*s.wheelDeltaX),"axis"in s&&s.axis===s.HORIZONTAL_AXIS&&(d=-1*c,c=0),f=0===c?d:c,"deltaY"in s&&(f=c=-1*s.deltaY),"deltaX"in s&&(d=s.deltaX,0===c&&(f=-1*d)),0!==c||0!==d){if(1===s.deltaMode){var w=e.data(this,"mousewheel-line-height");f*=w,c*=w,d*=w}else if(2===s.deltaMode){var v=e.data(this,"mousewheel-page-height");f*=v,c*=v,d*=v}if(o=Math.max(Math.abs(c),Math.abs(d)),(!i||o<i)&&(i=o,u(s,o)&&(i/=40)),u(s,o)&&(f/=40,d/=40,c/=40),f=Math[f>=1?"floor":"ceil"](f/i),d=Math[d>=1?"floor":"ceil"](d/i),c=Math[c>=1?"floor":"ceil"](c/i),a.settings.normalizeOffset&&this.getBoundingClientRect){var p=this.getBoundingClientRect();m=n.clientX-p.left,g=n.clientY-p.top}return n.deltaX=d,n.deltaY=c,n.deltaFactor=i,n.offsetX=m,n.offsetY=g,n.deltaMode=0,h.unshift(n,f,d,c),t&&clearTimeout(t),t=setTimeout(r,200),(e.event.dispatch||e.event.handle).apply(this,h)}}function r(){i=null}function u(e,t){return a.settings.adjustOldDeltas&&"mousewheel"===e.type&&t%120==0}e.fn.extend({mousewheel:function(e){return e?this.bind("mousewheel",e):this.trigger("mousewheel")},unmousewheel:function(e){return this.unbind("mousewheel",e)}})});
|