var uhr=function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(i,o,function(e){return t[e]}.bind(null,o));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=12)}({0:function(t,e){t.exports=jQuery},1:function(t,e){t.exports=Cookies},12:function(t,e,n){"use strict";n.r(e);var i=function(){function t(){}return t.registerTheme=function(e,n){t.themes.some(function(t){return t.name===e})?console.log("Theme with name '"+e+"' already registered; ignoring register request for styleClass '"+n+"'."):t.themes.push({name:e,styleClass:n})},t.hasThemes=function(){return t.themes.length>0},t.hasMultipleThemes=function(){return t.themes.length>1},t.getFirstTheme=function(){return t.getTheme(0)},t.getTheme=function(e){return t.themes[e]},t.getThemes=function(){return t.themes},t.registerLayout=function(e){!t.layouts.some(function(t){return e.code===t.code&&(e.prettyName!==t.prettyName&&console.error("Error: Language code '"+e.code+"' cannot be registered for layout '"+e.prettyName+"' because it is already registered for layout '"+t.prettyName+"'!"),!0)})&&(t.layouts.push(e),t.layouts.sort(function(t,e){return t.prettyName.localeCompare(e.prettyName)}))},t.hasLayouts=function(){return t.layouts.length>0},t.hasMultipleLayouts=function(){return t.layouts.length>1},t.getFirstLayout=function(){return t.layouts[0]},t.getLayouts=function(){return t.layouts},t.layouts=[],t.themes=[],t}(),o=n(0);var s=function(){function t(t,e){this.style="",this.value=t,e&&(this.style=e)}return t.prototype.addStyle=function(t){""===this.style?this.style=t:this.style+=" "+t},t.prototype.toString=function(){return''+this.value+""},t}(),r=function(){function t(t){this.layout=t}return t.prototype.parse=function(){var e=[];return this.layout.letters.forEach(function(t){for(var n=[],i=0;i")}),t&&t(),e.renderarea.fadeIn("fast")})},t}(),h={code:null,hours:null,letters:[],minutes:null,permanent:[],prettyName:null,version:2},u=n(1),c=function(){function t(t){this.widgetInstance=t,this.timer=null,this.currentMinute=null;var e=this.widgetInstance.options.time;void 0===this.widgetInstance.options.time&&(this.widgetInstance.options.time=new Date),this.parseHash(),this.setupHTML(),this.wireFunctionality(),void 0!==e&&this.setTime(e)}return t.prototype.destroy=function(){this.timer&&(window.clearInterval(this.timer),this.timer=null),this.widgetInstance.element.removeAttr("style").removeAttr("class").empty(),$("#uhr-configlink"+this.widgetInstance.uuid).remove(),$("#uhr-controlpanel"+this.widgetInstance.uuid).remove()},t.prototype.start=function(){var t=this;this.isOn()||(this.timer=window.setInterval(function(){t.widgetInstance.options.time=new Date,t.update()},1e3),this.update(),this.setCookie("uhr-status","on"))},t.prototype.stop=function(){this.isOn()&&(window.clearInterval(this.timer),this.timer=null,this.update(),this.setCookie("uhr-status","off"))},t.prototype.toggle=function(){this.isOn()?this.stop():this.start()},t.prototype.setLanguage=function(t){var e=this;t!==this.widgetInstance.options.language&&(this.widgetInstance.options.language=t,new a(this.getCurrentLayout(),this.widgetInstance.element.find(".letterarea")).render(function(){e.currentMinute=-1,e.update()}),this.setCookie("uhr-language",t),this.update())},t.prototype.setTheme=function(t){t!==this.widgetInstance.options.theme&&(this.widgetInstance.element.removeClass(this.widgetInstance.options.theme).addClass(t),$("#uhr-onoffswitch"+this.widgetInstance.uuid).removeClass(this.widgetInstance.options.theme).addClass(t),this.widgetInstance.options.theme=t,this.setCookie("uhr-theme",t))},t.prototype.setTime=function(t){this.currentMinute=null,null===t?this.widgetInstance.options.time=new Date:(null!==this.timer&&window.clearInterval(this.timer),this.widgetInstance.options.time=t),this.update()},t.prototype.setMode=function(t){this.widgetInstance.options.mode=t,this.currentMinute=null,this.update(),this.setCookie("uhr-mode",t)},t.prototype.setWidth=function(t){var e=this.widgetInstance.element;e.css("width",t);var n=e.width();e.width(n),e.height(n),e.css("font-size",n/40+"px")},t.prototype.setupHTML=function(){var t=this,e=this.widgetInstance.element;if(e.addClass("uhr").empty().append('').append('').append('').append('').append('
').append('
'),this.setWidth(this.widgetInstance.options.width),this.widgetInstance.options.controls){var n=$('
'),o=$('
');n.append(o);var s=$('
');s.append(''),s.append(''),o.append(s);var r=$('
');if(r.append(''),r.append(''),o.append(r),i.hasMultipleLayouts()){var a=$('');i.getLayouts().forEach(function(t){a.append('")}),o.append(a)}if(i.hasMultipleThemes()){var h=$('');i.getThemes().forEach(function(t){h.append('")}),o.append(h)}var u=$('');u.on("click",function(){return $("#uhr-controlpanel"+t.widgetInstance.uuid).hide("fast")}),o.append(u),e.after(n),n.hide();var c=$('');c.on({click:function(){return t.toggleConfigScreen()}}),e.after(c)}},t.prototype.wireFunctionality=function(){var t=this,e=$("#uhr-onoffswitch-checkbox"+this.widgetInstance.uuid);e.on({click:function(){return t.toggle()}});var n=this.getCookie("uhr-status");(void 0===n||this.widgetInstance.options.force)&&(n=this.widgetInstance.options.status),e.prop("checked","on"===n),"on"===n?this.start():this.stop();var o=$("#uhr-modeswitch-checkbox"+this.widgetInstance.uuid);o.on({click:function(){"seconds"===t.widgetInstance.options.mode?t.setMode("normal"):t.setMode("seconds")}});var s=this.getCookie("uhr-mode");(void 0===s||this.widgetInstance.options.force)&&(s=this.widgetInstance.options.mode),o.prop("checked","seconds"!==s),"seconds"===s?this.setMode("seconds"):this.setMode("normal");var r=$("#uhr-languagechooser"+this.widgetInstance.uuid);r.on({change:function(){var e=$("#uhr-languagechooser"+t.widgetInstance.uuid).val();t.setLanguage(e)}});var a=this.getCookie("uhr-language");(void 0===a||this.widgetInstance.options.force)&&(a=this.widgetInstance.options.language);var h=i.getLayouts().some(function(t){return a===t.code});if(!h){var u=void 0;u=i.hasLayouts()?i.getFirstLayout().code:"",console.warn("Language '"+a+"' not found! Using fallback '"+u+"'."),a=u}r.val(a),this.widgetInstance.options.language="",this.setLanguage(a);var c=$("#uhr-themechooser"+this.widgetInstance.uuid);c.on({change:function(){var e=$("#uhr-themechooser"+t.widgetInstance.uuid).val();t.setTheme(e)}});var d=this.getCookie("uhr-theme");if((void 0===d||this.widgetInstance.options.force)&&(d=this.widgetInstance.options.theme),!(h=i.getThemes().some(function(t){return d===t.styleClass}))){var l=i.getFirstTheme().styleClass;console.warn("Theme '"+d+"' not found! Using fallback '"+l+"'."),d=l}c.val(d),this.widgetInstance.options.theme="",this.setTheme(d),this.widgetInstance.options.autoresize&&$(window).on({resize:function(){var e=t.widgetInstance.element.parent(),n=$(window),i=e.width(),o=e.height(),s=n.width(),r=n.height(),a=Math.min(i,o,s,r)+"px";t.setWidth(a)}})},t.prototype.isOn=function(){return null!==this.timer},t.prototype.getCookie=function(t){return u.get(t+this.widgetInstance.uuid)},t.prototype.setCookie=function(t,e){var n;n=void 0!==this.widgetInstance.options.cookiePath?{expires:365,path:this.widgetInstance.options.cookiePath}:{expires:365},u.set(t+this.widgetInstance.uuid,e,n)},t.prototype.update=function(){if(this.isOn()){var t=this.widgetInstance.options.time;if(!this.getCurrentLayout().hasOwnProperty("seconds")&&"seconds"!==this.widgetInstance.options.mode){if(t.getMinutes()===this.currentMinute)return;this.currentMinute=t.getMinutes()}this.show(t)}else this.clear(),this.currentMinute=-1},t.prototype.show=function(t){var e=this.getSecond(t),n=this.getDotMinute(t),i=this.getHour(t),o=this.getCoarseMinute(t);if(this.clear(),"seconds"===this.widgetInstance.options.mode)this.highlight("second"+e);else{this.highlight("on");for(var s=1;s<=n;s++)this.highlight("dot"+s);this.highlight("minute"+o),this.highlight("hour"+i)}},t.prototype.clear=function(){this.widgetInstance.element.find(".item").removeClass("active")},t.prototype.highlight=function(t){this.widgetInstance.element.find(".item."+t).addClass("active")},t.prototype.getSecond=function(t){return"function"==typeof this.getCurrentLayout().getSeconds?this.getCurrentLayout().getSeconds(t):t.getSeconds()},t.prototype.getDotMinute=function(t){return"function"==typeof this.getCurrentLayout().getDotMinute?this.getCurrentLayout().getDotMinute(t):t.getMinutes()%5},t.prototype.getCoarseMinute=function(t){return"function"==typeof this.getCurrentLayout().getCoarseMinute?this.getCurrentLayout().getCoarseMinute(t):t.getMinutes()},t.prototype.getHour=function(t){if("function"==typeof this.getCurrentLayout().getHour)return this.getCurrentLayout().getHour(t);var e=t.getHours();return t.getMinutes()>=25?(e+1)%24:e},t.prototype.toggleConfigScreen=function(){$("#uhr-controlpanel"+this.widgetInstance.uuid).toggle("fast")},t.prototype.parseHash=function(){var t=this,e=window.location.hash;void 0!==e&&"#"===e.charAt(0)&&(e=e.substring(1),(e=decodeURIComponent(e)).split("&").forEach(function(e){var n=e.split("="),i=n[0],o=n[1];switch(i){case"l":case"language":t.widgetInstance.options.language=o,t.widgetInstance.options.force=!0;break;case"t":case"theme":t.widgetInstance.options.theme=o,t.widgetInstance.options.force=!0;break;case"m":case"mode":t.widgetInstance.options.mode=o,t.widgetInstance.options.force=!0;break;case"s":case"status":t.widgetInstance.options.status=o,t.widgetInstance.options.force=!0}}))},t.prototype.getCurrentLayout=function(){var t=this,e=i.getLayouts().filter(function(e){return e.code===t.widgetInstance.options.language},this);return e.length>0?e[0]:h},t}();o("link[rel=stylesheet]").each(function(t,e){var n=o(e),s=n.attr("data-class");if(void 0!==s){var r=n.attr("data-name");void 0===r&&(r=s),i.registerTheme(r,s)}}),i.hasThemes()||i.registerTheme("",""),$.widget("fritteli.uhr",{options:{width:"100%",status:"on",language:"de_CH",theme:i.getFirstTheme().styleClass,force:!1,controls:!0,cookiePath:void 0,autoresize:!0,mode:"normal"},start:function(){this.__fritteli_uhr_instance.start()},stop:function(){this.__fritteli_uhr_instance.stop()},toggle:function(){this.__fritteli_uhr_instance.toggle()},language:function(t){this.__fritteli_uhr_instance.setLanguage(t)},theme:function(t){this.__fritteli_uhr_instance.setTheme(t)},time:function(t){this.__fritteli_uhr_instance.setTime(t)},mode:function(t){this.__fritteli_uhr_instance.setMode(t)},width:function(t){this.__fritteli_uhr_instance.setWidth(t)},_create:function(){this.__fritteli_uhr_instance=new c(this)},_destroy:function(){this.__fritteli_uhr_instance.destroy()},__fritteli_uhr_instance:null}),$.fritteli.uhr.register=i.registerLayout}}); //# sourceMappingURL=uhr.js.map