Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"use strict";
angular.module("Main").directive("activitycalendar", function () {
return {
link: function (scope, elm) {
var $el = angular.element(elm);
function refreshCalendar() {
var curCalView = $el.fullCalendar("getView");
var moment = null;
if ($el.children().length !== 0) {
moment = $el.fullCalendar("getDate");
}
$el.fullCalendar("destroy");
if (moment !== null) {
$el.fullCalendar("gotoDate", moment);
}
initCalendar(curCalView.name);
}
function initCalendar(setView) {
if (!setView) {
setView = "month";
}
$el.fullCalendar({
eventLimit: 3,
header: {
left: "",
center: "title",
right: "prev,next,month"
},
fixedWeekCount: false,
defaultView: "month",
selectable: true,
selectHelper: true,
buttonText: {
prev: "<",
next: ">"
},
events: scope.events,
eventClick: scope.eventClick,
timezone: "local",
eventRender: function (event, element) {
element.find(".fc-title").html("");
element.find(".fc-time").html("");
}
});
}
scope.$watch("events.length", function () {
refreshCalendar();
});
scope.$on("refreshCalendar", () => {
refreshCalendar();
});
initCalendar();
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.