Finish loading empty calendars. Fixes issue: #124

This commit is contained in:
Michael Teeuw 2016-04-05 10:01:54 +02:00
parent 700ebc53f8
commit c4bfa6d4d8
3 changed files with 18 additions and 6 deletions

View File

@ -112,6 +112,18 @@ The following properties can be configured:
</code>
</td>
</tr>
<tr>
<td><code>loadingText</code></td>
<td>Text to display while loading item.<br>
<br><b>Default value:</b> <code>'Loading events &hellip;'</code>
</td>
</tr>
<tr>
<td><code>emptyCalendarText</code></td>
<td>Text to display when there are no upcoming events.<br>
<br><b>Default value:</b> <code>''No upcoming events.'</code>
</td>
</tr>
</tbody>
</table>

View File

@ -28,7 +28,9 @@ Module.register('calendar',{
],
titleReplace: {
'De verjaardag van ' : ''
}
},
loadingText: 'Loading events &hellip;',
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;
}

View File

@ -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);
};