Multi Calendar 2

goForward

method
MultiCalendar.prototype.goForward()

Moves the multi-calendar date forward by a day or by a week
depending on how many days are being shown.

goForward() {
  const startDate = this.startDate;
  const gapUnit = this.currViewMode.dateGapUnit;
  const newDate = DateHandler.add(startDate, 1, gapUnit);
  this.setStartDate(newDate);
}

goBack

method
MultiCalendar.prototype.goBack()

Moves the multi-calendar date back by a day or by a week
depending on how many days are being shown.

goBack() {
  const startDate = this.startDate;
  const gapUnit = this.currViewMode.dateGapUnit;
  const newDate = DateHandler.add(startDate, -1, gapUnit);
  this.setStartDate(newDate);
}

refresh

method
MultiCalendar.prototype.refresh()

Fetches data from the server for the current showing days and updates
the events.

refresh() {
  this._loadEvents();
}

showWeekends

method
MultiCalendar.prototype.showWeekends()

Option name Type Description
show Boolean
  • Whether to show the weekends or not.
return

Shows or hides Saturday and Sunday from the current calendar view.
If calendar is in mobile mode (oneDay view) it does nothing.

showWeekends(show) {
  if (this.currViewMode === viewModes.oneDay) { return; }
  const newView = show ? 'fullWeek' : 'weekdays';
  this._setViewMode(newView);
}

goToDate

method
MultiCalendar.prototype.goToDate()

Option name Type Description
date String, Date

[description]

controlBar ControlBar

[opitonal]

return

Moves all calendars to a view that shows the specified date.

goToDate(date, controlBar = this.controlBar) {
  if (DateHandler.isValid(date)) {
    this.setStartDate(date);
  } else {
    controlBar.setDate(this.date);
  }
}


// ====================================================
// ------------- End of Public interface --------------
// ====================================================

getDayCount

method
MultiCalendar.prototype.getDayCount()

Option name Type Description
calendars Array.<Calendar>
return Int
  • Amount of days being shown in each calendar. - If there are no calendars it returns 0.

Amount of days being shown in each calendar.

getDayCount(calendars = this.calendars) {
  if (calendars.length === 0) { return 0; }
  return calendars[0].getDayCount();
}

setStartDate

method
MultiCalendar.prototype.setStartDate()

Option name Type Description
date DateHandler, String
calendars Array.<Calendar>

[optional]

Sets the start date of all calendars and of the control bar.

setStartDate(date, calendars = this.calendars) {
  // This function may be called before a view mode is set. In this clase
  // the only acceptable start date is Today.
  let newDate;
  if (!this.currViewMode) {
    newDate = DateHandler.newDate();
  } else {
    const dateRange = this.currViewMode.dateRange;
    newDate = DateHandler.startOf(date, dateRange);
  }

  for (const cal of calendars) {
    cal.setStartDate(newDate);
  }

  this.startDate = newDate;
  const daysInCalendar = this.getDayCount();

  // Make sure endDate will never be negative.
  // even if there are 0 days in each calendar
  const daysToEnd = Math.max(daysInCalendar - 1, 0);
  this.endDate = DateHandler.addDays(newDate, daysToEnd);

  this.controlBar.setDate(newDate);
  this._loadEvents();
}