/*! * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2015 * @version 1.3.3 * * 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 _compare,_lpad,_extend,defaultSettings,DAY,HOUR;DAY=1000*60*60*24;HOUR=3600;_compare=function(str1,str2){return typeof(str1)==='string'&&typeof(str2)==='string'&&str1.toLowerCase()===str2.toLowerCase();};_lpad=function(value,length,char){var chr=char||'0',val=value.toString();return val.length-1){out.month=vMonth+1;} vMonth=vSettings.months.indexOf(vDatePart);if(vMonth>-1){out.month=vMonth+1;}}else{if(iDatePart>=1&&iDatePart<=12){out.month=iDatePart;}} vDateFlag=true;break;case'd':case'j':if(iDatePart>=1&&iDatePart<=31){out.day=iDatePart;} vDateFlag=true;break;case'g':case'h':vMeriIndex=(vFormatParts.indexOf('a')>-1)?vFormatParts.indexOf('a'):(vFormatParts.indexOf('A')>-1)?vFormatParts.indexOf('A'):-1;mer=vDateParts[vMeriIndex];if(vMeriIndex>-1){vMeriOffset=_compare(mer,vSettings.meridiem[0])?0:(_compare(mer,vSettings.meridiem[1])?12:-1);if(iDatePart>=1&&iDatePart<=12&&vMeriOffset>-1){out.hour=iDatePart+vMeriOffset;}else if(iDatePart>=0&&iDatePart<=23){out.hour=iDatePart;}}else if(iDatePart>=0&&iDatePart<=23){out.hour=iDatePart;} vTimeFlag=true;break;case'G':case'H':if(iDatePart>=0&&iDatePart<=23){out.hour=iDatePart;} vTimeFlag=true;break;case'i':if(iDatePart>=0&&iDatePart<=59){out.min=iDatePart;} vTimeFlag=true;break;case's':if(iDatePart>=0&&iDatePart<=59){out.sec=iDatePart;} vTimeFlag=true;break;}} if(vDateFlag===true&&out.year&&out.month&&out.day){out.date=new Date(out.year,out.month-1,out.day,out.hour,out.min,out.sec,0);}else{if(vTimeFlag!==true){return false;} out.date=new Date(0,0,0,out.hour,out.min,out.sec,0);} return out.date;},guessDate:function(vDateStr,vFormat){if(typeof vDateStr!=='string'){return vDateStr;} var self=this,vParts=vDateStr.replace(self.separators,'\0').split('\0'),vPattern=/^[djmn]/g,vFormatParts=vFormat.match(self.validParts),vDate=new Date(),vDigit=0,vYear,i,iPart,iSec;if(!vPattern.test(vFormatParts[0])){return vDateStr;} for(i=0;i0){vParts.splice(i+1,0,iPart.substr(vDigit));}} return vDate;},parseFormat:function(vChar,vDate){var self=this,vSettings=self.dateSettings,fmt,backspace=/\\?(.?)/gi,doFormat=function(t,s){return fmt[t]?fmt[t]():s;};fmt={d:function(){return _lpad(fmt.j(),2);},D:function(){return vSettings.daysShort[fmt.w()];},j:function(){return vDate.getDate();},l:function(){return vSettings.days[fmt.w()];},N:function(){return fmt.w()||7;},w:function(){return vDate.getDay();},z:function(){var a=new Date(fmt.Y(),fmt.n()-1,fmt.j()),b=new Date(fmt.Y(),0,1);return Math.round((a-b)/DAY);},W:function(){var a=new Date(fmt.Y(),fmt.n()-1,fmt.j()-fmt.N()+3),b=new Date(a.getFullYear(),0,4);return _lpad(1+Math.round((a-b)/DAY/7),2);},F:function(){return vSettings.months[vDate.getMonth()];},m:function(){return _lpad(fmt.n(),2);},M:function(){return vSettings.monthsShort[vDate.getMonth()];},n:function(){return vDate.getMonth()+1;},t:function(){return(new Date(fmt.Y(),fmt.n(),0)).getDate();},L:function(){var Y=fmt.Y();return(Y%4===0&&Y%100!==0||Y%400===0)?1:0;},o:function(){var n=fmt.n(),W=fmt.W(),Y=fmt.Y();return Y+(n===12&&W<9?1:n===1&&W>9?-1:0);},Y:function(){return vDate.getFullYear();},y:function(){return fmt.Y().toString().slice(-2);},a:function(){return fmt.A().toLowerCase();},A:function(){var n=fmt.G()<12?0:1;return vSettings.meridiem[n];},B:function(){var H=vDate.getUTCHours()*HOUR,i=vDate.getUTCMinutes()*60,s=vDate.getUTCSeconds();return _lpad(Math.floor((H+i+s+HOUR)/86.4)%1000,3);},g:function(){return fmt.G()%12||12;},G:function(){return vDate.getHours();},h:function(){return _lpad(fmt.g(),2);},H:function(){return _lpad(fmt.G(),2);},i:function(){return _lpad(vDate.getMinutes(),2);},s:function(){return _lpad(vDate.getSeconds(),2);},u:function(){return _lpad(vDate.getMilliseconds()*1000,6);},e:function(){var str=/\((.*)\)/.exec(String(vDate))[1];return str||'Coordinated Universal Time';},T:function(){var str=(String(vDate).match(self.tzParts)||[""]).pop().replace(self.tzClip,"");return str||'UTC';},I:function(){var a=new Date(fmt.Y(),0),c=Date.UTC(fmt.Y(),0),b=new Date(fmt.Y(),6),d=Date.UTC(fmt.Y(),6);return((a-c)!==(b-d))?1:0;},O:function(){var tzo=vDate.getTimezoneOffset(),a=Math.abs(tzo);return(tzo>0?'-':'+')+_lpad(Math.floor(a/60)*100+a%60,4);},P:function(){var O=fmt.O();return(O.substr(0,3)+':'+O.substr(3,2));},Z:function(){return-vDate.getTimezoneOffset()*60;},c:function(){return'Y-m-d\\TH:i:sP'.replace(backspace,doFormat);},r:function(){return'D, d M Y H:i:s O'.replace(backspace,doFormat);},U:function(){return vDate.getTime()/1000||0;}};return doFormat(vChar,vChar);},formatDate:function(vDate,vFormat){var self=this,i,n,len,str,vChar,vDateStr='';if(typeof vDate==='string'){vDate=self.parseDate(vDate,vFormat);if(vDate===false){return false;}} if(vDate instanceof Date){len=vFormat.length;for(i=0;i');scroller=$('
');scrollbar.append(scroller);timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);calcOffset=function calcOffset(event){var offset=pointerEventToXY(event).y-startY+startTopScroll;if(offset<0){offset=0;} if(offset+scroller[0].offsetHeight>h1){offset=h1-scroller[0].offsetHeight;} timeboxparent.trigger('scroll_element.xdsoft_scroller',[maximumOffset?offset/maximumOffset:0]);};scroller.on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller',function(event){if(!parentHeight){timeboxparent.trigger('resize_scroll.xdsoft_scroller',[percent]);} startY=pointerEventToXY(event).y;startTopScroll=parseInt(scroller.css('margin-top'),10);h1=scrollbar[0].offsetHeight;if(event.type==='mousedown'||event.type==='touchstart'){if(document){$(document.body).addClass('xdsoft_noselect');} $([document.body,window]).on('touchend mouseup.xdsoft_scroller',function arguments_callee(){$([document.body,window]).off('touchend mouseup.xdsoft_scroller',arguments_callee).off('mousemove.xdsoft_scroller',calcOffset).removeClass('xdsoft_noselect');});$(document.body).on('mousemove.xdsoft_scroller',calcOffset);}else{touchStart=true;event.stopPropagation();event.preventDefault();}}).on('touchmove',function(event){if(touchStart){event.preventDefault();calcOffset(event);}}).on('touchend touchcancel',function(){touchStart=false;startTopScroll=0;});timeboxparent.on('scroll_element.xdsoft_scroller',function(event,percentage){if(!parentHeight){timeboxparent.trigger('resize_scroll.xdsoft_scroller',[percentage,true]);} percentage=percentage>1?1:(percentage<0||isNaN(percentage))?0:percentage;scroller.css('margin-top',maximumOffset*percentage);setTimeout(function(){timebox.css('marginTop',-parseInt((timebox[0].offsetHeight-parentHeight)*percentage,10));},10);}).on('resize_scroll.xdsoft_scroller',function(event,percentage,noTriggerScroll){var percent,sh;parentHeight=timeboxparent[0].clientHeight;height=timebox[0].offsetHeight;percent=parentHeight/height;sh=percent*scrollbar[0].offsetHeight;if(percent>1){scroller.hide();}else{scroller.show();scroller.css('height',parseInt(sh>10?sh:10,10));maximumOffset=scrollbar[0].offsetHeight-scroller[0].offsetHeight;if(noTriggerScroll!==true){timeboxparent.trigger('scroll_element.xdsoft_scroller',[percentage||Math.abs(parseInt(timebox.css('marginTop'),10))/(height-parentHeight)]);}}});timeboxparent.on('mousewheel',function(event){var top=Math.abs(parseInt(timebox.css('marginTop'),10));top=top-(event.deltaY*20);if(top<0){top=0;} timeboxparent.trigger('scroll_element.xdsoft_scroller',[top/(height-parentHeight)]);event.stopPropagation();return false;});timeboxparent.on('touchstart',function(event){start=pointerEventToXY(event);startTop=Math.abs(parseInt(timebox.css('marginTop'),10));});timeboxparent.on('touchmove',function(event){if(start){event.preventDefault();var coord=pointerEventToXY(event);timeboxparent.trigger('scroll_element.xdsoft_scroller',[(startTop-(coord.y-start.y))/(height-parentHeight)]);}});timeboxparent.on('touchend touchcancel',function(){start=false;startTop=0;});} timeboxparent.trigger('resize_scroll.xdsoft_scroller',[percent]);});};$.fn.xdsoft_datetimepicker=function(opt,opt2){var result=this,KEY0=48,KEY9=57,_KEY0=96,_KEY9=105,CTRLKEY=17,DEL=46,ENTER=13,ESC=27,BACKSPACE=8,ARROWLEFT=37,ARROWUP=38,ARROWRIGHT=39,ARROWDOWN=40,TAB=9,F5=116,AKEY=65,CKEY=67,VKEY=86,ZKEY=90,YKEY=89,ctrlDown=false,options=($.isPlainObject(opt)||!opt)?$.extend(true,{},default_options,opt):$.extend(true,{},default_options),lazyInitTimer=0,createDateTimePicker,destroyDateTimePicker,lazyInit=function(input){input.on('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart',function initOnActionCallback(){if(input.is(':disabled')||input.data('xdsoft_datetimepicker')){return;} clearTimeout(lazyInitTimer);lazyInitTimer=setTimeout(function(){if(!input.data('xdsoft_datetimepicker')){createDateTimePicker(input);} input.off('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart',initOnActionCallback).trigger('open.xdsoft');},100);});};createDateTimePicker=function(input){var datetimepicker=$('
'),xdsoft_copyright=$(''),datepicker=$('
'),month_picker=$('
'+'
'+'
'+'
'),calendar=$('
'),timepicker=$('
'),timeboxparent=timepicker.find('.xdsoft_time_box').eq(0),timebox=$('
'),applyButton=$(''),monthselect=$('
'),yearselect=$('
'),triggerAfterOpen=false,XDSoft_datetime,xchangeTimer,timerclick,current_time_index,setPos,timer=0,_xdsoft_datetime,forEachAncestorOf,throttle;if(options.id){datetimepicker.attr('id',options.id);} if(options.style){datetimepicker.attr('style',options.style);} if(options.weeks){datetimepicker.addClass('xdsoft_showweeks');} if(options.rtl){datetimepicker.addClass('xdsoft_rtl');} datetimepicker.addClass('xdsoft_'+options.theme);datetimepicker.addClass(options.className);month_picker.find('.xdsoft_month span').after(monthselect);month_picker.find('.xdsoft_year span').after(yearselect);month_picker.find('.xdsoft_month,.xdsoft_year').on('touchstart mousedown.xdsoft',function(event){var select=$(this).find('.xdsoft_select').eq(0),val=0,top=0,visible=select.is(':visible'),items,i;month_picker.find('.xdsoft_select').hide();if(_xdsoft_datetime.currentTime){val=_xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month')?'getMonth':'getFullYear']();} select[visible?'hide':'show']();for(items=select.find('div.xdsoft_option'),i=0;i=0&&splittedHours<24&&splittedMinutes>=0&&splittedMinutes<60){$(this).val([splittedHours,splittedMinutes].map(function(item){return item>9?item:'0'+item;}).join(':'));}else{$(this).val(dateHelper.formatDate(_xdsoft_datetime.now(),options.format));}} datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());} datetimepicker.trigger('changedatetime.xdsoft');datetimepicker.trigger('close.xdsoft');});} options.dayOfWeekStartPrev=(options.dayOfWeekStart===0)?6:options.dayOfWeekStart-1;datetimepicker.trigger('xchange.xdsoft').trigger('afterOpen.xdsoft');};datetimepicker.data('options',options).on('touchstart mousedown.xdsoft',function(event){event.stopPropagation();event.preventDefault();yearselect.hide();monthselect.hide();return false;});timeboxparent.append(timebox);timeboxparent.xdsoftScroller();datetimepicker.on('afterOpen.xdsoft',function(){timeboxparent.xdsoftScroller();});datetimepicker.append(datepicker).append(timepicker);if(options.withoutCopyright!==true){datetimepicker.append(xdsoft_copyright);} datepicker.append(month_picker).append(calendar).append(applyButton);$(options.parentID).append(datetimepicker);XDSoft_datetime=function(){var _this=this;_this.now=function(norecursion){var d=new Date(),date,time;if(!norecursion&&options.defaultDate){date=_this.strToDateTime(options.defaultDate);d.setFullYear(date.getFullYear());d.setMonth(date.getMonth());d.setDate(date.getDate());} if(options.yearOffset){d.setFullYear(d.getFullYear()+options.yearOffset);} if(!norecursion&&options.defaultTime){time=_this.strtotime(options.defaultTime);d.setHours(time.getHours());d.setMinutes(time.getMinutes());} return d;};_this.isValidDate=function(d){if(Object.prototype.toString.call(d)!=="[object Date]"){return false;} return!isNaN(d.getTime());};_this.setCurrentTime=function(dTime,requireValidDate){if(typeof dTime==='string'){_this.currentTime=_this.strToDateTime(dTime);} else if(_this.isValidDate(dTime)){_this.currentTime=dTime;} else if(!dTime&&!requireValidDate&&options.allowBlank){_this.currentTime=null;} else{_this.currentTime=_this.now();} datetimepicker.trigger('xchange.xdsoft');};_this.empty=function(){_this.currentTime=null;};_this.getCurrentTime=function(dTime){return _this.currentTime;};_this.nextMonth=function(){if(_this.currentTime===undefined||_this.currentTime===null){_this.currentTime=_this.now();} var month=_this.currentTime.getMonth()+1,year;if(month===12){_this.currentTime.setFullYear(_this.currentTime.getFullYear()+1);month=0;} year=_this.currentTime.getFullYear();_this.currentTime.setDate(Math.min(new Date(_this.currentTime.getFullYear(),month+1,0).getDate(),_this.currentTime.getDate()));_this.currentTime.setMonth(month);if(options.onChangeMonth&&$.isFunction(options.onChangeMonth)){options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));} if(year!==_this.currentTime.getFullYear()&&$.isFunction(options.onChangeYear)){options.onChangeYear.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));} datetimepicker.trigger('xchange.xdsoft');return month;};_this.prevMonth=function(){if(_this.currentTime===undefined||_this.currentTime===null){_this.currentTime=_this.now();} var month=_this.currentTime.getMonth()-1;if(month===-1){_this.currentTime.setFullYear(_this.currentTime.getFullYear()-1);month=11;} _this.currentTime.setDate(Math.min(new Date(_this.currentTime.getFullYear(),month+1,0).getDate(),_this.currentTime.getDate()));_this.currentTime.setMonth(month);if(options.onChangeMonth&&$.isFunction(options.onChangeMonth)){options.onChangeMonth.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'));} datetimepicker.trigger('xchange.xdsoft');return month;};_this.getWeekOfYear=function(datetime){if(options.onGetWeekOfYear&&$.isFunction(options.onGetWeekOfYear)){var week=options.onGetWeekOfYear.call(datetimepicker,datetime);if(typeof week!=='undefined'){return week;}} var onejan=new Date(datetime.getFullYear(),0,1);if(onejan.getDay()!=4) onejan.setMonth(0,1+((4-onejan.getDay()+7)%7));return Math.ceil((((datetime-onejan)/86400000)+onejan.getDay()+1)/7);};_this.strToDateTime=function(sDateTime){var tmpDate=[],timeOffset,currentTime;if(sDateTime&&sDateTime instanceof Date&&_this.isValidDate(sDateTime)){return sDateTime;} tmpDate=/^(\+|\-)(.*)$/.exec(sDateTime);if(tmpDate){tmpDate[2]=dateHelper.parseDate(tmpDate[2],options.formatDate);} if(tmpDate&&tmpDate[2]){timeOffset=tmpDate[2].getTime()-(tmpDate[2].getTimezoneOffset())*60000;currentTime=new Date((_this.now(true)).getTime()+parseInt(tmpDate[1]+'1',10)*timeOffset);}else{currentTime=sDateTime?dateHelper.parseDate(sDateTime,options.format):_this.now();} if(!_this.isValidDate(currentTime)){currentTime=_this.now();} return currentTime;};_this.strToDate=function(sDate){if(sDate&&sDate instanceof Date&&_this.isValidDate(sDate)){return sDate;} var currentTime=sDate?dateHelper.parseDate(sDate,options.formatDate):_this.now(true);if(!_this.isValidDate(currentTime)){currentTime=_this.now(true);} return currentTime;};_this.strtotime=function(sTime){if(sTime&&sTime instanceof Date&&_this.isValidDate(sTime)){return sTime;} var currentTime=sTime?dateHelper.parseDate(sTime,options.formatTime):_this.now(true);if(!_this.isValidDate(currentTime)){currentTime=_this.now(true);} return currentTime;};_this.str=function(){return dateHelper.formatDate(_this.currentTime,options.format);};_this.currentTime=this.now();};_xdsoft_datetime=new XDSoft_datetime();applyButton.on('touchend click',function(e){e.preventDefault();datetimepicker.data('changed',true);_xdsoft_datetime.setCurrentTime(getCurrentValue());input.val(_xdsoft_datetime.str());datetimepicker.trigger('close.xdsoft');});month_picker.find('.xdsoft_today_button').on('touchend mousedown.xdsoft',function(){datetimepicker.data('changed',true);_xdsoft_datetime.setCurrentTime(0,true);datetimepicker.trigger('afterOpen.xdsoft');}).on('dblclick.xdsoft',function(){var currentDate=_xdsoft_datetime.getCurrentTime(),minDate,maxDate;currentDate=new Date(currentDate.getFullYear(),currentDate.getMonth(),currentDate.getDate());minDate=_xdsoft_datetime.strToDate(options.minDate);minDate=new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());if(currentDatemaxDate){return;} input.val(_xdsoft_datetime.str());input.trigger('change');datetimepicker.trigger('close.xdsoft');});month_picker.find('.xdsoft_prev,.xdsoft_next').on('touchend mousedown.xdsoft',function(){var $this=$(this),timer=0,stop=false;(function arguments_callee1(v){if($this.hasClass(options.next)){_xdsoft_datetime.nextMonth();}else if($this.hasClass(options.prev)){_xdsoft_datetime.prevMonth();} if(options.monthChangeSpinner){if(!stop){timer=setTimeout(arguments_callee1,v||100);}}}(500));$([document.body,window]).on('touchend mouseup.xdsoft',function arguments_callee2(){clearTimeout(timer);stop=true;$([document.body,window]).off('touchend mouseup.xdsoft',arguments_callee2);});});timepicker.find('.xdsoft_prev,.xdsoft_next').on('touchend mousedown.xdsoft',function(){var $this=$(this),timer=0,stop=false,period=110;(function arguments_callee4(v){var pheight=timeboxparent[0].clientHeight,height=timebox[0].offsetHeight,top=Math.abs(parseInt(timebox.css('marginTop'),10));if($this.hasClass(options.next)&&(height-pheight)-options.timeHeightInTimePicker>=top){timebox.css('marginTop','-'+(top+options.timeHeightInTimePicker)+'px');}else if($this.hasClass(options.prev)&&top-options.timeHeightInTimePicker>=0){timebox.css('marginTop','-'+(top-options.timeHeightInTimePicker)+'px');} timeboxparent.trigger('scroll_element.xdsoft_scroller',[Math.abs(parseInt(timebox[0].style.marginTop,10)/(height-pheight))]);period=(period>10)?10:period-10;if(!stop){timer=setTimeout(arguments_callee4,v||period);}}(500));$([document.body,window]).on('touchend mouseup.xdsoft',function arguments_callee5(){clearTimeout(timer);stop=true;$([document.body,window]).off('touchend mouseup.xdsoft',arguments_callee5);});});xchangeTimer=0;datetimepicker.on('xchange.xdsoft',function(event){clearTimeout(xchangeTimer);xchangeTimer=setTimeout(function(){if(_xdsoft_datetime.currentTime===undefined||_xdsoft_datetime.currentTime===null){if(options.allowBlank) return;_xdsoft_datetime.currentTime=_xdsoft_datetime.now();} var table='',start=new Date(_xdsoft_datetime.currentTime.getFullYear(),_xdsoft_datetime.currentTime.getMonth(),1,12,0,0),i=0,j,today=_xdsoft_datetime.now(),maxDate=false,minDate=false,hDate,day,d,y,m,w,classes=[],customDateSettings,newRow=true,time='',h='',line_time,description;while(start.getDay()!==options.dayOfWeekStart){start.setDate(start.getDate()-1);} table+='';if(options.weeks){table+='';} for(j=0;j<7;j+=1){table+='';} table+='';table+='';if(options.maxDate!==false){maxDate=_xdsoft_datetime.strToDate(options.maxDate);maxDate=new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate(),23,59,59,999);} if(options.minDate!==false){minDate=_xdsoft_datetime.strToDate(options.minDate);minDate=new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());} while(i<_xdsoft_datetime.currentTime.countDaysInMonth()||start.getDay()!==options.dayOfWeekStart||_xdsoft_datetime.currentTime.getMonth()===start.getMonth()){classes=[];i+=1;day=start.getDay();d=start.getDate();y=start.getFullYear();m=start.getMonth();w=_xdsoft_datetime.getWeekOfYear(start);description='';classes.push('xdsoft_date');if(options.beforeShowDay&&$.isFunction(options.beforeShowDay.call)){customDateSettings=options.beforeShowDay.call(datetimepicker,start);}else{customDateSettings=null;} if(options.allowDateRe&&Object.prototype.toString.call(options.allowDateRe)==="[object RegExp]"){if(!options.allowDateRe.test(dateHelper.formatDate(start,options.formatDate))){classes.push('xdsoft_disabled');}}else if(options.allowDates&&options.allowDates.length>0){if(options.allowDates.indexOf(dateHelper.formatDate(start,options.formatDate))===-1){classes.push('xdsoft_disabled');}}else if((maxDate!==false&&start>maxDate)||(minDate!==false&&start'+w+'';}} table+='';if(start.getDay()===options.dayOfWeekStartPrev){table+='';newRow=true;} start.setDate(d+1);} table+='
'+options.i18n[globalLocale].dayOfWeekShort[(j+options.dayOfWeekStart)%7]+'
'+'
'+d+'
'+'
';calendar.html(table);month_picker.find('.xdsoft_label span').eq(0).text(options.i18n[globalLocale].months[_xdsoft_datetime.currentTime.getMonth()]);month_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());time='';h='';m='';line_time=function line_time(h,m){var now=_xdsoft_datetime.now(),optionDateTime,current_time,isALlowTimesInit=options.allowTimes&&$.isArray(options.allowTimes)&&options.allowTimes.length;now.setHours(h);h=parseInt(now.getHours(),10);now.setMinutes(m);m=parseInt(now.getMinutes(),10);optionDateTime=new Date(_xdsoft_datetime.currentTime);optionDateTime.setHours(h);optionDateTime.setMinutes(m);classes=[];if((options.minDateTime!==false&&options.minDateTime>optionDateTime)||(options.maxTime!==false&&_xdsoft_datetime.strtotime(options.maxTime).getTime()now.getTime())){classes.push('xdsoft_disabled');}else if((options.minDateTime!==false&&options.minDateTime>optionDateTime)||((options.disabledMinTime!==false&&now.getTime()>_xdsoft_datetime.strtotime(options.disabledMinTime).getTime())&&(options.disabledMaxTime!==false&&now.getTime()<_xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))){classes.push('xdsoft_disabled');}else if(input.is('[readonly]')){classes.push('xdsoft_disabled');} current_time=new Date(_xdsoft_datetime.currentTime);current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(),10));if(!isALlowTimesInit){current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes()/options.step)*options.step);} if((options.initTime||options.defaultSelect||datetimepicker.data('changed'))&¤t_time.getHours()===parseInt(h,10)&&((!isALlowTimesInit&&options.step>59)||current_time.getMinutes()===parseInt(m,10))){if(options.defaultSelect||datetimepicker.data('changed')){classes.push('xdsoft_current');}else if(options.initTime){classes.push('xdsoft_init_time');}} if(parseInt(today.getHours(),10)===parseInt(h,10)&&parseInt(today.getMinutes(),10)===parseInt(m,10)){classes.push('xdsoft_today');} time+='
'+dateHelper.formatDate(now,options.formatTime)+'
';};if(!options.allowTimes||!$.isArray(options.allowTimes)||!options.allowTimes.length){for(i=0,j=0;i<(options.hours12?12:24);i+=1){for(j=0;j<60;j+=options.step){h=(i<10?'0':'')+i;m=(j<10?'0':'')+j;line_time(h,m);}}}else{for(i=0;i'+i+'';} yearselect.children().eq(0).html(opt);for(i=parseInt(options.monthStart,10),opt='';i<=parseInt(options.monthEnd,10);i+=1){opt+='
'+options.i18n[globalLocale].months[i]+'
';} monthselect.children().eq(0).html(opt);$(datetimepicker).trigger('generate.xdsoft');},10);event.stopPropagation();}).on('afterOpen.xdsoft',function(){if(options.timepicker){var classType,pheight,height,top;if(timebox.find('.xdsoft_current').length){classType='.xdsoft_current';}else if(timebox.find('.xdsoft_init_time').length){classType='.xdsoft_init_time';} if(classType){pheight=timeboxparent[0].clientHeight;height=timebox[0].offsetHeight;top=timebox.find(classType).index()*options.timeHeightInTimePicker+1;if((height-pheight)1||(options.closeOnDateSelect===true||(options.closeOnDateSelect===false&&!options.timepicker)))&&!options.inline){datetimepicker.trigger('close.xdsoft');} setTimeout(function(){timerclick=0;},200);});timebox.on('touchmove','div',function(){currentlyScrollingTimeDiv=true;}).on('touchend click.xdsoft','div',function(xdevent){xdevent.stopPropagation();if(currentlyScrollingTimeDiv){currentlyScrollingTimeDiv=false;return;} var $this=$(this),currentTime=_xdsoft_datetime.currentTime;if(currentTime===undefined||currentTime===null){_xdsoft_datetime.currentTime=_xdsoft_datetime.now();currentTime=_xdsoft_datetime.currentTime;} if($this.hasClass('xdsoft_disabled')){return false;} currentTime.setHours($this.data('hour'));currentTime.setMinutes($this.data('minute'));datetimepicker.trigger('select.xdsoft',[currentTime]);datetimepicker.data('input').val(_xdsoft_datetime.str());if(options.onSelectTime&&$.isFunction(options.onSelectTime)){options.onSelectTime.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'),xdevent);} datetimepicker.data('changed',true);datetimepicker.trigger('xchange.xdsoft');datetimepicker.trigger('changedatetime.xdsoft');if(options.inline!==true&&options.closeOnTimeSelect===true){datetimepicker.trigger('close.xdsoft');}});datepicker.on('mousewheel.xdsoft',function(event){if(!options.scrollMonth){return true;} if(event.deltaY<0){_xdsoft_datetime.nextMonth();}else{_xdsoft_datetime.prevMonth();} return false;});input.on('mousewheel.xdsoft',function(event){if(!options.scrollInput){return true;} if(!options.datepicker&&options.timepicker){current_time_index=timebox.find('.xdsoft_current').length?timebox.find('.xdsoft_current').eq(0).index():0;if(current_time_index+event.deltaY>=0&¤t_time_index+event.deltaYwindowHeight+windowScrollTop){verticalAnchorEdge='bottom';verticalPosition=(windowHeight+windowScrollTop)-dateInputOffset.top;}else{verticalPosition-=windowScrollTop;}}else{if(verticalPosition+dateInputElem.offsetHeight>windowHeight+windowScrollTop){verticalPosition=dateInputOffset.top-dateInputElem.offsetHeight+1;}} if(verticalPosition<0){verticalPosition=0;} if(left+dateInputElem.offsetWidth>windowWidth){left=windowWidth-dateInputElem.offsetWidth;}} datetimepickerElem=datetimepicker[0];forEachAncestorOf(datetimepickerElem,function(ancestorNode){var ancestorNodePosition;ancestorNodePosition=window.getComputedStyle(ancestorNode).getPropertyValue('position');if(ancestorNodePosition==='relative'&&windowWidth>=ancestorNode.offsetWidth){left=left-((windowWidth-ancestorNode.offsetWidth)/2);return false;}});datetimepickerCss={position:position,left:left,top:'',bottom:''};datetimepickerCss[verticalAnchorEdge]=verticalPosition;datetimepicker.css(datetimepickerCss);};datetimepicker.on('open.xdsoft',function(event){var onShow=true;if(options.onShow&&$.isFunction(options.onShow)){onShow=options.onShow.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'),event);} if(onShow!==false){datetimepicker.show();setPos();$(window).off('resize.xdsoft',setPos).on('resize.xdsoft',setPos);if(options.closeOnWithoutClick){$([document.body,window]).on('touchstart mousedown.xdsoft',function arguments_callee6(){datetimepicker.trigger('close.xdsoft');$([document.body,window]).off('touchstart mousedown.xdsoft',arguments_callee6);});}}}).on('close.xdsoft',function(event){var onClose=true;month_picker.find('.xdsoft_month,.xdsoft_year').find('.xdsoft_select').hide();if(options.onClose&&$.isFunction(options.onClose)){onClose=options.onClose.call(datetimepicker,_xdsoft_datetime.currentTime,datetimepicker.data('input'),event);} if(onClose!==false&&!options.opened&&!options.inline){datetimepicker.hide();} event.stopPropagation();}).on('toggle.xdsoft',function(){if(datetimepicker.is(':visible')){datetimepicker.trigger('close.xdsoft');}else{datetimepicker.trigger('open.xdsoft');}}).data('input',input);timer=0;datetimepicker.data('xdsoft_datetime',_xdsoft_datetime);datetimepicker.setOptions(options);function getCurrentValue(){var ct=false,time;if(options.startDate){ct=_xdsoft_datetime.strToDate(options.startDate);}else{ct=options.value||((input&&input.val&&input.val())?input.val():'');if(ct){ct=_xdsoft_datetime.strToDateTime(ct);}else if(options.defaultDate){ct=_xdsoft_datetime.strToDateTime(options.defaultDate);if(options.defaultTime){time=_xdsoft_datetime.strtotime(options.defaultTime);ct.setHours(time.getHours());ct.setMinutes(time.getMinutes());}}} if(ct&&_xdsoft_datetime.isValidDate(ct)){datetimepicker.data('changed',true);}else{ct='';} return ct||0;} function setMask(options){var isValidValue=function(mask,value){var reg=mask.replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g,'\\$1').replace(/_/g,'{digit+}').replace(/([0-9]{1})/g,'{digit$1}').replace(/\{digit([0-9]{1})\}/g,'[0-$1_]{1}').replace(/\{digit[\+]\}/g,'[0-9_]{1}');return(new RegExp(reg)).test(value);},getCaretPos=function(input){try{if(document.selection&&document.selection.createRange){var range=document.selection.createRange();return range.getBookmark().charCodeAt(2)-2;} if(input.setSelectionRange){return input.selectionStart;}}catch(e){return 0;}},setCaretPos=function(node,pos){node=(typeof node==="string"||node instanceof String)?document.getElementById(node):node;if(!node){return false;} if(node.createTextRange){var textRange=node.createTextRange();textRange.collapse(true);textRange.moveEnd('character',pos);textRange.moveStart('character',pos);textRange.select();return true;} if(node.setSelectionRange){node.setSelectionRange(pos,pos);return true;} return false;};if(options.mask){input.off('keydown.xdsoft');} if(options.mask===true){if(typeof moment!='undefined'){options.mask=options.format.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');}else{options.mask=options.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');}} if($.type(options.mask)==='string'){if(!isValidValue(options.mask,input.val())){input.val(options.mask.replace(/[0-9]/g,'_'));setCaretPos(input[0],0);} input.on('keydown.xdsoft',function(event){var val=this.value,key=event.which,pos,digit;if(((key>=KEY0&&key<=KEY9)||(key>=_KEY0&&key<=_KEY9))||(key===BACKSPACE||key===DEL)){pos=getCaretPos(this);digit=(key!==BACKSPACE&&key!==DEL)?String.fromCharCode((_KEY0<=key&&key<=_KEY9)?key-KEY0:key):'_';if((key===BACKSPACE||key===DEL)&&pos){pos-=1;digit='_';} while(/[^0-9_]/.test(options.mask.substr(pos,1))&&pos0){pos+=(key===BACKSPACE||key===DEL)?-1:1;} val=val.substr(0,pos)+digit+val.substr(pos+1);if($.trim(val)===''){val=options.mask.replace(/[0-9]/g,'_');}else{if(pos===options.mask.length){event.preventDefault();return false;}} pos+=(key===BACKSPACE||key===DEL)?0:1;while(/[^0-9_]/.test(options.mask.substr(pos,1))&&pos0){pos+=(key===BACKSPACE||key===DEL)?-1:1;} if(isValidValue(options.mask,val)){this.value=val;setCaretPos(this,pos);}else if($.trim(val)===''){this.value=options.mask.replace(/[0-9]/g,'_');}else{input.trigger('error_input.xdsoft');}}else{if(([AKEY,CKEY,VKEY,ZKEY,YKEY].indexOf(key)!==-1&&ctrlDown)||[ESC,ARROWUP,ARROWDOWN,ARROWLEFT,ARROWRIGHT,F5,CTRLKEY,TAB,ENTER].indexOf(key)!==-1){return true;}} event.preventDefault();return false;});}} _xdsoft_datetime.setCurrentTime(getCurrentValue());input.data('xdsoft_datetimepicker',datetimepicker).on('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart',function(){if(input.is(':disabled')||(input.data('xdsoft_datetimepicker').is(':visible')&&options.closeOnInputClick)){return;} clearTimeout(timer);timer=setTimeout(function(){if(input.is(':disabled')){return;} triggerAfterOpen=true;_xdsoft_datetime.setCurrentTime(getCurrentValue(),true);if(options.mask){setMask(options);} datetimepicker.trigger('open.xdsoft');},100);}).on('keydown.xdsoft',function(event){var elementSelector,key=event.which;if([ENTER].indexOf(key)!==-1&&options.enterLikeTab){elementSelector=$("input:visible,textarea:visible,button:visible,a:visible");datetimepicker.trigger('close.xdsoft');elementSelector.eq(elementSelector.index(this)+1).focus();return false;} if([TAB].indexOf(key)!==-1){datetimepicker.trigger('close.xdsoft');return true;}}).on('blur.xdsoft',function(){datetimepicker.trigger('close.xdsoft');});};destroyDateTimePicker=function(input){var datetimepicker=input.data('xdsoft_datetimepicker');if(datetimepicker){datetimepicker.data('xdsoft_datetime',null);datetimepicker.remove();input.data('xdsoft_datetimepicker',null).off('.xdsoft');$(window).off('resize.xdsoft');$([window,document.body]).off('mousedown.xdsoft touchstart');if(input.unmousewheel){input.unmousewheel();}}};$(document).off('keydown.xdsoftctrl keyup.xdsoftctrl').on('keydown.xdsoftctrl',function(e){if(e.keyCode===CTRLKEY){ctrlDown=true;}}).on('keyup.xdsoftctrl',function(e){if(e.keyCode===CTRLKEY){ctrlDown=false;}});this.each(function(){var datetimepicker=$(this).data('xdsoft_datetimepicker'),$input;if(datetimepicker){if($.type(opt)==='string'){switch(opt){case'show':$(this).select().focus();datetimepicker.trigger('open.xdsoft');break;case'hide':datetimepicker.trigger('close.xdsoft');break;case'toggle':datetimepicker.trigger('toggle.xdsoft');break;case'destroy':destroyDateTimePicker($(this));break;case'reset':this.value=this.defaultValue;if(!this.value||!datetimepicker.data('xdsoft_datetime').isValidDate(dateHelper.parseDate(this.value,options.format))){datetimepicker.data('changed',false);} datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);break;case'validate':$input=datetimepicker.data('input');$input.trigger('blur.xdsoft');break;default:if(datetimepicker[opt]&&$.isFunction(datetimepicker[opt])){result=datetimepicker[opt](opt2);}}}else{datetimepicker.setOptions(opt);} return 0;} if($.type(opt)!=='string'){if(!options.lazyInit||options.open||options.inline){createDateTimePicker($(this));}else{lazyInit($(this));}}});return result;};$.fn.xdsoft_datetimepicker.defaults=default_options;function HighlightedDate(date,desc,style){"use strict";this.date=date;this.desc=desc;this.style=style;}})); /*! * jQuery Mousewheel 3.1.13 * * Copyright jQuery Foundation and other contributors * Released under the MIT license * http://jquery.org/license */ (function(factory){if(typeof define==='function'&&define.amd){define(['jquery'],factory);}else if(typeof exports==='object'){module.exports=factory;}else{factory(jQuery);}}(function($){var toFix=['wheel','mousewheel','DOMMouseScroll','MozMousePixelScroll'],toBind=('onwheel'in document||document.documentMode>=9)?['wheel']:['mousewheel','DomMouseScroll','MozMousePixelScroll'],slice=Array.prototype.slice,nullLowestDeltaTimeout,lowestDelta;if($.event.fixHooks){for(var i=toFix.length;i;){$.event.fixHooks[toFix[--i]]=$.event.mouseHooks;}} var special=$.event.special.mousewheel={version:'3.1.12',setup:function(){if(this.addEventListener){for(var i=toBind.length;i;){this.addEventListener(toBind[--i],handler,false);}}else{this.onmousewheel=handler;} $.data(this,'mousewheel-line-height',special.getLineHeight(this));$.data(this,'mousewheel-page-height',special.getPageHeight(this));},teardown:function(){if(this.removeEventListener){for(var i=toBind.length;i;){this.removeEventListener(toBind[--i],handler,false);}}else{this.onmousewheel=null;} $.removeData(this,'mousewheel-line-height');$.removeData(this,'mousewheel-page-height');},getLineHeight:function(elem){var $elem=$(elem),$parent=$elem['offsetParent'in $.fn?'offsetParent':'parent']();if(!$parent.length){$parent=$('body');} return parseInt($parent.css('fontSize'),10)||parseInt($elem.css('fontSize'),10)||16;},getPageHeight:function(elem){return $(elem).height();},settings:{adjustOldDeltas:true,normalizeOffset:true}};$.fn.extend({mousewheel:function(fn){return fn?this.bind('mousewheel',fn):this.trigger('mousewheel');},unmousewheel:function(fn){return this.unbind('mousewheel',fn);}});function handler(event){var orgEvent=event||window.event,args=slice.call(arguments,1),delta=0,deltaX=0,deltaY=0,absDelta=0,offsetX=0,offsetY=0;event=$.event.fix(orgEvent);event.type='mousewheel';if('detail'in orgEvent){deltaY=orgEvent.detail*-1;} if('wheelDelta'in orgEvent){deltaY=orgEvent.wheelDelta;} if('wheelDeltaY'in orgEvent){deltaY=orgEvent.wheelDeltaY;} if('wheelDeltaX'in orgEvent){deltaX=orgEvent.wheelDeltaX*-1;} if('axis'in orgEvent&&orgEvent.axis===orgEvent.HORIZONTAL_AXIS){deltaX=deltaY*-1;deltaY=0;} delta=deltaY===0?deltaX:deltaY;if('deltaY'in orgEvent){deltaY=orgEvent.deltaY*-1;delta=deltaY;} if('deltaX'in orgEvent){deltaX=orgEvent.deltaX;if(deltaY===0){delta=deltaX*-1;}} if(deltaY===0&&deltaX===0){return;} if(orgEvent.deltaMode===1){var lineHeight=$.data(this,'mousewheel-line-height');delta*=lineHeight;deltaY*=lineHeight;deltaX*=lineHeight;}else if(orgEvent.deltaMode===2){var pageHeight=$.data(this,'mousewheel-page-height');delta*=pageHeight;deltaY*=pageHeight;deltaX*=pageHeight;} absDelta=Math.max(Math.abs(deltaY),Math.abs(deltaX));if(!lowestDelta||absDelta=1?'floor':'ceil'](delta/lowestDelta);deltaX=Math[deltaX>=1?'floor':'ceil'](deltaX/lowestDelta);deltaY=Math[deltaY>=1?'floor':'ceil'](deltaY/lowestDelta);if(special.settings.normalizeOffset&&this.getBoundingClientRect){var boundingRect=this.getBoundingClientRect();offsetX=event.clientX-boundingRect.left;offsetY=event.clientY-boundingRect.top;} event.deltaX=deltaX;event.deltaY=deltaY;event.deltaFactor=lowestDelta;event.offsetX=offsetX;event.offsetY=offsetY;event.deltaMode=0;args.unshift(event,delta,deltaX,deltaY);if(nullLowestDeltaTimeout){clearTimeout(nullLowestDeltaTimeout);} nullLowestDeltaTimeout=setTimeout(nullLowestDelta,200);return($.event.dispatch||$.event.handle).apply(this,args);} function nullLowestDelta(){lowestDelta=null;} function shouldAdjustOldDeltas(orgEvent,absDelta){return special.settings.adjustOldDeltas&&orgEvent.type==='mousewheel'&&absDelta%120===0;}}));