uhr/dist/jquery.uhr.main.min.js

6 lines
11 KiB
JavaScript
Raw Normal View History

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