D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
travexx
/
www
/
assets
/
vendor
/
calendar
/
Filename :
calendar.min.js
back
Copy
!function(e){var t=new Date;t.setHours(0,0,0,0);var n,a,o={date:null,weekDayLength:1,prevButton:"Prev",nextButton:"Next",monthYearSeparator:" ",onClickDate:function(e){},onChangeMonth:function(e){},onClickToday:function(e){},onClickMonthNext:function(e){},onClickMonthPrev:function(e){},onClickYearNext:function(e){},onClickYearPrev:function(e){},onShowYearView:function(e){},onSelectYear:function(e){},customDateProps:function(e){return{classes:"",data:{}}},customDateHeaderProps:function(e){return{classes:"",data:{}}},customWeekProps:function(e){return{classes:"",data:{}}},showThreeMonthsInARow:!0,enableMonthChange:!0,enableYearView:!0,showTodayButton:!0,highlightSelectedWeekday:!0,highlightSelectedWeek:!0,todayButtonContent:"Today",showYearDropdown:!1,min:null,max:null,disable:function(e){},startOnMonday:!1,monthMap:{1:"january",2:"february",3:"march",4:"april",5:"may",6:"june",7:"july",8:"august",9:"september",10:"october",11:"november",12:"december"},dayMap:{0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"},alternateDayMap:{1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday",7:"sunday"}},r=!1;function s(e){return new Date(e.getFullYear(),e.getMonth()+1,0)}function i(e,t){var n,a,o,r,i,c=(a=(n=e).getMonth()+1+"/1/"+n.getFullYear(),new Date(a)),l=c.getDate(),d=s(e),u=(r=(o=e).getMonth(),i=o.getFullYear(),0===r&&(i-=1,r=12),new Date(i,r,0)).getDate(),h=[],f=c.getDay();settings.startOnMonday&&(f-=1);var y=1;if(1===t){var p=f-1<0?6+f:f-1;if(p<6)for(;p>=0;p--){var v=new Date(e.getFullYear(),e.getMonth()-1,u-p);h.push(v)}for(var g=7-h.length,m=0;m<g;m++){var v=new Date(c.getFullYear(),c.getMonth(),l+m);h.push(v)}}else for(var w=(t-(f<0?2:1))*7-f,b=1;b<=7;b++)if(w+b<=d){var v=new Date(e.getFullYear(),e.getMonth(),w+b);h.push(v)}else{var v=new Date(e.getFullYear(),e.getMonth()+1,y++);h.push(v)}return h}function c(o){var c,l,d,u,h,f,y,p=function e(t){for(var n=s(t).getDate(),a=s(t).getDate(),o=parseInt(n/7)+1,r=[],c=1;c<=o;c++)r.push(i(t,c));var l=r[r.length-1],d=l[l.length-1].getDate();return d<a&&a-d<7&&r.push(i(t,c)),r}(o);n.html((c=p,l=o,y="",(y+='<div class="calendar-box">',r)?(y+='<div class="months-container">',y+=function e(t){var n='<div class="buttons-container">'+(settings.enableMonthChange&&settings.enableYearView?'<button class="prev-button">'+settings.prevButton+"</button>":"")+'<span class="label-container year-label">';if(settings.showYearDropdown){n+='<select class="year-dropdown">';for(var a=1970;a<2117;a++)a===t.getFullYear()?n+='<option selected="selected" value="'+a+'">'+a+"</option>":n+='<option value="'+a+'">'+a+"</option>";n+="</select>"}else n+=t.getFullYear();return n+("</span>"+(settings.enableMonthChange&&settings.enableYearView?'<button class="next-button">'+settings.nextButton+"</button>":"")+"</div>")}(l),y+=function e(t){var n="";for(var a in n+='<div class="months-wrapper">',settings.monthMap)if(settings.monthMap.hasOwnProperty(a)){var o="";n+='<span class="month'+(o=settings.showThreeMonthsInARow?" one-third":"")+'" data-month="'+a+'" data-year="'+t.getFullYear()+'"><span>'+settings.monthMap[a]+"</span></span>"}return n+"</div>"}(l),y+="</div>"):(y+='<div class="weeks-container">',y+=(d=l,'<div class="buttons-container">'+(settings.enableMonthChange?'<button class="prev-button">'+settings.prevButton+"</button>":"")+'<span class="label-container month-container"><span class="month-label">'+settings.monthMap[d.getMonth()+1]+"</span>"+settings.monthYearSeparator+'<span class="year-label">'+d.getFullYear()+"</span></span>"+(settings.enableMonthChange?'<button class="next-button">'+settings.nextButton+"</button>":"")+"</div>"),y+=function e(t){let{classes:n,data:a}=settings.customWeekProps(0),o="";Object.keys(a)&&Object.keys(a).forEach(e=>{o+=` data-${e}="${a[e]}" `});var r="";for(var s in r+='<div class="weeks-wrapper header">',r+='<div class="week'+(settings.startOnMonday?" start-on-monday":"")+(n?" "+n:"")+'" data-week-no="0"'+o+">",settings.dayMap)if(settings.dayMap.hasOwnProperty(s)){let{classes:i,data:c}=settings.customDateHeaderProps(s),l="";Object.keys(c)&&Object.keys(c).forEach(e=>{l+=` data-${e}="${c[e]}" `}),r+='<div class="day header'+(i?" "+i:"")+'" data-day="'+s+'"'+l+" >"+("function"==typeof settings.formatWeekDay?settings.formatWeekDay(s):settings.dayMap[s].substring(0,settings.weekDayLength))+"</div>"}return r+="</div>",r+="</div>"}(l),y+=(u=c,h=l,f="",f+='<div class="weeks-wrapper">',u.forEach(function(e,n){let{classes:o,data:r}=settings.customWeekProps(n),s="";Object.keys(r)&&Object.keys(r).forEach(e=>{s+=` data-${e}="${r[e]}" `}),f+='<div class="week'+(settings.startOnMonday?" start-on-monday":"")+(o?" "+o:"")+'" data-week-no="'+(n+1)+'"'+s+">",e.forEach(function(e,n){var o=!1;e.getMonth()!==h.getMonth()&&(o=!0),o=o?" disabled":"";var r=!1;a?(e==a.toString()&&(r=!0),r=r?" selected":""):r="";var s=!1;e==t.toString()&&(s=!0),s=s?" today":"";var i="ola";(settings.min&&settings.min>e||settings.max&&settings.max<e||settings.disable&&"function"==typeof settings.disable&&settings.disable(e))&&(i='disabled="disabled" ');let{classes:c,data:l}=settings.customDateProps(e),d="";Object.keys(l)&&Object.keys(l).forEach(e=>{d+=` data-${e}="${l[e]}" `}),f+='<div class="day'+o+r+s+(c?" "+c:"")+'" data-date="'+e+'" '+d+i+" ><span>"+("function"==typeof settings.formatDate?settings.formatDate(e):e.getDate())+"</span></div>"}),f+="</div>"}),f+="</div>"),y+="</div>"),settings.showTodayButton&&(y+='<div class="special-buttons"><button class="today-button">'+settings.todayButtonContent+"</button></div>"),y+="</div>")),settings.highlightSelectedWeekday&&function t(){var a=n.find(".selected");if(a.length>0){var o=new Date(a.data("date")).getDay();n.find(".week").each(function(t,n){e(n).find(".day:eq("+(o-(settings.startOnMonday?1:0))+")").addClass("highlight")})}}(),settings.highlightSelectedWeek&&n.find(".selected").parents(".week").addClass("highlight")}e.fn.updateCalendarOptions=function(t){var n=e.extend(settings,t);e.fn.calendar.bind(this)(n)},e.fn.calendar=function(s){var i;return(settings=e.extend(o,s)).startOnMonday&&(settings.dayMap=settings.alternateDayMap),settings.min&&(settings.min=new Date(settings.min),settings.min.setHours(0),settings.min.setMinutes(0),settings.min.setSeconds(0)),settings.max&&(settings.max=new Date(settings.max),settings.max.setHours(0),settings.max.setMinutes(0),settings.max.setSeconds(0)),n=e(this),settings.date?((a="string"==typeof settings.date?new Date(settings.date):settings.date).setHours(0,0,0,0),i=a):i=t,window.currentDate=i,c(i),settings.enableMonthChange&&(n.off("click",".weeks-container .prev-button").on("click",".weeks-container .prev-button",function(e){i=new Date(i.getFullYear(),i.getMonth()-1,1),settings.onClickMonthPrev(i),c(i)}),n.off("click",".weeks-container .next-button").on("click",".weeks-container .next-button",function(e){i=new Date(i.getFullYear(),i.getMonth()+1,1),settings.onClickMonthNext(i),c(i)})),n.off("click",".day").on("click",".day",function(t){var n=e(this).data("date");"disabled"!==e(this).attr("disabled")&&settings.onClickDate(n)}),settings.enableMonthChange&&settings.enableYearView&&(n.off("click",".month-container").on("click",".month-container",function(e){r=!0,i=new Date(i.getFullYear(),0,1),settings.onShowYearView(i),c(i)}),n.off("click",".months-container .month").on("click",".months-container .month",function(t){var n=e(this),a=n.data("month"),o=n.data("year"),s=new Date(o,a-1,1);settings.onChangeMonth(s),r=!1,c(i=s)}),n.off("click",".months-container .prev-button").on("click",".months-container .prev-button",function(e){i=new Date(i.getFullYear()-1,0,1),settings.onClickYearPrev(i),settings.onSelectYear(i),c(i)}),n.off("click",".months-container .next-button").on("click",".months-container .next-button",function(e){i=new Date(i.getFullYear()+1,0,1),settings.onClickMonthNext(i),settings.onSelectYear(i),c(i)}),n.off("change",".months-container .year-dropdown").on("change",".months-container .year-dropdown",function(t){var n=e(this).val();i=new Date(n,0,1),settings.onSelectYear(i),c(i)})),settings.showTodayButton&&n.off("click",".today-button").on("click",".today-button",function(e){i=t,a=t,settings.onClickToday(t),settings.onClickDate(t),r=!1,c(i)}),this.getSelectedDate=function(){return a},this}}(jQuery);