-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsCalendar.min.js
2 lines (1 loc) · 17.8 KB
/
jsCalendar.min.js
1
2
if(Response===void 0){var Response={};Response.Widgets={}}Response.Utilities=function(){var a=navigator.appVersion.indexOf("MSIE"),b={clientBrowserIsInternetExplorer:function(){return-1==a?!1:!0},getInternetExplorerVersion:function(b){if(a>-1){var c=navigator.appVersion.substr(a+5,3);if(c===b+".0")return!0}return!1},isOldIE:function(){if(b.clientBrowserIsInternetExplorer()){if(b.getInternetExplorerVersion(6))return!0;if(b.getInternetExplorerVersion(7))return!0}return!1}};return b}(),Response.Collections=function(){return{Dictionary:function(){var a={};return a.index=0,{add:function(b,c){return a.index+=1,this[b]=c},setValue:function(a,b){this[a]=b},getValue:function(a){return this[a]},remove:function(a){delete this[a]},exist:function(a){return this[a]?!0:!1},getIndex:function(){return a.index}}}}}(),Response.Collections.Cookie=function(){var a={deleteCookie:function(a){a+="=";var b=document.cookie,c=b.indexOf(a),d=b.indexOf(";",c)+1;document.cookie=b.substring(0,d)+" expires=Thu, 01-Jan-70 00:00:01 GMT;"+b.substring(d,b.length)}};return a}(),Response.Widgets.Window=function(){var a={};return a.windows=new Response.Collections.Dictionary,{getWindows:function(){return a.windows},Window:function(a,b,c,d,e){var f={};return f.element=document.createElement("div"),f.element.style.position="absolute",f.element.style.width=a,f.element.style.height=b,f.element.style.top=c,f.element.style.left=d,f.element.style.background="white",f.element.style.border="1px solid black",f.element.style.zIndex=100,f.element.id=e,{id:f.element.id,element:f.element,setHTML:function(a){f.element.innerHTML=a}}},CreateWindow:function(b,c,d,e,f,g){if(!a.windows.exist(g)){var h=new Response.Widgets.Window.Window(b,c,d,e,g);return h.setHTML(f),document.getElementById("body").appendChild(h.element),a.windows.add(h.id,h),h}return!1},DestroyWindow:function(b){b&&(a.windows.remove(b.id),b.parentNode.removeChild(b))},CreateTitleWindow:function(b){if(!a.windows.exist("response_title_window")){var c=new Response.Widgets.Window.Window("auto","auto","auto","auto","response_title_window");c.setHTML(b),c.element.style.padding="0.5em",document.getElementById("response_calendar_day_title").appendChild(c.element),a.windows.add(c.id,c)}return!1}}}(),Response.Widgets.Calendar=function(){return{CalendarObjectCounter:0,DateObject:function(){var a={setDateNumber:function(a){this.dateNumber=a},setMonthNumber:function(a){this.monthNumber=a},setThisMonth:function(a){this.thisMonth=a},getDateNumber:function(){return this.dateNumber},setFullDate:function(a){this.daysDate=a},setToday:function(a){this.todaysDate=a},setSelectedDate:function(a){this.selectedDate=a},isToday:function(){return this.todaysDate},isSelectedDate:function(){return this.selectedDate},getFullDate:function(){return this.daysDate},getMonthNumber:function(){return this.monthNumber},getThisMonth:function(){return this.thisMonth},getSelectedDate:function(){return this.selectedDate}};return a},Text:function(){var a=new Response.Collections.Dictionary;a.add("language","en"),a.add("January","January"),a.add("February","February"),a.add("March","March"),a.add("April","April"),a.add("May","May"),a.add("June","June"),a.add("July","July"),a.add("August","August"),a.add("September","September"),a.add("October","October"),a.add("November","November"),a.add("December","December"),a.add("Monday","Monday"),a.add("Tuesday","Tuesday"),a.add("Wednesday","Wednesday"),a.add("Thursday","Thursday"),a.add("Friday","Friday"),a.add("Saturday","Saturday"),a.add("Sunday","Sunday"),a.add("Week","Week"),a.add("Today","Today");var b=new Response.Collections.Dictionary;b.add("language","nn"),b.add("January","Januar"),b.add("February","Februar"),b.add("March","Mars"),b.add("April","April"),b.add("May","Mai"),b.add("June","Juni"),b.add("July","Juli"),b.add("August","August"),b.add("September","September"),b.add("October","Oktober"),b.add("November","November"),b.add("December","Desember"),b.add("Monday","Måndag"),b.add("Tuesday","Tysdag"),b.add("Wednesday","Onsdag"),b.add("Thursday","Torsdag"),b.add("Friday","Fredag"),b.add("Saturday","Laurdag"),b.add("Sunday","Sundag"),b.add("Week","Veke"),b.add("Today","Idag");var c=new Response.Collections.Dictionary;c.add("language","nb"),c.add("January","Januar"),c.add("February","Februar"),c.add("March","Mars"),c.add("April","April"),c.add("May","Mai"),c.add("June","Juni"),c.add("July","Juli"),c.add("August","August"),c.add("September","September"),c.add("October","Oktober"),c.add("November","November"),c.add("December","Desember"),c.add("Monday","Mandag"),c.add("Tuesday","Tirsdag"),c.add("Wednesday","Onsdag"),c.add("Thursday","Torsdag"),c.add("Friday","Fredag"),c.add("Saturday","Lørdag"),c.add("Sunday","Søndag"),c.add("Week","Uke"),c.add("Today","Idag");var d={currentLanguage:a,languages:[a,b,c]},e={setLanguage:function(a){for(var b=0;d.languages.length>b;b++)d.languages[b].getValue("language")===a&&(d.currentLanguage=d.languages[b])},getMonthText:function(a){var b=["January","February","March","April","May","June","July","August","September","October","November","December"];return d.currentLanguage.getValue(b[a])},getDayText:function(a){var b=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"];return d.currentLanguage.getValue(b[a])},getText:function(a){return d.currentLanguage.getValue(a)}};return e},CalendarObject:function(a,b,c,d,e,f,g){Response.Widgets.Calendar.CalendarObjectCounter+=1;var h={createCalendarMainElement:function(){var a=document.createElement("span");return a.id="ResponseCalendarMainElement"+h.calendarId,a.style.cssText=h.theme.getValue("CalendarMainElement"),a},createCalendarWeekAndDayRow:function(a){for(var b=a.insertRow(-1),c=h.getCalendarHeaderColumns(),d=0;c.length>d;d++){var e=b.insertCell(-1);e.innerHTML=c[d],e.style.cssText=h.theme.getValue("CalendarDayWeekCellSize")}b.style.cssText=h.theme.getValue("smallTextCell")+h.theme.getValue("TextAlignCenter")},createCalendarTableElement:function(){var a=document.createElement("table");return a.id="ResponseCalendarTable"+h.calendarId,a.style.cssText=h.theme.getValue("CalendarTable"),a},setNewDate:function(a){i.setCurrentDate(a),h.flushCalendar(),i.drawCalendar()},flushCalendar:function(){for(var a=h.calendarTableElement.rows.length;a>0;a--)h.calendarTableElement.deleteRow(a-1);h.calendarMainElement.removeChild(h.calendarHeaderElement),h.calendarMainElement.removeChild(h.calendarBottomElement)},getWeek:function(a,b,c){b+=1;var d=Math.floor((14-b)/12),e=a+4800-d,f=b+12*d-3,g=null;"gregorian"===h.type&&(g=c+Math.floor((153*f+2)/5)+365*e+Math.floor(e/4)-Math.floor(e/100)+Math.floor(e/400)-32045),"julian"===h.type&&(g=c+1+Math.Round((153*f+2)/5)+(365+e)+Math.round(e/4)-32083);var i=(g+31741-g%7)%146097%36524%1461,j=Math.floor(i/1460),k=(i-j)%365+j;return Math.floor(k/7)+1},getWeeks:function(a,b){for(var d=i.findLastDay(b,a),e=[],f=1;d>=f;f++){for(var g=h.getWeek(a,b,f),j=!1,k=0;e.length>=k;k++)if(g==e[k]){j=!0;break}j||e.push(g)}return 5>e.length&&(e.push(e[e.length-1]+1),e.push(e[e.length-1]+1)),6>e.length&&e.push(e[e.length-1]+1),e},findNumberOfDaysDifference:function(a,b){if(a>b){for(var c=-1;c>-50;c--)if(b.setDate(b.getDate()+1),b.getDate()==a.getDate())return c}else if(b>a)for(var c=1;50>c;c++)if(b.setDate(b.getDate()-1),b.getDate()==a.getDate())return c},setSelectedRow:function(a){var b=0;if(b=7*(a-h.currentWeek),h.getWeeks(h.currentYear,h.currentMonth,h.currentDay),b>100){for(var d=new Date(currentDate),e=0;6>e;e++){d.setDate(d.getDate()+7);var f=h.getWeek(d.getFullYear(),d.getMonth(),d.getDate());if(f==a){b=findNumberOfDaysDifference(currentDate,d);break}}d=new Date(currentDate);for(var e=0;6>e;e++){d.setDate(d.getDate()-7);var f=h.getWeek(d.getFullYear(),d.getMonth(),d.getDate());if(f==a){b=h.findNumberOfDaysDifference(currentDate,d);break}}}var g=new Date(h.currentDate.setDate(h.currentDate.getDate()+b));i.setCurrentDate(g)},getRealDay:function(a){if("gregorian"===h.type)var b=[6,0,1,2,3,4,5];else if("julian"===h.type)var b=[0,1,2,3,4,5,6];return b[a]},getLanguage:function(){var a=new Response.Widgets.Calendar.Text;return a.setLanguage(h.language),a},getCalendarHeaderColumns:function(){if("gregorian"===h.type){var a=3,b=h.language.getText("Week");if("small"===h.theme.getThemeSize()){var a=2;b=b.substring(0,1)}else if("large"===h.theme.getThemeSize())var a=9;return[b,h.language.getText("Monday").substring(0,a),h.language.getText("Tuesday").substring(0,a),h.language.getText("Wednesday").substring(0,a),h.language.getText("Thursday").substring(0,a),h.language.getText("Friday").substring(0,a),h.language.getText("Saturday").substring(0,a),h.language.getText("Sunday").substring(0,a)]}return"julian"===h.type?["week","sun","mon","tue","wed","thu","fri","sat"]:null},setCalendarHeader:function(a,b){var c=document.createElement("table"),d=c.insertRow(-1);d.style.cssText=h.theme.getValue("CalendarTable");var e=d.insertCell(-1),f=d.insertCell(-1),g=d.insertCell(-1),j=d.insertCell(-1),k=d.insertCell(-1);e.innerHTML="<button><<</button>",e.onclick=function(){return i.setPrevYear()},e.ondblclick=function(){return i.setPrevYear()},e.style.cssText=h.theme.getValue("NextPrevMonthButton"),f.innerHTML="<button><</button>",f.onclick=function(){return i.setPrevMonth()},f.ondblclick=function(){return i.setPrevMonth()},f.style.cssText=h.theme.getValue("NextPrevMonthButton"),g.colSpan="6",g.innerHTML=h.language.getMonthText(a)+" - "+b,j.innerHTML="<button>></button>",j.onclick=function(){return i.setNextMonth()},j.ondblclick=function(){return i.setNextMonth()},j.style.cssText=h.theme.getValue("NextPrevMonthButton"),k.innerHTML="<button>>></button>",k.onclick=function(){return i.setNextYear()},k.ondblclick=function(){return i.setNextYear()},k.style.cssText=h.theme.getValue("NextPrevMonthButton"),c.style.cssText=h.theme.getValue("CalendarHeaderTable"),h.calendarWeekAndDayElement?h.calendarMainElement.insertBefore(c,h.calendarWeekAndDayElement):h.calendarMainElement.insertBefore(c,null),h.calendarHeaderElement=c},type:c,language:"nb",theme:e,size:"normal",multiple:g,currentDate:null,currentDay:null,currentMonth:null,currentYear:null,currentWeek:null,selectedWeek:null,calendarTableElement:null,calendarMainElement:null,calendarHeaderElement:null,calendarBottomElement:null,todaysDate:(new Date).toDateString(),selectedDate:null,calendarId:null,theme:new Response.Widgets.Calendar.Themes.ThemeObject,inputElement:a,isRendered:!1},i={setCurrentDate:function(a){h.currentDate=a,h.currentYear=a.getFullYear(),h.currentMonth=a.getMonth(),h.currentDay=a.getDate(),h.currentWeek=h.getWeek(h.currentYear,h.currentMonth,h.currentDay)},drawCalendar:function(){h.selectedDate||(h.selectedDate=h.currentDate.toDateString()),document.body.appendChild(h.calendarMainElement);var a=h.currentDate.getFullYear(),b=h.currentDate.getMonth(),c=h.currentDate.getDate();""+h.getWeek(a,b,c),h.setCalendarHeader(b,a);var k,f=h.getCalendarHeaderColumns(),g=1,j=h.getWeeks(a,b,c);h.createCalendarWeekAndDayRow(h.calendarTableElement);for(var l=0;j.length>l;l++){var m=h.calendarTableElement.insertRow(-1);m.id="row_id_"+l,g>i.findLastDay(b,a)&&(b+=1,g=10>k?k+1:1);for(var n=i.findFirstDay(b,a,g),o=i.getDatesInWeek(n),p=0;f.length>p;p++){var q=m.insertCell(-1);q.className="calendarcells",q.id="cell_id_"+(""+l)+(""+p),0===p?q.style.cssText=h.theme.getValue("smallTextCell"):(q.onmouseover=function(){return i.litCell(this)},q.onmouseout=function(){return i.unlitCell(this)},q.onclick=function(){return i.selectDate(h.inputElement,this.innerHTML)},q.style.cssText=h.theme.getValue("CalendarDefaultBackgroundColor"));var r;0===p?(r=document.createTextNode(j[l]),q.className="week"):(r=document.createTextNode(o[p-1].getDateNumber()),k=o[p-1].getDateNumber(),o[p-1].getThisMonth()||(q.style.cssText=h.theme.getValue("LightGreyText"),q.onmouseover=function(){return null},q.onmouseout=function(){return null},q.onclick=function(){return null}),o[p-1].isToday()&&(q.style.cssText=h.theme.getValue("CalendarTodayColors"),q.className="Response-TodaysDate-Cell"),o[p-1].isSelectedDate()&&(q.style.cssText=h.theme.getValue("CalendarSelectedColors"),q.className="Response-SelectedDate-Cell")),q.appendChild(r)}g+=7}for(h.calendarBottomElement=document.createElement("table"),h.calendarBottomElement.style.cssText="width:100%;",m=h.calendarBottomElement.insertRow(-1),m.id="rcalendar_todaybutton",p=0;3>p;p++)q=m.insertCell(-1),q.className="rcalendar_todaybutton_cells",q.id="cell_todaybutton_id_"+p,1==p?(q.innerHTML="<button>"+h.language.getText("Today")+"</button>",q.style.cssText=h.theme.getValue("todaybutton"),q.onclick=function(){return h.setNewDate(new Date)}):q.style.cssText=h.theme.getValue("todaycell");h.calendarMainElement.appendChild(h.calendarBottomElement),h.calendarMainElement.appendChild(h.calendarTableElement)},findFirstDay:function(a,b,c){var d=new Date(b,a,c);return d},findLastDay:function(a,b){for(var c=new Date(b,a),d=28,e=!1;!e;){c.setDate(d+1);var f=c.getMonth();f!=a?e=!0:d++}return d},getDatesInWeek:function(a){for(var b=Array(7),c=h.getRealDay(a.getDay()),d=0,e=c;b.length>e;e++){var f=new Date(a);0!==d&&f.setDate(f.getDate()+d),b[e]=f,d++}for(var g=0,e=c;e>=0;e--){var f=new Date(a);f.setDate(f.getDate()+g),b[e]=f,g--}for(var i=Array(),j=0;7>j;j++){var k=new Response.Widgets.Calendar.DateObject;k.setFullDate(b[j].getFullYear()+"-"+(b[j].getMonth()+1)+"-"+b[j].getDate()),k.setDateNumber(b[j].getDate()),k.setMonthNumber(b[j].getMonth()),h.currentDate.getMonth()==b[j].getMonth()?k.setThisMonth(!0):k.setThisMonth(!1),h.todaysDate===b[j].toDateString()?k.setToday(!0):k.setToday(!1),h.selectedDate===b[j].toDateString()?k.setSelectedDate(!0):k.setSelectedDate(!1),i.push(k)}return i},setNextMonth:function(){var a=new Date(h.currentDate.setMonth(h.currentDate.getMonth()+1));h.setNewDate(a)},setPrevMonth:function(){var a=new Date(h.currentDate.setMonth(h.currentDate.getMonth()-1));h.setNewDate(a)},setNextYear:function(){var a=new Date(h.currentDate.setFullYear(h.currentDate.getFullYear()+1));h.setNewDate(a)},setPrevYear:function(){var a=new Date(h.currentDate.setFullYear(h.currentDate.getFullYear()-1));h.setNewDate(a)},litCell:function(a){a.style.cssText=h.theme.getValue("CalendarDefaultHighLightColor")},unlitCell:function(a){a.style.cssText="Response-TodaysDate-Cell"===a.className?h.theme.getValue("CalendarTodayColors"):"Response-SelectedDate-Cell"===a.className?h.theme.getValue("CalendarSelectedColors"):h.theme.getValue("CalendarDefaultBackgroundColor")},selectDate:function(a,b){var c=""+(h.currentMonth+1),d=""+b;1==c.length&&(c="0"+c),1==d.length&&(d="0"+d),a.value=h.currentYear+"-"+c+"-"+d,i.removeCalendar()},removeCalendar:function(){h.calendarMainElement.parentNode&&h.calendarMainElement.parentNode.removeChild(h.calendarMainElement)},isRendered:function(){return h.isRendered},setIsRendered:function(a){h.isRendered=a}};return h.calendarId=Response.Widgets.Calendar.CalendarObjectCounter,h.language=h.getLanguage(),b?i.setCurrentDate(b):i.setCurrentDate(new Date),h.type=c?c:"gregorian",e&&f?h.theme.setTheme(e,f,h.inputElement):h.theme.setTheme("default","normal",h.inputElement),h.calendarTableElement=h.createCalendarTableElement(),h.calendarMainElement=h.createCalendarMainElement(),i}}}(),Response.Widgets.Calendar.Themes=function(){return{ThemeObject:function(){var a=new Response.Collections.Dictionary,b=new Response.Collections.Dictionary,c={element:null,themes:[a,b],currentTheme:a,themeSize:"normal",createTheme:function(){var b=.6,d=30,e=16,f=32,g=24,h=274,i=24,j=4,k=1,l=.9;"small"===c.themeSize?(b=.7,d=23,e=10,f=28,g=12,h=220,i=12,j=4,k=.75,l=.7):"large"===c.themeSize&&(b=.8,d=76,e=32,f=32,g=36,h=644,i=24,j=8,k=1.2,l=1),a.add("name","default"),a.add("LightGreyText","color:#cccccc;"),a.add("todaybutton","width:50%;text-align: center;"),a.add("todaycell","width:25%;"),a.add("TableBorder","border:1px black solid;"),a.add("TextAlignCenter","text-align:center;"),a.add("smallTextCell","font-size:"+b+"em;"+"color:#333333;"+"width:32px;height:24px;"),a.add("CalendarDayWeekCellSize","width:"+d+"px;"+"height:"+e+"px;"),a.add("CalendarDefaultBackgroundColor","font-size:"+l+"em;"+"background:#FDFBFF;"+"border:1px solid #E6E6E6;"+"width:"+f+"px;"+"height:"+g+"px;"),a.add("CalendarDefaultHighLightColor","font-size:"+l+"em;"+"background:#C2C7E7;"+"border-radius:0.5em;"+"border:1px solid #888AA0;"+"cursor:pointer;"+"width:"+f+"px;"+"height:"+g+"px;"),a.add("CalendarTodayColors","font-size:"+l+"em;"+"background:#FFC2B5;"+"border-radius:0.5em;"+"border:1px solid #EF9584;"+"cursor:pointer;"+"width:"+f+"px;"+"height:"+g+"px;"),a.add("CalendarSelectedColors","font-size:"+l+"em;"+"background:#E2EAC2;"+"border-radius:0.5em;"+"border:1px solid #C3CC9E;"+"cursor:pointer;"+"width:"+f+"px;"+"height:"+g+"px;"),a.add("CalendarTable","font-size:"+k+"em;"+"width:"+h+"px;"+"text-align:center;"),a.add("CalendarHeaderTable","background:#C5DDEE;border:1px solid #53A2DA;width:"+h+"px;"+"text-align:center;"+"border-radius:0.5em;"+"color:#333333;"),a.add("NextPrevMonthButton","border-radius:0.5em;width:"+i+"px;"),a.add("CalendarMainElement","background:#F6F9FD;border:1px solid #E2E7ED;border-radius:0.5em;z-index:100;position:absolute;top:"+c.element.offsetTop+"px;"+"left:"+(c.element.offsetWidth+40)+"px;"+"padding:"+j+"px;"+"display:table;")}},d={setTheme:function(a,b,d){c.element=d,c.themeSize=b,c.createTheme();for(var e=0;c.themes.length>e;e++)c.themes[e].getValue("name")===a&&(c.currentTheme=c.themes[e])},getValue:function(a){return c.currentTheme.getValue(a)},getThemeSize:function(){return c.themeSize}};return d}}}(),Response.Widgets.Calendar.Events=function(){var a={calendar:null,show:!1,showCalendar:function(b){a.calendar&&a.calendar.removeCalendar(),a.calendar=new Response.Widgets.Calendar.CalendarObject(b.previousSibling);var c=null;if(""!==b.previousSibling.value){if(Response.Utilities.clientBrowserIsInternetExplorer()){var d=b.previousSibling.value.split("-");c=new Date(d[0],d[1]-1,d[2])}else c=new Date(b.previousSibling.value);a.calendar.setCurrentDate(c)}a.calendar.drawCalendar()},outsideClick:function(){a.calendar&&(a.calendar.isRendered()?(a.calendar.removeCalendar(),a.calendar=null):a.calendar.setIsRendered(!0))}};return a}();