fix config option

This commit is contained in:
fewieden 2017-03-16 16:57:55 +01:00
parent d26d94b62a
commit ccb81179ab
3 changed files with 21 additions and 10 deletions

View File

@ -49,6 +49,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Korean Translation. - Korean Translation.
- Added console warning on startup when deprecated config options are used - Added console warning on startup when deprecated config options are used
- Added `DAYAFTERTOMORROW`, `UPDATE_NOTIFICATION`, `UPDATE_NOTIFICATION_MODULE`, `UPDATE_INFO` to Norwegian translations (`nn` and `nb`). - Added `DAYAFTERTOMORROW`, `UPDATE_NOTIFICATION`, `UPDATE_NOTIFICATION_MODULE`, `UPDATE_INFO` to Norwegian translations (`nn` and `nb`).
- Added multiple calendar icon support.
### Fixed ### Fixed
- Update .gitignore to not ignore default modules folder. - Update .gitignore to not ignore default modules folder.

View File

@ -68,7 +68,7 @@ config: {
| Option | Description | Option | Description
| --------------------- | ----------- | --------------------- | -----------
| `url` | The url of the calendar .ical. This property is required. <br><br> **Possible values:** Any public accessble .ical calendar. | `url` | The url of the calendar .ical. This property is required. <br><br> **Possible values:** Any public accessble .ical calendar.
| `symbol` | The symbol to show in front of an event. This property is optional. <br><br> **Possible values:** See [Font Awesome](http://fontawesome.io/icons/) website. | `symbol` | The symbol to show in front of an event. This property is optional. <br><br> **Possible values:** See [Font Awesome](http://fontawesome.io/icons/) website. To have multiple symbols you can define them in an array e.g. `["calendar", "plane"]`
| `color` | The font color of an event from this calendar. This property should be set if the config is set to colored: true. <br><br> **Possible values:** HEX, RGB or RGBA values (#efefef, rgb(242,242,242), rgba(242,242,242,0.5)). | `color` | The font color of an event from this calendar. This property should be set if the config is set to colored: true. <br><br> **Possible values:** HEX, RGB or RGBA values (#efefef, rgb(242,242,242), rgba(242,242,242,0.5)).
| `repeatingCountTitle` | The count title for yearly repating events in this calendar. <br><br> **Example:** `'Birthday'` | `repeatingCountTitle` | The count title for yearly repating events in this calendar. <br><br> **Example:** `'Birthday'`
| `user` | The username for HTTP Basic authentication. | `user` | The username for HTTP Basic authentication.

View File

@ -130,10 +130,20 @@ Module.register("calendar", {
if (this.config.displaySymbol) { if (this.config.displaySymbol) {
var symbolWrapper = document.createElement("td"); var symbolWrapper = document.createElement("td");
symbolWrapper.className = "symbol"; symbolWrapper.className = "symbol align-right";
var symbols = this.symbolsForUrl(event.url);
if(typeof symbols === "string") {
symbols = [symbols];
}
for(var i = 0; i < symbols.length; i++) {
var symbol = document.createElement("span"); var symbol = document.createElement("span");
symbol.className = "fa fa-" + this.symbolForUrl(event.url); symbol.className = "fa fa-" + symbols[i];
if(i > 0){
symbol.style.paddingLeft = "5px";
}
symbolWrapper.appendChild(symbol); symbolWrapper.appendChild(symbol);
}
eventWrapper.appendChild(symbolWrapper); eventWrapper.appendChild(symbolWrapper);
} }
@ -324,14 +334,14 @@ Module.register("calendar", {
}); });
}, },
/* symbolForUrl(url) /* symbolsForUrl(url)
* Retrieves the symbol for a specific url. * Retrieves the symbols for a specific url.
* *
* argument url string - Url to look for. * argument url string - Url to look for.
* *
* return string - The Symbol * return string/array - The Symbols
*/ */
symbolForUrl: function (url) { symbolsForUrl: function (url) {
return this.getCalendarProperty(url, "symbol", this.config.defaultSymbol); return this.getCalendarProperty(url, "symbol", this.config.defaultSymbol);
}, },
@ -369,7 +379,7 @@ Module.register("calendar", {
getCalendarProperty: function (url, property, defaultValue) { getCalendarProperty: function (url, property, defaultValue) {
for (var c in this.config.calendars) { for (var c in this.config.calendars) {
var calendar = this.config.calendars[c]; var calendar = this.config.calendars[c];
if (calendar.url === url && typeof calendar[property] === "string") { if (calendar.url === url && calendar.hasOwnProperty(property)) {
return calendar[property]; return calendar[property];
} }
} }