From df8d1bc006b21ab48a85e9a85424040762ddb9f3 Mon Sep 17 00:00:00 2001 From: Peter W Date: Mon, 19 Oct 2015 23:02:01 +1300 Subject: [PATCH 01/40] speed tx time: switch to minified versions of handlebars / jquery-ui - Simulations in chrome developer tools show this changes download times from 2.2min and 2.0min to 1.4min and 1.3min for jquery-ui and handlebars JS files, on a GPRS (50Kbps) network speed, decreasing overall Load time from 2.8min to 2.4min. --- index.html | 4 ++-- js/vendor/handlebars.js | 2 +- js/vendor/handlebars.min-v3.0.0.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 js/vendor/handlebars.min-v3.0.0.js diff --git a/index.html b/index.html index 93795e3..bf717fe 100644 --- a/index.html +++ b/index.html @@ -356,10 +356,10 @@

Results

- + - + diff --git a/js/vendor/handlebars.js b/js/vendor/handlebars.js index c966fe0..ac191b8 120000 --- a/js/vendor/handlebars.js +++ b/js/vendor/handlebars.js @@ -1 +1 @@ -handlebars-v3.0.0.js \ No newline at end of file +handlebars.min-v3.0.0.js \ No newline at end of file diff --git a/js/vendor/handlebars.min-v3.0.0.js b/js/vendor/handlebars.min-v3.0.0.js new file mode 100644 index 0000000..839ce0c --- /dev/null +++ b/js/vendor/handlebars.min-v3.0.0.js @@ -0,0 +1,28 @@ +/*! + + handlebars v3.0.0 + +Copyright (C) 2011-2014 by Yehuda Katz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +@license +*/ +!function(a,b){"function"==typeof define&&define.amd?define([],b):"object"==typeof exports?module.exports=b():a.Handlebars=b()}(this,function(){var a=function(){"use strict";function a(a){return i[a]}function b(a){for(var b=1;bc;c++)if(a[c]===b)return c;return-1}function d(b){return b&&b.toHTML?b.toHTML():null==b?"":b?(b=""+b,k.test(b)?b.replace(j,a):b):b+""}function e(a){return a||0===a?n(a)&&0===a.length?!0:!1:!0}function f(a,b){return a.path=b,a}function g(a,b){return(a?a+".":"")+b}var h={},i={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},j=/[&<>"'`]/g,k=/[&<>"'`]/;h.extend=b;var l=Object.prototype.toString;h.toString=l;var m=function(a){return"function"==typeof a};m(/x/)&&(m=function(a){return"function"==typeof a&&"[object Function]"===l.call(a)});var m;h.isFunction=m;var n=Array.isArray||function(a){return a&&"object"==typeof a?"[object Array]"===l.call(a):!1};return h.isArray=n,h.indexOf=c,h.escapeExpression=d,h.isEmpty=e,h.blockParams=f,h.appendContextPath=g,h}(),b=function(){"use strict";function a(a,b){var d,e,f=b&&b.loc;f&&(d=f.start.line,e=f.start.column,a+=" - "+d+":"+e);for(var g=Error.prototype.constructor.call(this,a),h=0;h0?(c.ids&&(c.ids=[c.name]),a.helpers.each(b,c)):d(this);if(c.data&&c.ids){var g=q(c.data);g.contextPath=f.appendContextPath(c.data.contextPath,c.name),c={data:g}}return e(b,c)}),a.registerHelper("each",function(a,b){function c(b,c,g){d&&(d.key=b,d.index=c,d.first=0===c,d.last=!!g,e&&(d.contextPath=e+b)),m+=h(a[b],{data:d,blockParams:f.blockParams([a[b],b],[e+b,null])})}if(!b)throw new g("Must pass iterator to #each");var d,e,h=b.fn,i=b.inverse,j=0,m="";if(b.data&&b.ids&&(e=f.appendContextPath(b.data.contextPath,b.ids[0])+"."),l(a)&&(a=a.call(this)),b.data&&(d=q(b.data)),a&&"object"==typeof a)if(k(a))for(var n=a.length;n>j;j++)c(j,j,j===a.length-1);else{var o;for(var p in a)a.hasOwnProperty(p)&&(o&&c(o,j-1),o=p,j++);o&&c(o,j-1,!0)}return 0===j&&(m=i(this)),m}),a.registerHelper("if",function(a,b){return l(a)&&(a=a.call(this)),!b.hash.includeZero&&!a||f.isEmpty(a)?b.inverse(this):b.fn(this)}),a.registerHelper("unless",function(b,c){return a.helpers["if"].call(this,b,{fn:c.inverse,inverse:c.fn,hash:c.hash})}),a.registerHelper("with",function(a,b){l(a)&&(a=a.call(this));var c=b.fn;if(f.isEmpty(a))return b.inverse(this);if(b.data&&b.ids){var d=q(b.data);d.contextPath=f.appendContextPath(b.data.contextPath,b.ids[0]),b={data:d}}return c(a,b)}),a.registerHelper("log",function(b,c){var d=c.data&&null!=c.data.level?parseInt(c.data.level,10):1;a.log(d,b)}),a.registerHelper("lookup",function(a,b){return a&&a[b]})}var e={},f=a,g=b,h="3.0.0";e.VERSION=h;var i=6;e.COMPILER_REVISION=i;var j={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:"== 1.x.x",5:"== 2.0.0-alpha.x",6:">= 2.0.0-beta.1"};e.REVISION_CHANGES=j;var k=f.isArray,l=f.isFunction,m=f.toString,n="[object Object]";e.HandlebarsEnvironment=c,c.prototype={constructor:c,logger:o,log:p,registerHelper:function(a,b){if(m.call(a)===n){if(b)throw new g("Arg not supported with multiple helpers");f.extend(this.helpers,a)}else this.helpers[a]=b},unregisterHelper:function(a){delete this.helpers[a]},registerPartial:function(a,b){if(m.call(a)===n)f.extend(this.partials,a);else{if("undefined"==typeof b)throw new g("Attempting to register a partial as undefined");this.partials[a]=b}},unregisterPartial:function(a){delete this.partials[a]}};var o={methodMap:{0:"debug",1:"info",2:"warn",3:"error"},DEBUG:0,INFO:1,WARN:2,ERROR:3,level:1,log:function(a,b){if("undefined"!=typeof console&&o.level<=a){var c=o.methodMap[a];(console[c]||console.log).call(console,b)}}};e.logger=o;var p=o.log;e.log=p;var q=function(a){var b=f.extend({},a);return b._parent=a,b};return e.createFrame=q,e}(a,b),d=function(){"use strict";function a(a){this.string=a}var b;return a.prototype.toString=a.prototype.toHTML=function(){return""+this.string},b=a}(),e=function(a,b,c){"use strict";function d(a){var b=a&&a[0]||1,c=n;if(b!==c){if(c>b){var d=o[c],e=o[b];throw new m("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+d+") or downgrade your runtime to an older version ("+e+").")}throw new m("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+a[1]+").")}}function e(a,b){if(!b)throw new m("No environment passed to template");if(!a||!a.main)throw new m("Unknown template object: "+typeof a);b.VM.checkRevision(a.compiler);var c=function(c,d,e){e.hash&&(d=l.extend({},d,e.hash)),c=b.VM.resolvePartial.call(this,c,d,e);var f=b.VM.invokePartial.call(this,c,d,e);if(null==f&&b.compile&&(e.partials[e.name]=b.compile(c,a.compilerOptions,b),f=e.partials[e.name](d,e)),null!=f){if(e.indent){for(var g=f.split("\n"),h=0,i=g.length;i>h&&(g[h]||h+1!==i);h++)g[h]=e.indent+g[h];f=g.join("\n")}return f}throw new m("The partial "+e.name+" could not be compiled when running in runtime-only mode")},d={strict:function(a,b){if(!(b in a))throw new m('"'+b+'" not defined in '+a);return a[b]},lookup:function(a,b){for(var c=a.length,d=0;c>d;d++)if(a[d]&&null!=a[d][b])return a[d][b]},lambda:function(a,b){return"function"==typeof a?a.call(b):a},escapeExpression:l.escapeExpression,invokePartial:c,fn:function(b){return a[b]},programs:[],program:function(a,b,c,d,e){var g=this.programs[a],h=this.fn(a);return b||e||d||c?g=f(this,a,h,b,c,d,e):g||(g=this.programs[a]=f(this,a,h)),g},data:function(a,b){for(;a&&b--;)a=a._parent;return a},merge:function(a,b){var c=a||b;return a&&b&&a!==b&&(c=l.extend({},b,a)),c},noop:b.VM.noop,compilerInfo:a.compiler},e=function(b,c){c=c||{};var f=c.data;e._setup(c),!c.partial&&a.useData&&(f=j(b,f));var g,h=a.useBlockParams?[]:void 0;return a.useDepths&&(g=c.depths?[b].concat(c.depths):[b]),a.main.call(d,b,d.helpers,d.partials,f,h,g)};return e.isTop=!0,e._setup=function(c){c.partial?(d.helpers=c.helpers,d.partials=c.partials):(d.helpers=d.merge(c.helpers,b.helpers),a.usePartial&&(d.partials=d.merge(c.partials,b.partials)))},e._child=function(b,c,e,g){if(a.useBlockParams&&!e)throw new m("must pass block params");if(a.useDepths&&!g)throw new m("must pass parent depths");return f(d,b,a[b],c,0,e,g)},e}function f(a,b,c,d,e,f,g){var h=function(b,e){return e=e||{},c.call(a,b,a.helpers,a.partials,e.data||d,f&&[e.blockParams].concat(f),g&&[b].concat(g))};return h.program=b,h.depth=g?g.length:0,h.blockParams=e||0,h}function g(a,b,c){return a?a.call||c.name||(c.name=a,a=c.partials[a]):a=c.partials[c.name],a}function h(a,b,c){if(c.partial=!0,void 0===a)throw new m("The partial "+c.name+" could not be found");return a instanceof Function?a(b,c):void 0}function i(){return""}function j(a,b){return b&&"root"in b||(b=b?p(b):{},b.root=a),b}var k={},l=a,m=b,n=c.COMPILER_REVISION,o=c.REVISION_CHANGES,p=c.createFrame;return k.checkRevision=d,k.template=e,k.program=f,k.resolvePartial=g,k.invokePartial=h,k.noop=i,k}(a,b,c),f=function(a,b,c,d,e){"use strict";var f,g=a,h=b,i=c,j=d,k=e,l=function(){var a=new g.HandlebarsEnvironment;return j.extend(a,g),a.SafeString=h,a.Exception=i,a.Utils=j,a.escapeExpression=j.escapeExpression,a.VM=k,a.template=function(b){return k.template(b,a)},a},m=l();m.create=l;var n="undefined"!=typeof global?global:window,o=n.Handlebars;return m.noConflict=function(){n.Handlebars===m&&(n.Handlebars=o)},m["default"]=m,f=m}(c,d,b,a,e),g=function(){"use strict";var a,b={Program:function(a,b,c,d){this.loc=d,this.type="Program",this.body=a,this.blockParams=b,this.strip=c},MustacheStatement:function(a,b,c,d,e,f){this.loc=f,this.type="MustacheStatement",this.path=a,this.params=b||[],this.hash=c,this.escaped=d,this.strip=e},BlockStatement:function(a,b,c,d,e,f,g,h,i){this.loc=i,this.type="BlockStatement",this.path=a,this.params=b||[],this.hash=c,this.program=d,this.inverse=e,this.openStrip=f,this.inverseStrip=g,this.closeStrip=h},PartialStatement:function(a,b,c,d,e){this.loc=e,this.type="PartialStatement",this.name=a,this.params=b||[],this.hash=c,this.indent="",this.strip=d},ContentStatement:function(a,b){this.loc=b,this.type="ContentStatement",this.original=this.value=a},CommentStatement:function(a,b,c){this.loc=c,this.type="CommentStatement",this.value=a,this.strip=b},SubExpression:function(a,b,c,d){this.loc=d,this.type="SubExpression",this.path=a,this.params=b||[],this.hash=c},PathExpression:function(a,b,c,d,e){this.loc=e,this.type="PathExpression",this.data=a,this.original=d,this.parts=c,this.depth=b},StringLiteral:function(a,b){this.loc=b,this.type="StringLiteral",this.original=this.value=a},NumberLiteral:function(a,b){this.loc=b,this.type="NumberLiteral",this.original=this.value=Number(a)},BooleanLiteral:function(a,b){this.loc=b,this.type="BooleanLiteral",this.original=this.value="true"===a},Hash:function(a,b){this.loc=b,this.type="Hash",this.pairs=a},HashPair:function(a,b,c){this.loc=c,this.type="HashPair",this.key=a,this.value=b},helpers:{helperExpression:function(a){return!("SubExpression"!==a.type&&!a.params.length&&!a.hash)},scopedId:function(a){return/^\.|this\b/.test(a.original)},simpleId:function(a){return 1===a.parts.length&&!b.helpers.scopedId(a)&&!a.depth}}};return a=b}(),h=function(){"use strict";var a,b=function(){function a(){this.yy={}}var b={trace:function(){},yy:{},symbols_:{error:2,root:3,program:4,EOF:5,program_repetition0:6,statement:7,mustache:8,block:9,rawBlock:10,partial:11,content:12,COMMENT:13,CONTENT:14,openRawBlock:15,END_RAW_BLOCK:16,OPEN_RAW_BLOCK:17,helperName:18,openRawBlock_repetition0:19,openRawBlock_option0:20,CLOSE_RAW_BLOCK:21,openBlock:22,block_option0:23,closeBlock:24,openInverse:25,block_option1:26,OPEN_BLOCK:27,openBlock_repetition0:28,openBlock_option0:29,openBlock_option1:30,CLOSE:31,OPEN_INVERSE:32,openInverse_repetition0:33,openInverse_option0:34,openInverse_option1:35,openInverseChain:36,OPEN_INVERSE_CHAIN:37,openInverseChain_repetition0:38,openInverseChain_option0:39,openInverseChain_option1:40,inverseAndProgram:41,INVERSE:42,inverseChain:43,inverseChain_option0:44,OPEN_ENDBLOCK:45,OPEN:46,mustache_repetition0:47,mustache_option0:48,OPEN_UNESCAPED:49,mustache_repetition1:50,mustache_option1:51,CLOSE_UNESCAPED:52,OPEN_PARTIAL:53,partialName:54,partial_repetition0:55,partial_option0:56,param:57,sexpr:58,OPEN_SEXPR:59,sexpr_repetition0:60,sexpr_option0:61,CLOSE_SEXPR:62,hash:63,hash_repetition_plus0:64,hashSegment:65,ID:66,EQUALS:67,blockParams:68,OPEN_BLOCK_PARAMS:69,blockParams_repetition_plus0:70,CLOSE_BLOCK_PARAMS:71,path:72,dataName:73,STRING:74,NUMBER:75,BOOLEAN:76,DATA:77,pathSegments:78,SEP:79,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",13:"COMMENT",14:"CONTENT",16:"END_RAW_BLOCK",17:"OPEN_RAW_BLOCK",21:"CLOSE_RAW_BLOCK",27:"OPEN_BLOCK",31:"CLOSE",32:"OPEN_INVERSE",37:"OPEN_INVERSE_CHAIN",42:"INVERSE",45:"OPEN_ENDBLOCK",46:"OPEN",49:"OPEN_UNESCAPED",52:"CLOSE_UNESCAPED",53:"OPEN_PARTIAL",59:"OPEN_SEXPR",62:"CLOSE_SEXPR",66:"ID",67:"EQUALS",69:"OPEN_BLOCK_PARAMS",71:"CLOSE_BLOCK_PARAMS",74:"STRING",75:"NUMBER",76:"BOOLEAN",77:"DATA",79:"SEP"},productions_:[0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[12,1],[10,3],[15,5],[9,4],[9,4],[22,6],[25,6],[36,6],[41,2],[43,3],[43,1],[24,3],[8,5],[8,5],[11,5],[57,1],[57,1],[58,5],[63,1],[65,3],[68,3],[18,1],[18,1],[18,1],[18,1],[18,1],[54,1],[54,1],[73,2],[72,1],[78,3],[78,1],[6,0],[6,2],[19,0],[19,2],[20,0],[20,1],[23,0],[23,1],[26,0],[26,1],[28,0],[28,2],[29,0],[29,1],[30,0],[30,1],[33,0],[33,2],[34,0],[34,1],[35,0],[35,1],[38,0],[38,2],[39,0],[39,1],[40,0],[40,1],[44,0],[44,1],[47,0],[47,2],[48,0],[48,1],[50,0],[50,2],[51,0],[51,1],[55,0],[55,2],[56,0],[56,1],[60,0],[60,2],[61,0],[61,1],[64,1],[64,2],[70,1],[70,2]],performAction:function(a,b,c,d,e,f){var g=f.length-1;switch(e){case 1:return f[g-1];case 2:this.$=new d.Program(f[g],null,{},d.locInfo(this._$));break;case 3:this.$=f[g];break;case 4:this.$=f[g];break;case 5:this.$=f[g];break;case 6:this.$=f[g];break;case 7:this.$=f[g];break;case 8:this.$=new d.CommentStatement(d.stripComment(f[g]),d.stripFlags(f[g],f[g]),d.locInfo(this._$));break;case 9:this.$=new d.ContentStatement(f[g],d.locInfo(this._$));break;case 10:this.$=d.prepareRawBlock(f[g-2],f[g-1],f[g],this._$);break;case 11:this.$={path:f[g-3],params:f[g-2],hash:f[g-1]};break;case 12:this.$=d.prepareBlock(f[g-3],f[g-2],f[g-1],f[g],!1,this._$);break;case 13:this.$=d.prepareBlock(f[g-3],f[g-2],f[g-1],f[g],!0,this._$);break;case 14:this.$={path:f[g-4],params:f[g-3],hash:f[g-2],blockParams:f[g-1],strip:d.stripFlags(f[g-5],f[g])};break;case 15:this.$={path:f[g-4],params:f[g-3],hash:f[g-2],blockParams:f[g-1],strip:d.stripFlags(f[g-5],f[g])};break;case 16:this.$={path:f[g-4],params:f[g-3],hash:f[g-2],blockParams:f[g-1],strip:d.stripFlags(f[g-5],f[g])};break;case 17:this.$={strip:d.stripFlags(f[g-1],f[g-1]),program:f[g]};break;case 18:var h=d.prepareBlock(f[g-2],f[g-1],f[g],f[g],!1,this._$),i=new d.Program([h],null,{},d.locInfo(this._$));i.chained=!0,this.$={strip:f[g-2].strip,program:i,chain:!0};break;case 19:this.$=f[g];break;case 20:this.$={path:f[g-1],strip:d.stripFlags(f[g-2],f[g])};break;case 21:this.$=d.prepareMustache(f[g-3],f[g-2],f[g-1],f[g-4],d.stripFlags(f[g-4],f[g]),this._$);break;case 22:this.$=d.prepareMustache(f[g-3],f[g-2],f[g-1],f[g-4],d.stripFlags(f[g-4],f[g]),this._$);break;case 23:this.$=new d.PartialStatement(f[g-3],f[g-2],f[g-1],d.stripFlags(f[g-4],f[g]),d.locInfo(this._$));break;case 24:this.$=f[g];break;case 25:this.$=f[g];break;case 26:this.$=new d.SubExpression(f[g-3],f[g-2],f[g-1],d.locInfo(this._$));break;case 27:this.$=new d.Hash(f[g],d.locInfo(this._$));break;case 28:this.$=new d.HashPair(f[g-2],f[g],d.locInfo(this._$));break;case 29:this.$=f[g-1];break;case 30:this.$=f[g];break;case 31:this.$=f[g];break;case 32:this.$=new d.StringLiteral(f[g],d.locInfo(this._$));break;case 33:this.$=new d.NumberLiteral(f[g],d.locInfo(this._$));break;case 34:this.$=new d.BooleanLiteral(f[g],d.locInfo(this._$));break;case 35:this.$=f[g];break;case 36:this.$=f[g];break;case 37:this.$=d.preparePath(!0,f[g],this._$);break;case 38:this.$=d.preparePath(!1,f[g],this._$);break;case 39:f[g-2].push({part:f[g],separator:f[g-1]}),this.$=f[g-2];break;case 40:this.$=[{part:f[g]}];break;case 41:this.$=[];break;case 42:f[g-1].push(f[g]);break;case 43:this.$=[];break;case 44:f[g-1].push(f[g]);break;case 51:this.$=[];break;case 52:f[g-1].push(f[g]);break;case 57:this.$=[];break;case 58:f[g-1].push(f[g]);break;case 63:this.$=[];break;case 64:f[g-1].push(f[g]);break;case 71:this.$=[];break;case 72:f[g-1].push(f[g]);break;case 75:this.$=[];break;case 76:f[g-1].push(f[g]);break;case 79:this.$=[];break;case 80:f[g-1].push(f[g]);break;case 83:this.$=[];break;case 84:f[g-1].push(f[g]);break;case 87:this.$=[f[g]];break;case 88:f[g-1].push(f[g]);break;case 89:this.$=[f[g]];break;case 90:f[g-1].push(f[g])}},table:[{3:1,4:2,5:[2,41],6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],46:[2,41],49:[2,41],53:[2,41]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:10,13:[1,11],14:[1,18],15:16,17:[1,21],22:14,25:15,27:[1,19],32:[1,20],37:[2,2],42:[2,2],45:[2,2],46:[1,12],49:[1,13],53:[1,17]},{1:[2,1]},{5:[2,42],13:[2,42],14:[2,42],17:[2,42],27:[2,42],32:[2,42],37:[2,42],42:[2,42],45:[2,42],46:[2,42],49:[2,42],53:[2,42]},{5:[2,3],13:[2,3],14:[2,3],17:[2,3],27:[2,3],32:[2,3],37:[2,3],42:[2,3],45:[2,3],46:[2,3],49:[2,3],53:[2,3]},{5:[2,4],13:[2,4],14:[2,4],17:[2,4],27:[2,4],32:[2,4],37:[2,4],42:[2,4],45:[2,4],46:[2,4],49:[2,4],53:[2,4]},{5:[2,5],13:[2,5],14:[2,5],17:[2,5],27:[2,5],32:[2,5],37:[2,5],42:[2,5],45:[2,5],46:[2,5],49:[2,5],53:[2,5]},{5:[2,6],13:[2,6],14:[2,6],17:[2,6],27:[2,6],32:[2,6],37:[2,6],42:[2,6],45:[2,6],46:[2,6],49:[2,6],53:[2,6]},{5:[2,7],13:[2,7],14:[2,7],17:[2,7],27:[2,7],32:[2,7],37:[2,7],42:[2,7],45:[2,7],46:[2,7],49:[2,7],53:[2,7]},{5:[2,8],13:[2,8],14:[2,8],17:[2,8],27:[2,8],32:[2,8],37:[2,8],42:[2,8],45:[2,8],46:[2,8],49:[2,8],53:[2,8]},{18:22,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:31,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{4:32,6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],37:[2,41],42:[2,41],45:[2,41],46:[2,41],49:[2,41],53:[2,41]},{4:33,6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],42:[2,41],45:[2,41],46:[2,41],49:[2,41],53:[2,41]},{12:34,14:[1,18]},{18:36,54:35,58:37,59:[1,38],66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{5:[2,9],13:[2,9],14:[2,9],16:[2,9],17:[2,9],27:[2,9],32:[2,9],37:[2,9],42:[2,9],45:[2,9],46:[2,9],49:[2,9],53:[2,9]},{18:39,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:40,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:41,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{31:[2,71],47:42,59:[2,71],66:[2,71],74:[2,71],75:[2,71],76:[2,71],77:[2,71]},{21:[2,30],31:[2,30],52:[2,30],59:[2,30],62:[2,30],66:[2,30],69:[2,30],74:[2,30],75:[2,30],76:[2,30],77:[2,30]},{21:[2,31],31:[2,31],52:[2,31],59:[2,31],62:[2,31],66:[2,31],69:[2,31],74:[2,31],75:[2,31],76:[2,31],77:[2,31]},{21:[2,32],31:[2,32],52:[2,32],59:[2,32],62:[2,32],66:[2,32],69:[2,32],74:[2,32],75:[2,32],76:[2,32],77:[2,32]},{21:[2,33],31:[2,33],52:[2,33],59:[2,33],62:[2,33],66:[2,33],69:[2,33],74:[2,33],75:[2,33],76:[2,33],77:[2,33]},{21:[2,34],31:[2,34],52:[2,34],59:[2,34],62:[2,34],66:[2,34],69:[2,34],74:[2,34],75:[2,34],76:[2,34],77:[2,34]},{21:[2,38],31:[2,38],52:[2,38],59:[2,38],62:[2,38],66:[2,38],69:[2,38],74:[2,38],75:[2,38],76:[2,38],77:[2,38],79:[1,43]},{66:[1,30],78:44},{21:[2,40],31:[2,40],52:[2,40],59:[2,40],62:[2,40],66:[2,40],69:[2,40],74:[2,40],75:[2,40],76:[2,40],77:[2,40],79:[2,40]},{50:45,52:[2,75],59:[2,75],66:[2,75],74:[2,75],75:[2,75],76:[2,75],77:[2,75]},{23:46,36:48,37:[1,50],41:49,42:[1,51],43:47,45:[2,47]},{26:52,41:53,42:[1,51],45:[2,49]},{16:[1,54]},{31:[2,79],55:55,59:[2,79],66:[2,79],74:[2,79],75:[2,79],76:[2,79],77:[2,79]},{31:[2,35],59:[2,35],66:[2,35],74:[2,35],75:[2,35],76:[2,35],77:[2,35]},{31:[2,36],59:[2,36],66:[2,36],74:[2,36],75:[2,36],76:[2,36],77:[2,36]},{18:56,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{28:57,31:[2,51],59:[2,51],66:[2,51],69:[2,51],74:[2,51],75:[2,51],76:[2,51],77:[2,51]},{31:[2,57],33:58,59:[2,57],66:[2,57],69:[2,57],74:[2,57],75:[2,57],76:[2,57],77:[2,57]},{19:59,21:[2,43],59:[2,43],66:[2,43],74:[2,43],75:[2,43],76:[2,43],77:[2,43]},{18:63,31:[2,73],48:60,57:61,58:64,59:[1,38],63:62,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{66:[1,68]},{21:[2,37],31:[2,37],52:[2,37],59:[2,37],62:[2,37],66:[2,37],69:[2,37],74:[2,37],75:[2,37],76:[2,37],77:[2,37],79:[1,43]},{18:63,51:69,52:[2,77],57:70,58:64,59:[1,38],63:71,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{24:72,45:[1,73]},{45:[2,48]},{4:74,6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],37:[2,41],42:[2,41],45:[2,41],46:[2,41],49:[2,41],53:[2,41]},{45:[2,19]},{18:75,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{4:76,6:3,13:[2,41],14:[2,41],17:[2,41],27:[2,41],32:[2,41],45:[2,41],46:[2,41],49:[2,41],53:[2,41]},{24:77,45:[1,73]},{45:[2,50]},{5:[2,10],13:[2,10],14:[2,10],17:[2,10],27:[2,10],32:[2,10],37:[2,10],42:[2,10],45:[2,10],46:[2,10],49:[2,10],53:[2,10]},{18:63,31:[2,81],56:78,57:79,58:64,59:[1,38],63:80,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{59:[2,83],60:81,62:[2,83],66:[2,83],74:[2,83],75:[2,83],76:[2,83],77:[2,83]},{18:63,29:82,31:[2,53],57:83,58:64,59:[1,38],63:84,64:65,65:66,66:[1,67],69:[2,53],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:63,31:[2,59],34:85,57:86,58:64,59:[1,38],63:87,64:65,65:66,66:[1,67],69:[2,59],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{18:63,20:88,21:[2,45],57:89,58:64,59:[1,38],63:90,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{31:[1,91]},{31:[2,72],59:[2,72],66:[2,72],74:[2,72],75:[2,72],76:[2,72],77:[2,72]},{31:[2,74]},{21:[2,24],31:[2,24],52:[2,24],59:[2,24],62:[2,24],66:[2,24],69:[2,24],74:[2,24],75:[2,24],76:[2,24],77:[2,24]},{21:[2,25],31:[2,25],52:[2,25],59:[2,25],62:[2,25],66:[2,25],69:[2,25],74:[2,25],75:[2,25],76:[2,25],77:[2,25]},{21:[2,27],31:[2,27],52:[2,27],62:[2,27],65:92,66:[1,93],69:[2,27]},{21:[2,87],31:[2,87],52:[2,87],62:[2,87],66:[2,87],69:[2,87]},{21:[2,40],31:[2,40],52:[2,40],59:[2,40],62:[2,40],66:[2,40],67:[1,94],69:[2,40],74:[2,40],75:[2,40],76:[2,40],77:[2,40],79:[2,40]},{21:[2,39],31:[2,39],52:[2,39],59:[2,39],62:[2,39],66:[2,39],69:[2,39],74:[2,39],75:[2,39],76:[2,39],77:[2,39],79:[2,39]},{52:[1,95]},{52:[2,76],59:[2,76],66:[2,76],74:[2,76],75:[2,76],76:[2,76],77:[2,76]},{52:[2,78]},{5:[2,12],13:[2,12],14:[2,12],17:[2,12],27:[2,12],32:[2,12],37:[2,12],42:[2,12],45:[2,12],46:[2,12],49:[2,12],53:[2,12]},{18:96,66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{36:48,37:[1,50],41:49,42:[1,51],43:98,44:97,45:[2,69]},{31:[2,63],38:99,59:[2,63],66:[2,63],69:[2,63],74:[2,63],75:[2,63],76:[2,63],77:[2,63]},{45:[2,17]},{5:[2,13],13:[2,13],14:[2,13],17:[2,13],27:[2,13],32:[2,13],37:[2,13],42:[2,13],45:[2,13],46:[2,13],49:[2,13],53:[2,13]},{31:[1,100]},{31:[2,80],59:[2,80],66:[2,80],74:[2,80],75:[2,80],76:[2,80],77:[2,80]},{31:[2,82]},{18:63,57:102,58:64,59:[1,38],61:101,62:[2,85],63:103,64:65,65:66,66:[1,67],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{30:104,31:[2,55],68:105,69:[1,106]},{31:[2,52],59:[2,52],66:[2,52],69:[2,52],74:[2,52],75:[2,52],76:[2,52],77:[2,52]},{31:[2,54],69:[2,54]},{31:[2,61],35:107,68:108,69:[1,106]},{31:[2,58],59:[2,58],66:[2,58],69:[2,58],74:[2,58],75:[2,58],76:[2,58],77:[2,58]},{31:[2,60],69:[2,60]},{21:[1,109]},{21:[2,44],59:[2,44],66:[2,44],74:[2,44],75:[2,44],76:[2,44],77:[2,44]},{21:[2,46]},{5:[2,21],13:[2,21],14:[2,21],17:[2,21],27:[2,21],32:[2,21],37:[2,21],42:[2,21],45:[2,21],46:[2,21],49:[2,21],53:[2,21]},{21:[2,88],31:[2,88],52:[2,88],62:[2,88],66:[2,88],69:[2,88]},{67:[1,94]},{18:63,57:110,58:64,59:[1,38],66:[1,30],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{5:[2,22],13:[2,22],14:[2,22],17:[2,22],27:[2,22],32:[2,22],37:[2,22],42:[2,22],45:[2,22],46:[2,22],49:[2,22],53:[2,22]},{31:[1,111]},{45:[2,18]},{45:[2,70]},{18:63,31:[2,65],39:112,57:113,58:64,59:[1,38],63:114,64:65,65:66,66:[1,67],69:[2,65],72:23,73:24,74:[1,25],75:[1,26],76:[1,27],77:[1,29],78:28},{5:[2,23],13:[2,23],14:[2,23],17:[2,23],27:[2,23],32:[2,23],37:[2,23],42:[2,23],45:[2,23],46:[2,23],49:[2,23],53:[2,23]},{62:[1,115]},{59:[2,84],62:[2,84],66:[2,84],74:[2,84],75:[2,84],76:[2,84],77:[2,84]},{62:[2,86]},{31:[1,116]},{31:[2,56]},{66:[1,118],70:117},{31:[1,119]},{31:[2,62]},{14:[2,11]},{21:[2,28],31:[2,28],52:[2,28],62:[2,28],66:[2,28],69:[2,28]},{5:[2,20],13:[2,20],14:[2,20],17:[2,20],27:[2,20],32:[2,20],37:[2,20],42:[2,20],45:[2,20],46:[2,20],49:[2,20],53:[2,20]},{31:[2,67],40:120,68:121,69:[1,106]},{31:[2,64],59:[2,64],66:[2,64],69:[2,64],74:[2,64],75:[2,64],76:[2,64],77:[2,64]},{31:[2,66],69:[2,66]},{21:[2,26],31:[2,26],52:[2,26],59:[2,26],62:[2,26],66:[2,26],69:[2,26],74:[2,26],75:[2,26],76:[2,26],77:[2,26]},{13:[2,14],14:[2,14],17:[2,14],27:[2,14],32:[2,14],37:[2,14],42:[2,14],45:[2,14],46:[2,14],49:[2,14],53:[2,14]},{66:[1,123],71:[1,122]},{66:[2,89],71:[2,89]},{13:[2,15],14:[2,15],17:[2,15],27:[2,15],32:[2,15],42:[2,15],45:[2,15],46:[2,15],49:[2,15],53:[2,15]},{31:[1,124]},{31:[2,68]},{31:[2,29]},{66:[2,90],71:[2,90]},{13:[2,16],14:[2,16],17:[2,16],27:[2,16],32:[2,16],37:[2,16],42:[2,16],45:[2,16],46:[2,16],49:[2,16],53:[2,16]}],defaultActions:{4:[2,1],47:[2,48],49:[2,19],53:[2,50],62:[2,74],71:[2,78],76:[2,17],80:[2,82],90:[2,46],97:[2,18],98:[2,70],103:[2,86],105:[2,56],108:[2,62],109:[2,11],121:[2,68],122:[2,29]},parseError:function(a){throw new Error(a)},parse:function(a){function b(){var a;return a=c.lexer.lex()||1,"number"!=typeof a&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0;this.lexer.setInput(a),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,"undefined"==typeof this.lexer.yylloc&&(this.lexer.yylloc={});var l=this.lexer.yylloc;f.push(l);var m=this.lexer.options&&this.lexer.options.ranges;"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var n,o,p,q,r,s,t,u,v,w={};;){if(p=d[d.length-1],this.defaultActions[p]?q=this.defaultActions[p]:((null===n||"undefined"==typeof n)&&(n=b()),q=g[p]&&g[p][n]),"undefined"==typeof q||!q.length||!q[0]){var x="";if(!k){v=[];for(s in g[p])this.terminals_[s]&&s>2&&v.push("'"+this.terminals_[s]+"'");x=this.lexer.showPosition?"Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+v.join(", ")+", got '"+(this.terminals_[n]||n)+"'":"Parse error on line "+(i+1)+": Unexpected "+(1==n?"end of input":"'"+(this.terminals_[n]||n)+"'"),this.parseError(x,{text:this.lexer.match,token:this.terminals_[n]||n,line:this.lexer.yylineno,loc:l,expected:v})}}if(q[0]instanceof Array&&q.length>1)throw new Error("Parse Error: multiple actions possible at state: "+p+", token: "+n);switch(q[0]){case 1:d.push(n),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(q[1]),n=null,o?(n=o,o=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,l=this.lexer.yylloc,k>0&&k--);break;case 2:if(t=this.productions_[q[1]][1],w.$=e[e.length-t],w._$={first_line:f[f.length-(t||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(t||1)].first_column,last_column:f[f.length-1].last_column},m&&(w._$.range=[f[f.length-(t||1)].range[0],f[f.length-1].range[1]]),r=this.performAction.call(w,h,j,i,this.yy,q[1],e,f),"undefined"!=typeof r)return r;t&&(d=d.slice(0,-1*t*2),e=e.slice(0,-1*t),f=f.slice(0,-1*t)),d.push(this.productions_[q[1]][0]),e.push(w.$),f.push(w._$),u=g[d[d.length-2]][d[d.length-1]],d.push(u);break;case 3:return!0}}return!0}},c=function(){var a={EOF:1,parseError:function(a,b){if(!this.yy.parser)throw new Error(a);this.yy.parser.parseError(a,b)},setInput:function(a){return 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},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var b=a.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var b=a.length,c=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b-1),this.offset-=b;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),c.length-1&&(this.yylineno-=c.length-1);var e=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:c?(c.length===d.length?this.yylloc.first_column:0)+d[d.length-c.length].length-c[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[e[0],e[0]+this.yyleng-b]),this},more:function(){return this._more=!0,this},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),b=new 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,c,d,e;this._more||(this.yytext="",this.match="");for(var f=this._currentRules(),g=0;gb[0].length)||(b=c,d=g,this.options.flex));g++);return b?(e=b[0].match(/(?:\r\n?|\n).*/g),e&&(this.yylineno+=e.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:e?e[e.length-1].length-e[e.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+b[0].length},this.yytext+=b[0],this.match+=b[0],this.matches=b,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(b[0].length),this.matched+=b[0],a=this.performAction.call(this,this.yy,this,f[d],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),a?a:void 0):""===this._input?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)}};return a.options={},a.performAction=function(a,b,c,d){function e(a,c){return b.yytext=b.yytext.substr(a,b.yyleng-c)}switch(c){case 0:if("\\\\"===b.yytext.slice(-2)?(e(0,1),this.begin("mu")):"\\"===b.yytext.slice(-1)?(e(0,1),this.begin("emu")):this.begin("mu"),b.yytext)return 14;break;case 1:return 14;case 2:return this.popState(),14;case 3:return b.yytext=b.yytext.substr(5,b.yyleng-9),this.popState(),16;case 4:return 14;case 5:return this.popState(),13;case 6:return 59;case 7:return 62;case 8:return 17;case 9:return this.popState(),this.begin("raw"),21;case 10:return 53;case 11:return 27;case 12:return 45;case 13:return this.popState(),42;case 14:return this.popState(),42;case 15:return 32;case 16:return 37;case 17:return 49;case 18:return 46;case 19:this.unput(b.yytext),this.popState(),this.begin("com");break;case 20:return this.popState(),13;case 21:return 46;case 22:return 67;case 23:return 66;case 24:return 66;case 25:return 79;case 26:break;case 27:return this.popState(),52;case 28:return this.popState(),31;case 29:return b.yytext=e(1,2).replace(/\\"/g,'"'),74;case 30:return b.yytext=e(1,2).replace(/\\'/g,"'"),74;case 31:return 77;case 32:return 76;case 33:return 76;case 34:return 75;case 35:return 69;case 36:return 71;case 37:return 66;case 38:return b.yytext=e(1,2),66;case 39:return"INVALID";case 40:return 5}},a.rules=[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]*?(?=(\{\{\{\{\/)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/],a.conditions={mu:{rules:[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[5],inclusive:!1},raw:{rules:[3,4],inclusive:!1},INITIAL:{rules:[0,1,40],inclusive:!0}},a +}();return b.lexer=c,a.prototype=b,b.Parser=a,new a}();return a=b}(),i=function(a,b){"use strict";function c(){this.parents=[]}var d,e=a,f=b;return c.prototype={constructor:c,mutating:!1,acceptKey:function(a,b){var c=this.accept(a[b]);if(this.mutating){if(c&&(!c.type||!f[c.type]))throw new e('Unexpected node type "'+c.type+'" found when accepting '+b+" on "+a.type);a[b]=c}},acceptRequired:function(a,b){if(this.acceptKey(a,b),!a[b])throw new e(a.type+" requires "+b)},acceptArray:function(a){for(var b=0,c=a.length;c>b;b++)this.acceptKey(a,b),a[b]||(a.splice(b,1),b--,c--)},accept:function(a){if(a){this.current&&this.parents.unshift(this.current),this.current=a;var b=this[a.type](a);return this.current=this.parents.shift(),!this.mutating||b?b:b!==!1?a:void 0}},Program:function(a){this.acceptArray(a.body)},MustacheStatement:function(a){this.acceptRequired(a,"path"),this.acceptArray(a.params),this.acceptKey(a,"hash")},BlockStatement:function(a){this.acceptRequired(a,"path"),this.acceptArray(a.params),this.acceptKey(a,"hash"),this.acceptKey(a,"program"),this.acceptKey(a,"inverse")},PartialStatement:function(a){this.acceptRequired(a,"name"),this.acceptArray(a.params),this.acceptKey(a,"hash")},ContentStatement:function(){},CommentStatement:function(){},SubExpression:function(a){this.acceptRequired(a,"path"),this.acceptArray(a.params),this.acceptKey(a,"hash")},PartialExpression:function(a){this.acceptRequired(a,"name"),this.acceptArray(a.params),this.acceptKey(a,"hash")},PathExpression:function(){},StringLiteral:function(){},NumberLiteral:function(){},BooleanLiteral:function(){},Hash:function(a){this.acceptArray(a.pairs)},HashPair:function(a){this.acceptRequired(a,"value")}},d=c}(b,g),j=function(a){"use strict";function b(){}function c(a,b,c){void 0===b&&(b=a.length);var d=a[b-1],e=a[b-2];return d?"ContentStatement"===d.type?(e||!c?/\r?\n\s*?$/:/(^|\r?\n)\s*?$/).test(d.original):void 0:c}function d(a,b,c){void 0===b&&(b=-1);var d=a[b+1],e=a[b+2];return d?"ContentStatement"===d.type?(e||!c?/^\s*?\r?\n/:/^\s*?(\r?\n|$)/).test(d.original):void 0:c}function e(a,b,c){var d=a[null==b?0:b+1];if(d&&"ContentStatement"===d.type&&(c||!d.rightStripped)){var e=d.value;d.value=d.value.replace(c?/^\s+/:/^[ \t]*\r?\n?/,""),d.rightStripped=d.value!==e}}function f(a,b,c){var d=a[null==b?a.length-1:b-1];if(d&&"ContentStatement"===d.type&&(c||!d.leftStripped)){var e=d.value;return d.value=d.value.replace(c?/\s+$/:/[ \t]+$/,""),d.leftStripped=d.value!==e,d.leftStripped}}var g,h=a;return b.prototype=new h,b.prototype.Program=function(a){var b=!this.isRootSeen;this.isRootSeen=!0;for(var g=a.body,h=0,i=g.length;i>h;h++){var j=g[h],k=this.accept(j);if(k){var l=c(g,h,b),m=d(g,h,b),n=k.openStandalone&&l,o=k.closeStandalone&&m,p=k.inlineStandalone&&l&&m;k.close&&e(g,h,!0),k.open&&f(g,h,!0),p&&(e(g,h),f(g,h)&&"PartialStatement"===j.type&&(j.indent=/([ \t]+$)/.exec(g[h-1].original)[1])),n&&(e((j.program||j.inverse).body),f(g,h)),o&&(e(g,h),f((j.inverse||j.program).body))}}return a},b.prototype.BlockStatement=function(a){this.accept(a.program),this.accept(a.inverse);var b=a.program||a.inverse,g=a.program&&a.inverse,h=g,i=g;if(g&&g.chained)for(h=g.body[0].program;i.chained;)i=i.body[i.body.length-1].program;var j={open:a.openStrip.open,close:a.closeStrip.close,openStandalone:d(b.body),closeStandalone:c((h||b).body)};if(a.openStrip.close&&e(b.body,null,!0),g){var k=a.inverseStrip;k.open&&f(b.body,null,!0),k.close&&e(h.body,null,!0),a.closeStrip.open&&f(i.body,null,!0),c(b.body)&&d(h.body)&&(f(b.body),e(h.body))}else a.closeStrip.open&&f(b.body,null,!0);return j},b.prototype.MustacheStatement=function(a){return a.strip},b.prototype.PartialStatement=b.prototype.CommentStatement=function(a){var b=a.strip||{};return{inlineStandalone:!0,open:b.open,close:b.close}},g=b}(i),k=function(a){"use strict";function b(a,b){this.source=a,this.start={line:b.first_line,column:b.first_column},this.end={line:b.last_line,column:b.last_column}}function c(a,b){return{open:"~"===a.charAt(2),close:"~"===b.charAt(b.length-3)}}function d(a){return a.replace(/^\{\{~?\!-?-?/,"").replace(/-?-?~?\}\}$/,"")}function e(a,b,c){c=this.locInfo(c);for(var d=a?"@":"",e=[],f=0,g="",h=0,i=b.length;i>h;h++){var k=b[h].part;if(d+=(b[h].separator||"")+k,".."===k||"."===k||"this"===k){if(e.length>0)throw new j("Invalid path: "+d,{loc:c});".."===k&&(f++,g+="../")}else e.push(k)}return new this.PathExpression(a,f,e,d,c)}function f(a,b,c,d,e,f){var g=d.charAt(3)||d.charAt(2),h="{"!==g&&"&"!==g;return new this.MustacheStatement(a,b,c,h,e,this.locInfo(f))}function g(a,b,c,d){if(a.path.original!==c){var e={loc:a.path.loc};throw new j(a.path.original+" doesn't match "+c,e)}d=this.locInfo(d);var f=new this.Program([b],null,{},d);return new this.BlockStatement(a.path,a.params,a.hash,f,void 0,{},{},{},d)}function h(a,b,c,d,e,f){if(d&&d.path&&a.path.original!==d.path.original){var g={loc:a.path.loc};throw new j(a.path.original+" doesn't match "+d.path.original,g)}b.blockParams=a.blockParams;var h,i;return c&&(c.chain&&(c.program.body[0].closeStrip=d.strip),i=c.strip,h=c.program),e&&(e=h,h=b,b=e),new this.BlockStatement(a.path,a.params,a.hash,b,h,a.strip,i,d&&d.strip,this.locInfo(f))}var i={},j=a;return i.SourceLocation=b,i.stripFlags=c,i.stripComment=d,i.preparePath=e,i.prepareMustache=f,i.prepareRawBlock=g,i.prepareBlock=h,i}(b),l=function(a,b,c,d,e){"use strict";function f(a,b){if("Program"===a.type)return a;h.yy=m,m.locInfo=function(a){return new m.SourceLocation(b&&b.srcName,a)};var c=new j;return c.accept(h.parse(a))}var g={},h=a,i=b,j=c,k=d,l=e.extend;g.parser=h;var m={};return l(m,k,i),g.parse=f,g}(h,g,j,k,a),m=function(a,b,c){"use strict";function d(){}function e(a,b,c){if(null==a||"string"!=typeof a&&"Program"!==a.type)throw new j("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+a);b=b||{},"data"in b||(b.data=!0),b.compat&&(b.useDepths=!0);var d=c.parse(a,b),e=(new c.Compiler).compile(d,b);return(new c.JavaScriptCompiler).compile(e,b)}function f(a,b,c){function d(){var d=c.parse(a,b),e=(new c.Compiler).compile(d,b),f=(new c.JavaScriptCompiler).compile(e,b,void 0,!0);return c.template(f)}if(null==a||"string"!=typeof a&&"Program"!==a.type)throw new j("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+a);b=b||{},"data"in b||(b.data=!0),b.compat&&(b.useDepths=!0);var e,f=function(a,b){return e||(e=d()),e.call(this,a,b)};return f._setup=function(a){return e||(e=d()),e._setup(a)},f._child=function(a,b,c,f){return e||(e=d()),e._child(a,b,c,f)},f}function g(a,b){if(a===b)return!0;if(k(a)&&k(b)&&a.length===b.length){for(var c=0;cc;c++){var d=this.opcodes[c],e=a.opcodes[c];if(d.opcode!==e.opcode||!g(d.args,e.args))return!1}for(b=this.children.length,c=0;b>c;c++)if(!this.children[c].equals(a.children[c]))return!1;return!0},guid:0,compile:function(a,b){this.sourceNode=[],this.opcodes=[],this.children=[],this.options=b,this.stringParams=b.stringParams,this.trackIds=b.trackIds,b.blockParams=b.blockParams||[];var c=b.knownHelpers;if(b.knownHelpers={helperMissing:!0,blockHelperMissing:!0,each:!0,"if":!0,unless:!0,"with":!0,log:!0,lookup:!0},c)for(var d in c)b.knownHelpers[d]=c[d];return this.accept(a)},compileProgram:function(a){var b=(new this.compiler).compile(a,this.options),c=this.guid++;return this.usePartial=this.usePartial||b.usePartial,this.children[c]=b,this.useDepths=this.useDepths||b.useDepths,c},accept:function(a){this.sourceNode.unshift(a);var b=this[a.type](a);return this.sourceNode.shift(),b},Program:function(a){this.options.blockParams.unshift(a.blockParams);for(var b=a.body,c=0,d=b.length;d>c;c++)this.accept(b[c]);return this.options.blockParams.shift(),this.isSimple=1===d,this.blockParams=a.blockParams?a.blockParams.length:0,this},BlockStatement:function(a){h(a);var b=a.program,c=a.inverse;b=b&&this.compileProgram(b),c=c&&this.compileProgram(c);var d=this.classifySexpr(a);"helper"===d?this.helperSexpr(a,b,c):"simple"===d?(this.simpleSexpr(a),this.opcode("pushProgram",b),this.opcode("pushProgram",c),this.opcode("emptyHash"),this.opcode("blockValue",a.path.original)):(this.ambiguousSexpr(a,b,c),this.opcode("pushProgram",b),this.opcode("pushProgram",c),this.opcode("emptyHash"),this.opcode("ambiguousBlockValue")),this.opcode("append")},PartialStatement:function(a){this.usePartial=!0;var b=a.params;if(b.length>1)throw new j("Unsupported number of partial arguments: "+b.length,a);b.length||b.push({type:"PathExpression",parts:[],depth:0});var c=a.name.original,d="SubExpression"===a.name.type;d&&this.accept(a.name),this.setupFullMustacheParams(a,void 0,void 0,!0);var e=a.indent||"";this.options.preventIndent&&e&&(this.opcode("appendContent",e),e=""),this.opcode("invokePartial",d,c,e),this.opcode("append")},MustacheStatement:function(a){this.SubExpression(a),this.opcode(a.escaped&&!this.options.noEscape?"appendEscaped":"append")},ContentStatement:function(a){a.value&&this.opcode("appendContent",a.value)},CommentStatement:function(){},SubExpression:function(a){h(a);var b=this.classifySexpr(a);"simple"===b?this.simpleSexpr(a):"helper"===b?this.helperSexpr(a):this.ambiguousSexpr(a)},ambiguousSexpr:function(a,b,c){var d=a.path,e=d.parts[0],f=null!=b||null!=c;this.opcode("getContext",d.depth),this.opcode("pushProgram",b),this.opcode("pushProgram",c),this.accept(d),this.opcode("invokeAmbiguous",e,f)},simpleSexpr:function(a){this.accept(a.path),this.opcode("resolvePossibleLambda")},helperSexpr:function(a,b,c){var d=this.setupFullMustacheParams(a,b,c),e=a.path,f=e.parts[0];if(this.options.knownHelpers[f])this.opcode("invokeKnownHelper",d.length,f);else{if(this.options.knownHelpersOnly)throw new j("You specified knownHelpersOnly, but used the unknown helper "+f,a);e.falsy=!0,this.accept(e),this.opcode("invokeHelper",d.length,e.original,m.helpers.simpleId(e))}},PathExpression:function(a){this.addDepth(a.depth),this.opcode("getContext",a.depth);var b=a.parts[0],c=m.helpers.scopedId(a),d=!a.depth&&!c&&this.blockParamIndex(b);d?this.opcode("lookupBlockParam",d,a.parts):b?a.data?(this.options.data=!0,this.opcode("lookupData",a.depth,a.parts)):this.opcode("lookupOnContext",a.parts,a.falsy,c):this.opcode("pushContext")},StringLiteral:function(a){this.opcode("pushString",a.value)},NumberLiteral:function(a){this.opcode("pushLiteral",a.value)},BooleanLiteral:function(a){this.opcode("pushLiteral",a.value)},Hash:function(a){var b,c,d=a.pairs;for(this.opcode("pushHash"),b=0,c=d.length;c>b;b++)this.pushParam(d[b].value);for(;b--;)this.opcode("assignToHash",d[b].key);this.opcode("popHash")},opcode:function(a){this.opcodes.push({opcode:a,args:n.call(arguments,1),loc:this.sourceNode[0].loc})},addDepth:function(a){a&&(this.useDepths=!0)},classifySexpr:function(a){var b=m.helpers.simpleId(a.path),c=b&&!!this.blockParamIndex(a.path.parts[0]),d=!c&&m.helpers.helperExpression(a),e=!c&&(d||b),f=this.options;if(e&&!d){var g=a.path.parts[0];f.knownHelpers[g]?d=!0:f.knownHelpersOnly&&(e=!1)}return d?"helper":e?"ambiguous":"simple"},pushParams:function(a){for(var b=0,c=a.length;c>b;b++)this.pushParam(a[b])},pushParam:function(a){var b=null!=a.value?a.value:a.original||"";if(this.stringParams)b.replace&&(b=b.replace(/^(\.?\.\/)*/g,"").replace(/\//g,".")),a.depth&&this.addDepth(a.depth),this.opcode("getContext",a.depth||0),this.opcode("pushStringParam",b,a.type),"SubExpression"===a.type&&this.accept(a);else{if(this.trackIds){var c;if(!a.parts||m.helpers.scopedId(a)||a.depth||(c=this.blockParamIndex(a.parts[0])),c){var d=a.parts.slice(1).join(".");this.opcode("pushId","BlockParam",c,d)}else b=a.original||b,b.replace&&(b=b.replace(/^\.\//g,"").replace(/^\.$/g,"")),this.opcode("pushId",a.type,b)}this.accept(a)}},setupFullMustacheParams:function(a,b,c,d){var e=a.params;return this.pushParams(e),this.opcode("pushProgram",b),this.opcode("pushProgram",c),a.hash?this.accept(a.hash):this.opcode("emptyHash",d),e},blockParamIndex:function(a){for(var b=0,c=this.options.blockParams.length;c>b;b++){var d=this.options.blockParams[b],e=d&&l(d,a);if(d&&e>=0)return[b,e]}}},i.precompile=e,i.compile=f,i}(b,a,g),n=function(a){"use strict";function b(a,b,c){if(e(a)){for(var d=[],f=0,g=a.length;g>f;f++)d.push(b.wrap(a[f],c));return d}return"boolean"==typeof a||"number"==typeof a?a+"":a}function c(a){this.srcFile=a,this.source=[]}var d,e=a.isArray;try{var f=require("source-map"),g=f.SourceNode}catch(h){g=function(a,b,c,d){this.src="",d&&this.add(d)},g.prototype={add:function(a){e(a)&&(a=a.join("")),this.src+=a},prepend:function(a){e(a)&&(a=a.join("")),this.src=a+this.src},toStringWithSourceMap:function(){return{code:this.toString()}},toString:function(){return this.src}}}return c.prototype={prepend:function(a,b){this.source.unshift(this.wrap(a,b))},push:function(a,b){this.source.push(this.wrap(a,b))},merge:function(){var a=this.empty();return this.each(function(b){a.add([" ",b,"\n"])}),a},each:function(a){for(var b=0,c=this.source.length;c>b;b++)a(this.source[b])},empty:function(a){return a=a||this.currentLocation||{start:{}},new g(a.start.line,a.start.column,this.srcFile)},wrap:function(a,c){return a instanceof g?a:(c=c||this.currentLocation||{start:{}},a=b(a,this,c),new g(c.start.line,c.start.column,this.srcFile,a))},functionCall:function(a,b,c){return c=this.generateList(c),this.wrap([a,b?"."+b+"(":"(",c,")"])},quotedString:function(a){return'"'+(a+"").replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")+'"'},objectLiteral:function(a){var c=[];for(var d in a)if(a.hasOwnProperty(d)){var e=b(a[d],this);"undefined"!==e&&c.push([this.quotedString(d),":",e])}var f=this.generateList(c);return f.prepend("{"),f.add("}"),f},generateList:function(a,c){for(var d=this.empty(c),e=0,f=a.length;f>e;e++)e&&d.add(","),d.add(b(a[e],this,c));return d},generateArray:function(a,b){var c=this.generateList(a,b);return c.prepend("["),c.add("]"),c}},d=c}(a),o=function(a,b,c,d){"use strict";function e(a){this.value=a}function f(){}function g(a,b,c,d){var e=b.popStack(),f=0,g=c.length;for(a&&g--;g>f;f++)e=b.nameLookup(e,c[f],d);return a?[b.aliasable("this.strict"),"(",e,", ",b.quotedString(c[f]),")"]:e}var h,i=a.COMPILER_REVISION,j=a.REVISION_CHANGES,k=b,l=c.isArray,m=d;f.prototype={nameLookup:function(a,b){return f.isValidJavaScriptVariableName(b)?[a,".",b]:[a,"['",b,"']"]},depthedLookup:function(a){return[this.aliasable("this.lookup"),'(depths, "',a,'")']},compilerInfo:function(){var a=i,b=j[a];return[a,b]},appendToBuffer:function(a,b,c){return l(a)||(a=[a]),a=this.source.wrap(a,b),this.environment.isSimple?["return ",a,";"]:c?["buffer += ",a,";"]:(a.appendToBuffer=!0,a)},initializeBuffer:function(){return this.quotedString("")},compile:function(a,b,c,d){this.environment=a,this.options=b,this.stringParams=this.options.stringParams,this.trackIds=this.options.trackIds,this.precompile=!d,this.name=this.environment.name,this.isChild=!!c,this.context=c||{programs:[],environments:[]},this.preamble(),this.stackSlot=0,this.stackVars=[],this.aliases={},this.registers={list:[]},this.hashes=[],this.compileStack=[],this.inlineStack=[],this.blockParams=[],this.compileChildren(a,b),this.useDepths=this.useDepths||a.useDepths||this.options.compat,this.useBlockParams=this.useBlockParams||a.useBlockParams;var e,f,g,h,i=a.opcodes;for(g=0,h=i.length;h>g;g++)e=i[g],this.source.currentLocation=e.loc,f=f||e.loc,this[e.opcode].apply(this,e.args);if(this.source.currentLocation=f,this.pushSource(""),this.stackSlot||this.inlineStack.length||this.compileStack.length)throw new k("Compile completed with content left on stack");var j=this.createFunctionContext(d);if(this.isChild)return j;var l={compiler:this.compilerInfo(),main:j},m=this.context.programs;for(g=0,h=m.length;h>g;g++)m[g]&&(l[g]=m[g]);return this.environment.usePartial&&(l.usePartial=!0),this.options.data&&(l.useData=!0),this.useDepths&&(l.useDepths=!0),this.useBlockParams&&(l.useBlockParams=!0),this.options.compat&&(l.compat=!0),d?l.compilerOptions=this.options:(l.compiler=JSON.stringify(l.compiler),this.source.currentLocation={start:{line:1,column:0}},l=this.objectLiteral(l),b.srcName?(l=l.toStringWithSourceMap({file:b.destName}),l.map=l.map&&l.map.toString()):l=l.toString()),l},preamble:function(){this.lastContext=0,this.source=new m(this.options.srcName)},createFunctionContext:function(a){var b="",c=this.stackVars.concat(this.registers.list);c.length>0&&(b+=", "+c.join(", "));var d=0;for(var e in this.aliases){var f=this.aliases[e];this.aliases.hasOwnProperty(e)&&f.children&&f.referenceCount>1&&(b+=", alias"+ ++d+"="+e,f.children[0]="alias"+d)}var g=["depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&g.push("blockParams"),this.useDepths&&g.push("depths");var h=this.mergeSource(b);return a?(g.push(h),Function.apply(this,g)):this.source.wrap(["function(",g.join(","),") {\n ",h,"}"])},mergeSource:function(a){var b,c,d,e,f=this.environment.isSimple,g=!this.forceBuffer;return this.source.each(function(a){a.appendToBuffer?(d?a.prepend(" + "):d=a,e=a):(d&&(c?d.prepend("buffer += "):b=!0,e.add(";"),d=e=void 0),c=!0,f||(g=!1))}),g?d?(d.prepend("return "),e.add(";")):c||this.source.push('return "";'):(a+=", buffer = "+(b?"":this.initializeBuffer()),d?(d.prepend("return buffer + "),e.add(";")):this.source.push("return buffer;")),a&&this.source.prepend("var "+a.substring(2)+(b?"":";\n")),this.source.merge()},blockValue:function(a){var b=this.aliasable("helpers.blockHelperMissing"),c=[this.contextName(0)];this.setupHelperArgs(a,0,c);var d=this.popStack();c.splice(1,0,d),this.push(this.source.functionCall(b,"call",c))},ambiguousBlockValue:function(){var a=this.aliasable("helpers.blockHelperMissing"),b=[this.contextName(0)];this.setupHelperArgs("",0,b,!0),this.flushInline();var c=this.topStack();b.splice(1,0,c),this.pushSource(["if (!",this.lastHelper,") { ",c," = ",this.source.functionCall(a,"call",b),"}"])},appendContent:function(a){this.pendingContent?a=this.pendingContent+a:this.pendingLocation=this.source.currentLocation,this.pendingContent=a},append:function(){if(this.isInline())this.replaceStack(function(a){return[" != null ? ",a,' : ""']}),this.pushSource(this.appendToBuffer(this.popStack()));else{var a=this.popStack();this.pushSource(["if (",a," != null) { ",this.appendToBuffer(a,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("this.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(a){this.lastContext=a},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(a,b,c){var d=0;c||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(a[d++])),this.resolvePath("context",a,d,b)},lookupBlockParam:function(a,b){this.useBlockParams=!0,this.push(["blockParams[",a[0],"][",a[1],"]"]),this.resolvePath("context",b,1)},lookupData:function(a,b){this.pushStackLiteral(a?"this.data(data, "+a+")":"data"),this.resolvePath("data",b,0,!0)},resolvePath:function(a,b,c,d){if(this.options.strict||this.options.assumeObjects)return void this.push(g(this.options.strict,this,b,a));for(var e=b.length;e>c;c++)this.replaceStack(function(e){var f=this.nameLookup(e,b[c],a);return d?[" && ",f]:[" != null ? ",f," : ",e]})},resolvePossibleLambda:function(){this.push([this.aliasable("this.lambda"),"(",this.popStack(),", ",this.contextName(0),")"])},pushStringParam:function(a,b){this.pushContext(),this.pushString(b),"SubExpression"!==b&&("string"==typeof a?this.pushString(a):this.pushStackLiteral(a))},emptyHash:function(a){this.trackIds&&this.push("{}"),this.stringParams&&(this.push("{}"),this.push("{}")),this.pushStackLiteral(a?"undefined":"{}")},pushHash:function(){this.hash&&this.hashes.push(this.hash),this.hash={values:[],types:[],contexts:[],ids:[]}},popHash:function(){var a=this.hash;this.hash=this.hashes.pop(),this.trackIds&&this.push(this.objectLiteral(a.ids)),this.stringParams&&(this.push(this.objectLiteral(a.contexts)),this.push(this.objectLiteral(a.types))),this.push(this.objectLiteral(a.values))},pushString:function(a){this.pushStackLiteral(this.quotedString(a))},pushLiteral:function(a){this.pushStackLiteral(a)},pushProgram:function(a){this.pushStackLiteral(null!=a?this.programExpression(a):null)},invokeHelper:function(a,b,c){var d=this.popStack(),e=this.setupHelper(a,b),f=c?[e.name," || "]:"",g=["("].concat(f,d);this.options.strict||g.push(" || ",this.aliasable("helpers.helperMissing")),g.push(")"),this.push(this.source.functionCall(g,"call",e.callParams))},invokeKnownHelper:function(a,b){var c=this.setupHelper(a,b);this.push(this.source.functionCall(c.name,"call",c.callParams))},invokeAmbiguous:function(a,b){this.useRegister("helper");var c=this.popStack();this.emptyHash();var d=this.setupHelper(0,a,b),e=this.lastHelper=this.nameLookup("helpers",a,"helper"),f=["(","(helper = ",e," || ",c,")"];this.options.strict||(f[0]="(helper = ",f.push(" != null ? helper : ",this.aliasable("helpers.helperMissing"))),this.push(["(",f,d.paramsInit?["),(",d.paramsInit]:[],"),","(typeof helper === ",this.aliasable('"function"')," ? ",this.source.functionCall("helper","call",d.callParams)," : helper))"])},invokePartial:function(a,b,c){var d=[],e=this.setupParams(b,1,d,!1);a&&(b=this.popStack(),delete e.name),c&&(e.indent=JSON.stringify(c)),e.helpers="helpers",e.partials="partials",d.unshift(a?b:this.nameLookup("partials",b,"partial")),this.options.compat&&(e.depths="depths"),e=this.objectLiteral(e),d.push(e),this.push(this.source.functionCall("this.invokePartial","",d))},assignToHash:function(a){var b,c,d,e=this.popStack();this.trackIds&&(d=this.popStack()),this.stringParams&&(c=this.popStack(),b=this.popStack());var f=this.hash;b&&(f.contexts[a]=b),c&&(f.types[a]=c),d&&(f.ids[a]=d),f.values[a]=e},pushId:function(a,b,c){"BlockParam"===a?this.pushStackLiteral("blockParams["+b[0]+"].path["+b[1]+"]"+(c?" + "+JSON.stringify("."+c):"")):"PathExpression"===a?this.pushString(b):this.pushStackLiteral("SubExpression"===a?"true":"null")},compiler:f,compileChildren:function(a,b){for(var c,d,e=a.children,f=0,g=e.length;g>f;f++){c=e[f],d=new this.compiler;var h=this.matchExistingProgram(c);null==h?(this.context.programs.push(""),h=this.context.programs.length,c.index=h,c.name="program"+h,this.context.programs[h]=d.compile(c,b,this.context,!this.precompile),this.context.environments[h]=c,this.useDepths=this.useDepths||d.useDepths,this.useBlockParams=this.useBlockParams||d.useBlockParams):(c.index=h,c.name="program"+h,this.useDepths=this.useDepths||c.useDepths,this.useBlockParams=this.useBlockParams||c.useBlockParams)}},matchExistingProgram:function(a){for(var b=0,c=this.context.environments.length;c>b;b++){var d=this.context.environments[b];if(d&&d.equals(a))return b}},programExpression:function(a){var b=this.environment.children[a],c=[b.index,"data",b.blockParams];return(this.useBlockParams||this.useDepths)&&c.push("blockParams"),this.useDepths&&c.push("depths"),"this.program("+c.join(", ")+")"},useRegister:function(a){this.registers[a]||(this.registers[a]=!0,this.registers.list.push(a))},push:function(a){return a instanceof e||(a=this.source.wrap(a)),this.inlineStack.push(a),a},pushStackLiteral:function(a){this.push(new e(a))},pushSource:function(a){this.pendingContent&&(this.source.push(this.appendToBuffer(this.source.quotedString(this.pendingContent),this.pendingLocation)),this.pendingContent=void 0),a&&this.source.push(a)},replaceStack:function(a){var b,c,d,f=["("];if(!this.isInline())throw new k("replaceStack on non-inline");var g=this.popStack(!0);if(g instanceof e)b=[g.value],f=["(",b],d=!0;else{c=!0;var h=this.incrStack();f=["((",this.push(h)," = ",g,")"],b=this.topStack()}var i=a.call(this,b);d||this.popStack(),c&&this.stackSlot--,this.push(f.concat(i,")"))},incrStack:function(){return this.stackSlot++,this.stackSlot>this.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var a=this.inlineStack;this.inlineStack=[];for(var b=0,c=a.length;c>b;b++){var d=a[b];if(d instanceof e)this.compileStack.push(d);else{var f=this.incrStack();this.pushSource([f," = ",d,";"]),this.compileStack.push(f)}}},isInline:function(){return this.inlineStack.length},popStack:function(a){var b=this.isInline(),c=(b?this.inlineStack:this.compileStack).pop();if(!a&&c instanceof e)return c.value;if(!b){if(!this.stackSlot)throw new k("Invalid stack pop");this.stackSlot--}return c},topStack:function(){var a=this.isInline()?this.inlineStack:this.compileStack,b=a[a.length-1];return b instanceof e?b.value:b},contextName:function(a){return this.useDepths&&a?"depths["+a+"]":"depth"+a},quotedString:function(a){return this.source.quotedString(a)},objectLiteral:function(a){return this.source.objectLiteral(a)},aliasable:function(a){var b=this.aliases[a];return b?(b.referenceCount++,b):(b=this.aliases[a]=this.source.wrap(a),b.aliasable=!0,b.referenceCount=1,b)},setupHelper:function(a,b,c){var d=[],e=this.setupHelperArgs(b,a,d,c),f=this.nameLookup("helpers",b,"helper");return{params:d,paramsInit:e,name:f,callParams:[this.contextName(0)].concat(d)}},setupParams:function(a,b,c){var d,e={},f=[],g=[],h=[];e.name=this.quotedString(a),e.hash=this.popStack(),this.trackIds&&(e.hashIds=this.popStack()),this.stringParams&&(e.hashTypes=this.popStack(),e.hashContexts=this.popStack());var i=this.popStack(),j=this.popStack();(j||i)&&(e.fn=j||"this.noop",e.inverse=i||"this.noop");for(var k=b;k--;)d=this.popStack(),c[k]=d,this.trackIds&&(h[k]=this.popStack()),this.stringParams&&(g[k]=this.popStack(),f[k]=this.popStack());return this.trackIds&&(e.ids=this.source.generateArray(h)),this.stringParams&&(e.types=this.source.generateArray(g),e.contexts=this.source.generateArray(f)),this.options.data&&(e.data="data"),this.useBlockParams&&(e.blockParams="blockParams"),e},setupHelperArgs:function(a,b,c,d){var e=this.setupParams(a,b,c,!0);return e=this.objectLiteral(e),d?(this.useRegister("options"),c.push("options"),["options=",e]):(c.push(e),"")}};for(var n="break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield await null true false".split(" "),o=f.RESERVED_WORDS={},p=0,q=n.length;q>p;p++)o[n[p]]=!0;return f.isValidJavaScriptVariableName=function(a){return!f.RESERVED_WORDS[a]&&/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(a)},h=f}(c,b,a,n),p=function(a,b,c,d,e){"use strict";var f,g=a,h=b,i=c.parser,j=c.parse,k=d.Compiler,l=d.compile,m=d.precompile,n=e,o=g.create,p=function(){var a=o();return a.compile=function(b,c){return l(b,c,a)},a.precompile=function(b,c){return m(b,c,a)},a.AST=h,a.Compiler=k,a.JavaScriptCompiler=n,a.Parser=i,a.parse=j,a};g=p(),g.create=p;var q="undefined"!=typeof global?global:window,r=q.Handlebars;return g.noConflict=function(){q.Handlebars===g&&(q.Handlebars=r)},g["default"]=g,f=g}(f,g,l,m,o);return p}); \ No newline at end of file From ce82fc4eb38f0436b777d54ad33386f370dd1738 Mon Sep 17 00:00:00 2001 From: Peter W Date: Tue, 20 Oct 2015 15:06:32 +1300 Subject: [PATCH 02/40] reduced jquery-ui size - The custom jquery-ui download we used previously included components we didn't use - This change reduces file size from 71.9kb for jquery-ui.min.js to 33kb. Chrome dev tools show a time reduction on a GPRS network (50Kbps) from 1.4 minutes to 50 seconds, reducing total Load time from 2.4 to 2.3 minutes. --- js/vendor/jquery-ui/jquery-ui.js | 2444 +------------------------- js/vendor/jquery-ui/jquery-ui.min.js | 9 +- 2 files changed, 6 insertions(+), 2447 deletions(-) diff --git a/js/vendor/jquery-ui/jquery-ui.js b/js/vendor/jquery-ui/jquery-ui.js index a4bb4ec..7174d2a 100644 --- a/js/vendor/jquery-ui/jquery-ui.js +++ b/js/vendor/jquery-ui/jquery-ui.js @@ -1,6 +1,6 @@ -/*! jQuery UI - v1.11.4 - 2015-04-12 +/*! jQuery UI - v1.11.4 - 2015-10-19 * http://jqueryui.com -* Includes: core.js, widget.js, mouse.js, position.js, draggable.js, resizable.js, autocomplete.js, menu.js +* Includes: core.js, widget.js, position.js, autocomplete.js, menu.js * Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ (function( factory ) { @@ -856,192 +856,6 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { var widget = $.widget; -/*! - * jQuery UI Mouse 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/mouse/ - */ - - -var mouseHandled = false; -$( document ).mouseup( function() { - mouseHandled = false; -}); - -var mouse = $.widget("ui.mouse", { - version: "1.11.4", - options: { - cancel: "input,textarea,button,select,option", - distance: 1, - delay: 0 - }, - _mouseInit: function() { - var that = this; - - this.element - .bind("mousedown." + this.widgetName, function(event) { - return that._mouseDown(event); - }) - .bind("click." + this.widgetName, function(event) { - if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) { - $.removeData(event.target, that.widgetName + ".preventClickEvent"); - event.stopImmediatePropagation(); - return false; - } - }); - - this.started = false; - }, - - // TODO: make sure destroying one instance of mouse doesn't mess with - // other instances of mouse - _mouseDestroy: function() { - this.element.unbind("." + this.widgetName); - if ( this._mouseMoveDelegate ) { - this.document - .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate) - .unbind("mouseup." + this.widgetName, this._mouseUpDelegate); - } - }, - - _mouseDown: function(event) { - // don't let more than one widget handle mouseStart - if ( mouseHandled ) { - return; - } - - this._mouseMoved = false; - - // we may have missed mouseup (out of window) - (this._mouseStarted && this._mouseUp(event)); - - this._mouseDownEvent = event; - - var that = this, - btnIsLeft = (event.which === 1), - // event.target.nodeName works around a bug in IE 8 with - // disabled inputs (#7620) - elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false); - if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { - return true; - } - - this.mouseDelayMet = !this.options.delay; - if (!this.mouseDelayMet) { - this._mouseDelayTimer = setTimeout(function() { - that.mouseDelayMet = true; - }, this.options.delay); - } - - if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { - this._mouseStarted = (this._mouseStart(event) !== false); - if (!this._mouseStarted) { - event.preventDefault(); - return true; - } - } - - // Click event may never have fired (Gecko & Opera) - if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) { - $.removeData(event.target, this.widgetName + ".preventClickEvent"); - } - - // these delegates are required to keep context - this._mouseMoveDelegate = function(event) { - return that._mouseMove(event); - }; - this._mouseUpDelegate = function(event) { - return that._mouseUp(event); - }; - - this.document - .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate ) - .bind( "mouseup." + this.widgetName, this._mouseUpDelegate ); - - event.preventDefault(); - - mouseHandled = true; - return true; - }, - - _mouseMove: function(event) { - // Only check for mouseups outside the document if you've moved inside the document - // at least once. This prevents the firing of mouseup in the case of IE<9, which will - // fire a mousemove event if content is placed under the cursor. See #7778 - // Support: IE <9 - if ( this._mouseMoved ) { - // IE mouseup check - mouseup happened when mouse was out of window - if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) { - return this._mouseUp(event); - - // Iframe mouseup check - mouseup occurred in another document - } else if ( !event.which ) { - return this._mouseUp( event ); - } - } - - if ( event.which || event.button ) { - this._mouseMoved = true; - } - - if (this._mouseStarted) { - this._mouseDrag(event); - return event.preventDefault(); - } - - if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { - this._mouseStarted = - (this._mouseStart(this._mouseDownEvent, event) !== false); - (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); - } - - return !this._mouseStarted; - }, - - _mouseUp: function(event) { - this.document - .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate ) - .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate ); - - if (this._mouseStarted) { - this._mouseStarted = false; - - if (event.target === this._mouseDownEvent.target) { - $.data(event.target, this.widgetName + ".preventClickEvent", true); - } - - this._mouseStop(event); - } - - mouseHandled = false; - return false; - }, - - _mouseDistanceMet: function(event) { - return (Math.max( - Math.abs(this._mouseDownEvent.pageX - event.pageX), - Math.abs(this._mouseDownEvent.pageY - event.pageY) - ) >= this.options.distance - ); - }, - - _mouseDelayMet: function(/* event */) { - return this.mouseDelayMet; - }, - - // These are placeholder methods, to be overriden by extending plugin - _mouseStart: function(/* event */) {}, - _mouseDrag: function(/* event */) {}, - _mouseStop: function(/* event */) {}, - _mouseCapture: function(/* event */) { return true; } -}); - - /*! * jQuery UI Position 1.11.4 * http://jqueryui.com @@ -1549,2260 +1363,6 @@ $.ui.position = { var position = $.ui.position; -/*! - * jQuery UI Draggable 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/draggable/ - */ - - -$.widget("ui.draggable", $.ui.mouse, { - version: "1.11.4", - widgetEventPrefix: "drag", - options: { - addClasses: true, - appendTo: "parent", - axis: false, - connectToSortable: false, - containment: false, - cursor: "auto", - cursorAt: false, - grid: false, - handle: false, - helper: "original", - iframeFix: false, - opacity: false, - refreshPositions: false, - revert: false, - revertDuration: 500, - scope: "default", - scroll: true, - scrollSensitivity: 20, - scrollSpeed: 20, - snap: false, - snapMode: "both", - snapTolerance: 20, - stack: false, - zIndex: false, - - // callbacks - drag: null, - start: null, - stop: null - }, - _create: function() { - - if ( this.options.helper === "original" ) { - this._setPositionRelative(); - } - if (this.options.addClasses){ - this.element.addClass("ui-draggable"); - } - if (this.options.disabled){ - this.element.addClass("ui-draggable-disabled"); - } - this._setHandleClassName(); - - this._mouseInit(); - }, - - _setOption: function( key, value ) { - this._super( key, value ); - if ( key === "handle" ) { - this._removeHandleClassName(); - this._setHandleClassName(); - } - }, - - _destroy: function() { - if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) { - this.destroyOnClear = true; - return; - } - this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ); - this._removeHandleClassName(); - this._mouseDestroy(); - }, - - _mouseCapture: function(event) { - var o = this.options; - - this._blurActiveElement( event ); - - // among others, prevent a drag on a resizable-handle - if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) { - return false; - } - - //Quit if we're not on a valid handle - this.handle = this._getHandle(event); - if (!this.handle) { - return false; - } - - this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix ); - - return true; - - }, - - _blockFrames: function( selector ) { - this.iframeBlocks = this.document.find( selector ).map(function() { - var iframe = $( this ); - - return $( "
" ) - .css( "position", "absolute" ) - .appendTo( iframe.parent() ) - .outerWidth( iframe.outerWidth() ) - .outerHeight( iframe.outerHeight() ) - .offset( iframe.offset() )[ 0 ]; - }); - }, - - _unblockFrames: function() { - if ( this.iframeBlocks ) { - this.iframeBlocks.remove(); - delete this.iframeBlocks; - } - }, - - _blurActiveElement: function( event ) { - var document = this.document[ 0 ]; - - // Only need to blur if the event occurred on the draggable itself, see #10527 - if ( !this.handleElement.is( event.target ) ) { - return; - } - - // support: IE9 - // IE9 throws an "Unspecified error" accessing document.activeElement from an ";this.dialog=new cdb.ui.common.ShareDialog({title:e.map.get("title"),description:e.map.get("description"),model:this.options.vis.map,code:i,url:e.url,public_map_url:r,share_url:e.share_url,template:t,target:$(".cartodb-share a"),size:$(document).width()>400?"":"small",width:$(document).width()>400?430:216}),$(".cartodb-map-wrapper").append(this.dialog.render().$el)},render:function(){return this.$el.html(this.template(_.extend(this.model.attributes))),this}}),cdb.geo.ui.Zoom=cdb.core.View.extend({className:"cartodb-zoom",events:{"click .zoom_in":"zoom_in","click .zoom_out":"zoom_out"},default_options:{timeout:0,msg:""},initialize:function(){this.map=this.model,_.defaults(this.options,this.default_options),this.template=this.options.template?this.options.template:cdb.templates.getTemplate("geo/zoom"),this.map.bind("change:zoom change:minZoom change:maxZoom",this._checkZoom,this)},render:function(){return this.$el.html(this.template(this.options)),this._checkZoom(),this},_checkZoom:function(){var e=this.map.get("zoom");this.$(".zoom_in")[ethis.map.get("minZoom")?"removeClass":"addClass"]("disabled")},zoom_in:function(e){this.map.get("maxZoom")>this.map.getZoom()&&this.map.setZoom(this.map.getZoom()+1),e.preventDefault(),e.stopPropagation()},zoom_out:function(e){this.map.get("minZoom")\n
<%= title %>
<% } %>
  • <%= leftLabel %>
  • <%= rightLabel %>
  • <%= colors %>\n
'),initialize:function(){this.items=this.model.items},_generateColorList:function(){var e="";if(this.model.get("colors"))return _.map(this.model.get("colors"),function(e){return'\n
'}).join("");for(var t=2;t
'}return e},setLeftLabel:function(e){this.model.set("leftLabel",e)},setRightLabel:function(e){this.model.set("rightLabel",e)},setColors:function(e){this.model.set("colors",e)},render:function(){if(this.model.get("template")){var e=_.template(this.model.get("template"));this.$el.html(e(this.model.toJSON()))}else if(this.items.length>=2){this.leftLabel=this.items.at(0),this.rightLabel=this.items.at(1);var t=this.model.get("leftLabel")||this.leftLabel.get("value"),n=this.model.get("rightLabel")||this.rightLabel.get("value"),r=this._generateColorList(),i=_.extend(this.model.toJSON(),{leftLabel:t,rightLabel:n,colors:r,buckets_count:r.length});this.$el.html(this.template(i))}return this}}),cdb.geo.ui.DensityLegend=cdb.geo.ui.BaseLegend.extend({className:"density-legend",template:_.template('<% if (title && show_title) { %>\n
<%= title %>
<% } %>
  • <%= leftLabel %>
  • <%= rightLabel %>
  • <%= colors %>\n
'),initialize:function(){this.items=this.model.items},setLeftLabel:function(e){this.model.set("leftLabel",e)},setRightLabel:function(e){this.model.set("rightLabel",e)},setColors:function(e){this.model.set("colors",e)},_generateColorList:function(){var e="";if(this.model.get("colors"))return _.map(this.model.get("colors"),function(e){return'\n
'}).join("");for(var t=2;t'}return e},render:function(){if(this.model.get("template")){var e=_.template(this.model.get("template"));this.$el.html(e(this.model.toJSON()))}else if(this.items.length>=2){this.leftLabel=this.items.at(0),this.rightLabel=this.items.at(1);var t=this.model.get("leftLabel")||this.leftLabel.get("value"),n=this.model.get("rightLabel")||this.rightLabel.get("value"),r=this._generateColorList(),i=_.extend(this.model.toJSON(),{leftLabel:t,rightLabel:n,colors:r,buckets_count:r.length});this.$el.html(this.template(i))}return this}}),cdb.geo.ui.Legend.Density=cdb.geo.ui.DensityLegend.extend({type:"density",className:"cartodb-legend density",initialize:function(){this.items=this.options.items,this.model=new cdb.geo.ui.LegendModel({type:this.type,title:this.options.title,show_title:this.options.title?!0:!1,leftLabel:this.options.left||this.options.leftLabel,rightLabel:this.options.right||this.options.rightLabel,colors:this.options.colors,buckets_count:this.options.colors?this.options.colors.length:0,items:this.options.items}),this._bindModel()},_bindModel:function(){this.model.bind("change:colors change:template change:title change:show_title change:colors change:leftLabel change:rightLabel",this.render,this)},_generateColorList:function(){return _.map(this.model.get("colors"),function(e){return'
'}).join("")},render:function(){var e=_.extend(this.model.toJSON(),{colors:this._generateColorList()});return this.$el.html(this.template(e)),this}}),cdb.geo.ui.IntensityLegend=cdb.geo.ui.BaseLegend.extend({className:"intensity-legend",template:_.template('<% if (title && show_title) { %>\n
<%= title %>
<% } %>
  • <%= leftLabel %>
  • <%= rightLabel %>
'),initialize:function(){this.items=this.model.items},_bindModel:function(){this.model.bind("change:template",this.render,this)},setColor:function(e){this.model.set("color",e)},setLeftLabel:function(e){this.model.set("leftLabel",e)},setRightLabel:function(e){this.model.set("rightLabel",e)},_hexToRGB:function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null},_rgbToHex:function(e,t,n){function r(e){var t=e.toString(16);return t.length==1?"0"+t:t}return"#"+r(e)+r(t)+r(n)},_calculateMultiply:function(e,t){var n=this._hexToRGB(e);if(n){var r=n.r,i=n.g,s=n.b;for(var o=0;o<=t;o++)r=Math.round(r*n.r/255),i=Math.round(i*n.g/255),s=Math.round(s*n.b/255);return this._rgbToHex(r,i,s)}return"#ffffff"},_renderGraph:function(e){var t="";t+="background: <%= color %>;",t+="background: -moz-linear-gradient(left, <%= color %> 0%, <%= right %> 100%);",t+="background: -webkit-gradient(linear, left top, right top, color-stop(0%,<%= color %>), color-stop(100%,<%= right %>));",t+="background: -webkit-linear-gradient(left, <%= color %> 0%,<%= right %> 100%);",t+="background: -o-linear-gradient(left, <%= color %> 0%,<%= right %> 100%);",t+="background: -ms-linear-gradient(left, <%= color %> 0%,<%= right %> 100%)",t+="background: linear-gradient(to right, <%= color %> 0%,<%= right %> 100%);",t+="filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<%= color %>', endColorstr='<%= right %>',GradientType=1 );",t+="background-image: -ms-linear-gradient(left, <%= color %> 0%,<%= right %> 100%)";var n=_.template(t),r=this._calculateMultiply(e,4);this.$el.find(".graph").attr("style",n({color:e,right:r}))},render:function(){if(this.model.get("template")){var e=_.template(this.model.get("template"));this.$el.html(e(this.model.toJSON()))}else if(this.items.length>=3){this.leftLabel=this.items.at(0),this.rightLabel=this.items.at(1);var t=this.model.get("color")||this.items.at(2).get("value"),n=this.model.get("leftLabel")||this.leftLabel.get("value"),r=this.model.get("rightLabel")||this.rightLabel.get("value"),i=_.extend(this.model.toJSON(),{color:t,leftLabel:n,rightLabel:r});this.$el.html(this.template(i)),this._renderGraph(t)}return this}}),cdb.geo.ui.CategoryLegend=cdb.geo.ui.BaseLegend.extend({className:"category-legend",template:_.template('<% if (title && show_title) { %>\n
<%= title %>
<% } %>
    '),initialize:function(){this.items=this.model.items},_bindModel:function(){this.model.bind("change:title change:show_title change:template",this.render,this)},_renderItems:function(){this.items.each(this._renderItem,this)},_renderItem:function(e){view=new cdb.geo.ui.LegendItem({model:e,className:e.get("value")&&e.get("value").indexOf("http")>=0||e.get("type")&&e.get("type")=="image"?"bkg":"",template:'
    <%= name || ((name === false) ? "false": "null") %>'}),this.$el.find("ul").append(view.render())},render:function(){if(this.model.get("template")){var e=_.template(this.model.get("template"));this.$el.html(e(this.model.toJSON()))}else this.$el.html(this.template(this.model.toJSON())),this.items.length>0?this._renderItems():this.$el.html('
    The category legend is empty
    ');return this}}),cdb.geo.ui.Legend.Category=cdb.geo.ui.CategoryLegend.extend({className:"cartodb-legend category",type:"category",initialize:function(){this.items=new cdb.geo.ui.LegendItems(this.options.data),this.model=new cdb.geo.ui.LegendModel({type:this.type,title:this.options.title,show_title:this.options.title?!0:!1}),this._bindModel()},render:function(){return this.$el.html(this.template(this.model.toJSON())),this._renderItems(),this}}),cdb.geo.ui.ColorLegend=cdb.geo.ui.BaseLegend.extend({className:"color-legend",type:"color",template:_.template('<% if (title && show_title) { %>\n
    <%= title %>
    <% } %>
      '),initialize:function(){this.items=this.model.items},_renderItems:function(){this.items.each(this._renderItem,this)},_renderItem:function(e){view=new cdb.geo.ui.LegendItem({model:e,className:e.get("value")&&e.get("value").indexOf("http")>=0?"bkg":"",template:'
      <%= name || ((name === false) ? "false": "null") %>'}),this.$el.find("ul").append(view.render())},render:function(){return this.$el.html(this.template(this.model.toJSON())),this.items.length>0?this._renderItems():this.$el.html('
      The color legend is empty
      '),this}}),cdb.geo.ui.Legend.Color=cdb.geo.ui.Legend.Category.extend({}),cdb.geo.ui.StackedLegend=cdb.core.View.extend({events:{dragstart:"_stopPropagation",mousedown:"_stopPropagation",touchstart:"_stopPropagation",MSPointerDown:"_stopPropagation",dblclick:"_stopPropagation",mousewheel:"_stopPropagation",DOMMouseScroll:"_stopPropagation",dbclick:"_stopPropagation",click:"_stopPropagation"},className:"cartodb-legend-stack",initialize:function(){_.each(this.options.legends,this._setupBinding,this)},_stopPropagation:function(e){e.stopPropagation()},getLegendByIndex:function(e){if(!this._layerByIndex){this._layerByIndex={};var t=this.options.legends;for(var n=0;n0&&this.legendItems.each(this._renderLegend,this),this},_renderLegend:function(e){var t=e.get("type");t||(t="custom"),t=this._capitalize(t);var n=new cdb.geo.ui.Legend[t](e.attributes);this.legends.push(n),e.get("visible")!==!1&&this.$el.append(n.render().$el)},getLegendAt:function(e){return this.legends[e]},addLegend:function(e){var t=new cdb.geo.ui.LegendModel(e);this.legendItems.push(t)},removeLegendAt:function(e){var t=this.legendItems.at(e);this.legendItems.remove(t)}}),cdb.geo.ui.LegendModel=cdb.core.Model.extend({defaults:{type:null,show_title:!1,title:"",template:""},initialize:function(){this.items=new cdb.geo.ui.LegendItems(this.get("items")),this.items.bind("add remove reset change",function(){this.set({items:this.items.toJSON()})},this),this.bind("change:items",this._onUpdateItems,this),this.bind("change:title change:show_title",this._onUpdateTitle,this),this.bind("change:template",this._onUpdateTemplate,this)},_onUpdateTemplate:function(){this.template=this.get("template")},_onUpdateTitle:function(){this.title=this.get("title"),this.show_title=this.get("show_title")},_onUpdateItems:function(){var e=this.get("items");this.items.reset(e)}}),cdb.geo.ui.CustomLegend=cdb.geo.ui.BaseLegend.extend({className:"custom-legend",type:"custom",template:_.template('<% if (title && show_title) { %>\n
      <%= title %>
      <% } %>
        '),initialize:function(){this.items=this.model.items},setData:function(e){this.items=new cdb.geo.ui.LegendItems(e),this.model.items=this.items,this.model.set("items",e)},_renderItems:function(){this.items.each(this._renderItem,this)},_renderItem:function(e){view=new cdb.geo.ui.LegendItem({model:e,className:e.get("value")&&e.get("value").indexOf("http")>=0?"bkg":"",template:'
        \n <%= name || "null" %>'}),this.$el.find("ul").append(view.render())},render:function(){if(this.model.get("template")){var e=_.template(this.model.get("template"));this.$el.html(e(this.model.toJSON()))}else this.$el.html(this.template(this.model.toJSON())),this.items.length>0?this._renderItems():this.$el.html('
        The legend is empty
        ');return this}}),cdb.geo.ui.Legend.Custom=cdb.geo.ui.CustomLegend -.extend({className:"cartodb-legend custom",type:"custom",initialize:function(){this.items=new cdb.geo.ui.LegendItems(this.options.data||this.options.items),this.model=new cdb.geo.ui.LegendModel({type:this.type,title:this.options.title,show_title:this.options.title?!0:!1,items:this.items.models}),this._bindModel()},_bindModel:function(){this.model.bind("change:items change:template change:title change:show_title",this.render,this)}}),cdb.geo.ui.BubbleLegend=cdb.geo.ui.BaseLegend.extend({className:"bubble-legend",template:_.template('<% if (title && show_title) { %>\n
        <%= title %>
        <% } %>
        • <%= min %>
        • <%= max %>
        '),initialize:function(){this.items=this.model.items},_bindModel:function(){this.model.bind("change:template change:title change:show_title change:color change:min change:max",this.render,this)},setColor:function(e){this.model.set("color",e)},setMinValue:function(e){this.model.set("min",e)},setMaxValue:function(e){this.model.set("max",e)},_renderGraph:function(e){this.$el.find(".graph").css("background",e)},render:function(){if(this.model.get("template")){var e=_.template(this.model.get("template"));this.$el.html(e(this.model.toJSON())),this.$el.removeClass("bubble-legend")}else{var t=this.model.get("color")||(this.items.length>=3?this.items.at(2).get("value"):"");if(this.items.length>=3){var n=this.model.get("min")||this.items.at(0).get("value"),r=this.model.get("max")||this.items.at(1).get("value"),i=_.extend(this.model.toJSON(),{min:n,max:r});this.$el.html(this.template(i))}this._renderGraph(t)}return this}}),cdb.geo.ui.Legend.Bubble=cdb.geo.ui.BubbleLegend.extend({className:"cartodb-legend bubble",type:"bubble",initialize:function(){this.model=new cdb.geo.ui.LegendModel({type:this.type,title:this.options.title,min:this.options.min,max:this.options.max,color:this.options.color,show_title:this.options.title?!0:!1}),this.add_related_model(this.model),this._bindModel()},render:function(){return this.$el.html(this.template(this.model.toJSON())),this._renderGraph(this.model.get("color")),this}}),cdb.geo.ui.Legend.Choropleth=cdb.geo.ui.ChoroplethLegend.extend({type:"choropleth",className:"cartodb-legend choropleth",initialize:function(){this.items=this.options.items,this.model=new cdb.geo.ui.LegendModel({type:this.type,title:this.options.title,show_title:this.options.title?!0:!1,leftLabel:this.options.left||this.options.leftLabel,rightLabel:this.options.right||this.options.rightLabel,colors:this.options.colors,buckets_count:this.options.colors?this.options.colors.length:0}),this.add_related_model(this.model),this._bindModel()},_bindModel:function(){this.model.bind("change:template change:title change:show_title change:colors change:leftLabel change:rightLabel",this.render,this)},_generateColorList:function(){return _.map(this.model.get("colors"),function(e){return'
        '}).join("")},render:function(){var e=_.extend(this.model.toJSON(),{colors:this._generateColorList()});return this.$el.html(this.template(e)),this}}),cdb.geo.ui.Legend.Intensity=cdb.geo.ui.IntensityLegend.extend({className:"cartodb-legend intensity",type:"intensity",initialize:function(){this.items=this.options.items,this.model=new cdb.geo.ui.LegendModel({type:this.type,title:this.options.title,show_title:this.options.title?!0:!1,color:this.options.color,leftLabel:this.options.left||this.options.leftLabel,rightLabel:this.options.right||this.options.rightLabel}),this.add_related_model(this.model),this._bindModel()},_bindModel:function(){this.model.bind("change:title change:show_title change:color change:leftLabel change:rightLabel",this.render,this)},render:function(){return this.$el.html(this.template(this.model.toJSON())),this._renderGraph(this.model.get("color")),this}}),cdb.geo.ui.SwitcherItemModel=Backbone.Model.extend({}),cdb.geo.ui.SwitcherItems=Backbone.Collection.extend({model:cdb.geo.ui.SwitcherItemModel}),cdb.geo.ui.SwitcherItem=cdb.core.View.extend({tagName:"li",events:{"click a":"select"},initialize:function(){_.bindAll(this,"render"),this.template=cdb.templates.getTemplate("templates/map/switcher/item"),this.parent=this.options.parent,this.model.on("change:selected",this.render)},select:function(e){e.preventDefault(),this.parent.toggle(this);var t=this.model.get("callback");t&&t()},render:function(){return this.model.get("selected")==1?this.$el.addClass("selected"):this.$el.removeClass("selected"),this.$el.html(this.template(this.model.toJSON())),this.$el}}),cdb.geo.ui.Switcher=cdb.core.View.extend({id:"switcher",default_options:{},initialize:function(){this.map=this.model,this.add_related_model(this.model),_.bindAll(this,"render","show","hide","toggle"),_.defaults(this.options,this.default_options),this.collection&&(this.model.collection=this.collection),this.template=this.options.template?this.options.template:cdb.templates.getTemplate("geo/switcher")},show:function(){this.$el.fadeIn(250)},hide:function(){this.$el.fadeOut(250)},toggle:function(e){this.collection&&this.collection.each(function(e){e.set("selected",!e.get("selected"))})},render:function(){var e=this;return this.model!=undefined&&this.$el.html(this.template(this.model.toJSON())),this.collection&&this.collection.each(function(t){var n=new cdb.geo.ui.SwitcherItem({parent:e,className:t.get("className"),model:t});e.$el.find("ul").append(n.render())}),this}}),cdb.geo.ui.InfowindowModel=Backbone.Model.extend({SYSTEM_COLUMNS:["the_geom","the_geom_webmercator","created_at","updated_at","cartodb_id","cartodb_georef_status"],defaults:{template_name:"infowindow_light",latlng:[0,0],offset:[28,0],maxHeight:180,autoPan:!0,template:"",content:"",visibility:!1,alternative_names:{},fields:null},clearFields:function(){this.set({fields:[]})},saveFields:function(e){e=e||"old_fields",this.set(e,_.clone(this.get("fields")))},fieldCount:function(){var e=this.get("fields");return e?e.length:0},restoreFields:function(e,t){t=t||"old_fields";var n=this.get(t);e&&(n=n.filter(function(t){return _.contains(e,t.name)})),n&&n.length&&this._setFields(n),this.unset(t)},_cloneFields:function(){return _(this.get("fields")).map(function(e){return _.clone(e)})},_setFields:function(e){e.sort(function(e,t){return e.position-t.position}),this.set({fields:e})},sortFields:function(){this.get("fields").sort(function(e,t){return e.position-t.position})},_addField:function(e,t){var n=$.Deferred();if(!this.containsField(e)){var r=this.get("fields");r?(t=t===undefined?r.length:t,r.push({name:e,title:!0,position:t})):(t=t===undefined?0:t,this.set("fields",[{name:e,title:!0,position:t}],{silent:!0}))}return n.resolve(),n.promise()},addField:function(e,t){var n=this;return $.when(this._addField(e,t)).then(function(){n.sortFields(),n.trigger("change:fields"),n.trigger("add:fields")}),this},getFieldProperty:function(e,t){if(this.containsField(e)){var n=this.get("fields")||[],r=_.indexOf(_(n).pluck("name"),e);return n[r][t]}return null},setFieldProperty:function(e,t,n){if(this.containsField(e)){var r=this._cloneFields()||[],i=_.indexOf(_(r).pluck("name"),e);r[i][t]=n,this._setFields(r)}return this},getAlternativeName:function(e){return this.get("alternative_names")&&this.get("alternative_names")[e]},setAlternativeName:function(e,t){var n=this.get("alternative_names")||[];n[e]=t,this.set({alternative_names:n}),this.trigger("change:alternative_names")},getFieldPos:function(e){var t=this.getFieldProperty(e,"position");return t==undefined?Number.MAX_VALUE:t},containsAlternativeName:function(e){var t=this.get("alternative_names")||[];return t[e]},containsField:function(e){var t=this.get("fields")||[];return _.contains(_(t).pluck("name"),e)},removeField:function(e){if(this.containsField(e)){var t=this._cloneFields()||[],n=_.indexOf(_(t).pluck("name"),e);n>=0&&t.splice(n,1),this._setFields(t),this.trigger("remove:fields")}return this},updateContent:function(e){var t=this.get("fields");this.set("content",cdb.geo.ui.InfowindowModel.contentForFields(e,t))}},{contentForFields:function(e,t,n){n=n||{};var r=[];for(var i=0;i0&&e.data()!=null&&e.data().jsp&&e.data().jsp.destroy();var t=_.map(this.model.attributes.content.fields,function(e){return _.clone(e)}),n=this.model.get("content")?this.model.get("content").data:{};if(this.model.get("template_name")){var r=_.clone(this.model.attributes.template_name);t=this._fieldsToString(t,r)}var i={};_.each(this.model.get("content").fields,function(e){i[e.title]=e.value});var s=_.extend({content:{fields:t,data:n}},i);this.$el.html(this.template(s)),this.model.get("width")&&this.$(".cartodb-popup").css("width",this.model.get("width")+"px"),this.$(".cartodb-popup .cartodb-popup-content").css("max-height",this.model.get("maxHeight")+"px");var o=this;setTimeout(function(){var e=o.$(".cartodb-popup-content").outerHeight();o.model.get("maxHeight")<=e&&o.$(".cartodb-popup-content").jScrollPane({maintainPosition:!1,verticalDragMinHeight:20})},1),this._checkLoading(),this._loadCover(),this.isLoadingData()||(this.model.trigger("domready",this,this.$el),this.trigger("domready",this,this.$el))}return this},_getModelTemplate:function(){return this.model.get("template_name")},_setTemplate:function(){this.model.get("template_name")&&(this.template=cdb.templates.getTemplate(this._getModelTemplate()),this.render())},_compileTemplate:function(){var e=this.model.get("template")?this.model.get("template"):cdb.templates.getTemplate(this._getModelTemplate());typeof e!="function"?this.template=(new cdb.core.Template({template:e,type:this.model.get("template_type")||"mustache"})).asFunction():this.template=e,this.render()},_checkOrigin:function(e){var t=$(e.target).closest(".jspVerticalBar").length>0&&e.type!="touchstart";t||e.stopPropagation()},_fieldsToString:function(e,t){var n=[];if(e&&e.length>0){var r=this;n=_.map(e,function(e,n){return r._sanitizeField(e,t,e.index||n)})}return n},_sanitizeField:function(e,t,n){if(e.value==null||e.value==undefined)e.value="";var r=this.model.getAlternativeName(e.title);e.title&&r?e.title=r:e.title&&(e.title=e.title.replace(/_/g," "));var i=e.value.toString();return!e.type&&n==0&&e.value.length>35&&t&&t.search("_header_")!=-1&&(i=e.value.substr(0,32)+"..."),!e.type&&n==1&&e.value.length>35&&t&&t.search("_header_with_image")!=-1&&(i=e.value.substr(0,32)+"..."),this._isValidURL(e.value)&&(i=""+i+""),n==0&&t.search("_header_with_image")!=-1&&(i=e.value),e.value=i,e},isLoadingData:function(){var e=this.model.get("content");return e.fields&&e.fields.length==1&&e.fields[0].type==="loading"},_checkLoading:function(){this.isLoadingData()?this._startSpinner():this._stopSpinner()},_stopSpinner:function(){this.spinner&&this.spinner.stop()},_startSpinner:function(e){this._stopSpinner();var e=this.$el.find(".loading");if(e){var t=this.model.get("template_name").search("dark")!=-1;t?this.spin_options.color="#FFF":this.spin_options.color="rgba(0,0,0,0.5)",this.spinner=(new Spinner(this.spin_options)).spin(),e.append(this.spinner.el)}},_containsCover:function(){return this.$el.find(".cartodb-popup.header").attr("data-cover")?!0:!1},_getCoverURL:function(){var e=this.model.get("content");return e&&e.fields&&e.fields.length>0?(e.fields[0].value||"").toString():!1},_loadCover:function(){if(!this._containsCover())return;var e=this,t=this.$(".cover"),n=this.$(".shadow"),r=this._getCoverURL();if(!this._isValidURL(r)){n.hide(),cdb.log.info("Header image url not valid");return}var i=document.getElementById("spinner"),s={lines:9,length:4,width:2,radius:4,corners:1,rotate:0,color:"#ccc",speed:1,trail:60,shadow:!0,hwaccel:!1,zIndex:2e9},o=(new Spinner(s)).spin(i),u=t.find("img");u.hide(function(){this.remove()}),u=$("").attr("src",r),t.append(u),u.load(function(){o.stop();var e=u.width(),n=u.height(),r=t.width(),i=t.height(),s=n/e,a=i/r;if(e>r&&n>i)if(s8?(this.$el.css({marginBottom:"-10px",display:"block",opacity:0}),this.$el.delay(e).animate({opacity:1,marginBottom:0},300)):this.$el.show()},_animateOut:function(){if(!$.browser.msie||$.browser.msie&&parseInt($.browser.version)>8){var e=this;this.$el.animate({marginBottom:"-10px",opacity:"0",display:"block"},180,function(){e.$el.css({display:"none"})})}else this.$el.hide()},_updatePosition:function(){if(this.isHidden())return;var e=this.model.get("offset");pos=this.mapView.latLonToPixel(this.model.get("latlng")),x=this.$el.position().left,y=this.$el.position().top,containerHeight=this.$el.outerHeight(!0),containerWidth=this.$el.width(),left=pos.x-e[0],size=this.mapView.getSize(),bottom=-1*(pos.y-e[1]-size.y),this.$el.css({bottom:bottom,left:left})},adjustPan:function(e){var t=this.model.get("offset");if(!this.model.get("autoPan")||this.isHidden())return;var n=this.$el.position().left,r=this.$el.position().top,i=this.$el.outerHeight(!0)+15,s=this.$el.width(),o=this.mapView.latLonToPixel(this.model.get("latlng")),u={x:0,y:0};size=this.mapView.getSize(),wait_callback=0,o.x-t[0]<0&&(u.x=o.x-t[0]-10),o.x-t[0]+s>size.x&&(u.x=o.x+s-size.x-t[0]+10),o.y-i<0&&(u.y=o.y-i-10),o.y-i>size.y&&(u.y=o.y+i-size.y);if(u.x||u.y)this.mapView.panBy(u),wait_callback=300;return wait_callback}}),cdb.geo.ui.Header=cdb.core.View.extend({className:"cartodb-header",initialize:function(){var e=this.model.get("extra");this.model.set({title:e.title,description:this._setLinksTarget(e.description),show_title:e.show_title,show_description:e.show_description},{silent:!0})},show:function(){var e=this.model.get("title")&&this.model.get("show_title"),t=this.model.get("description")&&this.model.get("show_description");if(e||t){var n=this;this.$el.show(),e&&n.$title.show(),t&&n.$description.show()}},_setLinksTarget:function(e){if(!e)return e;var t=new RegExp(/<(a)([^>]+)>/g);return e.replace(t,'<$1 target="_blank"$2>')},render:function(){return this.$el.html(this.options.template(this.model.attributes)),this.$title=this.$el.find(".content div.title"),this.$description=this.$el.find(".content div.description"),this.model.get("show_title")||this.model.get("show_description")?this.show():this.hide(),this}}),cdb.geo.ui.Search=cdb.core.View.extend({className:"cartodb-searchbox",events:{"click input[type='text']":"_focus","submit form":"_submit",click:"_stopPropagation",dblclick:"_stopPropagation",mousedown:"_stopPropagation"},initialize:function(){},render:function(){return this.$el.html(this.options.template(this.options)),this},_stopPropagation:function(e){e.stopPropagation()},_focus:function(e){e.preventDefault(),$(e.target).focus()},_showLoader:function(){this.$("span.loader").show()},_hideLoader:function(){this.$("span.loader").hide()},_submit:function(e){e.preventDefault();var t=this,n=this.$("input.text").val();this._showLoader(),cdb.geo.geocoder.NOKIA.geocode(n,function(e){if(e.length>0){var n=!0;if(!e[0].boundingbox||e[0].boundingbox.south==e[0].boundingbox.north||e[0].boundingbox.east==e[0].boundingbox.west)n=!1;n&&e[0].boundingbox?t.model.setBounds([[parseFloat(e[0].boundingbox.south),parseFloat(e[0].boundingbox.west)],[parseFloat(e[0].boundingbox.north),parseFloat(e[0].boundingbox.east)]]):e[0].lat&&e[0].lon&&(t.model.setCenter([e[0].lat,e[0].lon]),t.model.setZoom(10))}t._hideLoader()})}}),cdb.geo.ui.LayerSelector=cdb.core.View.extend({className:"cartodb-layer-selector-box",events:{click:"_openDropdown",dblclick:"killEvent",mousedown:"killEvent"},initialize:function(){this.map=this.options.mapView.map,this.mapView=this.options.mapView,this.mapView.bind("click zoomstart drag",function(){this.dropdown&&this.dropdown.hide()},this),this.add_related_model(this.mapView),this.layers=[]},render:function(){return this.$el.html(this.options.template(this.options)),this.dropdown=new cdb.ui.common.Dropdown({className:"cartodb-dropdown border",template:this.options.dropdown_template,target:this.$el.find("a"),speedIn:300,speedOut:200,position:"position",tick:"right",vertical_position:"down",horizontal_position:"right",vertical_offset:7,horizontal_offset:13}),cdb.god&&cdb.god.bind("closeDialogs",this.dropdown.hide,this.dropdown),this.$el.append(this.dropdown.render().el),this._getLayers(),this._setCount(),this},_getLayers:function(){var e=this;this.layers=[],_.each(this.map.layers.models,function(t){if(t.get("type")=="layergroup"||t.get("type")==="namedmap"){var n=e.mapView.getLayerByCid(t.cid);for(var r=0;r<%= layer_name %> switch"> '},events:{click:"_onSwitchClick"},initialize:function(){this.model.has("visible")||this.model.set("visible",!1),this.model.bind("change:visible",this._onSwitchSelected,this),this.add_related_model(this.model),this._onSwitchSelected(),this.template=this.options.template?cdb.templates.getTemplate(this.options.template):_.template(this.defaults.template)},render:function(){var e=_.clone(this.model.attributes);return e.layer_name=e.layer_name||e.table_name,this.$el.append(this.template(e)),this},_onSwitchSelected:function(){var e=this.model.get("visible");this.$el.find(".switch").removeClass(e?"disabled":"enabled").addClass(e?"enabled":"disabled"),this.trigger("switchChanged")},_onSwitchClick:function(e){this.killEvent(e),this.model.set("visible",!this.model.get("visible"))}}),cdb.geo.ui.LayerViewFromLayerGroup=cdb.geo.ui.LayerView.extend({_onSwitchSelected:function(){cdb.geo.ui.LayerView.prototype._onSwitchSelected.call(this);var e=this.options.layerView.getSubLayer(this.options.layerIndex),t=this.model.get("visible");t?e.show():e.hide()}}),cdb.geo.ui.MobileLayer=cdb.core.View.extend({events:{"click h3":"_toggle",dblclick:"_stopPropagation"},tagName:"li",className:"cartodb-mobile-layer has-toggle",template:cdb.core.Template.compile("<% if (show_title) { %>

        <%= layer_name %><% } %>

        "),_stopPropagation:function(e){e.stopPropagation()},initialize:function(){_.defaults(this.options,this.default_options),this.model.bind("change:visible",this._onChangeVisible,this)},_onChangeVisible:function(){this.$el.find(".legend")[this.model.get("visible")?"fadeIn":"fadeOut"](150),this.$el[this.model.get("visible")?"removeClass":"addClass"]("hidden"),this.trigger("change_visibility",this)},_toggle:function(e){e.preventDefault(),e.stopPropagation();if(this.options.hide_toggle)return;this.model.set("visible",!this.model.get("visible"))},_renderLegend:function(){if(!this.options.show_legends)return;if(this.model.get("legend")&&(this.model.get("legend").type=="none"||!this.model.get("legend").type))return;if(this.model.get("legend")&&this.model.get("legend").items&&this.model.get("legend").items.length==0)return;this.$el.addClass("has-legend");var e=new cdb.geo.ui.Legend(this.model.get("legend"));e.undelegateEvents(),this.$el.append(e.render().$el)},_truncate:function(e,t){return e.substr(0,t-1)+(e.length>t?"…":"")},render:function(){var e=this.model.get("layer_name");e=e?this._truncate(e,23):"untitled";var t=_.extend(this.model.attributes,{layer_name:this.options.show_title?e:"",toggle_class:this.options.hide_toggle?" hide":""});return this.$el.html(this.template(_.extend(t,{show_title:this.options.show_title}))),this.options.hide_toggle&&this.$el.removeClass("has-toggle"),this.model.get("visible")||this.$el.addClass("hidden"),this.model.get("legend")&&this._renderLegend(),this._onChangeVisible(),this}}),cdb.geo.ui.Mobile=cdb.core.View.extend({className:"cartodb-mobile",events:{"click .cartodb-attribution-button":"_onAttributionClick","click .toggle":"_toggle","click .fullscreen":"_toggleFullScreen","click .backdrop":"_onBackdropClick","dblclick .aside":"_stopPropagation","dragstart .aside":"_checkOrigin","mousedown .aside":"_checkOrigin","touchstart .aside":"_checkOrigin","MSPointerDown .aside":"_checkOrigin"},initialize:function(){_.bindAll(this,"_toggle","_reInitScrollpane"),_.defaults(this.options,this.default_options),this.hasLayerSelector=!1,this.mobileEnabled=/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),this.visibility_options=this.options.visibility_options||{},this.mapView=this.options.mapView,this.map=this.mapView.map,this.template=this.options.template?this.options.template:cdb.templates.getTemplate("geo/zoom"),this.overlays=this.options.overlays,this._setupModel(),window.addEventListener("orientationchange",_.bind(this.doOnOrientationChange,this)),this._addWheelEvent()},_addWheelEvent:function(){var e=this,t=this.options.mapView;$(document).on("webkitfullscreenchange mozfullscreenchange fullscreenchange",function(){!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement&&t.options.map.set("scrollwheel",!1),t.invalidateSize()})},_setupModel:function(){this.model=new Backbone.Model({open:!1,layer_count:0}),this.model.on("change:open",this._onChangeOpen,this),this.model.on("change:layer_count",this._onChangeLayerCount,this)},_checkOrigin:function(e){var t=$(e.target).closest(".jspVerticalBar").length>0&&e.type!="touchstart";t||e.stopPropagation()},_stopPropagation:function(e){e.stopPropagation()},_onBackdropClick:function(e){e.preventDefault(),e.stopPropagation(),this.$el.find(".backdrop").fadeOut(250),this.$el.find(".cartodb-attribution").fadeOut(250)},_onAttributionClick:function(e){e.preventDefault(),e.stopPropagation(),this.$el.find(".backdrop").fadeIn(250),this.$el.find(".cartodb-attribution").fadeIn(250)},_toggle:function(e){e.preventDefault(),e.stopPropagation(),this.model.set("open",!this.model.get("open"))},_toggleFullScreen:function(e){e.stopPropagation(),e.preventDefault();var t=window.document,n=$("#map > div")[0],r=n.requestFullscreen||n.mozRequestFullScreen||n.webkitRequestFullScreen,i=t.exitFullscreen||t.mozCancelFullScreen||t.webkitExitFullscreen,s=this.options.mapView;!t.fullscreenElement&&!t.mozFullScreenElement&&!t.webkitFullscreenElement?(r.call(n),s&&s.options.map.set("scrollwheel",!0)):i.call(t)},_open:function(){var e=this.$el.find(".aside").width();this.$el.find(".cartodb-header").animate({right:e},200),this.$el.find(".aside").animate({right:0},200),this.$el.find(".cartodb-attribution-button").animate({right:e+parseInt(this.$el.find(".cartodb-attribution-button").css("right"))},200),this.$el.find(".cartodb-attribution").animate({right:e+parseInt(this.$el.find(".cartodb-attribution-button").css("right"))},200),this._initScrollPane()},_close:function(){this.$el.find(".cartodb-header").animate({right:0},200),this.$el.find(".aside").animate({right:-this.$el.find(".aside").width()},200),this.$el.find(".cartodb-attribution-button").animate({right:20},200),this.$el.find(".cartodb-attribution").animate({right:20},200)},default_options:{timeout:0,msg:""},_stopPropagation:function(e){e.stopPropagation()},doOnOrientationChange:function(){switch(window.orientation){case-90:case 90:this.recalc("landscape");break;default:this.recalc("portrait")}},recalc:function(e){var t=$(".legends > div.cartodb-legend-stack").height();this.$el.hasClass("open")&&t<100&&!this.$el.hasClass("torque")?(this.$el.css("height",t),this.$el.find(".top-shadow").hide(),this.$el.find(".bottom-shadow").hide()):this.$el.hasClass("open")&&t<100&&this.$el.hasClass("legends")&&this.$el.hasClass("torque")&&(this.$el.css("height",t+$(".legends > div.torque").height()),this.$el.find(".top-shadow").hide(),this.$el.find(".bottom-shadow").hide())},_onChangeLayerCount:function(){var e=this.model.get("layer_count"),t=e+" layer"+(e!=1?"s":"");this.$el.find(".aside .layer-container > h3").html(t)},_onChangeOpen:function(){this.model.get("open")?this._open():this._close()},_createLayer:function(e,t){return new cdb.geo.ui[e](t)},_getLayers:function(){this.layers=[],this.options.layerView?this._getLayersFromLayerView():_.each(this.map.layers.models,this._getLayer,this)},_getLayersFromLayerView:function(){if(this.options.layerView&&this.options.layerView.model.get("type")=="layergroup")this.layers=_.map(this.options.layerView.layers,function(t,n){var r=new cdb.core.Model(t);return r.set("order",n),r.set("type","layergroup"),r.set("visible",t.visible),r.set("layer_name",t.options.layer_name),e=this._createLayer("LayerViewFromLayerGroup",{model:r,layerView:this.options.layerView,layerIndex:n}),e.model},this);else if(this.options.layerView&&this.options.layerView.model.get("type")=="torque"){var e=this._createLayer("LayerView",{model:this.options.layerView.model});this.layers.push(e.model)}},_getLayer:function(e){if(e.get("type")=="layergroup"||e.get("type")==="namedmap"){var t=this.mapView.getLayerByCid(e.cid);for(var n=0;n+ -
        ',"mustache"),t=new cdb.geo.ui.Zoom({model:this.options.map,template:e});this.$el.append(t.render().$el),this.$el.addClass("with-zoom")},_addFullscreen:function(){this.visibility_options.fullscreen!=0&&(this.hasFullscreen=!0,this.$el.addClass("with-fullscreen"))},_addSearch:function(){this.hasSearch=!0;var e=cdb.core.Template.compile('
        ',"mustache"),t=new cdb.geo.ui.Search({template:e,model:this.mapView.map});this.$el.find(".aside").prepend(t.render().$el),this.$el.find(".cartodb-searchbox").show(),this.$el.addClass("with-search")},_addHeader:function(e){this.hasHeader=!0,this.$header=this.$el.find(".cartodb-header");var t=_.template('
        <% if (show_title) { %>
        <%= title %>
        <% } %><% if (show_description) { %>
        <%= description %><% } %>
        ' -),n=e.options.extra,r=!1,i=!1,s=!1;if(n){if(this.visibility_options.title||this.visibility_options.title!=0&&n.show_title)r=!0,i=!0;if(this.visibility_options.description||this.visibility_options.description!=0&&n.show_description)r=!0,s=!0;var o=t({title:n.title,show_title:i,description:n.description,show_description:s});r&&(this.$el.addClass("with-header"),this.$header.find(".content").append(o))}},_addAttributions:function(){var e="";this.options.mapView.$el.find(".leaflet-control-attribution").hide(),this.options.layerView?(e=this.options.layerView.model.get("attribution"),this.$el.find(".cartodb-attribution").append(e)):this.options.map.get("attribution")&&(e=this.options.map.get("attribution"),_.each(e,function(e){var t=$("
      • "),n=t.html(e);this.$el.find(".cartodb-attribution").append(t)},this)),e&&this.$el.find(".cartodb-attribution-button").fadeIn(250)},_renderLayers:function(){var e=this.visibility_options.legends,t=this.layers.filter(function(e){return e.get("legend")&&e.get("legend").type!=="none"}),n=t.length?!0:!1;if(!this.hasLayerSelector&&!e)return;if(!this.hasLayerSelector&&!n)return;if(this.layers.length==0)return;if(this.layers.length==1&&!n)return;this.$el.addClass("with-layers"),this.model.set("layer_count",0),this.hasSearch||this.$el.find(".aside .layer-container").prepend("

        "),_.each(this.layers,this._renderLayer,this)},_renderLayer:function(e){var t=e.get("legend")&&e.get("legend").type!==""&&e.get("legend").type!=="none";if(!this.hasLayerSelector&&!t)return;if(!this.hasLayerSelector&&!e.get("visible"))return;var n=this.layers.length==1||!this.hasLayerSelector,r=!0;this.visibility_options&&this.visibility_options.legends!==undefined&&(r=this.visibility_options.legends);var i=new cdb.geo.ui.MobileLayer({model:e,show_legends:r,show_title:this.hasLayerSelector?!0:!1,hide_toggle:n});this.$el.find(".aside .layers").append(i.render().$el),i.bind("change_visibility",this._reInitScrollpane,this),this.model.set("layer_count",this.model.get("layer_count")+1)},_renderTorque:function(){this.options.torqueLayer&&(this.hasTorque=!0,this.slider=new cdb.geo.ui.TimeSlider({type:"time_slider",layer:this.options.torqueLayer,map:this.options.map,pos_margin:0,position:"none",width:"auto"}),this.slider.bind("time_clicked",function(){this.slider.toggleTime()},this),this.$el.find(".torque").append(this.slider.render().$el),this.options.torqueLayer.hidden?this.slider.hide():this.$el.addClass("with-torque"))},render:function(){return this._bindOrientationChange(),this.$el.html(this.template(this.options)),this._renderOverlays(),this._addAttributions(),this.$header=this.$el.find(".cartodb-header"),this.$header.show(),this._getLayers(),this._renderLayers(),this._renderTorque(),this}}),cdb.geo.ui.TilesLoader=cdb.core.View.extend({className:"cartodb-tiles-loader",default_options:{animationSpeed:500},initialize:function(){_.defaults(this.options,this.default_options),this.isVisible=0,this.template=this.options.template?this.options.template:cdb.templates.getTemplate("geo/tiles_loader")},render:function(){return this.$el.html($(this.template(this.options))),this},show:function(e){if(this.isVisible)return;!$.browser.msie||$.browser.msie&&$.browser.version.indexOf("9.")!=0?this.$el.fadeTo(this.options.animationSpeed,1):this.$el.show(),this.isVisible++},hide:function(e){this.isVisible--;if(this.isVisible>0)return;this.isVisible=0,!$.browser.msie||$.browser.msie&&$.browser.version.indexOf("9.")==0?this.$el.stop(!0).fadeTo(this.options.animationSpeed,0):this.$el.hide()},visible:function(){return this.isVisible>0}}),cdb.geo.ui.InfoBox=cdb.core.View.extend({className:"cartodb-infobox",defaults:{pos_margin:20,position:"bottom|right",width:200},initialize:function(){var e=this;_.defaults(this.options,this.defaults),this.options.layer&&this.enable(),this.setTemplate(this.options.template||this.defaultTemplate,"mustache")},setTemplate:function(e){this.template=cdb.core.Template.compile(e,"mustache")},enable:function(){this.options.layer&&this.options.layer.on("featureOver",function(e,t,n,r){this.render(r).show()},this).on("featureOut",function(){this.hide()},this)},disable:function(){this.options.layer&&this.options.layer.off(null,null,this)},setPosition:function(e){var t={};e.indexOf("top")!==-1?t.top=this.options.pos_margin:e.indexOf("bottom")!==-1&&(t.bottom=this.options.pos_margin),e.indexOf("left")!==-1?t.left=this.options.pos_margin:e.indexOf("right")!==-1&&(t.right=this.options.pos_margin),this.$el.css(t)},render:function(e){return this.$el.html(this.template(e)),this.options.width&&this.$el.css("width",this.options.width),this.options.position&&this.setPosition(this.options.position),this}}),cdb.geo.ui.Tooltip=cdb.geo.ui.InfoBox.extend({defaultTemplate:"

        {{text}}

        ",className:"cartodb-tooltip",defaults:{vertical_offset:0,horizontal_offset:0,position:"top|center"},initialize:function(){this.options.template=this.options.template||this.defaultTemplate,cdb.geo.ui.InfoBox.prototype.initialize.call(this),this._filter=null,this.showing=!1,this.showhideTimeout=null},setLayer:function(e){return this.options.layer=e,this},setFilter:function(e){return this._filter=e,this},setFields:function(e){return this.options.fields=e,this},setAlternativeNames:function(e){this.options.alternative_names=e},enable:function(){this.options.layer&&(this.options.layer.unbind(null,null,this),this.options.layer.on("mouseover",function(e,t,n,r){if(this.options.fields){var i=["fields","content"];this.options.omit_columns&&(i=i.concat(this.options.omit_columns));var s=cdb.geo.ui.InfowindowModel.contentForFields(r,this.options.fields,{empty_fields:this.options.empty_fields});r.content=_.omit(r,i),r.fields=s.fields;var o=this.options.alternative_names;if(o)for(var u=0;u=t.length?-1:+t[e]},visibleLayers:function(){var e=[];for(var t=0;t>18&63,o=f>>12&63,u=f>>6&63,a=f&63,p[c++]=t.charAt(s)+t.charAt(o)+t.charAt(u)+t.charAt(a);while(l0?n:null},containInfowindow:function(){var e=this.options.layer_definition.layers;for(var t=0;t0)return!0}return!1},containTooltip:function(){var e=this.options.layer_definition.layers;for(var t=0;t0)return!0}return!1},containTooltip:function(){var e=this.layers||[];for(var t=0;t=0&&(this.layers.splice(e,1),this.interactionEnabled.splice(e,1),this._reorderSubLayers(),this.invalidate()),this},_reorderSubLayers:function(){for(var e=0;e=0){if(!e.sql||!e.cartocss)throw new Error("layer definition should contain at least a sql and a cartocss");this.layers.splice(t,0,{type:"cartodb",options:e}),this._definitionUpdated()}return this},setInteractivity:function(e,t){t===undefined&&(t=e,e=0);if(e>=this.getLayerCount()&&e<0)throw new Error("layer does not exist");typeof t=="string"&&(t=t.split(","));for(var n=0;n>>1:e>>>1;t[n]=e}return t},cartodb.crc32=function(e){var t=cartodb._crcTable||(cartodb._crcTable=cartodb._makeCRCTable()),n=-1;for(var r=0,i=e.length;r>>8^t[(n^e.charCodeAt(r))&255];return(n^-1)>>>0},cartodb.uniqueCallbackName=function(e){return cartodb._callback_c=cartodb._callback_c||0,++cartodb._callback_c,cartodb.crc32(e)+"_"+cartodb._callback_c},CartoDBLayerCommon.prototype={show:function(){this.setOpacity(this.options.previous_opacity===undefined?.99:this.options.previous_opacity),delete this.options.previous_opacity,this._interactionDisabled=!1,this.visible=!0},hide:function(){this.options.previous_opacity==undefined&&(this.options.previous_opacity=this.options.opacity),this.setOpacity(0),this._interactionDisabled=!0,this.visible=!1},toggle:function(){return this.isVisible()?this.hide():this.show(),this.isVisible()},isVisible:function(){return this.visible},setInteraction:function(e,t){t==undefined&&(t=e,e=0);var n;this.interactionEnabled[e]=t;if(!t)n=this.interaction[e],n&&(n.remove(),this.interaction[e]=null);else if(this.urls){var r=this.getLayerIndexByNumber(+e),i=this._tileJSONfromTiles(r,this.urls);n=this.interaction[e],n&&n.remove();var s=this;this.interaction[e]=this.interactionClass().map(this.options.map).tilejson(i).on("on",function(t){if(s._interactionDisabled)return;t.layer=+e,s._manageOnEvents(s.options.map,t)}).on("off",function(t){if(s._interactionDisabled)return;t=t||{},t.layer=+e,s._manageOffEvents(s.options.map,t)})}return this},setOptions:function(e){if(typeof e!="object"||e.length)throw new Error(e+" options must be an object");_.extend(this.options,e);var e=this.options;this.options.query=this.options.query||"select * from "+this.options.table_name,this.options.query_wrapper&&(this.options.query=_.template(this.options.query_wrapper)({sql:this.options.query})),this.setSilent(!0),e.interaction&&this.setInteraction(e.interaction),e.opacity&&this.setOpacity(e.opacity),e.query&&this.setQuery(e.query.replace(/\{\{table_name\}\}/g,this.options.table_name)),e.tile_style&&this.setCartoCSS(e.tile_style.replace(new RegExp(e.table_name,"g"),"layer0")),e.cartocss&&this.setCartoCSS(e.cartocss),e.interactivity&&this.setInteractivity(e.interactivity),e.visible?this.show():this.hide(),this.setSilent(!1),this._definitionUpdated()},_getLayerDefinition:function(){var e={},t=this.options,n,r,i;n=t.query||"select * from "+t.table_name,t.query_wrapper&&(n=_.template(t.query_wrapper)({sql:n})),r=t.tile_style,i=t.cartocss_version||"2.1.0";for(var s in t.extra_params){var o=t.extra_params[s];e[s]=o.replace?o.replace(/\{\{table_name\}\}/g,t.table_name):o}return n=n.replace(/\{\{table_name\}\}/g,t.table_name),r=r.replace(/\{\{table_name\}\}/g,t.table_name),r=r.replace(new RegExp(t.table_name,"g"),"layer0"),{sql:n,cartocss:r,cartocss_version:i,params:e,interactivity:t.interactivity}},error:function(e){},tilesOk:function(){},_clearInteraction:function(){for(var e in this.interactionEnabled)this.interactionEnabled.hasOwnProperty(e)&&this.interactionEnabled[e]&&this.setInteraction(e,!1)},_reloadInteraction:function(){for(var e in this.interactionEnabled)this.interactionEnabled.hasOwnProperty(e)&&this.interactionEnabled[e]&&(this.setInteraction(e,!1),this.setInteraction(e,!0))},_checkTiles:function(){var e={z:4,x:6,y:6},t=this,n=new Image,r=this._tileJSON();getTiles(function(n){var r=n.tiles[0].replace(/\{z\}/g,e.z).replace(/\{x\}/g,e.x).replace(/\{y\}/g,e.y);this.options.ajax({method:"get",url:r,crossDomain:!0,success:function(){t.tilesOk(),clearTimeout(i)},error:function(e,n,r){clearTimeout(i),t.error(e.responseText&&JSON.parse(e.responseText))}})});var i=setTimeout(function(){clearTimeout(i),t.error("tile timeout")},3e4)}},cdb.geo.common={},cdb.geo.common.CartoDBLogo={isWadusAdded:function(e,t){var n=[],r=new RegExp("\\b"+t+"\\b"),i=e.getElementsByTagName("*");for(var s=0,o=i.length;s0},isRetinaBrowser:function(){return"devicePixelRatio"in window&&window.devicePixelRatio>1||"matchMedia"in window&&window.matchMedia("(min-resolution:144dpi)")&&window.matchMedia("(min-resolution:144dpi)").matches},addWadus:function(e,t,n){var r=this;setTimeout(function(){if(!r.isWadusAdded(n,"cartodb-logo")){var t=document.createElement("div"),i=r.isRetinaBrowser();t.setAttribute("class","cartodb-logo"),t.setAttribute("style","position:absolute; bottom:0; left:0; display:block; border:none; z-index:1000000;");var s=location.protocol.indexOf("https")===-1?"http":"https",o=cdb.config.get("cartodb_logo_link");t.innerHTML="CartoDB",n.appendChild(t)}},t||0)}},function(){var e=function(e,t,n){this.leafletLayer=t,this.leafletMap=n,this.model=e,this.model.bind("change",this._modelUpdated,this),this.type=e.get("type")||e.get("kind"),this.type=this.type.toLowerCase()};_.extend(e.prototype,Backbone.Events),_.extend(e.prototype,{remove:function(){this.leafletMap.removeLayer(this.leafletLayer),this.model.unbind(null,null,this),this.unbind()},reload:function(){this.leafletLayer.redraw()}}),cdb.geo.LeafLetLayerView=e}(),function(){if(typeof L=="undefined")return;var e=L.Class.extend({includes:L.Mixin.Events,initialize:function(e,t){cdb.geo.LeafLetLayerView.call(this,e,this,t)},onAdd:function(){this.redraw()},onRemove:function(){var e=this.leafletMap.getContainer();e.style.background="none"},_modelUpdated:function(){this.redraw()},redraw:function(){var e=this.leafletMap.getContainer();e.style.backgroundColor=this.model.get("color")||"#FFF";if(this.model.get("image")){var t="transparent url("+this.model.get("image")+") repeat center center";e.style.background=t}}});_.extend(e.prototype,cdb.geo.LeafLetLayerView.prototype),cdb.geo.LeafLetPlainLayerView=e}(),function(){if(typeof L=="undefined")return;var e=L.TileLayer.extend({initialize:function(e,t){L.TileLayer.prototype.initialize.call(this,e.get("urlTemplate"),{tms:e.get("tms"),attribution:e.get("attribution"),minZoom:e.get("minZomm"),maxZoom:e.get("maxZoom"),subdomains:e.get("subdomains")||"abc",errorTileUrl:e.get("errorTileUrl"),opacity:e.get("opacity")}),cdb.geo.LeafLetLayerView.call(this,e,this,t)}});_.extend(e.prototype,cdb.geo.LeafLetLayerView.prototype,{_modelUpdated:function(){_.defaults(this.leafletLayer.options,_.clone(this.model.attributes)),this.leafletLayer.options.subdomains=this.model.get("subdomains")||"abc",this.leafletLayer.options.attribution=this.model.get("attribution"),this.leafletLayer.options.maxZoom=this.model.get("maxZoom"),this.leafletLayer.options.minZoom=this.model.get("minZoom"),this.leafletLayer.setUrl(this.model.get("urlTemplate"))}}),cdb.geo.LeafLetTiledLayerView=e}(),function(){if(typeof L=="undefined")return;var e=L.TileLayer.WMS.extend({initialize:function(e,t){L.TileLayer.WMS.prototype.initialize.call(this,e.get("urlTemplate"),{attribution:e.get("attribution"),layers:e.get("layers"),format:e.get("format"),transparent:e.get("transparent"),minZoom:e.get("minZomm"),maxZoom:e.get("maxZoom"),subdomains:e.get("subdomains")||"abc",errorTileUrl:e.get("errorTileUrl"),opacity:e.get("opacity")}),cdb.geo.LeafLetLayerView.call(this,e,this,t)}});_.extend(e.prototype,cdb.geo.LeafLetLayerView.prototype,{_modelUpdated:function(){_.defaults(this.leafletLayer.options,_.clone(this.model.attributes)),this.leafletLayer.setUrl(this.model.get("urlTemplate"))}}),cdb.geo.LeafLetWMSLayerView=e}(),function(){function e(e){var t=e.extend({includes:[cdb.geo.LeafLetLayerView.prototype,Backbone.Events],initialize:function(t,n){var r=this,i=[];t.attributes.attribution=cdb.config.get("cartodb_attributions");var s=_.clone(t.attributes);s.map=n;var o=s.featureOver,u=s.featureOut,a=s.featureClick,f,l=-1;s.featureOver=function(e,t,n,s,u){i[u]||r.trigger("layerenter",e,t,n,s,u),i[u]=1,o&&o.apply(this,arguments),r.featureOver&&r.featureOver.apply(r,arguments),e.timeStamp===f&&clearTimeout(l),l=setTimeout(function(){r.trigger("mouseover",e,t,n,s,u),r.trigger("layermouseover",e,t,n,s,u)},0),f=e.timeStamp},s.featureOut=function(e,t){i[t]&&r.trigger("layermouseout",t),i[t]=0,_.any(i)||r.trigger("mouseout"),u&&u.apply(this,arguments),r.featureOut&&r.featureOut.apply(r,arguments)},s.featureClick=_.debounce(function(){a&&a.apply(r,arguments),r.featureClick&&r.featureClick.apply(r,arguments)},10),e.prototype.initialize.call(this,s),cdb.geo.LeafLetLayerView.call(this,t,this,n)},featureOver:function(e,t,n,r,i){this.trigger("featureOver",e,[t.lat,t.lng],n,r,i)},featureOut:function(e,t){this.trigger("featureOut",e,t)},featureClick -:function(e,t,n,r,i){this.trigger("featureClick",e,[t.lat,t.lng],n,r,i)},error:function(e){this.trigger("error",e?e.errors:"unknown error"),this.model.trigger("error",e?e.errors:"unknown error")},ok:function(e){this.model.trigger("tileOk")},onLayerDefinitionUpdated:function(){this.__update()}});return t}if(typeof L=="undefined")return;L.CartoDBGroupLayerBase=L.TileLayer.extend({interactionClass:wax.leaf.interaction,includes:[cdb.geo.LeafLetLayerView.prototype,CartoDBLayerCommon.prototype],options:{opacity:.99,attribution:"CartoDB",debug:!1,visible:!0,added:!1,tiler_domain:"cartodb.com",tiler_port:"80",tiler_protocol:"http",sql_api_domain:"cartodb.com",sql_api_port:"80",sql_api_protocol:"http",maxZoom:30,extra_params:{},cdn_url:null,subdomains:null},initialize:function(e){e=e||{},L.Util.setOptions(this,e);if(!e.layer_definition&&!e.sublayers)throw new Error("cartodb-leaflet needs at least the layer_definition or sublayer list");e.layer_definition||(this.options.layer_definition=LayerDefinition.layerDefFromSubLayers(e.sublayers)),LayerDefinition.call(this,this.options.layer_definition,this.options),this.fire=this.trigger,CartoDBLayerCommon.call(this),L.TileLayer.prototype.initialize.call(this),this.interaction=[],this.addProfiling()},addProfiling:function(){this.bind("tileloadstart",function(e){var t=this.tileStats||(this.tileStats={});t[e.tile.src]=cartodb.core.Profiler.metric("cartodb-js.tile.png.load.time").start()});var e=function(e){var t=this.tileStats&&this.tileStats[e.tile.src];t&&t.end()};this.bind("tileload",e),this.bind("tileerror",function(t){cartodb.core.Profiler.metric("cartodb-js.tile.png.error").inc(),e(t)})},getTileUrl:function(e){var t="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";this._adjustTilePoint(e);var n=[t];this.tilejson&&(n=this.tilejson.tiles);var r=(e.x+e.y)%n.length;return L.Util.template(n[r],L.Util.extend({z:this._getZoomForUrl(),x:e.x,y:e.y},this.options))},setOpacity:function(e){if(isNaN(e)||e>1||e<0)throw new Error(e+" is not a valid value");this.options.opacity=Math.min(e,.99),this.options.visible&&(L.TileLayer.prototype.setOpacity.call(this,this.options.opacity),this.fire("updated"))},onAdd:function(e){var t=this;this.options.map=e,this.options.cartodb_logo!=0&&cdb.geo.common.CartoDBLogo.addWadus({left:8,bottom:8},0,e._container),this.__update(function(){var n=L.stamp(t);if(!e._layers[n])return;L.TileLayer.prototype.onAdd.call(t,e),t.fire("added"),t.options.added=!0})},onRemove:function(e){this.options.added&&(this.options.added=!1,L.TileLayer.prototype.onRemove.call(this,e))},__update:function(e){var t=this;this.fire("updated"),this.fire("loading");var n=this.options.map;this.getTiles(function(n,r){n?(t.tilejson=n,t.setUrl(t.tilejson.tiles[0]),t._reloadInteraction(),t.ok&&t.ok(),e&&e()):(t.error&&t.error(r),e&&e())})},_checkLayer:function(){if(!this.options.added)throw new Error("the layer is not still added to the map")},setAttribution:function(e){this._checkLayer(),this.map.attributionControl.removeAttribution(this.options.attribution),this.options.attribution=e,this.map.attributionControl.addAttribution(this.options.attribution),this.options.attribution=this.options.attribution,this.tilejson.attribution=this.options.attribution,this.fire("updated")},_manageOnEvents:function(e,t){var n=this._findPos(e,t),r=e.layerPointToLatLng(n),i=t.e.type.toLowerCase(),s=e.layerPointToContainerPoint(n);switch(i){case"mousemove":if(this.options.featureOver)return this.options.featureOver(t.e,r,s,t.data,t.layer);break;case"click":case"touchend":case"mspointerup":this.options.featureClick&&this.options.featureClick(t.e,r,s,t.data,t.layer);break;default:}},_manageOffEvents:function(e,t){if(this.options.featureOut)return this.options.featureOut&&this.options.featureOut(t.e,t.layer)},_findPos:function(e,t){var n=0,r=0,i=e.getContainer(),s,o;t.e.changedTouches&&t.e.changedTouches.length>0?(s=t.e.changedTouches[0].clientX+window.scrollX,o=t.e.changedTouches[0].clientY+window.scrollY):(s=t.e.clientX,o=t.e.clientY);if(i.offsetParent){do n+=i.offsetLeft,r+=i.offsetTop;while(i=i.offsetParent);return e.containerPointToLayerPoint(new L.Point(s-n,o-r))}var u=i.getBoundingClientRect(),a=new L.Point(t.e.clientX-u.left-i.clientLeft-window.scrollX,t.e.clientY-u.top-i.clientTop-window.scrollY);return e.containerPointToLayerPoint(a)}}),L.CartoDBGroupLayer=L.CartoDBGroupLayerBase.extend({includes:[LayerDefinition.prototype]}),L.NamedMap=L.CartoDBGroupLayerBase.extend({includes:[cdb.geo.LeafLetLayerView.prototype,NamedMap.prototype,CartoDBLayerCommon.prototype],initialize:function(e){e=e||{},L.Util.setOptions(this,e);if(!e.named_map&&!e.sublayers)throw new Error("cartodb-leaflet needs at least the named_map");NamedMap.call(this,this.options.named_map,this.options),this.fire=this.trigger,CartoDBLayerCommon.call(this),L.TileLayer.prototype.initialize.call(this),this.interaction=[],this.addProfiling()}}),cdb.geo.LeafLetCartoDBLayerGroupView=e(L.CartoDBGroupLayer),cdb.geo.LeafLetCartoDBNamedMapView=e(L.NamedMap)}(),function(){if(typeof L=="undefined")return;L.CartoDBLayer=L.CartoDBGroupLayer.extend({options:{query:"SELECT * FROM {{table_name}}",opacity:.99,attribution:"CartoDB",debug:!1,visible:!0,added:!1,extra_params:{},layer_definition_version:"1.0.0"},initialize:function(e){L.Util.setOptions(this,e);if(!e.table_name||!e.user_name||!e.tile_style)throw"cartodb-leaflet needs at least a CartoDB table name, user_name and tile_style";L.CartoDBGroupLayer.prototype.initialize.call(this,{layer_definition:{version:this.options.layer_definition_version,layers:[{type:"cartodb",options:this._getLayerDefinition(),infowindow:this.options.infowindow}]}}),this.setOptions(this.options)},setQuery:function(e,t){t===undefined&&(t=e,e=0),t=t||"select * from "+this.options.table_name,LayerDefinition.prototype.setQuery.call(this,e,t)},isVisible:function(){return this.visible},isAdded:function(){return this.options.added}});var e=L.CartoDBLayer.extend({initialize:function(e,t){var n=this;_.bindAll(this,"featureOut","featureOver","featureClick"),e.attributes.attribution=cdb.config.get("cartodb_attributions");var r=_.clone(e.attributes);r.map=t;var i=r.featureOver,s=r.featureOut,o=r.featureClick;r.featureOver=function(){i&&i.apply(this,arguments),n.featureOver&&n.featureOver.apply(this,arguments)},r.featureOut=function(){s&&s.apply(this,arguments),n.featureOut&&n.featureOut.apply(this,arguments)},r.featureClick=function(){o&&o.apply(this,arguments),n.featureClick&&n.featureClick.apply(r,arguments)},e.bind("change:visible",function(){n.model.get("visible")?n.show():n.hide()},this),L.CartoDBLayer.prototype.initialize.call(this,r),cdb.geo.LeafLetLayerView.call(this,e,this,t)},_modelUpdated:function(){var e=_.clone(this.model.attributes);this.leafletLayer.setOptions(e)},featureOver:function(e,t,n,r){this.trigger("featureOver",e,[t.lat,t.lng],n,r,0)},featureOut:function(e){this.trigger("featureOut",e,0)},featureClick:function(e,t,n,r){this.trigger("featureClick",e,[t.lat,t.lng],n,r,0)},reload:function(){this.model.invalidate()},error:function(e){this.trigger("error",e?e.error:"unknown error"),this.model.trigger("tileError",e?e.error:"unknown error")},tilesOk:function(e){this.model.trigger("tileOk")},includes:[cdb.geo.LeafLetLayerView.prototype,Backbone.Events]});cdb.geo.LeafLetLayerCartoDBView=e}(),function(){if(typeof L=="undefined")return;cdb.geo.LeafletMapView=cdb.geo.MapView.extend({initialize:function(){_.bindAll(this,"_addLayer","_removeLayer","_setZoom","_setCenter","_setView"),cdb.geo.MapView.prototype.initialize.call(this);var e=this,t=this.map.get("center"),n={zoomControl:!1,center:new L.LatLng(t[0],t[1]),zoom:this.map.get("zoom"),minZoom:this.map.get("minZoom"),maxZoom:this.map.get("maxZoom")};this.map.get("bounding_box_ne");if(!this.options.map_object)this.map_leaflet=new L.Map(this.el,n),this.map_leaflet.attributionControl.setPrefix(""),this.map.get("scrollwheel")==0&&this.map_leaflet.scrollWheelZoom.disable();else{this.map_leaflet=this.options.map_object,this.setElement(this.map_leaflet.getContainer());var r=e.map_leaflet.getCenter();e._setModelProperty({center:[r.lat,r.lng]}),e._setModelProperty({zoom:e.map_leaflet.getZoom()}),e.map.unset("view_bounds_sw",{silent:!0}),e.map.unset("view_bounds_ne",{silent:!0})}this.map.bind("set_view",this._setView,this),this.map.layers.bind("add",this._addLayer,this),this.map.layers.bind("remove",this._removeLayer,this),this.map.layers.bind("reset",this._addLayers,this),this.map.layers.bind("change:type",this._swicthLayerView,this),this.map.geometries.bind("add",this._addGeometry,this),this.map.geometries.bind("remove",this._removeGeometry,this),this._bindModel(),this._addLayers(),this.map_leaflet.on("layeradd",function(t){this.trigger("layeradd",t,e)},this),this.map_leaflet.on("zoomstart",function(){e.trigger("zoomstart")}),this.map_leaflet.on("click",function(t){e.trigger("click",t.originalEvent,[t.latlng.lat,t.latlng.lng])}),this.map_leaflet.on("dblclick",function(t){e.trigger("dblclick",t.originalEvent)}),this.map_leaflet.on("zoomend",function(){e._setModelProperty({zoom:e.map_leaflet.getZoom()}),e.trigger("zoomend")},this),this.map_leaflet.on("move",function(){var t=e.map_leaflet.getCenter();e._setModelProperty({center:[t.lat,t.lng]})}),this.map_leaflet.on("drag",function(){var t=e.map_leaflet.getCenter();e._setModelProperty({center:[t.lat,t.lng]}),e.trigger("drag")},this),this.map.bind("change:maxZoom",function(){L.Util.setOptions(e.map_leaflet,{maxZoom:e.map.get("maxZoom")})},this),this.map.bind("change:minZoom",function(){L.Util.setOptions(e.map_leaflet,{minZoom:e.map.get("minZoom")})},this),this.trigger("ready");var i=this.map.getViewBounds();i&&this.showBounds(i)},clean:function(){L.DomEvent.off(window,"resize",this.map_leaflet._onResize,this.map_leaflet);for(var e in this.layers){var t=this.layers[e];t.remove(),delete this.layers[e]}cdb.core.View.prototype.clean.call(this)},_setScrollWheel:function(e,t){t?this.map_leaflet.scrollWheelZoom.enable():this.map_leaflet.scrollWheelZoom.disable()},_setZoom:function(e,t){this._setView()},_setCenter:function(e,t){this._setView()},_setView:function(){this.map_leaflet.setView(this.map.get("center"),this.map.get("zoom")||0)},_addGeomToMap:function(e){var t=cdb.geo.LeafletMapView.createGeometry(e);return t.geom.addTo(this.map_leaflet),t},_removeGeomFromMap:function(e){this.map_leaflet.removeLayer(e.geom)},createLayer:function(e){return cdb.geo.LeafletMapView.createLayer(e,this.map_leaflet)},_addLayer:function(e,t,n){var r=this,i,s;s=cdb.geo.LeafletMapView.createLayer(e,this.map_leaflet);if(!s)return;var o=!n||n.index===undefined||n.index===_.size(this.layers);if(!o)for(var u in this.layers)this.map_leaflet.removeLayer(this.layers[u]);this.layers[e.cid]=s,o?(cdb.geo.LeafletMapView.addLayerToMap(s,r.map_leaflet),s.setZIndex&&s.setZIndex(e.get("order"))):this.map.layers.each(function(e){var t=r.layers[e.cid];t&&(cdb.geo.LeafletMapView.addLayerToMap(t,r.map_leaflet),t.setZIndex&&t.setZIndex(e.get("order")))});var a=e.get("attribution");if(a){var f=this.map.get("attribution")||[];_.contains(f,a)||f.push(a),this.map.set({attribution:f})}return(n==undefined||!n.silent)&&this.trigger("newLayerView",s,e,this),s},pixelToLatLon:function(e){var t=this.map_leaflet.containerPointToLatLng([e[0],e[1]]);return t},latLonToPixel:function(e){var t=this.map_leaflet.latLngToLayerPoint(new L.LatLng(e[0],e[1]));return this.map_leaflet.layerPointToContainerPoint(t)},getBounds:function(){var e=this.map_leaflet.getBounds(),t=e.getSouthWest(),n=e.getNorthEast();return[[t.lat,t.lng],[n.lat,n.lng]]},setAttribution:function(e){},getSize:function(){return this.map_leaflet.getSize()},panBy:function(e){this.map_leaflet.panBy(new L.Point(e.x,e.y))},setCursor:function(e){$(this.map_leaflet.getContainer()).css("cursor",e)},getNativeMap:function(){return this.map_leaflet},invalidateSize:function(){this.map_leaflet.invalidateSize({pan:!1}),this.map_leaflet.setView(this.map.get("center"),this.map.get("zoom")||0,{animate:!1})}},{layerTypeMap:{tiled:cdb.geo.LeafLetTiledLayerView,wms:cdb.geo.LeafLetWMSLayerView,cartodb:cdb.geo.LeafLetLayerCartoDBView,carto:cdb.geo.LeafLetLayerCartoDBView,plain:cdb.geo.LeafLetPlainLayerView,gmapsbase:cdb.geo.LeafLetPlainLayerView,layergroup:cdb.geo.LeafLetCartoDBLayerGroupView,namedmap:cdb.geo.LeafLetCartoDBNamedMapView,torque:function(e,t){return new cdb.geo.LeafLetTorqueLayer(e,t)}},createLayer:function(e,t){var n=null,r=this.layerTypeMap[e.get("type").toLowerCase()];if(r)try{n=new r(e,t)}catch(i){cdb.log.error("MAP: error creating layer"+e.get("type")+" "+i)}else cdb.log.error("MAP: "+e.get("type")+" can't be created");return n},addLayerToMap:function(e,t,n){t.addLayer(e.leafletLayer),n!==undefined&&v.setZIndex&&v.setZIndex(n)},createGeometry:function(e){return e.isPoint()?new cdb.geo.leaflet.PointView(e):new cdb.geo.leaflet.PathView(e)}}),L.Icon.Default.imagePath=function(){var e=document.getElementsByTagName("script"),t=/\/?cartodb[\-\._]?([\w\-\._]*)\.js\??/,n,r,i,s;for(n=0,r=e.length;n=0?this.gmapsMap.overlayMapTypes.removeAt(t):this.gmapsLayer.setMap&&this.gmapsLayer.setMap(null),this.model.unbind(null,null,this),this.unbind()}},refreshView:function(){var e=this;if(this.isBase){var t="_baseLayer";this.gmapsMap.setMapTypeId(null),this.gmapsMap.mapTypes.set(t,this.gmapsLayer),this.gmapsMap.setMapTypeId(t)}else{var n=this._searchLayerIndex();n>=0&&this.gmapsMap.overlayMapTypes.setAt(n,this)}},reload:function(){this.refreshView()},_update:function(){this.refreshView()}}),cdb.geo.GMapsLayerView=e}(),function(){if(typeof google=="undefined"||typeof google.maps=="undefined")return;var e=function(e,t){cdb.geo.GMapsLayerView.call(this,e,null,t)};_.extend(e.prototype,cdb.geo.GMapsLayerView.prototype,{_update:function(){var e=this.model,t={roadmap:google.maps.MapTypeId.ROADMAP,gray_roadmap:google.maps.MapTypeId.ROADMAP,dark_roadmap:google.maps.MapTypeId.ROADMAP,hybrid:google.maps.MapTypeId.HYBRID,satellite:google.maps.MapTypeId.SATELLITE,terrain:google.maps.MapTypeId.TERRAIN};this.gmapsMap.setOptions({mapTypeId:t[e.get("base_type")]}),this.gmapsMap.setOptions({styles:e.get("style")||DEFAULT_MAP_STYLE})},remove:function(){}}),cdb.geo.GMapsBaseLayerView=e}(),function(){if(typeof google=="undefined"||typeof google.maps=="undefined")return;var e=function(e,t){this.color=e.get("color"),cdb.geo.GMapsLayerView.call(this,e,this,t)};_.extend(e.prototype,cdb.geo.GMapsLayerView.prototype,{_update:function(){this.color=this.model.get("color"),this.refreshView()},getTile:function(e,t,n){var r=document.createElement("div");return r.style.width=this.tileSize.x,r.style.height=this.tileSize.y,r["background-color"]=this.color,r},tileSize:new google.maps.Size(256,256),maxZoom:100,minZoom:0,name:"plain layer",alt:"plain layer"}),cdb.geo.GMapsPlainLayerView=e}(),function(){if(typeof google=="undefined"||typeof google.maps=="undefined")return;var e=function(e,t){cdb.geo.GMapsLayerView.call(this,e,this,t),this.tileSize=new google.maps.Size(256,256),this.opacity=1,this.isPng=!0,this.maxZoom=22,this.minZoom=0,this.name="cartodb tiled layer",google.maps.ImageMapType.call(this,this)};_.extend(e.prototype,cdb.geo.GMapsLayerView.prototype,google.maps.ImageMapType.prototype,{getTileUrl:function(e,t){var n=e.y,r=1<=r)return null;var i=e.x;if(i<0||i>=r)i=(i%r+r)%r;this.model.get("tms")&&(n=r-n-1);var s=this.model.get("urlTemplate");return s.replace("{x}",i).replace("{y}",n).replace("{z}",t)}}),cdb.geo.GMapsTiledLayerView=e}(),function(){function s(e,t){var r=Math.round(t*100);r>=99?e.style.filter=n:e.style.filter="alpha(opacity="+t+");"}function o(){}function u(e){var t=function(t,n){var r=this,i=[];_.bindAll(this,"featureOut","featureOver","featureClick"),t.attributes.attribution=cdb.config.get("cartodb_attributions");var s=_.clone(t.attributes);s.map=n;var o=s.featureOver,u=s.featureOut,a=s.featureClick,f,l=-1;s.featureOver=function(e,t,n,s,u){i[u]||r.trigger("layerenter",e,t,n,s,u),i[u]=1,o&&o.apply(this,arguments),r.featureOver&&r.featureOver.apply(this,arguments),e.timeStamp===f&&clearTimeout(l),l=setTimeout(function(){r.trigger("mouseover",e,t,n,s,u),r.trigger("layermouseover",e,t,n,s,u)},0),f=e.timeStamp},s.featureOut=function(e,t){i[t]&&r.trigger("layermouseout",t),i[t]=0,_.any(i)||r.trigger("mouseout"),u&&u.apply(this,arguments),r.featureOut&&r.featureOut.apply(this,arguments)},s.featureClick=_.debounce(function(){a&&a.apply(this,arguments),r.featureClick&&r.featureClick.apply(s,arguments)},10),e.call(this,s),cdb.geo.GMapsLayerView.call(this,t,this,n)};return _.extend(t.prototype,cdb.geo.GMapsLayerView.prototype,e.prototype,{_update:function(){this.setOptions(this.model.attributes)},reload:function(){this.model.invalidate()},remove:function(){cdb.geo.GMapsLayerView.prototype.remove.call(this),this.clear()},featureOver:function(e,t,n,r,i){this.trigger("featureOver",e,[t.lat(),t.lng()],n,r,i)},featureOut:function(e,t){this.trigger("featureOut",e,t)},featureClick:function(e,t,n,r,i){this.trigger("featureClick",e,[t.lat(),t.lng()],n,r,i)},error:function(e){this.model&&(this.model.trigger("error",e?e.errors:"unknown error"),this.model.trigger("tileError",e?e.errors:"unknown error"))},ok:function(e){this.model.trigger("tileOk")},tilesOk:function(e){this.model.trigger("tileOk")},loading:function(){this.trigger("loading")},finishLoading:function(){this.trigger("load")}}),t}if(typeof google=="undefined"||typeof google.maps=="undefined")return;var e=function(e){this.setMap(e)};e.prototype=new google.maps.OverlayView,e.prototype.draw=function(){},e.prototype.latLngToPixel=function(e){var t=this.getProjection();return t?t.fromLatLngToContainerPixel(e):[0,0]},e.prototype.pixelToLatLng=function(e){var t=this.getProjection();return t?t.fromContainerPixelToLatLng(e):[0,0]};var t={opacity:.99,attribution:"CartoDB",debug:!1,visible:!0,added:!1,tiler_domain:"cartodb.com",tiler_port:"80",tiler_protocol:"http",sql_api_domain:"cartodb.com",sql_api_port:"80",sql_api_protocol:"http",extra_params:{},cdn_url:null,subdomains:null},n="progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)",r=function(n){this.options=_.defaults(n,t),this.tiles=0,this.tilejson=null,this.interaction=[];if(!n.named_map&&!n.sublayers)throw new Error("cartodb-gmaps needs at least the named_map");this.options.cartodb_logo!=0&&cdb.geo.common.CartoDBLogo.addWadus({left:74,bottom:8},2e3,this.options.map.getDiv()),wax.g.connector.call(this,n),_.extend(this.options,n),this.projector=new e(n.map),NamedMap.call(this,this.options.named_map,this.options),CartoDBLayerCommon.call(this),this.update()},i=function(n){this.options=_.defaults(n,t),this.tiles=0,this.tilejson=null,this.interaction=[];if(!n.layer_definition&&!n.sublayers)throw new Error("cartodb-leaflet needs at least the layer_definition or sublayer list");n.layer_definition||(n.layer_definition=LayerDefinition.layerDefFromSubLayers(n.sublayers)),this.options.cartodb_logo!=0&&cdb.geo.common.CartoDBLogo.addWadus({left:74,bottom:8},2e3,this.options.map.getDiv()),wax.g.connector.call(this,n),_.extend(this.options,n),this.projector=new e(n.map),LayerDefinition.call(this,n.layer_definition,this.options),CartoDBLayerCommon.call(this),this.update()};o.prototype.setOpacity=function(e){if(isNaN(e)||e>1||e<0)throw new Error(e+" is not a valid value, should be in [0, 1] range");this.opacity=this.options.opacity=e;for(var t in this.cache){var n=this.cache[t];n.style.opacity=e,s(n,e)}},o.prototype.setAttribution=function(){},o.prototype.getTile=function(e,t,n){var r="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",i=this,o="ActiveXObject"in window,u=o&&!document.addEventListener;this.options.added=!0;if(this.tilejson===null){var a=t+"/"+e.x+"/"+e.y,f=this.cache[a]=new Image(256,256);return f.src=r,f.setAttribute("gTileKey",a),f.style.opacity=this.options.opacity,f}var l=wax.g.connector.prototype.getTile.call(this,e,t,n);u&&s(l,this.options.opacity),l.style.opacity=this.options.opacity,this.tiles===0&&this.loading&&this.loading(),this.tiles++;var c=cartodb.core.Profiler.metric("cartodb-js.tile.png.load.time").start(),h=function(){c.end(),i.tiles--,i.tiles===0&&i.finishLoading&&i.finishLoading()};return l.onload=h,l.onerror=function(){cartodb.core.Profiler.metric("cartodb-js.tile.png.error").inc(),h()},l},o.prototype.onAdd=function(){},o.prototype.clear=function(){this._clearInteraction(),self.finishLoading&&self.finishLoading()},o.prototype.update=function(e){var t=this;this.loading&&this.loading(),this.getTiles(function(n,r){n?(t.tilejson=n,t.options.tiles=n.tiles,t.tiles=0,t.cache={},t._reloadInteraction(),t.refreshView(),t.ok&&t.ok(),e&&e()):t.error&&t.error(r)})},o.prototype.refreshView=function(){var e=this,t=this.options.map;t.overlayMapTypes.forEach(function(n,r){if(n==e){t.overlayMapTypes.setAt(r,e);return}})},o.prototype.onLayerDefinitionUpdated=function(){this.update()},o.prototype._checkLayer=function(){if(!this.options.added)throw new Error("the layer is not still added to the map")},o.prototype._findPos=function(e,t){var n,r;n=curtop=0;var i=e.getDiv(),s,o;t.e.changedTouches&&t.e.changedTouches.length>0?(s=t.e.changedTouches[0].clientX+window.scrollX,o=t.e.changedTouches[0].clientY+window.scrollY):(s=t.e.clientX,o=t.e.clientY);do n+=i.offsetLeft,curtop+=i.offsetTop;while(i=i.offsetParent);return new google.maps.Point(s-n,o-curtop)},o.prototype._manageOffEvents=function(e,t){if(this.options.featureOut)return this.options.featureOut&&this.options.featureOut(t.e,t.layer)},o.prototype._manageOnEvents=function(e,t){var n=this._findPos(e,t),r=this.projector.pixelToLatLng(n),i=t.e.type.toLowerCase();switch(i){case"mousemove":if(this.options.featureOver)return this.options.featureOver(t.e,r,n,t.data,t.layer);break;case"click":case"touchend":case"mspointerup":this.options.featureClick&&this.options.featureClick(t.e,r,n,t.data,t.layer);break;default:}},i.Projector=e,i.prototype=new wax.g.connector,_.extend(i.prototype,LayerDefinition.prototype,o.prototype,CartoDBLayerCommon.prototype),i.prototype.interactionClass=wax.g.interaction,r.prototype=new wax.g.connector,_.extend(r.prototype,NamedMap.prototype,o.prototype,CartoDBLayerCommon.prototype),r.prototype.interactionClass=wax.g.interaction,cdb.geo.CartoDBLayerGroupGMaps=i,cdb.geo.CartoDBNamedMapGMaps=r,cdb.geo.GMapsCartoDBLayerGroupView=u(i),cdb.geo.GMapsCartoDBNamedMapView=u(r),cdb.geo.CartoDBNamedMapGMaps=r}(),function(){if(typeof google=="undefined"||typeof google.maps=="undefined")return;var e=function(e){this.setMap(e)};e.prototype=new google.maps.OverlayView,e.prototype.draw=function(){},e.prototype.latLngToPixel=function(e){var t=this.getProjection();return t?t.fromLatLngToContainerPixel(e):[0,0]},e.prototype.pixelToLatLng=function(e){var t=this.getProjection();return t?t.fromContainerPixelToLatLng(e):[0,0]};var t=function(e){var t={query:"SELECT * FROM {{table_name}}",opacity:.99,attribution:"CartoDB",opacity:1,debug:!1,visible:!0,added:!1,extra_params:{},layer_definition_version:"1.0.0"};this.options=_.defaults(e,t);if(!e.table_name||!e.user_name||!e.tile_style)throw"cartodb-gmaps needs at least a CartoDB table name, user_name and tile_style";this.options.layer_definition={version:this.options.layer_definition_version,layers:[{type:"cartodb",options:this._getLayerDefinition(),infowindow:this.options.infowindow}]},cdb.geo.CartoDBLayerGroupGMaps.call(this,this.options),this.setOptions(this.options)};_.extend(t.prototype,cdb.geo.CartoDBLayerGroupGMaps.prototype),t.prototype.setQuery=function(e,t){t===undefined&&(t=e,e=0),t=t||"select * from "+this.options.table_name,LayerDefinition.prototype.setQuery.call(this,e,t)},cdb.geo.CartoDBLayerGMaps=t;var n=function(e,t){var n=this;_.bindAll(this,"featureOut","featureOver","featureClick"),e.attributes.attribution=cdb.config.get("cartodb_attributions");var r=_.clone(e.attributes);r.map=t;var i=r.featureOver,s=r.featureOut,o=r.featureClick;r.featureOver=function(){i&&i.apply(this,arguments),n.featureOver&&n.featureOver.apply(this,arguments)},r.featureOut=function(){s&&s.apply(this,arguments),n.featureOut&&n.featureOut.apply(this,arguments)},r.featureClick=function(){o&&o.apply(this,arguments),n.featureClick&&n.featureClick.apply(r,arguments)},cdb.geo.CartoDBLayerGMaps.call(this,r),cdb.geo.GMapsLayerView.call(this,e,this,t)};cdb.geo.GMapsCartoDBLayerView=n,_.extend(n.prototype,cdb.geo.CartoDBLayerGMaps.prototype,cdb.geo.GMapsLayerView.prototype,{_update:function(){this.setOptions(this.model.attributes)},reload:function(){this.model.invalidate()},remove:function(){cdb.geo.GMapsLayerView.prototype.remove.call(this),this.clear()},featureOver:function(e,t,n,r){this.trigger("featureOver",e,[t.lat(),t.lng()],n,r,0)},featureOut:function(e){this.trigger("featureOut",e)},featureClick:function(e,t,n,r,i){this.trigger("featureClick",e,[t.lat(),t.lng()],n,r,0)},error:function(e){this.model&&(this.model.trigger("error",e?e.error:"unknown error"),this.model.trigger("tileError",e?e.error:"unknown error"))},tilesOk:function(e){this.model.trigger("tileOk")},loading:function(){this.trigger("loading")},finishLoading:function(){this.trigger("load")}})}();if(typeof google!="undefined"&&typeof google.maps!="undefined"){var DEFAULT_MAP_STYLE=[{stylers:[{saturation:-65},{gamma:1.52}]},{featureType:"administrative",stylers:[{saturation:-95},{gamma:2.26}]},{featureType:"water",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"administrative.locality",stylers:[{visibility:"off"}]},{featureType:"road",stylers:[{visibility:"simplified"},{saturation:-99},{gamma:2.22}]},{featureType:"poi",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"road.arterial",stylers:[{visibility:"off"}]},{featureType:"road.local",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"transit",stylers:[{visibility:"off"}]},{featureType:"road",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"poi",stylers:[{saturation:-55}]}];cdb.geo.GoogleMapsMapView=cdb.geo.MapView.extend({layerTypeMap:{tiled:cdb.geo.GMapsTiledLayerView,cartodb:cdb.geo.GMapsCartoDBLayerView,carto:cdb.geo.GMapsCartoDBLayerView,plain:cdb.geo.GMapsPlainLayerView,gmapsbase:cdb.geo.GMapsBaseLayerView,layergroup:cdb.geo.GMapsCartoDBLayerGroupView,namedmap:cdb.geo.GMapsCartoDBNamedMapView,torque:function(e,t){return new cdb.geo.GMapsTorqueLayerView(e,t)},wms:cdb.geo.LeafLetWMSLayerView},initialize:function(){_.bindAll(this,"_ready"),this._isReady=!1;var e=this;cdb.geo.MapView.prototype.initialize.call(this);var t=this.map.getViewBounds();t&&this.showBounds(t);var n=this.map.get("center");if(!this.options.map_object)this.map_googlemaps=new google.maps.Map(this.el,{center:new google.maps.LatLng(n[0],n[1]),zoom:this.map.get("zoom"),minZoom:this.map.get("minZoom"),maxZoom:this.map.get("maxZoom"),disableDefaultUI:!0,scrollwheel:this.map.get("scrollwheel"),mapTypeControl:!1,mapTypeId:google.maps.MapTypeId.ROADMAP,backgroundColor:"white",tilt:0}),this.map.bind("change:maxZoom",function(){e.map_googlemaps.setOptions({maxZoom:e.map.get("maxZoom")})},this),this.map.bind("change:minZoom",function(){e.map_googlemaps.setOptions({minZoom:e.map.get("minZoom")})},this);else{this.map_googlemaps=this.options.map_object,this.setElement(this.map_googlemaps.getDiv());var r=e.map_googlemaps.getCenter();e._setModelProperty({center:[r.lat(),r.lng()]}),e._setModelProperty({zoom:e.map_googlemaps.getZoom()}),e.map.unset("view_bounds_sw",{silent:!0}),e.map.unset("view_bounds_ne",{silent:!0})}this.map.geometries.bind("add",this._addGeometry,this),this.map.geometries.bind("remove",this._removeGeometry,this),this._bindModel(),this._addLayers(),google.maps.event.addListener(this.map_googlemaps,"center_changed",function(){var t=e.map_googlemaps.getCenter();e._setModelProperty({center:[t.lat(),t.lng()]})}),google.maps.event.addListener(this.map_googlemaps,"zoom_changed",function(){e._setModelProperty({zoom:e.map_googlemaps.getZoom()})}),google.maps.event.addListener(this.map_googlemaps,"click",function(t){e.trigger("click",t,[t.latLng.lat(),t.latLng.lng()])}),google.maps.event.addListener(this.map_googlemaps,"dblclick",function(t){e.trigger("dblclick",t)}),this.map.layers.bind("add",this._addLayer,this),this.map.layers.bind("remove",this._removeLayer,this),this.map.layers.bind("reset",this._addLayers,this),this.map.layers.bind("change:type",this._swicthLayerView,this),this.projector=new cdb.geo.CartoDBLayerGroupGMaps.Projector(this.map_googlemaps),this.projector.draw=this._ready},_ready:function(){this.projector.draw=function(){},this.trigger("ready"),this._isReady=!0},_setScrollWheel:function(e,t){this.map_googlemaps.setOptions({scrollwheel:t})},_setZoom:function(e,t){t=t||0,this.map_googlemaps.setZoom(t)},_setCenter:function(e,t){var n=new google.maps.LatLng(t[0],t[1]);this.map_googlemaps.setCenter(n)},createLayer:function(e){var t,n=this.layerTypeMap[e.get("type").toLowerCase()];if(n)try{t=new n(e,this.map_googlemaps)}catch(r){cdb.log.error("MAP: error creating layer"+e.get("type")+" "+r)}else cdb.log.error("MAP: "+e.get("type")+" can't be created");return t},_addLayer:function(e,t,n){n=n||{};var r=this,i,s;s=this.createLayer(e);if(!s)return;this.layers[e.cid]=s;if(s){var o=_(this.layers).filter(function(e){return!!e.getTile}).length-1,u=_.keys(this.layers).length===1||n&&n.index===0;if(u&&!n.no_base_layer){var a=s.model;a.get("type")==="GMapsBase"?s._update():(s.isBase=!0,s._update())}else o-=1,o=Math.max(0,o),s.getTile?(s.gmapsLayer||cdb.log.error("gmaps layer can't be null"),r.map_googlemaps.overlayMapTypes.setAt(o,s.gmapsLayer)):s.gmapsLayer.setMap(r.map_googlemaps);(n===undefined||!n.silent)&&this.trigger("newLayerView",s,e,this)}else cdb.log.error("layer type not supported");var f=e.get("attribution");if(f){var l=this.map.get("attribution")||[];_.contains(l,f)||l.push(f),this.map.set({attribution:l})}return s},pixelToLatLon:function(e){return this.projector.fromContainerPixelToLatLng(new google.maps.Point(e[0],e[1]))},latLonToPixel:function(e){return this.projector.latLngToPixel(new google.maps.LatLng(e[0],e[1]))},getSize:function(){return{x:this.$el.width(),y:this.$el.height()}},panBy:function(e){var t=this.map.get("center"),n=this.latLonToPixel(t);e.x+=n.x,e.y+=n.y;var r=this.projector.pixelToLatLng(e);this.map.setCenter([r.lat(),r.lng()])},getBounds:function(){if(this._isReady){var e=this.map_googlemaps.getBounds(),t=e.getSouthWest(),n=e.getNorthEast();return[[t.lat(),t.lng()],[n.lat(),n.lng()]]}return[[0,0],[0,0]]},setAttribution:function(e){var t=document.getElementById("cartodb-gmaps-attribution"),n=e.get("attribution").join(", ");t&&t.parentNode.removeChild(t);var r=this.map_googlemaps.getDiv(),i=document.createElement("div");i.setAttribute("id","cartodb-gmaps-attribution"),i.setAttribute("class","gmaps"),r.appendChild(i),i.innerHTML=n},setCursor:function(e){this.map_googlemaps.setOptions({draggableCursor:e})},_addGeomToMap:function(e){var t=cdb.geo.GoogleMapsMapView.createGeometry(e);if(t.geom.length)for(var n=0;n/g)||[]).join("");var n=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;return!e||typeof e!="string"?"":e.replace(n,function(e,n){return t.indexOf("<"+n.toLowerCase()+">")>-1?e:""})},open:function(){var e=this;this.$el.show(0,function(){e.isOpen=!0})},hide:function(){var e=this;this.$el.hide(0,function(){e.isOpen=!1}),this.options.clean_on_hide&&this.clean()},toggle:function(){this.isOpen?this.hide():this.open()},_truncateTitle:function(e,t){return e.substr(0,t-1)+(e.length>t?"…":"")},render:function(){var e=this.$el,t=this.options.title,n=this.options.description,r=this._stripHTML(this.options.description),i=this.options.share_url,s,o;this.$el.addClass(this.options.size);var u=t+": "+r,a;t&&r?a=this._truncateTitle(t+": "+r,112)+" %23map ":t?a=this._truncateTitle(t,112)+" %23map":r?a=this._truncateTitle(r,112)+" %23map":a="%23map",this.options.facebook_url?s=this.options.facebook_url:s="http://www.facebook.com/sharer.php?u="+i+"&text="+u,this.options.twitter_url?o=this.options.twitter_url:o="https://twitter.com/share?url="+i+"&text="+a;var f=_.extend(this.options,{facebook_url:s,twitter_url:o});return e.html(this.options.template(f)),e.find(".modal").css({width:this.options.width}),this.render_content&&this.$(".content").append(this.render_content()),this.options.modal_class&&this.$el.addClass(this.options.modal_class),this.options.disableLinks&&this.$el.find("a").attr("target",""),this}}),cdb.ui.common.Notification=cdb.core.View.extend({tagName:"div",className:"dialog",events:{"click .close":"hide"},default_options:{timeout:0,msg:"",hideMethod:"",duration:"normal"},initialize:function(){this.closeTimeout=-1,_.defaults(this.options,this.default_options),this.template=this.options.template?_.template(this.options.template):cdb.templates.getTemplate("common/notification"),this.$el.hide()},render:function(){var e=this.$el;return e.html(this.template(this.options)),this.render_content&&this.$(".content").append(this.render_content()),this},hide:function(e){var t=this;e&&e.preventDefault(),clearTimeout(this.closeTimeout),this.options.hideMethod!=""&&this.$el.is(":visible")?this.$el[this.options.hideMethod](this.options.duration,"swing",function(){t.$el.html(""),t.trigger("notificationDeleted"),t.remove()}):(this.$el.hide(),t.$el.html(""),t.trigger("notificationDeleted"),t.remove())},open:function(e,t){this.render(),this.$el.show(e,t),this.options.timeout&&(this.closeTimeout=setTimeout(_.bind(this.hide,this),this.options.timeout))}}),cdb.ui.common.Row=cdb.core.Model.extend({}),cdb.ui.common.TableData=Backbone.Collection.extend({model:cdb.ui.common.Row,fetched:!1,initialize:function(){var e=this;this.bind("reset",function(){e.fetched=!0})},getCell:function(e,t){var n=this.at(e);return n?n.get(t):null},isEmpty:function(){return this.length===0}}),cdb.ui.common.TableProperties=cdb.core.Model.extend({columnNames:function(){return _.map(this.get("schema"),function(e){return e[0]})},columnName:function(e){return this.columnNames()[e]}}),cdb.ui.common.RowView=cdb.core.View.extend({tagName:"tr",initialize:function(){this.model.bind("change",this.render,this),this.model.bind("destroy",this.clean,this),this.model.bind("remove",this.clean,this),this.model.bind("change",this.triggerChange,this),this.model.bind("sync",this.triggerSync,this),this.model.bind("error",this.triggerError,this),this.add_related_model(this.model),this.order=this.options.order},triggerChange:function(){this.trigger("changeRow")},triggerSync:function(){this.trigger("syncRow")},triggerError:function(){this.trigger("errorRow")},valueView:function(e,t){return t},render:function(){var e=this,t=this.model,n="",r=0,i;this.options.row_header?i='':i='';var s=e.valueView("","");s.html&&(s=s[0].outerHTML),i+=s,i+="",r++,n+=i;var o=this.order||_.keys(t.attributes),u="",a=t.attributes;for(var f=0,l=o.length;f',s=e.valueView(c,h);s.html&&(s=s[0].outerHTML),i+=s,i+="",r++,u+=i}}return n+=u,this.$el.html(n).attr("id","row_"+t.id),this},getCell:function(e){var t=e;return this.options.row_header&&++e,this.$("td:eq("+e+")")},getTableView:function(){return this.tableView}}),cdb.ui.common.Table=cdb.core.View.extend({tagName:"table",rowView:cdb.ui.common.RowView,events:{"click td":"_cellClick","dblclick td":"_cellDblClick"},default_options:{},initialize:function(){var e=this;_.defaults(this.options,this.default_options),this.dataModel=this.options.dataModel,this.rowViews=[],this.setDataSource(this.dataModel),this.model.bind("change",this.render,this),this.model.bind("change:dataSource",this.setDataSource,this),this.bind("clean",this.clear_rows,this),this.add_related_model(this.dataModel),this.add_related_model(this.model),this.model.bind("removing:row",function(){e.rowsBeingDeleted=e.rowsBeingDeleted?e.rowsBeingDeleted+1:1,e.rowDestroying()}),this.model.bind("remove:row",function(){e.rowsBeingDeleted>0&&(e.rowsBeingDeleted--,e.rowDestroyed(),e.dataModel.length==0&&e.emptyTable())})},headerView:function(e){return e[0]},setDataSource:function(e){this.dataModel&&this.dataModel.unbind(null,null,this),this.dataModel=e,this.dataModel.bind("reset",this._renderRows,this),this.dataModel.bind("error",this._renderRows,this),this.dataModel.bind("add",this.addRow,this)},_renderHeader:function(){var e=this,t=$(""),n=$("");return this.options.row_header?n.append($("").append(e.headerView(["","header"]))):n.append($("").append(e.headerView(["","header"]))),_(this.model.get("schema")).each(function(t){n.append($("").append(e.headerView(t)))}),t.append(n),t},clear_rows:function(){this.$("tfoot").remove(),this.$("tr.noRows").remove();var e=null;while(e=this.rowViews.pop())e.unbind(null,null,this),e.clean();this.rowViews=[]},addRow:function(e,t,n){var r=this,i=new r.rowView({model:e,order:this.model.columnNames(),row_header:this.options.row_header});i.tableView=this,i.bind("clean",function(){var e=_.indexOf(r.rowViews,i);r.rowViews.splice(e,1);for(var t=e;t").css({position:"relative",width:"100%",height:"100%"});this.container=l;var c=$("
        ").addClass("cartodb-map-wrapper").css({position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%"});l.append(c),this.$el.append(l);var h=new cdb.geo.MapView.create(c,a);this.mapView=h,this._addLayers(e.layers,t),(t.legends||t.legends===undefined&&this.map.get("legends")!==!1)&&this.addLegends(e.layers,this.mobile_enabled);if(t.time_slider){var p=_(this.getLayers()).filter(function(e){return e.model.get("type")==="torque"});p&&p.length&&(this.torqueLayer=p[0],!this.mobile_enabled&&this.torqueLayer&&this.addTimeSlider(this.torqueLayer))}return t.sublayer_options||this._setupSublayers(e.layers,t),t.sublayer_options&&this._setLayerOptions(t),this.mobile_enabled&&(t.legends===undefined&&(t.legends=this.legends?!0:!1),this.addMobile(e.overlays,e.layers,t)),this._addOverlays(e.overlays,t),_.defer(function(){n.trigger("done",n,n.getLayers())}),this},_addFullScreen:function(){this.addOverlay({options:{allowWheelOnFullscreen:!0},type:"fullscreen"})},_createOverlays:function(e,t){_.each(e,function(e){var n=e.type;if(this.mobile_enabled&&n==="zoom")return;if(this.mobile_enabled&&n==="header")return;if(n==="image"||n==="text"||n==="annotation"){var r=e.options.device=="mobile"?!0:!1;if(this.mobile!==r)return;if(!t[n]&&t[n]!==undefined)return}var i=this.addOverlay(e);i&&n in t&&t[n]===!1&&i.hide();var s=e.options;(n=="share"&&t.shareable||n=="share"&&i.model.get("display")&&t["shareable"]==undefined)&&i.show(),(n=="layer_selector"&&t[n]||n=="layer_selector"&&i.model.get("display")&&t[n]==undefined)&&i.show(),(n=="fullscreen"&&t[n]||n=="fullscreen"&&i.model.get("display")&&t[n]==undefined)&&i.show(),!this.mobile_enabled&&(n=="search"&&t[n]||n=="search"&&s.display&&t[n]==undefined)&&i.show();if(!this.mobile_enabled&&n==="header"){var o=i.model;t.title!==undefined&&o.set("show_title",t.title),t.description!==undefined&&o.set("show_description",t.description),(o.get("show_title")||o.get("show_description"))&&$(".cartodb-map-wrapper").addClass("with_header"),i.render()}},this)},addMobile:function(e,t,n){var r,i=t[1];i.options&&i.options.layer_definition?r=i.options.layer_definition.layers:i.options&&i.options.named_map&&i.options.named_map.layers&&(r=i.options.named_map.layers),this.addOverlay({type:"mobile",layers:r,overlays:e,options:n,torqueLayer:this.torqueLayer})},createLegendView:function(e){var t=[];for(var n=e.length-1;n>=0;--n){var r=e[n];if(r.legend){r.legend.data=r.legend.items;var i=r.legend;if(i.items&&i.items.length||i.template)r.legend.index=n,t.push(new cdb.geo.ui.Legend(r.legend))}r.options&&r.options.layer_definition?t=t.concat(this.createLegendView(r.options.layer_definition.layers)):r.options&&r.options.named_map&&r.options.named_map.layers&&(t=t.concat(this.createLegendView(r.options.named_map.layers)))}return t},addOverlay:function(e){e.map=this.map;var n=t.create(e.type,this,e);return n&&(e.type=="loader"&&(this.loader=n),this.mapView.addOverlay(n),this.overlays.push(n),n.bind("clean",function(){for(var e in this.overlays){var t=this.overlays[e];if(n.cid===t.cid){this.overlays.splice(e,1);return}}},this),e.type=="header"),n},_applyOptions:function(e,t){function n(t){if(!e.overlays)return null;for(var n=0;n1){var c=t.auth_token;for(var h=1;h','x','
        ','
        ',"{{#content.fields}}","{{#title}}

        {{title}}

        {{/title}}","{{#value}}",'

        {{{ value }}}

        ',"{{/value}}","{{^value}}",'

        null

        ',"{{/value}}","{{/content.fields}}","
        ","
        ",'
        ',"
        "].join("")},cdb.vis.Vis=s}(),function(){cdb.vis.Overlay.register("logo",function(e,t){}),cdb.vis.Overlay.register("mobile",function(e,t){var n=cdb.core.Template.compile(e.template||'
          ',e.templateType||"mustache"),r=new cdb.geo.ui.Mobile({template:n,mapView:t.mapView,overlays:e.overlays,layerView:e.layerView,visibility_options:e.options,torqueLayer:e.torqueLayer,map:e.map});return r.render()}),cdb.vis.Overlay.register("image",function(e,t){var n=e.options,r=cdb.core.Template.compile(e.template||'
          {{{ content }}}
          ',e.templateType||"mustache"),i=new cdb.geo.ui.Image({model:new cdb.core.Model(n),template:r});return i.render()}),cdb.vis.Overlay.register("text",function(e,t){var n=e.options,r=cdb.core.Template.compile(e.template||'
          {{{ text }}}
          ',e.templateType||"mustache"),i=new cdb.geo.ui.Text({model:new cdb.core.Model(n),template:r,className:"cartodb-overlay overlay-text "+n.device});return i.render()}),cdb.vis.Overlay.register("annotation",function(e,t){var n=e.options,r=cdb.core.Template.compile(e.template||'
          {{{ text }}}
          ',e.templateType||"mustache"),n=e.options,i=new cdb.geo.ui.Annotation({className:"cartodb-overlay overlay-annotation "+n.device,template:r,mapView:t.mapView,device:n.device,text:n.extra.rendered_text,minZoom:n.style["min-zoom"],maxZoom:n.style["max-zoom"],latlng:n.extra.latlng,style:n.style});return i.render()}),cdb.vis.Overlay.register("zoom_info",function(e,t){}),cdb.vis.Overlay.register("header",function(e,t){var n=e.options,r=cdb.core.Template.compile(e.template||'
          {{{ title }}}
          {{{ description }}}
          ',e.templateType||"mustache"),i=new cdb.geo.ui.Header({model:new cdb.core.Model(n),template:r});return i.render()}),cdb.vis.Overlay.register("zoom",function(e,t){if(!e.template){t.trigger("error","zoom template is empty");return}var n=new cdb.geo.ui.Zoom({model:e.map,template:cdb.core.Template.compile(e.template)});return n.render()}),cdb.vis.Overlay.register("loader",function(e){var t=new cdb.geo.ui.TilesLoader({template:cdb.core.Template.compile(e.template)});return t.render()}),cdb.vis.Overlay.register("time_slider",function(e,t){var n=new cdb.geo.ui.TimeSlider(e);return n.render()}),cdb.vis.Overlay.register("_header",function(e,t){function i(e,t){return e.substr(0,t-1)+(e.length>t?"…":"")}var n=100;location.href?e.share_url=encodeURIComponent(location.href):e.share_url=e.url;var r=cdb.core.Template.compile(e.template||" {{#title}}

          {{#url}} {{title}} {{/url}} {{^url}} {{title}} {{/url}}

          {{/title}} {{#description}}

          {{{description}}}

          {{/description}} {{#mobile_shareable}} {{/mobile_shareable}} ",e.templateType||"mustache"),s=e.map.get("title"),o=e.map.get("description"),u=s+": "+o,a;s&&o?a=i(s+": "+o,112)+" %23map ":s?a=i(s,112)+" %23map":o?a=i(o,112)+" %23map":a="%23map";var f=e.shareable=="false"||!e.shareable?null:e.shareable,l=f;l=l&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);var c=new cdb.geo.ui.Header({title:s,description:o,facebook_title:u,twitter_title:a,url:e.url,share_url:e.share_url,mobile_shareable:l,shareable:f&&!l,template:r});return c.render()}),cdb.vis.Overlay.register("infowindow",function(e,t){if(_.size(e.fields)==0)return null;var n=new cdb.geo.ui.InfowindowModel({template:e.template,alternative_names:e.alternative_names,fields:e.fields,template_name:e.template_name}),r=e.templateType||"mustache",i=new cdb.geo.ui.Infowindow -({model:n,mapView:t.mapView,template:(new cdb.core.Template({template:e.template,type:r})).asFunction()});return i}),cdb.vis.Overlay.register("layer_selector",function(e,t){var n=e.options,r=cdb.core.Template.compile(e.template||' Visible layers
          ',e.templateType||"underscore"),i=cdb.core.Template.compile(e.template||'
            ',e.templateType||"underscore"),s=new cdb.geo.ui.LayerSelector({model:new cdb.core.Model(n),mapView:t.mapView,template:r,dropdown_template:i,layer_names:e.layer_names});return t.legends&&s.bind("change:visible",function(e,n,r){if(r.get("type")==="torque"){var i=t.getOverlay("time_slider");i&&i[e?"show":"hide"]()}if(r.get("type")==="layergroup"||r.get("type")==="torque"){var s=t.legends&&t.legends.getLegendByIndex(n);s&&s[e?"show":"hide"]()}}),s.render()}),cdb.vis.Overlay.register("fullscreen",function(e,t){var n=e.options;n.allowWheelOnFullscreen=!1;var r=cdb.core.Template.compile(e.template||'',e.templateType||"mustache"),i=new cdb.ui.common.FullScreen({doc:"#map > div",model:new cdb.core.Model(n),mapView:t.mapView,template:r});return i.render()}),cdb.vis.Overlay.register("share",function(e,t){var n=e.options,r=cdb.core.Template.compile(e.template||'',e.templateType||"mustache"),i=new cdb.geo.ui.Share({model:new cdb.core.Model(n),vis:t,map:t.map,template:r});return i.createDialog(),i.render()}),cdb.vis.Overlay.register("search",function(e,t){var n=e.options,r=cdb.core.Template.compile(e.template||'
            ',e.templateType||"mustache"),i=new cdb.geo.ui.Search({template:r,model:t.map});return i.render()}),cdb.vis.Overlay.register("tooltip",function(e,t){var n;if(!e.layer){var r=t.getLayers();r.length>1&&(n=r[1]),e.layer=n}if(!e.layer)throw new Error("layer is null");e.layer.setInteraction(!0);var i=new cdb.geo.ui.Tooltip(e);return i}),cdb.vis.Overlay.register("infobox",function(e,t){var n,r=t.getLayers();e.layer||(r.length>1&&(n=r[1]),e.layer=n);if(!e.layer)throw new Error("layer is null");e.layer.setInteraction(!0);var i=new cdb.geo.ui.InfoBox(e);return i})}(),function(){function n(e){for(var n in t)if(e.indexOf(n)!==-1)return e.replace(n,t[n]);return e}function r(e,t){t.infowindow&&t.infowindow.fields&&(t.interactivity?t.interactivity.indexOf("cartodb_id")===-1&&(t.interactivity=t.interactivity+",cartodb_id"):t.interactivity="cartodb_id"),e.https&&(t.tiler_protocol="https",t.tiler_port=443,t.sql_api_protocol="https",t.sql_api_port=443),t.cartodb_logo=e.cartodb_logo==undefined?t.cartodb_logo:e.cartodb_logo}var e=cdb.vis.Layers,t={"https://dnv9my2eseobd.cloudfront.net/":"http://a.tiles.mapbox.com/","https://maps.nlp.nokia.com/":"http://maps.nlp.nokia.com/","https://tile.stamen.com/":"http://tile.stamen.com/","https://{s}.maps.nlp.nokia.com/":"http://{s}.maps.nlp.nokia.com/","https://cartocdn_{s}.global.ssl.fastly.net/":"http://{s}.api.cartocdn.com/"};e.register("tilejson",function(e,t){var r=t.tiles[0];return r=e.https?r:n(r),new cdb.geo.TileLayer({urlTemplate:r})}),e.register("tiled",function(e,t){var r=t.urlTemplate;return r=e.https?r:n(r),t.urlTemplate=r,new cdb.geo.TileLayer(t)}),e.register("wms",function(e,t){return new cdb.geo.WMSLayer(t)}),e.register("gmapsbase",function(e,t){return new cdb.geo.GMapsBaseLayer(t)}),e.register("plain",function(e,t){return new cdb.geo.PlainLayer(t)}),e.register("background",function(e,t){return new cdb.geo.PlainLayer(t)});var i=function(e,t){return r(e,t),t.sublayers?(t.type="layergroup",new cdb.geo.CartoDBGroupLayer(t)):new cdb.geo.CartoDBLayer(t)};e.register("cartodb",i),e.register("carto",i),e.register("layergroup",function(e,t){return r(e,t),new cdb.geo.CartoDBGroupLayer(t)}),e.register("namedmap",function(e,t){return r(e,t),new cdb.geo.CartoDBNamedMapLayer(t)}),e.register("torque",function(e,t){return e.https&&t.sql_api_domain&&t.sql_api_domain.indexOf("cartodb.com")!==-1&&(t.sql_api_protocol="https",t.sql_api_port=443,t.tiler_protocol="https",t.tiler_port=443),t.cartodb_logo=e.cartodb_logo==undefined?t.cartodb_logo:e.cartodb_logo,new cdb.geo.TorqueLayer(t)})}(),function(){function e(){}function n(e){var t=e.host||"cartodb.com",n=e.protocol||"https";return n+"://"+e.user+"."+t+"/api/v1/viz/"+e.table+"/viz.json"}function r(e,t){var r=null;if(e.layers!==undefined||(e.kind||e.type)!==undefined){_.defer(function(){t(e)});return}e.table!==undefined&&e.user!==undefined?r=n(e):e.indexOf&&e.indexOf("http")===0&&(r=e),r?cdb.vis.Loader.get(r,t):_.defer(function(){t(null)})}_.extend(e.prototype,Backbone.Events,{done:function(e){return this.bind("done",e)},error:function(e){return this.bind("error",e)}}),cdb._Promise=e;var t={};cartodb.createLayer=function(t,n,i,s){var o=new e,u,a;i=i||{};if(t===undefined)throw new TypeError("map should be provided");if(n===undefined)throw new TypeError("layer should be provided");var f=arguments,l=f[f.length-1];return _.isFunction(l)&&(s=l),o.addTo=function(e,t){return o.on("done",function(){a.addLayerToMap(u,e,t)}),o},r(n,function(e){function c(){u=f.createLayer(n,{no_base_layer:!0});var e,r=/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),a=i.mobile_layout&&r||i.force_mobile;if(!u)return o.trigger("error","layer not supported"),o;i.infowindow&&f.addInfowindow(u),i.tooltip&&f.addTooltip(u),i.legends&&f.addLegends([n],r&&i.mobile_layout||i.force_mobile),i.time_slider&&u.model.get("type")==="torque"&&(a||f.addTimeSlider(u),e=u),a&&(i.mapView=t.viz.mapView,f.addOverlay({type:"mobile",layerView:u,overlays:[],torqueLayer:e,options:i})),s&&s(u),o.trigger("done",u)}var n;if(!e){o.trigger("error");return}if(e.layers){e.layers.length<2&&o.trigger("error","visualization file does not contain layer info");var r=i.layerIndex===undefined?1:i.layerIndex;if(e.layers.length<=r){o.trigger("error","layerIndex out of bounds");return}n=e.layers[r]}else n=e;if(!n){o.trigger("error");return}i&&!_.isFunction(i)&&(n.options=n.options||{},_.extend(n.options,i)),i=_.defaults(i,{infowindow:!0,https:!1,legends:!0,time_slider:!0,tooltip:!0});if(typeof t.overlayMapTypes!="undefined")a=cdb.geo.GoogleMapsMapView;else{if(!(t instanceof L.Map||window.L&&t instanceof window.L.Map))return o.trigger("error","cartodb.js can't guess the map type"),o;a=cdb.geo.LeafletMapView}var f=t.viz;if(!f){var l=new a({map_object:t,map:new cdb.geo.Map});t.viz=f=new cdb.vis.Vis({mapView:l}),f.updated_at=e.updated_at,f.https=i.https}f.checkModules([n])?c():f.loadModules([n],function(){c()})}),o}}(),function(){function t(e){if(cartodb===this||window===this)return new t(e);if(!e.user)throw new Error("user should be provided");var n=new String(window.location.protocol);n=n.slice(0,n.length-1),n=="file"&&(n="https"),this.ajax=e.ajax||(typeof jQuery!="undefined"?jQuery.ajax:reqwest);if(!this.ajax)throw new Error("jQuery or reqwest should be loaded");this.options=_.defaults(e,{version:"v2",protocol:n,jsonp:typeof jQuery!="undefined"?!jQuery.support.cors:!1})}var e=this;e.cartodb=e.cartodb||{},t.prototype._host=function(){var e=this.options;if(e&&e.completeDomain)return e.completeDomain+"/api/"+e.version+"/sql";var t=e.host||"cartodb.com",n=e.protocol||"https";return n+"://"+e.user+"."+t+"/api/"+e.version+"/sql"},t.prototype.execute=function(e,t,n,r){var i=1024,s=new cartodb._Promise;if(!e)throw new TypeError("sql should not be null");var o=arguments,u=o[o.length-1];_.isFunction(u)&&(r=u),n=_.defaults(n||{},this.options);var a={type:"get",dataType:"json",crossDomain:!0};n.cache!==undefined&&(a.cache=n.cache),n.jsonp&&(delete a.crossDomain,n.jsonpCallback&&(a.jsonpCallback=n.jsonpCallback),a.dataType="jsonp");var f="156543.03515625",l="ST_MakeEnvelope(-20037508.5,-20037508.5,20037508.5,20037508.5,3857)";e=e.replace("!bbox!",l).replace("!pixel_width!",f).replace("!pixel_height!",f);var c=Mustache.render(e,t),h=c.length0&&e.rows[0].maxx!=null){var t=e.rows[0],n=-85.0511,s=85.0511,o=-179,u=179,a=function(e,t,n){return en?n:e},f=a(t.maxx,o,u),l=a(t.minx,o,u),c=a(t.maxy,n,s),h=a(t.miny,n,s),p=[[c,f],[h,l]];i.trigger("done",p),r&&r(p)}}).error(function(e){i.trigger("error",e)}),i},t.prototype.table=function(e){function a(){a.fetch.apply(a,arguments)}var t=e,n,r=[],i,s,o,u=this;return a.fetch=function(e){e=e||{};var t=arguments,n=t[t.length-1];_.isFunction(n)&&(callback=n,t.length===1&&(e={})),u.execute(a.sql(),e,callback)},a.sql=function(){var e="select";return r.length?e+=" "+r.join(",")+" ":e+=" * ",e+="from "+t,n&&(e+=" where "+n),i&&(e+=" limit "+i),s&&(e+=" order by "+s),o&&(e+=" "+o),e},a.filter=function(e){return n=e,a},a.order_by=function(e){return s=e,a},a.asc=function(){return o="asc",a},a.desc=function(){return o="desc",a},a.columns=function(e){return r=e,a},a.limit=function(e){return i=e,a},a},e.cartodb.SQL=t}(),function(){cartodb.createVis=function(e,t,n,r){if(!e)throw new TypeError("a DOM element should be provided");var i=arguments,s=i[i.length-1];_.isFunction(s)&&(r=s),e=typeof e=="string"?document.getElementById(e):e;var o=new cartodb.vis.Vis({el:e});return t&&(o.load(t,n),r&&o.done(r)),o}}(),cdb.$=$,cdb.L=L,cdb.Mustache=Mustache,cdb.Backbone=Backbone,cdb._=_}();for(var i in __prev)__prev[i]&&(window[i]=__prev[i])})(); \ No newline at end of file diff --git a/js/vendor/handlebars-v3.0.0.js b/js/vendor/handlebars-v3.0.0.js deleted file mode 100644 index f5c05ab..0000000 --- a/js/vendor/handlebars-v3.0.0.js +++ /dev/null @@ -1,3746 +0,0 @@ -/*! - - handlebars v3.0.0 - -Copyright (C) 2011-2014 by Yehuda Katz - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -@license -*/ -/* exported Handlebars */ -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - define([], factory); - } else if (typeof exports === 'object') { - module.exports = factory(); - } else { - root.Handlebars = factory(); - } -}(this, function () { -// handlebars/utils.js -var __module3__ = (function() { - "use strict"; - var __exports__ = {}; - /*jshint -W004 */ - var escape = { - "&": "&", - "<": "<", - ">": ">", - '"': """, - "'": "'", - "`": "`" - }; - - var badChars = /[&<>"'`]/g; - var possible = /[&<>"'`]/; - - function escapeChar(chr) { - return escape[chr]; - } - - function extend(obj /* , ...source */) { - for (var i = 1; i < arguments.length; i++) { - for (var key in arguments[i]) { - if (Object.prototype.hasOwnProperty.call(arguments[i], key)) { - obj[key] = arguments[i][key]; - } - } - } - - return obj; - } - - __exports__.extend = extend;var toString = Object.prototype.toString; - __exports__.toString = toString; - // Sourced from lodash - // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt - var isFunction = function(value) { - return typeof value === 'function'; - }; - // fallback for older versions of Chrome and Safari - /* istanbul ignore next */ - if (isFunction(/x/)) { - isFunction = function(value) { - return typeof value === 'function' && toString.call(value) === '[object Function]'; - }; - } - var isFunction; - __exports__.isFunction = isFunction; - /* istanbul ignore next */ - var isArray = Array.isArray || function(value) { - return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false; - }; - __exports__.isArray = isArray; - // Older IE versions do not directly support indexOf so we must implement our own, sadly. - function indexOf(array, value) { - for (var i = 0, len = array.length; i < len; i++) { - if (array[i] === value) { - return i; - } - } - return -1; - } - - __exports__.indexOf = indexOf; - function escapeExpression(string) { - // don't escape SafeStrings, since they're already safe - if (string && string.toHTML) { - return string.toHTML(); - } else if (string == null) { - return ""; - } else if (!string) { - return string + ''; - } - - // Force a string conversion as this will be done by the append regardless and - // the regex test will do this transparently behind the scenes, causing issues if - // an object's to string has escaped characters in it. - string = "" + string; - - if(!possible.test(string)) { return string; } - return string.replace(badChars, escapeChar); - } - - __exports__.escapeExpression = escapeExpression;function isEmpty(value) { - if (!value && value !== 0) { - return true; - } else if (isArray(value) && value.length === 0) { - return true; - } else { - return false; - } - } - - __exports__.isEmpty = isEmpty;function blockParams(params, ids) { - params.path = ids; - return params; - } - - __exports__.blockParams = blockParams;function appendContextPath(contextPath, id) { - return (contextPath ? contextPath + '.' : '') + id; - } - - __exports__.appendContextPath = appendContextPath; - return __exports__; -})(); - -// handlebars/exception.js -var __module4__ = (function() { - "use strict"; - var __exports__; - - var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; - - function Exception(message, node) { - var loc = node && node.loc, - line, - column; - if (loc) { - line = loc.start.line; - column = loc.start.column; - - message += ' - ' + line + ':' + column; - } - - var tmp = Error.prototype.constructor.call(this, message); - - // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. - for (var idx = 0; idx < errorProps.length; idx++) { - this[errorProps[idx]] = tmp[errorProps[idx]]; - } - - if (loc) { - this.lineNumber = line; - this.column = column; - } - } - - Exception.prototype = new Error(); - - __exports__ = Exception; - return __exports__; -})(); - -// handlebars/base.js -var __module2__ = (function(__dependency1__, __dependency2__) { - "use strict"; - var __exports__ = {}; - var Utils = __dependency1__; - var Exception = __dependency2__; - - var VERSION = "3.0.0"; - __exports__.VERSION = VERSION;var COMPILER_REVISION = 6; - __exports__.COMPILER_REVISION = COMPILER_REVISION; - var REVISION_CHANGES = { - 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it - 2: '== 1.0.0-rc.3', - 3: '== 1.0.0-rc.4', - 4: '== 1.x.x', - 5: '== 2.0.0-alpha.x', - 6: '>= 2.0.0-beta.1' - }; - __exports__.REVISION_CHANGES = REVISION_CHANGES; - var isArray = Utils.isArray, - isFunction = Utils.isFunction, - toString = Utils.toString, - objectType = '[object Object]'; - - function HandlebarsEnvironment(helpers, partials) { - this.helpers = helpers || {}; - this.partials = partials || {}; - - registerDefaultHelpers(this); - } - - __exports__.HandlebarsEnvironment = HandlebarsEnvironment;HandlebarsEnvironment.prototype = { - constructor: HandlebarsEnvironment, - - logger: logger, - log: log, - - registerHelper: function(name, fn) { - if (toString.call(name) === objectType) { - if (fn) { throw new Exception('Arg not supported with multiple helpers'); } - Utils.extend(this.helpers, name); - } else { - this.helpers[name] = fn; - } - }, - unregisterHelper: function(name) { - delete this.helpers[name]; - }, - - registerPartial: function(name, partial) { - if (toString.call(name) === objectType) { - Utils.extend(this.partials, name); - } else { - if (typeof partial === 'undefined') { - throw new Exception('Attempting to register a partial as undefined'); - } - this.partials[name] = partial; - } - }, - unregisterPartial: function(name) { - delete this.partials[name]; - } - }; - - function registerDefaultHelpers(instance) { - instance.registerHelper('helperMissing', function(/* [args, ]options */) { - if(arguments.length === 1) { - // A missing field in a {{foo}} constuct. - return undefined; - } else { - // Someone is actually trying to call something, blow up. - throw new Exception("Missing helper: '" + arguments[arguments.length-1].name + "'"); - } - }); - - instance.registerHelper('blockHelperMissing', function(context, options) { - var inverse = options.inverse, - fn = options.fn; - - if(context === true) { - return fn(this); - } else if(context === false || context == null) { - return inverse(this); - } else if (isArray(context)) { - if(context.length > 0) { - if (options.ids) { - options.ids = [options.name]; - } - - return instance.helpers.each(context, options); - } else { - return inverse(this); - } - } else { - if (options.data && options.ids) { - var data = createFrame(options.data); - data.contextPath = Utils.appendContextPath(options.data.contextPath, options.name); - options = {data: data}; - } - - return fn(context, options); - } - }); - - instance.registerHelper('each', function(context, options) { - if (!options) { - throw new Exception('Must pass iterator to #each'); - } - - var fn = options.fn, inverse = options.inverse; - var i = 0, ret = "", data; - - var contextPath; - if (options.data && options.ids) { - contextPath = Utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.'; - } - - if (isFunction(context)) { context = context.call(this); } - - if (options.data) { - data = createFrame(options.data); - } - - function execIteration(key, i, last) { - if (data) { - data.key = key; - data.index = i; - data.first = i === 0; - data.last = !!last; - - if (contextPath) { - data.contextPath = contextPath + key; - } - } - - ret = ret + fn(context[key], { - data: data, - blockParams: Utils.blockParams([context[key], key], [contextPath + key, null]) - }); - } - - if(context && typeof context === 'object') { - if (isArray(context)) { - for(var j = context.length; i 2) { - expected.push("'" + this.terminals_[p] + "'"); - } - if (this.lexer.showPosition) { - errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; - } else { - errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); - } - this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); - } - } - if (action[0] instanceof Array && action.length > 1) { - throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); - } - switch (action[0]) { - case 1: - stack.push(symbol); - vstack.push(this.lexer.yytext); - lstack.push(this.lexer.yylloc); - stack.push(action[1]); - symbol = null; - if (!preErrorSymbol) { - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - yyloc = this.lexer.yylloc; - if (recovering > 0) - recovering--; - } else { - symbol = preErrorSymbol; - preErrorSymbol = null; - } - break; - case 2: - len = this.productions_[action[1]][1]; - yyval.$ = vstack[vstack.length - len]; - yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; - if (ranges) { - yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; - } - r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); - if (typeof r !== "undefined") { - return r; - } - if (len) { - stack = stack.slice(0, -1 * len * 2); - vstack = vstack.slice(0, -1 * len); - lstack = lstack.slice(0, -1 * len); - } - stack.push(this.productions_[action[1]][0]); - vstack.push(yyval.$); - lstack.push(yyval._$); - newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; - stack.push(newState); - break; - case 3: - return true; - } - } - return true; - } - }; - /* Jison generated lexer */ - var lexer = (function(){ - var lexer = ({EOF:1, - parseError:function parseError(str, hash) { - if (this.yy.parser) { - this.yy.parser.parseError(str, hash); - } else { - throw new Error(str); - } - }, - setInput:function (input) { - this._input = input; - this._more = this._less = this.done = false; - 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}; - if (this.options.ranges) this.yylloc.range = [0,0]; - this.offset = 0; - return this; - }, - input:function () { - var ch = this._input[0]; - this.yytext += ch; - this.yyleng++; - this.offset++; - this.match += ch; - this.matched += ch; - var lines = ch.match(/(?:\r\n?|\n).*/g); - if (lines) { - this.yylineno++; - this.yylloc.last_line++; - } else { - this.yylloc.last_column++; - } - if (this.options.ranges) this.yylloc.range[1]++; - - this._input = this._input.slice(1); - return ch; - }, - unput:function (ch) { - var len = ch.length; - var lines = ch.split(/(?:\r\n?|\n)/g); - - this._input = ch + this._input; - this.yytext = this.yytext.substr(0, this.yytext.length-len-1); - //this.yyleng -= len; - this.offset -= len; - var oldLines = this.match.split(/(?:\r\n?|\n)/g); - this.match = this.match.substr(0, this.match.length-1); - this.matched = this.matched.substr(0, this.matched.length-1); - - if (lines.length-1) this.yylineno -= lines.length-1; - var r = this.yylloc.range; - - this.yylloc = {first_line: this.yylloc.first_line, - last_line: this.yylineno+1, - first_column: this.yylloc.first_column, - last_column: lines ? - (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: - this.yylloc.first_column - len - }; - - if (this.options.ranges) { - this.yylloc.range = [r[0], r[0] + this.yyleng - len]; - } - return this; - }, - more:function () { - this._more = true; - return this; - }, - less:function (n) { - this.unput(this.match.slice(n)); - }, - pastInput:function () { - var past = this.matched.substr(0, this.matched.length - this.match.length); - return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); - }, - upcomingInput:function () { - var next = this.match; - if (next.length < 20) { - next += this._input.substr(0, 20-next.length); - } - return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); - }, - showPosition:function () { - var pre = this.pastInput(); - var c = new Array(pre.length + 1).join("-"); - return pre + this.upcomingInput() + "\n" + c+"^"; - }, - next:function () { - if (this.done) { - return this.EOF; - } - if (!this._input) this.done = true; - - var token, - match, - tempMatch, - index, - col, - lines; - if (!this._more) { - this.yytext = ''; - this.match = ''; - } - var rules = this._currentRules(); - for (var i=0;i < rules.length; i++) { - tempMatch = this._input.match(this.rules[rules[i]]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (!this.options.flex) break; - } - } - if (match) { - lines = match[0].match(/(?:\r\n?|\n).*/g); - if (lines) this.yylineno += lines.length; - this.yylloc = {first_line: this.yylloc.last_line, - last_line: this.yylineno+1, - first_column: this.yylloc.last_column, - last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; - this.yytext += match[0]; - this.match += match[0]; - this.matches = match; - this.yyleng = this.yytext.length; - if (this.options.ranges) { - this.yylloc.range = [this.offset, this.offset += this.yyleng]; - } - this._more = false; - this._input = this._input.slice(match[0].length); - this.matched += match[0]; - token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); - if (this.done && this._input) this.done = false; - if (token) return token; - else return; - } - if (this._input === "") { - return this.EOF; - } else { - return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), - {text: "", token: null, line: this.yylineno}); - } - }, - lex:function lex() { - var r = this.next(); - if (typeof r !== 'undefined') { - return r; - } else { - return this.lex(); - } - }, - begin:function begin(condition) { - this.conditionStack.push(condition); - }, - popState:function popState() { - return this.conditionStack.pop(); - }, - _currentRules:function _currentRules() { - return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; - }, - topState:function () { - return this.conditionStack[this.conditionStack.length-2]; - }, - pushState:function begin(condition) { - this.begin(condition); - }}); - lexer.options = {}; - lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { - - - function strip(start, end) { - return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng-end); - } - - - var YYSTATE=YY_START - switch($avoiding_name_collisions) { - case 0: - if(yy_.yytext.slice(-2) === "\\\\") { - strip(0,1); - this.begin("mu"); - } else if(yy_.yytext.slice(-1) === "\\") { - strip(0,1); - this.begin("emu"); - } else { - this.begin("mu"); - } - if(yy_.yytext) return 14; - - break; - case 1:return 14; - break; - case 2: - this.popState(); - return 14; - - break; - case 3: - yy_.yytext = yy_.yytext.substr(5, yy_.yyleng-9); - this.popState(); - return 16; - - break; - case 4: return 14; - break; - case 5: - this.popState(); - return 13; - - break; - case 6:return 59; - break; - case 7:return 62; - break; - case 8: return 17; - break; - case 9: - this.popState(); - this.begin('raw'); - return 21; - - break; - case 10:return 53; - break; - case 11:return 27; - break; - case 12:return 45; - break; - case 13:this.popState(); return 42; - break; - case 14:this.popState(); return 42; - break; - case 15:return 32; - break; - case 16:return 37; - break; - case 17:return 49; - break; - case 18:return 46; - break; - case 19: - this.unput(yy_.yytext); - this.popState(); - this.begin('com'); - - break; - case 20: - this.popState(); - return 13; - - break; - case 21:return 46; - break; - case 22:return 67; - break; - case 23:return 66; - break; - case 24:return 66; - break; - case 25:return 79; - break; - case 26:// ignore whitespace - break; - case 27:this.popState(); return 52; - break; - case 28:this.popState(); return 31; - break; - case 29:yy_.yytext = strip(1,2).replace(/\\"/g,'"'); return 74; - break; - case 30:yy_.yytext = strip(1,2).replace(/\\'/g,"'"); return 74; - break; - case 31:return 77; - break; - case 32:return 76; - break; - case 33:return 76; - break; - case 34:return 75; - break; - case 35:return 69; - break; - case 36:return 71; - break; - case 37:return 66; - break; - case 38:yy_.yytext = strip(1,2); return 66; - break; - case 39:return 'INVALID'; - break; - case 40:return 5; - break; - } - }; - lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]*?(?=(\{\{\{\{\/)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/]; - lexer.conditions = {"mu":{"rules":[6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"com":{"rules":[5],"inclusive":false},"raw":{"rules":[3,4],"inclusive":false},"INITIAL":{"rules":[0,1,40],"inclusive":true}}; - return lexer;})() - parser.lexer = lexer; - function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; - return new Parser; - })();__exports__ = handlebars; - /* jshint ignore:end */ - return __exports__; -})(); - -// handlebars/compiler/visitor.js -var __module11__ = (function(__dependency1__, __dependency2__) { - "use strict"; - var __exports__; - var Exception = __dependency1__; - var AST = __dependency2__; - - function Visitor() { - this.parents = []; - } - - Visitor.prototype = { - constructor: Visitor, - mutating: false, - - // Visits a given value. If mutating, will replace the value if necessary. - acceptKey: function(node, name) { - var value = this.accept(node[name]); - if (this.mutating) { - // Hacky sanity check: - if (value && (!value.type || !AST[value.type])) { - throw new Exception('Unexpected node type "' + value.type + '" found when accepting ' + name + ' on ' + node.type); - } - node[name] = value; - } - }, - - // Performs an accept operation with added sanity check to ensure - // required keys are not removed. - acceptRequired: function(node, name) { - this.acceptKey(node, name); - - if (!node[name]) { - throw new Exception(node.type + ' requires ' + name); - } - }, - - // Traverses a given array. If mutating, empty respnses will be removed - // for child elements. - acceptArray: function(array) { - for (var i = 0, l = array.length; i < l; i++) { - this.acceptKey(array, i); - - if (!array[i]) { - array.splice(i, 1); - i--; - l--; - } - } - }, - - accept: function(object) { - if (!object) { - return; - } - - if (this.current) { - this.parents.unshift(this.current); - } - this.current = object; - - var ret = this[object.type](object); - - this.current = this.parents.shift(); - - if (!this.mutating || ret) { - return ret; - } else if (ret !== false) { - return object; - } - }, - - Program: function(program) { - this.acceptArray(program.body); - }, - - MustacheStatement: function(mustache) { - this.acceptRequired(mustache, 'path'); - this.acceptArray(mustache.params); - this.acceptKey(mustache, 'hash'); - }, - - BlockStatement: function(block) { - this.acceptRequired(block, 'path'); - this.acceptArray(block.params); - this.acceptKey(block, 'hash'); - - this.acceptKey(block, 'program'); - this.acceptKey(block, 'inverse'); - }, - - PartialStatement: function(partial) { - this.acceptRequired(partial, 'name'); - this.acceptArray(partial.params); - this.acceptKey(partial, 'hash'); - }, - - ContentStatement: function(/* content */) {}, - CommentStatement: function(/* comment */) {}, - - SubExpression: function(sexpr) { - this.acceptRequired(sexpr, 'path'); - this.acceptArray(sexpr.params); - this.acceptKey(sexpr, 'hash'); - }, - PartialExpression: function(partial) { - this.acceptRequired(partial, 'name'); - this.acceptArray(partial.params); - this.acceptKey(partial, 'hash'); - }, - - PathExpression: function(/* path */) {}, - - StringLiteral: function(/* string */) {}, - NumberLiteral: function(/* number */) {}, - BooleanLiteral: function(/* bool */) {}, - - Hash: function(hash) { - this.acceptArray(hash.pairs); - }, - HashPair: function(pair) { - this.acceptRequired(pair, 'value'); - } - }; - - __exports__ = Visitor; - return __exports__; -})(__module4__, __module7__); - -// handlebars/compiler/whitespace-control.js -var __module10__ = (function(__dependency1__) { - "use strict"; - var __exports__; - var Visitor = __dependency1__; - - function WhitespaceControl() { - } - WhitespaceControl.prototype = new Visitor(); - - WhitespaceControl.prototype.Program = function(program) { - var isRoot = !this.isRootSeen; - this.isRootSeen = true; - - var body = program.body; - for (var i = 0, l = body.length; i < l; i++) { - var current = body[i], - strip = this.accept(current); - - if (!strip) { - continue; - } - - var _isPrevWhitespace = isPrevWhitespace(body, i, isRoot), - _isNextWhitespace = isNextWhitespace(body, i, isRoot), - - openStandalone = strip.openStandalone && _isPrevWhitespace, - closeStandalone = strip.closeStandalone && _isNextWhitespace, - inlineStandalone = strip.inlineStandalone && _isPrevWhitespace && _isNextWhitespace; - - if (strip.close) { - omitRight(body, i, true); - } - if (strip.open) { - omitLeft(body, i, true); - } - - if (inlineStandalone) { - omitRight(body, i); - - if (omitLeft(body, i)) { - // If we are on a standalone node, save the indent info for partials - if (current.type === 'PartialStatement') { - // Pull out the whitespace from the final line - current.indent = (/([ \t]+$)/).exec(body[i-1].original)[1]; - } - } - } - if (openStandalone) { - omitRight((current.program || current.inverse).body); - - // Strip out the previous content node if it's whitespace only - omitLeft(body, i); - } - if (closeStandalone) { - // Always strip the next node - omitRight(body, i); - - omitLeft((current.inverse || current.program).body); - } - } - - return program; - }; - WhitespaceControl.prototype.BlockStatement = function(block) { - this.accept(block.program); - this.accept(block.inverse); - - // Find the inverse program that is involed with whitespace stripping. - var program = block.program || block.inverse, - inverse = block.program && block.inverse, - firstInverse = inverse, - lastInverse = inverse; - - if (inverse && inverse.chained) { - firstInverse = inverse.body[0].program; - - // Walk the inverse chain to find the last inverse that is actually in the chain. - while (lastInverse.chained) { - lastInverse = lastInverse.body[lastInverse.body.length-1].program; - } - } - - var strip = { - open: block.openStrip.open, - close: block.closeStrip.close, - - // Determine the standalone candiacy. Basically flag our content as being possibly standalone - // so our parent can determine if we actually are standalone - openStandalone: isNextWhitespace(program.body), - closeStandalone: isPrevWhitespace((firstInverse || program).body) - }; - - if (block.openStrip.close) { - omitRight(program.body, null, true); - } - - if (inverse) { - var inverseStrip = block.inverseStrip; - - if (inverseStrip.open) { - omitLeft(program.body, null, true); - } - - if (inverseStrip.close) { - omitRight(firstInverse.body, null, true); - } - if (block.closeStrip.open) { - omitLeft(lastInverse.body, null, true); - } - - // Find standalone else statments - if (isPrevWhitespace(program.body) - && isNextWhitespace(firstInverse.body)) { - - omitLeft(program.body); - omitRight(firstInverse.body); - } - } else { - if (block.closeStrip.open) { - omitLeft(program.body, null, true); - } - } - - return strip; - }; - - WhitespaceControl.prototype.MustacheStatement = function(mustache) { - return mustache.strip; - }; - - WhitespaceControl.prototype.PartialStatement = - WhitespaceControl.prototype.CommentStatement = function(node) { - /* istanbul ignore next */ - var strip = node.strip || {}; - return { - inlineStandalone: true, - open: strip.open, - close: strip.close - }; - }; - - - function isPrevWhitespace(body, i, isRoot) { - if (i === undefined) { - i = body.length; - } - - // Nodes that end with newlines are considered whitespace (but are special - // cased for strip operations) - var prev = body[i-1], - sibling = body[i-2]; - if (!prev) { - return isRoot; - } - - if (prev.type === 'ContentStatement') { - return (sibling || !isRoot ? (/\r?\n\s*?$/) : (/(^|\r?\n)\s*?$/)).test(prev.original); - } - } - function isNextWhitespace(body, i, isRoot) { - if (i === undefined) { - i = -1; - } - - var next = body[i+1], - sibling = body[i+2]; - if (!next) { - return isRoot; - } - - if (next.type === 'ContentStatement') { - return (sibling || !isRoot ? (/^\s*?\r?\n/) : (/^\s*?(\r?\n|$)/)).test(next.original); - } - } - - // Marks the node to the right of the position as omitted. - // I.e. {{foo}}' ' will mark the ' ' node as omitted. - // - // If i is undefined, then the first child will be marked as such. - // - // If mulitple is truthy then all whitespace will be stripped out until non-whitespace - // content is met. - function omitRight(body, i, multiple) { - var current = body[i == null ? 0 : i + 1]; - if (!current || current.type !== 'ContentStatement' || (!multiple && current.rightStripped)) { - return; - } - - var original = current.value; - current.value = current.value.replace(multiple ? (/^\s+/) : (/^[ \t]*\r?\n?/), ''); - current.rightStripped = current.value !== original; - } - - // Marks the node to the left of the position as omitted. - // I.e. ' '{{foo}} will mark the ' ' node as omitted. - // - // If i is undefined then the last child will be marked as such. - // - // If mulitple is truthy then all whitespace will be stripped out until non-whitespace - // content is met. - function omitLeft(body, i, multiple) { - var current = body[i == null ? body.length - 1 : i - 1]; - if (!current || current.type !== 'ContentStatement' || (!multiple && current.leftStripped)) { - return; - } - - // We omit the last node if it's whitespace only and not preceeded by a non-content node. - var original = current.value; - current.value = current.value.replace(multiple ? (/\s+$/) : (/[ \t]+$/), ''); - current.leftStripped = current.value !== original; - return current.leftStripped; - } - - __exports__ = WhitespaceControl; - return __exports__; -})(__module11__); - -// handlebars/compiler/helpers.js -var __module12__ = (function(__dependency1__) { - "use strict"; - var __exports__ = {}; - var Exception = __dependency1__; - - function SourceLocation(source, locInfo) { - this.source = source; - this.start = { - line: locInfo.first_line, - column: locInfo.first_column - }; - this.end = { - line: locInfo.last_line, - column: locInfo.last_column - }; - } - - __exports__.SourceLocation = SourceLocation;function stripFlags(open, close) { - return { - open: open.charAt(2) === '~', - close: close.charAt(close.length-3) === '~' - }; - } - - __exports__.stripFlags = stripFlags;function stripComment(comment) { - return comment.replace(/^\{\{~?\!-?-?/, '') - .replace(/-?-?~?\}\}$/, ''); - } - - __exports__.stripComment = stripComment;function preparePath(data, parts, locInfo) { - /*jshint -W040 */ - locInfo = this.locInfo(locInfo); - - var original = data ? '@' : '', - dig = [], - depth = 0, - depthString = ''; - - for(var i=0,l=parts.length; i 0) { - throw new Exception('Invalid path: ' + original, {loc: locInfo}); - } else if (part === '..') { - depth++; - depthString += '../'; - } - } else { - dig.push(part); - } - } - - return new this.PathExpression(data, depth, dig, original, locInfo); - } - - __exports__.preparePath = preparePath;function prepareMustache(path, params, hash, open, strip, locInfo) { - /*jshint -W040 */ - // Must use charAt to support IE pre-10 - var escapeFlag = open.charAt(3) || open.charAt(2), - escaped = escapeFlag !== '{' && escapeFlag !== '&'; - - return new this.MustacheStatement(path, params, hash, escaped, strip, this.locInfo(locInfo)); - } - - __exports__.prepareMustache = prepareMustache;function prepareRawBlock(openRawBlock, content, close, locInfo) { - /*jshint -W040 */ - if (openRawBlock.path.original !== close) { - var errorNode = {loc: openRawBlock.path.loc}; - - throw new Exception(openRawBlock.path.original + " doesn't match " + close, errorNode); - } - - locInfo = this.locInfo(locInfo); - var program = new this.Program([content], null, {}, locInfo); - - return new this.BlockStatement( - openRawBlock.path, openRawBlock.params, openRawBlock.hash, - program, undefined, - {}, {}, {}, - locInfo); - } - - __exports__.prepareRawBlock = prepareRawBlock;function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) { - /*jshint -W040 */ - // When we are chaining inverse calls, we will not have a close path - if (close && close.path && openBlock.path.original !== close.path.original) { - var errorNode = {loc: openBlock.path.loc}; - - throw new Exception(openBlock.path.original + ' doesn\'t match ' + close.path.original, errorNode); - } - - program.blockParams = openBlock.blockParams; - - var inverse, - inverseStrip; - - if (inverseAndProgram) { - if (inverseAndProgram.chain) { - inverseAndProgram.program.body[0].closeStrip = close.strip; - } - - inverseStrip = inverseAndProgram.strip; - inverse = inverseAndProgram.program; - } - - if (inverted) { - inverted = inverse; - inverse = program; - program = inverted; - } - - return new this.BlockStatement( - openBlock.path, openBlock.params, openBlock.hash, - program, inverse, - openBlock.strip, inverseStrip, close && close.strip, - this.locInfo(locInfo)); - } - - __exports__.prepareBlock = prepareBlock; - return __exports__; -})(__module4__); - -// handlebars/compiler/base.js -var __module8__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) { - "use strict"; - var __exports__ = {}; - var parser = __dependency1__; - var AST = __dependency2__; - var WhitespaceControl = __dependency3__; - var Helpers = __dependency4__; - var extend = __dependency5__.extend; - - __exports__.parser = parser; - - var yy = {}; - extend(yy, Helpers, AST); - - function parse(input, options) { - // Just return if an already-compiled AST was passed in. - if (input.type === 'Program') { return input; } - - parser.yy = yy; - - // Altering the shared object here, but this is ok as parser is a sync operation - yy.locInfo = function(locInfo) { - return new yy.SourceLocation(options && options.srcName, locInfo); - }; - - var strip = new WhitespaceControl(); - return strip.accept(parser.parse(input)); - } - - __exports__.parse = parse; - return __exports__; -})(__module9__, __module7__, __module10__, __module12__, __module3__); - -// handlebars/compiler/compiler.js -var __module13__ = (function(__dependency1__, __dependency2__, __dependency3__) { - "use strict"; - var __exports__ = {}; - var Exception = __dependency1__; - var isArray = __dependency2__.isArray; - var indexOf = __dependency2__.indexOf; - var AST = __dependency3__; - - var slice = [].slice; - - - function Compiler() {} - - __exports__.Compiler = Compiler;// the foundHelper register will disambiguate helper lookup from finding a - // function in a context. This is necessary for mustache compatibility, which - // requires that context functions in blocks are evaluated by blockHelperMissing, - // and then proceed as if the resulting value was provided to blockHelperMissing. - - Compiler.prototype = { - compiler: Compiler, - - equals: function(other) { - var len = this.opcodes.length; - if (other.opcodes.length !== len) { - return false; - } - - for (var i = 0; i < len; i++) { - var opcode = this.opcodes[i], - otherOpcode = other.opcodes[i]; - if (opcode.opcode !== otherOpcode.opcode || !argEquals(opcode.args, otherOpcode.args)) { - return false; - } - } - - // We know that length is the same between the two arrays because they are directly tied - // to the opcode behavior above. - len = this.children.length; - for (i = 0; i < len; i++) { - if (!this.children[i].equals(other.children[i])) { - return false; - } - } - - return true; - }, - - guid: 0, - - compile: function(program, options) { - this.sourceNode = []; - this.opcodes = []; - this.children = []; - this.options = options; - this.stringParams = options.stringParams; - this.trackIds = options.trackIds; - - options.blockParams = options.blockParams || []; - - // These changes will propagate to the other compiler components - var knownHelpers = options.knownHelpers; - options.knownHelpers = { - 'helperMissing': true, - 'blockHelperMissing': true, - 'each': true, - 'if': true, - 'unless': true, - 'with': true, - 'log': true, - 'lookup': true - }; - if (knownHelpers) { - for (var name in knownHelpers) { - options.knownHelpers[name] = knownHelpers[name]; - } - } - - return this.accept(program); - }, - - compileProgram: function(program) { - var result = new this.compiler().compile(program, this.options); - var guid = this.guid++; - - this.usePartial = this.usePartial || result.usePartial; - - this.children[guid] = result; - this.useDepths = this.useDepths || result.useDepths; - - return guid; - }, - - accept: function(node) { - this.sourceNode.unshift(node); - var ret = this[node.type](node); - this.sourceNode.shift(); - return ret; - }, - - Program: function(program) { - this.options.blockParams.unshift(program.blockParams); - - var body = program.body; - for(var i=0, l=body.length; i 1) { - throw new Exception('Unsupported number of partial arguments: ' + params.length, partial); - } else if (!params.length) { - params.push({type: 'PathExpression', parts: [], depth: 0}); - } - - var partialName = partial.name.original, - isDynamic = partial.name.type === 'SubExpression'; - if (isDynamic) { - this.accept(partial.name); - } - - this.setupFullMustacheParams(partial, undefined, undefined, true); - - var indent = partial.indent || ''; - if (this.options.preventIndent && indent) { - this.opcode('appendContent', indent); - indent = ''; - } - - this.opcode('invokePartial', isDynamic, partialName, indent); - this.opcode('append'); - }, - - MustacheStatement: function(mustache) { - this.SubExpression(mustache); - - if(mustache.escaped && !this.options.noEscape) { - this.opcode('appendEscaped'); - } else { - this.opcode('append'); - } - }, - - ContentStatement: function(content) { - if (content.value) { - this.opcode('appendContent', content.value); - } - }, - - CommentStatement: function() {}, - - SubExpression: function(sexpr) { - transformLiteralToPath(sexpr); - var type = this.classifySexpr(sexpr); - - if (type === 'simple') { - this.simpleSexpr(sexpr); - } else if (type === 'helper') { - this.helperSexpr(sexpr); - } else { - this.ambiguousSexpr(sexpr); - } - }, - ambiguousSexpr: function(sexpr, program, inverse) { - var path = sexpr.path, - name = path.parts[0], - isBlock = program != null || inverse != null; - - this.opcode('getContext', path.depth); - - this.opcode('pushProgram', program); - this.opcode('pushProgram', inverse); - - this.accept(path); - - this.opcode('invokeAmbiguous', name, isBlock); - }, - - simpleSexpr: function(sexpr) { - this.accept(sexpr.path); - this.opcode('resolvePossibleLambda'); - }, - - helperSexpr: function(sexpr, program, inverse) { - var params = this.setupFullMustacheParams(sexpr, program, inverse), - path = sexpr.path, - name = path.parts[0]; - - if (this.options.knownHelpers[name]) { - this.opcode('invokeKnownHelper', params.length, name); - } else if (this.options.knownHelpersOnly) { - throw new Exception("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr); - } else { - path.falsy = true; - - this.accept(path); - this.opcode('invokeHelper', params.length, path.original, AST.helpers.simpleId(path)); - } - }, - - PathExpression: function(path) { - this.addDepth(path.depth); - this.opcode('getContext', path.depth); - - var name = path.parts[0], - scoped = AST.helpers.scopedId(path), - blockParamId = !path.depth && !scoped && this.blockParamIndex(name); - - if (blockParamId) { - this.opcode('lookupBlockParam', blockParamId, path.parts); - } else if (!name) { - // Context reference, i.e. `{{foo .}}` or `{{foo ..}}` - this.opcode('pushContext'); - } else if (path.data) { - this.options.data = true; - this.opcode('lookupData', path.depth, path.parts); - } else { - this.opcode('lookupOnContext', path.parts, path.falsy, scoped); - } - }, - - StringLiteral: function(string) { - this.opcode('pushString', string.value); - }, - - NumberLiteral: function(number) { - this.opcode('pushLiteral', number.value); - }, - - BooleanLiteral: function(bool) { - this.opcode('pushLiteral', bool.value); - }, - - Hash: function(hash) { - var pairs = hash.pairs, i, l; - - this.opcode('pushHash'); - - for (i=0, l=pairs.length; i= 0) { - return [depth, param]; - } - } - } - }; - - function precompile(input, options, env) { - if (input == null || (typeof input !== 'string' && input.type !== 'Program')) { - throw new Exception("You must pass a string or Handlebars AST to Handlebars.precompile. You passed " + input); - } - - options = options || {}; - if (!('data' in options)) { - options.data = true; - } - if (options.compat) { - options.useDepths = true; - } - - var ast = env.parse(input, options); - var environment = new env.Compiler().compile(ast, options); - return new env.JavaScriptCompiler().compile(environment, options); - } - - __exports__.precompile = precompile;function compile(input, options, env) { - if (input == null || (typeof input !== 'string' && input.type !== 'Program')) { - throw new Exception("You must pass a string or Handlebars AST to Handlebars.compile. You passed " + input); - } - - options = options || {}; - - if (!('data' in options)) { - options.data = true; - } - if (options.compat) { - options.useDepths = true; - } - - var compiled; - - function compileInput() { - var ast = env.parse(input, options); - var environment = new env.Compiler().compile(ast, options); - var templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); - return env.template(templateSpec); - } - - // Template is only compiled on first use and cached after that point. - var ret = function(context, options) { - if (!compiled) { - compiled = compileInput(); - } - return compiled.call(this, context, options); - }; - ret._setup = function(options) { - if (!compiled) { - compiled = compileInput(); - } - return compiled._setup(options); - }; - ret._child = function(i, data, blockParams, depths) { - if (!compiled) { - compiled = compileInput(); - } - return compiled._child(i, data, blockParams, depths); - }; - return ret; - } - - __exports__.compile = compile;function argEquals(a, b) { - if (a === b) { - return true; - } - - if (isArray(a) && isArray(b) && a.length === b.length) { - for (var i = 0; i < a.length; i++) { - if (!argEquals(a[i], b[i])) { - return false; - } - } - return true; - } - } - - function transformLiteralToPath(sexpr) { - if (!sexpr.path.parts) { - var literal = sexpr.path; - // Casting to string here to make false and 0 literal values play nicely with the rest - // of the system. - sexpr.path = new AST.PathExpression(false, 0, [literal.original+''], literal.original+'', literal.log); - } - } - return __exports__; -})(__module4__, __module3__, __module7__); - -// handlebars/compiler/code-gen.js -var __module15__ = (function(__dependency1__) { - "use strict"; - var __exports__; - var isArray = __dependency1__.isArray; - - try { - var SourceMap = require('source-map'), - SourceNode = SourceMap.SourceNode; - } catch (err) { - /* istanbul ignore next: tested but not covered in istanbul due to dist build */ - SourceNode = function(line, column, srcFile, chunks) { - this.src = ''; - if (chunks) { - this.add(chunks); - } - }; - /* istanbul ignore next */ - SourceNode.prototype = { - add: function(chunks) { - if (isArray(chunks)) { - chunks = chunks.join(''); - } - this.src += chunks; - }, - prepend: function(chunks) { - if (isArray(chunks)) { - chunks = chunks.join(''); - } - this.src = chunks + this.src; - }, - toStringWithSourceMap: function() { - return {code: this.toString()}; - }, - toString: function() { - return this.src; - } - }; - } - - - function castChunk(chunk, codeGen, loc) { - if (isArray(chunk)) { - var ret = []; - - for (var i = 0, len = chunk.length; i < len; i++) { - ret.push(codeGen.wrap(chunk[i], loc)); - } - return ret; - } else if (typeof chunk === 'boolean' || typeof chunk === 'number') { - // Handle primitives that the SourceNode will throw up on - return chunk+''; - } - return chunk; - } - - - function CodeGen(srcFile) { - this.srcFile = srcFile; - this.source = []; - } - - CodeGen.prototype = { - prepend: function(source, loc) { - this.source.unshift(this.wrap(source, loc)); - }, - push: function(source, loc) { - this.source.push(this.wrap(source, loc)); - }, - - merge: function() { - var source = this.empty(); - this.each(function(line) { - source.add([' ', line, '\n']); - }); - return source; - }, - - each: function(iter) { - for (var i = 0, len = this.source.length; i < len; i++) { - iter(this.source[i]); - } - }, - - empty: function(loc) { - loc = loc || this.currentLocation || {start:{}}; - return new SourceNode(loc.start.line, loc.start.column, this.srcFile); - }, - wrap: function(chunk, loc) { - if (chunk instanceof SourceNode) { - return chunk; - } - - loc = loc || this.currentLocation || {start:{}}; - chunk = castChunk(chunk, this, loc); - - return new SourceNode(loc.start.line, loc.start.column, this.srcFile, chunk); - }, - - functionCall: function(fn, type, params) { - params = this.generateList(params); - return this.wrap([fn, type ? '.' + type + '(' : '(', params, ')']); - }, - - quotedString: function(str) { - return '"' + (str + '') - .replace(/\\/g, '\\\\') - .replace(/"/g, '\\"') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 - .replace(/\u2029/g, '\\u2029') + '"'; - }, - - objectLiteral: function(obj) { - var pairs = []; - - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - var value = castChunk(obj[key], this); - if (value !== 'undefined') { - pairs.push([this.quotedString(key), ':', value]); - } - } - } - - var ret = this.generateList(pairs); - ret.prepend('{'); - ret.add('}'); - return ret; - }, - - - generateList: function(entries, loc) { - var ret = this.empty(loc); - - for (var i = 0, len = entries.length; i < len; i++) { - if (i) { - ret.add(','); - } - - ret.add(castChunk(entries[i], this, loc)); - } - - return ret; - }, - - generateArray: function(entries, loc) { - var ret = this.generateList(entries, loc); - ret.prepend('['); - ret.add(']'); - - return ret; - } - }; - - __exports__ = CodeGen; - return __exports__; -})(__module3__); - -// handlebars/compiler/javascript-compiler.js -var __module14__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__) { - "use strict"; - var __exports__; - var COMPILER_REVISION = __dependency1__.COMPILER_REVISION; - var REVISION_CHANGES = __dependency1__.REVISION_CHANGES; - var Exception = __dependency2__; - var isArray = __dependency3__.isArray; - var CodeGen = __dependency4__; - - function Literal(value) { - this.value = value; - } - - function JavaScriptCompiler() {} - - JavaScriptCompiler.prototype = { - // PUBLIC API: You can override these methods in a subclass to provide - // alternative compiled forms for name lookup and buffering semantics - nameLookup: function(parent, name /* , type*/) { - if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) { - return [parent, ".", name]; - } else { - return [parent, "['", name, "']"]; - } - }, - depthedLookup: function(name) { - return [this.aliasable('this.lookup'), '(depths, "', name, '")']; - }, - - compilerInfo: function() { - var revision = COMPILER_REVISION, - versions = REVISION_CHANGES[revision]; - return [revision, versions]; - }, - - appendToBuffer: function(source, location, explicit) { - // Force a source as this simplifies the merge logic. - if (!isArray(source)) { - source = [source]; - } - source = this.source.wrap(source, location); - - if (this.environment.isSimple) { - return ['return ', source, ';']; - } else if (explicit) { - // This is a case where the buffer operation occurs as a child of another - // construct, generally braces. We have to explicitly output these buffer - // operations to ensure that the emitted code goes in the correct location. - return ['buffer += ', source, ';']; - } else { - source.appendToBuffer = true; - return source; - } - }, - - initializeBuffer: function() { - return this.quotedString(""); - }, - // END PUBLIC API - - compile: function(environment, options, context, asObject) { - this.environment = environment; - this.options = options; - this.stringParams = this.options.stringParams; - this.trackIds = this.options.trackIds; - this.precompile = !asObject; - - this.name = this.environment.name; - this.isChild = !!context; - this.context = context || { - programs: [], - environments: [] - }; - - this.preamble(); - - this.stackSlot = 0; - this.stackVars = []; - this.aliases = {}; - this.registers = { list: [] }; - this.hashes = []; - this.compileStack = []; - this.inlineStack = []; - this.blockParams = []; - - this.compileChildren(environment, options); - - this.useDepths = this.useDepths || environment.useDepths || this.options.compat; - this.useBlockParams = this.useBlockParams || environment.useBlockParams; - - var opcodes = environment.opcodes, - opcode, - firstLoc, - i, - l; - - for (i = 0, l = opcodes.length; i < l; i++) { - opcode = opcodes[i]; - - this.source.currentLocation = opcode.loc; - firstLoc = firstLoc || opcode.loc; - this[opcode.opcode].apply(this, opcode.args); - } - - // Flush any trailing content that might be pending. - this.source.currentLocation = firstLoc; - this.pushSource(''); - - /* istanbul ignore next */ - if (this.stackSlot || this.inlineStack.length || this.compileStack.length) { - throw new Exception('Compile completed with content left on stack'); - } - - var fn = this.createFunctionContext(asObject); - if (!this.isChild) { - var ret = { - compiler: this.compilerInfo(), - main: fn - }; - var programs = this.context.programs; - for (i = 0, l = programs.length; i < l; i++) { - if (programs[i]) { - ret[i] = programs[i]; - } - } - - if (this.environment.usePartial) { - ret.usePartial = true; - } - if (this.options.data) { - ret.useData = true; - } - if (this.useDepths) { - ret.useDepths = true; - } - if (this.useBlockParams) { - ret.useBlockParams = true; - } - if (this.options.compat) { - ret.compat = true; - } - - if (!asObject) { - ret.compiler = JSON.stringify(ret.compiler); - - this.source.currentLocation = {start: {line: 1, column: 0}}; - ret = this.objectLiteral(ret); - - if (options.srcName) { - ret = ret.toStringWithSourceMap({file: options.destName}); - ret.map = ret.map && ret.map.toString(); - } else { - ret = ret.toString(); - } - } else { - ret.compilerOptions = this.options; - } - - return ret; - } else { - return fn; - } - }, - - preamble: function() { - // track the last context pushed into place to allow skipping the - // getContext opcode when it would be a noop - this.lastContext = 0; - this.source = new CodeGen(this.options.srcName); - }, - - createFunctionContext: function(asObject) { - var varDeclarations = ''; - - var locals = this.stackVars.concat(this.registers.list); - if(locals.length > 0) { - varDeclarations += ", " + locals.join(", "); - } - - // Generate minimizer alias mappings - // - // When using true SourceNodes, this will update all references to the given alias - // as the source nodes are reused in situ. For the non-source node compilation mode, - // aliases will not be used, but this case is already being run on the client and - // we aren't concern about minimizing the template size. - var aliasCount = 0; - for (var alias in this.aliases) { - var node = this.aliases[alias]; - - if (this.aliases.hasOwnProperty(alias) && node.children && node.referenceCount > 1) { - varDeclarations += ', alias' + (++aliasCount) + '=' + alias; - node.children[0] = 'alias' + aliasCount; - } - } - - var params = ["depth0", "helpers", "partials", "data"]; - - if (this.useBlockParams || this.useDepths) { - params.push('blockParams'); - } - if (this.useDepths) { - params.push('depths'); - } - - // Perform a second pass over the output to merge content when possible - var source = this.mergeSource(varDeclarations); - - if (asObject) { - params.push(source); - - return Function.apply(this, params); - } else { - return this.source.wrap(['function(', params.join(','), ') {\n ', source, '}']); - } - }, - mergeSource: function(varDeclarations) { - var isSimple = this.environment.isSimple, - appendOnly = !this.forceBuffer, - appendFirst, - - sourceSeen, - bufferStart, - bufferEnd; - this.source.each(function(line) { - if (line.appendToBuffer) { - if (bufferStart) { - line.prepend(' + '); - } else { - bufferStart = line; - } - bufferEnd = line; - } else { - if (bufferStart) { - if (!sourceSeen) { - appendFirst = true; - } else { - bufferStart.prepend('buffer += '); - } - bufferEnd.add(';'); - bufferStart = bufferEnd = undefined; - } - - sourceSeen = true; - if (!isSimple) { - appendOnly = false; - } - } - }); - - - if (appendOnly) { - if (bufferStart) { - bufferStart.prepend('return '); - bufferEnd.add(';'); - } else if (!sourceSeen) { - this.source.push('return "";'); - } - } else { - varDeclarations += ", buffer = " + (appendFirst ? '' : this.initializeBuffer()); - - if (bufferStart) { - bufferStart.prepend('return buffer + '); - bufferEnd.add(';'); - } else { - this.source.push('return buffer;'); - } - } - - if (varDeclarations) { - this.source.prepend('var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n')); - } - - return this.source.merge(); - }, - - // [blockValue] - // - // On stack, before: hash, inverse, program, value - // On stack, after: return value of blockHelperMissing - // - // The purpose of this opcode is to take a block of the form - // `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and - // replace it on the stack with the result of properly - // invoking blockHelperMissing. - blockValue: function(name) { - var blockHelperMissing = this.aliasable('helpers.blockHelperMissing'), - params = [this.contextName(0)]; - this.setupHelperArgs(name, 0, params); - - var blockName = this.popStack(); - params.splice(1, 0, blockName); - - this.push(this.source.functionCall(blockHelperMissing, 'call', params)); - }, - - // [ambiguousBlockValue] - // - // On stack, before: hash, inverse, program, value - // Compiler value, before: lastHelper=value of last found helper, if any - // On stack, after, if no lastHelper: same as [blockValue] - // On stack, after, if lastHelper: value - ambiguousBlockValue: function() { - // We're being a bit cheeky and reusing the options value from the prior exec - var blockHelperMissing = this.aliasable('helpers.blockHelperMissing'), - params = [this.contextName(0)]; - this.setupHelperArgs('', 0, params, true); - - this.flushInline(); - - var current = this.topStack(); - params.splice(1, 0, current); - - this.pushSource([ - 'if (!', this.lastHelper, ') { ', - current, ' = ', this.source.functionCall(blockHelperMissing, 'call', params), - '}']); - }, - - // [appendContent] - // - // On stack, before: ... - // On stack, after: ... - // - // Appends the string value of `content` to the current buffer - appendContent: function(content) { - if (this.pendingContent) { - content = this.pendingContent + content; - } else { - this.pendingLocation = this.source.currentLocation; - } - - this.pendingContent = content; - }, - - // [append] - // - // On stack, before: value, ... - // On stack, after: ... - // - // Coerces `value` to a String and appends it to the current buffer. - // - // If `value` is truthy, or 0, it is coerced into a string and appended - // Otherwise, the empty string is appended - append: function() { - if (this.isInline()) { - this.replaceStack(function(current) { - return [' != null ? ', current, ' : ""']; - }); - - this.pushSource(this.appendToBuffer(this.popStack())); - } else { - var local = this.popStack(); - this.pushSource(['if (', local, ' != null) { ', this.appendToBuffer(local, undefined, true), ' }']); - if (this.environment.isSimple) { - this.pushSource(['else { ', this.appendToBuffer("''", undefined, true), ' }']); - } - } - }, - - // [appendEscaped] - // - // On stack, before: value, ... - // On stack, after: ... - // - // Escape `value` and append it to the buffer - appendEscaped: function() { - this.pushSource(this.appendToBuffer( - [this.aliasable('this.escapeExpression'), '(', this.popStack(), ')'])); - }, - - // [getContext] - // - // On stack, before: ... - // On stack, after: ... - // Compiler value, after: lastContext=depth - // - // Set the value of the `lastContext` compiler value to the depth - getContext: function(depth) { - this.lastContext = depth; - }, - - // [pushContext] - // - // On stack, before: ... - // On stack, after: currentContext, ... - // - // Pushes the value of the current context onto the stack. - pushContext: function() { - this.pushStackLiteral(this.contextName(this.lastContext)); - }, - - // [lookupOnContext] - // - // On stack, before: ... - // On stack, after: currentContext[name], ... - // - // Looks up the value of `name` on the current context and pushes - // it onto the stack. - lookupOnContext: function(parts, falsy, scoped) { - var i = 0; - - if (!scoped && this.options.compat && !this.lastContext) { - // The depthed query is expected to handle the undefined logic for the root level that - // is implemented below, so we evaluate that directly in compat mode - this.push(this.depthedLookup(parts[i++])); - } else { - this.pushContext(); - } - - this.resolvePath('context', parts, i, falsy); - }, - - // [lookupBlockParam] - // - // On stack, before: ... - // On stack, after: blockParam[name], ... - // - // Looks up the value of `parts` on the given block param and pushes - // it onto the stack. - lookupBlockParam: function(blockParamId, parts) { - this.useBlockParams = true; - - this.push(['blockParams[', blockParamId[0], '][', blockParamId[1], ']']); - this.resolvePath('context', parts, 1); - }, - - // [lookupData] - // - // On stack, before: ... - // On stack, after: data, ... - // - // Push the data lookup operator - lookupData: function(depth, parts) { - /*jshint -W083 */ - if (!depth) { - this.pushStackLiteral('data'); - } else { - this.pushStackLiteral('this.data(data, ' + depth + ')'); - } - - this.resolvePath('data', parts, 0, true); - }, - - resolvePath: function(type, parts, i, falsy) { - /*jshint -W083 */ - if (this.options.strict || this.options.assumeObjects) { - this.push(strictLookup(this.options.strict, this, parts, type)); - return; - } - - var len = parts.length; - for (; i < len; i++) { - this.replaceStack(function(current) { - var lookup = this.nameLookup(current, parts[i], type); - // We want to ensure that zero and false are handled properly if the context (falsy flag) - // needs to have the special handling for these values. - if (!falsy) { - return [' != null ? ', lookup, ' : ', current]; - } else { - // Otherwise we can use generic falsy handling - return [' && ', lookup]; - } - }); - } - }, - - // [resolvePossibleLambda] - // - // On stack, before: value, ... - // On stack, after: resolved value, ... - // - // If the `value` is a lambda, replace it on the stack by - // the return value of the lambda - resolvePossibleLambda: function() { - this.push([this.aliasable('this.lambda'), '(', this.popStack(), ', ', this.contextName(0), ')']); - }, - - // [pushStringParam] - // - // On stack, before: ... - // On stack, after: string, currentContext, ... - // - // This opcode is designed for use in string mode, which - // provides the string value of a parameter along with its - // depth rather than resolving it immediately. - pushStringParam: function(string, type) { - this.pushContext(); - this.pushString(type); - - // If it's a subexpression, the string result - // will be pushed after this opcode. - if (type !== 'SubExpression') { - if (typeof string === 'string') { - this.pushString(string); - } else { - this.pushStackLiteral(string); - } - } - }, - - emptyHash: function(omitEmpty) { - if (this.trackIds) { - this.push('{}'); // hashIds - } - if (this.stringParams) { - this.push('{}'); // hashContexts - this.push('{}'); // hashTypes - } - this.pushStackLiteral(omitEmpty ? 'undefined' : '{}'); - }, - pushHash: function() { - if (this.hash) { - this.hashes.push(this.hash); - } - this.hash = {values: [], types: [], contexts: [], ids: []}; - }, - popHash: function() { - var hash = this.hash; - this.hash = this.hashes.pop(); - - if (this.trackIds) { - this.push(this.objectLiteral(hash.ids)); - } - if (this.stringParams) { - this.push(this.objectLiteral(hash.contexts)); - this.push(this.objectLiteral(hash.types)); - } - - this.push(this.objectLiteral(hash.values)); - }, - - // [pushString] - // - // On stack, before: ... - // On stack, after: quotedString(string), ... - // - // Push a quoted version of `string` onto the stack - pushString: function(string) { - this.pushStackLiteral(this.quotedString(string)); - }, - - // [pushLiteral] - // - // On stack, before: ... - // On stack, after: value, ... - // - // Pushes a value onto the stack. This operation prevents - // the compiler from creating a temporary variable to hold - // it. - pushLiteral: function(value) { - this.pushStackLiteral(value); - }, - - // [pushProgram] - // - // On stack, before: ... - // On stack, after: program(guid), ... - // - // Push a program expression onto the stack. This takes - // a compile-time guid and converts it into a runtime-accessible - // expression. - pushProgram: function(guid) { - if (guid != null) { - this.pushStackLiteral(this.programExpression(guid)); - } else { - this.pushStackLiteral(null); - } - }, - - // [invokeHelper] - // - // On stack, before: hash, inverse, program, params..., ... - // On stack, after: result of helper invocation - // - // Pops off the helper's parameters, invokes the helper, - // and pushes the helper's return value onto the stack. - // - // If the helper is not found, `helperMissing` is called. - invokeHelper: function(paramSize, name, isSimple) { - var nonHelper = this.popStack(); - var helper = this.setupHelper(paramSize, name); - var simple = isSimple ? [helper.name, ' || '] : ''; - - var lookup = ['('].concat(simple, nonHelper); - if (!this.options.strict) { - lookup.push(' || ', this.aliasable('helpers.helperMissing')); - } - lookup.push(')'); - - this.push(this.source.functionCall(lookup, 'call', helper.callParams)); - }, - - // [invokeKnownHelper] - // - // On stack, before: hash, inverse, program, params..., ... - // On stack, after: result of helper invocation - // - // This operation is used when the helper is known to exist, - // so a `helperMissing` fallback is not required. - invokeKnownHelper: function(paramSize, name) { - var helper = this.setupHelper(paramSize, name); - this.push(this.source.functionCall(helper.name, 'call', helper.callParams)); - }, - - // [invokeAmbiguous] - // - // On stack, before: hash, inverse, program, params..., ... - // On stack, after: result of disambiguation - // - // This operation is used when an expression like `{{foo}}` - // is provided, but we don't know at compile-time whether it - // is a helper or a path. - // - // This operation emits more code than the other options, - // and can be avoided by passing the `knownHelpers` and - // `knownHelpersOnly` flags at compile-time. - invokeAmbiguous: function(name, helperCall) { - this.useRegister('helper'); - - var nonHelper = this.popStack(); - - this.emptyHash(); - var helper = this.setupHelper(0, name, helperCall); - - var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper'); - - var lookup = ['(', '(helper = ', helperName, ' || ', nonHelper, ')']; - if (!this.options.strict) { - lookup[0] = '(helper = '; - lookup.push( - ' != null ? helper : ', - this.aliasable('helpers.helperMissing') - ); - } - - this.push([ - '(', lookup, - (helper.paramsInit ? ['),(', helper.paramsInit] : []), '),', - '(typeof helper === ', this.aliasable('"function"'), ' ? ', - this.source.functionCall('helper','call', helper.callParams), ' : helper))' - ]); - }, - - // [invokePartial] - // - // On stack, before: context, ... - // On stack after: result of partial invocation - // - // This operation pops off a context, invokes a partial with that context, - // and pushes the result of the invocation back. - invokePartial: function(isDynamic, name, indent) { - var params = [], - options = this.setupParams(name, 1, params, false); - - if (isDynamic) { - name = this.popStack(); - delete options.name; - } - - if (indent) { - options.indent = JSON.stringify(indent); - } - options.helpers = 'helpers'; - options.partials = 'partials'; - - if (!isDynamic) { - params.unshift(this.nameLookup('partials', name, 'partial')); - } else { - params.unshift(name); - } - - if (this.options.compat) { - options.depths = 'depths'; - } - options = this.objectLiteral(options); - params.push(options); - - this.push(this.source.functionCall('this.invokePartial', '', params)); - }, - - // [assignToHash] - // - // On stack, before: value, ..., hash, ... - // On stack, after: ..., hash, ... - // - // Pops a value off the stack and assigns it to the current hash - assignToHash: function(key) { - var value = this.popStack(), - context, - type, - id; - - if (this.trackIds) { - id = this.popStack(); - } - if (this.stringParams) { - type = this.popStack(); - context = this.popStack(); - } - - var hash = this.hash; - if (context) { - hash.contexts[key] = context; - } - if (type) { - hash.types[key] = type; - } - if (id) { - hash.ids[key] = id; - } - hash.values[key] = value; - }, - - pushId: function(type, name, child) { - if (type === 'BlockParam') { - this.pushStackLiteral( - 'blockParams[' + name[0] + '].path[' + name[1] + ']' - + (child ? ' + ' + JSON.stringify('.' + child) : '')); - } else if (type === 'PathExpression') { - this.pushString(name); - } else if (type === 'SubExpression') { - this.pushStackLiteral('true'); - } else { - this.pushStackLiteral('null'); - } - }, - - // HELPERS - - compiler: JavaScriptCompiler, - - compileChildren: function(environment, options) { - var children = environment.children, child, compiler; - - for(var i=0, l=children.length; i this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); } - return this.topStackName(); - }, - topStackName: function() { - return "stack" + this.stackSlot; - }, - flushInline: function() { - var inlineStack = this.inlineStack; - this.inlineStack = []; - for (var i = 0, len = inlineStack.length; i < len; i++) { - var entry = inlineStack[i]; - /* istanbul ignore if */ - if (entry instanceof Literal) { - this.compileStack.push(entry); - } else { - var stack = this.incrStack(); - this.pushSource([stack, ' = ', entry, ';']); - this.compileStack.push(stack); - } - } - }, - isInline: function() { - return this.inlineStack.length; - }, - - popStack: function(wrapped) { - var inline = this.isInline(), - item = (inline ? this.inlineStack : this.compileStack).pop(); - - if (!wrapped && (item instanceof Literal)) { - return item.value; - } else { - if (!inline) { - /* istanbul ignore next */ - if (!this.stackSlot) { - throw new Exception('Invalid stack pop'); - } - this.stackSlot--; - } - return item; - } - }, - - topStack: function() { - var stack = (this.isInline() ? this.inlineStack : this.compileStack), - item = stack[stack.length - 1]; - - /* istanbul ignore if */ - if (item instanceof Literal) { - return item.value; - } else { - return item; - } - }, - - contextName: function(context) { - if (this.useDepths && context) { - return 'depths[' + context + ']'; - } else { - return 'depth' + context; - } - }, - - quotedString: function(str) { - return this.source.quotedString(str); - }, - - objectLiteral: function(obj) { - return this.source.objectLiteral(obj); - }, - - aliasable: function(name) { - var ret = this.aliases[name]; - if (ret) { - ret.referenceCount++; - return ret; - } - - ret = this.aliases[name] = this.source.wrap(name); - ret.aliasable = true; - ret.referenceCount = 1; - - return ret; - }, - - setupHelper: function(paramSize, name, blockHelper) { - var params = [], - paramsInit = this.setupHelperArgs(name, paramSize, params, blockHelper); - var foundHelper = this.nameLookup('helpers', name, 'helper'); - - return { - params: params, - paramsInit: paramsInit, - name: foundHelper, - callParams: [this.contextName(0)].concat(params) - }; - }, - - setupParams: function(helper, paramSize, params) { - var options = {}, contexts = [], types = [], ids = [], param; - - options.name = this.quotedString(helper); - options.hash = this.popStack(); - - if (this.trackIds) { - options.hashIds = this.popStack(); - } - if (this.stringParams) { - options.hashTypes = this.popStack(); - options.hashContexts = this.popStack(); - } - - var inverse = this.popStack(), - program = this.popStack(); - - // Avoid setting fn and inverse if neither are set. This allows - // helpers to do a check for `if (options.fn)` - if (program || inverse) { - options.fn = program || 'this.noop'; - options.inverse = inverse || 'this.noop'; - } - - // The parameters go on to the stack in order (making sure that they are evaluated in order) - // so we need to pop them off the stack in reverse order - var i = paramSize; - while (i--) { - param = this.popStack(); - params[i] = param; - - if (this.trackIds) { - ids[i] = this.popStack(); - } - if (this.stringParams) { - types[i] = this.popStack(); - contexts[i] = this.popStack(); - } - } - - if (this.trackIds) { - options.ids = this.source.generateArray(ids); - } - if (this.stringParams) { - options.types = this.source.generateArray(types); - options.contexts = this.source.generateArray(contexts); - } - - if (this.options.data) { - options.data = 'data'; - } - if (this.useBlockParams) { - options.blockParams = 'blockParams'; - } - return options; - }, - - setupHelperArgs: function(helper, paramSize, params, useRegister) { - var options = this.setupParams(helper, paramSize, params, true); - options = this.objectLiteral(options); - if (useRegister) { - this.useRegister('options'); - params.push('options'); - return ['options=', options]; - } else { - params.push(options); - return ''; - } - } - }; - - - var reservedWords = ( - "break else new var" + - " case finally return void" + - " catch for switch while" + - " continue function this with" + - " default if throw" + - " delete in try" + - " do instanceof typeof" + - " abstract enum int short" + - " boolean export interface static" + - " byte extends long super" + - " char final native synchronized" + - " class float package throws" + - " const goto private transient" + - " debugger implements protected volatile" + - " double import public let yield await" + - " null true false" - ).split(" "); - - var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {}; - - for(var i=0, l=reservedWords.length; i= 0 ) && focusable( element, !isTabIndexNaN ); - } -}); - -// support: jQuery <1.8 -if ( !$( "" ).outerWidth( 1 ).jquery ) { - $.each( [ "Width", "Height" ], function( i, name ) { - var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], - type = name.toLowerCase(), - orig = { - innerWidth: $.fn.innerWidth, - innerHeight: $.fn.innerHeight, - outerWidth: $.fn.outerWidth, - outerHeight: $.fn.outerHeight - }; - - function reduce( elem, size, border, margin ) { - $.each( side, function() { - size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; - if ( border ) { - size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; - } - if ( margin ) { - size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; - } - }); - return size; - } - - $.fn[ "inner" + name ] = function( size ) { - if ( size === undefined ) { - return orig[ "inner" + name ].call( this ); - } - - return this.each(function() { - $( this ).css( type, reduce( this, size ) + "px" ); - }); - }; - - $.fn[ "outer" + name] = function( size, margin ) { - if ( typeof size !== "number" ) { - return orig[ "outer" + name ].call( this, size ); - } - - return this.each(function() { - $( this).css( type, reduce( this, size, true, margin ) + "px" ); - }); - }; - }); -} - -// support: jQuery <1.8 -if ( !$.fn.addBack ) { - $.fn.addBack = function( selector ) { - return this.add( selector == null ? - this.prevObject : this.prevObject.filter( selector ) - ); - }; -} - -// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413) -if ( $( "" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { - $.fn.removeData = (function( removeData ) { - return function( key ) { - if ( arguments.length ) { - return removeData.call( this, $.camelCase( key ) ); - } else { - return removeData.call( this ); - } - }; - })( $.fn.removeData ); -} - -// deprecated -$.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); - -$.fn.extend({ - focus: (function( orig ) { - return function( delay, fn ) { - return typeof delay === "number" ? - this.each(function() { - var elem = this; - setTimeout(function() { - $( elem ).focus(); - if ( fn ) { - fn.call( elem ); - } - }, delay ); - }) : - orig.apply( this, arguments ); - }; - })( $.fn.focus ), - - disableSelection: (function() { - var eventType = "onselectstart" in document.createElement( "div" ) ? - "selectstart" : - "mousedown"; - - return function() { - return this.bind( eventType + ".ui-disableSelection", function( event ) { - event.preventDefault(); - }); - }; - })(), - - enableSelection: function() { - return this.unbind( ".ui-disableSelection" ); - }, - - zIndex: function( zIndex ) { - if ( zIndex !== undefined ) { - return this.css( "zIndex", zIndex ); - } - - if ( this.length ) { - var elem = $( this[ 0 ] ), position, value; - while ( elem.length && elem[ 0 ] !== document ) { - // Ignore z-index if position is set to a value where z-index is ignored by the browser - // This makes behavior of this function consistent across browsers - // WebKit always returns auto if the element is positioned - position = elem.css( "position" ); - if ( position === "absolute" || position === "relative" || position === "fixed" ) { - // IE returns 0 when zIndex is not specified - // other browsers return a string - // we ignore the case of nested elements with an explicit value of 0 - //
            - value = parseInt( elem.css( "zIndex" ), 10 ); - if ( !isNaN( value ) && value !== 0 ) { - return value; - } - } - elem = elem.parent(); - } - } - - return 0; - } -}); - -// $.ui.plugin is deprecated. Use $.widget() extensions instead. -$.ui.plugin = { - add: function( module, option, set ) { - var i, - proto = $.ui[ module ].prototype; - for ( i in set ) { - proto.plugins[ i ] = proto.plugins[ i ] || []; - proto.plugins[ i ].push( [ option, set[ i ] ] ); - } - }, - call: function( instance, name, args, allowDisconnected ) { - var i, - set = instance.plugins[ name ]; - - if ( !set ) { - return; - } - - if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) { - return; - } - - for ( i = 0; i < set.length; i++ ) { - if ( instance.options[ set[ i ][ 0 ] ] ) { - set[ i ][ 1 ].apply( instance.element, args ); - } - } - } -}; - - -/*! - * jQuery UI Widget 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/jQuery.widget/ - */ - - -var widget_uuid = 0, - widget_slice = Array.prototype.slice; - -$.cleanData = (function( orig ) { - return function( elems ) { - var events, elem, i; - for ( i = 0; (elem = elems[i]) != null; i++ ) { - try { - - // Only trigger remove when necessary to save time - events = $._data( elem, "events" ); - if ( events && events.remove ) { - $( elem ).triggerHandler( "remove" ); - } - - // http://bugs.jquery.com/ticket/8235 - } catch ( e ) {} - } - orig( elems ); - }; -})( $.cleanData ); - -$.widget = function( name, base, prototype ) { - var fullName, existingConstructor, constructor, basePrototype, - // proxiedPrototype allows the provided prototype to remain unmodified - // so that it can be used as a mixin for multiple widgets (#8876) - proxiedPrototype = {}, - namespace = name.split( "." )[ 0 ]; - - name = name.split( "." )[ 1 ]; - fullName = namespace + "-" + name; - - if ( !prototype ) { - prototype = base; - base = $.Widget; - } - - // create selector for plugin - $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { - return !!$.data( elem, fullName ); - }; - - $[ namespace ] = $[ namespace ] || {}; - existingConstructor = $[ namespace ][ name ]; - constructor = $[ namespace ][ name ] = function( options, element ) { - // allow instantiation without "new" keyword - if ( !this._createWidget ) { - return new constructor( options, element ); - } - - // allow instantiation without initializing for simple inheritance - // must use "new" keyword (the code above always passes args) - if ( arguments.length ) { - this._createWidget( options, element ); - } - }; - // extend with the existing constructor to carry over any static properties - $.extend( constructor, existingConstructor, { - version: prototype.version, - // copy the object used to create the prototype in case we need to - // redefine the widget later - _proto: $.extend( {}, prototype ), - // track widgets that inherit from this widget in case this widget is - // redefined after a widget inherits from it - _childConstructors: [] - }); - - basePrototype = new base(); - // we need to make the options hash a property directly on the new instance - // otherwise we'll modify the options hash on the prototype that we're - // inheriting from - basePrototype.options = $.widget.extend( {}, basePrototype.options ); - $.each( prototype, function( prop, value ) { - if ( !$.isFunction( value ) ) { - proxiedPrototype[ prop ] = value; - return; - } - proxiedPrototype[ prop ] = (function() { - var _super = function() { - return base.prototype[ prop ].apply( this, arguments ); - }, - _superApply = function( args ) { - return base.prototype[ prop ].apply( this, args ); - }; - return function() { - var __super = this._super, - __superApply = this._superApply, - returnValue; - - this._super = _super; - this._superApply = _superApply; - - returnValue = value.apply( this, arguments ); - - this._super = __super; - this._superApply = __superApply; - - return returnValue; - }; - })(); - }); - constructor.prototype = $.widget.extend( basePrototype, { - // TODO: remove support for widgetEventPrefix - // always use the name + a colon as the prefix, e.g., draggable:start - // don't prefix for widgets that aren't DOM-based - widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name - }, proxiedPrototype, { - constructor: constructor, - namespace: namespace, - widgetName: name, - widgetFullName: fullName - }); - - // If this widget is being redefined then we need to find all widgets that - // are inheriting from it and redefine all of them so that they inherit from - // the new version of this widget. We're essentially trying to replace one - // level in the prototype chain. - if ( existingConstructor ) { - $.each( existingConstructor._childConstructors, function( i, child ) { - var childPrototype = child.prototype; - - // redefine the child widget using the same prototype that was - // originally used, but inherit from the new version of the base - $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto ); - }); - // remove the list of existing child constructors from the old constructor - // so the old child constructors can be garbage collected - delete existingConstructor._childConstructors; - } else { - base._childConstructors.push( constructor ); - } - - $.widget.bridge( name, constructor ); - - return constructor; -}; - -$.widget.extend = function( target ) { - var input = widget_slice.call( arguments, 1 ), - inputIndex = 0, - inputLength = input.length, - key, - value; - for ( ; inputIndex < inputLength; inputIndex++ ) { - for ( key in input[ inputIndex ] ) { - value = input[ inputIndex ][ key ]; - if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { - // Clone objects - if ( $.isPlainObject( value ) ) { - target[ key ] = $.isPlainObject( target[ key ] ) ? - $.widget.extend( {}, target[ key ], value ) : - // Don't extend strings, arrays, etc. with objects - $.widget.extend( {}, value ); - // Copy everything else by reference - } else { - target[ key ] = value; - } - } - } - } - return target; -}; - -$.widget.bridge = function( name, object ) { - var fullName = object.prototype.widgetFullName || name; - $.fn[ name ] = function( options ) { - var isMethodCall = typeof options === "string", - args = widget_slice.call( arguments, 1 ), - returnValue = this; - - if ( isMethodCall ) { - this.each(function() { - var methodValue, - instance = $.data( this, fullName ); - if ( options === "instance" ) { - returnValue = instance; - return false; - } - if ( !instance ) { - return $.error( "cannot call methods on " + name + " prior to initialization; " + - "attempted to call method '" + options + "'" ); - } - if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { - return $.error( "no such method '" + options + "' for " + name + " widget instance" ); - } - methodValue = instance[ options ].apply( instance, args ); - if ( methodValue !== instance && methodValue !== undefined ) { - returnValue = methodValue && methodValue.jquery ? - returnValue.pushStack( methodValue.get() ) : - methodValue; - return false; - } - }); - } else { - - // Allow multiple hashes to be passed on init - if ( args.length ) { - options = $.widget.extend.apply( null, [ options ].concat(args) ); - } - - this.each(function() { - var instance = $.data( this, fullName ); - if ( instance ) { - instance.option( options || {} ); - if ( instance._init ) { - instance._init(); - } - } else { - $.data( this, fullName, new object( options, this ) ); - } - }); - } - - return returnValue; - }; -}; - -$.Widget = function( /* options, element */ ) {}; -$.Widget._childConstructors = []; - -$.Widget.prototype = { - widgetName: "widget", - widgetEventPrefix: "", - defaultElement: "
            ", - options: { - disabled: false, - - // callbacks - create: null - }, - _createWidget: function( options, element ) { - element = $( element || this.defaultElement || this )[ 0 ]; - this.element = $( element ); - this.uuid = widget_uuid++; - this.eventNamespace = "." + this.widgetName + this.uuid; - - this.bindings = $(); - this.hoverable = $(); - this.focusable = $(); - - if ( element !== this ) { - $.data( element, this.widgetFullName, this ); - this._on( true, this.element, { - remove: function( event ) { - if ( event.target === element ) { - this.destroy(); - } - } - }); - this.document = $( element.style ? - // element within the document - element.ownerDocument : - // element is window or document - element.document || element ); - this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); - } - - this.options = $.widget.extend( {}, - this.options, - this._getCreateOptions(), - options ); - - this._create(); - this._trigger( "create", null, this._getCreateEventData() ); - this._init(); - }, - _getCreateOptions: $.noop, - _getCreateEventData: $.noop, - _create: $.noop, - _init: $.noop, - - destroy: function() { - this._destroy(); - // we can probably remove the unbind calls in 2.0 - // all event bindings should go through this._on() - this.element - .unbind( this.eventNamespace ) - .removeData( this.widgetFullName ) - // support: jquery <1.6.3 - // http://bugs.jquery.com/ticket/9413 - .removeData( $.camelCase( this.widgetFullName ) ); - this.widget() - .unbind( this.eventNamespace ) - .removeAttr( "aria-disabled" ) - .removeClass( - this.widgetFullName + "-disabled " + - "ui-state-disabled" ); - - // clean up events and states - this.bindings.unbind( this.eventNamespace ); - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); - }, - _destroy: $.noop, - - widget: function() { - return this.element; - }, - - option: function( key, value ) { - var options = key, - parts, - curOption, - i; - - if ( arguments.length === 0 ) { - // don't return a reference to the internal hash - return $.widget.extend( {}, this.options ); - } - - if ( typeof key === "string" ) { - // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } - options = {}; - parts = key.split( "." ); - key = parts.shift(); - if ( parts.length ) { - curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); - for ( i = 0; i < parts.length - 1; i++ ) { - curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; - curOption = curOption[ parts[ i ] ]; - } - key = parts.pop(); - if ( arguments.length === 1 ) { - return curOption[ key ] === undefined ? null : curOption[ key ]; - } - curOption[ key ] = value; - } else { - if ( arguments.length === 1 ) { - return this.options[ key ] === undefined ? null : this.options[ key ]; - } - options[ key ] = value; - } - } - - this._setOptions( options ); - - return this; - }, - _setOptions: function( options ) { - var key; - - for ( key in options ) { - this._setOption( key, options[ key ] ); - } - - return this; - }, - _setOption: function( key, value ) { - this.options[ key ] = value; - - if ( key === "disabled" ) { - this.widget() - .toggleClass( this.widgetFullName + "-disabled", !!value ); - - // If the widget is becoming disabled, then nothing is interactive - if ( value ) { - this.hoverable.removeClass( "ui-state-hover" ); - this.focusable.removeClass( "ui-state-focus" ); - } - } - - return this; - }, - - enable: function() { - return this._setOptions({ disabled: false }); - }, - disable: function() { - return this._setOptions({ disabled: true }); - }, - - _on: function( suppressDisabledCheck, element, handlers ) { - var delegateElement, - instance = this; - - // no suppressDisabledCheck flag, shuffle arguments - if ( typeof suppressDisabledCheck !== "boolean" ) { - handlers = element; - element = suppressDisabledCheck; - suppressDisabledCheck = false; - } - - // no element argument, shuffle and use this.element - if ( !handlers ) { - handlers = element; - element = this.element; - delegateElement = this.widget(); - } else { - element = delegateElement = $( element ); - this.bindings = this.bindings.add( element ); - } - - $.each( handlers, function( event, handler ) { - function handlerProxy() { - // allow widgets to customize the disabled handling - // - disabled as an array instead of boolean - // - disabled class as method for disabling individual parts - if ( !suppressDisabledCheck && - ( instance.options.disabled === true || - $( this ).hasClass( "ui-state-disabled" ) ) ) { - return; - } - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - - // copy the guid so direct unbinding works - if ( typeof handler !== "string" ) { - handlerProxy.guid = handler.guid = - handler.guid || handlerProxy.guid || $.guid++; - } - - var match = event.match( /^([\w:-]*)\s*(.*)$/ ), - eventName = match[1] + instance.eventNamespace, - selector = match[2]; - if ( selector ) { - delegateElement.delegate( selector, eventName, handlerProxy ); - } else { - element.bind( eventName, handlerProxy ); - } - }); - }, - - _off: function( element, eventName ) { - eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + - this.eventNamespace; - element.unbind( eventName ).undelegate( eventName ); - - // Clear the stack to avoid memory leaks (#10056) - this.bindings = $( this.bindings.not( element ).get() ); - this.focusable = $( this.focusable.not( element ).get() ); - this.hoverable = $( this.hoverable.not( element ).get() ); - }, - - _delay: function( handler, delay ) { - function handlerProxy() { - return ( typeof handler === "string" ? instance[ handler ] : handler ) - .apply( instance, arguments ); - } - var instance = this; - return setTimeout( handlerProxy, delay || 0 ); - }, - - _hoverable: function( element ) { - this.hoverable = this.hoverable.add( element ); - this._on( element, { - mouseenter: function( event ) { - $( event.currentTarget ).addClass( "ui-state-hover" ); - }, - mouseleave: function( event ) { - $( event.currentTarget ).removeClass( "ui-state-hover" ); - } - }); - }, - - _focusable: function( element ) { - this.focusable = this.focusable.add( element ); - this._on( element, { - focusin: function( event ) { - $( event.currentTarget ).addClass( "ui-state-focus" ); - }, - focusout: function( event ) { - $( event.currentTarget ).removeClass( "ui-state-focus" ); - } - }); - }, - - _trigger: function( type, event, data ) { - var prop, orig, - callback = this.options[ type ]; - - data = data || {}; - event = $.Event( event ); - event.type = ( type === this.widgetEventPrefix ? - type : - this.widgetEventPrefix + type ).toLowerCase(); - // the original event may come from any element - // so we need to reset the target on the new event - event.target = this.element[ 0 ]; - - // copy original event properties over to the new event - orig = event.originalEvent; - if ( orig ) { - for ( prop in orig ) { - if ( !( prop in event ) ) { - event[ prop ] = orig[ prop ]; - } - } - } - - this.element.trigger( event, data ); - return !( $.isFunction( callback ) && - callback.apply( this.element[0], [ event ].concat( data ) ) === false || - event.isDefaultPrevented() ); - } -}; - -$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { - $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { - if ( typeof options === "string" ) { - options = { effect: options }; - } - var hasOptions, - effectName = !options ? - method : - options === true || typeof options === "number" ? - defaultEffect : - options.effect || defaultEffect; - options = options || {}; - if ( typeof options === "number" ) { - options = { duration: options }; - } - hasOptions = !$.isEmptyObject( options ); - options.complete = callback; - if ( options.delay ) { - element.delay( options.delay ); - } - if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { - element[ method ]( options ); - } else if ( effectName !== method && element[ effectName ] ) { - element[ effectName ]( options.duration, options.easing, callback ); - } else { - element.queue(function( next ) { - $( this )[ method ](); - if ( callback ) { - callback.call( element[ 0 ] ); - } - next(); - }); - } - }; -}); - -var widget = $.widget; - - -/*! - * jQuery UI Position 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/position/ - */ - -(function() { - -$.ui = $.ui || {}; - -var cachedScrollbarWidth, supportsOffsetFractions, - max = Math.max, - abs = Math.abs, - round = Math.round, - rhorizontal = /left|center|right/, - rvertical = /top|center|bottom/, - roffset = /[\+\-]\d+(\.[\d]+)?%?/, - rposition = /^\w+/, - rpercent = /%$/, - _position = $.fn.position; - -function getOffsets( offsets, width, height ) { - return [ - parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), - parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) - ]; -} - -function parseCss( element, property ) { - return parseInt( $.css( element, property ), 10 ) || 0; -} - -function getDimensions( elem ) { - var raw = elem[0]; - if ( raw.nodeType === 9 ) { - return { - width: elem.width(), - height: elem.height(), - offset: { top: 0, left: 0 } - }; - } - if ( $.isWindow( raw ) ) { - return { - width: elem.width(), - height: elem.height(), - offset: { top: elem.scrollTop(), left: elem.scrollLeft() } - }; - } - if ( raw.preventDefault ) { - return { - width: 0, - height: 0, - offset: { top: raw.pageY, left: raw.pageX } - }; - } - return { - width: elem.outerWidth(), - height: elem.outerHeight(), - offset: elem.offset() - }; -} - -$.position = { - scrollbarWidth: function() { - if ( cachedScrollbarWidth !== undefined ) { - return cachedScrollbarWidth; - } - var w1, w2, - div = $( "
            " ), - innerDiv = div.children()[0]; - - $( "body" ).append( div ); - w1 = innerDiv.offsetWidth; - div.css( "overflow", "scroll" ); - - w2 = innerDiv.offsetWidth; - - if ( w1 === w2 ) { - w2 = div[0].clientWidth; - } - - div.remove(); - - return (cachedScrollbarWidth = w1 - w2); - }, - getScrollInfo: function( within ) { - var overflowX = within.isWindow || within.isDocument ? "" : - within.element.css( "overflow-x" ), - overflowY = within.isWindow || within.isDocument ? "" : - within.element.css( "overflow-y" ), - hasOverflowX = overflowX === "scroll" || - ( overflowX === "auto" && within.width < within.element[0].scrollWidth ), - hasOverflowY = overflowY === "scroll" || - ( overflowY === "auto" && within.height < within.element[0].scrollHeight ); - return { - width: hasOverflowY ? $.position.scrollbarWidth() : 0, - height: hasOverflowX ? $.position.scrollbarWidth() : 0 - }; - }, - getWithinInfo: function( element ) { - var withinElement = $( element || window ), - isWindow = $.isWindow( withinElement[0] ), - isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9; - return { - element: withinElement, - isWindow: isWindow, - isDocument: isDocument, - offset: withinElement.offset() || { left: 0, top: 0 }, - scrollLeft: withinElement.scrollLeft(), - scrollTop: withinElement.scrollTop(), - - // support: jQuery 1.6.x - // jQuery 1.6 doesn't support .outerWidth/Height() on documents or windows - width: isWindow || isDocument ? withinElement.width() : withinElement.outerWidth(), - height: isWindow || isDocument ? withinElement.height() : withinElement.outerHeight() - }; - } -}; - -$.fn.position = function( options ) { - if ( !options || !options.of ) { - return _position.apply( this, arguments ); - } - - // make a copy, we don't want to modify arguments - options = $.extend( {}, options ); - - var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, - target = $( options.of ), - within = $.position.getWithinInfo( options.within ), - scrollInfo = $.position.getScrollInfo( within ), - collision = ( options.collision || "flip" ).split( " " ), - offsets = {}; - - dimensions = getDimensions( target ); - if ( target[0].preventDefault ) { - // force left top to allow flipping - options.at = "left top"; - } - targetWidth = dimensions.width; - targetHeight = dimensions.height; - targetOffset = dimensions.offset; - // clone to reuse original targetOffset later - basePosition = $.extend( {}, targetOffset ); - - // force my and at to have valid horizontal and vertical positions - // if a value is missing or invalid, it will be converted to center - $.each( [ "my", "at" ], function() { - var pos = ( options[ this ] || "" ).split( " " ), - horizontalOffset, - verticalOffset; - - if ( pos.length === 1) { - pos = rhorizontal.test( pos[ 0 ] ) ? - pos.concat( [ "center" ] ) : - rvertical.test( pos[ 0 ] ) ? - [ "center" ].concat( pos ) : - [ "center", "center" ]; - } - pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; - pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; - - // calculate offsets - horizontalOffset = roffset.exec( pos[ 0 ] ); - verticalOffset = roffset.exec( pos[ 1 ] ); - offsets[ this ] = [ - horizontalOffset ? horizontalOffset[ 0 ] : 0, - verticalOffset ? verticalOffset[ 0 ] : 0 - ]; - - // reduce to just the positions without the offsets - options[ this ] = [ - rposition.exec( pos[ 0 ] )[ 0 ], - rposition.exec( pos[ 1 ] )[ 0 ] - ]; - }); - - // normalize collision option - if ( collision.length === 1 ) { - collision[ 1 ] = collision[ 0 ]; - } - - if ( options.at[ 0 ] === "right" ) { - basePosition.left += targetWidth; - } else if ( options.at[ 0 ] === "center" ) { - basePosition.left += targetWidth / 2; - } - - if ( options.at[ 1 ] === "bottom" ) { - basePosition.top += targetHeight; - } else if ( options.at[ 1 ] === "center" ) { - basePosition.top += targetHeight / 2; - } - - atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); - basePosition.left += atOffset[ 0 ]; - basePosition.top += atOffset[ 1 ]; - - return this.each(function() { - var collisionPosition, using, - elem = $( this ), - elemWidth = elem.outerWidth(), - elemHeight = elem.outerHeight(), - marginLeft = parseCss( this, "marginLeft" ), - marginTop = parseCss( this, "marginTop" ), - collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width, - collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height, - position = $.extend( {}, basePosition ), - myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); - - if ( options.my[ 0 ] === "right" ) { - position.left -= elemWidth; - } else if ( options.my[ 0 ] === "center" ) { - position.left -= elemWidth / 2; - } - - if ( options.my[ 1 ] === "bottom" ) { - position.top -= elemHeight; - } else if ( options.my[ 1 ] === "center" ) { - position.top -= elemHeight / 2; - } - - position.left += myOffset[ 0 ]; - position.top += myOffset[ 1 ]; - - // if the browser doesn't support fractions, then round for consistent results - if ( !supportsOffsetFractions ) { - position.left = round( position.left ); - position.top = round( position.top ); - } - - collisionPosition = { - marginLeft: marginLeft, - marginTop: marginTop - }; - - $.each( [ "left", "top" ], function( i, dir ) { - if ( $.ui.position[ collision[ i ] ] ) { - $.ui.position[ collision[ i ] ][ dir ]( position, { - targetWidth: targetWidth, - targetHeight: targetHeight, - elemWidth: elemWidth, - elemHeight: elemHeight, - collisionPosition: collisionPosition, - collisionWidth: collisionWidth, - collisionHeight: collisionHeight, - offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], - my: options.my, - at: options.at, - within: within, - elem: elem - }); - } - }); - - if ( options.using ) { - // adds feedback as second argument to using callback, if present - using = function( props ) { - var left = targetOffset.left - position.left, - right = left + targetWidth - elemWidth, - top = targetOffset.top - position.top, - bottom = top + targetHeight - elemHeight, - feedback = { - target: { - element: target, - left: targetOffset.left, - top: targetOffset.top, - width: targetWidth, - height: targetHeight - }, - element: { - element: elem, - left: position.left, - top: position.top, - width: elemWidth, - height: elemHeight - }, - horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", - vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" - }; - if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { - feedback.horizontal = "center"; - } - if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { - feedback.vertical = "middle"; - } - if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { - feedback.important = "horizontal"; - } else { - feedback.important = "vertical"; - } - options.using.call( this, props, feedback ); - }; - } - - elem.offset( $.extend( position, { using: using } ) ); - }); -}; - -$.ui.position = { - fit: { - left: function( position, data ) { - var within = data.within, - withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, - outerWidth = within.width, - collisionPosLeft = position.left - data.collisionPosition.marginLeft, - overLeft = withinOffset - collisionPosLeft, - overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, - newOverRight; - - // element is wider than within - if ( data.collisionWidth > outerWidth ) { - // element is initially over the left side of within - if ( overLeft > 0 && overRight <= 0 ) { - newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset; - position.left += overLeft - newOverRight; - // element is initially over right side of within - } else if ( overRight > 0 && overLeft <= 0 ) { - position.left = withinOffset; - // element is initially over both left and right sides of within - } else { - if ( overLeft > overRight ) { - position.left = withinOffset + outerWidth - data.collisionWidth; - } else { - position.left = withinOffset; - } - } - // too far left -> align with left edge - } else if ( overLeft > 0 ) { - position.left += overLeft; - // too far right -> align with right edge - } else if ( overRight > 0 ) { - position.left -= overRight; - // adjust based on position and margin - } else { - position.left = max( position.left - collisionPosLeft, position.left ); - } - }, - top: function( position, data ) { - var within = data.within, - withinOffset = within.isWindow ? within.scrollTop : within.offset.top, - outerHeight = data.within.height, - collisionPosTop = position.top - data.collisionPosition.marginTop, - overTop = withinOffset - collisionPosTop, - overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, - newOverBottom; - - // element is taller than within - if ( data.collisionHeight > outerHeight ) { - // element is initially over the top of within - if ( overTop > 0 && overBottom <= 0 ) { - newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset; - position.top += overTop - newOverBottom; - // element is initially over bottom of within - } else if ( overBottom > 0 && overTop <= 0 ) { - position.top = withinOffset; - // element is initially over both top and bottom of within - } else { - if ( overTop > overBottom ) { - position.top = withinOffset + outerHeight - data.collisionHeight; - } else { - position.top = withinOffset; - } - } - // too far up -> align with top - } else if ( overTop > 0 ) { - position.top += overTop; - // too far down -> align with bottom edge - } else if ( overBottom > 0 ) { - position.top -= overBottom; - // adjust based on position and margin - } else { - position.top = max( position.top - collisionPosTop, position.top ); - } - } - }, - flip: { - left: function( position, data ) { - var within = data.within, - withinOffset = within.offset.left + within.scrollLeft, - outerWidth = within.width, - offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, - collisionPosLeft = position.left - data.collisionPosition.marginLeft, - overLeft = collisionPosLeft - offsetLeft, - overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, - myOffset = data.my[ 0 ] === "left" ? - -data.elemWidth : - data.my[ 0 ] === "right" ? - data.elemWidth : - 0, - atOffset = data.at[ 0 ] === "left" ? - data.targetWidth : - data.at[ 0 ] === "right" ? - -data.targetWidth : - 0, - offset = -2 * data.offset[ 0 ], - newOverRight, - newOverLeft; - - if ( overLeft < 0 ) { - newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; - if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { - position.left += myOffset + atOffset + offset; - } - } else if ( overRight > 0 ) { - newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; - if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { - position.left += myOffset + atOffset + offset; - } - } - }, - top: function( position, data ) { - var within = data.within, - withinOffset = within.offset.top + within.scrollTop, - outerHeight = within.height, - offsetTop = within.isWindow ? within.scrollTop : within.offset.top, - collisionPosTop = position.top - data.collisionPosition.marginTop, - overTop = collisionPosTop - offsetTop, - overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, - top = data.my[ 1 ] === "top", - myOffset = top ? - -data.elemHeight : - data.my[ 1 ] === "bottom" ? - data.elemHeight : - 0, - atOffset = data.at[ 1 ] === "top" ? - data.targetHeight : - data.at[ 1 ] === "bottom" ? - -data.targetHeight : - 0, - offset = -2 * data.offset[ 1 ], - newOverTop, - newOverBottom; - if ( overTop < 0 ) { - newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; - if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { - position.top += myOffset + atOffset + offset; - } - } else if ( overBottom > 0 ) { - newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; - if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { - position.top += myOffset + atOffset + offset; - } - } - } - }, - flipfit: { - left: function() { - $.ui.position.flip.left.apply( this, arguments ); - $.ui.position.fit.left.apply( this, arguments ); - }, - top: function() { - $.ui.position.flip.top.apply( this, arguments ); - $.ui.position.fit.top.apply( this, arguments ); - } - } -}; - -// fraction support test -(function() { - var testElement, testElementParent, testElementStyle, offsetLeft, i, - body = document.getElementsByTagName( "body" )[ 0 ], - div = document.createElement( "div" ); - - //Create a "fake body" for testing based on method used in jQuery.support - testElement = document.createElement( body ? "div" : "body" ); - testElementStyle = { - visibility: "hidden", - width: 0, - height: 0, - border: 0, - margin: 0, - background: "none" - }; - if ( body ) { - $.extend( testElementStyle, { - position: "absolute", - left: "-1000px", - top: "-1000px" - }); - } - for ( i in testElementStyle ) { - testElement.style[ i ] = testElementStyle[ i ]; - } - testElement.appendChild( div ); - testElementParent = body || document.documentElement; - testElementParent.insertBefore( testElement, testElementParent.firstChild ); - - div.style.cssText = "position: absolute; left: 10.7432222px;"; - - offsetLeft = $( div ).offset().left; - supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11; - - testElement.innerHTML = ""; - testElementParent.removeChild( testElement ); -})(); - -})(); - -var position = $.ui.position; - - -/*! - * jQuery UI Menu 1.11.4 - * http://jqueryui.com - * - * Copyright jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/menu/ - */ - - -var menu = $.widget( "ui.menu", { - version: "1.11.4", - defaultElement: "