diff options
author | Konstantin <vorobev@gmail.com> | 2017-02-24 07:38:08 +0900 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2017-02-23 17:38:08 -0500 |
commit | 437fc1b7d9d8a510342d16fc8f68fdb369e6ad8a (patch) | |
tree | 4468617b4c673882011ffae4c96f7b0a9a93d080 /assets/js | |
parent | 343e86a138648644870209708760c1e1f36805f7 (diff) |
Make link to calendar view bookable (#3063)
Diffstat (limited to 'assets/js')
-rw-r--r-- | assets/js/components/calendar.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/assets/js/components/calendar.js b/assets/js/components/calendar.js index d07c911d..ed6916b2 100644 --- a/assets/js/components/calendar.js +++ b/assets/js/components/calendar.js @@ -1,13 +1,23 @@ KB.component('calendar', function (containerElement, options) { + var modeMapping = { // Let's have bookable pretty mode names + month: 'month', + week: 'agendaWeek', + day: 'agendaDay' + }; this.render = function () { var calendar = $(containerElement); + var mode = 'month'; + if (window.location.hash) { // Check if hash contains mode + var hashMode = window.location.hash.substr(1); + mode = modeMapping[hashMode] || mode; + } calendar.fullCalendar({ locale: $("body").data("js-lang"), editable: true, eventLimit: true, - defaultView: "month", + defaultView: mode, header: { left: 'prev,next today', center: 'title', @@ -26,7 +36,14 @@ KB.component('calendar', function (containerElement, options) { }) }); }, - viewRender: function() { + viewRender: function(view) { + // Map view.name back and update location.hash + for (var id in modeMapping) { + if (modeMapping[id] === view.name) { // Found + window.location.hash = id; + break; + } + } var url = options.checkUrl; var params = { "start": calendar.fullCalendar('getView').start.format(), |