From ae3da935bee2e63c7c71e61b4e60e7ca015d33c9 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Sat, 28 Jun 2014 12:10:24 +0200 Subject: [PATCH] only render selectors for language and theme if there is more than one language / theme definition. use the first defined theme as default if not explicitly specified. --- uhr.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/uhr.js b/uhr.js index 1d00bbb..d842352 100644 --- a/uhr.js +++ b/uhr.js @@ -42,7 +42,7 @@ along with this program. If not, see . width: '100%', status: 'on', language: 'de_CH', - theme: 'black', + theme: window._uhr.themes[0].class, force: false, controls: true }, @@ -225,22 +225,30 @@ along with this program. If not, see . e.after(toggleSwitch); // language chooser - var languageChooser = $(''); + var options = []; for (var code in window._uhr.languages) { if (window._uhr.languages.hasOwnProperty(code)) { var language = window._uhr.languages[code]; - languageChooser.append(''); + options.push(''); } } - e.after(languageChooser); + if (options.length > 1) { + var languageChooser = $(''); + for (var i = 0; i < options.length; i++) { + languageChooser.append(options[i]); + } + e.after(languageChooser); + } // theme chooser - var themeChooser = $(''); - for (var i = 0; i < window._uhr.themes.length; i++) { - var theme = window._uhr.themes[i]; - themeChooser.append(''); + if (window._uhr.themes.length > 1) { + var themeChooser = $(''); + for (var i = 0; i < window._uhr.themes.length; i++) { + var theme = window._uhr.themes[i]; + themeChooser.append(''); + } + e.after(themeChooser); } - e.after(themeChooser); } }, _wireFunctionality: function() {