
(function(){var componentsFromKeyPath,n,_i,_len,_ref,_ref2;var __bind=function(fn,me){return function(){return fn.apply(me,arguments);};},__hasProp=Object.prototype.hasOwnProperty,__extends=function(child,parent){for(var key in parent){if(__hasProp.call(parent,key))child[key]=parent[key];}function ctor(){this.constructor=child;}ctor.prototype=parent.prototype;child.prototype=new ctor;child.__super__=parent.prototype;return child;},__slice=Array.prototype.slice,__indexOf=Array.prototype.indexOf||function(item){for(var i=0,l=this.length;i<l;i++){if(__hasProp.call(this,i)&&this[i]===item)return i;}return-1;};$.extend({defer:function(callback){return this.timeout(0,callback);},timeout:function(time,callback){return setTimeout(callback,time);},interval:function(time,callback){return setInterval(callback,time);},clearInterval:function(id){return clearInterval(id);},capitalize:function(string){return string.charAt(0).toUpperCase()+string.slice(1);},range:function(v){var s;if(v!=null){if(window.getSelection){s=window.getSelection();s.removeAllRanges();return s.addRange(v);}else if(document.selection){return v.select();}}else{if(window.getSelection){s=window.getSelection();if(s.rangeCount)return s.getRangeAt(0);}else if(document.selection){return document.selection.createRange();}}}});$.fn.extend({outerHTML:function(){return $('<dummy/>').append(this.clone()).html();},execCommand:function(name,value){if(!(this[0]instanceof Document))return;return this[0].execCommand(name,false,value);},commandEnabled:function(name){if(!(this[0]instanceof Document))return;return this[0].queryCommandEnabled(name);},commandState:function(name){if(!(this[0]instanceof Document))return;return this[0].queryCommandState(name);},commandValue:function(name){if(!(this[0]instanceof Document))return;return this[0].queryCommandValue(name);}});_ref=['cut','copy','paste'];for(_i=0,_len=_ref.length;_i<_len;_i++){n=_ref[_i];if((_ref2=$.attrFn)!=null)_ref2[n]=true;$.fn[n]=function(d,f){var _ref3;if(!f)_ref3=[d,null],f=_ref3[0],d=_ref3[1];if(arguments.length>0){return this.bind(n,d,f);}else{return this.trigger(n);}};}
$.browser.chrome=navigator.userAgent.toLowerCase().indexOf('chrome')>-1;String.prototype.dashify=function(){return this.replace(/([a-z])([A-Z])/g,'$1-$2').replace(/([A-Z])([a-z])/g,'-$1$2').replace(/-+/g,'-').replace(/^-|-$/,'').toLowerCase();};String.prototype.underscorize=function(){return this.replace(/([a-z])([A-Z])/g,'$1_$2').replace(/([A-Z])([a-z])/g,'_$1$2').replace(/_+/g,'_').replace(/^_|_$/,'').toLowerCase();};jQuery.cookie=function(key,value,options){if(arguments.length>1&&String(value)!=="[object Object]"){options=jQuery.extend({},options);if(value===null||value===undefined){options.expires=-1;}
if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days);}
value=String(value);return(document.cookie=[encodeURIComponent(key),'=',options.raw?value:encodeURIComponent(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''));}
options=value||{};var result,decode=options.raw?function(s){return s;}:decodeURIComponent;return(result=new RegExp('(?:^|; )'+encodeURIComponent(key)+'=([^;]*)').exec(document.cookie))?decode(result[1]):null;};;(function($,window,undefined){'$:nomunge';var elems=$([]),jq_resize=$.resize=$.extend($.resize,{}),timeout_id,str_setTimeout='setTimeout',str_resize='resize',str_data=str_resize+'-special-event',str_delay='delay',str_throttle='throttleWindow';jq_resize[str_delay]=250;jq_resize[str_throttle]=true;$.event.special[str_resize]={setup:function(){if(!jq_resize[str_throttle]&&this[str_setTimeout]){return false;}
var elem=$(this);elems=elems.add(elem);$.data(this,str_data,{w:elem.width(),h:elem.height()});if(elems.length===1){loopy();}},teardown:function(){if(!jq_resize[str_throttle]&&this[str_setTimeout]){return false;}
var elem=$(this);elems=elems.not(elem);elem.removeData(str_data);if(!elems.length){clearTimeout(timeout_id);}},add:function(handleObj){if(!jq_resize[str_throttle]&&this[str_setTimeout]){return false;}
var old_handler;function new_handler(e,w,h){var elem=$(this),data=$.data(this,str_data);data.w=w!==undefined?w:elem.width();data.h=h!==undefined?h:elem.height();old_handler.apply(this,arguments);};if($.isFunction(handleObj)){old_handler=handleObj;return new_handler;}else{old_handler=handleObj.handler;handleObj.handler=new_handler;}}};function loopy(){timeout_id=window[str_setTimeout](function(){elems.each(function(){var elem=$(this),width=elem.width(),height=elem.height(),data=$.data(this,str_data);if(width!==data.w||height!==data.h){elem.trigger(str_resize,[data.w=width,data.h=height]);}});loopy();},jq_resize[str_delay]);};})(jQuery,this);;(function($){var div=document.createElement("div"),divStyle=div.style,propertyName="transform",suffix="Transform",testProperties=["O"+suffix,"ms"+suffix,"Webkit"+suffix,"Moz"+suffix,propertyName],i=testProperties.length,supportProperty,supportMatrixFilter,propertyHook,rMatrix=/Matrix([^)]*)/;while(i--){if(testProperties[i]in divStyle){$.support[propertyName]=supportProperty=testProperties[i];continue;}}
if(!supportProperty){$.support.matrixFilter=supportMatrixFilter=divStyle.filter==="";}
div=divStyle=null;$.cssNumber[propertyName]=true;$.cssHooks[propertyName]=propertyHook={get:function(elem){var transform=$.data(elem,"transform")||{translate:[0,0],rotate:0,scale:[1,1],skew:[0,0]};transform.toString=function(){return"translate("+this.translate[0]+"px,"+this.translate[1]+"px) rotate("+this.rotate+"rad) scale("+this.scale+") skew("+this.skew[0]+"rad,"+this.skew[1]+"rad)";}
return transform;},set:function(elem,value,animate){if(typeof value==="string"){value=components(value);}
var translate=value.translate,rotate=value.rotate,scale=value.scale,skew=value.skew,elemStyle=elem.style,currentStyle,filter;$.data(elem,"transform",value);if(!skew[0]&&!skew[1]){skew=0;}
if(supportProperty){elemStyle[supportProperty]="translate("+translate[0]+"px,"+translate[1]+"px) rotate("+rotate+"rad) scale("+scale+")"+(skew?" skew("+skew[0]+"rad,"+skew[1]+"rad)":"");}else if(supportMatrixFilter){if(!animate){elemStyle.zoom=1;}
var cos=Math.cos(rotate),sin=Math.sin(rotate),M11=cos*scale[0],M12=-sin*scale[1],M21=sin*scale[0],M22=cos*scale[1],tanX,tanY,Matrix,centerOrigin;if(skew){tanX=Math.tan(skew[0]);tanY=Math.tan(skew[1]);M11+=M12*tanY;M12+=M11*tanX;M21+=M22*tanY;M22+=M21*tanX;}
Matrix=["Matrix("+"M11="+M11,"M12="+M12,"M21="+M21,"M22="+M22,"SizingMethod='auto expand'"].join();filter=(currentStyle=elem.currentStyle)&&currentStyle.filter||elemStyle.filter||"";elemStyle.filter=rMatrix.test(filter)?filter.replace(rMatrix,Matrix):filter+" progid:DXImageTransform.Microsoft."+Matrix+")";if((centerOrigin=$.transform.centerOrigin)){elemStyle[centerOrigin=="margin"?"marginLeft":"left"]=-(elem.offsetWidth/2)+(elem.clientWidth/2)+"px";elemStyle[centerOrigin=="margin"?"marginTop":"top"]=-(elem.offsetHeight/2)+(elem.clientHeight/2)+"px";}
elemStyle.left=translate[0]+"px";elemStyle.top=translate[1]+"px";}}};$.fx.step.transform=function(fx){var elem=fx.elem,start=fx.start,end=fx.end,pos=fx.pos,transform={},coef;if(!start||typeof end==="string"){if(!start){start=propertyHook.get(elem);}
if(supportMatrixFilter){elem.style.zoom=1;}
fx.end=end=components(end);}
transform.translate=[(start.translate[0]+(end.translate[0]-start.translate[0])*pos+.5)|0,(start.translate[1]+(end.translate[1]-start.translate[1])*pos+.5)|0];transform.rotate=start.rotate+(end.rotate-start.rotate)*pos;transform.scale=[start.scale[0]+(end.scale[0]-start.scale[0])*pos,start.scale[1]+(end.scale[1]-start.scale[1])*pos];transform.skew=[start.skew[0]+(end.skew[0]-start.skew[0])*pos,start.skew[1]+(end.skew[1]-start.skew[1])*pos];propertyHook.set(elem,transform,true);};function components(transform){transform=transform.split(")");var translate=[0,0],rotate=0,scale=[1,1],skew=[0,0],i=transform.length-1,trim=$.trim,split,value;while(i--){split=transform[i].split("(");value=split[1];switch(trim(split[0])){case"translateX":translate[0]+=parseInt(value,10);break;case"translateY":translate[1]+=parseInt(value,10);break;case"translate":value=value.split(",");translate[0]+=parseInt(value[0],10);translate[1]+=parseInt(value[1]||0,10);break;case"rotate":rotate+=toRadian(value);break;case"scaleX":scale[0]*=value;case"scaleY":scale[1]*=value;case"scale":value=value.split(",");scale[0]*=value[0];scale[1]*=(value.length>1?value[1]:value[0]);break;case"skewX":skew[0]+=toRadian(value);break;case"skewY":skew[1]+=toRadian(value);break;case"skew":value=value.split(",");skew[0]+=toRadian(value[0]);skew[1]+=toRadian(value[1]||"0");break;}}
return{translate:translate,rotate:rotate,scale:scale,skew:skew};}
function toRadian(value){return~value.indexOf("deg")?parseInt(value,10)*(Math.PI*2/360):~value.indexOf("grad")?parseInt(value,10)*(Math.PI/200):parseFloat(value);}
$.transform={centerOrigin:"margin",radToDeg:function(rad){return rad*180/Math.PI;}};})(jQuery);;var handlebars=(function(){var parser={trace:function trace(){},yy:{},symbols_:{"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"hash":26,"param":27,"STRING":28,"INTEGER":29,"BOOLEAN":30,"hashSegments":31,"hashSegment":32,"ID":33,"EQUALS":34,"pathSegments":35,"SEP":36,"$accept":0,"$end":1},terminals_:{2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",28:"STRING",29:"INTEGER",30:"BOOLEAN",33:"ID",34:"EQUALS",36:"SEP"},productions_:[0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,3],[17,2],[17,2],[17,1],[25,2],[25,1],[27,1],[27,1],[27,1],[27,1],[26,1],[31,2],[31,1],[32,3],[32,3],[32,3],[32,3],[21,1],[35,3],[35,1]],performAction:function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 1:return $$[$0-1]
break;case 2:this.$=new yy.ProgramNode($$[$0-2],$$[$0])
break;case 3:this.$=new yy.ProgramNode($$[$0])
break;case 4:this.$=new yy.ProgramNode([])
break;case 5:this.$=[$$[$0]]
break;case 6:$$[$0-1].push($$[$0]);this.$=$$[$0-1]
break;case 7:this.$=new yy.InverseNode($$[$0-2],$$[$0-1],$$[$0])
break;case 8:this.$=new yy.BlockNode($$[$0-2],$$[$0-1],$$[$0])
break;case 9:this.$=$$[$0]
break;case 10:this.$=$$[$0]
break;case 11:this.$=new yy.ContentNode($$[$0])
break;case 12:this.$=new yy.CommentNode($$[$0])
break;case 13:this.$=new yy.MustacheNode($$[$0-1][0],$$[$0-1][1])
break;case 14:this.$=new yy.MustacheNode($$[$0-1][0],$$[$0-1][1])
break;case 15:this.$=$$[$0-1]
break;case 16:this.$=new yy.MustacheNode($$[$0-1][0],$$[$0-1][1])
break;case 17:this.$=new yy.MustacheNode($$[$0-1][0],$$[$0-1][1],true)
break;case 18:this.$=new yy.PartialNode($$[$0-1])
break;case 19:this.$=new yy.PartialNode($$[$0-2],$$[$0-1])
break;case 20:break;case 21:this.$=[[$$[$0-2]].concat($$[$0-1]),$$[$0]]
break;case 22:this.$=[[$$[$0-1]].concat($$[$0]),null]
break;case 23:this.$=[[$$[$0-1]],$$[$0]]
break;case 24:this.$=[[$$[$0]],null]
break;case 25:$$[$0-1].push($$[$0]);this.$=$$[$0-1];break;case 26:this.$=[$$[$0]]
break;case 27:this.$=$$[$0]
break;case 28:this.$=new yy.StringNode($$[$0])
break;case 29:this.$=new yy.IntegerNode($$[$0])
break;case 30:this.$=new yy.BooleanNode($$[$0])
break;case 31:this.$=new yy.HashNode($$[$0])
break;case 32:$$[$0-1].push($$[$0]);this.$=$$[$0-1]
break;case 33:this.$=[$$[$0]]
break;case 34:this.$=[$$[$0-2],$$[$0]]
break;case 35:this.$=[$$[$0-2],new yy.StringNode($$[$0])]
break;case 36:this.$=[$$[$0-2],new yy.IntegerNode($$[$0])]
break;case 37:this.$=[$$[$0-2],new yy.BooleanNode($$[$0])]
break;case 38:this.$=new yy.IdNode($$[$0])
break;case 39:$$[$0-2].push($$[$0]);this.$=$$[$0-2];break;case 40:this.$=[$$[$0]]
break;}},table:[{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,33:[1,25],35:24},{17:26,21:23,33:[1,25],35:24},{17:27,21:23,33:[1,25],35:24},{17:28,21:23,33:[1,25],35:24},{21:29,33:[1,25],35:24},{1:[2,1]},{6:30,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,31],21:23,33:[1,25],35:24},{10:32,20:[1,33]},{10:34,20:[1,33]},{18:[1,35]},{18:[2,24],21:40,25:36,26:37,27:38,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,38],28:[2,38],29:[2,38],30:[2,38],33:[2,38],36:[1,46]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],36:[2,40]},{18:[1,47]},{18:[1,48]},{18:[1,49]},{18:[1,50],21:51,33:[1,25],35:24},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:52,33:[1,25],35:24},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,22],21:40,26:53,27:54,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,23]},{18:[2,26],28:[2,26],29:[2,26],30:[2,26],33:[2,26]},{18:[2,31],32:55,33:[1,56]},{18:[2,27],28:[2,27],29:[2,27],30:[2,27],33:[2,27]},{18:[2,28],28:[2,28],29:[2,28],30:[2,28],33:[2,28]},{18:[2,29],28:[2,29],29:[2,29],30:[2,29],33:[2,29]},{18:[2,30],28:[2,30],29:[2,30],30:[2,30],33:[2,30]},{18:[2,33],33:[2,33]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],34:[1,57],36:[2,40]},{33:[1,58]},{14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]},{18:[1,59]},{18:[1,60]},{18:[2,21]},{18:[2,25],28:[2,25],29:[2,25],30:[2,25],33:[2,25]},{18:[2,32],33:[2,32]},{34:[1,57]},{21:61,28:[1,62],29:[1,63],30:[1,64],33:[1,25],35:24},{18:[2,39],28:[2,39],29:[2,39],30:[2,39],33:[2,39],36:[2,39]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]},{18:[2,34],33:[2,34]},{18:[2,35],33:[2,35]},{18:[2,36],33:[2,36]},{18:[2,37],33:[2,37]}],defaultActions:{16:[2,1],37:[2,23],53:[2,21]},parseError:function parseError(str,hash){throw new Error(str);},parse:function parse(input){var self=this,stack=[0],vstack=[null],lstack=[],table=this.table,yytext='',yylineno=0,yyleng=0,recovering=0,TERROR=2,EOF=1;this.lexer.setInput(input);this.lexer.yy=this.yy;this.yy.lexer=this.lexer;if(typeof this.lexer.yylloc=='undefined')
this.lexer.yylloc={};var yyloc=this.lexer.yylloc;lstack.push(yyloc);if(typeof this.yy.parseError==='function')
this.parseError=this.yy.parseError;function popStack(n){stack.length=stack.length-2*n;vstack.length=vstack.length-n;lstack.length=lstack.length-n;}
function lex(){var token;token=self.lexer.lex()||1;if(typeof token!=='number'){token=self.symbols_[token]||token;}
return token;};var symbol,preErrorSymbol,state,action,a,r,yyval={},p,len,newState,expected;while(true){state=stack[stack.length-1];if(this.defaultActions[state]){action=this.defaultActions[state];}else{if(symbol==null)
symbol=lex();action=table[state]&&table[state][symbol];}
if(typeof action==='undefined'||!action.length||!action[0]){if(!recovering){expected=[];for(p in table[state])if(this.terminals_[p]&&p>2){expected.push("'"+this.terminals_[p]+"'");}
var errStr='';if(this.lexer.showPosition){errStr='Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+'\nExpecting '+expected.join(', ');}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(recovering==3){if(symbol==EOF){throw new Error(errStr||'Parsing halted.');}
yyleng=this.lexer.yyleng;yytext=this.lexer.yytext;yylineno=this.lexer.yylineno;yyloc=this.lexer.yylloc;symbol=lex();}
while(1){if((TERROR.toString())in table[state]){break;}
if(state==0){throw new Error(errStr||'Parsing halted.');}
popStack(1);state=stack[stack.length-1];}
preErrorSymbol=symbol;symbol=TERROR;state=stack[stack.length-1];action=table[state]&&table[state][TERROR];recovering=3;}
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};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;}};var lexer=(function(){var lexer=({EOF:1,parseError:function parseError(str,hash){if(this.yy.parseError){this.yy.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};return this;},input:function(){var ch=this._input[0];this.yytext+=ch;this.yyleng++;this.match+=ch;this.matched+=ch;var lines=ch.match(/\n/);if(lines)this.yylineno++;this._input=this._input.slice(1);return ch;},unput:function(ch){this._input=ch+this._input;return this;},more:function(){this._more=true;return this;},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,col,lines;if(!this._more){this.yytext='';this.match='';}
var rules=this._currentRules();for(var i=0;i<rules.length;i++){match=this._input.match(this.rules[rules[i]]);if(match){lines=match[0].match(/\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-1:this.yylloc.last_column+match[0].length}
this.yytext+=match[0];this.match+=match[0];this.matches=match;this.yyleng=this.yytext.length;this._more=false;this._input=this._input.slice(match[0].length);this.matched+=match[0];token=this.performAction.call(this,this.yy,this,rules[i],this.conditionStack[this.conditionStack.length-1]);if(token)return token;else return;}}
if(this._input===""){return this.EOF;}else{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;}});lexer.performAction=function anonymous(yy,yy_,$avoiding_name_collisions,YY_START){var YYSTATE=YY_START
switch($avoiding_name_collisions){case 0:this.begin("mu");if(yy_.yytext)return 14;break;case 1:return 14;break;case 2:return 24;break;case 3:return 16;break;case 4:return 20;break;case 5:return 19;break;case 6:return 19;break;case 7:return 23;break;case 8:return 23;break;case 9:yy_.yytext=yy_.yytext.substr(3,yy_.yyleng-5);this.begin("INITIAL");return 15;break;case 10:return 22;break;case 11:return 34;break;case 12:return 33;break;case 13:return 33;break;case 14:return 36;break;case 15:break;case 16:this.begin("INITIAL");return 18;break;case 17:this.begin("INITIAL");return 18;break;case 18:yy_.yytext=yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"');return 28;break;case 19:return 30;break;case 20:return 30;break;case 21:return 29;break;case 22:return 33;break;case 23:return'INVALID';break;case 24:return 5;break;}};lexer.rules=[/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s/.])/,/^./,/^$/];lexer.conditions={"mu":{"rules":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"inclusive":false},"INITIAL":{"rules":[0,1,24],"inclusive":true}};return lexer;})()
parser.lexer=lexer;return parser;})();if(typeof require!=='undefined'&&typeof exports!=='undefined'){exports.parser=handlebars;exports.parse=function(){return handlebars.parse.apply(handlebars,arguments);}
exports.main=function commonjsMain(args){if(!args[1])
throw new Error('Usage: '+args[0]+' FILE');if(typeof process!=='undefined'){var source=require('fs').readFileSync(require('path').join(process.cwd(),args[1]),"utf8");}else{var cwd=require("file").path(require("file").cwd());var source=cwd.join(args[1]).read({charset:"utf-8"});}
return exports.parser.parse(source);}
if(typeof module!=='undefined'&&require.main===module){exports.main(typeof process!=='undefined'?process.argv.slice(1):require("system").args);}};;var Handlebars={};window.Handlebars=Handlebars;Handlebars.VERSION="1.0.beta.2";Handlebars.Parser=handlebars;Handlebars.parse=function(string){Handlebars.Parser.yy=Handlebars.AST;return Handlebars.Parser.parse(string);};Handlebars.print=function(ast){return new Handlebars.PrintVisitor().accept(ast);};Handlebars.helpers={};Handlebars.partials={};Handlebars.registerHelper=function(name,fn,inverse){if(inverse){fn.not=inverse;}
this.helpers[name]=fn;};Handlebars.registerPartial=function(name,str){this.partials[name]=str;};Handlebars.registerHelper('helperMissing',function(arg){if(arguments.length===2){return undefined;}else{throw new Error("Could not find property '"+arg+"'");}});Handlebars.registerHelper('blockHelperMissing',function(context,fn,inverse){inverse=inverse||function(){};var ret="";var type=Object.prototype.toString.call(context);if(type==="[object Function]"){context=context();}
if(context===true){return fn(this);}else if(context===false||context==null){return inverse(this);}else if(type==="[object Array]"){if(context.length>0){for(var i=0,j=context.length;i<j;i++){ret=ret+fn(context[i]);}}else{ret=inverse(this);}
return ret;}else{return fn(context);}},function(context,fn){return fn(context);});Handlebars.registerHelper('each',function(context,fn,inverse){var ret="";if(context&&context.length>0){for(var i=0,j=context.length;i<j;i++){ret=ret+fn(context[i]);}}else{ret=inverse(this);}
return ret;});Handlebars.registerHelper('if',function(context,fn,inverse){if(!context||context==[]){return inverse(this);}else{return fn(this);}});Handlebars.registerHelper('unless',function(context,fn,inverse){return Handlebars.helpers['if'].call(this,context,inverse,fn);});Handlebars.registerHelper('with',function(context,fn){return fn(context);});Handlebars.logger={DEBUG:0,INFO:1,WARN:2,ERROR:3,level:3,log:function(level,str){}};Handlebars.log=function(level,str){Handlebars.logger.log(level,str);};;(function(){Handlebars.AST={};Handlebars.AST.ProgramNode=function(statements,inverse){this.type="program";this.statements=statements;if(inverse){this.inverse=new Handlebars.AST.ProgramNode(inverse);}};Handlebars.AST.MustacheNode=function(params,hash,unescaped){this.type="mustache";this.id=params[0];this.params=params.slice(1);this.hash=hash;this.escaped=!unescaped;};Handlebars.AST.PartialNode=function(id,context){this.type="partial";this.id=id;this.context=context;};var verifyMatch=function(open,close){if(open.original!==close.original){throw new Handlebars.Exception(open.original+" doesn't match "+close.original);}};Handlebars.AST.BlockNode=function(mustache,program,close){verifyMatch(mustache.id,close);this.type="block";this.mustache=mustache;this.program=program;};Handlebars.AST.InverseNode=function(mustache,program,close){verifyMatch(mustache.id,close);this.type="inverse";this.mustache=mustache;this.program=program;};Handlebars.AST.ContentNode=function(string){this.type="content";this.string=string;};Handlebars.AST.HashNode=function(pairs){this.type="hash";this.pairs=pairs;};Handlebars.AST.IdNode=function(parts){this.type="ID";this.original=parts.join(".");var dig=[],depth=0;for(var i=0,l=parts.length;i<l;i++){var part=parts[i];if(part===".."){depth++;}
else if(part==="."||part==="this"){continue;}
else{dig.push(part);}}
this.parts=dig;this.string=dig.join('.');this.depth=depth;this.isSimple=(dig.length===1)&&(depth===0);};Handlebars.AST.StringNode=function(string){this.type="STRING";this.string=string;};Handlebars.AST.IntegerNode=function(integer){this.type="INTEGER";this.integer=integer;};Handlebars.AST.BooleanNode=function(boolean){this.type="BOOLEAN";this.boolean=boolean;};Handlebars.AST.CommentNode=function(comment){this.type="comment";this.comment=comment;};})();;Handlebars.Visitor=function(){};Handlebars.Visitor.prototype={accept:function(object){return this[object.type](object);}};;Handlebars.Exception=function(message){this.message=message;};Handlebars.SafeString=function(string){this.string=string;};Handlebars.SafeString.prototype.toString=function(){return this.string.toString();};(function(){var escape={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","\x60":"&#x60;"};var badChars=/&(?!\w+;)|[<>"'\x60]/g;var possible=/[&<>"'\x60]/;var escapeChar=function(chr){return escape[chr]||"&amp;"};Handlebars.Utils={escapeExpression:function(string){if(string instanceof Handlebars.SafeString){return string.toString();}else if(string==null||string===false){return"";}
if(!possible.test(string)){return string;}
return string.replace(badChars,escapeChar);},isEmpty:function(value){if(typeof value==="undefined"){return true;}else if(value===null){return true;}else if(value===false){return true;}else if(Object.prototype.toString.call(value)==="[object Array]"&&value.length===0){return true;}else{return false;}}};})();;Handlebars.Compiler=function(){};Handlebars.JavaScriptCompiler=function(){};(function(Compiler,JavaScriptCompiler){Compiler.OPCODE_MAP={appendContent:1,getContext:2,lookupWithHelpers:3,lookup:4,append:5,invokeMustache:6,appendEscaped:7,pushString:8,truthyOrFallback:9,functionOrFallback:10,invokeProgram:11,invokePartial:12,push:13,invokeInverse:14,assignToHash:15,pushStringParam:16};Compiler.MULTI_PARAM_OPCODES={appendContent:1,getContext:1,lookupWithHelpers:1,lookup:1,invokeMustache:2,pushString:1,truthyOrFallback:1,functionOrFallback:1,invokeProgram:2,invokePartial:1,push:1,invokeInverse:1,assignToHash:1,pushStringParam:1};Compiler.DISASSEMBLE_MAP={};for(var prop in Compiler.OPCODE_MAP){var value=Compiler.OPCODE_MAP[prop];Compiler.DISASSEMBLE_MAP[value]=prop;}
Compiler.multiParamSize=function(code){return Compiler.MULTI_PARAM_OPCODES[Compiler.DISASSEMBLE_MAP[code]];};Compiler.prototype={compiler:Compiler,disassemble:function(){var opcodes=this.opcodes,opcode,nextCode;var out=[],str,name,value;for(var i=0,l=opcodes.length;i<l;i++){opcode=opcodes[i];if(opcode==='DECLARE'){name=opcodes[++i];value=opcodes[++i];out.push("DECLARE "+name+" = "+value);}else{str=Compiler.DISASSEMBLE_MAP[opcode];var extraParams=Compiler.multiParamSize(opcode);var codes=[];for(var j=0;j<extraParams;j++){nextCode=opcodes[++i];if(typeof nextCode==="string"){nextCode="\""+nextCode.replace("\n","\\n")+"\"";}
codes.push(nextCode);}
str=str+" "+codes.join(" ");out.push(str);}}
return out.join("\n");},guid:0,compile:function(program,options){this.children=[];this.depths={list:[]};this.options=options||{};return this.program(program);},accept:function(node){return this[node.type](node);},program:function(program){var statements=program.statements,statement;this.opcodes=[];for(var i=0,l=statements.length;i<l;i++){statement=statements[i];this[statement.type](statement);}
this.depths.list=this.depths.list.sort(function(a,b){return a-b;});return this;},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;for(var i=0,l=result.depths.list.length;i<l;i++){depth=result.depths.list[i];if(depth<2){continue;}
else{this.addDepth(depth-1);}}
return guid;},block:function(block){var mustache=block.mustache;var depth,child,inverse,inverseGuid;var params=this.setupStackForMustache(mustache);var programGuid=this.compileProgram(block.program);if(block.program.inverse){inverseGuid=this.compileProgram(block.program.inverse);this.declare('inverse',inverseGuid);}
this.opcode('invokeProgram',programGuid,params.length);this.declare('inverse',null);this.opcode('append');},inverse:function(block){this.ID(block.mustache.id);var programGuid=this.compileProgram(block.program);this.opcode('invokeInverse',programGuid);this.opcode('append');},hash:function(hash){var pairs=hash.pairs,pair,val;this.opcode('push','{}');for(var i=0,l=pairs.length;i<l;i++){pair=pairs[i];val=pair[1];this.accept(val);this.opcode('assignToHash',pair[0]);}},partial:function(partial){var id=partial.id;this.usePartial=true;if(partial.context){this.ID(partial.context);}else{this.opcode('push','context');}
this.opcode('invokePartial',id.original);this.opcode('append');},content:function(content){this.opcode('appendContent',content.string);},mustache:function(mustache){var params=this.setupStackForMustache(mustache);this.opcode('invokeMustache',params.length,mustache.id.original);if(mustache.escaped){this.opcode('appendEscaped');}else{this.opcode('append');}},ID:function(id){this.addDepth(id.depth);this.opcode('getContext',id.depth);this.opcode('lookupWithHelpers',id.parts[0]||null);for(var i=1,l=id.parts.length;i<l;i++){this.opcode('lookup',id.parts[i]);}},STRING:function(string){this.opcode('pushString',string.string);},INTEGER:function(integer){this.opcode('push',integer.integer);},BOOLEAN:function(boolean){this.opcode('push',boolean.boolean);},comment:function(){},pushParams:function(params){var i=params.length,param;while(i--){param=params[i];if(this.options.stringParams){if(param.depth){this.addDepth(param.depth);}
this.opcode('getContext',param.depth||0);this.opcode('pushStringParam',param.string);}else{this[param.type](param);}}},opcode:function(name,val1,val2){this.opcodes.push(Compiler.OPCODE_MAP[name]);if(val1!==undefined){this.opcodes.push(val1);}
if(val2!==undefined){this.opcodes.push(val2);}},declare:function(name,value){this.opcodes.push('DECLARE');this.opcodes.push(name);this.opcodes.push(value);},addDepth:function(depth){if(depth===0){return;}
if(!this.depths[depth]){this.depths[depth]=true;this.depths.list.push(depth);}},setupStackForMustache:function(mustache){var params=mustache.params;this.pushParams(params);if(mustache.hash){this.hash(mustache.hash);}else{this.opcode('push','{}');}
this.ID(mustache.id);return params;}};JavaScriptCompiler.prototype={nameLookup:function(parent,name,type){if(JavaScriptCompiler.RESERVED_WORDS[name]||name.indexOf('-')!==-1||!isNaN(name)){return parent+"['"+name+"']";}else if(/^[0-9]+$/.test(name)){return parent+"["+name+"]";}else{return parent+"."+name;}},appendToBuffer:function(string){return"buffer = buffer + "+string+";";},initializeBuffer:function(){return this.quotedString("");},compile:function(environment,options){this.environment=environment;this.options=options||{};this.preamble();this.stackSlot=0;this.stackVars=[];this.registers={list:[]};this.compileChildren(environment,options);Handlebars.log(Handlebars.logger.DEBUG,environment.disassemble()+"\n\n");var opcodes=environment.opcodes,opcode,name,declareName,declareVal;this.i=0;for(l=opcodes.length;this.i<l;this.i++){opcode=this.nextOpcode(0);if(opcode[0]==='DECLARE'){this.i=this.i+2;this[opcode[1]]=opcode[2];}else{this.i=this.i+opcode[1].length;this[opcode[0]].apply(this,opcode[1]);}}
return this.createFunction();},nextOpcode:function(n){var opcodes=this.environment.opcodes,opcode=opcodes[this.i+n],name,val;var extraParams,codes;if(opcode==='DECLARE'){name=opcodes[this.i+1];val=opcodes[this.i+2];return['DECLARE',name,val];}else{name=Compiler.DISASSEMBLE_MAP[opcode];extraParams=Compiler.multiParamSize(opcode);codes=[];for(var j=0;j<extraParams;j++){codes.push(opcodes[this.i+j+1+n]);}
return[name,codes];}},eat:function(opcode){this.i=this.i+opcode.length;},preamble:function(){var out=[];out.push("var buffer = "+this.initializeBuffer()+", currentContext = context");var copies="helpers = helpers || Handlebars.helpers;";if(this.environment.usePartial){copies=copies+" partials = partials || Handlebars.partials;";}
out.push(copies);this.lastContext=0;this.source=out;},createFunction:function(){var container={escapeExpression:Handlebars.Utils.escapeExpression,invokePartial:Handlebars.VM.invokePartial,programs:[],program:function(i,helpers,partials,data){var programWrapper=this.programs[i];if(data){return Handlebars.VM.program(this.children[i],helpers,partials,data);}else if(programWrapper){return programWrapper;}else{programWrapper=this.programs[i]=Handlebars.VM.program(this.children[i],helpers,partials);return programWrapper;}},programWithDepth:Handlebars.VM.programWithDepth,noop:Handlebars.VM.noop};var locals=this.stackVars.concat(this.registers.list);if(locals.length>0){this.source[0]=this.source[0]+", "+locals.join(", ");}
this.source[0]=this.source[0]+";";this.source.push("return buffer;");var params=["Handlebars","context","helpers","partials"];if(this.options.data){params.push("data");}
for(var i=0,l=this.environment.depths.list.length;i<l;i++){params.push("depth"+this.environment.depths.list[i]);}
if(params.length===4&&!this.environment.usePartial){params.pop();}
params.push(this.source.join("\n"));var fn=Function.apply(this,params);fn.displayName="Handlebars.js";Handlebars.log(Handlebars.logger.DEBUG,fn.toString()+"\n\n");container.render=fn;container.children=this.environment.children;return function(context,options,$depth){try{options=options||{};var args=[Handlebars,context,options.helpers,options.partials,options.data];var depth=Array.prototype.slice.call(arguments,2);args=args.concat(depth);return container.render.apply(container,args);}catch(e){throw e;}};},appendContent:function(content){this.source.push(this.appendToBuffer(this.quotedString(content)));},append:function(){var local=this.popStack();this.source.push("if("+local+" || "+local+" === 0) { "+this.appendToBuffer(local)+" }");},appendEscaped:function(){var opcode=this.nextOpcode(1),extra="";if(opcode[0]==='appendContent'){extra=" + "+this.quotedString(opcode[1][0]);this.eat(opcode);}
this.source.push(this.appendToBuffer("this.escapeExpression("+this.popStack()+")"+extra));},getContext:function(depth){if(this.lastContext!==depth){this.lastContext=depth;if(depth===0){this.source.push("currentContext = context;");}else{this.source.push("currentContext = depth"+depth+";");}}},lookupWithHelpers:function(name){if(name){var topStack=this.nextStack();var toPush="if('"+name+"' in helpers) { "+topStack+" = "+this.nameLookup('helpers',name,'helper')+"; } else { "+topStack+" = "+
this.nameLookup('currentContext',name,'context')+"; }";this.source.push(toPush);}else{this.pushStack("currentContext");}},lookup:function(name){var topStack=this.topStack();this.source.push(topStack+" = "+this.nameLookup(topStack,name,'context')+";");},pushStringParam:function(string){this.pushStack("currentContext");this.pushString(string);},pushString:function(string){this.pushStack(this.quotedString(string));},push:function(name){this.pushStack(name);},invokeMustache:function(paramSize,original){this.populateParams(paramSize,this.quotedString(original),"{}",null,function(nextStack,helperMissingString,id){this.source.push("else if("+id+"=== undefined) { "+nextStack+" = helpers.helperMissing.call("+helperMissingString+"); }");this.source.push("else { "+nextStack+" = "+id+"; }");});},invokeProgram:function(guid,paramSize){var inverse=this.programExpression(this.inverse);var mainProgram=this.programExpression(guid);this.populateParams(paramSize,null,mainProgram,inverse,function(nextStack,helperMissingString,id){this.source.push("else { "+nextStack+" = helpers.blockHelperMissing.call("+helperMissingString+"); }");});},populateParams:function(paramSize,helperId,program,inverse,fn){var id=this.popStack(),nextStack;var params=[],param,stringParam;var hash=this.popStack();this.register('tmp1',program);this.source.push('tmp1.hash = '+hash+';');if(this.options.stringParams){this.source.push('tmp1.contexts = [];');}
for(var i=0;i<paramSize;i++){param=this.popStack();params.push(param);if(this.options.stringParams){this.source.push('tmp1.contexts.push('+this.popStack()+');');}}
if(inverse){this.source.push('tmp1.fn = tmp1;');this.source.push('tmp1.inverse = '+inverse+';');}
if(this.options.data){this.source.push('tmp1.data = data;');}
params.push('tmp1');if(inverse){params.push(inverse);}
this.populateCall(params,id,helperId||id,fn);},populateCall:function(params,id,helperId,fn){var paramString=["context"].concat(params).join(", ");var helperMissingString=["context"].concat(helperId).concat(params).join(", ");nextStack=this.nextStack();this.source.push("if(typeof "+id+" === 'function') { "+nextStack+" = "+id+".call("+paramString+"); }");fn.call(this,nextStack,helperMissingString,id);},invokeInverse:function(guid){var program=this.programExpression(guid);var blockMissingParams=["context",this.topStack(),"this.noop",program];this.pushStack("helpers.blockHelperMissing.call("+blockMissingParams.join(", ")+")");},invokePartial:function(context){this.pushStack("this.invokePartial("+this.nameLookup('partials',context,'partial')+", '"+context+"', "+this.popStack()+", helpers, partials);");},assignToHash:function(key){var value=this.popStack();var hash=this.topStack();this.source.push(hash+"['"+key+"'] = "+value+";");},compiler:JavaScriptCompiler,compileChildren:function(environment,options){var children=environment.children,child,compiler;var compiled=[];for(var i=0,l=children.length;i<l;i++){child=children[i];compiler=new this.compiler();compiled[i]=compiler.compile(child,options);}
environment.rawChildren=children;environment.children=compiled;},programExpression:function(guid){if(guid==null){return"this.noop";}
var programParams=[guid,"helpers","partials"];var depths=this.environment.rawChildren[guid].depths.list;if(this.options.data){programParams.push("data");}
for(var i=0,l=depths.length;i<l;i++){depth=depths[i];if(depth===1){programParams.push("context");}
else{programParams.push("depth"+(depth-1));}}
if(!this.environment.usePartial){if(programParams[3]){programParams[2]="null";}else{programParams.pop();}}
if(depths.length===0){return"this.program("+programParams.join(", ")+")";}else{programParams[0]="this.children["+guid+"]";return"this.programWithDepth("+programParams.join(", ")+")";}},register:function(name,val){this.useRegister(name);this.source.push(name+" = "+val+";");},useRegister:function(name){if(!this.registers[name]){this.registers[name]=true;this.registers.list.push(name);}},pushStack:function(item){this.source.push(this.nextStack()+" = "+item+";");return"stack"+this.stackSlot;},nextStack:function(){this.stackSlot++;if(this.stackSlot>this.stackVars.length){this.stackVars.push("stack"+this.stackSlot);}
return"stack"+this.stackSlot;},popStack:function(){return"stack"+this.stackSlot--;},topStack:function(){return"stack"+this.stackSlot;},quotedString:function(str){return'"'+str.replace(/\\/g,'\\\\').replace(/"/g,'\\"').replace(/\n/g,'\\n').replace(/\r/g,'\\r')+'"';}};var reservedWords=("break case catch continue default delete do else finally "+"for function if in instanceof new return switch this throw "+"try typeof var void while with null true false").split(" ");compilerWords=JavaScriptCompiler.RESERVED_WORDS={};for(var i=0,l=reservedWords.length;i<l;i++){compilerWords[reservedWords[i]]=true;}})(Handlebars.Compiler,Handlebars.JavaScriptCompiler);Handlebars.VM={programWithDepth:function(fn,helpers,partials,data,$depth){var args=Array.prototype.slice.call(arguments,4);return function(context,options){options=options||{};options={helpers:options.helpers||helpers,partials:options.partials||partials,data:options.data||data};return fn.apply(this,[context,options].concat(args));};},program:function(fn,helpers,partials,data){return function(context,options){options=options||{};return fn(context,{helpers:options.helpers||helpers,partials:options.partials||partials,data:options.data||data});};},noop:function(){return"";},compile:function(string,options){var ast=Handlebars.parse(string);var environment=new Handlebars.Compiler().compile(ast,options);return new Handlebars.JavaScriptCompiler().compile(environment,options);},invokePartial:function(partial,name,context,helpers,partials){if(partial===undefined){throw new Handlebars.Exception("The partial "+name+" could not be found");}else if(partial instanceof Function){return partial(context,{helpers:helpers,partials:partials});}else{partials[name]=Handlebars.VM.compile(partial);return partials[name](context,{helpers:helpers,partials:partials});}}};Handlebars.compile=Handlebars.VM.compile;;;this.Lipsum={version:[0,1],revision:"3acc64c",willRun:$.browser.webkit,isLoggedIn:false,currentPage:null,currentAdmin:null,currentLocale:"da_DK",templates:{},extensionsByType:{"video/3gpp":".3gp","application/octet-stream":".woff","application/postscript":".ps","audio/x-aiff":".aiff","application/pgp-signature":".sig","video/x-ms-asf":".asx","text/x-asm":".s","application/atom+xml":".atom","audio/basic":".snd","video/x-msvideo":".avi","application/x-msdownload":".msi","image/bmp":".bmp","application/x-bzip2":".bz2","text/x-c":".hh","application/vnd.ms-cab-compressed":".cab","application/vnd.ms-htmlhelp":".chm","text/plain":".txt","application/x-x509-ca-cert":".pem","text/css":".css","text/csv":".csv","application/x-debian-package":".deb","text/x-diff":".diff","image/vnd.djvu":".djvu","application/msword":".dot","application/xml-dtd":".dtd","application/x-dvi":".dvi","application/java-archive":".war","message/rfc822":".mime","text/x-fortran":".for","video/x-flv":".flv","text/x-script.ruby":".ru","image/gif":".gif","application/x-gzip":".gz","text/x-component":".htc","text/html":".html","image/vnd.microsoft.icon":".ico","text/calendar":".ifb","text/x-java-source":".java","application/x-java-jnlp-file":".jnlp","image/jpeg":".jpg","application/javascript":".js","application/json":".json","audio/x-mpegurl":".m3u","video/mp4":".mp4v","text/troff":".tr","text/cache-manifest":".manifest","application/mathml+xml":".mml","application/mbox":".mbox","audio/midi":".midi","video/x-mng":".mng","video/quicktime":".qt","audio/mpeg":".mp3","video/mpeg":".mpg","application/vnd.oasis.opendocument.presentation":".odp","application/vnd.oasis.opendocument.spreadsheet":".ods","application/vnd.oasis.opendocument.text":".odt","application/ogg":".ogg","video/ogg":".ogv","text/x-pascal":".pas","image/x-portable-bitmap":".pbm","application/pdf":".pdf","image/x-portable-graymap":".pgm","application/pgp-encrypted":".pgp","text/x-script.perl":".pl","text/x-script.perl-module":".pm","image/png":".png","image/x-portable-anymap":".pnm","image/x-portable-pixmap":".ppm","application/vnd.ms-powerpoint":".ppt","image/vnd.adobe.photoshop":".psd","text/x-script.python":".py","audio/x-pn-realaudio":".ram","application/x-rar-compressed":".rar","application/rdf+xml":".rdf","application/x-redhat-package-manager":".rpm","application/rss+xml":".rss","application/rtf":".rtf","text/sgml":".sgml","application/x-sh":".sh","image/svg+xml":".svgz","application/x-shockwave-flash":".swf","application/x-tar":".tar","application/x-bzip-compressed-tar":".tbz","application/x-tcl":".tcl","application/x-tex":".tex","application/x-texinfo":".texinfo","image/tiff":".tiff","application/x-bittorrent":".torrent","text/x-vcard":".vcf","text/x-vcalendar":".vcs","model/vrml":".wrl","audio/x-wav":".wav","video/webm":".webm","audio/x-ms-wma":".wma","video/x-ms-wmv":".wmv","video/x-ms-wmx":".wmx","application/wsdl+xml":".wsdl","image/x-xbitmap":".xbm","application/xhtml+xml":".xhtml","application/vnd.ms-excel":".xls","application/xml":".xsl","image/x-xpixmap":".xpm","application/xslt+xml":".xslt","text/yaml":".yml","application/zip":".zip"},browser:{supportsDictation:$.browser.chrome},initialize:function(){if(!this.willRun)return;this.site=new this.Site;this.site.environment="production";this.LoginController.initialize();return this.resumeAdministrationSessionIfNecessary();},hasInitializedAdministration:false,initializeAdministration:function(){var _this=this;if(this.hasInitializedAdministration)return;this.hasInitializedAdministration=true;this.Model.fetchAll(function(){var callback,_j,_len2,_ref3;_this.currentPage=_this.Page.atPath(location.pathname);_ref3=_this.configureCallbacks;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){callback=_ref3[_j];callback.call(_this);}
return $(window).bind('keypress',function(event){if(event.keyCode===96){if(!$(':focus').length){if(!event.shiftKey){if(!event.ctrlKey){if(!event.altKey){if(!event.metaKey)_this.UI.toggleAllInstances();}}}}}
return true;});});return this;},terminateAdministration:function(){this.Manager.terminateAllInstances();this.hasInitializedAdministration=false;return this;},configureCallbacks:[],configure:function(callback){this.configureCallbacks.push(callback);return this;},reloadLocation:function(callback){var _this=this;return this.HTTP.request({path:location.pathname,method:'GET',dataType:'html',errorHandler:function(response){if(typeof console!=="undefined"&&console!==null){if(typeof console.error==="function"){console.error("Error reloading location!");}}
return typeof console!=="undefined"&&console!==null?typeof console.error==="function"?console.error(response):void 0:void 0;},successHandler:function(response){var body,head,postfix,_ref3,_ref4;head=$((_ref3=response.match(/<head.*>([\s\S]*)<\/head>/i))!=null?_ref3[1]:void 0);body=(_ref4=response.match(/<body.*>([\s\S]*)<\/body>/i))!=null?_ref4[1]:void 0;head.filter('meta').each(function(){if(!$("head meta[name='"+($(this).attr('name'))+"']").length){return $('head').append(this);}});head.filter('link').each(function(){if(!$("head link[href='"+($(this).attr('href'))+"']").length){return $('head').append(this);}});postfix=Lipsum.site.environment==='development'?"?"+(Date.now()/1000):'';head.append($("<script type='text/javascript' src='/lipsum/admin.js"+postfix+"'/>"));$('body').html(body);_this.LoginController.initialize();return typeof callback==="function"?callback():void 0;}});},invalidateCache:function(path){var _this=this;this.HTTP.request({path:'/lipsum/cache'+path,method:'DELETE',successHandler:function(){return typeof console!=="undefined"&&console!==null?console.info("Invalidated cache for “"+path+"”."):void 0;}});return this;},resumeAdministrationSessionIfNecessary:function(){var _this=this;if($.cookie('lipsum')){this.Administrator.fetchAll(function(){var complete;complete=function(){var metaElement;if((metaElement=$('html head meta[name="admin"]')).length){return _this.completeAuthenticationWithAdministratorID(Number(metaElement.attr('content')));}};complete();if($('html head meta[name="admin"]').length===0){return _this.reloadLocation(complete);}});}
return this;},completeAuthenticationWithAdministratorID:function(ID){var _this=this;if(!(this.currentAdmin=this.Administrator.get(ID))){throw"Administrator object #"+ID+" not found";}
this.isLoggedIn=true;$.cookie('lipsum',true);if(!$('html head meta[name="admin"]').length){this.reloadLocation(function(){return _this.initializeAdministration();});}else{this.initializeAdministration();}
this.LoginController.lockButton.addClass('unlocked');this.LoginController.nameLabel.text(this.currentAdmin.fullName);return this;},deauthenticateCurrentAdministrator:function(){var _this=this;this.currentAdmin=null;this.isLoggedIn=false;$.cookie('lipsum',null);this.terminateAdministration();this.reloadLocation(function(){return _this.LoginController.initialize();});return this;}};Lipsum.Object=(function(){function Object(){}
Object.toString=function(){return this.name;};Object.prototype.toString=function(){return"$<"+this.constructor.name+">";};Object.prototype.getKeyPath=function(keyPath){var component,components,value;components=componentsFromKeyPath(keyPath);component=components.shift();switch(typeof component){case'string':value=this[component];break;case'number':value=this.getKeyPathIndex(component);}
if(components.length>0){if(value===void 0){if(typeof console!=="undefined"&&console!==null){if(typeof console.error==="function"){console.error("Key path cascading beyond non-object value.");}}
return value;}
return value.getKeyPath(components);}else{return value;}};Object.prototype.setKeyPath=function(keyPath,value){var components,finalProperty,object,_ref3;components=componentsFromKeyPath(keyPath);_ref3=this.resolveKeyPathExcludingFinalProperty(components),object=_ref3[0],finalProperty=_ref3[1];switch(typeof finalProperty){case'string':object[finalProperty]=value;break;case'number':this.setKeyPathIndex(finalProperty,value);}
return value;};Object.prototype.resolveKeyPathExcludingFinalProperty=function(keyPath){var components,object,property;components=componentsFromKeyPath(keyPath);property=components.pop();object=components.length>0?this.getKeyPath(components):this;return[object,property];};return Object;})();componentsFromKeyPath=function(keyPath){var component,x,_j,_len2,_ref3,_results;if(typeof keyPath!=='string'){return(function(){var _j,_len2,_results;_results=[];for(_j=0,_len2=keyPath.length;_j<_len2;_j++){x=keyPath[_j];_results.push(x);}
return _results;})();}
_ref3=keyPath.split(/[\.\[\]]+/i);_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){component=_ref3[_j];if(!(component.length>0))continue;if(component.match(/^\d+$/))component=parseInt(component);_results.push(component);}
return _results;};Lipsum.UI={toggleAllInstances:function(){this.Frame.toggleAllInstances();this.Toolbar.toggleAllInstances();return this;}};Lipsum.UI.Frame=(function(){__extends(Frame,Lipsum.Object);Frame.instances=[];Frame.isHidingAllInstances=false;Frame.toggleAllInstances=function(){var frame,_j,_len2,_ref3;_ref3=this.instances;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){frame=_ref3[_j];if(this.isHidingAllInstances){frame.present();}else{frame.dismiss();}}
return this.isHidingAllInstances=!this.isHidingAllInstances;};Frame.repositionAllInstances=function(){var frame,_j,_len2,_ref3,_results;_ref3=this.instances;_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){frame=_ref3[_j];_results.push(frame.$reposition());}
return _results;};Frame.prototype.isVisible=false;Frame.prototype.isFocused=false;Frame.prototype.isTopOnScreen=false;Frame.prototype.isBottomOnScreen=false;Frame.prototype.isLeftSideOnScreen=false;Frame.prototype.isRightSideOnScreen=false;function Frame(){this.$imageLoadHandler=__bind(this.$imageLoadHandler,this);this.$windowResizeHandler=__bind(this.$windowResizeHandler,this);this.$windowScrollHandler=__bind(this.$windowScrollHandler,this);Frame.instances.push(this);this.rootElement=$('<div class="lipsum-frame"/>');this.contentElement=$('<div class="lipsum-frame-content"/>');this.overlayElement=$('<div class="lipsum-frame-overlay"/>');this.overlayElement.hide();this.canvasElement=$('<canvas class="lipsum-frame-backing"/>');this.canvasContext=this.canvasElement.get(0).getContext('2d');this.borderElement=$('<div class="lipsum-frame-border"/>');this.rootElement.append(this.canvasElement);this.rootElement.append(this.borderElement);this.rootElement.append(this.overlayElement);this.rootElement.append(this.contentElement);}
Frame.prototype.destructor=function(){var _this=this;this.dismiss(function(){return _this.rootElement.remove();});return this;};Frame.prototype.present=function(){var _this=this;if(!this.targetElement)throw"Frame missing targetElement";$(window).bind('resize',this.$windowResizeHandler);$(window).bind('scroll',this.$windowScrollHandler);this.rootElement.hide();this.rootElement.prependTo($('body'));this.rootElement.stop(true,true);this.rootElement.fadeIn(250,function(){return _this.isVisible=true;});this.$reposition();this.$redrawCanvas();return this;};Frame.prototype.dismiss=function(callback){var _this=this;$(window).unbind('resize',this.$windowResizeHandler);$(window).unbind('scroll',this.$windowScrollHandler);this.rootElement.stop(true,true);this.rootElement.fadeOut(350,function(){_this.rootElement.detach();_this.isVisible=false;return typeof callback==="function"?callback(_this):void 0;});return this;};Frame.prototype.focus=function(){if(this.isFocused)return;this.overlayElement.removeClass('success');this.overlayElement.addClass('focus');this.overlayElement.stop(true,true);this.overlayElement.fadeIn(200);this.isFocused=true;return this;};Frame.prototype.unfocus=function(){if(!this.isFocused)return;this.overlayElement.stop(true,true);this.overlayElement.fadeOut(250);this.isFocused=false;return this;};Frame.prototype.indicateSuccess=function(){var _this=this;this.overlayElement.stop(true,true);this.overlayElement.removeClass('focus');this.overlayElement.addClass('success');this.overlayElement.fadeIn(250,'easeOutSine',function(){return $.timeout(500,function(){_this.overlayElement.stop(true,true);return _this.overlayElement.fadeOut(500,'easeInSine');});});return this;};Frame.prototype.recalculateBounds=function(){return this.$reposition();};Frame.prototype.$reposition=function(){this.rootElement.width(this.targetElement.width());this.rootElement.height(this.targetElement.height());return this.rootElement.position({my:'center',at:'center',of:this.targetElement,collision:'none'});};Frame.prototype.$redrawCanvas=function(){var h,r,rootHeight,rootWidth,w,x,y,_ref3,_ref4;return;rootWidth=this.rootElement.width();rootHeight=this.rootElement.height();this.canvasElement.css({left:-15,top:-15,width:rootWidth+15*2,height:rootHeight+15*2});this.canvasElement.attr({width:rootWidth+15*2,height:rootHeight+15*2});this.canvasContext.fillStyle='#222';this.canvasContext.lineWidth=2;this.canvasContext.strokeStyle='#111';this.canvasContext.shadowBlur=3;this.canvasContext.shadowColor='rgba(0,0,0,.1)';this.canvasContext.shadowOffsetY=2;_ref3=[3,6,6,rootWidth+18,rootHeight+18],r=_ref3[0],x=_ref3[1],y=_ref3[2],w=_ref3[3],h=_ref3[4];this.canvasContext.beginPath();this.canvasContext.moveTo(x+r,y);this.canvasContext.lineTo(x+w-r,y);this.canvasContext.quadraticCurveTo(x+w,y,x+w,y+r);this.canvasContext.lineTo(x+w,y+h-r);this.canvasContext.quadraticCurveTo(x+w,y+h,x+w-r,y+h);this.canvasContext.lineTo(x+r,y+h);this.canvasContext.quadraticCurveTo(x,y+h,x,y+h-r);this.canvasContext.lineTo(x,y+r);this.canvasContext.quadraticCurveTo(x,y,x+r,y);this.canvasContext.closePath();this.canvasContext.stroke();this.canvasContext.fill();this.canvasContext.fillStyle='transparent';this.canvasContext.shadowBlur=0;this.canvasContext.shadowOffsetY=0;this.canvasContext.globalCompositeOperation='source-out';_ref4=[1,10,10,rootWidth+10,rootHeight+10],r=_ref4[0],x=_ref4[1],y=_ref4[2],w=_ref4[3],h=_ref4[4];this.canvasContext.beginPath();this.canvasContext.moveTo(x+r,y);this.canvasContext.lineTo(x+w-r,y);this.canvasContext.quadraticCurveTo(x+w,y,x+w,y+r);this.canvasContext.lineTo(x+w,y+h-r);this.canvasContext.quadraticCurveTo(x+w,y+h,x+w-r,y+h);this.canvasContext.lineTo(x+r,y+h);this.canvasContext.quadraticCurveTo(x,y+h,x,y+h-r);this.canvasContext.lineTo(x,y+r);this.canvasContext.quadraticCurveTo(x,y,x+r,y);this.canvasContext.closePath();this.canvasContext.stroke();return this.canvasContext.fill();};Frame.prototype.$windowScrollHandler=function(event){this.topY=this.rootElement.offset().top+5;return this.bottomY=this.rootElement.offset().top+this.rootElement.height()-5;};Frame.prototype.$windowResizeHandler=function(event){this.$reposition();return this.$redrawCanvas();};Frame.prototype.$imageLoadHandler=function(event){return this.$reposition();};return Frame;})();Lipsum.UI.Button=(function(){__extends(Button,Lipsum.Object);function Button(){}
return Button;})();Lipsum.UI.Popover=(function(){__extends(Popover,Lipsum.Object);Popover.ArrowDirection={'up':'up','down':'down','left':'left','right':'right'};Popover.ArrowPlacement={'beginning':'beginning','middle':'middle','end':'end'};Popover.ArrowAttachment={'edge':'edge','center':'center'};Popover.DismissalBehavior={'none':'none','modal':'modal','transient':'transient'};Popover.PositioningMethod={'absolute':'absolute','fixed':'fixed'};Popover.current=null;Popover.prototype.delegate=null;Popover.prototype.isVisible=false;Popover.prototype.isShaking=false;Popover.prototype.isResizing=false;Popover.prototype.isPresenting=false;Popover.prototype.isDismissing=false;function Popover(){this.$resizeHandler=__bind(this.$resizeHandler,this);this.$windowResizeHandler=__bind(this.$windowResizeHandler,this);this.$windowClickHandler=__bind(this.$windowClickHandler,this);this.$windowKeyDownHandler=__bind(this.$windowKeyDownHandler,this);this.arrowDirection=Popover.ArrowDirection.up;this.arrowPlacement=Popover.ArrowPlacement.middle;this.arrowAttachment=Popover.ArrowAttachment.edge;this.dismissalBehavior=Popover.DismissalBehavior.none;this.positioningOffset=[0,0];this.positioningMethod=Popover.PositioningMethod.absolute;this.rootElement=$('<div class="lipsum-popover"/>');this.contentElement=$('<div class="lipsum-popover-content"/>');this.canvasElement=$('<canvas class="lipsum-popover-backing"/>');this.canvasContext=this.canvasElement.get(0).getContext('2d');this.rootElement.append(this.canvasElement);this.rootElement.append(this.contentElement);}
Popover.prototype.present=function(options){var initialStyle,initialXOffset,initialYOffset,left,top,_ref3,_ref4,_ref5;var _this=this;if(options==null)options={};if(this.isPresenting)return false;if(this.isVisible)return false;if(!((_ref3=this.targetElement)!=null?_ref3.length:void 0)){throw"Popover missing targetElement";}
if(Popover.current){Popover.current.dismiss({callback:function(){return _this.present(options);}});return this;}
Popover.current=this;$(window).bind('click',this.$windowClickHandler);$(window).bind('resize',this.$windowResizeHandler);$(window).bind('keydown',this.$windowKeyDownHandler);this.rootElement.prependTo($('body'));this.rootElement.show();_ref4=[parseInt(this.rootElement.css('left')),parseInt(this.rootElement.css('top'))],left=_ref4[0],top=_ref4[1];if(this.arrowDirection===Popover.ArrowDirection.up)initialYOffset=-1;if(this.arrowDirection===Popover.ArrowDirection.down)initialYOffset=+1;if(this.arrowDirection===Popover.ArrowDirection.left)initialXOffset=-1;if(this.arrowDirection===Popover.ArrowDirection.right){initialXOffset=+1;}
initialStyle={opacity:0,left:left,top:top,transform:"scale(0) translate("+(50*initialXOffset)+"px,"+(50*initialYOffset)+"px)"};this.$reposition();this.$redrawCanvas();this.isPresenting=true;this.isDismissing=false;if((_ref5=this.delegate)!=null){if(typeof _ref5.popoverWillPresent==="function"){_ref5.popoverWillPresent(this);}}
this.rootElement.css(initialStyle);this.rootElement.animate({opacity:1,left:left,top:top,transform:"scale(1.1) translate("+(-5*initialXOffset)+"px,"+(-5*initialYOffset)+"px)"},200,'easeOutQuad',function(){return _this.rootElement.animate({transform:'scale(1) translate(0,0)'},150,'easeInQuad',function(){var _ref6,_ref7,_ref8;_this.rootElement.bind('resize',_this.$resizeHandler);if((_ref6=_this.delegate)!=null){if((_ref7=_ref6.popoverDidPresent)!=null)_ref7.call(_this);}
if((_ref8=options.callback)!=null)_ref8.call(_this);_this.isPresenting=false;return _this.isVisible=true;});});return this;};Popover.prototype.dismiss=function(options){var _ref3;var _this=this;if(options==null)options={};if(this.isDismissing)return false;if(!this.isVisible)return false;this.rootElement.unbind('resize',this.$resizeHandler);$(window).unbind('click',this.$windowClickHandler);$(window).unbind('resize',this.$windowResizeHandler);$(window).unbind('keydown',this.$windowKeyDownHandler);Popover.current=null;this.isPresenting=false;this.isDismissing=true;if((_ref3=this.delegate)!=null){if(typeof _ref3.popoverWillDismiss==="function"){_ref3.popoverWillDismiss(this);}}
this.rootElement.fadeOut(250,'easeOutSine',function(){var _ref4,_ref5;_this.rootElement.detach();if((_ref4=_this.delegate)!=null){if(typeof _ref4.popoverDidDismiss==="function"){_ref4.popoverDidDismiss(_this);}}
if((_ref5=options.callback)!=null)_ref5.call(_this);_this.isDismissing=false;return _this.isVisible=false;});return this;};Popover.prototype.shake=function(options){var _this=this;if(options==null)options={};if(this.isShaking)return false;this.isShaking=true;this.rootElement.effect('shake',60,function(){var _ref3;if((_ref3=options.callback)!=null)_ref3.call(_this);return _this.isShaking=false;});return this;};Popover.prototype.recalculateBounds=function(){this.$redrawCanvas();this.$reposition();return this;};Popover.prototype.setContent=function(elements){var c,e,replacingContent;replacingContent=(function(){var _j,_len2;if(!$.isArray(elements)){return elements;}else{c=$();for(_j=0,_len2=elements.length;_j<_len2;_j++){e=elements[_j];c=c.add(e);}
return c;}})();this.contentElement.children().detach();this.contentElement.append(replacingContent);return this;};Popover.prototype.replaceContent=function(elements){var c,currentContent,e,newHeight,newWidth,oldHeight,oldWidth,replacingContent,_ref3,_ref4;var _this=this;if(this.isPresenting||this.isDismissing||this.isShaking)return false;replacingContent=(function(){var _j,_len2;if(!$.isArray(elements)){return elements;}else{c=$();for(_j=0,_len2=elements.length;_j<_len2;_j++){e=elements[_j];c=c.add(e);}
return c;}})();currentContent=this.contentElement.children();console.log(currentContent);console.log(replacingContent);if(replacingContent.is(currentContent))return;this.rootElement.unbind('resize',this.$resizeHandler);_ref3=[this.rootElement.width(),this.rootElement.height()],oldWidth=_ref3[0],oldHeight=_ref3[1];currentContent.detach();replacingContent.appendTo(this.contentElement);_ref4=[this.rootElement.width(),this.rootElement.height()],newWidth=_ref4[0],newHeight=_ref4[1];replacingContent.detach();currentContent.appendTo(this.contentElement);this.rootElement.stop(true);this.contentElement.stop(true);this.contentElement.css({width:this.contentElement.width(),height:this.contentElement.height(),position:'absolute'});this.contentElement.fadeOut(150);$.timeout(100,function(){_this.rootElement.css({width:oldWidth,height:oldHeight});return _this.rootElement.animate({width:newWidth,height:newHeight},{duration:200,step:function(timestamp,effect){_this.rootElement.css({overflow:'visible'});_this.$redrawCanvas();return _this.$reposition();},complete:function(){currentContent.detach();replacingContent.appendTo(_this.contentElement);_this.rootElement.bind('resize',_this.$resizeHandler);_this.rootElement.css({width:'',height:'',overflow:''});_this.contentElement.css({width:'',height:'',position:''});return _this.contentElement.fadeIn(250);}});});return this;};Popover.prototype.$reposition=function(){var arrowDimension,arrowPositions,invertedPositions,offsetX,offsetY,positionSource,positionTarget,_ref3;invertedPositions={top:'bottom',left:'right',right:'left',bottom:'top'};arrowPositions={up:'top',down:'bottom',left:'left',right:'right'};arrowDimension=(function(){switch(this.arrowDirection){case Popover.ArrowDirection.up:case Popover.ArrowDirection.down:return'vertical';case Popover.ArrowDirection.left:case Popover.ArrowDirection.right:return'horizontal';}}).call(this);positionSource=(function(){switch(this.arrowPlacement){case Popover.ArrowPlacement.beginning:switch(arrowDimension){case'vertical':return['left',arrowPositions[this.arrowDirection]].join(' ');case'horizontal':return[arrowPositions[this.arrowDirection],'top'].join(' ');}
break;case Popover.ArrowPlacement.middle:return arrowPositions[this.arrowDirection];case Popover.ArrowPlacement.end:switch(arrowDimension){case'vertical':return['right',arrowPositions[this.arrowDirection]].join(' ');case'horizontal':return[arrowPositions[this.arrowDirection],'bottom'].join(' ');}}}).call(this);positionTarget=(function(){switch(this.arrowAttachment){case Popover.ArrowAttachment.edge:return invertedPositions[arrowPositions[this.arrowDirection]];case Popover.ArrowAttachment.center:return'center';}}).call(this);_ref3=[0,0],offsetX=_ref3[0],offsetY=_ref3[1];switch(this.arrowDirection){case Popover.ArrowDirection.up:offsetY=+18;break;case Popover.ArrowDirection.down:offsetY=-18;break;case Popover.ArrowDirection.left:offsetX=+18;break;case Popover.ArrowDirection.right:offsetX=-18;}
offsetX+=this.positioningOffset[0];offsetY+=this.positioningOffset[1];if(this.positioningMethod===Popover.PositioningMethod.fixed){this.rootElement.css({position:'fixed',left:0,top:0});}
return this.rootElement.position({my:positionSource,at:positionTarget,of:this.targetElement,offset:[offsetX,offsetY].join(' '),collision:'fit'});};Popover.prototype.$redrawCanvas=function(){var arrowSize,canvasHeight,canvasOffsetX,canvasOffsetY,canvasWidth,drawShape,h,padding,r,radius,rootHeight,rootWidth,w,x,y,_ref3;var _this=this;radius=6;padding=15;arrowSize=10;rootWidth=this.rootElement.width();rootHeight=this.rootElement.height();canvasWidth=rootWidth+padding*2;canvasHeight=rootHeight+padding*2;if(this.arrowDirection===Popover.ArrowDirection.left||this.arrowDirection===Popover.ArrowDirection.right){canvasWidth+=arrowSize;}
if(this.arrowDirection===Popover.ArrowDirection.up||this.arrowDirection===Popover.ArrowDirection.down){canvasHeight+=arrowSize;}
canvasOffsetX=0;canvasOffsetY=0;if(this.arrowDirection===Popover.ArrowDirection.left){canvasOffsetX=arrowSize;}
if(this.arrowDirection===Popover.ArrowDirection.up){canvasOffsetY=arrowSize;}
this.canvasElement.css({left:-padding-canvasOffsetX,top:-padding-canvasOffsetY});this.canvasElement.attr({width:canvasWidth,height:canvasHeight});this.canvasContext.restore();_ref3=[radius,padding+canvasOffsetX-this.canvasContext.lineWidth/2,padding+canvasOffsetY-this.canvasContext.lineWidth/2,rootWidth+this.canvasContext.lineWidth,rootHeight+this.canvasContext.lineWidth],r=_ref3[0],x=_ref3[1],y=_ref3[2],w=_ref3[3],h=_ref3[4];drawShape=function(r,x,y,w,h){var arrowOffset;_this.canvasContext.beginPath();_this.canvasContext.moveTo(x+r,y);if(_this.arrowDirection===Popover.ArrowDirection.up){switch(_this.arrowPlacement){case Popover.ArrowPlacement.beginning:arrowOffset=arrowSize*2;break;case Popover.ArrowPlacement.middle:arrowOffset=Math.floor(w/2);break;case Popover.ArrowPlacement.end:arrowOffset=w-arrowSize*2;}
_this.canvasContext.lineTo(x+arrowOffset-arrowSize,y);_this.canvasContext.lineTo(x+arrowOffset,y-arrowSize);_this.canvasContext.lineTo(x+arrowOffset+arrowSize,y);}
_this.canvasContext.lineTo(x+w-r,y);_this.canvasContext.quadraticCurveTo(x+w,y,x+w,y+r);if(_this.arrowDirection===Popover.ArrowDirection.right){_this.canvasContext.lineTo(x+w+.5,y+Math.floor(h/2)-arrowSize);_this.canvasContext.lineTo(x+w+.5+arrowSize,y+Math.floor(h/2));_this.canvasContext.lineTo(x+w+.5,y+Math.floor(h/2)+arrowSize);}
_this.canvasContext.lineTo(x+w,y+h-r);_this.canvasContext.quadraticCurveTo(x+w,y+h,x+w-r,y+h);if(_this.arrowDirection===Popover.ArrowDirection.down){switch(_this.arrowPlacement){case Popover.ArrowPlacement.beginning:arrowOffset=arrowSize*2;break;case Popover.ArrowPlacement.middle:arrowOffset=Math.floor(w/2);break;case Popover.ArrowPlacement.end:arrowOffset=w-arrowSize*2;}
_this.canvasContext.lineTo(x+arrowOffset+.5+arrowSize,y+h);_this.canvasContext.lineTo(x+arrowOffset+.5,y+h+arrowSize);_this.canvasContext.lineTo(x+arrowOffset+.5-arrowSize,y+h);}
_this.canvasContext.lineTo(x+r,y+h);_this.canvasContext.quadraticCurveTo(x,y+h,x,y+h-r);if(_this.arrowDirection===Popover.ArrowDirection.left){_this.canvasContext.lineTo(x-.5,y+Math.floor(h/2)+arrowSize);_this.canvasContext.lineTo(x-.5-arrowSize,y+Math.floor(h/2));_this.canvasContext.lineTo(x-.5,y+Math.floor(h/2)-arrowSize);}
_this.canvasContext.lineTo(x,y+r);_this.canvasContext.quadraticCurveTo(x,y,x+r,y);return _this.canvasContext.closePath();};this.canvasContext.fillStyle='rgba(238,238,238,.9)';this.canvasContext.lineCap='round';this.canvasContext.lineWidth=1;this.canvasContext.strokeStyle='#F8F8F8';this.canvasContext.shadowBlur=8;this.canvasContext.shadowColor='rgba(85,85,85,.33)';this.canvasContext.shadowOffsetY=4;drawShape(r,x,y,w,h);this.canvasContext.fill();this.canvasContext.stroke();this.canvasContext.strokeStyle='rgba(0,0,0,.33)';drawShape(r,x-1,y-1,w+2,h+2);return this.canvasContext.stroke();};Popover.prototype.$windowKeyDownHandler=function(event){var _this=this;switch(event.keyCode){case 13:if(this.contentElement.find(':focus').length){if(this.defaultButton&&!this.defaultButton.attr('disabled')){this.defaultButton.addClass('active');return $.timeout(100,function(){_this.defaultButton.removeClass('active');return _this.defaultButton.click();});}}
break;case 27:return this.dismiss();}};Popover.prototype.$windowClickHandler=function(event){switch(this.dismissalBehavior){case Popover.DismissalBehavior.modal:return event.preventDefault();case Popover.DismissalBehavior.transient:if(!this.rootElement.find(event.target).length)return this.dismiss();}};Popover.prototype.$windowResizeHandler=function(event){return this.$reposition();};Popover.prototype.$resizeHandler=function(event){this.$reposition();return this.$redrawCanvas();};return Popover;})();Lipsum.UI.PopupButton=(function(){__extends(PopupButton,Lipsum.Object);function PopupButton(){}
return PopupButton;})();Lipsum.UI.ToolbarItem=(function(){__extends(ToolbarItem,Lipsum.Object);function ToolbarItem(options){this.options=options!=null?options:{};this.$windowKeyDownHandler=__bind(this.$windowKeyDownHandler,this);this.$windowKeyUpHandler=__bind(this.$windowKeyUpHandler,this);this.name=this.options.name;this.alternate=this.options.alternate;this.toolbar=null;this.rootElement=$('<li class="lipsum-toolbar-item"/>');if(this.alternate){$(window).bind('keyup',this.$windowKeyUpHandler);$(window).bind('keydown',this.$windowKeyDownHandler);}}
ToolbarItem.prototype.$windowKeyUpHandler=function(event){if(event.keyCode===18){this.rootElement.insertBefore(this.alternate.rootElement);return this.alternate.rootElement.detach();}};ToolbarItem.prototype.$windowKeyDownHandler=function(event){if(event.keyCode===18){this.alternate.rootElement.insertBefore(this.rootElement);return this.rootElement.detach();}};return ToolbarItem;})();Lipsum.UI.ToolbarButton=(function(){__extends(ToolbarButton,Lipsum.UI.ToolbarItem);function ToolbarButton(options){this.options=options!=null?options:{};ToolbarButton.__super__.constructor.apply(this,arguments);this.buttonElement=$('<button class="lipsum-toolbar-button"/>');this.buttonElement.attr({tabIndex:-1});this.buttonElement.appendTo(this.rootElement);if(this.name){this.buttonElement.addClass("lipsum-toolbar-button-named-"+(this.name.dashify()));}
if(this.options.disabled===true){this.buttonElement.attr({disabled:true});}
if((this.titleText=this.options.title)||true){this.titleElement=$('<span/>');this.titleElement.text(this.titleText);this.titleElement.appendTo(this.buttonElement);}
if(this.imageURL=this.options.image){this.imageElement=$('<img/>');this.imageElement.attr({src:this.imageURL});this.imageElement.appendTo(this.titleElement||this.buttonElement);}
if(this.clickHandler=this.options.action){this.buttonElement.bind('click',this.clickHandler);}}
ToolbarButton.prototype.simulateClick=function(){var _this=this;this.buttonElement.addClass('active');$.timeout(150,function(){return _this.buttonElement.removeClass('active');});if(typeof this.clickHandler==="function")this.clickHandler();return this;};return ToolbarButton;})();Lipsum.UI.Toolbar=(function(){__extends(Toolbar,Lipsum.Object);Toolbar.Alignment={'left':'left','right':'right'};Toolbar.Attachment={'anchored':'anchored','floating':'floating'};Toolbar.Disposition={'inside':'inside','outside':'outside'};Toolbar.instances=[];Toolbar.isHidingAllInstances=false;Toolbar.toggleAllInstances=function(){var toolbar,_j,_len2,_ref3;_ref3=this.instances;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){toolbar=_ref3[_j];if(toolbar.attachment===this.Attachment.floating){if(this.isHidingAllInstances){toolbar.present();}else{toolbar.dismiss();}}}
return this.isHidingAllInstances=!this.isHidingAllInstances;};Toolbar.prototype.isVisible=false;Toolbar.prototype.isAnimating=false;function Toolbar(){this.$windowResizeHandler=__bind(this.$windowResizeHandler,this);this.$windowScrollHandler=__bind(this.$windowScrollHandler,this);Toolbar.instances.push(this);this.items=[];this.frame=null;this.alignment=Toolbar.Alignment.left;this.attachment=Toolbar.Attachment.anchored;this.disposition=Toolbar.Disposition.outside;this.rootElement=$('<div class="lipsum-toolbar"/>');this.contentElements=[];this;}
Toolbar.prototype.present=function(options){var _ref3,_ref4;var _this=this;if(options==null)options={};if(this.isVisible)return false;if(this.isAnimating)return false;if(!(this.frame||this.managedItem)){throw"Toolbar missing frame or managedItem";}
this.isAnimating=true;$(window).bind('resize',this.$windowResizeHandler);$(window).bind('scroll',this.$windowScrollHandler);this.rootElement.removeClass('lipsum-toolbar-left-aligned');this.rootElement.removeClass('lipsum-toolbar-right-aligned');this.rootElement.addClass("lipsum-toolbar-"+this.alignment+"-aligned");this.rootElement.stop(true,true);this.rootElement.hide();this.rootElement.prependTo(((_ref3=this.frame)!=null?_ref3.contentElement:void 0)||((_ref4=this.managedItem)!=null?_ref4.rootElement:void 0));this.$inDOM=true;this.rootElement.show();this.$reposition();this.rootElement.hide();this.rootElement.fadeIn((options.animation===false?0:150),function(){_this.isAnimating=false;return _this.isVisible=true;});return this;};Toolbar.prototype.dismiss=function(options){var _this=this;if(options==null)options={};if(!this.isVisible)return false;if(this.isAnimating)return false;this.isAnimating=true;$(window).bind('resize',this.$windowResizeHandler);$(window).bind('scroll',this.$windowScrollHandler);this.rootElement.fadeOut((options.animation===false?0:250),function(){_this.rootElement.detach();_this.isAnimating=false;_this.isVisible=false;return _this.$inDOM=false;});return this;};Toolbar.prototype.itemNamed=function(name){var item,_j,_len2,_ref3;_ref3=this.items;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){item=_ref3[_j];if(item.name===name)return item;}};Toolbar.prototype.addItem=function(){var args,item;item=arguments[0],args=2<=arguments.length?__slice.call(arguments,1):[];this.addItems.apply(this,[[item]].concat(__slice.call(args)));return this;};Toolbar.prototype.addItems=function(items,insertionPoint){var container,item,_j,_len2;if(insertionPoint==null)insertionPoint='last';container=$('<ul class="lipsum-toolbar-content"/>');for(_j=0,_len2=items.length;_j<_len2;_j++){item=items[_j];if(!(item!=null))continue;this.items.push(item);item.toolbar=this;item.rootElement.appendTo(container);}
if(insertionPoint==='last'){container.appendTo(this.rootElement);this.contentElements.push(container);}else if(insertionPoint==='first'){container.prependTo(this.rootElement);this.contentElements.unshift(container);}else{throw"Invalid insertion point “"+insertionPoint+"” when adding toolbar item";}
this.$reposition();return this;};Toolbar.prototype.removeItem=function(item){var index;item.toolbar=null;item.rootElement.parent().detach();if((index=this.items.indexOf(item))!==-1)this.items.splice(index,1);this.$reposition();return this;};Toolbar.prototype.lockOpacity=function(){this.rootElement.css({opacity:1});return this;};Toolbar.prototype.unlockOpacity=function(){this.rootElement.css({opacity:''});return this;};Toolbar.prototype.$reposition=function(){var absoluteX,attachToFrameIfNeccesary,attachToWindowIfNeccesary,relativeX,scrollY,verticalSourcePosition,verticalTargetPosition;var _this=this;if(!this.$inDOM)return;switch(this.attachment){case Toolbar.Attachment.anchored:verticalTargetPosition='top';verticalSourcePosition=(function(){switch(this.disposition){case Toolbar.Disposition.inside:return'top';case Toolbar.Disposition.outside:return'bottom';}}).call(this);attachToFrameIfNeccesary=function(position){var _ref3,_ref4;if(!_this.$isAttachedToWindow)return;_this.rootElement.removeClass('lipsum-toolbar-top-attached');_this.rootElement.removeClass('lipsum-toolbar-bottom-attached');_this.rootElement.removeClass('lipsum-toolbar-window-attached');_this.rootElement.addClass("lipsum-toolbar-"+position+"-attached");_this.rootElement.prependTo(((_ref3=_this.frame)!=null?_ref3.contentElement:void 0)||((_ref4=_this.managedItem)!=null?_ref4.rootElement:void 0));_this.rootElement.css({position:''});return _this.$isAttachedToWindow=false;};attachToWindowIfNeccesary=function(){if(_this.$isAttachedToWindow)return;_this.rootElement.removeClass('lipsum-toolbar-top-attached');_this.rootElement.removeClass('lipsum-toolbar-bottom-attached');_this.rootElement.addClass('lipsum-toolbar-window-attached');_this.rootElement.prependTo($('body'));_this.rootElement.css({position:'fixed'});return _this.$isAttachedToWindow=true;};relativeX=(function(){switch(this.alignment){case Toolbar.Alignment.left:return-6;case Toolbar.Alignment.right:return this.frame.contentElement.width()-this.rootElement.width()+6;}}).call(this);absoluteX=relativeX+this.frame.contentElement.offset().left;scrollY=document.body.scrollTop;if(scrollY<this.frame.topY-10){attachToFrameIfNeccesary('top');this.rootElement.css({left:relativeX,top:-this.rootElement.height()-6});}else if(scrollY>this.frame.bottomY+14){attachToFrameIfNeccesary('bottom');this.rootElement.css({left:relativeX,top:this.frame.rootElement.height()+8});}else{attachToWindowIfNeccesary();this.rootElement.css({left:absoluteX,top:-2});}
break;case Toolbar.Attachment.floating:this.rootElement.css({position:'absolute'});this.rootElement.addClass('lipsum-toolbar-floating');this.rootElement.position({my:""+this.alignment+" top",at:""+this.alignment+" top",of:this.targetElement,collision:'none'});}
return this;};Toolbar.prototype.$windowScrollHandler=function(event){return this.$reposition();};Toolbar.prototype.$windowResizeHandler=function(event){return this.$reposition();};return Toolbar;})();Lipsum.HTTP={pendingRequests:[],request:function(options){this.pendingRequests.push(options);return this.dequeueRequestIfNecessary();},upload:function(options){return this.request($.extend({},options,{isUpload:true}));},hasPendingRequests:function(){return this.pendingRequests.length>0;},dequeueRequestIfNecessary:function(){var DOMRequest,isSuccessStatus,jQueryRequestOptions,key,loadListener,options,progressListener,value,_ref3,_ref4;var _this=this;if(this.hasPendingRequests()){options=this.pendingRequests.shift();if(options.isUpload){DOMRequest=new XMLHttpRequest;isSuccessStatus=function(code){return code>=200&&code<300||code===304;};loadListener=function(event){if(isSuccessStatus(DOMRequest.status)){if(typeof options.successHandler==="function"){options.successHandler();}}else{if(typeof options.errorHandler==="function"){options.errorHandler();}}
return typeof options.completeHandler==="function"?options.completeHandler():void 0;};progressListener=function(event){if(event.lengthComputable){return typeof options.progressHandler==="function"?options.progressHandler(event.loaded/event.total):void 0;}};DOMRequest.addEventListener('load',loadListener);DOMRequest.addEventListener('loadend',function(event){return typeof options.completeHandler==="function"?options.completeHandler():void 0;});DOMRequest.addEventListener('loadstart',function(event){return typeof options.beginHandler==="function"?options.beginHandler():void 0;});DOMRequest.addEventListener('error',function(event){return typeof options.errorHandler==="function"?options.errorHandler():void 0;});DOMRequest.addEventListener('abort',function(event){return typeof options.cancelHandler==="function"?options.cancelHandler():void 0;});DOMRequest.addEventListener('timeout',function(event){return typeof options.timeoutHandler==="function"?options.timeoutHandler():void 0;});DOMRequest.upload.addEventListener('progress',progressListener);DOMRequest.open(options.method,options.path);if((_ref3=options.headers)==null)options.headers={};if(options.data instanceof Blob){options.headers['Content-Type']=options.data.type;}
_ref4=options.headers;for(key in _ref4){value=_ref4[key];DOMRequest.setRequestHeader(key,value);}
return DOMRequest.send(options.data);}else{jQueryRequestOptions={url:options.path,type:options.method,data:options.data,dataType:options.dataType||'json',complete:options.completeHandler,progress:options.progressHandler,headers:{'X-Lipsum':"v"+(Lipsum.version.join('.'))},error:function(){if(typeof options.errorHandler==="function"){options.errorHandler.apply(options,arguments);}
return _this.$presentErrorPrompt();},success:function(){if(typeof options.successHandler==="function"){options.successHandler.apply(options,arguments);}
return _this.dequeueRequestIfNecessary();}};return $.ajax(jQueryRequestOptions);}}},$presentErrorPrompt:function(){return;if(confirm("A connection error occurred.\n\nDo you wish to continue?")){return this.dequeueRequestIfNecessary();}}};Lipsum.Model=(function(){__extends(Model,Lipsum.Object);Model.descendants=[];Model.configure=function(configuration){var property,relationship,_j,_k,_len2,_len3,_ref3,_ref4,_results;if(!Lipsum.willRun)return;Model.descendants.push(this);this.schema=[];this.instances=[];this.relationships=[];configuration.apply(this,[]);_ref3=this.schema;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){property=_ref3[_j];this.defineAccessorsForProperty(property);}
_ref4=this.relationships;_results=[];for(_k=0,_len3=_ref4.length;_k<_len3;_k++){relationship=_ref4[_k];_results.push(this.defineAccessorsForRelationship(relationship));}
return _results;};Model.property=function(name,type,options){if(options==null)options={};return this.schema.push({name:name,type:type,options:options});};Model.hasMany=function(target,options){var relationship;relationship=this.Relationship.pendingFor({source:this.name,target:options.model});relationship.type='many';relationship.source=this;relationship.targetProperty=target;this.relationships.push(relationship);return relationship.finalize();};Model.belongsTo=function(source,options){var relationship;relationship=this.Relationship.pendingFor({target:this.name,source:options.model});relationship.type='many';relationship.target=this;relationship.sourceProperty=source;this.property(""+relationship.sourceProperty+"_id",Number);this.relationships.push(relationship);return relationship.finalize();};Model.remix=function(name,options){var Dummy,className,remixable,remixed,remixer;if(options==null)options={};className=""+this.name+options.model;remixer=this;remixable=this.Remixable.instances[options.model];if(remixable==null)throw"Remixable “"+name+"” not loaded";remixed=this[options.model]=eval("(function() {\n  function "+className+"() { "+className+".__super__.constructor.apply(this, arguments); };\n  return "+className+";\n})()");Dummy=(function(){__extends(Dummy,Object);function Dummy(){Dummy.__super__.constructor.apply(this,arguments);}
return Dummy;})();__extends(remixed,Lipsum.Model);;remixed.configure(function(){remixable.configuration.apply(this,[]);return this.belongsTo(remixer.name.toLowerCase(),{model:remixer.name});});return this.hasMany(name,{model:remixed.name});};Model.after=function(){};Model.get=function(id){var instance,_j,_len2,_ref3;_ref3=this.all();for(_j=0,_len2=_ref3.length;_j<_len2;_j++){instance=_ref3[_j];if(instance.getAttribute('id')===id)return instance;}
return null;};Model.all=function(query){var instance,_j,_len2,_ref3,_results;_ref3=this.instances;_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){instance=_ref3[_j];if((instance instanceof this)&&instance.matchesQuery(query)){_results.push(instance);}}
return _results;};Model.first=function(query){var instance,_j,_len2,_ref3;_ref3=this.instances;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){instance=_ref3[_j];if(instance.matchesQuery(query))return instance;}
return null;};Model.externalPath=function(){return"/lipsum/model/"+this.name;};Model.fetchAll=function(callback){var descendantsFetched,descendantsToFetch,model,_fn,_j,_len2,_ref3;var _this=this;if(this===Model){descendantsToFetch=this.descendants.length;descendantsFetched=0;_ref3=this.descendants;_fn=function(){var fetchingModel;fetchingModel=model;return fetchingModel.fetchAll(function(){++descendantsFetched;if(descendantsFetched===descendantsToFetch){return typeof callback==="function"?callback():void 0;}});};for(_j=0,_len2=_ref3.length;_j<_len2;_j++){model=_ref3[_j];_fn();}
return;}
if(this.isAbstract)return;if(this.all().length>0){if(typeof callback==="function")callback();return;}
return Lipsum.HTTP.request({path:this.externalPath(),method:'GET',successHandler:function(response){var object,_k,_len3;for(_k=0,_len3=response.length;_k<_len3;_k++){object=response[_k];new _this(object);}
return typeof callback==="function"?callback():void 0;}});};Model.defineAccessorsForProperty=function(property){var name;name=property.name;this.prototype.__defineGetter__(name,function(){return this.getAttribute(name);});if(!property.options.readOnly){return this.prototype.__defineSetter__(name,function(value){return this.setAttribute(name,value);});}};Model.defineAccessorsForRelationship=function(relationship){var name;name=(function(){if(relationship.target===this){return relationship.sourceProperty;}else if(relationship.source){return relationship.targetProperty;}else{throw"ERROR!";}}).call(this);this.prototype.__defineGetter__(name,function(){return this.getAttribute(name);});return this.prototype.__defineSetter__(name,function(value){return this.setAttribute(name,value);});};function Model(attributes){this.model=this.constructor;this.$data={};this.$errors=[];this.model.instances.push(this);if(this.constructor===Model)throw"Model is an abstract superclass";if(attributes!=null)this.update(attributes);this.$isDirty=false;}
Model.prototype.update=function(attributes){var name,value,_results;_results=[];for(name in attributes){value=attributes[name];_results.push(this.setAttribute(name,value));}
return _results;};Model.prototype.getAttribute=function(name){var dataName,relation,_j,_len2,_ref3;dataName=name.underscorize();if(this.$data[dataName]!==void 0)return this.$data[dataName];_ref3=this.constructor.relationships;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){relation=_ref3[_j];if(relation.read(this,dataName))return relation.read(this,dataName);}
return;};Model.prototype.setAttribute=function(name,value){var dataName;dataName=name.underscorize();this.$isDirty=true;this.$data[dataName]=value;return value;};Model.prototype.isNew=function(){return!(this.$data.id!=null);};Model.prototype.isDirty=function(recursion){var relation,target,targets,_j,_k,_len2,_len3,_ref3;if(recursion==null)recursion=false;if(this.$isDirty||this.isNew()){return true;}else{if(recursion===true){_ref3=this.constructor.relationships;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){relation=_ref3[_j];if(!(relation.source===this.constructor))continue;targets=this.getAttribute(relation.targetProperty).all();for(_k=0,_len3=targets.length;_k<_len3;_k++){target=targets[_k];if(target.isDirty())return true;}}}
return false;}};Model.prototype.matchesQuery=function(query){var property,value;for(property in query){value=query[property];if(this.getAttribute(property)!==value)return false;}
return true;};Model.prototype.externalPath=function(){if(this.isNew()){return this.constructor.externalPath();}else{return this.constructor.externalPath()+("/"+this.$data['id']);}};Model.prototype.save=function(callback,recursion){var _this=this;if(recursion==null)recursion=false;this.$commit(function(){var relation,target,targets,_j,_len2,_ref3,_results;if(typeof callback==="function")callback();if(recursion&&_this.isDirty(true)){_ref3=_this.constructor.relationships;_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){relation=_ref3[_j];if(!(relation.source===_this.constructor))continue;targets=_this.getAttribute(relation.targetProperty).all();_results.push((function(){var _k,_len3,_results2;_results2=[];for(_k=0,_len3=targets.length;_k<_len3;_k++){target=targets[_k];if(target.isDirty()){_results2.push(target.save());}else{_results2.push(void 0);}}
return _results2;})());}
return _results;}});return this;};Model.prototype.objectRepresentation=function(){var object,property,value,_j,_len2,_ref3;object=new Object;_ref3=this.constructor.schema;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){property=_ref3[_j];if(!(property.options.readOnly!==true))continue;value=this.getAttribute(property.name);if(value instanceof Lipsum.Model){value=value.getAttribute('id');if(value==null){if(typeof console!=="undefined"&&console!==null){if(typeof console.error==="function"){console.error("No ID found, no foreign key in object representation of "+this.constructor.name);}}}}
object[property.name.underscorize()]=value;}
return object;};Model.prototype.JSONRepresentation=function(){return JSON.stringify(this.objectRepresentation());};Model.prototype.$commit=function(callback){if(this.$data.id!=null){return this.$commitChanges(callback);}else{return this.$commitCreation(callback);}};Model.prototype.$commitCreation=function(callback){var _this=this;return Lipsum.HTTP.request({path:this.externalPath(),data:this.JSONRepresentation(),method:'POST',contentType:'application/json',successHandler:function(response){_this.$isDirty=false;if(response.attributes.id==null){throw"No identifier received from server when saving";}
_this.setAttribute('id',response.attributes.id);return typeof callback==="function"?callback():void 0;}});};Model.prototype.$commitChanges=function(callback){var _this=this;return Lipsum.HTTP.request({path:this.externalPath(),data:this.JSONRepresentation(),method:'PUT',contentType:'application/json',successHandler:function(response){_this.$isDirty=false;return typeof callback==="function"?callback():void 0;}});};Model.prototype.$commitDestruction=function(callback){var _this=this;return Lipsum.HTTP.request({path:this.externalPath(),method:'DELETE',contentType:null,successHandler:function(response){return typeof callback==="function"?callback():void 0;}});};return Model;})();Lipsum.Model.Collection=(function(){__extends(Collection,Lipsum.Object);function Collection(options){var key,value;if(options==null)options={};for(key in options){value=options[key];this[key]=value;}}
Collection.prototype.all=function(){var rec,_j,_len2,_ref3,_results;_ref3=this.model.all();_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){rec=_ref3[_j];if(this.associated(rec))_results.push(rec);}
return _results;};Collection.prototype.first=function(){return this.all()[0];};Collection.prototype.last=function(){var values;values=this.all();return values[values.length-1];};Collection.prototype.getKeyPathIndex=function(index){return this.all()[index];};Collection.prototype.setKeyPathIndex=function(index){throw"Not implemented yet";};Collection.prototype.associated=function(record){var value;value=record.getAttribute(this.fkey);return value===this.record.getAttribute('id')||value===this.record;};return Collection;})();Lipsum.Model.Remixable=(function(){__extends(Remixable,Lipsum.Object);Remixable.instances={};function Remixable(name,configuration){this.configuration=configuration;Remixable.instances[name]=this;}
return Remixable;})();Lipsum.Model.Relationship=(function(){var _this=this;__extends(Relationship,Lipsum.Object);Relationship.pending=[];Relationship.pendingFor=function(options){var relation,_j,_len2,_ref3,_ref4,_ref5;_ref3=Relationship.pending;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){relation=_ref3[_j];if(relation.expectedSourceName===options.source&&((_ref4=relation.target)!=null?_ref4.name:void 0)===options.target){return relation;}
if(relation.expectedTargetName===options.target&&((_ref5=relation.source)!=null?_ref5.name:void 0)===options.source){return relation;}}
relation=new Relationship({expectedSourceName:options.source,expectedTargetName:options.target});Relationship.pending.push(relation);return relation;};function Relationship(options){var key,value;if(options==null)options={};for(key in options){value=options[key];this[key]=value;}}
Relationship.prototype.finalize=function(){return this.$dequeue();};Relationship.prototype.$dequeue=function(){var r;if((this.source!=null)&&(this.target!=null)){return this.constructor.pending=(function(){var _j,_len2,_ref3,_results;_ref3=this.constructor.pending;_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){r=_ref3[_j];if(r!==this)_results.push(r);}
return _results;}).call(this);}};Relationship.prototype.read=function(instance,property){var foreignKey;if(property===this.sourceProperty&&instance.model===this.target){foreignKey=""+property+"_id";if(instance[foreignKey]!=null){return this.source.get(instance[foreignKey]);}}else if(property===this.targetProperty&&instance.model===this.source){return new Lipsum.Model.Collection({name:property,model:this.target,record:instance,fkey:""+this.sourceProperty+"_id"});}else{return;}};return Relationship;}).call(this);Lipsum.Administrator=(function(){__extends(Administrator,Lipsum.Model);function Administrator(){Administrator.__super__.constructor.apply(this,arguments);}
Administrator.configure(function(){this.property('id',Number);this.property('username',String,{unique:true});return this.property('fullName',String);});return Administrator;})();Lipsum.Content=new Lipsum.Model.Remixable('Content',function(){this.property('id',Number);this.property('name',String);return this.property('string',String);});Lipsum.Fragment=(function(){__extends(Fragment,Lipsum.Model);function Fragment(){Fragment.__super__.constructor.apply(this,arguments);}
Fragment.configure(function(){this.property('name',String);return this.remix('content',{model:'Content'});});Fragment.prototype.value=function(){var _ref3;return(_ref3=this.content.all()[0])!=null?_ref3.string:void 0;};return Fragment;})();Lipsum.Page=(function(){__extends(Page,Lipsum.Model);function Page(){Page.__super__.constructor.apply(this,arguments);}
Page.configure(function(){this.property('id',Number);this.property('name',String);this.property('path',String);this.property('fullPath',String,{readOnly:true});this.property('title',String);this.property('keywords',String);this.property('description',String);return this.remix('content',{model:'Content'});});Page.named=function(name){return this.first({name:name});};Page.atPath=function(path){return this.first({fullPath:path});};Page.prototype.contentNamed=function(name){var c,_j,_len2,_ref3;_ref3=this.content.all();for(_j=0,_len2=_ref3.length;_j<_len2;_j++){c=_ref3[_j];if(c.name===name)return c;}
return null;};Page.prototype.mainContent=function(){return this.contentNamed('main');};Page.prototype.invalidateCache=function(){Lipsum.invalidateCache(this.fullPath);return this;};Page.prototype.pathWithLocalizedComponents=function(){var component,components,fragment;components=1<=arguments.length?__slice.call(arguments,0):[];components=(function(){var _j,_len2,_results;_results=[];for(_j=0,_len2=components.length;_j<_len2;_j++){component=components[_j];switch(typeof component){case'string':_results.push(component);break;case'object':fragment=Lipsum.Fragment.first(component);_results.push(fragment.value());break;default:throw"Invalid component type "+(typeof component)+" when generating localized path";}}
return _results;})();return[Lipsum.currentPage.fullPath].concat(components).join('/');};return Page;})();Lipsum.Widget=(function(){__extends(Widget,Lipsum.Model);function Widget(){Widget.__super__.constructor.apply(this,arguments);}
Widget.configure(function(){});return Widget;})();Lipsum.Site=(function(){__extends(Site,Lipsum.Object);function Site(){Site.__super__.constructor.apply(this,arguments);}
Site.prototype.$addManager=function(managerClass,element,options){var key,manager,value;if(element.length!==1)return;manager=new managerClass(element);for(key in options){value=options[key];manager[key]=value;}
manager.finalize();return manager;};Site.prototype.addCollectionManager=function(selector,options){return this.$addManager(Lipsum.CollectionManager,$(selector),options);};Site.prototype.addEditorManager=function(selector,options){return this.$addManager(Lipsum.EditorManager,$(selector),options);};return Site;})();Lipsum.Editor=(function(){__extends(Editor,Lipsum.Object);Editor.subclasses={};Editor.named=function(name){return this.subclasses[name];};Editor.register=function(){var name,names,_j,_len2,_results;names=1<=arguments.length?__slice.call(arguments,0):[];_results=[];for(_j=0,_len2=names.length;_j<_len2;_j++){name=names[_j];_results.push(this.subclasses[name]=this);}
return _results;};function Editor(manager,element,object,propertyName,options){this.manager=manager;this.element=element;this.object=object;this.propertyName=propertyName;this.options=options!=null?options:{};if(this.constructor===Editor)throw"Editor is an abstract superclass";}
Editor.prototype.beginEditing=function(){this.manager.editorDidBeginEditing(this);return this;};Editor.prototype.ceaseEditing=function(){this.manager.editorDidCeaseEditing(this);return this;};Editor.prototype.storeCurrentValue=function(){var _ref3;if((_ref3=this.object)!=null){_ref3.setKeyPath(this.propertyName,this.currentValue());}
return this;};Editor.prototype.hasChanges=function(){return this.storedValue()!==this.currentValue();};Editor.prototype.storedValue=function(){var _ref3;return(_ref3=this.object)!=null?_ref3.getKeyPath(this.propertyName):void 0;};Editor.prototype.currentValue=function(){throw"currentValue called on abstract Editor";};return Editor;})();Lipsum.ImageEditor=(function(){__extends(ImageEditor,Lipsum.Editor);ImageEditor.register('image');function ImageEditor(){this.$fileInputChangeHandler=__bind(this.$fileInputChangeHandler,this);this.$clickHandler=__bind(this.$clickHandler,this);ImageEditor.__super__.constructor.apply(this,arguments);this.lastUpload=void 0;this.$initializeElement();this.$initializePopover();}
ImageEditor.prototype.beginEditing=function(){this.chooseButton.attr({disabled:this.object.isNew()});this.popover.present();return ImageEditor.__super__.beginEditing.apply(this,arguments);};ImageEditor.prototype.ceaseEditing=function(){this.popover.dismiss();return ImageEditor.__super__.ceaseEditing.apply(this,arguments);};ImageEditor.prototype.currentValue=function(){return this.element.attr('src');};ImageEditor.prototype.hasChanges=function(){return!!this.hasUnsavedChanges;};ImageEditor.prototype.storeCurrentValue=function(){return this.hasUnsavedChanges=false;};ImageEditor.prototype.presentFilePicker=function(){this.fileInput.click();return this;};ImageEditor.prototype.$initializeElement=function(){this.element.css({cursor:'crosshair'});return this.element.bind('click',this.$clickHandler);};ImageEditor.prototype.$initializePopover=function(){var _this=this;this.fileInput=$('<input type="file"/>');this.fileInput.css({visibility:'hidden',position:'absolute'});this.fileInput.attr({tabIndex:-1});this.fileInput.bind('change',this.$fileInputChangeHandler);this.chooseButton=$('<button/>');this.chooseButton.text("Replace…");this.chooseButton.click(function(){return _this.presentFilePicker();});this.progressBar=$('<progress/>');this.progressBarValue=$('<span class="lipsum-progress-value"/>');this.progressBarValue.appendTo(this.progressBar);this.popover=new Lipsum.UI.Popover;this.popover.delegate={popoverWillDismiss:function(){return _this.ceaseEditing();}};this.popover.targetElement=this.element;this.popover.arrowDirection=Lipsum.UI.Popover.ArrowDirection.down;this.popover.dismissalBehavior=Lipsum.UI.Popover.DismissalBehavior.transient;this.popover.contentElement.addClass('lipsum-image-popover');this.popover.contentElement.append(this.chooseButton);return this.popover.rootElement.append(this.fileInput);};ImageEditor.prototype.$reloadElement=function(){return this.element.attr({src:this.element.attr('src')+'?'+Date.now()/1000});};ImageEditor.prototype.$uploadFile=function(file){var finalObject,finalProperty,progressMode,_ref3;var _this=this;this.popover.dismissalBehavior=Lipsum.UI.Popover.DismissalBehavior.modal;_ref3=this.object.resolveKeyPathExcludingFinalProperty(this.propertyName),finalObject=_ref3[0],finalProperty=_ref3[1];progressMode=false;return Lipsum.HTTP.upload({data:file,path:""+(finalObject.externalPath())+"/"+finalProperty,method:'POST',errorHandler:function(){if(typeof console!=="undefined"&&console!==null){console.error("Error uploading file!");}
return _this.popover.shake({callback:function(){_this.popover.replaceContent(_this.chooseButton);return _this.popover.dismissalBehavior=Lipsum.UI.Popover.DismissalBehavior.transient;}});},successHandler:function(){_this.$reloadElement();_this.popover.dismiss();_this.hasUnsavedChanges=true;_this.needsCacheInvalidation=true;_this.lastUpload={type:file.type};return _this.manager.editorDidChange(_this);},completeHandler:function(){_this.popover.replaceContent(_this.chooseButton);return _this.popover.dismissalBehavior=Lipsum.UI.Popover.DismissalBehavior.transient;},progressHandler:function(progress){_this.progressBarValue.css({width:""+(Math.ceil(progress*100))+"%"});if(progressMode===false){progressMode=true;return _this.popover.replaceContent(_this.progressBar);}}});};ImageEditor.prototype.$clickHandler=function(){return this.beginEditing();};ImageEditor.prototype.$fileInputChangeHandler=function(){var file;var _this=this;if(file=this.fileInput[0].files[0]){return $.timeout(100,function(){_this.$uploadFile(file);return _this.fileInput.val('');});}else{return this.popover.dismiss();}};return ImageEditor;})();Lipsum.LinkEditor=(function(){__extends(LinkEditor,Lipsum.Editor);LinkEditor.register('link');function LinkEditor(){this.$saveButtonHandler=__bind(this.$saveButtonHandler,this);this.$editButtonHandler=__bind(this.$editButtonHandler,this);LinkEditor.__super__.constructor.apply(this,arguments);this.$initializePopover();}
LinkEditor.prototype.beginEditing=function(){this.$updatePopoverElements();this.popover.present();return LinkEditor.__super__.beginEditing.apply(this,arguments);};LinkEditor.prototype.ceaseEditing=function(){this.popover.dismiss();return LinkEditor.__super__.ceaseEditing.apply(this,arguments);};LinkEditor.prototype.currentValue=function(){return this.element.attr('href');};LinkEditor.prototype.currentValueKind=function(){if(/^page:/.test(this.currentValue())){return'page';}else if(/^mailto:/.test(this.currentValue())){return'mail';}else{return'web';}};LinkEditor.prototype.currentHumanReadableValue=function(){var pageName,_ref3,_ref4,_ref5;switch(this.currentValueKind()){case'page':pageName=(_ref3=this.currentValue())!=null?_ref3.replace(/^page:/,''):void 0;return((_ref4=Lipsum.Page.named(pageName))!=null?_ref4.title:void 0)||pageName;case'mail':return(_ref5=this.currentValue())!=null?_ref5.replace(/^mailto:/,''):void 0;default:return this.currentValue();}};LinkEditor.prototype.$initializePopover=function(){var _this=this;this.$defaultElements=[this.$valueLabelElement=$('<strong/>').text("…"),this.$openButtonElement=$('<button/>').text("Open").click(function(){return open(_this.currentValue());}),this.$editButtonElement=$('<button/>').text("Edit").click(this.$editButtonHandler)];this.$editingElements=[this.$valueTextFieldElement=$('<input type="text"/>').val("…"),this.$saveButtonElement=$('<button/>').text("Save").click(this.$saveButtonHandler)];this.popover=new Lipsum.UI.Popover;this.popover.targetElement=this.element;this.popover.arrowDirection=Lipsum.UI.Popover.ArrowDirection.down;this.popover.dismissalBehavior=Lipsum.UI.Popover.DismissalBehavior.modal;this.popover.contentElement.addClass('lipsum-link-popover');return this.popover.setContent(this.$defaultElements);};LinkEditor.prototype.$updatePopoverElements=function(){this.$valueLabelElement.text(this.currentHumanReadableValue());this.$valueTextFieldElement.val(this.currentValue());this.$valueLabelElement.removeClass('page mail web');return this.$valueLabelElement.addClass(this.currentValueKind());};LinkEditor.prototype.$editButtonHandler=function(event){this.popover.replaceContent(this.$editingElements);return this.popover.defaultButton=this.$saveButtonElement;};LinkEditor.prototype.$saveButtonHandler=function(event){this.element.attr({href:this.$valueTextFieldElement.val()});this.$updatePopoverElements();this.popover.replaceContent(this.$defaultElements);return this.popover.defaultButton=null;};return LinkEditor;})();Lipsum.TextEditor=(function(){__extends(TextEditor,Lipsum.Editor);TextEditor.register('text');TextEditor.FeatureGroup={'style':'style','link':'link','lists':'lists','media':'media'};TextEditor.FeatureSets={"default":['style','link']};function TextEditor(){this.$keyPressHandler=__bind(this.$keyPressHandler,this);this.$changeHandler=__bind(this.$changeHandler,this);this.$mouseDownHandler=__bind(this.$mouseDownHandler,this);this.$mouseUpHandler=__bind(this.$mouseUpHandler,this);this.$blurHandler=__bind(this.$blurHandler,this);this.$focusHandler=__bind(this.$focusHandler,this);var _base,_ref3;TextEditor.__super__.constructor.apply(this,arguments);if((_ref3=(_base=this.options).features)==null){_base.features=TextEditor.FeatureSets["default"];}
this.$initializeToolbar();this.$initializeElement();}
TextEditor.prototype.beginEditing=function(){var _this=this;TextEditor.__super__.beginEditing.apply(this,arguments);this.toolbar.present({animation:this!==this.manager.activeEditor});$.defer(function(){if(!_this.element.is(':focus'))return _this.element.focus();});return this;};TextEditor.prototype.ceaseEditing=function(){TextEditor.__super__.ceaseEditing.apply(this,arguments);this.clearSelection();this.toolbar.dismiss();return this;};TextEditor.prototype.currentValue=function(){var _ref3;return(_ref3=this.element.html())!=null?_ref3.trim():void 0;};TextEditor.prototype.storedValue=function(){var value;value=TextEditor.__super__.storedValue.apply(this,arguments);return value&&(""+value).trim();};TextEditor.prototype.saveSelection=function(){this.savedSelection=$.range();return this;};TextEditor.prototype.restoreSelection=function(){$.range(this.savedSelection);return this;};TextEditor.prototype.clearSelection=function(){$.range(document.createRange());this.savedSelection=null;return this;};TextEditor.prototype.findElementInSelection=function(selector){var element,result;result=null;element=this.$selectionStartContainerParentElement();element.parentsUntil(this.element).andSelf().each(function(){if($(this).is(selector))return result=$(this);});return result;};TextEditor.prototype.executeDOMCommand=function(command,argument){if(argument==null)argument=null;$(document).execCommand(command,argument);this.$changeHandler();return this;};TextEditor.prototype.makeSelectionBold=function(){this.executeDOMCommand('bold');return this;};TextEditor.prototype.makeSelectionItalic=function(){this.executeDOMCommand('italic');return this;};TextEditor.prototype.makeSelectionLink=function(){return this;};TextEditor.prototype.insertBulletedList=function(){this.executeDOMCommand('insertUnorderedList');return this;};TextEditor.prototype.insertNumberedList=function(){this.executeDOMCommand('insertOrderedList');return this;};TextEditor.prototype.$initializeToolbar=function(){var _this=this;this.toolbar=new Lipsum.UI.Toolbar;this.toolbar.frame=this.manager.frame;this.toolbar.rootElement.mousedown(function(){_this.$isUsingToolbar=true;return _this.saveSelection();});this.toolbar.rootElement.mouseup(function(){_this.$isUsingToolbar=false;if(!$(':focus').length)return _this.restoreSelection();});this.toolbar.addItems([new Lipsum.UI.ToolbarButton({name:'bold',action:function(){return _this.makeSelectionBold();}}),new Lipsum.UI.ToolbarButton({name:'italic',action:function(){return _this.makeSelectionItalic();}})]);this.toolbar.addItems([new Lipsum.UI.ToolbarButton({name:'link',disabled:true,action:function(){return _this.makeSelectionLink();}})]);return this.toolbar.addItems([new Lipsum.UI.ToolbarButton({name:'bulletedList',action:function(){return _this.insertBulletedList();}}),new Lipsum.UI.ToolbarButton({name:'numberedList',action:function(){return _this.insertNumberedList();}})]);};TextEditor.prototype.$initializeElement=function(){this.element.css({outline:'none'});this.element.attr({contentEditable:true});this.element.bind('focus',this.$focusHandler);this.element.bind('blur',this.$blurHandler);this.element.bind('keyup',this.$changeHandler);this.element.bind('keydown',this.$changeHandler);this.element.bind('keypress',this.$keyPressHandler);this.element.bind('mouseup',this.$mouseUpHandler);return this.element.bind('mousedown',this.$mouseDownHandler);};TextEditor.prototype.$updateSelectionSpecificSubeditors=function(){var element,_ref3,_ref4,_ref5;return;if(element=this.findElementInSelection('a')){if(((_ref3=this.$currentSubeditor)!=null?_ref3.element[0]:void 0)!==element[0]){console.log("Not the same element; spawning a new editor …");if((_ref4=this.$currentSubeditor)!=null)_ref4.ceaseEditing();this.$currentSubeditor=new Lipsum.LinkEditor(this.manager,element,null,null);this.$currentSubeditor.parentEditor=this;return this.$currentSubeditor.beginEditing();}else{return console.log("The same element!");}}else{console.log("No selection specific subeditable elements found.");if((_ref5=this.$currentSubeditor)!=null)_ref5.ceaseEditing();return this.$currentSubeditor=null;}};TextEditor.prototype.$selectionStartContainerParentElement=function(){var _ref3;return $((_ref3=$.range())!=null?_ref3.startContainer.parentElement:void 0);};TextEditor.prototype.$focusHandler=function(event){if(!this.$isUsingToolbar)this.beginEditing();return this.$updateSelectionSpecificSubeditors();};TextEditor.prototype.$blurHandler=function(event){if(!this.$isUsingToolbar)this.ceaseEditing();return this.$updateSelectionSpecificSubeditors();};TextEditor.prototype.$mouseUpHandler=function(event){return this.$updateSelectionSpecificSubeditors();};TextEditor.prototype.$mouseDownHandler=function(event){return this.$updateSelectionSpecificSubeditors();};TextEditor.prototype.$changeHandler=function(event){this.$updateSelectionSpecificSubeditors();return this.manager.editorDidChange(this);};TextEditor.prototype.$keyPressHandler=function(event){var toolbarButton;this.$changeHandler(event);toolbarButton=(function(){if(event.metaKey===true&&event.shiftKey===false&&event.altKey===false&&event.ctrlKey===false){switch(event.keyCode){case 98:return this.toolbar.itemNamed('bold');case 105:return this.toolbar.itemNamed('italic');}}}).call(this);if(toolbarButton){toolbarButton.simulateClick();return event.preventDefault();}};return TextEditor;})();Lipsum.ManagedItem=(function(){__extends(ManagedItem,Lipsum.Object);function ManagedItem(){this.object=null;this.element=null;this.manager=null;this.toolbar=null;this.editors=[];this.rootElement=$('<div class="lipsum-managed-item"/>');this.contentElement=$('<div class="lipsum-managed-item-content"/>');this.contentElement.appendTo(this.rootElement);}
ManagedItem.prototype.initializeToolbar=function(){var _this=this;this.toolbar=new Lipsum.UI.Toolbar;this.toolbar.alignment=Lipsum.UI.Toolbar.Alignment.left;this.toolbar.attachment=Lipsum.UI.Toolbar.Attachment.floating;this.toolbar.managedItem=this;this.toolbar.targetElement=this.element;this.toolbar.addItems([this.settingsEditor!=null?new Lipsum.UI.ToolbarButton({name:'settings',title:"Settings",action:function(){return _this.manager.presentSettingsForItem(_this);}}):void 0,new Lipsum.UI.ToolbarButton({name:'delete',title:"Delete",action:function(){return _this.manager.removeItem(_this);}})]);return this;};ManagedItem.prototype.hasChanges=function(){var editor,_j,_len2,_ref3;_ref3=this.editors;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){editor=_ref3[_j];if(editor.hasChanges())return true;}
return false;};return ManagedItem;})();Lipsum.Manager=(function(){__extends(Manager,Lipsum.Object);Manager.instances=[];Manager.terminateAllInstances=function(){var manager,_j,_len2,_ref3;_ref3=this.instances;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){manager=_ref3[_j];manager.destructor();}
return this.instances=[];};function Manager(targetElement){var _ref3;var _this=this;this.targetElement=targetElement;if(this.constructor===Manager)throw"Manager is an abstract superclass";if(!((_ref3=this.targetElement)!=null?_ref3.length:void 0)){throw"Manager missing targetElement";}
Manager.instances.push(this);this.frame=new Lipsum.UI.Frame;this.frame.targetElement=this.targetElement;this.mainToolbar=new Lipsum.UI.Toolbar;this.mainToolbar.frame=this.frame;this.mainToolbar.alignment='right';this.localeButton=new Lipsum.UI.ToolbarButton({name:'localize',title:"Localize"});this.synchronizeButton=new Lipsum.UI.ToolbarButton({name:'synchronize',title:"Synchronize",action:function(){return _this.synchronizeChanges();}});}
Manager.prototype.destructor=function(){this.frame.dismiss();return this.mainToolbar.dismiss();};Manager.prototype.finalize=function(){this.frame.present();this.mainToolbar.present();return $(window).trigger('scroll');};Manager.prototype.synchronizeChanges=function(){return this;};Manager.prototype.popoverWillPresent=function(popover){if(!(this.activeEditor||this.activePopover))this.frame.focus();return this.activePopover=popover;};Manager.prototype.popoverWillDismiss=function(popover){if(this.activePopover===popover)this.activePopover=null;if(!(this.activeEditor||this.activePopover))return this.frame.unfocus();};Manager.prototype.editorDidBeginEditing=function(editor){var _ref3;if((this.activeEditor!=null)&&this.activeEditor!==editor){if((_ref3=this.activeEditor.toolbar)!=null){_ref3.dismiss({animation:false});}}
if(!(this.activeEditor||this.activePopover))this.frame.focus();return this.activeEditor=editor;};Manager.prototype.editorDidCeaseEditing=function(editor){var _this=this;if(this.activeEditor===editor)this.activeEditor=null;return $.defer(function(){if(!(_this.activeEditor||_this.activePopover)){return _this.frame.unfocus();}});};Manager.prototype.editorDidChange=function(editor){$.defer(function(){return Lipsum.UI.Frame.repositionAllInstances();});if(editor.hasChanges()){return this.$presentSynchronizeButton();}else{return this.$dismissSynchronizeButton();}};Manager.prototype.$presentSynchronizeButton=function(){var _ref3;if(_ref3=this.synchronizeButton,__indexOf.call(this.mainToolbar.items,_ref3)<0){return this.mainToolbar.addItem(this.synchronizeButton,'first');}};Manager.prototype.$dismissSynchronizeButton=function(){var _ref3;if(_ref3=this.synchronizeButton,__indexOf.call(this.mainToolbar.items,_ref3)>=0){return this.mainToolbar.removeItem(this.synchronizeButton);}};Manager.prototype.$enableSynchronizeButton=function(){return this.synchronizeButton.buttonElement.attr({disabled:false});};Manager.prototype.$disableSynchronizeButton=function(){return this.synchronizeButton.buttonElement.attr({disabled:true});};return Manager;})();Lipsum.CollectionManager=(function(){__extends(CollectionManager,Lipsum.Manager);function CollectionManager(targetElement){this.targetElement=targetElement;CollectionManager.__super__.constructor.apply(this,arguments);this.managedItems=[];this.managedModel=null;this.dependentPages=[];this.dependentPaths=[];this.$changeQueue=[];this.$deletionQueue=[];}
CollectionManager.prototype.finalize=function(){var _this=this;this.mainToolbar.addItem(new Lipsum.UI.ToolbarButton({name:'add',title:"Add",disabled:!(this.$template()!=null),action:function(){return _this.insertNewItem();}}));this.initializePreexistingChildElements();return CollectionManager.__super__.finalize.apply(this,arguments);};CollectionManager.prototype.insertNewItem=function(){var item;item=this.$createManagedItem();this.managedItems.push(item);this.targetElement.prepend(item.element);item.element.fadeIn();this.$presentSynchronizeButton();this.frame.recalculateBounds();return this;};CollectionManager.prototype.removeItem=function(item){var popover;var _this=this;popover=this.popoverForToolbarItem(item.toolbar.itemNamed('delete'));popover.contentElement.append($('<button/>').text("Remove").click(function(){popover.dismiss();return _this.$removeItem(item);}));popover.present();return this;};CollectionManager.prototype.presentSettingsForItem=function(item){var _ref3;if((_ref3=item.settingsEditor)!=null)_ref3.present();return this;};CollectionManager.prototype.synchronizeChanges=function(){var callback,currentUpdate,item,latestUpdate,_j,_len2,_ref3;var _this=this;this.$disableSynchronizeButton();this.$dismissSynchronizeButton();this.$changeQueue=[];_ref3=this.managedItems;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){item=_ref3[_j];if(item.hasChanges())this.$changeQueue.push(item);}
currentUpdate=0;latestUpdate=this.$changeQueue.length+this.$deletionQueue.length;callback=function(){if((currentUpdate+=1)===latestUpdate){_this.frame.indicateSuccess();_this.$enableSynchronizeButton();return _this.$invalidateCache();}};while(this.$changeQueue.length!==0){item=this.$changeQueue.shift();this.synchronizeChangesForItem(item,callback);}
while(this.$deletionQueue.length!==0){item=this.$deletionQueue.shift();item.object.$commitDestruction(callback);}
return this;};CollectionManager.prototype.synchronizeChangesForItem=function(item,callback){var editor,_j,_len2,_ref3;var _this=this;_ref3=item.editors;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){editor=_ref3[_j];if(typeof console!=="undefined"&&console!==null){console.log("Storing "+editor+" …");}
editor.storeCurrentValue();}
item.object.save((function(){return typeof callback==="function"?callback():void 0;}),true);return this;};CollectionManager.prototype.popoverForToolbarItem=function(toolbarItem){var popover;var _this=this;popover=new Lipsum.UI.Popover;popover.delegate={popoverWillPresent:function(popover){toolbarItem.toolbar.lockOpacity();return _this.popoverWillPresent(popover);},popoverWillDismiss:function(popover){toolbarItem.toolbar.unlockOpacity();return _this.popoverWillDismiss(popover);}};popover.targetElement=toolbarItem.rootElement;popover.arrowDirection=Lipsum.UI.Popover.ArrowDirection.up;popover.dismissalBehavior=Lipsum.UI.Popover.DismissalBehavior.transient;return popover;};CollectionManager.prototype.initializePreexistingChildElements=function(){var elements;var _this=this;elements=$($.makeArray(this.targetElement.children()).reverse());elements.each(function(i,e){return _this.$initializeElement($(e));});return this;};CollectionManager.prototype.$initializeElement=function(element){var item,object,objectID;if(!(objectID=element.data('lipsum-managed-item-object-id'))){throw"element missing lipsum-managed-item-object-id data attribute";}
if(!(object=this.managedModel.get(objectID))){throw""+this.managedModel.name+" object #"+objectID+" not found";}
item=new Lipsum.ManagedItem;item.object=object;item.element=element;item.manager=this;this.$configureEditorsForElement(item,element);item.contentElement.append(element.children());item.rootElement.appendTo(element);item.initializeToolbar();item.toolbar.present();return this.managedItems.push(item);};CollectionManager.prototype.$configureEditorsForElement=function(item,element){var field,fieldElement,_j,_len2,_ref3,_results;if(this.settingsEditor!=null){item.settingsEditor=new this.settingsEditor(item);item.editors.push(item.settingsEditor);}
_ref3=this.editorFields;_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){field=_ref3[_j];fieldElement=element.find(field.selector);_results.push(this.$configureEditorForElementField(item,fieldElement,field));}
return _results;};CollectionManager.prototype.$configureEditorForElementField=function(item,element,field){var editorClass,_ref3;if((_ref3=field.type)==null)field.type='text';if(editorClass=Lipsum.Editor.named(field.type)){return item.editors.push(new editorClass(this,element,item.object,field.property,field.options));}else{throw"missing editor type: "+field.type;}};CollectionManager.prototype.$templateName=function(){return this.managedModel.name.underscorize();};CollectionManager.prototype.$template=function(){return Lipsum.templates[this.$templateName()];};CollectionManager.prototype.$createManagedItem=function(){var compiler,element,item,resource;item=new Lipsum.ManagedItem;resource=new this.managedModel;if(this.$template()==null){throw"No template found for model "+this.managedModel.name;}
compiler=Handlebars.compile(this.$template());element=$(compiler(resource.objectRepresentation()));item.object=resource;item.element=element;item.manager=this;item.contentElement.append(element.children());item.rootElement.appendTo(element);item.initializeToolbar();item.toolbar.present();this.$configureEditorsForElement(item,element);return item;};CollectionManager.prototype.$removeItem=function(item){var i;this.$removeElement(item.element);this.$presentSynchronizeButton();this.managedItems=(function(){var _j,_len2,_ref3,_results;_ref3=this.managedItems;_results=[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){i=_ref3[_j];if(i!==item)_results.push(i);}
return _results;}).call(this);if(!item.object.isNew())return this.$deletionQueue.push(item);};CollectionManager.prototype.$removeElement=function(element){var done,elements,item,previousPosition,_j,_len2,_ref3;var _this=this;this.targetElement.css({width:this.targetElement.width(),height:this.targetElement.height(),position:'relative'});_ref3=this.managedItems;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){item=_ref3[_j];item.element.css(item.element.position());item.element.css({position:'absolute'});}
done=function(){var item,_k,_len3,_ref4;element.detach();_this.targetElement.css({width:'',height:''});_this.targetElement.css({position:''});_ref4=_this.managedItems;for(_k=0,_len3=_ref4.length;_k<_len3;_k++){item=_ref4[_k];$(item.element).css({position:'',left:'',top:''});}
return Lipsum.UI.Frame.repositionAllInstances();};previousPosition=element.position();element.animate({transform:'scale(0)'},300,'easeInSine');elements=element.nextAll();if(elements.length===0)done();return elements.each(function(index,nextElement){var upcomingPosition;upcomingPosition=previousPosition;previousPosition=$(nextElement).position();return $.timeout(100*index,function(){return $(nextElement).animate(upcomingPosition,200,'easeOutQuad',function(){if(index+1===elements.length)return done();});});});};CollectionManager.prototype.$invalidateCache=function(){var editor,item,object,page,path,paths,pathsToCacheInvalidate,_j,_k,_l,_len2,_len3,_len4,_len5,_len6,_m,_n,_ref3,_ref4,_ref5,_results;pathsToCacheInvalidate=[Lipsum.currentPage.fullPath];_ref3=this.dependentPaths||[];for(_j=0,_len2=_ref3.length;_j<_len2;_j++){object=_ref3[_j];switch(typeof object){case'string':pathsToCacheInvalidate.push(object);break;case'function':paths=object(this)||[];for(_k=0,_len3=paths.length;_k<_len3;_k++){path=paths[_k];pathsToCacheInvalidate.push(path);}}}
_ref4=this.dependentPages||[];for(_l=0,_len4=_ref4.length;_l<_len4;_l++){object=_ref4[_l];switch(typeof object){case'string':if(page=Lipsum.Page.named(object)){pathsToCacheInvalidate.push(page.fullPath);}
break;case'object':if(object(typeof Lipsum.Page)){pathsToCacheInvalidate.push(object.fullPath);}}}
for(_m=0,_len5=pathsToCacheInvalidate.length;_m<_len5;_m++){path=pathsToCacheInvalidate[_m];Lipsum.invalidateCache(path);}
_ref5=this.managedItems;_results=[];for(_n=0,_len6=_ref5.length;_n<_len6;_n++){item=_ref5[_n];_results.push((function(){var _len7,_o,_ref6,_results2;_ref6=item.editors;_results2=[];for(_o=0,_len7=_ref6.length;_o<_len7;_o++){editor=_ref6[_o];_results2.push(editor.needsCacheInvalidation&&(editor.needsCacheInvalidation=false));}
return _results2;})());}
return _results;};return CollectionManager;})();Lipsum.EditorManager=(function(){__extends(EditorManager,Lipsum.Manager);function EditorManager(targetElement){this.targetElement=targetElement;EditorManager.__super__.constructor.apply(this,arguments);}
EditorManager.prototype.finalize=function(){var _ref3;if(this.model!=null){if((_ref3=this.object)==null){this.object=this.model.get(this.targetElement.data('lipsum-object-id'));}}
this.editor=new Lipsum.TextEditor(this,this.targetElement,this.object,this.property);return EditorManager.__super__.finalize.apply(this,arguments);};EditorManager.prototype.synchronizeChanges=function(){var _ref3;var _this=this;EditorManager.__super__.synchronizeChanges.apply(this,arguments);this.$dismissSynchronizeButton();if((_ref3=Lipsum.currentPage)!=null)_ref3.invalidateCache();this.editor.storeCurrentValue();return this.object.save(function(){return _this.frame.indicateSuccess();});};return EditorManager;})();Lipsum.WidgetManager=(function(){__extends(WidgetManager,Lipsum.Manager);function WidgetManager(targetElement){this.targetElement=targetElement;WidgetManager.__super__.constructor.apply(this,arguments);}
WidgetManager.prototype.finalize=function(){return WidgetManager.__super__.finalize.apply(this,arguments);};WidgetManager.prototype.synchronizeChanges=function(){};return WidgetManager;})();Lipsum.LoginController={$isLoggingIn:false,$isLoggingOut:false,initialize:function(){var _ref3;var _this=this;this.lockButton=$('<button id="lipsum-lock" tabindex="-1"/>');this.lockButton.prependTo($('body'));this.lockButton.click(function(){if(Lipsum.isLoggedIn){return _this.logoutPopover.present();}else{return _this.loginPopover.present();}});this.loginPopover=new Lipsum.UI.Popover;this.logoutPopover=new Lipsum.UI.Popover;this.loginPopover.delegate=this.logoutPopover.delegate=this;this.loginPopover.targetElement=this.logoutPopover.targetElement=this.lockButton;this.loginPopover.arrowDirection=this.logoutPopover.arrowDirection=Lipsum.UI.Popover.ArrowDirection.down;this.loginPopover.arrowPlacement=this.logoutPopover.arrowPlacement=Lipsum.UI.Popover.ArrowPlacement.end;this.loginPopover.dismissalBehavior=this.logoutPopover.dismissalBehavior=Lipsum.UI.Popover.DismissalBehavior.transient;this.loginPopover.positioningMethod=this.logoutPopover.positioningMethod=Lipsum.UI.Popover.PositioningMethod.fixed;this.loginPopover.positioningOffset=this.logoutPopover.positioningOffset=[18,8];this.loginPopover.contentElement.addClass('lipsum-login-popover');this.loginPopover.contentElement.append(this.usernameField=$('<input type="text" placeholder="Username"/>'));this.loginPopover.contentElement.append(this.passwordField=$('<input type="password" placeholder="Password"/>'));this.loginPopover.contentElement.append(this.loginButton=$('<button disabled/>').text("Log In").click(function(){return _this.logIn(_this.usernameField.val(),_this.passwordField.val());}));this.loginPopover.defaultButton=this.loginButton;this.usernameField.add(this.passwordField).bind('keyup keydown click change',function(){return _this.loginButton.attr({disabled:!_this.$isLoggingIn&&!_this.usernameField.val().length||!_this.passwordField.val().length});});this.logoutPopover.contentElement.addClass('lipsum-logout-popover');this.logoutPopover.contentElement.append(this.nameLabel=$('<strong/>').text(((_ref3=Lipsum.currentAdmin)!=null?_ref3.fullName:void 0)||"—"));this.logoutPopover.contentElement.append(this.settingsButton=$('<button disabled/>').text("Settings").click(function(){return _this.logoutPopover.shake();}));this.logoutPopover.contentElement.append(this.logoutButton=$('<button/>').text("Log Out").click(function(){return _this.logOut();}));if(Lipsum.isLoggedIn)this.lockButton.addClass('unlocked');return this;},logIn:function(username,password){var _this=this;this.$isLoggingIn=true;this.loginButton.attr({disabled:true});Lipsum.HTTP.request({path:'/lipsum',data:{username:username,password:password},method:'POST',errorHandler:function(response){_this.loginButton.attr({disabled:false});_this.loginPopover.shake();if(!_this.loginPopover.contentElement.find(':focus').length){return _this.usernameField.focus();}},successHandler:function(response){Lipsum.Administrator.fetchAll(function(){return Lipsum.completeAuthenticationWithAdministratorID(response['id']);});_this.nameLabel.text(response['full_name']);_this.lockButton.addClass('unlocked');return _this.loginPopover.dismiss(function(){return _this.loginButton.attr({disabled:false});});},completeHandler:function(response){return _this.$isLoggingIn=false;}});return this;},logOut:function(){var _this=this;this.$isLoggingOut=true;this.logoutButton.attr({disabled:true});return Lipsum.HTTP.request({path:'/lipsum',method:'DELETE',errorHandler:function(response){return _this.logoutButton.attr({disabled:false});},successHandler:function(response){Lipsum.deauthenticateCurrentAdministrator();_this.lockButton.removeClass('unlocked');return _this.logoutPopover.dismiss(function(){return _this.logoutButton.attr({disabled:false});});},completeHandler:function(response){return _this.$isLoggingOut=false;}});},popoverWillPresent:function(popover){if(popover===this.loginPopover){this.usernameField.val(null);this.passwordField.val(null);this.usernameField.change();this.passwordField.change();this.usernameField.focus();return this.lockButton.css({opacity:1});}},popoverWillDismiss:function(popover){if(popover===this.loginPopover){return this.lockButton.css({opacity:''});}}};$(function(){return Lipsum.initialize();});this.CharacterAvatarEditor=(function(){__extends(CharacterAvatarEditor,Lipsum.Editor);CharacterAvatarEditor.register('characterAvatar');function CharacterAvatarEditor(){this.$handleChange=__bind(this.$handleChange,this);this.$clickHandler=__bind(this.$clickHandler,this);var _this=this;CharacterAvatarEditor.__super__.constructor.apply(this,arguments);this.popover=new Lipsum.UI.Popover;this.popover.delegate={popoverWillDismiss:function(){return _this.ceaseEditing();}};this.popover.targetElement=this.element;this.popover.arrowDirection='down';this.popover.dismissalBehavior='transient';this.element.css({cursor:'crosshair'});this.element.bind('click',this.$clickHandler);}
CharacterAvatarEditor.prototype.beginEditing=function(){this.popover.contentElement.empty().append(this.$popupButton());this.popover.present();return CharacterAvatarEditor.__super__.beginEditing.apply(this,arguments);};CharacterAvatarEditor.prototype.ceaseEditing=function(){this.popover.dismiss();return CharacterAvatarEditor.__super__.ceaseEditing.apply(this,arguments);};CharacterAvatarEditor.prototype.hasChanges=function(){return this.object.getAttribute(this.propertyName)!==this.currentValue();};CharacterAvatarEditor.prototype.currentValue=function(){return parseInt(this.element.attr('data-character-number'));};CharacterAvatarEditor.prototype.$popupButton=function(){var button,name,popup,select,_j,_len2,_ref3;var _this=this;popup=$('<div class="lipsum-popup-button"/>');select=$('<select/>').appendTo(popup);button=$('<button/>').appendTo(popup);_ref3=this.constructor.characterNames;for(_j=0,_len2=_ref3.length;_j<_len2;_j++){name=_ref3[_j];select.append($("<option value='"+(select.children().length+1)+"'/>").text(name));}
select.val(this.currentValue());button.text(this.constructor.characterNames[this.currentValue()-1]);select.change(function(){return _this.$handleChange(select.val());});return popup;};CharacterAvatarEditor.prototype.$clickHandler=function(event){return this.beginEditing();};CharacterAvatarEditor.prototype.$handleChange=function(number){this.element.attr({'data-character-number':""+number});this.element.attr({src:"/characters/"+number+".png"});this.manager.editorDidChange(this);return this.ceaseEditing();};return CharacterAvatarEditor;})();Lipsum.configure(function(){return CharacterAvatarEditor.characterNames={da_DK:["Bimse Fan Gok","Luna Frick","Dr. Gørde Bedre","Uffe Deluxe","Oberst March","Trucker Keld","Tonny Thomsen","Kæmpe Kirsten","Hugo Saurus","Klovnen Coco","Karla Von Kiks","Dina Digter","Sofus Schwarzenegger","Nanna Hastberg","Fie Fjong","Søren Skotte","Kælder Karl","Bella Lynggaard","Vera Vampyr","Caroline Kvist","Grev Ålefjeld","Gudrun Granit","Søster Marie","Leif Lipton","Fru Kendis","Roy Reporter","Mette Nelly","Hr. Bitterhofen","Bedste Bine","Hr. Kendis"],en_UK:["Peru Von Through","Terra Rash","Dr. Triharder","Zed Dezzy","Sgt Drill","Axel Greese","Brent McQueen","Dirty Dora","Hugo Sharp","Chuckles","Felicity Green","Dina Inkwell","Brick Brute","Stephanie Steel","Ima Fastone","Scotty O'Kilter","Joe Büllow","Geraldine Smirk","Wampaire Carla","Charlotte Sprigg","Lord Hamilton-Burp","Marion Marmaduke","Sister Mary","Mearl Grey","Mrs. Angebrad","Chuck Matthews","Nurse Nelly","Mr. Parkins","Plum Ginny","Mr. Angebrad"],sv_SE:["Ernst von Dalí","Lortiga Lotta","Dr. Göran Bätre","Henrik Hårfager","Överste Fält","Meckar-Micke","Brolle Sr.","Stygge Stine","Professor Snille","Kalle Kuling","Tina Tårta","Liza Book","Ulf Stark","Nanna Penning","Anja Kvick","Scott Machsnål","Jürgen Mellin","Gladys Solstråle","Vera Vampyr","Caroline Kvist","Greve Fis Von Förnäm","Gudrun Granit","Heliga Hanna","Leif Lipton","Fru Snobb","Morgan Pålsson","Syster Yster","Herr Butterkvist","Tant Grå","Herr Snobb"],no_NO:["Tideman Munch","Svulla Skjør","Dr. Ståpå Mehr","Harald Hippi","Sersjant Marj","Tralle Hjuel","Aksel Lyngbø","Doris Deform","Georg Glup","Klovnen Bobo","Klara Kokk","Rosa Rim","Kåre Kraft","Kristin Brundtvann","Regine Rask","Angus Mckilt","Tor Von Trapp","Sigrid Sleip","Vera Vampyr","Kari Kvist","Grev Fise-Finn","Sara Safari","Søster Maria","Torvald The","Fru Stjernne","Roar Reporter","Søster Glad","Herr Grethen","Besta Rund-Vihn","Herr Stjerhne"],nl_NL:["Peru Von Through","Terra Rash","Dr. Triharder","Zed Dezzy","Sgt Drill","Axel Greese","Brent McQueen","Dirty Dora","Hugo Sharp","Chuckles","Felicity Green","Dina Inkwell","Brick Brute","Stephanie Steel","Ima Fastone","Scotty O'Kilter","Joe Büllow","Geraldine Smirk","Wampaire Carla","Charlotte Sprigg","Lord Hamilton-Burp","Marion Marmaduke","Sister Mary","Mearl Grey","Mrs. Angebrad","Chuck Matthews","Nurse Nelly","Mr. Parkins","Plum Ginny","Mr. Angebrad"]}[Lipsum.currentLocale];});this.CardDeckSettingsEditor=(function(){__extends(CardDeckSettingsEditor,Lipsum.Object);function CardDeckSettingsEditor(item){this.item=item;this.$changeHandler=__bind(this.$changeHandler,this);this.badge=$('.rarity-badge',this.item.element);}
CardDeckSettingsEditor.prototype.popover=function(){var _ref3,_ref4,_ref5;if(this.$popover!=null)return this.$popover;this.$popover=this.item.manager.popoverForToolbarItem(this.item.toolbar.itemNamed('settings'));this.$selectElement=$('<select/>');this.$selectElement.bind('change',this.$changeHandler);(_ref3=this.$selectElement).append.apply(_ref3,[$('<option value="common"/>').text("Common"),$('<option value="rare"/>').text("Rare"),$('<option value="super_rare"/>').text("Super Rare"),$('<option value="ultra_rare"/>').text("Ultra Rare")]);this.$popover.contentElement.append($('<strong/>').text("Rarity:"));(_ref5=this.$popover.contentElement).append.apply(_ref5,[(_ref4=$('<div class="lipsum-popup-button"/>')).append.apply(_ref4,[this.$selectElement,this.$buttonElement=$('<button/>').css({width:'100px'}).text("Common")])]);this.$selectElement.val(this.readCurrentValue());this.$buttonElement.text(this.$selectElement.find(':selected').text());return this.$popover;};CardDeckSettingsEditor.prototype.present=function(){return this.popover().present();};CardDeckSettingsEditor.prototype.readCurrentValue=function(){return this.item.object.getAttribute('rarity');};CardDeckSettingsEditor.prototype.storeCurrentValue=function(){if(this.$selectElement!=null){return this.item.object.setAttribute('rarity',this.$selectElement.val());}};CardDeckSettingsEditor.prototype.hasChanges=function(){return(this.$selectElement!=null)&&this.readCurrentValue()!==this.$selectElement.val();};CardDeckSettingsEditor.prototype.$changeHandler=function(event){this.$buttonElement.text(this.$selectElement.find(':selected').text());this.badge.removeClass('common rare super-rare ultra-rare');this.badge.addClass(this.$selectElement.val().replace(/_/g,'-'));return this.item.manager.editorDidChange(this);};return CardDeckSettingsEditor;})();this.Card=(function(){__extends(Card,Lipsum.Model);function Card(){Card.__super__.constructor.apply(this,arguments);}
Card.configure(function(){this.property('id',Number);this.property('name',String);this.property('description',String);this.property('ingenuity',Number);this.property('experience',Number);this.property('coolness',Number);this.property('endurance',Number);this.property('courage',Number);this.property('imageType',String);return this.belongsTo('deck',{model:'CardDeck'});});return Card;})();this.CardDeck=(function(){__extends(CardDeck,Lipsum.Model);CardDeck.configure(function(){this.property('id',Number);this.property('name',String);this.property('rarity',String);this.property('description',String);this.property('imageType',String);return this.hasMany('cards',{model:'Card'});});function CardDeck(){var i;CardDeck.__super__.constructor.apply(this,arguments);if(this.isNew()){for(i=1;i<=3;i++){new Card({deck_id:this});}}}
return CardDeck;})();this.NewsPost=(function(){__extends(NewsPost,Lipsum.Model);function NewsPost(){NewsPost.__super__.constructor.apply(this,arguments);}
NewsPost.configure(function(){this.property('id',Number);this.property('mainContent',String);return this.property('character',Number);});return NewsPost;})();Lipsum.configure(function(){var _ref3;this.site.addEditorManager('.paper-tearing-content-inner.text-page',{object:(_ref3=Lipsum.currentPage)!=null?_ref3.mainContent():void 0,property:'string'});this.site.addCollectionManager('#news-posts',{dependentPages:['index'],managedModel:NewsPost,editorFields:[{selector:'#aside-polaroid img',property:'character',type:'characterAvatar'},{selector:'.paper-tearing-content-inner',property:'mainContent'}]});return this.site.addCollectionManager('#trading-cards',{managedModel:CardDeck,editorFields:[{selector:'h2',property:'name',options:{oneLine:true}},{selector:'.polaroid .image',property:'image',type:'image'},{selector:'.deck-description',property:'description'},{selector:'.card:nth(0) h3',property:'cards[0].name',options:{oneLine:true}},{selector:'.card:nth(0) .card-image',property:'cards[0].image',type:'image'},{selector:'.card:nth(0) .card-description',property:'cards[0].description'},{selector:'.card:nth(0) .stats .ingenuity .number',property:'cards[0].ingenuity',options:{number:true}},{selector:'.card:nth(0) .stats .experience .number',property:'cards[0].experience',options:{number:true}},{selector:'.card:nth(0) .stats .coolness .number',property:'cards[0].coolness',options:{number:true}},{selector:'.card:nth(0) .stats .endurance .number',property:'cards[0].endurance',options:{number:true}},{selector:'.card:nth(0) .stats .courage .number',property:'cards[0].courage',options:{number:true}},{selector:'.card:nth(1) h3',property:'cards[1].name',options:{oneLine:true}},{selector:'.card:nth(1) .card-image',property:'cards[1].image',type:'image'},{selector:'.card:nth(1) .card-description',property:'cards[1].description'},{selector:'.card:nth(1) .stats .ingenuity .number',property:'cards[1].ingenuity',options:{number:true}},{selector:'.card:nth(1) .stats .experience .number',property:'cards[1].experience',options:{number:true}},{selector:'.card:nth(1) .stats .coolness .number',property:'cards[1].coolness',options:{number:true}},{selector:'.card:nth(1) .stats .endurance .number',property:'cards[1].endurance',options:{number:true}},{selector:'.card:nth(1) .stats .courage .number',property:'cards[1].courage',options:{number:true}},{selector:'.card:nth(2) h3',property:'cards[2].name',options:{oneLine:true}},{selector:'.card:nth(2) .card-image',property:'cards[2].image',type:'image'},{selector:'.card:nth(2) .card-description',property:'cards[2].description'},{selector:'.card:nth(2) .stats .ingenuity .number',property:'cards[2].ingenuity',options:{number:true}},{selector:'.card:nth(2) .stats .experience .number',property:'cards[2].experience',options:{number:true}},{selector:'.card:nth(2) .stats .coolness .number',property:'cards[2].coolness',options:{number:true}},{selector:'.card:nth(2) .stats .endurance .number',property:'cards[2].endurance',options:{number:true}},{selector:'.card:nth(2) .stats .courage .number',property:'cards[2].courage',options:{number:true}}],settingsEditor:CardDeckSettingsEditor,dependentPaths:[function(manager){var editor,extension,imageName,item,paths,type,_j,_k,_len2,_len3,_ref4,_ref5,_ref6,_ref7;paths=[];_ref4=manager.managedItems;for(_j=0,_len2=_ref4.length;_j<_len2;_j++){item=_ref4[_j];_ref5=item.editors;for(_k=0,_len3=_ref5.length;_k<_len3;_k++){editor=_ref5[_k];if(!(editor instanceof Lipsum.ImageEditor))continue;if(!editor.needsCacheInvalidation)continue;type=(_ref6=editor.lastUpload)!=null?_ref6.type:void 0;extension=Lipsum.extensionsByType[type];imageName=(_ref7=item.object.getAttribute('id'))!=null?_ref7.toString():void 0;if(extension)imageName+=extension;paths.push(Lipsum.currentPage.pathWithLocalizedComponents({name:'card'},imageName));}}
return paths;}]});});Lipsum.configure(function(){});Lipsum.templates['card_deck']='<div class="deck">\n  <div class="polaroid">\n    <img class="image"/>\n    <div class="rarity-badge"></div>\n  </div>\n  <h2>Lorem ipsum</h2>\n  <div class="deck-description">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>\n  \n  <div class="cards">\n    {{> card}}\n    {{> card}}\n    {{> card}}\n  </div>\n</div>\n';Lipsum.templates['news_post']='<div>\n  <div id="aside-polaroid" class="small">\n    <img src="/characters/1.png" alt="" data-character-number="1"/>\n  </div>\n  <div class="paper-tearing-wrapper top">\n    <div class="paper-tearing-header"></div>\n    <div class="paper-tearing-content">\n      <div class="paper-tearing-content-inner">\n        <p>Lorem ipsum dolor sit amet</p>\n      </div>\n    </div>\n    <div class="paper-tearing-footer"></div>\n  </div>\n</div>\n';Handlebars.registerPartial('card','<div class="card">\n  <img class="card-image"/>\n  <img class="speech-bubble-pointer" src="/trading_card_images/slices/speechbubble_pointer.png">\n  \n  <h3>Lorem ipsum</h3>\n  <div class="card-description">dolor sit amet</div>\n  <ul class="stats">\n    <li class="ingenuity"><div>Opfindsomhed</div><span class="number">0</span></li>\n    <li class="experience"><div>Erfaring</div><span class="number">0</span></li>\n    <li class="coolness"><div>Coolness</div><span class="number">0</span></li>\n    <li class="endurance"><div>Udholdenhed</div><span class="number">0</span></li>\n    <li class="courage"><div>Mod</div><span class="number">0</span></li>\n  </ul>\n</div>');}).call(this);
