Google Calendar Integration

Event data can be loaded from remote sources, like public google calendars. Through the integration plugin you can easily show events that are available in a public calendar. The integration plugin needs to be added to the download package or installed separately from a dedicated NPM package.

You will just need the CALENDAR_ID and an apiKey from google and you should be ready to roll.

Public calendars are read-only. If you are interested in syncing private google calendars with read/write/delete access, check out this example.

This example uses the integration plugin to connect to and load events from Google Calendar and it is not available in the trial. Give the live demo a try and see how it can be configured.
Get started with the scheduler

Demo

Loading the live demo

Preview in full screen

Load public Google Calendar events into a Scheduler — connect with your calendar ID and API key using the Google Calendar integration plugin.

Code

mobiscroll.setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
});

$(function () {
  var googleCalendarSync = mobiscroll.googleCalendarSync;
  var CALENDAR_ID = 'theacidmedia.net_8l6v679q5j2f7q8lpmcjr4mm3k@group.calendar.google.com';
  var $cont = $('#demo-google-cal');
  var view = 'week';
  var firstDay;
  var lastDay;
  var apiLoaded;

    googleCalendarSync.init({
      apiKey: '<YOUR_GOOGLE_API_KEY>',
      onInit: loadEvents,
    });

  function loadEvents() {
    apiLoaded = true;
    loadingEvents(true);
    googleCalendarSync
      .getEvents(CALENDAR_ID, firstDay, lastDay)
      .then(function (resp) {
        loadingEvents(false);
        calInst.setEvents(resp);
      })
      .catch(onError);
  }

  function loadingEvents(show) {
    if (show) {
      $cont.addClass('md-loading-events');
    } else {
      $cont.removeClass('md-loading-events');
    }
  }

  function onError(resp) {
    mobiscroll.toast({
      message: resp.error ? resp.error : resp.result.error.message,
    });
  }

  var calInst = $('#demo-google-cal')
    .mobiscroll()
    .eventcalendar({
      view: {
        scheduler: { type: 'week' },
      },
      exclusiveEndDates: true,
      onPageLoading: function (args) {
        var start = args.viewStart;
        var end = args.viewEnd;

        // Calculate dates
        // (pre-load events for previous and next pages as well)
        if (view == 'month') {
          firstDay = start;
          lastDay = end;
        } else {
          firstDay = new Date(start.getFullYear(), start.getMonth(), start.getDate() - 7);
          lastDay = new Date(end.getFullYear(), end.getMonth(), end.getDate() + 7);
        }

        if (apiLoaded) {
          loadEvents();
        }
      },
      renderHeader: function () {
        return (
          '<div mbsc-calendar-nav class="google-cal-header-nav"></div>' +
          '<div class="md-spinner">' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '<div class="md-spinner-blade"></div>' +
          '</div>' +
          '<div class="google-cal-header-picker">' +
          '<label>Month<input mbsc-segmented type="radio" name="google-calendar-view" value="month" class="md-google-calendar-view"></label>' +
          '<label>Week<input mbsc-segmented type="radio" name="google-calendar-view" value="week" class="md-google-calendar-view" checked></label>' +
          '<label>Day<input mbsc-segmented type="radio" name="google-calendar-view" value="day" class="md-google-calendar-view"></label>' +
          '<label>Agenda<input mbsc-segmented type="radio" name="google-calendar-view" value="agenda" class="md-google-calendar-view"></label>' +
          '</div>' +
          '<div mbsc-calendar-prev class="google-cal-header-prev"></div>' +
          '<div mbsc-calendar-today class="google-cal-header-today"></div>' +
          '<div mbsc-calendar-next class="google-cal-header-next"></div>'
        );
      },
    })
    .mobiscroll('getInst');

  $('.md-google-calendar-view').change(function (ev) {
    view = ev.target.value;
    switch (view) {
      case 'month':
        calInst.setOptions({
          view: {
            calendar: {
              labels: true,
            },
          },
        });
        break;
      case 'week':
        calInst.setOptions({
          view: {
            scheduler: { type: 'week' },
          },
        });
        break;
      case 'day':
        calInst.setOptions({
          view: {
            scheduler: { type: 'day' },
          },
        });
        break;
      case 'agenda':
        calInst.setOptions({
          view: {
            calendar: { type: 'week' },
            agenda: { type: 'week' },
          },
        });
        break;
    }
  });
});
  

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.