Created
January 8, 2016 11:26
-
-
Save imrvelj/36e6e7d3f5d41c0bf15a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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