From c4bfa6d4d842cfe58b94f2d16fba8e4256a1fa39 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Tue, 5 Apr 2016 10:01:54 +0200 Subject: [PATCH] Finish loading empty calendars. Fixes issue: #124 --- modules/default/calendar/README.md | 12 ++++++++++++ modules/default/calendar/calendar.js | 8 ++++++-- modules/default/calendar/node_helper.js | 4 ---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/default/calendar/README.md b/modules/default/calendar/README.md index cfe4e2b8..6854803a 100644 --- a/modules/default/calendar/README.md +++ b/modules/default/calendar/README.md @@ -112,6 +112,18 @@ The following properties can be configured: + + loadingText + Text to display while loading item.
+
Default value: 'Loading events …' + + + + emptyCalendarText + Text to display when there are no upcoming events.
+
Default value: ''No upcoming events.' + + diff --git a/modules/default/calendar/calendar.js b/modules/default/calendar/calendar.js index 84045944..3365ea00 100644 --- a/modules/default/calendar/calendar.js +++ b/modules/default/calendar/calendar.js @@ -28,7 +28,9 @@ Module.register('calendar',{ ], titleReplace: { 'De verjaardag van ' : '' - } + }, + loadingText: 'Loading events …', + emptyCalendarText: 'No upcoming events.' }, // Define required scripts. @@ -55,6 +57,7 @@ Module.register('calendar',{ } this.calendarData = {}; + this.loaded = false; }, // Override socket notification handler. @@ -62,6 +65,7 @@ Module.register('calendar',{ if (notification === 'CALENDAR_EVENTS') { if (this.hasCalendarURL(payload.url)) { this.calendarData[payload.url] = payload.events; + this.loaded = true; } } else if(notification === 'FETCH_ERROR') { Log.error('Calendar Error. Could not fetch calendar: ' + payload.url); @@ -82,7 +86,7 @@ Module.register('calendar',{ wrapper.className = "small"; if (events.length === 0) { - wrapper.innerHTML = "Loading events ..."; + wrapper.innerHTML = (this.loaded) ? this.config.emptyCalendarText : this.config.loadingText; wrapper.className = "small dimmed"; return wrapper; } diff --git a/modules/default/calendar/node_helper.js b/modules/default/calendar/node_helper.js index 7b6e3188..238bb84b 100644 --- a/modules/default/calendar/node_helper.js +++ b/modules/default/calendar/node_helper.js @@ -123,10 +123,6 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe * Broadcast the exsisting events. */ this.broadcastEvents = function() { - if (events.length <= 0) { - //console.log('No events to broadcast yet.'); - return; - } //console.log('Broadcasting ' + events.length + ' events.'); eventsReceivedCallback(self); };