Add the legacy frontend themes, scripts, and plugin assets required by the main SPOTA interfaces.
3 lines
14 KiB
JavaScript
3 lines
14 KiB
JavaScript
/*! bootstrap-calendar 2013-08-29 */
|
|
https://github.com/Serhioromano/bootstrap-calendar.git
|
|
"use strict";Date.prototype.getWeek=function(){var t=new Date(this.getFullYear(),0,1);return Math.ceil(((this.getTime()-t.getTime())/864e5+t.getDay()+1)/7)},Date.prototype.getMonthFormatted=function(){var t=this.getMonth()+1;return 10>t?"0"+t:t},Date.prototype.getDateFormatted=function(){var t=this.getDate();return 10>t?"0"+t:t},String.prototype.format||(String.prototype.format=function(){var t=arguments;return this.replace(/{(\d+)}/g,function(e,s){return t[s]!==void 0?t[s]:e})}),function(t){function e(t,e){var s,a,i;i=t,s=0>t.indexOf("?")?"?":"&";for(a in e)i+=s+a+"="+encodeURIComponent(e[a]),s="&";return i}function s(e,s){return this.options=t.extend(!0,{},i,e),this.setLanguage(this.options.language),this.context=s,s.css("width",this.options.width),this.view(),this}function a(t){var e=t%19,s=Math.floor(t/100),a=t%100,i=Math.floor(s/4),o=s%4,n=Math.floor((s+8)/25),r=Math.floor((s-n+1)/3),h=(19*e+s-i-r+15)%30,d=Math.floor(a/4),p=a%4,l=(32+2*o+2*d-h-p)%7,c=Math.floor((e+11*h+22*l)/451),u=h+l+7*c+114,y=Math.floor(u/31)-1,g=u%31+1;return new Date(t,y,g,0,0,0)}var i={width:"100%",view:"month",day:"now",first_day:1,events_url:"",tmpl_path:"tmpls/",classes:{months:{inmonth:"cal-day-inmonth",outmonth:"cal-day-outmonth",saturday:"cal-day-weekend",sunday:"cal-day-weekend",holidays:"cal-day-holiday",today:"cal-day-today"},week:{workday:"cal-day-workday",saturday:"cal-day-weekend",sunday:"cal-day-weekend",holidays:"cal-day-holiday",today:"cal-day-today"}},enable_easter_holidays:!1,views:{year:{slide_events:1,enable:1},month:{slide_events:1,enable:1},week:{enable:1},day:{enable:1}},onAfterEventsLoad:function(){},onBeforeEventsLoad:function(t){t()},onAfterViewLoad:function(){},events:[],position:{start:new Date,end:new Date},templates:{year:"",month:"",week:"",day:""},stop_cycling:!1},o={error_noview:"Calendar: View {0} not found",error_dateformat:'Calendar: Wrong date format {0}. Should be either "now" or "yyyy-mm-dd"',error_loadurl:"Calendar: Events load URL is not set",error_where:'Calendar: Wrong navigation direction {0}. Can be only "next" or "prev" or "today"',title_year:"Year {0}",title_month:"{0} year {1}",title_week:"{0} week of year {1}",title_day:"{0} {1} {2} year {3}",week:"Week",m0:"January",m1:"February",m2:"March",m3:"April",m4:"May",m5:"June",m6:"July",m7:"August",m8:"September",m9:"October",m10:"November",m11:"December",ms0:"Jan",ms1:"Feb",ms2:"Mar",ms3:"Apr",ms4:"May",ms5:"Jun",ms6:"Jul",ms7:"Aug",ms8:"Sep",ms9:"Oct",ms10:"Nov",ms11:"Dec",d0:"Sunday",d1:"Monday",d2:"Tuesday",d3:"Wednesday",d4:"Thursday",d5:"Friday",d6:"Saturday",easter:"Easter",easterMonday:"Easter Monday"};s.prototype.setOptions=function(e){t.extend(this.options,e),"language"in e&&this.setLanguage(e.language)},s.prototype.setLanguage=function(e){window.calendar_languages&&e in window.calendar_languages?(this.strings=t.extend(!0,{},o,calendar_languages[e]),this.options.language=e):(this.strings=o,delete this.options.language)},s.prototype._render=function(){this.context.html(""),this._loadTemplate(this.options.view),this.stop_cycling=!1;var e={};e.events=[],e.cal=this,e.day=1,e.months=1==this.options.first_day?[this.strings.d1,this.strings.d2,this.strings.d3,this.strings.d4,this.strings.d5,this.strings.d6,this.strings.d0]:[this.strings.d0,this.strings.d1,this.strings.d2,this.strings.d3,this.strings.d4,this.strings.d5,this.strings.d6];var s=parseInt(this.options.position.start.getTime()),a=parseInt(this.options.position.end.getTime());switch(t.each(this.options.events,function(t,i){a>=parseInt(i.start)&&parseInt(i.end)>=s&&e.events.push(i)}),this.options.view){case"month":break;case"week":break;case"day":}e.start=new Date(this.options.position.start.getTime()),e.lang=this.strings,this.context.append(this.options.templates[this.options.view](e)),this._update()},s.prototype._week=function(){this._loadTemplate("week-days");var e={},s=parseInt(this.options.position.start.getTime()),a=parseInt(this.options.position.end.getTime()),i=[],o=this;return t.each(this.options.events,function(t,e){a>=parseInt(e.start)&&parseInt(e.end)>=s&&(e.start_day=new Date(parseInt(e.start)).getDay(),1==o.options.first_day&&(e.start_day=e.start_day-1),0>o.options.start_day&&(e.start_day=0),e.days=864e5>=e.end-e.start?1:(e.end-e.start)/864e5,s>e.start&&(e.days=e.days-(s-e.start)/864e5,e.start_day=0),e.days=Math.ceil(e.days),e.start_day+e.days>7&&(e.days=7-e.start_day),1==o.options.first_day,i.push(e))}),e.events=i,e.cal=this,o.options.templates["week-days"](e)},s.prototype._month=function(e){this._loadTemplate("year-month");var s={},a=e+1;s.data_day=this.options.position.start.getFullYear()+"-"+(10>a?"0"+a:a)+"-"+"01",s.month_name=this.strings["m"+e];var i=new Date(this.options.position.start.getFullYear(),e,1,0,0,0),o=parseInt(i.getTime()),n=parseInt(new Date(this.options.position.start.getFullYear(),e+1,0,0,0,0).getTime()),r=[];return t.each(this.options.events,function(t,e){n>=parseInt(e.start)&&parseInt(e.end)>=o&&r.push(e)}),s.events=r,this.options.templates["year-month"](s)},s.prototype._day=function(e,s){this._loadTemplate("month-day");var a={tooltip:""},i=this.options.classes.months.outmonth,o=this.options.position.start.getDay();2==this.options.first_day?o++:o=0==o?7:o,s=s-o+1;var n=new Date(this.options.position.start.getFullYear(),this.options.position.start.getMonth(),s,0,0,0);if(s>0&&(i=this.options.classes.months.inmonth),s+1>this.options.position.end.getDate()&&(this.stop_cycling=!0),s>this.options.position.end.getDate()&&(s-=this.options.position.end.getDate(),i=this.options.classes.months.outmonth),i=t.trim(i+" "+this._getDayClass("months",n)),0>=s){var r=new Date(this.options.position.start.getFullYear(),this.options.position.start.getMonth(),0).getDate();s=r-Math.abs(s),i+=" cal-month-first-row"}var h=this._getHoliday(n);h!==!1&&(a.tooltip=h),a.data_day=n.getFullYear()+"-"+n.getMonthFormatted()+"-"+(10>s?"0"+s:s),a.cls=i,a.day=s;var d=parseInt(n.getTime()),p=parseInt(d+864e5),l=[];return t.each(this.options.events,function(t,e){p>parseInt(e.start)&&parseInt(e.end)>d&&l.push(e)}),a.events=l,this.options.templates["month-day"](a)},s.prototype._getHoliday=function(t){if(this.options.enable_easter_holidays){var e=a(t.getFullYear());if(e.toDateString()==t.toDateString())return this.strings.easter;var s=new Date;if(s.setTime(e.getTime()),s.setDate(e.getDate()+1),s.toDateString()==t.toDateString())return this.strings.easterMonday}if(this.options.holidays){var i=t.getDateFormatted()+"-"+t.getMonthFormatted();if(i in this.options.holidays)return this.options.holidays[i];if(i+="-"+t.getFullYear(),i in this.options.holidays)return this.options.holidays[i]}return!1},s.prototype._getHolidayName=function(t){var e=this._getHoliday(t);return e===!1?"":e},s.prototype._getDayClass=function(t,e){var s=this,a=function(e,a){var i;i=s.options.classes&&t in s.options.classes&&e in s.options.classes[t]?s.options.classes[t][e]:"","string"==typeof i&&i.length&&a.push(i)},i=[];e.toDateString()==(new Date).toDateString()&&a("today",i);var o=this._getHoliday(e);switch(o!==!1&&a("holidays",i),e.getDay()){case 0:a("sunday",i);break;case 6:a("saturday",i)}return i.join(" ")},s.prototype.view=function(t){t&&(this.options.view=t),this._init_position(),this._loadEvents(),this._render(),this.options.onAfterViewLoad.call(this,this.options.view)},s.prototype.navigate=function(e,s){var a=t.extend({},this.options.position);if("next"==e)switch(this.options.view){case"year":a.start.setFullYear(this.options.position.start.getFullYear()+1);break;case"month":a.start.setMonth(this.options.position.start.getMonth()+1);break;case"week":a.start.setDate(this.options.position.start.getDate()+7);break;case"day":a.start.setDate(this.options.position.start.getDate()+1)}else if("prev"==e)switch(this.options.view){case"year":a.start.setFullYear(this.options.position.start.getFullYear()-1);break;case"month":a.start.setMonth(this.options.position.start.getMonth()-1);break;case"week":a.start.setDate(this.options.position.start.getDate()-7);break;case"day":a.start.setDate(this.options.position.start.getDate()-1)}else"today"==e?a.start.setTime((new Date).getTime()):t.error(this.strings.error_where.format(e));this.options.day=a.start.getFullYear()+"-"+a.start.getMonthFormatted()+"-"+a.start.getDateFormatted(),this.view(),_.isFunction(s)&&s()},s.prototype._init_position=function(){var e,s,a;if("now"==this.options.day){var i=new Date;e=i.getFullYear(),s=i.getMonth(),a=i.getDate()}else if(this.options.day.match(/^\d{4}-\d{2}-\d{2}$/g)){var o=this.options.day.split("-");e=o[0],s=o[1]-1,a=o[2]}else t.error(this.strings.error_dateformat.format(this.options.day));switch(this.options.view){case"year":this.options.position.start.setTime(new Date(e,0,1).getTime()),this.options.position.end.setTime(new Date(e,12,0,23,59,59).getTime());break;case"month":this.options.position.start.setTime(new Date(e,s,1).getTime()),this.options.position.end.setTime(new Date(e,s+1,0,23,59,59).getTime());break;case"day":this.options.position.start.setTime(new Date(e,s,a).getTime()),this.options.position.end.setTime(new Date(e,s,a,23,59,59).getTime());break;case"week":var n=new Date(e,s,a),r=n.getDate()-n.getDay();1==this.options.first_day&&(r+=1);var h=r+6;this.options.position.start.setTime(new Date(e,s,r).getTime()),this.options.position.end.setTime(new Date(e,s,h,23,59,59).getTime());break;default:t.error(this.strings.error_noview.format(this.options.view))}return this},s.prototype.getTitle=function(){var t=this.options.position.start;switch(this.options.view){case"year":return this.strings.title_year.format(t.getFullYear());case"month":return this.strings.title_month.format(this.strings["m"+t.getMonth()],t.getFullYear());case"week":return this.strings.title_week.format(t.getWeek(),t.getFullYear());case"day":return this.strings.title_day.format(this.strings["d"+t.getDay()],t.getDate(),this.strings["m"+t.getMonth()],t.getFullYear())}},s.prototype.isToday=function(){var t=(new Date).getTime();return t>this.options.position.start&&this.options.position.end>t},s.prototype.getStartDate=function(){return this.options.position.start},s.prototype.getEndDate=function(){return this.options.position.end},s.prototype._loadEvents=function(){this.options.events_url||t.error(this.strings.error_loadurl);var s=this;this.options.onBeforeEventsLoad.call(this,function(){t.ajax({url:e(s.options.events_url,{from:s.options.position.start.getTime(),to:s.options.position.end.getTime()}),dataType:"json",type:"GET",async:!1}).done(function(e){e.success||t.error(e.error),s.options.events=e.result||[],s.options.onAfterEventsLoad.call(s,e.result)})})},s.prototype._loadTemplate=function(e){if(!this.options.templates[e]){var s=this;t.ajax({url:this.options.tmpl_path+e+".html",dataType:"html",type:"GET",async:!1}).done(function(t){s.options.templates[e]=_.template(t)})}},s.prototype._update=function(){var e=this;t('*[rel="tooltip"]').tooltip(),t("*[data-cal-date]").click(function(){var s=t(this).data("cal-view");e.options.views[s].enable&&(e.options.day=t(this).data("cal-date"),e.view(s))}),t(".cal-cell").dblclick(function(){var s=t("[data-cal-date]",this).data("cal-view");e.options.views[s].enable&&(e.options.day=t("[data-cal-date]",this).data("cal-date"),e.view(s))}),this["_update_"+this.options.view]()},s.prototype._update_day=function(){},s.prototype._update_week=function(){},s.prototype._update_year=function(){this._update_month_year()},s.prototype._update_month=function(){this._update_month_year();var e=t(document.createElement("div")).attr("id","cal-week-box");e.html(this.strings.week);var s=this.options.position.start.getFullYear()+"-"+this.options.position.start.getMonthFormatted()+"-";t(".cal-month-box .cal-row-fluid").each(function(a,i){var o=t(i);o.bind("mouseenter",function(){var a=t(".cal-cell1:first-child .cal-month-day",o),i=a.hasClass("cal-month-first-row")?1:t("[data-cal-date]",a).text();i=10>i?"0"+i:i,e.attr("data-cal-week",s+i).show().appendTo(a)}).bind("mouseleave",function(){e.hide()})});var a=this;e.click(function(){a.options.day=t(this).data("cal-week"),a.view("week")}),t("a.event").mouseenter(function(){t("a.event"+t(this).data("event-id")).parents(".cal-cell1").addClass("day-highlight dh-"+t(this).data("event-class"))}),t("a.event").mouseleave(function(){t("div.cal-cell1").removeClass("day-highlight dh-"+t(this).data("event-class"))})},s.prototype._update_month_year=function(){if(this.options.views[this.options.view].slide_events){var e=0,s=this,a=t(document.createElement("div")).attr("id","cal-day-box").html('<i class="icon-chevron-down"></i>');t(".cal-month-day, .cal-year-box .span3").each(function(s,i){t(i).bind("mouseenter",function(){0!=t(".events-list",i).length&&t(i).children("[data-cal-date]").text()!=e&&a.show().appendTo(i)}),t(i).bind("mouseleave",function(){a.hide()})});var i=t(document.createElement("div")).attr("id","cal-slide-box");i.hide().click(function(t){t.stopPropagation()}),this._loadTemplate("events-list"),a.click(function(a){a.stopPropagation();var o=t(this),n=o.parents(".cal-cell"),r=o.parents(".cal-row-fluid"),h=n.data("cal-row");o.fadeOut("fast"),i.html(s.options.templates["events-list"]({events:t(".events-list a.event",n)})).slideUp("fast",function(){r.after(i),e=t("[data-cal-date]",n).text(),t("#cal-slide-tick").addClass("tick"+h).show(),i.slideDown("fast",function(){t("body").one("click",function(){i.slideUp("fast"),e=0})})}),t("a.event-item").mouseenter(function(){t("a.event"+t(this).data("event-id")).parents(".cal-cell1").addClass("day-highlight dh-"+t(this).data("event-class"))}),t("a.event-item").mouseleave(function(){t("div.cal-cell1").removeClass("day-highlight dh-"+t(this).data("event-class"))})})}},t.fn.calendar=function(t){return new s(t,this)}}(jQuery); |