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.
This commit is contained in:
Manuel Friedli 2014-06-28 12:10:24 +02:00
parent 1bc60d7a1b
commit ae3da935be

14
uhr.js
View file

@ -42,7 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
width: '100%',
status: 'on',
language: 'de_CH',
theme: 'black',
theme: window._uhr.themes[0].class,
force: false,
controls: true
},
@ -225,16 +225,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
e.after(toggleSwitch);
// language chooser
var languageChooser = $('<select id="uhr-languagechooser' + this._id + '"></select>');
var options = [];
for (var code in window._uhr.languages) {
if (window._uhr.languages.hasOwnProperty(code)) {
var language = window._uhr.languages[code];
languageChooser.append('<option value="' + code + '">' + language.language + '</option>');
options.push('<option value="' + code + '">' + language.language + '</option>');
}
}
if (options.length > 1) {
var languageChooser = $('<select id="uhr-languagechooser' + this._id + '"></select>');
for (var i = 0; i < options.length; i++) {
languageChooser.append(options[i]);
}
e.after(languageChooser);
}
// theme chooser
if (window._uhr.themes.length > 1) {
var themeChooser = $('<select id="uhr-themechooser' + this._id + '"></select>');
for (var i = 0; i < window._uhr.themes.length; i++) {
var theme = window._uhr.themes[i];
@ -242,6 +249,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}
e.after(themeChooser);
}
}
},
_wireFunctionality: function() {
var uhr = this;