diff --git a/uhr.js b/uhr.js
index d842352..a2e4e46 100644
--- a/uhr.js
+++ b/uhr.js
@@ -37,6 +37,10 @@ along with this program. If not, see .
window._uhr.themes.push({'class': styleClass, 'name': name});
}
}
+ // fall-back if no theme was included
+ if (window._uhr.themes.length == 0) {
+ window._uhr.themes.push({});
+ }
$.widget("fritteli.uhr", {
options: {
width: '100%',
@@ -292,6 +296,19 @@ along with this program. If not, see .
if (selectedTheme == undefined || this.options.force) {
selectedTheme = this.options.theme;
}
+ var found = false;
+ for (var i = 0; i < window._uhr.themes.length; i++) {
+ var styleClass = window._uhr.themes[i].class;
+ if (selectedTheme == styleClass) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ var fallback = window._uhr.themes[0].class;
+ console.warn("Theme " + selectedTheme + " not found! Using fallback: " + fallback);
+ selectedTheme = fallback;
+ }
themeChooser.val(selectedTheme);
this.options.theme = "";
this.theme(selectedTheme);