tupali_fork/librerias/calendar/gcal.min.js
2017-10-16 13:51:40 -05:00

6 lines
3.1 KiB
JavaScript
Executable File

/*!
* FullCalendar v3.6.1 Google Calendar Plugin
* Docs & License: https://fullcalendar.io/
* (c) 2017 Adam Shaw
*/
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){function r(e){var r;return/^[^\/]+@([^\/\.]+\.)*(google|googlemail|gmail)\.com$/.test(e)?e:(r=/^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^\/]*)/.exec(e))||(r=/^https?:\/\/www.google.com\/calendar\/feeds\/([^\/]*)/.exec(e))?decodeURIComponent(r[1]):void 0}function t(e,r){return e.replace(/(\?.*?)?(#|$)/,function(e,t,a){return(t?t+"&":"?")+r+a})}var a=e.fullCalendar,n=a.Promise,o=a.EventSource,l=a.JsonFeedEventSource,i=a.EventSourceParser,s=a.applyAll,c=o.extend({googleCalendarApiKey:null,googleCalendarId:null,googleCalendarError:null,ajaxSettings:null,constructor:function(){o.apply(this,arguments),this.ajaxSettings={}},fetch:function(r,t,a){var o=this,i=this.buildUrl(),c=this.buildRequestParams(r,t,a),d=this.ajaxSettings,u=d.success;return c?n.construct(function(r,t){e.ajax(e.extend({},l.AJAX_DEFAULTS,d,{url:i,data:c,success:function(a){var n,l;a.error?(o.reportError("Google Calendar API: "+a.error.message,a.error.errors),t()):a.items&&(n=o.gcalItemsToRawEventDefs(a.items,c.timeZone),l=s(u,this,[n].concat(Array.prototype.slice.call(arguments,1))),e.isArray(l)&&(n=l),r(o.parseEventDefs(n)))}}))}):n.reject()},gcalItemsToRawEventDefs:function(e,r){var t=this;return e.map(function(e){return t.gcalItemToRawEventDef(e,r)})},gcalItemToRawEventDef:function(e,r){var a=e.htmlLink||null;return a&&r&&(a=t(a,"ctz="+r)),{id:e.id,title:e.summary,start:e.start.dateTime||e.start.date,end:e.end.dateTime||e.end.date,url:a,location:e.location,description:e.description}},buildUrl:function(){return c.API_BASE+"/"+encodeURIComponent(this.googleCalendarId)+"/events?callback=?"},buildRequestParams:function(r,t,a){var n,o=this.googleCalendarApiKey||this.calendar.opt("googleCalendarApiKey");return o?(r.hasZone()||(r=r.clone().utc().add(-1,"day")),t.hasZone()||(t=t.clone().utc().add(1,"day")),n=e.extend(this.ajaxSettings.data||{},{key:o,timeMin:r.format(),timeMax:t.format(),singleEvents:!0,maxResults:9999}),a&&"local"!==a&&(n.timeZone=a.replace(" ","_")),n):(this.reportError("Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/"),null)},reportError:function(e,r){var t=this.calendar,n=t.opt("googleCalendarError"),o=r||[{message:e}];this.googleCalendarError&&this.googleCalendarError.apply(t,o),n&&n.apply(t,o),a.warn.apply(null,[e].concat(r||[]))},getPrimitive:function(){return this.googleCalendarId},applyManualStandardProps:function(e){var t=o.prototype.applyManualStandardProps.apply(this,arguments),a=e.googleCalendarId;return null==a&&e.url&&(a=r(e.url)),null!=a&&(this.googleCalendarId=a,t)},applyMiscProps:function(r){e.extend(this.ajaxSettings,r)}});c.API_BASE="https://www.googleapis.com/calendar/v3/calendars",c.defineStandardProps({url:!1,googleCalendarId:!1,googleCalendarApiKey:!0,googleCalendarError:!0}),c.parse=function(e,r){var t;return"object"==typeof e?t=e:"string"==typeof e&&(t={url:e}),!!t&&o.parse.call(this,t,r)},i.registerClass(c),a.GcalEventSource=c});