uhr/dist/jquery.uhr.complete.min.js

5 lines
21 KiB
JavaScript
Raw Normal View History

/*! uhr - v8.0.4-dev.0 - 2019-05-03
* http://bärneruhr.ch/
* Copyright (c) 2019 Manuel Friedli; Licensed GPL-3.0 */
!function(d){"use strict";var e,i,n,l={id:0,languages:[],themes:[],registerLanguage:function(e,i){l.languages.some(function(t){return e===t.code&&(console.error("Error: Language code '"+e+"' cannot be registered for language '"+i.language+"' because it is already registered for language '"+t.language+"'!"),!0)})||(i.code=e,l.languages.push(i))}};d("link[rel=stylesheet]").each(function(t,e){var i=d(e),n=i.attr("data-class");if(void 0!==n){var s=i.attr("data-name");void 0===s&&(s=n),l.themes.push({styleClass:n,name:s})}}),0===l.themes.length&&l.themes.push({});var s;function N(t,e){var i=t,n=e||"";this.addStyle=function(t){""===n?n=t:n+=" "+t},this.toString=function(){return'<span class="item letter '+n+'">'+i+"</span>"}}function o(t){var e={3:[2,3,4],4:[1,5],5:[1,4,5],6:[1,3,5],7:[1,2,5],8:[1,5],9:[2,3,4]},i={3:[8,9,10],4:[7,11],5:[7,10,11],6:[7,9,11],7:[7,8,11],8:[7,11],9:[8,9,10]},n={3:[3],4:[2,3],5:[3],6:[3],7:[3],8:[3],9:[2,3,4]},s={3:[9],4:[8,9],5:[9],6:[9],7:[9],8:[9],9:[8,9,10]},o={3:[2,3,4],4:[1,5],5:[5],6:[4],7:[3],8:[2],9:[1,2,3,4,5]},r={3:[8,9,10],4:[7,11],5:[11],6:[10],7:[9],8:[8],9:[7,8,9,10,11]},a={3:[1,2,3,4,5],4:[4],5:[3],6:[4],7:[5],8:[1,5],9:[2,3,4]},h={3:[7,8,9,10,11],4:[10],5:[9],6:[10],7:[11],8:[7,11],9:[8,9,10]},u={3:[4],4:[3,4],5:[2,4],6:[1,4],7:[1,2,3,4,5],8:[4],9:[4]},c={3:[10],4:[9,10],5:[8,10],6:[7,10],7:[7,8,9,10,11],8:[10],9:[10]},d={3:[1,2,3,4,5],4:[1],5:[1,2,3,4],6:[5],7:[5],8:[1,5],9:[2,3,4]},l={3:[7,8,9,10,11],4:[7],5:[7,8,9,10],6:[11],7:[11],8:[7,11],9:[8,9,10]},f={3:[9,10],4:[8],5:[7],6:[7,8,9,10],7:[7,11],8:[7,11],9:[8,9,10]},g={3:[7,8,9,10,11],4:[11],5:[10],6:[9],7:[8],8:[8],9:[8]},E={3:[8,9,10],4:[7,11],5:[7,11],6:[8,9,10],7:[7,11],8:[7,11],9:[8,9,10]},p={3:[8,9,10],4:[7,11],5:[7,11],6:[8,9,10,11],7:[11],8:[10],9:[8,9]},v={0:[e,i],1:[e,s],2:[e,r],3:[e,h],4:[e,c],5:[e,l],6:[e,f],7:[e,g],8:[e,E],9:[e,p],10:[n,i],11:[n,s],12:[n,r],13:[n,h],14:[n,c],15:[n,l],16:[n,f],17:[n,g],18:[n,E],19:[n,p],20:[o,i],21:[o,s],22:[o,r],23:[o,h],24:[o,c],25:[o,l],26:[o,f],27:[o,g],28:[o,E],29:[o,p],30:[a,i],31:[a,s],32:[a,r],33:[a,h],34:[a,c],35:[a,l],36:[a,f],37:[a,g],38:[a,E],39:[a,p],40:[u,i],41:[u,s],42:[u,r],43:[u,h],44:[u,c],45:[u,l],46:[u,f],47:[u,g],48:[u,E],49:[u,p],50:[d,i],51:[d,s],52:[d,r],53:[d,h],54:[d,c],55:[d,l],56:[d,f],57:[d,g],58:[d,E],59:[d,p]};function m(i,n,t){null!=t&&Object.keys(t).forEach(function(e){t[e].forEach(function(t){i[e-1][t-1].addStyle(n)})})}function I(e,i,t){null!=t&&(Array.isArray(t)?t.forEach(function(t){m(e,i,t)}):m(e,i,t))}function b(n,s,o){null!=o&&Object.keys(o).forEach(function(t){var e=t.split(","),i=o[t];e.forEach(function(t){I(n,s+t,i)})})}this.parse=function(){var s=[];return t.letters.forEach(function(t){for(var e=[],i=0;i<t.length;i++){var n=new N(t[i]);e.push(n)}s.push(e)}),I(s,"on",t.permanent),void 0!==t.seconds&&null!==t.seconds?b(s,"second",t.seconds):b(s,"second",v),b(s,"minute",t.minutes),b(s,"hour",t.hours),s}}function r(n,s){this.render=function(t){if(void 0===n.parsed)switch(n.version){case 2:var e=new o(n).parse();Object.defineProperty(n,"parsed",{value:e,writable:!1,configurable:!1});break;default:return void console.warn("Unknown layout version: '"+n.version+"'")}var i=n.parsed;s.fadeOut("fast",function(){s.empty(),i.forEach(function(t,e,i){t.forEach(function(t){s.append(t.toString())}),e<i.length-1&&s.append("<br/>")}),"function"==typeof t&&t(),s.fadeIn("fast")})}}function f(t){this.options.mode=t,this.currentMinute=-1,n.bind(this)(),e.bind(this)("uhr-mode",t)}function g(t){var e=this.element;e.css("width",t);var i=e.width();e.width(i),e.height(i),e.css("font-size",i/40+"px")}var a,h;a=function(){var t=this.element;if(t.addClass("uhr"),t.empty(),t.append('<span class="item dot dot1"></span>'),t.append('<span class="item dot dot2"></span>'),t.append('<span class="item dot dot3"></span>'),t.append('<span class="item dot dot4"></span>'),t.append('<div class="letterarea"></div>'),t.append('<div class="reflection"></div>'),g.bind(this)(this.options.width),this.options.controls){var e=d('<div class="uhr-controlpanel" id="uhr-controlpanel'+this.id+