jquery-yohours
Version:
Jquery and bootstrap based input widget to create opening_hours data
37 lines (36 loc) • 16.6 kB
JavaScript
/*
jed.js https://github.com/SlexAxton/Jed
*/
(function(F,l){function u(a){return c.PF.compile(a||"nplurals=2; plural=(n != 1);")}function B(a,b){this._key=a;this._i18n=b}var C=Array.prototype,G=C.slice,H=Object.prototype.hasOwnProperty,D=C.forEach,E={},A={forEach:function(a,b,e){var m;if(null!==a)if(D&&a.forEach===D)a.forEach(b,e);else if(a.length===+a.length){var c=0;for(m=a.length;c<m&&!(c in a&&b.call(e,a[c],c,a)===E);c++);}else for(c in a)if(H.call(a,c)&&b.call(e,a[c],c,a)===E)break},extend:function(a){this.forEach(G.call(arguments,1),function(b){for(var e in b)a[e]=
b[e]});return a}},c=function(a){this.defaults={locale_data:{messages:{"":{domain:"messages",lang:"en",plural_forms:"nplurals=2; plural=(n != 1);"}}},domain:"messages",debug:!1};this.options=A.extend({},this.defaults,a);this.textdomain(this.options.domain);if(a.domain&&!this.options.locale_data[this.options.domain])throw Error("Text domain set to non-existent domain: `"+a.domain+"`");};c.context_delimiter=String.fromCharCode(4);A.extend(B.prototype,{onDomain:function(a){this._domain=a;return this},
withContext:function(a){this._context=a;return this},ifPlural:function(a,b){this._val=a;this._pkey=b;return this},fetch:function(a){"[object Array]"!={}.toString.call(a)&&(a=[].slice.call(arguments,0));return(a&&a.length?c.sprintf:function(a){return a})(this._i18n.dcnpgettext(this._domain,this._context,this._key,this._pkey,this._val),a)}});A.extend(c.prototype,{translate:function(a){return new B(a,this)},textdomain:function(a){if(!a)return this._textdomain;this._textdomain=a},gettext:function(a){return this.dcnpgettext.call(this,
l,l,a)},dgettext:function(a,b){return this.dcnpgettext.call(this,a,l,b)},dcgettext:function(a,b){return this.dcnpgettext.call(this,a,l,b)},ngettext:function(a,b,e){return this.dcnpgettext.call(this,l,l,a,b,e)},dngettext:function(a,b,e,m){return this.dcnpgettext.call(this,a,l,b,e,m)},dcngettext:function(a,b,e,m){return this.dcnpgettext.call(this,a,l,b,e,m)},pgettext:function(a,b){return this.dcnpgettext.call(this,l,a,b)},dpgettext:function(a,b,e){return this.dcnpgettext.call(this,a,b,e)},dcpgettext:function(a,
b,e){return this.dcnpgettext.call(this,a,b,e)},npgettext:function(a,b,e,m){return this.dcnpgettext.call(this,l,a,b,e,m)},dnpgettext:function(a,b,e,m,c){return this.dcnpgettext.call(this,a,b,e,m,c)},dcnpgettext:function(a,b,e,m,r){m=m||e;a=a||this._textdomain;if(!this.options)return a=new c,a.dcnpgettext.call(a,void 0,void 0,e,m,r);if(!this.options.locale_data)throw Error("No locale data provided.");if(!this.options.locale_data[a])throw Error("Domain `"+a+"` was not found.");if(!this.options.locale_data[a][""])throw Error("No locale meta information provided.");
if(!e)throw Error("No translation key found.");b=b?b+c.context_delimiter+e:e;var t=this.options.locale_data,g=t[a];t=(t.messages||this.defaults.locale_data.messages)[""];t=g[""].plural_forms||g[""]["Plural-Forms"]||g[""]["plural-forms"]||t.plural_forms||t["Plural-Forms"]||t["plural-forms"];if(void 0===r)var d=0;else{if("number"!=typeof r&&(r=parseInt(r,10),isNaN(r)))throw Error("The number that was passed in is not a number.");d=u(t)(r)}if(!g)throw Error("No domain named `"+a+"` could be found.");
g=g[b];if(!g||d>g.length)return this.options.missing_key_callback&&this.options.missing_key_callback(b,a),a=[e,m],!0===this.options.debug&&console.log(a[u(t)(r)]),a[u()(r)];a=g[d];return a?a:(a=[e,m],a[u()(r)])}});var v=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}var b=function(){b.cache.hasOwnProperty(arguments[0])||(b.cache[arguments[0]]=b.parse(arguments[0]));return b.format.call(null,b.cache[arguments[0]],arguments)};b.format=function(e,b){var c=
1,m=e.length,g=[],d,h;for(d=0;d<m;d++){var f=a(e[d]);if("string"===f)g.push(e[d]);else if("array"===f){var k=e[d];if(k[2])for(f=b[c],h=0;h<k[2].length;h++){if(!f.hasOwnProperty(k[2][h]))throw v('[sprintf] property "%s" does not exist',k[2][h]);f=f[k[2][h]]}else f=k[1]?b[k[1]]:b[c++];if(/[^s]/.test(k[8])&&"number"!=a(f))throw v("[sprintf] expecting number but found %s",a(f));if("undefined"==typeof f||null===f)f="";switch(k[8]){case "b":f=f.toString(2);break;case "c":f=String.fromCharCode(f);break;
case "d":f=parseInt(f,10);break;case "e":f=k[7]?f.toExponential(k[7]):f.toExponential();break;case "f":f=k[7]?parseFloat(f).toFixed(k[7]):parseFloat(f);break;case "o":f=f.toString(8);break;case "s":f=(f=String(f))&&k[7]?f.substring(0,k[7]):f;break;case "u":f=Math.abs(f);break;case "x":f=f.toString(16);break;case "X":f=f.toString(16).toUpperCase()}f=/[def]/.test(k[8])&&k[3]&&0<=f?"+"+f:f;h=k[4]?"0"==k[4]?"0":k[4].charAt(1):" ";var l=k[6]-String(f).length;if(k[6]){for(var w=[];0<l;w[--l]=h);h=w.join("")}else h=
"";g.push(k[5]?f+h:h+f)}}return g.join("")};b.cache={};b.parse=function(a){for(var e,b=[],c=0;a;){if(null!==(e=/^[^\x25]+/.exec(a)))b.push(e[0]);else if(null!==(e=/^\x25{2}/.exec(a)))b.push("%");else if(null!==(e=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(a))){if(e[2]){c|=1;var g=[],d=e[2],h;if(null!==(h=/^([a-z_][a-z_\d]*)/i.exec(d)))for(g.push(h[1]);""!==(d=d.substring(h[0].length));)if(null!==(h=/^\.([a-z_][a-z_\d]*)/i.exec(d)))g.push(h[1]);else if(null!==
(h=/^\[(\d+)\]/.exec(d)))g.push(h[1]);else throw"[sprintf] huh?";else throw"[sprintf] huh?";e[2]=g}else c|=2;if(3===c)throw"[sprintf] mixing positional and named placeholders is not (yet) supported";b.push(e)}else throw"[sprintf] huh?";a=a.substring(e[0].length)}return b};return b}();c.parse_plural=function(a,b){a=a.replace(/n/g,b);return c.parse_expression(a)};c.sprintf=function(a,b){if("[object Array]"=={}.toString.call(b)){var e=[].slice.call(b);e.unshift(a);return v.apply(null,e)}return v.apply(this,
[].slice.call(arguments))};c.prototype.sprintf=function(){return c.sprintf.apply(this,arguments)};c.PF={};c.PF.parse=function(a){a=c.PF.extractPluralExpr(a);return c.PF.parser.parse.call(c.PF.parser,a)};c.PF.compile=function(a){var b=c.PF.parse(a);return function(a){a=c.PF.interpreter(b)(a);return!0===a?1:a?a:0}};c.PF.interpreter=function(a){return function(b){switch(a.type){case "GROUP":return c.PF.interpreter(a.expr)(b);case "TERNARY":return c.PF.interpreter(a.expr)(b)?c.PF.interpreter(a.truthy)(b):
c.PF.interpreter(a.falsey)(b);case "OR":return c.PF.interpreter(a.left)(b)||c.PF.interpreter(a.right)(b);case "AND":return c.PF.interpreter(a.left)(b)&&c.PF.interpreter(a.right)(b);case "LT":return c.PF.interpreter(a.left)(b)<c.PF.interpreter(a.right)(b);case "GT":return c.PF.interpreter(a.left)(b)>c.PF.interpreter(a.right)(b);case "LTE":return c.PF.interpreter(a.left)(b)<=c.PF.interpreter(a.right)(b);case "GTE":return c.PF.interpreter(a.left)(b)>=c.PF.interpreter(a.right)(b);case "EQ":return c.PF.interpreter(a.left)(b)==
c.PF.interpreter(a.right)(b);case "NEQ":return c.PF.interpreter(a.left)(b)!=c.PF.interpreter(a.right)(b);case "MOD":return c.PF.interpreter(a.left)(b)%c.PF.interpreter(a.right)(b);case "VAR":return b;case "NUM":return a.val;default:throw Error("Invalid Token found.");}}};c.PF.regexps={TRIM_BEG:/^\s\s*/,TRIM_END:/\s\s*$/,HAS_SEMICOLON:/;\s*$/,NPLURALS:/nplurals=(\d+);/,PLURAL:/plural=(.*);/};c.PF.extractPluralExpr=function(a){a=a.replace(c.PF.regexps.TRIM_BEG,"").replace(c.PF.regexps.TRIM_END,"");
c.PF.regexps.HAS_SEMICOLON.test(a)||(a=a.concat(";"));if(!(1<a.match(c.PF.regexps.NPLURALS).length))throw Error("nplurals not found in plural_forms string: "+a);a=a.replace(c.PF.regexps.NPLURALS,"");var b=a.match(c.PF.regexps.PLURAL);if(!(b&&1<b.length))throw Error("`plural` expression not found: "+a);return b[1]};c.PF.parser=function(){var a={trace:function(){},yy:{},symbols_:{error:2,expressions:3,e:4,EOF:5,"?":6,":":7,"||":8,"&&":9,"<":10,"<=":11,">":12,">=":13,"!=":14,"==":15,"%":16,"(":17,")":18,
n:19,NUMBER:20,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",6:"?",7:":",8:"||",9:"&&",10:"<",11:"<=",12:">",13:">=",14:"!=",15:"==",16:"%",17:"(",18:")",19:"n",20:"NUMBER"},productions_:[0,[3,2],[4,5],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,1],[4,1]],performAction:function(a,b,c,t,g,d,h){b=d.length-1;switch(g){case 1:return{type:"GROUP",expr:d[b-1]};case 2:this.$={type:"TERNARY",expr:d[b-4],truthy:d[b-2],falsey:d[b]};break;case 3:this.$={type:"OR",left:d[b-2],right:d[b]};
break;case 4:this.$={type:"AND",left:d[b-2],right:d[b]};break;case 5:this.$={type:"LT",left:d[b-2],right:d[b]};break;case 6:this.$={type:"LTE",left:d[b-2],right:d[b]};break;case 7:this.$={type:"GT",left:d[b-2],right:d[b]};break;case 8:this.$={type:"GTE",left:d[b-2],right:d[b]};break;case 9:this.$={type:"NEQ",left:d[b-2],right:d[b]};break;case 10:this.$={type:"EQ",left:d[b-2],right:d[b]};break;case 11:this.$={type:"MOD",left:d[b-2],right:d[b]};break;case 12:this.$={type:"GROUP",expr:d[b-1]};break;
case 13:this.$={type:"VAR"};break;case 14:this.$={type:"NUM",val:Number(a)}}},table:[{3:1,4:2,17:[1,3],19:[1,4],20:[1,5]},{1:[3]},{5:[1,6],6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{4:17,17:[1,3],19:[1,4],20:[1,5]},{5:[2,13],6:[2,13],7:[2,13],8:[2,13],9:[2,13],10:[2,13],11:[2,13],12:[2,13],13:[2,13],14:[2,13],15:[2,13],16:[2,13],18:[2,13]},{5:[2,14],6:[2,14],7:[2,14],8:[2,14],9:[2,14],10:[2,14],11:[2,14],12:[2,14],13:[2,14],14:[2,14],15:[2,14],
16:[2,14],18:[2,14]},{1:[2,1]},{4:18,17:[1,3],19:[1,4],20:[1,5]},{4:19,17:[1,3],19:[1,4],20:[1,5]},{4:20,17:[1,3],19:[1,4],20:[1,5]},{4:21,17:[1,3],19:[1,4],20:[1,5]},{4:22,17:[1,3],19:[1,4],20:[1,5]},{4:23,17:[1,3],19:[1,4],20:[1,5]},{4:24,17:[1,3],19:[1,4],20:[1,5]},{4:25,17:[1,3],19:[1,4],20:[1,5]},{4:26,17:[1,3],19:[1,4],20:[1,5]},{4:27,17:[1,3],19:[1,4],20:[1,5]},{6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[1,28]},{6:[1,7],7:[1,29],8:[1,8],
9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{5:[2,3],6:[2,3],7:[2,3],8:[2,3],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,3]},{5:[2,4],6:[2,4],7:[2,4],8:[2,4],9:[2,4],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,4]},{5:[2,5],6:[2,5],7:[2,5],8:[2,5],9:[2,5],10:[2,5],11:[2,5],12:[2,5],13:[2,5],14:[2,5],15:[2,5],16:[1,16],18:[2,5]},{5:[2,6],6:[2,6],7:[2,6],8:[2,6],9:[2,6],10:[2,6],11:[2,6],12:[2,
6],13:[2,6],14:[2,6],15:[2,6],16:[1,16],18:[2,6]},{5:[2,7],6:[2,7],7:[2,7],8:[2,7],9:[2,7],10:[2,7],11:[2,7],12:[2,7],13:[2,7],14:[2,7],15:[2,7],16:[1,16],18:[2,7]},{5:[2,8],6:[2,8],7:[2,8],8:[2,8],9:[2,8],10:[2,8],11:[2,8],12:[2,8],13:[2,8],14:[2,8],15:[2,8],16:[1,16],18:[2,8]},{5:[2,9],6:[2,9],7:[2,9],8:[2,9],9:[2,9],10:[2,9],11:[2,9],12:[2,9],13:[2,9],14:[2,9],15:[2,9],16:[1,16],18:[2,9]},{5:[2,10],6:[2,10],7:[2,10],8:[2,10],9:[2,10],10:[2,10],11:[2,10],12:[2,10],13:[2,10],14:[2,10],15:[2,10],
16:[1,16],18:[2,10]},{5:[2,11],6:[2,11],7:[2,11],8:[2,11],9:[2,11],10:[2,11],11:[2,11],12:[2,11],13:[2,11],14:[2,11],15:[2,11],16:[2,11],18:[2,11]},{5:[2,12],6:[2,12],7:[2,12],8:[2,12],9:[2,12],10:[2,12],11:[2,12],12:[2,12],13:[2,12],14:[2,12],15:[2,12],16:[2,12],18:[2,12]},{4:30,17:[1,3],19:[1,4],20:[1,5]},{5:[2,2],6:[1,7],7:[2,2],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,2]}],defaultActions:{6:[2,1]},parseError:function(a,b){throw Error(a);},parse:function(a){function b(){var a=
e.lexer.lex()||1;"number"!==typeof a&&(a=e.symbols_[a]||a);return a}var e=this,c=[0],g=[null],d=[],h=this.table,f="",k=0,l=0,w=0;this.lexer.setInput(a);this.lexer.yy=this.yy;this.yy.lexer=this.lexer;"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});a=this.lexer.yylloc;d.push(a);"function"===typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var n,x,p,q,z={},u,y;;){p=c[c.length-1];this.defaultActions[p]?q=this.defaultActions[p]:(null==n&&(n=b()),q=h[p]&&h[p][n]);if("undefined"===
typeof q||!q.length||!q[0]){if(!w){x=[];for(u in h[p])this.terminals_[u]&&2<u&&x.push("'"+this.terminals_[u]+"'");var v="";v=this.lexer.showPosition?"Parse error on line "+(k+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+x.join(", ")+", got '"+this.terminals_[n]+"'":"Parse error on line "+(k+1)+": Unexpected "+(1==n?"end of input":"'"+(this.terminals_[n]||n)+"'");this.parseError(v,{text:this.lexer.match,token:this.terminals_[n]||n,line:this.lexer.yylineno,loc:a,expected:x})}if(3==w){if(1==n)throw Error(v||
"Parsing halted.");l=this.lexer.yyleng;f=this.lexer.yytext;k=this.lexer.yylineno;a=this.lexer.yylloc;n=b()}for(;!((2).toString()in h[p]);){if(0==p)throw Error(v||"Parsing halted.");c.length-=2;--g.length;--d.length;p=c[c.length-1]}x=n;n=2;p=c[c.length-1];q=h[p]&&h[p][2];w=3}if(q[0]instanceof Array&&1<q.length)throw Error("Parse Error: multiple actions possible at state: "+p+", token: "+n);switch(q[0]){case 1:c.push(n);g.push(this.lexer.yytext);d.push(this.lexer.yylloc);c.push(q[1]);n=null;x?(n=x,
x=null):(l=this.lexer.yyleng,f=this.lexer.yytext,k=this.lexer.yylineno,a=this.lexer.yylloc,0<w&&w--);break;case 2:y=this.productions_[q[1]][1];z.$=g[g.length-y];z._$={first_line:d[d.length-(y||1)].first_line,last_line:d[d.length-1].last_line,first_column:d[d.length-(y||1)].first_column,last_column:d[d.length-1].last_column};p=this.performAction.call(z,f,l,k,this.yy,q[1],g,d);if("undefined"!==typeof p)return p;y&&(c=c.slice(0,-2*y),g=g.slice(0,-1*y),d=d.slice(0,-1*y));c.push(this.productions_[q[1]][0]);
g.push(z.$);d.push(z._$);q=h[c[c.length-2]][c[c.length-1]];c.push(q);break;case 3:return!0}}}},b=function(){return{EOF:1,parseError:function(a,b){if(this.yy.parseError)this.yy.parseError(a,b);else throw Error(a);},setInput:function(a){this._input=a;this._more=this._less=this.done=!1;this.yylineno=this.yyleng=0;this.yytext=this.matched=this.match="";this.conditionStack=["INITIAL"];this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};return this},input:function(){var a=this._input[0];
this.yytext+=a;this.yyleng++;this.match+=a;this.matched+=a;a.match(/\n/)&&this.yylineno++;this._input=this._input.slice(1);return a},unput:function(a){this._input=a+this._input;return this},more:function(){this._more=!0;return this},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(20<a.length?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;20>a.length&&(a+=this._input.substr(0,20-a.length));return(a.substr(0,20)+(20<
a.length?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=Array(a.length+1).join("-");return a+this.upcomingInput()+"\n"+b+"^"},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,b;this._more||(this.match=this.yytext="");for(var c=this._currentRules(),l=0;l<c.length;l++)if(a=this._input.match(this.rules[c[l]])){if(b=a[0].match(/\n.*/g))this.yylineno+=b.length;this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,
last_column:b?b[b.length-1].length-1:this.yylloc.last_column+a[0].length};this.yytext+=a[0];this.match+=a[0];this.matches=a;this.yyleng=this.yytext.length;this._more=!1;this._input=this._input.slice(a[0].length);this.matched+=a[0];if(a=this.performAction.call(this,this.yy,this,c[l],this.conditionStack[this.conditionStack.length-1]))return a;return}if(""===this._input)return this.EOF;this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,
line:this.yylineno})},lex:function(){var a=this.next();return"undefined"!==typeof a?a:this.lex()},begin:function(a){this.conditionStack.push(a)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(a){this.begin(a)},performAction:function(a,b,c,l){switch(c){case 1:return 20;case 2:return 19;case 3:return 8;
case 4:return 9;case 5:return 6;case 6:return 7;case 7:return 11;case 8:return 13;case 9:return 10;case 10:return 12;case 11:return 14;case 12:return 15;case 13:return 16;case 14:return 17;case 15:return 18;case 16:return 5;case 17:return"INVALID"}},rules:[/^\s+/,/^[0-9]+(\.[0-9]+)?\b/,/^n\b/,/^\|\|/,/^&&/,/^\?/,/^:/,/^<=/,/^>=/,/^</,/^>/,/^!=/,/^==/,/^%/,/^\(/,/^\)/,/^$/,/^./],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],inclusive:!0}}}}();a.lexer=b;return a}();"undefined"!==
typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=c),exports.Jed=c):("function"===typeof define&&define.amd&&define(function(){return c}),F.Jed=c)})(this);