",options:{disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this.bindings=t(),this.hoverable=t(),this.focusable=t(),s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(i,s){var o,n,r,a=i;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof i)if(a={},o=i.split("."),i=o.shift(),o.length){for(n=a[i]=t.widget.extend({},this.options[i]),r=0;o.length-1>r;r++)n[o[r]]=n[o[r]]||{},n=n[o[r]];if(i=o.pop(),s===e)return n[i]===e?null:n[i];n[i]=s}else{if(s===e)return this.options[i]===e?null:this.options[i];a[i]=s}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!e).attr("aria-disabled",e),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(i,s,o){var n,r=this;"boolean"!=typeof i&&(o=s,s=i,i=!1),o?(s=n=t(s),this.bindings=this.bindings.add(s)):(o=s,s=this.element,n=this.widget()),t.each(o,function(o,a){function l(){return i||r.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?r[a]:a).apply(r,arguments):e}"string"!=typeof a&&(l.guid=a.guid=a.guid||l.guid||t.guid++);var h=o.match(/^(\w+)\s*(.*)$/),c=h[1]+r.eventNamespace,p=h[2];p?n.delegate(p,c,l):s.bind(c,l)})},_off:function(t,e){e=(e||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(e).undelegate(e)},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,i,s){var o,n,r=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],n=i.originalEvent)for(o in n)o in i||(i[o]=n[o]);return this.element.trigger(i,s),!(t.isFunction(r)&&r.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,o,n){"string"==typeof o&&(o={effect:o});var r,a=o?o===!0||"number"==typeof o?i:o.effect||i:e;o=o||{},"number"==typeof o&&(o={duration:o}),r=!t.isEmptyObject(o),o.complete=n,o.delay&&s.delay(o.delay),r&&t.effects&&t.effects.effect[a]?s[e](o):a!==e&&s[a]?s[a](o.duration,o.easing,n):s.queue(function(i){t(this)[e](),n&&n.call(s[0]),i()})}})})(jQuery);
\ No newline at end of file
diff --git a/uhr-de.js b/uhr-de.js
index 297484d..7c0d461 100644
--- a/uhr-de.js
+++ b/uhr-de.js
@@ -27,4 +27,4 @@ var layout = {
[h('Z', 10), h('E', 10),h('H', 10),h('N', 9, 10),h('E', 9),h('U', 9),h('N', 9),l('K'),l('U'),l('H'),l('R')]
]
};
-Uhr.registerLanguage('de', layout);
+window._uhr.languages['de'] = layout;
diff --git a/uhr-de_CH.js b/uhr-de_CH.js
index 4b6f5cb..874ae1c 100644
--- a/uhr-de_CH.js
+++ b/uhr-de_CH.js
@@ -27,4 +27,4 @@ var layout = {
[h('Z', 12), h('W', 12),h('Ö', 12),h('U', 12),h('F', 12),h('I', 12),l('N'),l('A'),l('U'),l('H'),l('R')]
]
};
-Uhr.registerLanguage('de_CH', layout);
+window._uhr.languages['de_CH'] = layout;
diff --git a/uhr-en.js b/uhr-en.js
index 2727d28..bca4c8e 100644
--- a/uhr-en.js
+++ b/uhr-en.js
@@ -34,4 +34,4 @@ var layout = {
return hour;
}
};
-Uhr.registerLanguage('en', layout);
+window._uhr.languages['en'] = layout;
diff --git a/uhr.js b/uhr.js
index 8337a01..3fa85ae 100644
--- a/uhr.js
+++ b/uhr.js
@@ -15,121 +15,133 @@ along with this program. If not, see
.
(function($) {
"use strict";
- if (window.Uhr !== undefined) {
+ if (window._uhr !== undefined) {
return;
}
- window.Uhr = {
+ window._uhr = {
id: 0,
- start: function(e) {
- if (!Uhr.isOn(e)) {
- e.data('timer', window.setInterval(function() {Uhr.update(e);}, 1000));
- Uhr.update(e);
- jQuery.cookie('status' + e.data('id'), 'on', {expires: 365, path: '/'});
+ languages: new Array()
+ };
+ $.widget("fritteli.uhr", {
+ options: {
+ width: '100%',
+ status: 'on',
+ language: 'de_CH',
+ theme: 'black',
+ force: false
+ },
+ start: function() {
+ if (!this._isOn()) {
+ var uhr = this;
+ this._timer = window.setInterval(function() {
+ uhr._update();
+ }, 1000);
+ this._update();
+ $.cookie('uhr-status' + this._id, 'on', {expires: 365, path: '/'});
+ } else {
}
},
- stop: function(e) {
- if (Uhr.isOn(e)) {
- window.clearInterval(e.data('timer'));
- e.data('timer', null);
- Uhr.update(e);
- jQuery.cookie('status' + e.data('id'), 'off', {expires: 365, path: '/'});
+ stop: function() {
+ if(this._isOn()) {
+ window.clearInterval(this._timer);
+ this._timer = null;
+ this._update();
+ $.cookie('uhr-status' + this._id, 'off', {expires: 365, path: '/'});
}
},
- update: function(e) {
- if (Uhr.isOn(e)) {
+ toggle: function() {
+ if(this._isOn()) {
+ this.stop();
+ } else {
+ this.start();
+ }
+ },
+ language: function(languageKey) {
+ if (languageKey !== this.options.language) {
+ this.options.language = languageKey;
+ var renderer = new UhrRenderer(this._language(), this.element.find('.letterarea'));
+ renderer.render(this);
+ $.cookie('uhr-language' + this._id, languageKey, {expires: 365, path: '/'});
+ this._update();
+ }
+ },
+ theme: function(theme) {
+ if (theme != this.options.theme) {
+ this.element.removeClass(this.options.theme).addClass(theme);
+ $('#uhr-onoffswitch' + this._id).removeClass(this.options.theme).addClass(theme);
+ this.options.theme = theme;
+ $.cookie('uhr-theme' + this._id, theme, {expires: 365, path: '/'});
+ }
+ },
+ // private variables
+ _id: -1,
+ _timer: null,
+ _currentMinute: -1,
+ // private methods
+ _isOn: function() {
+ return this._timer !== null;
+ },
+ _update: function() {
+ if (this._isOn()) {
var now = new Date();
- if (now.getMinutes() == e.data('currentMinute')) {
+ if (now.getMinutes() == this._currentMinute) {
return;
}
- e.data('currentMinute', now.getMinutes());
- var dotMinute = Uhr.getDotMinute(e, now);
- var hour = Uhr.getHour(e, now);
- var coarseMinute = this.getCoarseMinute(e, now);
- Uhr.clear(e);
- Uhr.highlight(e, 'on');
+ this._currentMinute = now.getMinutes();
+ var dotMinute = this._getDotMinute(now);
+ var hour = this._getHour(now);
+ var coarseMinute = this._getCoarseMinute(now);
+ this._clear();
+ this._highlight('on');
for (var i = 1; i <= dotMinute; i++) {
- Uhr.highlight(e, 'dot' + i);
+ this._highlight('dot' + i);
}
- Uhr.highlight(e, 'minute' + coarseMinute);
- hour = this.normalizeHour(hour);
- Uhr.highlight(e, 'hour' + hour);
+ this._highlight('minute' + coarseMinute);
+ hour = this._normalizeHour(hour);
+ this._highlight('hour' + hour);
if (coarseMinute == 0) {
- Uhr.highlight(e, 'sharphour');
+ this._highlight('sharphour');
}
} else {
- Uhr.clear(e);
- e.data('currentMinute', -1);
+ this._clear();
+ this._currentMinute = -1;
}
},
- toggle: function(e) {
- if (Uhr.isOn(e)) {
- Uhr.stop(e);
- } else {
- Uhr.start(e);
+ _language: function() {
+ return window._uhr.languages[this.options.language];
+ },
+ _highlight: function(itemClass) {
+ this.element.find('.item.' + itemClass).addClass('active');
+ },
+ _clear: function() {
+ this.element.find('.item').removeClass('active');
+ },
+ _getHour: function(date) {
+ if (typeof this._language().getHour === 'function') {
+ return this._language().getHour(date);
}
- },
- clear: function(e) {
- e.find('.item').removeClass('active');
- },
- setLanguage: function(e, language) {
- var newLanguage = Uhr.layouts[language];
- if (newLanguage !== undefined && newLanguage != e.data('currentLanguage')) {
- e.data('currentLanguage', newLanguage);
- var renderer = new UhrRenderer(newLanguage, e.find('.letterarea'));
- renderer.render(e);
- jQuery.cookie('language' + e.data('id'), language, {expires: 365, path: '/'});
- }
- },
- setTheme: function(e, theme) {
- var currentTheme = e.data('currentTheme');
- if (theme != currentTheme) {
- e.removeClass(currentTheme).addClass(theme);
- e.data('toggleSwitch').removeClass(currentTheme).addClass(theme);
- e.data('currentTheme', theme);
- jQuery.cookie('theme' + e.data('id'), theme, {expires: 365, path: '/'});
- }
- },
- isOn: function(e) {
- return e.data('timer') != null;
- },
- highlight: function(e, itemClass) {
- e.find('.item.' + itemClass).addClass('active');
- },
- getHour: function(e, date) {
- //FIXME
- /*
- if (typeof e.data('currentLayout').getHour === 'function') {
- return e.data('currentLayout').getHour(date);
- }
- */
var hour = date.getHours();
if (date.getMinutes() >= 25) {
return hour + 1;
}
return hour;
},
- getCoarseMinute: function(e, date) {
- //FIXME
- /*
- if (typeof e.data('currentLayout').getCoarseMinute === 'function') {
- return e.data('currentLayout').getCoarseMinute(date);
+ _getCoarseMinute: function(date) {
+ if (typeof this._language().getCoarseMinute === 'function') {
+ return this._language().getCoarseMinute(date);
}
- */
var minutes = date.getMinutes();
- return minutes - Uhr.getDotMinute(e, date);
+ return minutes - this._getDotMinute(date);
},
- getDotMinute: function(e, date) {
- //FIXME
- /*
- if (typeof e.data('currentLayout').getDotMinute === 'function') {
- return e.data('currentLayout').getDotMinute(date);
+ _getDotMinute: function(date) {
+ if (typeof this._language().getDotMinute === 'function') {
+ return this._language().getDotMinute(date);
}
- */
var minutes = date.getMinutes();
return minutes % 5;
},
- normalizeHour: function(hour) {
+ _normalizeHour: function(hour) {
if (hour > 12) {
hour %= 12;
}
@@ -138,25 +150,14 @@ along with this program. If not, see
.
}
return hour;
},
- registerLanguage: function(languageKey, layout) {
- this.layouts[languageKey] = layout;
+ _create: function() {
+ this._id = window._uhr.id++;
+ this._setupHTML();
+ this._wireFunctionality();
},
- layouts: new Array()
- }
- $.fn.uhr = function(options) {
- var settings = $.extend({
- width: '100%',
- force: false,
- status: 'on',
- language: 'de_CH',
- theme: 'black'
- }, options);
- return this.each(function() {
- var e = $(this);
- var id = window.Uhr.id++;
- e.data('id', id);
- e.data('timer', null);
-
+ _setupHTML: function() {
+ var e = this.element;
+ // Base clock area
e.addClass('uhr');
e.empty();
e.append('
');
@@ -165,333 +166,89 @@ along with this program. If not, see
.
e.append('
');
e.append('
');
e.append('
');
- e.css('width', settings.width);
+ e.css('width', this.options.width);
var realWidth = e.width()
e.width(realWidth);
e.height(realWidth);
e.css('font-size', (realWidth / 40) + 'px');
- var toggleSwitch = jQuery('
');
- toggleSwitch.append('
');
- toggleSwitch.append('
'
+ // on/off switch
+ var toggleSwitch = $('
');
+ toggleSwitch.append(' ');
+ toggleSwitch.append(''
+ '
'
+ '
'
+ ' ');
e.after(toggleSwitch);
- e.data('toggleSwitch', toggleSwitch);
- var languageSwitch = jQuery(' ')
- // FIXME handle layouts correctly
- for (var code in Uhr.layouts) {
- if (Uhr.layouts.hasOwnProperty(code)) {
- var language = Uhr.layouts[code];
- var option = '' + language.language + ' ';
- languageSwitch.append(option);
+ // language chooser
+ var languageChooser = $(' ')
+ for (var code in window._uhr.languages) {
+ if (window._uhr.languages.hasOwnProperty(code)) {
+ var language = window._uhr.languages[code];
+ languageChooser.append('' + language.language + ' ');
}
}
- e.after(languageSwitch);
- e.data('languageSwitch', languageSwitch);
+ e.after(languageChooser);
- var themeSwitch = jQuery(' ');
- themeSwitch.append('Schwarz ');
- themeSwitch.append('Rot ');
- themeSwitch.append('Blau ');
- themeSwitch.append('Grün ');
- themeSwitch.append('Weiss ');
- e.after(themeSwitch);
- e.data('themeSwitch', themeSwitch);
+ // theme chooser
+ var themeChooser = $(' ');
+ themeChooser.append('Schwarz ');
+ themeChooser.append('Rot ');
+ themeChooser.append('Blau ');
+ themeChooser.append('Grün ');
+ themeChooser.append('Weiss ');
+ e.after(themeChooser);
+ },
+ _wireFunctionality: function() {
+ var e = this.element;
+ var uhr = this;
-
- var input = jQuery('#onoffswitch' + id);
- input.on('click', function() {
- window.Uhr.toggle(e);
+ // on/off switch
+ var toggleSwitch = $('#uhr-onoffswitch-checkbox' + this._id);
+ toggleSwitch.on('click', function() {
+ uhr.toggle();
});
-
- var status = jQuery.cookie('status' + id);
- if (status == undefined || settings.force) {
- status = settings.status;
+ var status = $.cookie('uhr-status' + this._id);
+ if (status == undefined || this.options.force) {
+ status = this.options.status;
}
+ toggleSwitch.prop('checked', status == 'on');
if (status == 'on') {
- window.Uhr.start(e);
- input.prop('checked', true);
+ this.start();
} else {
- window.Uhr.stop(e);
- input.prop('checked', false);
+ this.stop();
}
- e.data('languageSwitch').on('change', function() {
- window.Uhr.setLanguage(e, this.value);
+ // language chooser
+ var languageChooser = $('#uhr-languagechooser' + this._id);
+ languageChooser.on('change', function() {
+ uhr.language(this.value);
});
- var selectedLanguage = jQuery.cookie('language' + id);
- if (selectedLanguage == undefined || settings.force) {
- selectedLanguage = settings.language;
+ var selectedLanguage = $.cookie('uhr-language' + this._id);
+ if (selectedLanguage == undefined || this.options.force) {
+ selectedLanguage = this.options.language;
}
- e.data('languageSwitch').val(selectedLanguage);
- window.Uhr.setLanguage(e, selectedLanguage);
+ languageChooser.val(selectedLanguage);
+ this.options.language = "";
+ this.language(selectedLanguage);
- e.data('themeSwitch').on('change', function() {
- window.Uhr.setTheme(e, this.value);
+ // theme chooser
+ var themeChooser = $('#uhr-themechooser' + this._id);
+ themeChooser.on('change', function() {
+ uhr.theme(this.value);
});
- var selectedTheme = jQuery.cookie('theme' + id);
- if (selectedTheme == undefined || settings.force) {
- selectedTheme = settings.theme;
+ var selectedTheme = $.cookie('uhr-theme' + this._id);
+ if (selectedTheme == undefined || this.options.force) {
+ selectedTheme = this.options.theme;
}
- e.data('themeSwitch').val(selectedTheme);
- window.Uhr.setTheme(e, selectedTheme);
-
- });
- };
+ themeChooser.val(selectedTheme);
+ this.options.theme = "";
+ this.theme(selectedTheme);
+ }
+ });
})(jQuery);
-(function($){
-return this;
-/**
- * Die Uhr.
- * @param clockarea Das jQuery-gewrappte HTML-Element, auf dem die Uhr angezeigt werden soll.
- * @param themeElement Das HTML-Stylesheet-Tag, das das Theme-CSS referenziert.
- */
-//if (typeof Uhr === 'undefined') {
-function Uhr(clockarea, settings) {
- this.id = Uhr.id++;
- this.timer = null;
- this.currentTheme = null;
- this.currentLayout = {};
- this.currentMinute = -1;
- this.initHTMLElements(clockarea, settings || {});
-}
-Uhr.id = 0;
-Uhr.layouts = new Array();
-Uhr.register = function (locale, layout) {
- Uhr.layouts[locale] = layout;
-}
-Uhr.prototype.toggle = function() {
- if (this.isOn()) {
- this.stop();
- } else {
- this.start();
- }
-}
-Uhr.prototype.start = function() {
- if (!this.isOn()) {
- var uhr = this;
- this.timer = window.setInterval(function() {uhr.update();}, 1000);
- this.update();
- jQuery.cookie('status' + this.id, 'on', {expires: 365, path: '/'});
- }
-}
-Uhr.prototype.stop = function() {
- if (this.isOn()) {
- window.clearInterval(this.timer);
- this.timer = null;
- this.update();
- jQuery.cookie('status' + this.id, 'off', {expires: 365, path: '/'});
- }
-}
-Uhr.prototype.isOn = function() {
- return this.timer != null;
-}
-Uhr.prototype.setLayout = function(locale) {
- var newLayout = Uhr.layouts[locale];
- if (newLayout !== undefined && newLayout != this.currentLayout) {
- this.currentLayout = newLayout;
- var renderer = new UhrRenderer(this.currentLayout, this.letterarea);
- renderer.render(this);
- jQuery.cookie('layout' + this.id, locale, {expires: 365, path: '/'});
- }
-}
-Uhr.prototype.setTheme = function(theme) {
- if (theme != this.currentTheme) {
- this.clockarea.removeClass(this.currentTheme);
- this.toggleSwitch.removeClass(this.currentTheme);
- this.clockarea.addClass(theme);
- this.toggleSwitch.addClass(theme);
- this.currentTheme = theme;
- jQuery.cookie('theme' + this.id, theme, {expires: 365, path: '/'});
- }
-}
-Uhr.prototype.update = function() {
- if (this.isOn()) {
- var now = new Date();
- if (now.getMinutes() == this.currentMinute) {
- return;
- }
- this.currentMinute = now.getMinutes();
- var dotMinute = this.getDotMinute(now);
- var hour = this.getHour(now);
- var coarseMinute = this.getCoarseMinute(now);
- this.clear();
- this.highlight('on');
- for (var i = 1; i <= dotMinute; i++) {
- this.highlight('dot' + i);
- }
- this.highlight('minute' + coarseMinute);
- hour = this.normalizeHour(hour);
- this.highlight('hour' + hour);
- if (coarseMinute == 0) {
- this.highlight('sharphour');
- }
- } else {
- this.clear();
- this.currentMinute = -1;
- }
-}
-Uhr.prototype.clear = function() {
- this.clockarea.find('.item').removeClass('active');
-}
-Uhr.prototype.highlight = function(itemClass) {
- this.clockarea.find('.item.' + itemClass).addClass('active');
-}
-Uhr.prototype.getHour = function(date) {
- if (typeof this.currentLayout.getHour === 'function') {
- return this.currentLayout.getHour(date);
- }
- var hour = date.getHours();
- if (date.getMinutes() >= 25) {
- return hour + 1;
- }
- return hour;
-}
-Uhr.prototype.getCoarseMinute = function(date) {
- if (typeof this.currentLayout.getCoarseMinute === 'function') {
- return this.currentLayout.getCoarseMinute(date);
- }
- var minutes = date.getMinutes();
- return minutes - this.getDotMinute(date);
-}
-Uhr.prototype.getDotMinute = function(date) {
- if (typeof this.currentLayout.getDotMinute === 'function') {
- return this.currentLayout.getDotMinute(date);
- }
- var minutes = date.getMinutes();
- return minutes % 5;
-}
-Uhr.prototype.normalizeHour = function(hour) {
- if (hour > 12) {
- hour %= 12;
- }
- if (hour == 0) {
- return 12;
- }
- return hour;
-}
-Uhr.prototype.initHTMLElements = function(clockarea, presets) {
- this.createHTMLElements(clockarea, presets.width);
- var force = presets.force || false;
- this.initToggleSwitch(presets.status, force);
- this.initLayoutSwitch(presets.layout, force);
- this.initThemeSwitch(presets.theme, force);
-}
-Uhr.prototype.createHTMLElements = function(clockarea, width) {
- this.createClockarea(clockarea, width)
- this.letterarea = this.clockarea.find('.letterarea');
- this.createToggleSwitch();
- this.createLayoutSwitch();
- this.createThemeSwitch();
-}
-Uhr.prototype.createClockarea = function(clockarea, width) {
- clockarea.addClass('uhr');
- clockarea.empty();
- clockarea.append(' ');
- clockarea.append(' ');
- clockarea.append(' ');
- clockarea.append(' ');
- clockarea.append('
');
- clockarea.append('
');
- if(width == undefined) {
- width = '100%';
- }
- clockarea.css('width', width);
- var realWidth = clockarea.width()
- clockarea.width(realWidth);
- clockarea.height(realWidth);
- clockarea.css('font-size', (realWidth / 40) + 'px');
- this.clockarea = clockarea
-}
-Uhr.prototype.createToggleSwitch = function() {
- this.toggleSwitch = jQuery('
');
- var input = jQuery(' ');
- this.toggleSwitch.append(input);
- this.toggleSwitch.append(''
- + '
'
- + '
'
- + ' ');
- this.clockarea.after(this.toggleSwitch);
-}
-Uhr.prototype.createLayoutSwitch = function () {
- this.layoutSwitch = jQuery(' ')
- for (var code in Uhr.layouts) {
- if (Uhr.layouts.hasOwnProperty(code)) {
- var layout = Uhr.layouts[code];
- var option = jQuery('' + layout.language + ' ')
- this.layoutSwitch.append(option);
- }
- }
- this.clockarea.after(this.layoutSwitch);
-}
-Uhr.prototype.createThemeSwitch = function () {
- this.themeSwitch = jQuery(' ');
- this.themeSwitch.append('Schwarz ');
- this.themeSwitch.append('Rot ');
- this.themeSwitch.append('Blau ');
- this.themeSwitch.append('Grün ');
- this.themeSwitch.append('Weiss ');
- this.clockarea.after(this.themeSwitch);
-}
-Uhr.prototype.initToggleSwitch = function(defaultValue, overrideCookie) {
- var input = jQuery('#onoffswitch' + this.id);
- var uhr = this;
- input.on('click', function() {
- uhr.toggle();
- });
- var status = jQuery.cookie('status' + this.id);
- if (status == undefined || (overrideCookie && (defaultValue != undefined))) {
- status = defaultValue;
- }
- if (status == undefined || status == 'undefined') {
- status = 'on';
- }
- if (status == 'on') {
- this.start();
- input.prop('checked', true);
- } else {
- this.stop();
- input.prop('checked', false);
- }
-}
-Uhr.prototype.initLayoutSwitch = function(defaultValue, overrideCookie) {
- var uhr = this;
- this.layoutSwitch.on('change', function() {
- uhr.setLayout(this.value);
- });
- var selectedLayout = jQuery.cookie('layout' + this.id);
- if (selectedLayout == undefined || (overrideCookie && (defaultValue != undefined))) {
- selectedLayout = defaultValue;
- }
- if (selectedLayout == undefined) {
- // FIXME not nice, hardcoded default-value
- selectedLayout = 'de_CH';
- }
- this.layoutSwitch.val(selectedLayout);
- this.setLayout(selectedLayout);
-}
-Uhr.prototype.initThemeSwitch = function(defaultValue, overrideCookie) {
- var uhr = this;
- this.themeSwitch.on('change', function() {
- uhr.setTheme(this.value);
- });
- var selectedTheme = jQuery.cookie('theme' + this.id);
- if (selectedTheme == undefined || (overrideCookie && (defaultValue != undefined))) {
- selectedTheme = defaultValue;
- }
- if (selectedTheme == undefined || selectedTheme == 'undefined') {
- selectedTheme = 'black';
- }
- this.themeSwitch.val(selectedTheme);
- this.setTheme(selectedTheme);
-}
-
-//}
-})(jQuery);
/**
* Hilfsklasse zum Rendern der Uhr.
* @param layout Layout-Objekt, das gerendert werden soll.
@@ -514,8 +271,8 @@ UhrRenderer.prototype.render = function(uhr) {
renderer.renderarea.append(' ');
}
}
- uhr.data('currentMinute', -1);
- Uhr.update(uhr);
+ uhr._currentMinute = -1;
+ uhr._update();
renderer.renderarea.fadeIn('fast');
});
}