Skip to content

Commit

Permalink
Fix bug 1130144 - Save calendar view in localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
lcamacho committed Feb 9, 2015
1 parent db33e43 commit 3b37016
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions airmozilla/main/static/main/js/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $(function() {
var container = $('#calendar');
var startsOnMonday = $('#startsOnMonday');
var storage = localStorage.getItem('startsOnMonday');
var view = localStorage.getItem('view');
if (storage === null) {
// this is a hack to try to determine if week starts on Sunday or Monday
// right now if user is in America's TZ the week would start on Sunday
Expand All @@ -21,6 +22,7 @@ $(function() {
url: container.data('events-url'),
cache: true
},
defaultView: (view !== null)? view : 'month',
timezone: 'local',
weekends: true,
firstDay: startsOnMonday.prop('checked')? 1 : 0,
Expand All @@ -31,11 +33,15 @@ $(function() {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
eventAfterAllRender: function(view) {
localStorage.setItem('view', view.name);
}
});
};
startsOnMonday.on('change', function(){
localStorage.setItem('startsOnMonday', startsOnMonday.prop('checked')? 1 : 0);
view = container.fullCalendar('getView').name;
container.fullCalendar('destroy');
initCalendar();
});
Expand Down

0 comments on commit 3b37016

Please sign in to comment.