luca 0.9.42 → 0.9.65
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +50 -9
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +5 -0
- data/assets/javascripts/dependencies/underscore-min.js +5 -31
- data/lib/generators/luca/application/application_generator.rb +71 -0
- data/lib/generators/luca/application/templates/controller.rb +6 -0
- data/lib/generators/luca/application/templates/index.html.erb +7 -0
- data/lib/generators/luca/application/templates/index.html.haml +6 -0
- data/lib/generators/luca/application/templates/javascripts/application.js +28 -0
- data/lib/generators/luca/application/templates/javascripts/application.js.coffee +20 -0
- data/lib/generators/luca/application/templates/javascripts/config.js +15 -0
- data/lib/generators/luca/application/templates/javascripts/config.js.coffee +9 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.js +5 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.js.coffee +5 -0
- data/lib/generators/luca/application/templates/javascripts/index.js +9 -0
- data/lib/generators/luca/application/templates/javascripts/index.js.coffee +9 -0
- data/lib/generators/luca/application/templates/javascripts/main.js +8 -0
- data/lib/generators/luca/application/templates/javascripts/main.js.coffee +3 -0
- data/lib/generators/luca/application/templates/javascripts/main.jst.ejs +1 -0
- data/lib/generators/luca/application/templates/javascripts/router.js +12 -0
- data/lib/generators/luca/application/templates/javascripts/router.js.coffee +7 -0
- data/lib/luca/rails/version.rb +1 -1
- data/spec/components/collection_view_spec.coffee +59 -0
- data/spec/components/multi_collection_view_spec.coffee +5 -0
- data/{src/templates/components/form_alert → spec/components/pagination_control_spec.coffee} +0 -0
- data/spec/components/table_view_spec.coffee +17 -0
- data/spec/core/container_spec.coffee +127 -5
- data/spec/core/model_spec.coffee +21 -3
- data/spec/define_spec.coffee +19 -0
- data/spec/mixin_spec.coffee +49 -0
- data/spec/modules/filterable_spec.coffee +25 -0
- data/spec/modules/paginatable_spec.coffee +0 -0
- data/spec/modules/state_model_spec.coffee +0 -0
- data/src/components/application.coffee +52 -38
- data/src/components/collection_view.coffee +118 -45
- data/src/components/fields/checkbox_field.coffee +2 -2
- data/src/components/fields/file_upload_field.coffee +0 -3
- data/src/components/fields/hidden_field.coffee +0 -3
- data/src/components/fields/label_field.coffee +1 -4
- data/src/components/fields/select_field.coffee +6 -6
- data/src/components/fields/text_area_field.coffee +1 -0
- data/src/components/fields/text_field.coffee +4 -0
- data/src/components/fields/type_ahead_field.coffee +5 -9
- data/src/components/form_view.coffee +28 -23
- data/src/components/multi_collection_view.coffee +121 -0
- data/src/components/pagination_control.coffee +106 -0
- data/src/components/table_view.coffee +22 -13
- data/src/containers/card_view.coffee +44 -11
- data/src/containers/panel_toolbar.coffee +88 -82
- data/src/containers/tab_view.coffee +3 -3
- data/src/core/collection.coffee +11 -4
- data/src/core/container.coffee +206 -122
- data/src/core/field.coffee +13 -10
- data/src/core/model.coffee +23 -27
- data/src/core/registry.coffee +42 -29
- data/src/core/view.coffee +63 -149
- data/src/define.coffee +91 -19
- data/src/framework.coffee +11 -9
- data/src/managers/collection_manager.coffee +24 -8
- data/src/modules/application_event_bindings.coffee +19 -0
- data/src/modules/collection_event_bindings.coffee +26 -0
- data/src/modules/deferrable.coffee +3 -1
- data/src/modules/dom_helpers.coffee +49 -0
- data/src/modules/enhanced_properties.coffee +23 -0
- data/src/modules/filterable.coffee +82 -0
- data/src/modules/grid_layout.coffee +13 -1
- data/src/modules/{load_mask.coffee → loadmaskable.coffee} +10 -4
- data/src/modules/modal_view.coffee +38 -0
- data/src/modules/paginatable.coffee +87 -0
- data/src/modules/state_model.coffee +16 -0
- data/src/modules/templating.coffee +8 -0
- data/src/plugins/events.coffee +30 -2
- data/src/templates/components/bootstrap_form_controls.jst.ejs +10 -0
- data/src/templates/components/collection_loader_view.jst.ejs +6 -0
- data/src/templates/components/form_alert.jst.ejs +4 -0
- data/src/templates/components/grid_view.jst.ejs +11 -0
- data/src/templates/components/grid_view_empty_text.jst.ejs +3 -0
- data/src/templates/components/load_mask.jst.ejs +5 -0
- data/src/templates/components/nav_bar.jst.ejs +4 -0
- data/src/templates/components/pagination.jst.ejs +10 -0
- data/src/templates/containers/basic.jst.ejs +1 -0
- data/src/templates/containers/tab_selector_container.jst.ejs +12 -0
- data/src/templates/containers/tab_view.jst.ejs +2 -0
- data/src/templates/containers/toolbar_wrapper.jst.ejs +1 -0
- data/src/templates/fields/button_field.jst.ejs +2 -0
- data/src/templates/fields/button_field_link.jst.ejs +6 -0
- data/src/templates/fields/checkbox_array.jst.ejs +4 -0
- data/src/templates/fields/checkbox_array_item.jst.ejs +3 -0
- data/src/templates/fields/checkbox_field.jst.ejs +10 -0
- data/src/templates/fields/file_upload_field.jst.ejs +10 -0
- data/src/templates/fields/hidden_field.jst.ejs +1 -0
- data/src/templates/fields/select_field.jst.ejs +11 -0
- data/src/templates/fields/text_area_field.jst.ejs +11 -0
- data/src/templates/fields/text_field.jst.ejs +16 -0
- data/src/templates/table_view.jst.ejs +4 -0
- data/src/tools/console.coffee +51 -21
- data/src/util.coffee +17 -4
- data/vendor/assets/javascripts/luca-ui-base.js +5304 -0
- data/vendor/assets/javascripts/luca-ui-bootstrap.js +9 -0
- data/vendor/assets/javascripts/luca-ui-development-tools.js +52 -24
- data/vendor/assets/javascripts/luca-ui-development-tools.min.js +1 -1
- data/vendor/assets/javascripts/luca-ui-full.js +1700 -595
- data/vendor/assets/javascripts/luca-ui-full.min.js +7 -6
- data/vendor/assets/javascripts/luca-ui-spec.js +6815 -0
- data/vendor/assets/javascripts/luca-ui-templates.js +92 -24
- data/vendor/assets/javascripts/luca-ui.js +1695 -564
- data/vendor/assets/javascripts/luca-ui.min.js +4 -4
- metadata +69 -28
- data/src/templates/components/bootstrap_form_controls.luca +0 -7
- data/src/templates/components/collection_loader_view.luca +0 -5
- data/src/templates/components/form_alert.luca +0 -3
- data/src/templates/components/grid_view.luca +0 -7
- data/src/templates/components/grid_view_empty_text.luca +0 -3
- data/src/templates/components/load_mask.luca +0 -3
- data/src/templates/components/nav_bar.luca +0 -2
- data/src/templates/containers/basic.luca +0 -1
- data/src/templates/containers/tab_selector_container.luca +0 -8
- data/src/templates/containers/tab_view.luca +0 -2
- data/src/templates/containers/toolbar_wrapper.luca +0 -1
- data/src/templates/fields/button_field.luca +0 -2
- data/src/templates/fields/button_field_link.luca +0 -5
- data/src/templates/fields/checkbox_array.luca +0 -4
- data/src/templates/fields/checkbox_array_item.luca +0 -4
- data/src/templates/fields/checkbox_field.luca +0 -9
- data/src/templates/fields/file_upload_field.luca +0 -8
- data/src/templates/fields/hidden_field.luca +0 -1
- data/src/templates/fields/select_field.luca +0 -8
- data/src/templates/fields/text_area_field.luca +0 -8
- data/src/templates/fields/text_field.luca +0 -17
- data/src/templates/sample/contents.luca +0 -1
- data/src/templates/sample/welcome.luca +0 -1
- data/src/templates/table_view.luca +0 -4
@@ -12,4 +12,4 @@
|
|
12
12
|
(a):void 0},b.prototype.makeReturn=function(a){var b,c,d,e,g;e=this.cases;for(c=0,d=e.length;c<d;c++)b=e[c],b[1].makeReturn(a);return a&&(this.otherwise||(this.otherwise=new f([new A("void 0")]))),(g=this.otherwise)!=null&&g.makeReturn(a),this},b.prototype.compileNode=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;i=a.indent+R,j=a.indent=i+R,d=this.tab+("switch ("+(((o=this.subject)!=null?o.compile(a,y):void 0)||!1)+") {\n"),p=this.cases;for(h=k=0,m=p.length;k<m;h=++k){q=p[h],f=q[0],b=q[1],r=bb([f]);for(l=0,n=r.length;l<n;l++)e=r[l],this.subject||(e=e.invert()),d+=i+("case "+e.compile(a,y)+":\n");if(c=b.compile(a,z))d+=c+"\n";if(h===this.cases.length-1&&!this.otherwise)break;g=this.lastNonComment(b.expressions);if(g instanceof K||g instanceof A&&g.jumps()&&g.value!=="debugger")continue;d+=j+"break;\n"}return this.otherwise&&this.otherwise.expressions.length&&(d+=i+("default:\n"+this.otherwise.compile(a,z)+"\n")),d+this.tab+"}"},b}(e),a.If=r=function(a){function b(a,b,c){this.body=b,c==null&&(c={}),this.condition=c.type==="unless"?a.invert():a,this.elseBody=null,this.isChain=!1,this.soak=c.soak}return lb(b,a),b.name="If",b.prototype.children=["condition","body","elseBody"],b.prototype.bodyNode=function(){var a;return(a=this.body)!=null?a.unwrap():void 0},b.prototype.elseBodyNode=function(){var a;return(a=this.elseBody)!=null?a.unwrap():void 0},b.prototype.addElse=function(a){return this.isChain?this.elseBodyNode().addElse(a):(this.isChain=a instanceof b,this.elseBody=this.ensureBlock(a)),this},b.prototype.isStatement=function(a){var b;return(a!=null?a.level:void 0)===z||this.bodyNode().isStatement(a)||((b=this.elseBodyNode())!=null?b.isStatement(a):void 0)},b.prototype.jumps=function(a){var b;return this.body.jumps(a)||((b=this.elseBody)!=null?b.jumps(a):void 0)},b.prototype.compileNode=function(a){return this.isStatement(a)?this.compileStatement(a):this.compileExpression(a)},b.prototype.makeReturn=function(a){return a&&(this.elseBody||(this.elseBody=new f([new A("void 0")]))),this.body&&(this.body=new f([this.body.makeReturn(a)])),this.elseBody&&(this.elseBody=new f([this.elseBody.makeReturn(a)])),this},b.prototype.ensureBlock=function(a){return a instanceof f?a:new f([a])},b.prototype.compileStatement=function(a){var c,d,e,f,g,h,i;return e=$(a,"chainChild"),g=$(a,"isExistentialEquals"),g?(new b(this.condition.invert(),this.elseBodyNode(),{type:"if"})).compile(a):(f=this.condition.compile(a,y),a.indent+=R,c=this.ensureBlock(this.body),d=c.compile(a),1===((i=c.expressions)!=null?i.length:void 0)&&!this.elseBody&&!e&&d&&f&&-1===d.indexOf("\n")&&80>f.length+d.length?""+this.tab+"if ("+f+") "+d.replace(/^\s+/,""):(d&&(d="\n"+d+"\n"+this.tab),h="if ("+f+") {"+d+"}",e||(h=this.tab+h),this.elseBody?h+" else "+(this.isChain?(a.indent=this.tab,a.chainChild=!0,this.elseBody.unwrap().compile(a,z)):"{\n"+this.elseBody.compile(a,z)+"\n"+this.tab+"}"):h))},b.prototype.compileExpression=function(a){var b,c,d,e;return e=this.condition.compile(a,v),c=this.bodyNode().compile(a,w),b=this.elseBodyNode()?this.elseBodyNode().compile(a,w):"void 0",d=""+e+" ? "+c+" : "+b,a.level>=v?"("+d+")":d},b.prototype.unfoldSoak=function(){return this.soak&&this},b}(e),i={wrap:function(a,c,d){var e,h,i,k,l;if(a.jumps())return a;i=new j([],f.wrap([a])),e=[];if((k=a.contains(this.literalArgs))||a.contains(this.literalThis))l=new A(k?"apply":"call"),e=[new A("this")],k&&e.push(new A("arguments")),i=new W(i,[new b(l)]);return i.noReturn=d,h=new g(i,e),c?f.wrap([h]):h},literalArgs:function(a){return a instanceof A&&a.value==="arguments"&&!a.asKey},literalThis:function(a){return a instanceof A&&a.value==="this"&&!a.asKey||a instanceof j&&a.bound}},gb=function(a,b,c){var d;if(!!(d=b[c].unfoldSoak(a)))return b[c]=d.body,d.body=new W(b),d},V={"extends":function(){return"function(child, parent) { for (var key in parent) { if ("+hb("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; }"},bind:function(){return"function(fn, me){ return function(){ return fn.apply(me, arguments); }; }"},indexOf:function(){return"[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }"},hasProp:function(){return"{}.hasOwnProperty"},slice:function(){return"[].slice"}},z=1,y=2,w=3,v=4,x=5,u=6,R=" ",p="[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*",o=RegExp("^"+p+"$"),L=/^[+-]?\d+$/,B=RegExp("^(?:("+p+")\\.prototype(?:\\.("+p+")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|("+p+")$"),q=/^['"]/,hb=function(a){var b;return b="__"+a,N.root.assign(b,V[a]()),b},eb=function(a,b){return a=a.replace(/\n/g,"$&"+b),a.replace(/\s+$/,"")}}).call(this)},require["./coffee-script"]=new function(){var a=this;(function(){var b,c,d,e,f,g,h,i,j,k={}.hasOwnProperty;e=require("fs"),h=require("path"),j=require("./lexer"),b=j.Lexer,c=j.RESERVED,g=require("./parser").parser,i=require("vm"),require.extensions?require.extensions[".coffee"]=function(a,b){var c;return c=d(e.readFileSync(b,"utf8"),{filename:b}),a._compile(c,b)}:require.registerExtension&&require.registerExtension(".coffee",function(a){return d(a)}),a.VERSION="1.2.1-pre",a.RESERVED=c,a.helpers=require("./helpers"),a.compile=d=function(b,c){var d,e,h;c==null&&(c={}),h=a.helpers.merge;try{e=g.parse(f.tokenize(b)).compile(c);if(!c.header)return e}catch(i){throw c.filename&&(i.message="In "+c.filename+", "+i.message),i}return d="Generated by CoffeeScript "+this.VERSION,"// "+d+"\n"+e},a.tokens=function(a,b){return f.tokenize(a,b)},a.nodes=function(a,b){return typeof a=="string"?g.parse(f.tokenize(a,b)):g.parse(a)},a.run=function(a,b){var c;return b==null&&(b={}),c=require.main,c.filename=process.argv[1]=b.filename?e.realpathSync(b.filename):".",c.moduleCache&&(c.moduleCache={}),c.paths=require("module")._nodeModulePaths(h.dirname(b.filename)),h.extname(c.filename)!==".coffee"||require.extensions?c._compile(d(a,b),c.filename):c._compile(a,c.filename)},a.eval=function(a,b){var c,e,f,g,j,l,m,n,o,p,q,r,s,t;b==null&&(b={});if(!!(a=a.trim())){e=i.Script;if(e){if(b.sandbox!=null){if(b.sandbox instanceof e.createContext().constructor)m=b.sandbox;else{m=e.createContext(),r=b.sandbox;for(g in r){if(!k.call(r,g))continue;n=r[g],m[g]=n}}m.global=m.root=m.GLOBAL=m}else m=global;m.__filename=b.filename||"eval",m.__dirname=h.dirname(m.__filename);if(m===global&&!m.module&&!m.require){c=require("module"),m.module=q=new c(b.modulename||"eval"),m.require=t=function(a){return c._load(a,q,!0)},q.filename=m.__filename,s=Object.getOwnPropertyNames(require);for(o=0,p=s.length;o<p;o++)l=s[o],l!=="paths"&&(t[l]=require[l]);t.paths=q.paths=c._nodeModulePaths(process.cwd()),t.resolve=function(a){return c._resolveFilename(a,q)}}}j={};for(g in b){if(!k.call(b,g))continue;n=b[g],j[g]=n}return j.bare=!0,f=d(a,j),m===global?i.runInThisContext(f):i.runInContext(f,m)}},f=new b,g.lexer={lex:function(){var a,b;return b=this.tokens[this.pos++]||[""],a=b[0],this.yytext=b[1],this.yylineno=b[2],a},setInput:function(a){return this.tokens=a,this.pos=0},upcomingInput:function(){return""}},g.yy=require("./nodes")}).call(this)},require["./browser"]=new function(){var exports=this;(function(){var CoffeeScript,runScripts;CoffeeScript=require("./coffee-script"),CoffeeScript.require=require,CoffeeScript.eval=function(code,options){return options==null&&(options={}),options.bare==null&&(options.bare=!0),eval(CoffeeScript.compile(code,options))},CoffeeScript.run=function(a,b){return b==null&&(b={}),b.bare=!0,Function(CoffeeScript.compile(a,b))()},typeof window!="undefined"&&window!==null&&(CoffeeScript.load=function(a,b){var c;return c=new(window.ActiveXObject||XMLHttpRequest)("Microsoft.XMLHTTP"),c.open("GET",a,!0),"overrideMimeType"in c&&c.overrideMimeType("text/plain"),c.onreadystatechange=function(){var d;if(c.readyState===4){if((d=c.status)!==0&&d!==200)throw new Error("Could not load "+a);CoffeeScript.run(c.responseText);if(b)return b()}},c.send(null)},runScripts=function(){var a,b,c,d,e,f;return f=document.getElementsByTagName("script"),a=function(){var a,b,c;c=[];for(a=0,b=f.length;a<b;a++)e=f[a],e.type==="text/coffeescript"&&c.push(e);return c}(),c=0,d=a.length,(b=function(){var d;d=a[c++];if((d!=null?d.type:void 0)==="text/coffeescript")return d.src?CoffeeScript.load(d.src,b):(CoffeeScript.run(d.innerHTML),b())})(),null},window.addEventListener?addEventListener("DOMContentLoaded",runScripts,!1):attachEvent("onload",runScripts))}).call(this)},require["./coffee-script"]}();typeof define=="function"&&define.amd?define(function(){return CoffeeScript}):root.CoffeeScript=CoffeeScript})(this);var CodeMirror=function(){function a(d,e){function Zb(a){return a>=0&&a<ub.size}function _b(a){return v(ub,a)}function ac(a,b){Lb=!0;var c=b-a.height;for(var d=a;d;d=d.parent)d.height+=c}function bc(a){var b={line:0,ch:0};rc(b,{line:ub.size-1,ch:_b(ub.size-1).text.length},hb(a),b,b),Fb=!0}function cc(){var a=[];return ub.iter(0,ub.size,function(b){a.push(b.text)}),a.join("\n")}function dc(a){function l(a){var b=Md(a,!0);if(b&&!_(b,g)){wb||pc(),g=b,Tc(d,b),Fb=!1;var c=Mc();if(b.line>=c.to||b.line<c.from)h=setTimeout(Zd(function(){l(a)}),150)}}function m(a){clearTimeout(h);var b=Md(a);b&&Tc(d,b),C(a),Ic(),Fb=!0,n(),j()}Sc(H(a,"shiftKey"));for(var b=F(a);b!=A;b=b.parentNode)if(b.parentNode==W&&b!=X)return;for(var b=F(a);b!=A;b=b.parentNode)if(b.parentNode==db)return f.onGutterClick&&f.onGutterClick($b,fb(db.childNodes,b)+Pb,a),C(a);var d=Md(a);switch(G(a)){case 3:L&&!c&&Nd(a);return;case 2:d&&Wc(d.line,d.ch,!0),setTimeout(Ic,20);return}if(!d){F(a)==U&&C(a);return}wb||pc();var e=+(new Date);if(Ab&&Ab.time>e-400&&_(Ab.pos,d))return C(a),setTimeout(Ic,20),dd(d.line);if(zb&&zb.time>e-400&&_(zb.pos,d))return Ab={time:e,pos:d},C(a),cd(d);zb={time:e,pos:d};var g=d,h;if(f.dragDrop&&T&&!f.readOnly&&!_(xb.from,xb.to)&&!ab(d,xb.from)&&!ab(xb.to,d)){P&&(kb.draggable=!0);function i(b){P&&(kb.draggable=!1),Cb=!1,j(),k(),Math.abs(a.clientX-b.clientX)+Math.abs(a.clientY-b.clientY)<10&&(C(b),Wc(d.line,d.ch,!0),Ic())}var j=I(document,"mouseup",Zd(i),!0),k=I(U,"drop",Zd(i),!0);Cb=!0,kb.dragDrop&&kb.dragDrop();return}C(a),Wc(d.line,d.ch,!0);var n=I(document,"mousemove",Zd(function(a){clearTimeout(h),C(a),!M&&!G(a)?m(a):l(a)}),!0),j=I(document,"mouseup",Zd(m),!0)}function ec(a){for(var b=F(a);b!=A;b=b.parentNode)if(b.parentNode==db)return C(a);var c=Md(a);if(!c)return;Ab={time:+(new Date),pos:c},C(a),cd(c)}function fc(a){if(f.onDragEvent&&f.onDragEvent($b,B(a)))return;a.preventDefault();var b=Md(a,!0),c=a.dataTransfer.files;if(!b||f.readOnly)return;if(c&&c.length&&window.FileReader&&window.File){function d(a,c){var d=new FileReader;d.onload=function(){g[c]=d.result,++h==e&&(b=Yc(b),Zd(function(){var a=xc(g.join(""),b,b);Tc(b,a)})())},d.readAsText(a)}var e=c.length,g=Array(e),h=0;for(var i=0;i<e;++i)d(c[i],i)}else try{var g=a.dataTransfer.getData("Text");g&&$d(function(){var a=xb.from,c=xb.to;Tc(b,b),Cb&&xc("",a,c),yc(g),Ic()})}catch(a){}}function gc(a){var b=Bc();a.dataTransfer.setData("Text",b);if(L||Q){var c=document.createElement("img");c.scr="data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs=",a.dataTransfer.setDragImage(c,0,0)}}function hc(a,b){if(typeof a=="string"){a=h[a];if(!a)return!1}var c=yb;try{f.readOnly&&(Eb=!0),b&&(yb=null),a($b)}catch(d){if(d!=K)throw d;return!1}finally{yb=c,Eb=!1}return!0}function ic(a){function h(){g=!0}var b=j(f.keyMap),c=b.auto;clearTimeout(lc),c&&!l(a)&&(lc=setTimeout(function(){j(f.keyMap)==b&&(f.keyMap=c.call?c.call(null,$b):c)},50));var d=jb[H(a,"keyCode")],e=!1;if(d==null||a.altGraphKey)return!1;H(a,"altKey")&&(d="Alt-"+d),H(a,"ctrlKey")&&(d="Ctrl-"+d),H(a,"metaKey")&&(d="Cmd-"+d);var g=!1;return H(a,"shiftKey")?e=k("Shift-"+d,f.extraKeys,f.keyMap,function(a){return hc(a,!0)},h)||k(d,f.extraKeys,f.keyMap,function(a){if(typeof a=="string"&&/^go[A-Z]/.test(a))return hc(a)},h):e=k(d,f.extraKeys,f.keyMap,hc,h),g&&(e=!1),e&&(C(a),Od(),M&&(a.oldKeyCode=a.keyCode,a.keyCode=0)),e}function jc(a,b){var c=k("'"+b+"'",f.extraKeys,f.keyMap,function(a){return hc(a,!0)});return c&&(C(a),Od()),c}function mc(a){wb||pc(),M&&a.keyCode==27&&(a.returnValue=!1),Cc&&Gc()&&(Cc=!1);if(f.onKeyEvent&&f.onKeyEvent($b,B(a)))return;var b=H(a,"keyCode");Sc(b==16||H(a,"shiftKey"));var d=ic(a);window.opera&&(kc=d?b:null,!d&&b==88&&H(a,c?"metaKey":"ctrlKey")&&yc(""))}function nc(a){Cc&&Gc();if(f.onKeyEvent&&f.onKeyEvent($b,B(a)))return;var b=H(a,"keyCode"),c=H(a,"charCode");if(window.opera&&b==kc){kc=null,C(a);return}if((window.opera&&(!a.which||a.which<10)||S)&&ic(a))return;var d=String.fromCharCode(c==null?b:c);f.electricChars&&tb.electricChars&&f.smartIndent&&!f.readOnly&&tb.electricChars.indexOf(d)>-1&&setTimeout(Zd(function(){fd(xb.to.line,"smart")}),75);if(jc(a,d))return;Ec()}function oc(a){if(f.onKeyEvent&&f.onKeyEvent($b,B(a)))return;H(a,"keyCode")==16&&(yb=null)}function pc(){if(f.readOnly=="nocursor")return;wb||(f.onFocus&&f.onFocus($b),wb=!0,A.className.search(/\bCodeMirror-focused\b/)==-1&&(A.className+=" CodeMirror-focused"),Kb||Hc(!0)),Dc(),Od()}function qc(){wb&&(f.onBlur&&f.onBlur($b),wb=!1,Sb&&Zd(function(){Sb&&(Sb(),Sb=null)})(),A.className=A.className.replace(" CodeMirror-focused","")),clearInterval(sb),setTimeout(function(){wb||(yb=null)},150)}function rc(a,b,c,d,e){if(Eb)return;if(Wb){var g=[];ub.iter(a.line,b.line+1,function(a){g.push(a.text)}),Wb.addChange(a.line,c.length,g);while(Wb.done.length>f.undoDepth)Wb.done.shift()}vc(a,b,c,d,e)}function sc(a,b){if(!a.length)return;var c=a.pop(),d=[];for(var e=c.length-1;e>=0;e-=1){var f=c[e],g=[],h=f.start+f.added;ub.iter(f.start,h,function(a){g.push(a.text)}),d.push({start:f.start,added:f.old.length,old:g});var i=Yc({line:f.start+f.old.length-1,ch:eb(g[g.length-1],f.old[f.old.length-1])});vc({line:f.start,ch:0},{line:h-1,ch:_b(h-1).text.length},f.old,i,i)}Fb=!0,b.push(d)}function tc(){sc(Wb.done,Wb.undone)}function uc(){sc(Wb.undone,Wb.done)}function vc(a,b,c,d,e){function y(a){return a<=Math.min(b.line,b.line+s)?a:a+s}if(Eb)return;var g=!1,h=Tb.length;f.lineWrapping||ub.iter(a.line,b.line+1,function(a){if(!a.hidden&&a.text.length==h)return g=!0,!0});if(a.line!=b.line||c.length>1)Lb=!0;var i=b.line-a.line,j=_b(a.line),k=_b(b.line);if(a.ch==0&&b.ch==0&&c[c.length-1]==""){var l=[],m=null;a.line?(m=_b(a.line-1),m.fixMarkEnds(k)):k.fixMarkStarts();for(var n=0,o=c.length-1;n<o;++n)l.push(r.inheritMarks(c[n],m));i&&ub.remove(a.line,i,Mb),l.length&&ub.insert(a.line,l)}else if(j==k)if(c.length==1)j.replace(a.ch,b.ch,c[0]);else{k=j.split(b.ch,c[c.length-1]),j.replace(a.ch,null,c[0]),j.fixMarkEnds(k);var l=[];for(var n=1,o=c.length-1;n<o;++n)l.push(r.inheritMarks(c[n],j));l.push(k),ub.insert(a.line+1,l)}else if(c.length==1)j.replace(a.ch,null,c[0]),k.replace(null,b.ch,""),j.append(k),ub.remove(a.line+1,i,Mb);else{var l=[];j.replace(a.ch,null,c[0]),k.replace(null,b.ch,c[c.length-1]),j.fixMarkEnds(k);for(var n=1,o=c.length-1;n<o;++n)l.push(r.inheritMarks(c[n],j));i>1&&ub.remove(a.line+1,i-1,Mb),ub.insert(a.line+1,l)}if(f.lineWrapping){var p=Math.max(5,U.clientWidth/Jd()-3);ub.iter(a.line,a.line+c.length,function(a){if(a.hidden)return;var b=Math.ceil(a.text.length/p)||1;b!=a.height&&ac(a,b)})}else ub.iter(a.line,a.line+c.length,function(a){var b=a.text;!a.hidden&&b.length>h&&(Tb=b,h=b.length,Ub=null,g=!1)}),g&&(Nb=!0);var q=[],s=c.length-i-1;for(var n=0,t=vb.length;n<t;++n){var u=vb[n];u<a.line?q.push(u):u>b.line&&q.push(u+s)}var v=a.line+Math.min(c.length,500);Td(a.line,v),q.push(v),vb=q,Vd(100),Hb.push({from:a.line,to:b.line+1,diff:s});var w={from:a,to:b,text:c};if(Ib){for(var x=Ib;x.next;x=x.next);x.next=w}else Ib=w;Uc(d,e,y(xb.from.line),y(xb.to.line)),U.clientHeight&&(W.style.height=ub.height*Gd()+2*Kd()+"px")}function wc(){var a=0;Tb="",Ub=null,ub.iter(0,ub.size,function(b){var c=b.text;!b.hidden&&c.length>a&&(a=c.length,Tb=c)}),Nb=!1}function xc(a,b,c){function d(d){if(ab(d,b))return d;if(!ab(c,d))return e;var f=d.line+a.length-(c.line-b.line)-1,g=d.ch;return d.line==c.line&&(g+=a[a.length-1].length-(c.ch-(c.line==b.line?b.ch:0))),{line:f,ch:g}}b=Yc(b),c?c=Yc(c):c=b,a=hb(a);var e;return zc(a,b,c,function(a){return e=a,{from:d(xb.from),to:d(xb.to)}}),e}function yc(a,b){zc(hb(a),xb.from,xb.to,function(a){return b=="end"?{from:a,to:a}:b=="start"?{from:xb.from,to:xb.from}:{from:xb.from,to:a}})}function zc(a,b,c,d){var e=a.length==1?a[0].length+b.ch:a[a.length-1].length,f=d({line:b.line+a.length-1,ch:e});rc(b,c,a,f.from,f.to)}function Ac(a,b){var c=a.line,d=b.line;if(c==d)return _b(c).text.slice(a.ch,b.ch);var e=[_b(c).text.slice(a.ch)];return ub.iter(c+1,d,function(a){e.push(a.text)}),e.push(_b(d).text.slice(0,b.ch)),e.join("\n")}function Bc(){return Ac(xb.from,xb.to)}function Dc(){if(Cc)return;qb.set(f.pollInterval,function(){Wd(),Gc(),wb&&Dc(),Xd()})}function Ec(){function b(){Wd();var c=Gc();!c&&!a?(a=!0,qb.set(60,b)):(Cc=!1,Dc()),Xd()}var a=!1;Cc=!0,qb.set(20,b)}function Gc(){if(Kb||!wb||ib(R)||f.readOnly)return!1;var a=R.value;if(a==Fc)return!1;yb=null;var b=0,c=Math.min(Fc.length,a.length);while(b<c&&Fc[b]==a[b])++b;return b<Fc.length?xb.from={line:xb.from.line,ch:xb.from.ch-(Fc.length-b)}:Db&&_(xb.from,xb.to)&&(xb.to={line:xb.to.line,ch:Math.min(_b(xb.to.line).text.length,xb.to.ch+(a.length-b))}),yc(a.slice(b),"end"),a.length>1e3?R.value=Fc="":Fc=a,!0}function Hc(a){_(xb.from,xb.to)?a&&(Fc=R.value=""):(Fc="",R.value=Bc(),$(R))}function Ic(){f.readOnly!="nocursor"&&R.focus()}function Jc(){if(!mb.getBoundingClientRect)return;var a=mb.getBoundingClientRect();if(M&&a.top==a.bottom)return;var b=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(a.top<0||a.bottom>b)&&mb.scrollIntoView()}function Kc(){var a=Ad(xb.inverted?xb.from:xb.to),b=f.lineWrapping?Math.min(a.x,kb.offsetWidth):a.x;return Lc(b,a.y,b,a.yBot)}function Lc(a,b,c,d){var e=Ld(),g=Kd();b+=g,d+=g,a+=e,c+=e;var h=U.clientHeight,i=U.scrollTop,j=!1,k=!0;b<i?(U.scrollTop=Math.max(0,b),j=!0):d>i+h&&(U.scrollTop=d-h,j=!0);var l=U.clientWidth,m=U.scrollLeft,n=f.fixedGutter?cb.clientWidth:0,o=a<n+e+10;return a<m+n||o?(o&&(a=0),U.scrollLeft=Math.max(0,a-10-n),j=!0):c>l+m-3&&(U.scrollLeft=c+10-l,j=!0,c>W.clientWidth&&(k=!1)),j&&f.onScroll&&f.onScroll($b),k}function Mc(){var a=Gd(),b=U.scrollTop-Kd(),c=Math.max(0,Math.floor(b/a)),d=Math.ceil((b+U.clientHeight)/a);return{from:x(ub,c),to:x(ub,d)}}function Nc(a,b){function n(){Ub=U.clientWidth;var a=ob.firstChild,b=!1;return ub.iter(Pb,Qb,function(c){if(!c.hidden){var d=Math.round(a.offsetHeight/k)||1;c.height!=d&&(ac(c,d),Lb=b=!0)}a=a.nextSibling}),b&&(W.style.height=ub.height*k+2*Kd()+"px"),b}if(!U.clientWidth){Pb=Qb=Ob=0;return}var c=Mc();if(a!==!0&&a.length==0&&c.from>Pb&&c.to<Qb)return;var d=Math.max(c.from-100,0),e=Math.min(ub.size,c.to+100);Pb<d&&d-Pb<20&&(d=Pb),Qb>e&&Qb-e<20&&(e=Math.min(ub.size,Qb));var g=a===!0?[]:Oc([{from:Pb,to:Qb,domStart:0}],a),h=0;for(var i=0;i<g.length;++i){var j=g[i];j.from<d&&(j.domStart+=d-j.from,j.from=d),j.to>e&&(j.to=e),j.from>=j.to?g.splice(i--,1):h+=j.to-j.from}if(h==e-d&&d==Pb&&e==Qb)return;g.sort(function(a,b){return a.domStart-b.domStart});var k=Gd(),l=cb.style.display;ob.style.display="none",Pc(d,e,g),ob.style.display=cb.style.display="";var m=d!=Pb||e!=Qb||Rb!=U.clientHeight+k;m&&(Rb=U.clientHeight+k),Pb=d,Qb=e,Ob=y(ub,d),X.style.top=Ob*k+"px",U.clientHeight&&(W.style.height=ub.height*k+2*Kd()+"px");if(ob.childNodes.length!=Qb-Pb)throw new Error("BAD PATCH! "+JSON.stringify(g)+" size="+(Qb-Pb)+" nodes="+ob.childNodes.length);return f.lineWrapping?n():(Ub==null&&(Ub=wd(Tb)),Ub>U.clientWidth?(kb.style.width=Ub+"px",W.style.width="",W.style.width=U.scrollWidth+"px"):kb.style.width=W.style.width=""),cb.style.display=l,(m||Lb)&&Qc()&&f.lineWrapping&&n()&&Qc(),Rc(),!b&&f.onUpdate&&f.onUpdate($b),!0}function Oc(a,b){for(var c=0,d=b.length||0;c<d;++c){var e=b[c],f=[],g=e.diff||0;for(var h=0,i=a.length;h<i;++h){var j=a[h];e.to<=j.from&&e.diff?f.push({from:j.from+g,to:j.to+g,domStart:j.domStart}):e.to<=j.from||e.from>=j.to?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from,domStart:j.domStart}),e.to<j.to&&f.push({from:e.to+g,to:j.to+g,domStart:j.domStart+(e.to-j.from)}))}a=f}return a}function Pc(a,b,c){if(!c.length)ob.innerHTML="";else{function d(a){var b=a.nextSibling;return a.parentNode.removeChild(a),b}var e=0,f=ob.firstChild,g;for(var h=0;h<c.length;++h){var i=c[h];while(i.domStart>e)f=d(f),e++;for(var j=0,k=i.to-i.from;j<k;++j)f=f.nextSibling,e++}while(f)f=d(f)}var l=c.shift(),f=ob.firstChild,j=a,m=document.createElement("div");ub.iter(a,b,function(a){l&&l.to==j&&(l=c.shift());if(!l||l.from>j){if(a.hidden)var b=m.innerHTML="<pre></pre>";else{var b="<pre"+(a.className?' class="'+a.className+'"':"")+">"+a.getHTML(jd)+"</pre>";a.bgClassName&&(b='<div style="position: relative"><pre class="'+a.bgClassName+'" style="position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2"> </pre>'+b+"</div>")}m.innerHTML=b,ob.insertBefore(m.firstChild,f)}else f=f.nextSibling;++j})}function Qc(){if(!f.gutter&&!f.lineNumbers)return;var a=X.offsetHeight,b=U.clientHeight;cb.style.height=(a-b<2?b:a)+"px";var c=[],d=Pb,e;ub.iter(Pb,Math.max(Qb,Pb+1),function(a){if(a.hidden)c.push("<pre></pre>");else{var b=a.gutterMarker,g=f.lineNumbers?d+f.firstLineNumber:null;b&&b.text?g=b.text.replace("%N%",g!=null?g:""):g==null&&(g=" "),c.push(b&&b.style?'<pre class="'+b.style+'">':"<pre>",g);for(var h=1;h<a.height;++h)c.push("<br/> ");c.push("</pre>"),b||(e=d)}++d}),cb.style.display="none",db.innerHTML=c.join("");if(e!=null){var g=db.childNodes[e-Pb],h=String(ub.size).length,i=Z(g),j="";while(i.length+j.length<h)j+=" ";j&&g.insertBefore(document.createTextNode(j),g.firstChild)}cb.style.display="";var k=Math.abs((parseInt(kb.style.marginLeft)||0)-cb.offsetWidth)>2;return kb.style.marginLeft=cb.offsetWidth+"px",Lb=!1,k}function Rc(){var a=_(xb.from,xb.to),b=Ad(xb.from,!0),c=a?b:Ad(xb.to,!0),d=xb.inverted?b:c,e=Gd(),g=Y(A),h=Y(ob);D.style.top=Math.max(0,Math.min(U.offsetHeight,d.y+h.top-g.top))+"px",D.style.left=Math.max(0,Math.min(U.offsetWidth,d.x+h.left-g.left))+"px";if(a)mb.style.top=d.y+"px",mb.style.left=(f.lineWrapping?Math.min(d.x,kb.offsetWidth):d.x)+"px",mb.style.display="",nb.style.display="none";else{var i=b.y==c.y,j="",k=kb.clientWidth||kb.offsetWidth,l=kb.clientHeight||kb.offsetHeight;function m(a,b,c,d){var e=O?"width: "+(c?k-c-a:k)+"px":"right: "+c+"px";j+='<div class="CodeMirror-selected" style="position: absolute; left: '+a+"px; top: "+b+"px; "+e+"; height: "+d+'px"></div>'}if(xb.from.ch&&b.y>=0){var n=i?k-c.x:0;m(b.x,b.y,n,e)}var o=Math.max(0,b.y+(xb.from.ch?e:0)),p=Math.min(c.y,l)-o;p>.2*e&&m(0,o,0,p),(!i||!xb.from.ch)&&c.y<l-.5*e&&m(0,c.y,k-c.x,e),nb.innerHTML=j,mb.style.display="none",nb.style.display=""}}function Sc(a){a?yb=yb||(xb.inverted?xb.to:xb.from):yb=null}function Tc(a,b){var c=yb&&Yc(yb);c&&(ab(c,a)?a=c:ab(b,c)&&(b=c)),Uc(a,b),Gb=!0}function Uc(a,b,c,d){ad=null,c==null&&(c=xb.from.line,d=xb.to.line);if(_(xb.from,a)&&_(xb.to,b))return;if(ab(b,a)){var e=b;b=a,a=e}if(a.line!=c){var g=Vc(a,c,xb.from.ch);g?a=g:ud(a.line,!1)}b.line!=d&&(b=Vc(b,d,xb.to.ch)),_(a,b)?xb.inverted=!1:_(a,xb.to)?xb.inverted=!1:_(b,xb.from)&&(xb.inverted=!0);if(f.autoClearEmptyLines&&_(xb.from,xb.to)){var h=xb.inverted?a:b;if(h.line!=xb.from.line&&xb.from.line<ub.size){var i=_b(xb.from.line);/^\s+$/.test(i.text)&&setTimeout(Zd(function(){if(i.parent&&/^\s+$/.test(i.text)){var a=w(i);xc("",{line:a,ch:0},{line:a,ch:i.text.length})}},10))}}xb.from=a,xb.to=b,Jb=!0}function Vc(a,b,c){function d(b){var d=a.line+b,e=b==1?ub.size:-1;while(d!=e){var g=_b(d);if(!g.hidden){var h=a.ch;if(f||h>c||h>g.text.length)h=g.text.length;return{line:d,ch:h}}d+=b}}var e=_b(a.line),f=a.ch==e.text.length&&a.ch!=c;return e.hidden?a.line>=b?d(1)||d(-1):d(-1)||d(1):a}function Wc(a,b,c){var d=Yc({line:a,ch:b||0});(c?Tc:Uc)(d,d)}function Xc(a){return Math.max(0,Math.min(a,ub.size-1))}function Yc(a){if(a.line<0)return{line:0,ch:0};if(a.line>=ub.size)return{line:ub.size-1,ch:_b(ub.size-1).text.length};var b=a.ch,c=_b(a.line).text.length;return b==null||b>c?{line:a.line,ch:c}:b<0?{line:a.line,ch:0}:a}function Zc(a,b){function g(){for(var b=d+a,c=a<0?-1:ub.size;b!=c;b+=a){var e=_b(b);if(!e.hidden)return d=b,f=e,!0}}function h(b){if(e==(a<0?0:f.text.length)){if(!!b||!g())return!1;e=a<0?f.text.length:0}else e+=a;return!0}var c=xb.inverted?xb.from:xb.to,d=c.line,e=c.ch,f=_b(d);if(b=="char")h();else if(b=="column")h(!0);else if(b=="word"){var i=!1;for(;;){if(a<0&&!h())break;if(gb(f.text.charAt(e)))i=!0;else if(i){a<0&&(a=1,h());break}if(a>0&&!h())break}}return{line:d,ch:e}}function $c(a,b){var c=a<0?xb.from:xb.to;if(yb||_(xb.from,xb.to))c=Zc(a,b);Wc(c.line,c.ch,!0)}function _c(a,b){_(xb.from,xb.to)?a<0?xc("",Zc(a,b),xb.to):xc("",xb.from,Zc(a,b)):xc("",xb.from,xb.to),Gb=!0}function bd(a,b){var c=0,d=Ad(xb.inverted?xb.from:xb.to,!0);ad!=null&&(d.x=ad),b=="page"?c=Math.min(U.clientHeight,window.innerHeight||document.documentElement.clientHeight):b=="line"&&(c=Gd());var e=Bd(d.x,d.y+c*a+2);b=="page"&&(U.scrollTop+=Ad(e,!0).y-d.y),Wc(e.line,e.ch,!0),ad=d.x}function cd(a){var b=_b(a.line).text,c=a.ch,d=a.ch;while(c>0&&gb(b.charAt(c-1)))--c;while(d<b.length&&gb(b.charAt(d)))++d;Tc({line:a.line,ch:c},{line:a.line,ch:d})}function dd(a){Tc({line:a,ch:0},Yc({line:a+1,ch:0}))}function ed(a){if(_(xb.from,xb.to))return fd(xb.from.line,a);var b=xb.to.line-(xb.to.ch?0:1);for(var c=xb.from.line;c<=b;++c)fd(c,a)}function fd(a,b){b||(b="add");if(b=="smart")if(!tb.indent)b="prev";else var c=Sd(a);var d=_b(a),e=d.indentation(f.tabSize),g=d.text.match(/^\s*/)[0],h;b=="prev"?a?h=_b(a-1).indentation(f.tabSize):h=0:b=="smart"?h=tb.indent(c,d.text.slice(g.length),d.text):b=="add"?h=e+f.indentUnit:b=="subtract"&&(h=e-f.indentUnit),h=Math.max(0,h);var i=h-e;if(!i){if(xb.from.line!=a&&xb.to.line!=a)return;var j=g}else{var j="",k=0;if(f.indentWithTabs)for(var l=Math.floor(h/f.tabSize);l;--l)k+=f.tabSize,j+=" ";while(k<h)++k,j+=" "}xc(j,{line:a,ch:0},{line:a,ch:g.length})}function gd(){tb=a.getMode(f,f.mode),ub.iter(0,ub.size,function(a){a.stateAfter=null}),vb=[0],Vd()}function hd(){var a=f.gutter||f.lineNumbers;cb.style.display=a?"":"none",a?Lb=!0:ob.parentNode.style.marginLeft=0}function id(a,b){if(f.lineWrapping){A.className+=" CodeMirror-wrap";var c=U.clientWidth/Jd()-3;ub.iter(0,ub.size,function(a){if(a.hidden)return;var b=Math.ceil(a.text.length/c)||1;b!=1&&ac(a,b)}),kb.style.width=W.style.width=""}else A.className=A.className.replace(" CodeMirror-wrap",""),Ub=null,Tb="",ub.iter(0,ub.size,function(a){a.height!=1&&!a.hidden&&ac(a,1),a.text.length>Tb.length&&(Tb=a.text)});Hb.push({from:0,to:ub.size})}function jd(a){var b=f.tabSize-a%f.tabSize,c=Vb[b];if(c)return c;for(var d='<span class="cm-tab">',e=0;e<b;++e)d+=" ";return Vb[b]={html:d+"</span>",width:b}}function kd(){U.className=U.className.replace(/\s*cm-s-\S+/g,"")+f.theme.replace(/(^|\s)\s*/g," cm-s-")}function ld(){var a=i[f.keyMap].style;A.className=A.className.replace(/\s*cm-keymap-\S+/g,"")+(a?" cm-keymap-"+a:"")}function md(){this.set=[]}function nd(a,b,c){function e(a,b,c,e){_b(a).addMark(new p(b,c,e,d))}a=Yc(a),b=Yc(b);var d=new md;if(!ab(a,b))return d;if(a.line==b.line)e(a.line,a.ch,b.ch,c);else{e(a.line,a.ch,null,c);for(var f=a.line+1,g=b.line;f<g;++f)e(f,null,null,c);e(b.line,null,b.ch,c)}return Hb.push({from:a.line,to:b.line+1}),d}function od(a){a=Yc(a);var b=new q(a.ch);return _b(a.line).addMark(b),b}function pd(a){a=Yc(a);var b=[],c=_b(a.line).marked;if(!c)return b;for(var d=0,e=c.length;d<e;++d){var f=c[d];(f.from==null||f.from<=a.ch)&&(f.to==null||f.to>=a.ch)&&b.push(f.marker||f)}return b}function qd(a,b,c){return typeof a=="number"&&(a=_b(Xc(a))),a.gutterMarker={text:b,style:c},Lb=!0,a}function rd(a){typeof a=="number"&&(a=_b(Xc(a))),a.gutterMarker=null,Lb=!0}function sd(a,b){var c=a,d=a;return typeof a=="number"?d=_b(Xc(a)):c=w(a),c==null?null:b(d,c)?(Hb.push({from:c,to:c+1}),d):null}function td(a,b,c){return sd(a,function(a){if(a.className!=b||a.bgClassName!=c)return a.className=b,a.bgClassName=c,!0})}function ud(a,b){return sd(a,function(a,c){if(a.hidden!=b){a.hidden=b;if(!f.lineWrapping){var d=a.text;b&&d.length==Tb.length?Nb=!0:!b&&d.length>Tb.length&&(Tb=d,Ub=null,Nb=!1)}ac(a,b?0:1);var e=xb.from.line,g=xb.to.line;if(b&&(e==c||g==c)){var h=e==c?Vc({line:e,ch:0},e,0):xb.from,i=g==c?Vc({line:g,ch:0},g,0):xb.to;if(!i)return;Uc(h,i)}return Lb=!0}})}function vd(a){if(typeof a=="number"){if(!Zb(a))return null;var b=a;a=_b(a);if(!a)return null}else{var b=w(a);if(b==null)return null}var c=a.gutterMarker;return{line:b,handle:a,text:a.text,markerText:c&&c.text,markerClass:c&&c.style,lineClass:a.className,bgClass:a.bgClassName}}function wd(a){return lb.innerHTML="<pre><span>x</span></pre>",lb.firstChild.firstChild.firstChild.nodeValue=a,lb.firstChild.firstChild.offsetWidth||10}function xd(a,b){function e(a){return zd(c,a).left}if(b<=0)return 0;var c=_b(a),d=c.text,f=0,g=0,h=d.length,i,j=Math.min(h,Math.ceil(b/Jd()));for(;;){var k=e(j);if(!(k<=b&&j<h)){i=k,h=j;break}j=Math.min(h,Math.ceil(j*1.2))}if(b>i)return h;j=Math.floor(h*.8),k=e(j),k<b&&(f=j,g=k);for(;;){if(h-f<=1)return i-b>b-g?f:h;var l=Math.ceil((f+h)/2),m=e(l);m>b?(h=l,i=m):(f=l,g=m)}}function zd(a,b){if(b==0)return{top:0,left:0};var c=f.lineWrapping&&b<a.text.length&&V.test(a.text.slice(b-1,b+1));lb.innerHTML="<pre>"+a.getHTML(jd,b,yd,c)+"</pre>";var d=document.getElementById(yd),e=d.offsetTop,g=d.offsetLeft;if(M&&e==0&&g==0){var h=document.createElement("span");h.innerHTML="x",d.parentNode.insertBefore(h,d.nextSibling),e=h.offsetTop}return{top:e,left:g}}function Ad(a,b){var c,d=Gd(),e=d*(y(ub,a.line)-(b?Ob:0));if(a.ch==0)c=0;else{var g=zd(_b(a.line),a.ch);c=g.left,f.lineWrapping&&(e+=Math.max(0,g.top))}return{x:c,y:e,yBot:e+d}}function Bd(a,b){function l(a){var b=zd(h,a);if(j){var d=Math.round(b.top/c);return Math.max(0,b.left+(d-k)*U.clientWidth)}return b.left}b<0&&(b=0);var c=Gd(),d=Jd(),e=Ob+Math.floor(b/c),g=x(ub,e);if(g>=ub.size)return{line:ub.size-1,ch:_b(ub.size-1).text.length};var h=_b(g),i=h.text,j=f.lineWrapping,k=j?e-y(ub,g):0;if(a<=0&&k==0)return{line:g,ch:0};var m=0,n=0,o=i.length,p,q=Math.min(o,Math.ceil((a+k*U.clientWidth*.9)/d));for(;;){var r=l(q);if(!(r<=a&&q<o)){p=r,o=q;break}q=Math.min(o,Math.ceil(q*1.2))}if(a>p)return{line:g,ch:o};q=Math.floor(o*.8),r=l(q),r<a&&(m=q,n=r);for(;;){if(o-m<=1)return{line:g,ch:p-a>a-n?m:o};var s=Math.ceil((m+o)/2),t=l(s);t>a?(o=s,p=t):(m=s,n=t)}}function Cd(a){var b=Ad(a,!0),c=Y(kb);return{x:c.left+b.x,y:c.top+b.y,yBot:c.top+b.yBot}}function Gd(){if(Fd==null){Fd="<pre>";for(var a=0;a<49;++a)Fd+="x<br/>";Fd+="x</pre>"}var b=ob.clientHeight;return b==Ed?Dd:(Ed=b,lb.innerHTML=Fd,Dd=lb.firstChild.offsetHeight/50||1,lb.innerHTML="",Dd)}function Jd(){return U.clientWidth==Id?Hd:(Id=U.clientWidth,Hd=wd("x"))}function Kd(){return kb.offsetTop}function Ld(){return kb.offsetLeft}function Md(a,b){var c=Y(U,!0),d,e;try{d=a.clientX,e=a.clientY}catch(a){return null}if(!b&&(d-c.left>U.clientWidth||e-c.top>U.clientHeight))return null;var f=Y(kb,!0);return Bd(d-f.left,e-f.top)}function Nd(a){function f(){var a=hb(R.value).join("\n");a!=e&&Zd(yc)(a,"end"),D.style.position="relative",R.style.cssText=d,N&&(U.scrollTop=c),Kb=!1,Hc(!0),Dc()}var b=Md(a),c=U.scrollTop;if(!b||window.opera)return;(_(xb.from,xb.to)||ab(b,xb.from)||!ab(b,xb.to))&&Zd(Wc)(b.line,b.ch);var d=R.style.cssText;D.style.position="absolute",R.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(a.clientY-5)+"px; left: "+(a.clientX-5)+"px; z-index: 1000; background: white; "+"border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",Kb=!0;var e=R.value=Bc();Ic(),$(R);if(L){E(a);var g=I(window,"mouseup",function(){g(),setTimeout(f,20)},!0)}else setTimeout(f,50)}function Od(){clearInterval(sb);var a=!0;mb.style.visibility="",sb=setInterval(function(){mb.style.visibility=(a=!a)?"":"hidden"},650)}function Qd(a){function p(a,b,c){if(!a.text)return;var d=a.styles,e=g?0:a.text.length-1,f;for(var i=g?0:d.length-2,j=g?d.length:-2;i!=j;i+=2*h){var k=d[i];if(d[i+1]!=null&&d[i+1]!=m){e+=h*k.length;continue}for(var l=g?0:k.length-1,p=g?k.length:-1;l!=p;l+=h,e+=h)if(e>=b&&e<c&&o.test(f=k.charAt(l))){var q=Pd[f];if(q.charAt(1)==">"==g)n.push(f);else{if(n.pop()!=q.charAt(0))return{pos:e,match:!1};if(!n.length)return{pos:e,match:!0}}}}}var b=xb.inverted?xb.from:xb.to,c=_b(b.line),d=b.ch-1,e=d>=0&&Pd[c.text.charAt(d)]||Pd[c.text.charAt(++d)];if(!e)return;var f=e.charAt(0),g=e.charAt(1)==">",h=g?1:-1,i=c.styles;for(var j=d+1,k=0,l=i.length;k<l;k+=2)if((j-=i[k].length)<=0){var m=i[k+1];break}
|
13
13
|
var n=[c.text.charAt(d)],o=/[(){}[\]]/;for(var k=b.line,l=g?Math.min(k+100,ub.size):Math.max(-1,k-100);k!=l;k+=h){var c=_b(k),q=k==b.line,r=p(c,q&&g?d+1:0,q&&!g?d:c.text.length);if(r)break}r||(r={pos:null,match:!1});var m=r.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",s=nd({line:b.line,ch:d},{line:b.line,ch:d+1},m),t=r.pos!=null&&nd({line:k,ch:r.pos},{line:k,ch:r.pos+1},m),u=Zd(function(){s.clear(),t&&t.clear()});a?setTimeout(u,800):Sb=u}function Rd(a){var b,c;for(var d=a,e=a-40;d>e;--d){if(d==0)return 0;var g=_b(d-1);if(g.stateAfter)return d;var h=g.indentation(f.tabSize);if(c==null||b>h)c=d-1,b=h}return c}function Sd(a){var b=Rd(a),c=b&&_b(b-1).stateAfter;return c?c=m(tb,c):c=n(tb),ub.iter(b,a,function(a){a.highlight(tb,c,f.tabSize),a.stateAfter=m(tb,c)}),b<a&&Hb.push({from:b,to:a}),a<ub.size&&!_b(a).stateAfter&&vb.push(a),c}function Td(a,b){var c=Sd(a);ub.iter(a,b,function(a){a.highlight(tb,c,f.tabSize),a.stateAfter=m(tb,c)})}function Ud(){var a=+(new Date)+f.workTime,b=vb.length;while(vb.length){if(!_b(Pb).stateAfter)var c=Pb;else var c=vb.pop();if(c>=ub.size)continue;var d=Rd(c),e=d&&_b(d-1).stateAfter;e?e=m(tb,e):e=n(tb);var g=0,h=tb.compareStates,i=!1,j=d,k=!1;ub.iter(j,ub.size,function(b){var d=b.stateAfter;if(+(new Date)>a)return vb.push(j),Vd(f.workDelay),i&&Hb.push({from:c,to:j+1}),k=!0;var l=b.highlight(tb,e,f.tabSize);l&&(i=!0),b.stateAfter=m(tb,e);var n=null;if(h){var o=d&&h(d,e);o!=K&&(n=!!o)}n==null&&(l!==!1||!d?g=0:++g>3&&(!tb.indent||tb.indent(d,"")==tb.indent(e,""))&&(n=!0));if(n)return!0;++j});if(k)return;i&&Hb.push({from:c,to:j+1})}b&&f.onHighlightComplete&&f.onHighlightComplete($b)}function Vd(a){if(!vb.length)return;rb.set(a,Zd(Ud))}function Wd(){Fb=Gb=Ib=null,Hb=[],Jb=!1,Mb=[]}function Xd(){var a=!1,b;Nb&&wc(),Jb&&(a=!Kc()),Hb.length?b=Nc(Hb,!0):(Jb&&Rc(),Lb&&Qc()),a&&Kc(),Jb&&(Jc(),Od()),wb&&!Kb&&(Fb===!0||Fb!==!1&&Jb)&&Hc(Gb),Jb&&f.matchBrackets&&setTimeout(Zd(function(){Sb&&(Sb(),Sb=null),_(xb.from,xb.to)&&Qd(!1)}),20);var c=Ib,d=Mb;Jb&&f.onCursorActivity&&f.onCursorActivity($b),c&&f.onChange&&$b&&f.onChange($b,c);for(var e=0;e<d.length;++e)d[e]($b);b&&f.onUpdate&&f.onUpdate($b)}function Zd(a){return function(){Yd++||Wd();try{var b=a.apply(this,arguments)}finally{--Yd||Xd()}return b}}function $d(a){Wb.startCompound();try{return a()}finally{Wb.endCompound()}}var f={},o=a.defaults;for(var s in o)o.hasOwnProperty(s)&&(f[s]=(e&&e.hasOwnProperty(s)?e:o)[s]);var A=document.createElement("div");A.className="CodeMirror"+(f.lineWrapping?" CodeMirror-wrap":""),A.innerHTML='<div style="overflow: hidden; position: relative; width: 3px; height: 0px;"><textarea style="position: absolute; padding: 0; width: 1px; height: 1em" wrap="off" autocorrect="off" autocapitalize="off"></textarea></div><div class="CodeMirror-scroll" tabindex="-1"><div style="position: relative"><div style="position: relative"><div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div><div class="CodeMirror-lines"><div style="position: relative; z-index: 0"><div style="position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden;"></div><pre class="CodeMirror-cursor"> </pre><div style="position: relative; z-index: -1"></div><div></div></div></div></div></div></div>',d.appendChild?d.appendChild(A):d(A);var D=A.firstChild,R=D.firstChild,U=A.lastChild,W=U.firstChild,X=W.firstChild,cb=X.firstChild,db=cb.firstChild,kb=cb.nextSibling.firstChild,lb=kb.firstChild,mb=lb.nextSibling,nb=mb.nextSibling,ob=nb.nextSibling;kd(),ld(),b&&(R.style.width="0px"),P||(kb.draggable=!0),kb.style.outline="none",f.tabindex!=null&&(R.tabIndex=f.tabindex),f.autofocus&&Ic(),!f.gutter&&!f.lineNumbers&&(cb.style.display="none"),S&&(D.style.height="1px",D.style.position="absolute");try{wd("x")}catch(pb){throw pb.message.match(/runtime/i)&&(pb=new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)")),pb}var qb=new J,rb=new J,sb,tb,ub=new u([new t([new r("")])]),vb,wb;gd();var xb={from:{line:0,ch:0},to:{line:0,ch:0},inverted:!1},yb,zb,Ab,Bb=0,Cb,Db=!1,Eb=!1,Fb,Gb,Hb,Ib,Jb,Kb,Lb,Mb,Nb,Ob=0,Pb=0,Qb=0,Rb=0,Sb,Tb="",Ub,Vb={};Zd(function(){bc(f.value||""),Fb=!1})();var Wb=new z;I(U,"mousedown",Zd(dc)),I(U,"dblclick",Zd(ec)),I(kb,"selectstart",C),L||I(U,"contextmenu",Nd),I(U,"scroll",function(){Bb=U.scrollTop,Nc([]),f.fixedGutter&&(cb.style.left=U.scrollLeft+"px"),f.onScroll&&f.onScroll($b)}),I(window,"resize",function(){Nc(!0)}),I(R,"keyup",Zd(oc)),I(R,"input",Ec),I(R,"keydown",Zd(mc)),I(R,"keypress",Zd(nc)),I(R,"focus",pc),I(R,"blur",qc);if(f.dragDrop){I(kb,"dragstart",gc);function Xb(a){if(f.onDragEvent&&f.onDragEvent($b,B(a)))return;E(a)}I(U,"dragenter",Xb),I(U,"dragover",Xb),I(U,"drop",Zd(fc))}I(U,"paste",function(){Ic(),Ec()}),I(R,"paste",Ec),I(R,"cut",Zd(function(){f.readOnly||yc("")})),S&&I(W,"mouseup",function(){document.activeElement==R&&R.blur(),Ic()});var Yb;try{Yb=document.activeElement==R}catch(pb){}Yb||f.autofocus?setTimeout(pc,20):qc();var $b=A.CodeMirror={getValue:cc,setValue:Zd(bc),getSelection:Bc,replaceSelection:Zd(yc),focus:function(){window.focus(),Ic(),pc(),Ec()},setOption:function(a,b){var c=f[a];f[a]=b,a=="mode"||a=="indentUnit"?gd():a=="readOnly"&&b=="nocursor"?(qc(),R.blur()):a=="readOnly"&&!b?Hc(!0):a=="theme"?kd():a=="lineWrapping"&&c!=b?Zd(id)():a=="tabSize"?Nc(!0):a=="keyMap"&&ld();if(a=="lineNumbers"||a=="gutter"||a=="firstLineNumber"||a=="theme")hd(),Nc(!0)},getOption:function(a){return f[a]},undo:Zd(tc),redo:Zd(uc),indentLine:Zd(function(a,b){typeof b!="string"&&(b==null?b=f.smartIndent?"smart":"prev":b=b?"add":"subtract"),Zb(a)&&fd(a,b)}),indentSelection:Zd(ed),historySize:function(){return{undo:Wb.done.length,redo:Wb.undone.length}},clearHistory:function(){Wb=new z},matchBrackets:Zd(function(){Qd(!0)}),getTokenAt:Zd(function(a){return a=Yc(a),_b(a.line).getTokenAt(tb,Sd(a.line),a.ch)}),getStateAfter:function(a){return a=Xc(a==null?ub.size-1:a),Sd(a+1)},cursorCoords:function(a,b){return a==null&&(a=xb.inverted),this.charCoords(a?xb.from:xb.to,b)},charCoords:function(a,b){return a=Yc(a),b=="local"?Ad(a,!1):b=="div"?Ad(a,!0):Cd(a)},coordsChar:function(a){var b=Y(kb);return Bd(a.x-b.left,a.y-b.top)},markText:Zd(nd),setBookmark:od,findMarksAt:pd,setMarker:Zd(qd),clearMarker:Zd(rd),setLineClass:Zd(td),hideLine:Zd(function(a){return ud(a,!0)}),showLine:Zd(function(a){return ud(a,!1)}),onDeleteLine:function(a,b){if(typeof a=="number"){if(!Zb(a))return null;a=_b(a)}return(a.handlers||(a.handlers=[])).push(b),a},lineInfo:vd,addWidget:function(a,b,c,d,e){a=Ad(Yc(a));var f=a.yBot,g=a.x;b.style.position="absolute",W.appendChild(b);if(d=="over")f=a.y;else if(d=="near"){var h=Math.max(U.offsetHeight,ub.height*Gd()),i=Math.max(W.clientWidth,kb.clientWidth)-Ld();a.yBot+b.offsetHeight>h&&a.y>b.offsetHeight&&(f=a.y-b.offsetHeight),g+b.offsetWidth>i&&(g=i-b.offsetWidth)}b.style.top=f+Kd()+"px",b.style.left=b.style.right="",e=="right"?(g=W.clientWidth-b.offsetWidth,b.style.right="0px"):(e=="left"?g=0:e=="middle"&&(g=(W.clientWidth-b.offsetWidth)/2),b.style.left=g+Ld()+"px"),c&&Lc(g,f,g+b.offsetWidth,f+b.offsetHeight)},lineCount:function(){return ub.size},clipPos:Yc,getCursor:function(a){return a==null&&(a=xb.inverted),bb(a?xb.from:xb.to)},somethingSelected:function(){return!_(xb.from,xb.to)},setCursor:Zd(function(a,b,c){b==null&&typeof a.line=="number"?Wc(a.line,a.ch,c):Wc(a,b,c)}),setSelection:Zd(function(a,b,c){(c?Tc:Uc)(Yc(a),Yc(b||a))}),getLine:function(a){if(Zb(a))return _b(a).text},getLineHandle:function(a){if(Zb(a))return _b(a)},setLine:Zd(function(a,b){Zb(a)&&xc(b,{line:a,ch:0},{line:a,ch:_b(a).text.length})}),removeLine:Zd(function(a){Zb(a)&&xc("",{line:a,ch:0},Yc({line:a+1,ch:0}))}),replaceRange:Zd(xc),getRange:function(a,b){return Ac(Yc(a),Yc(b))},triggerOnKeyDown:Zd(mc),execCommand:function(a){return h[a]($b)},moveH:Zd($c),deleteH:Zd(_c),moveV:Zd(bd),toggleOverwrite:function(){Db?(Db=!1,mb.className=mb.className.replace(" CodeMirror-overwrite","")):(Db=!0,mb.className+=" CodeMirror-overwrite")},posFromIndex:function(a){var b=0,c;return ub.iter(0,ub.size,function(d){var e=d.text.length+1;if(e>a)return c=a,!0;a-=e,++b}),Yc({line:b,ch:c})},indexFromPos:function(a){if(a.line<0||a.ch<0)return 0;var b=a.ch;return ub.iter(0,a.line,function(a){b+=a.text.length+1}),b},scrollTo:function(a,b){a!=null&&(U.scrollLeft=a),b!=null&&(U.scrollTop=b),Nc([])},operation:function(a){return Zd(a)()},compoundChange:function(a){return $d(a)},refresh:function(){Nc(!0),U.scrollHeight>Bb&&(U.scrollTop=Bb)},getInputField:function(){return R},getWrapperElement:function(){return A},getScrollerElement:function(){return U},getGutterElement:function(){return cb}},kc=null,lc,Cc=!1,Fc="",ad=null;md.prototype.clear=Zd(function(){var a=Infinity,b=-Infinity;for(var c=0,d=this.set.length;c<d;++c){var e=this.set[c],f=e.marked;if(!f||!e.parent)continue;var g=w(e);a=Math.min(a,g),b=Math.max(b,g);for(var h=0;h<f.length;++h)f[h].marker==this&&f.splice(h--,1)}a!=Infinity&&Hb.push({from:a,to:b+1})}),md.prototype.find=function(){var a,b;for(var c=0,d=this.set.length;c<d;++c){var e=this.set[c],f=e.marked;for(var g=0;g<f.length;++g){var h=f[g];if(h.marker==this)if(h.from!=null||h.to!=null){var i=w(e);i!=null&&(h.from!=null&&(a={line:i,ch:h.from}),h.to!=null&&(b={line:i,ch:h.to}))}}}return{from:a,to:b}};var yd="CodeMirror-temp-"+Math.floor(Math.random()*16777215).toString(16),Dd,Ed,Fd,Hd,Id=0,Pd={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},Yd=0;for(var _d in g)g.propertyIsEnumerable(_d)&&!$b.propertyIsEnumerable(_d)&&($b[_d]=g[_d]);return $b}function j(a){return typeof a=="string"?i[a]:a}function k(a,b,c,d,e){function f(b){b=j(b);var c=b[a];if(c!=null&&d(c))return!0;if(b.nofallthrough)return e&&e(),!0;var g=b.fallthrough;if(g==null)return!1;if(Object.prototype.toString.call(g)!="[object Array]")return f(g);for(var h=0,i=g.length;h<i;++h)if(f(g[h]))return!0;return!1}return b&&f(b)?!0:f(c)}function l(a){var b=jb[H(a,"keyCode")];return b=="Ctrl"||b=="Alt"||b=="Shift"||b=="Mod"}function m(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function n(a,b,c){return a.startState?a.startState(b,c):!0}function o(a,b){this.pos=this.start=0,this.string=a,this.tabSize=b||8}function p(a,b,c,d){this.from=a,this.to=b,this.style=c,this.marker=d}function q(a){this.from=a,this.to=a,this.line=null}function r(a,b){this.styles=b||[a,null],this.text=a,this.height=1,this.marked=this.gutterMarker=this.className=this.bgClassName=this.handlers=null,this.stateAfter=this.parent=this.hidden=null}function s(a,b,c,d){for(var e=0,f=0,g=0;f<b;e+=2){var h=c[e],i=f+h.length;g==0?(i>a&&d.push(h.slice(a-f,Math.min(h.length,b-f)),c[e+1]),i>=a&&(g=1)):g==1&&(i>b?d.push(h.slice(0,b-f),c[e+1]):d.push(h,c[e+1])),f=i}}function t(a){this.lines=a,this.parent=null;for(var b=0,c=a.length,d=0;b<c;++b)a[b].parent=this,d+=a[b].height;this.height=d}function u(a){this.children=a;var b=0,c=0;for(var d=0,e=a.length;d<e;++d){var f=a[d];b+=f.chunkSize(),c+=f.height,f.parent=this}this.size=b,this.height=c,this.parent=null}function v(a,b){while(!a.lines)for(var c=0;;++c){var d=a.children[c],e=d.chunkSize();if(b<e){a=d;break}b-=e}return a.lines[b]}function w(a){if(a.parent==null)return null;var b=a.parent,c=fb(b.lines,a);for(var d=b.parent;d;b=d,d=d.parent)for(var e=0,f=d.children.length;;++e){if(d.children[e]==b)break;c+=d.children[e].chunkSize()}return c}function x(a,b){var c=0;a:do{for(var d=0,e=a.children.length;d<e;++d){var f=a.children[d],g=f.height;if(b<g){a=f;continue a}b-=g,c+=f.chunkSize()}return c}while(!a.lines);for(var d=0,e=a.lines.length;d<e;++d){var h=a.lines[d],i=h.height;if(b<i)break;b-=i}return c+d}function y(a,b){var c=0;a:do{for(var d=0,e=a.children.length;d<e;++d){var f=a.children[d],g=f.chunkSize();if(b<g){a=f;continue a}b-=g,c+=f.height}return c}while(!a.lines);for(var d=0;d<b;++d)c+=a.lines[d].height;return c}function z(){this.time=0,this.done=[],this.undone=[],this.compound=0,this.closed=!1}function A(){E(this)}function B(a){return a.stop||(a.stop=A),a}function C(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function D(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function E(a){C(a),D(a)}function F(a){return a.target||a.srcElement}function G(a){if(a.which)return a.which;if(a.button&1)return 1;if(a.button&2)return 3;if(a.button&4)return 2}function H(a,b){var c=a.override&&a.override.hasOwnProperty(b);return c?a.override[b]:a[b]}function I(a,b,c,d){if(typeof a.addEventListener=="function"){a.addEventListener(b,c,!1);if(d)return function(){a.removeEventListener(b,c,!1)}}else{var e=function(a){c(a||window.event)};a.attachEvent("on"+b,e);if(d)return function(){a.detachEvent("on"+b,e)}}}function J(){this.id=null}function W(a,b,c){b==null&&(b=a.search(/[^\s\u00a0]/),b==-1&&(b=a.length));for(var d=0,e=0;d<b;++d)a.charAt(d)==" "?e+=c-e%c:++e;return e}function X(a){return a.currentStyle?a.currentStyle:window.getComputedStyle(a,null)}function Y(a,b){var c=a.ownerDocument.body,d=0,e=0,f=!1;for(var g=a;g;g=g.offsetParent){var h=g.offsetLeft,i=g.offsetTop;g==c?(d+=Math.abs(h),e+=Math.abs(i)):(d+=h,e+=i),b&&X(g).position=="fixed"&&(f=!0)}var j=b&&!f?null:c;for(var g=a.parentNode;g!=j;g=g.parentNode)g.scrollLeft!=null&&(d-=g.scrollLeft,e-=g.scrollTop);return{left:d,top:e}}function Z(a){return a.textContent||a.innerText||a.nodeValue||""}function $(a){b?(a.selectionStart=0,a.selectionEnd=a.value.length):a.select()}function _(a,b){return a.line==b.line&&a.ch==b.ch}function ab(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function bb(a){return{line:a.line,ch:a.ch}}function db(a){return cb.textContent=a,cb.innerHTML}function eb(a,b){if(!b)return 0;if(!a)return b.length;for(var c=a.length,d=b.length;c>=0&&d>=0;--c,--d)if(a.charAt(c)!=b.charAt(d))break;return d+1}function fb(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c<d;++c)if(a[c]==b)return c;return-1}function gb(a){return/\w/.test(a)||a.toUpperCase()!=a.toLowerCase()}a.defaults={value:"",mode:null,theme:"default",indentUnit:2,indentWithTabs:!1,smartIndent:!0,tabSize:4,keyMap:"default",extraKeys:null,electricChars:!0,autoClearEmptyLines:!1,onKeyEvent:null,onDragEvent:null,lineWrapping:!1,lineNumbers:!1,gutter:!1,fixedGutter:!1,firstLineNumber:1,readOnly:!1,dragDrop:!0,onChange:null,onCursorActivity:null,onGutterClick:null,onHighlightComplete:null,onUpdate:null,onFocus:null,onBlur:null,onScroll:null,matchBrackets:!1,workTime:100,workDelay:200,pollInterval:100,undoDepth:40,tabindex:null,autofocus:null};var b=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),c=b||/Mac/.test(navigator.platform),d=/Win/.test(navigator.platform),e=a.modes={},f=a.mimeModes={};a.defineMode=function(b,c){!a.defaults.mode&&b!="null"&&(a.defaults.mode=b);if(arguments.length>2){c.dependencies=[];for(var d=2;d<arguments.length;++d)c.dependencies.push(arguments[d])}e[b]=c},a.defineMIME=function(a,b){f[a]=b},a.resolveMode=function(b){if(typeof b=="string"&&f.hasOwnProperty(b))b=f[b];else if(typeof b=="string"&&/^[\w\-]+\/[\w\-]+\+xml$/.test(b))return a.resolveMode("application/xml");return typeof b=="string"?{name:b}:b||{name:"null"}},a.getMode=function(b,c){var c=a.resolveMode(c),d=e[c.name];return d?d(b,c):a.getMode(b,"text/plain")},a.listModes=function(){var a=[];for(var b in e)e.propertyIsEnumerable(b)&&a.push(b);return a},a.listMIMEs=function(){var a=[];for(var b in f)f.propertyIsEnumerable(b)&&a.push({mime:b,mode:f[b]});return a};var g=a.extensions={};a.defineExtension=function(a,b){g[a]=b};var h=a.commands={selectAll:function(a){a.setSelection({line:0,ch:0},{line:a.lineCount()-1})},killLine:function(a){var b=a.getCursor(!0),c=a.getCursor(!1),d=!_(b,c);!d&&a.getLine(b.line).length==b.ch?a.replaceRange("",b,{line:b.line+1,ch:0}):a.replaceRange("",b,d?c:{line:b.line})},deleteLine:function(a){var b=a.getCursor().line;a.replaceRange("",{line:b,ch:0},{line:b})},undo:function(a){a.undo()},redo:function(a){a.redo()},goDocStart:function(a){a.setCursor(0,0,!0)},goDocEnd:function(a){a.setSelection({line:a.lineCount()-1},null,!0)},goLineStart:function(a){a.setCursor(a.getCursor().line,0,!0)},goLineStartSmart:function(a){var b=a.getCursor(),c=a.getLine(b.line),d=Math.max(0,c.search(/\S/));a.setCursor(b.line,b.ch<=d&&b.ch?0:d,!0)},goLineEnd:function(a){a.setSelection({line:a.getCursor().line},null,!0)},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,"char")},goCharRight:function(a){a.moveH(1,"char")},goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goWordRight:function(a){a.moveH(1,"word")},delCharLeft:function(a){a.deleteH(-1,"char")},delCharRight:function(a){a.deleteH(1,"char")},delWordLeft:function(a){a.deleteH(-1,"word")},delWordRight:function(a){a.deleteH(1,"word")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},insertTab:function(a){a.replaceSelection(" ","end")},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.replaceSelection(" ","end")},transposeChars:function(a){var b=a.getCursor(),c=a.getLine(b.line);b.ch>0&&b.ch<c.length-1&&a.replaceRange(c.charAt(b.ch)+c.charAt(b.ch-1),{line:b.line,ch:b.ch-1},{line:b.line,ch:b.ch+1})},newlineAndIndent:function(a){a.replaceSelection("\n","end"),a.indentLine(a.getCursor().line)},toggleOverwrite:function(a){a.toggleOverwrite()}},i=a.keyMap={};i.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharRight",Backspace:"delCharLeft",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite"},i.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goWordLeft","Ctrl-Right":"goWordRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delWordLeft","Ctrl-Delete":"delWordRight","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore",fallthrough:"basic"},i.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goWordLeft","Alt-Right":"goWordRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delWordLeft","Ctrl-Alt-Backspace":"delWordRight","Alt-Delete":"delWordRight","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore",fallthrough:["basic","emacsy"]},i["default"]=c?i.macDefault:i.pcDefault,i.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageUp","Shift-Ctrl-V":"goPageDown","Ctrl-D":"delCharRight","Ctrl-H":"delCharLeft","Alt-D":"delWordRight","Alt-Backspace":"delWordLeft","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},a.fromTextArea=function(b,c){function d(){b.value=h.getValue()}c||(c={}),c.value=b.value,!c.tabindex&&b.tabindex&&(c.tabindex=b.tabindex),c.autofocus==null&&b.getAttribute("autofocus")!=null&&(c.autofocus=!0);if(b.form){var e=I(b.form,"submit",d,!0);if(typeof b.form.submit=="function"){var f=b.form.submit;function g(){d(),b.form.submit=f,b.form.submit(),b.form.submit=g}b.form.submit=g}}b.style.display="none";var h=a(function(a){b.parentNode.insertBefore(a,b.nextSibling)},c);return h.save=d,h.getTextArea=function(){return b},h.toTextArea=function(){d(),b.parentNode.removeChild(h.getWrapperElement()),b.style.display="",b.form&&(e(),typeof b.form.submit=="function"&&(b.form.submit=f))},h},a.copyState=m,a.startState=n,o.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)},next:function(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)},eat:function(a){var b=this.string.charAt(this.pos);if(typeof a=="string")var c=b==a;else var c=b&&(a.test?a.test(b):a(b));if(c)return++this.pos,b},eatWhile:function(a){var b=this.pos;while(this.eat(a));return this.pos>b},eatSpace:function(){var a=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);if(b>-1)return this.pos=b,!0},backUp:function(a){this.pos-=a},column:function(){return W(this.string,this.start,this.tabSize)},indentation:function(){return W(this.string,null,this.tabSize)},match:function(a,b,c){if(typeof a!="string"){var e=this.string.slice(this.pos).match(a);return e&&b!==!1&&(this.pos+=e[0].length),e}function d(a){return c?a.toLowerCase():a}if(d(this.string).indexOf(d(a),this.pos)==this.pos)return b!==!1&&(this.pos+=a.length),!0},current:function(){return this.string.slice(this.start,this.pos)}},a.StringStream=o,p.prototype={attach:function(a){this.marker.set.push(a)},detach:function(a){var b=fb(this.marker.set,a);b>-1&&this.marker.set.splice(b,1)},split:function(a,b){if(this.to<=a&&this.to!=null)return null;var c=this.from<a||this.from==null?null:this.from-a+b,d=this.to==null?null:this.to-a+b;return new p(c,d,this.style,this.marker)},dup:function(){return new p(null,null,this.style,this.marker)},clipTo:function(a,b,c,d,e){a&&d>this.from&&(d<this.to||this.to==null)?this.from=null:this.from!=null&&this.from>=b&&(this.from=Math.max(d,this.from)+e),c&&(b<this.to||this.to==null)&&(b>this.from||this.from==null)?this.to=null:this.to!=null&&this.to>b&&(this.to=d<this.to?this.to+e:b)},isDead:function(){return this.from!=null&&this.to!=null&&this.from>=this.to},sameSet:function(a){return this.marker==a.marker}},q.prototype={attach:function(a){this.line=a},detach:function(a){this.line==a&&(this.line=null)},split:function(a,b){if(a<this.from)return this.from=this.to=this.from-a+b,this},isDead:function(){return this.from>this.to},clipTo:function(a,b,c,d,e){(a||b<this.from)&&(c||d>this.to)?(this.from=0,this.to=-1):this.from>b&&(this.from=this.to=Math.max(d,this.from)+e)},sameSet:function(a){return!1},find:function(){return!this.line||!this.line.parent?null:{line:w(this.line),ch:this.from}},clear:function(){if(this.line){var a=fb(this.line.marked,this);a!=-1&&this.line.marked.splice(a,1),this.line=null}}},r.inheritMarks=function(a,b){var c=new r(a),d=b&&b.marked;if(d)for(var e=0;e<d.length;++e)if(d[e].to==null&&d[e].style){var f=c.marked||(c.marked=[]),g=d[e],h=g.dup();f.push(h),h.attach(c)}return c},r.prototype={replace:function(a,b,c){var d=[],e=this.marked,f=b==null?this.text.length:b;s(0,a,this.styles,d),c&&d.push(c,null),s(f,this.text.length,this.styles,d),this.styles=d,this.text=this.text.slice(0,a)+c+this.text.slice(f),this.stateAfter=null;if(e){var g=c.length-(f-a);for(var h=0;h<e.length;++h){var i=e[h];i.clipTo(a==null,a||0,b==null,f,g),i.isDead()&&(i.detach(this),e.splice(h--,1))}}},split:function(a,b){var c=[b,null],d=this.marked;s(a,this.text.length,this.styles,c);var e=new r(b+this.text.slice(a),c);if(d)for(var f=0;f<d.length;++f){var g=d[f],h=g.split(a,b.length);h&&(e.marked||(e.marked=[]),e.marked.push(h),h.attach(e),h==g&&d.splice(f--,1))}return e},append:function(a){var b=this.text.length,c=a.marked,d=this.marked;this.text+=a.text,s(0,a.text.length,a.styles,this.styles);if(d)for(var e=0;e<d.length;++e)d[e].to==null&&(d[e].to=b);if(c&&c.length){d||(this.marked=d=[]);a:for(var e=0;e<c.length;++e){var f=c[e];if(!f.from)for(var g=0;g<d.length;++g){var h=d[g];if(h.to==b&&h.sameSet(f)){h.to=f.to==null?null:f.to+b,h.isDead()&&(h.detach(this),c.splice(e--,1));continue a}}d.push(f),f.attach(this),f.from+=b,f.to!=null&&(f.to+=b)}}},fixMarkEnds:function(a){var b=this.marked,c=a.marked;if(!b)return;for(var d=0;d<b.length;++d){var e=b[d],f=e.to==null;if(f&&c)for(var g=0;g<c.length;++g)if(c[g].sameSet(e)){f=!1;break}f&&(e.to=this.text.length)}},fixMarkStarts:function(){var a=this.marked;if(!a)return;for(var b=0;b<a.length;++b)a[b].from==null&&(a[b].from=0)},addMark:function(a){a.attach(this),this.marked==null&&(this.marked=[]),this.marked.push(a),this.marked.sort(function(a,b){return(a.from||0)-(b.from||0)})},highlight:function(a,b,c){var d=new o(this.text,c),e=this.styles,f=0,g=!1,h=e[0],i;this.text==""&&a.blankLine&&a.blankLine(b);while(!d.eol()){var j=a.token(d,b),k=this.text.slice(d.start,d.pos);d.start=d.pos,f&&e[f-1]==j?e[f-2]+=k:k&&(!g&&(e[f+1]!=j||f&&e[f-2]!=i)&&(g=!0),e[f++]=k,e[f++]=j,i=h,h=e[f]);if(d.pos>5e3){e[f++]=this.text.slice(d.pos),e[f++]=null;break}}return e.length!=f&&(e.length=f,g=!0),f&&e[f-2]!=i&&(g=!0),g||(e.length<5&&this.text.length<10?null:!1)},getTokenAt:function(a,b,c){var d=this.text,e=new o(d);while(e.pos<c&&!e.eol()){e.start=e.pos;var f=a.token(e,b)}return{start:e.start,end:e.pos,string:e.current(),className:f||null,state:b}},indentation:function(a){return W(this.text,null,a)},getHTML:function(a,b,c,d){function h(b,c){if(!b)return;f&&M&&b.charAt(0)==" "&&(b=" "+b.slice(1)),f=!1;if(b.indexOf(" ")==-1){g+=b.length;var d=db(b)}else{var d="";for(var h=0;;){var i=b.indexOf(" ",h);if(i==-1){d+=db(b.slice(h)),g+=b.length-h;break}g+=i-h;var j=a(g);d+=db(b.slice(h,i))+j.html,g+=j.width,h=i+1}}c?e.push('<span class="',c,'">',d,"</span>"):e.push(d)}function p(a){return a?"cm-"+a.replace(/ +/g," cm-"):null}var e=[],f=!0,g=0,i=h;if(b!=null){var j=0,k='<span id="'+c+'">';i=function(a,c){var f=a.length;if(b>=j&&b<j+f){b>j&&(h(a.slice(0,b-j),c),d&&e.push("<wbr>")),e.push(k);var g=b-j;h(window.opera?a.slice(g,g+1):a.slice(g),c),e.push("</span>"),window.opera&&h(a.slice(g+1),c),b--,j+=f}else j+=f,h(a,c),j==b&&j==o?e.push(k+" </span>"):j>b+10&&/\s/.test(a)&&(i=function(){})}}var l=this.styles,m=this.text,n=this.marked,o=m.length;if(!m&&b==null)i(" ");else if(!n||!n.length)for(var q=0,r=0;r<o;q+=2){var s=l[q],t=l[q+1],u=s.length;r+u>o&&(s=s.slice(0,o-r)),r+=u,i(s,p(t))}else{var v=0,q=0,w="",t,x=0,y=n[0].from||0,z=[],A=0;function B(){var a;while(A<n.length&&((a=n[A]).from==v||a.from==null))a.style!=null&&z.push(a),++A;y=A<n.length?n[A].from:Infinity;for(var b=0;b<z.length;++b){var c=z[b].to||Infinity;c==v?z.splice(b--,1):y=Math.min(c,y)}}var C=0;while(v<o){y==v&&B();var D=Math.min(o,y);for(;;){if(w){var E=v+w.length,F=t;for(var G=0;G<z.length;++G)F=(F?F+" ":"")+z[G].style;i(E>D?w.slice(0,D-v):w,F);if(E>=D){w=w.slice(D-v),v=D;break}v=E}w=l[q++],t=p(l[q++])}}}return e.join("")},cleanUp:function(){this.parent=null;if(this.marked)for(var a=0,b=this.marked.length;a<b;++a)this.marked[a].detach(this)}},t.prototype={chunkSize:function(){return this.lines.length},remove:function(a,b,c){for(var d=a,e=a+b;d<e;++d){var f=this.lines[d];this.height-=f.height,f.cleanUp();if(f.handlers)for(var g=0;g<f.handlers.length;++g)c.push(f.handlers[g])}this.lines.splice(a,b)},collapse:function(a){a.splice.apply(a,[a.length,0].concat(this.lines))},insertHeight:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0,e=b.length;d<e;++d)b[d].parent=this},iterN:function(a,b,c){for(var d=a+b;a<d;++a)if(c(this.lines[a]))return!0}},u.prototype={chunkSize:function(){return this.size},remove:function(a,b,c){this.size-=b;for(var d=0;d<this.children.length;++d){var e=this.children[d],f=e.chunkSize();if(a<f){var g=Math.min(b,f-a),h=e.height;e.remove(a,g,c),this.height-=h-e.height,f==g&&(this.children.splice(d--,1),e.parent=null);if((b-=g)==0)break;a=0}else a-=f}if(this.size-b<25){var i=[];this.collapse(i),this.children=[new t(i)],this.children[0].parent=this}},collapse:function(a){for(var b=0,c=this.children.length;b<c;++b)this.children[b].collapse(a)},insert:function(a,b){var c=0;for(var d=0,e=b.length;d<e;++d)c+=b[d].height;this.insertHeight(a,b,c)},insertHeight:function(a,b,c){this.size+=b.length,this.height+=c;for(var d=0,e=this.children.length;d<e;++d){var f=this.children[d],g=f.chunkSize();if(a<=g){f.insertHeight(a,b,c);if(f.lines&&f.lines.length>50){while(f.lines.length>50){var h=f.lines.splice(f.lines.length-25,25),i=new t(h);f.height-=i.height,this.children.splice(d+1,0,i),i.parent=this}this.maybeSpill()}break}a-=g}},maybeSpill:function(){if(this.children.length<=10)return;var a=this;do{var b=a.children.splice(a.children.length-5,5),c=new u(b);if(!a.parent){var d=new u(a.children);d.parent=a,a.children=[d,c],a=d}else{a.size-=c.size,a.height-=c.height;var e=fb(a.parent.children,a);a.parent.children.splice(e+1,0,c)}c.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()},iter:function(a,b,c){this.iterN(a,b-a,c)},iterN:function(a,b,c){for(var d=0,e=this.children.length;d<e;++d){var f=this.children[d],g=f.chunkSize();if(a<g){var h=Math.min(b,g-a);if(f.iterN(a,h,c))return!0;if((b-=h)==0)break;a=0}else a-=g}}},z.prototype={addChange:function(a,b,c){this.undone.length=0;var d=+(new Date),e=this.done[this.done.length-1],f=e&&e[e.length-1],g=d-this.time;if(this.compound&&e&&!this.closed)e.push({start:a,added:b,old:c});else if(g>400||!f||this.closed||f.start>a+c.length||f.start+f.added<a)this.done.push([{start:a,added:b,old:c}]),this.closed=!1;else{var h=Math.max(0,f.start-a),i=Math.max(0,a+c.length-(f.start+f.added));for(var j=h;j>0;--j)f.old.unshift(c[j-1]);for(var j=i;j>0;--j)f.old.push(c[c.length-j]);h&&(f.start=a),f.added+=b-(c.length-h-i)}this.time=d},startCompound:function(){this.compound++||(this.closed=!0)},endCompound:function(){--this.compound||(this.closed=!0)}},a.e_stop=E,a.e_preventDefault=C,a.e_stopPropagation=D,a.connect=I,J.prototype={set:function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)}};var K=a.Pass={toString:function(){return"CodeMirror.Pass"}},L=/gecko\/\d{7}/i.test(navigator.userAgent),M=/MSIE \d/.test(navigator.userAgent),N=/MSIE [1-8]\b/.test(navigator.userAgent),O=M&&document.documentMode==5,P=/WebKit\//.test(navigator.userAgent),Q=/Chrome\//.test(navigator.userAgent),R=/Apple Computer/.test(navigator.vendor),S=/KHTML\//.test(navigator.userAgent),T=function(){if(N)return!1;var a=document.createElement("div");return"draggable"in a||"dragDrop"in a}(),U=function(){var a=document.createElement("textarea");return a.value="foo\nbar",a.value.indexOf("\r")>-1?"\r\n":"\n"}(),V=/^$/;L?V=/$'/:R?V=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/:Q&&(V=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/),document.documentElement.getBoundingClientRect!=null&&(Y=function(a,b){try{var c=a.getBoundingClientRect();c={top:c.top,left:c.left}}catch(d){c={top:0,left:0}}if(!b)if(window.pageYOffset==null){var e=document.documentElement||document.body.parentNode;e.scrollTop==null&&(e=document.body),c.top+=e.scrollTop,c.left+=e.scrollLeft}else c.top+=window.pageYOffset,c.left+=window.pageXOffset;return c});var cb=document.createElement("pre");db("a")=="\na"?db=function(a){return cb.textContent=a,cb.innerHTML.slice(1)}:db(" ")!=" "&&(db=function(a){return cb.innerHTML="",cb.appendChild(document.createTextNode(a)),cb.innerHTML}),a.htmlEscape=db;var hb="\n\nb".split(/\n/).length!=3?function(a){var b=0,c,d=[];while((c=a.indexOf("\n",b))>-1)d.push(a.slice(b,a.charAt(c-1)=="\r"?c-1:c)),b=c+1;return d.push(a.slice(b)),d}:function(a){return a.split(/\r?\n/)};a.splitLines=hb;var ib=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return!b||b.parentElement()!=a?!1:b.compareEndPoints("StartToEnd",b)!=0};a.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),a.defineMIME("text/plain","null");var jb={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};return a.keyNames=jb,function(){for(var a=0;a<10;a++)jb[a+48]=String(a);for(var a=65;a<=90;a++)jb[a]=String.fromCharCode(a);for(var a=1;a<=12;a++)jb[a+111]=jb[a+63235]="F"+a}(),a}();CodeMirror.defineMode("coffeescript",function(
|
14
14
|
a){function c(a){return new RegExp("^(("+a.join(")|(")+"))\\b")}function r(a,c){if(a.sol()){var k=c.scopes[0].offset;if(a.eatSpace()){var l=a.indentation();return l>k?"indent":l<k?"dedent":null}k>0&&v(a,c)}if(a.eatSpace())return null;var p=a.peek();if(a.match("####"))return a.skipToEnd(),"comment";if(a.match("###"))return c.tokenize=t,c.tokenize(a,c);if(p==="#")return a.skipToEnd(),"comment";if(a.match(/^-?[0-9\.]/,!1)){var r=!1;a.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)&&(r=!0),a.match(/^-?\d+\.\d*/)&&(r=!0),a.match(/^-?\.\d+/)&&(r=!0);if(r)return a.peek()=="."&&a.backUp(1),"number";var u=!1;a.match(/^-?0x[0-9a-f]+/i)&&(u=!0),a.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)&&(u=!0),a.match(/^-?0(?![\dx])/i)&&(u=!0);if(u)return"number"}if(a.match(n))return c.tokenize=s(a.current(),"string"),c.tokenize(a,c);if(a.match(o)){if(a.current()!="/"||a.match(/^.*\//,!1))return c.tokenize=s(a.current(),"string-2"),c.tokenize(a,c);a.backUp(1)}return a.match(h)||a.match(g)?"punctuation":a.match(f)||a.match(d)||a.match(j)?"operator":a.match(e)?"punctuation":a.match(q)?"atom":a.match(m)?"keyword":a.match(i)?"variable":(a.next(),b)}function s(c,d){var e=c.length==1;return function(g,h){while(!g.eol()){g.eatWhile(/[^'"\/\\]/);if(g.eat("\\")){g.next();if(e&&g.eol())return d}else{if(g.match(c))return h.tokenize=r,d;g.eat(/['"\/]/)}}return e&&(a.mode.singleLineStringErrors?d=b:h.tokenize=r),d}}function t(a,b){while(!a.eol()){a.eatWhile(/[^#]/);if(a.match("###")){b.tokenize=r;break}a.eatWhile("#")}return"comment"}function u(b,c,d){d=d||"coffee";var e=0;if(d==="coffee"){for(var f=0;f<c.scopes.length;f++)if(c.scopes[f].type==="coffee"){e=c.scopes[f].offset+a.indentUnit;break}}else e=b.column()+b.current().length;c.scopes.unshift({offset:e,type:d})}function v(a,b){if(b.scopes.length==1)return;if(b.scopes[0].type==="coffee"){var c=a.indentation(),d=-1;for(var e=0;e<b.scopes.length;++e)if(c===b.scopes[e].offset){d=e;break}if(d===-1)return!0;while(b.scopes[0].offset!==c)b.scopes.shift();return!1}return b.scopes.shift(),!1}function w(a,c){var d=c.tokenize(a,c),e=a.current();if(e===".")return d=c.tokenize(a,c),e=a.current(),d==="variable"?"variable":b;if(e==="@")return a.eat("@"),"keyword";e==="return"&&(c.dedent+=1),((e==="->"||e==="=>")&&!c.lambda&&c.scopes[0].type=="coffee"&&a.peek()===""||d==="indent")&&u(a,c);var f="[({".indexOf(e);return f!==-1&&u(a,c,"])}".slice(f,f+1)),k.exec(e)&&u(a,c),e=="then"&&v(a,c),d==="dedent"&&v(a,c)?b:(f="])}".indexOf(e),f!==-1&&v(a,c)?b:(c.dedent>0&&a.eol()&&c.scopes[0].type=="coffee"&&(c.scopes.length>1&&c.scopes.shift(),c.dedent-=1),d))}var b="error",d=new RegExp("^[\\+\\-\\*/%&|\\^~<>!?]"),e=new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"),f=new RegExp("^((->)|(=>)|(\\+\\+)|(\\+\\=)|(\\-\\-)|(\\-\\=)|(\\*\\*)|(\\*\\=)|(\\/\\/)|(\\/\\=)|(==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//))"),g=new RegExp("^((\\.\\.)|(\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"),h=new RegExp("^((\\.\\.\\.)|(//=)|(>>=)|(<<=)|(\\*\\*=))"),i=new RegExp("^[_A-Za-z$][_A-Za-z$0-9]*"),j=c(["and","or","not","is","isnt","in","instanceof","typeof"]),k=["for","while","loop","if","unless","else","switch","try","catch","finally","class"],l=["break","by","continue","debugger","delete","do","in","of","new","return","then","this","throw","when","until"],m=c(k.concat(l));k=c(k);var n=new RegExp("^('{3}|\"{3}|['\"])"),o=new RegExp("^(/{3}|/)"),p=["Infinity","NaN","undefined","null","true","false","on","off","yes","no"],q=c(p),x={startState:function(a){return{tokenize:r,scopes:[{offset:a||0,type:"coffee"}],lastToken:null,lambda:!1,dedent:0}},token:function(a,b){var c=w(a,b);return b.lastToken={style:c,content:a.current()},a.eol()&&a.lambda&&(b.lambda=!1),c},indent:function(a,b){return a.tokenize!=r?0:a.scopes[0].offset}};return x}),CodeMirror.defineMIME("text/x-coffeescript","coffeescript"),CodeMirror.defineMode("javascript",function(a,b){function g(a,b,c){return b.tokenize=c,c(a,b)}function h(a,b){var c=!1,d;while((d=a.next())!=null){if(d==b&&!c)return!1;c=!c&&d=="\\"}return c}function k(a,b,c){return i=a,j=c,b}function l(a,b){var c=a.next();if(c=='"'||c=="'")return g(a,b,m(c));if(/[\[\]{}\(\),;\:\.]/.test(c))return k(c);if(c=="0"&&a.eat(/x/i))return a.eatWhile(/[\da-f]/i),k("number","number");if(/\d/.test(c))return a.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),k("number","number");if(c=="/")return a.eat("*")?g(a,b,n):a.eat("/")?(a.skipToEnd(),k("comment","comment")):b.reAllowed?(h(a,"/"),a.eatWhile(/[gimy]/),k("regexp","string-2")):(a.eatWhile(f),k("operator",null,a.current()));if(c=="#")return a.skipToEnd(),k("error","error");if(f.test(c))return a.eatWhile(f),k("operator",null,a.current());a.eatWhile(/[\w\$_]/);var d=a.current(),i=e.propertyIsEnumerable(d)&&e[d];return i&&b.kwAllowed?k(i.type,i.style,d):k("variable","variable",d)}function m(a){return function(b,c){return h(b,a)||(c.tokenize=l),k("string","string")}}function n(a,b){var c=!1,d;while(d=a.next()){if(d=="/"&&c){b.tokenize=l;break}c=d=="*"}return k("comment","comment")}function p(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,d!=null&&(this.align=d)}function q(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0}function r(a,b,c,e,f){var g=a.cc;s.state=a,s.stream=f,s.marked=null,s.cc=g,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);for(;;){var h=g.length?g.pop():d?D:C;if(h(c,e)){while(g.length&&g[g.length-1].lex)g.pop()();return s.marked?s.marked:c=="variable"&&q(a,e)?"variable-2":b}}}function t(){for(var a=arguments.length-1;a>=0;a--)s.cc.push(arguments[a])}function u(){return t.apply(null,arguments),!0}function v(a){var b=s.state;if(b.context){s.marked="def";for(var c=b.localVars;c;c=c.next)if(c.name==a)return;b.localVars={name:a,next:b.localVars}}}function x(){s.state.context||(s.state.localVars=w),s.state.context={prev:s.state.context,vars:s.state.localVars}}function y(){s.state.localVars=s.state.context.vars,s.state.context=s.state.context.prev}function z(a,b){var c=function(){var c=s.state;c.lexical=new p(c.indented,s.stream.column(),a,null,c.lexical,b)};return c.lex=!0,c}function A(){var a=s.state;a.lexical.prev&&(a.lexical.type==")"&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function B(a){return function(c){return c==a?u():a==";"?t():u(arguments.callee)}}function C(a){return a=="var"?u(z("vardef"),L,B(";"),A):a=="keyword a"?u(z("form"),D,C,A):a=="keyword b"?u(z("form"),C,A):a=="{"?u(z("}"),K,A):a==";"?u():a=="function"?u(R):a=="for"?u(z("form"),B("("),z(")"),N,B(")"),A,C,A):a=="variable"?u(z("stat"),G):a=="switch"?u(z("form"),D,z("}","switch"),B("{"),K,A,A):a=="case"?u(D,B(":")):a=="default"?u(B(":")):a=="catch"?u(z("form"),x,B("("),S,B(")"),C,A,y):t(z("stat"),D,B(";"),A)}function D(a){return o.hasOwnProperty(a)?u(F):a=="function"?u(R):a=="keyword c"?u(E):a=="("?u(z(")"),E,B(")"),A,F):a=="operator"?u(D):a=="["?u(z("]"),J(D,"]"),A,F):a=="{"?u(z("}"),J(I,"}"),A,F):u()}function E(a){return a.match(/[;\}\)\],]/)?t():t(D)}function F(a,b){if(a=="operator"&&/\+\+|--/.test(b))return u(F);if(a=="operator"||a==":")return u(D);if(a==";")return;if(a=="(")return u(z(")"),J(D,")"),A,F);if(a==".")return u(H,F);if(a=="[")return u(z("]"),D,B("]"),A,F)}function G(a){return a==":"?u(A,C):t(F,B(";"),A)}function H(a){if(a=="variable")return s.marked="property",u()}function I(a){a=="variable"&&(s.marked="property");if(o.hasOwnProperty(a))return u(B(":"),D)}function J(a,b){function c(d){return d==","?u(a,c):d==b?u():u(B(b))}return function(e){return e==b?u():t(a,c)}}function K(a){return a=="}"?u():t(C,K)}function L(a,b){return a=="variable"?(v(b),u(M)):u()}function M(a,b){if(b=="=")return u(D,M);if(a==",")return u(L)}function N(a){return a=="var"?u(L,P):a==";"?t(P):a=="variable"?u(O):t(P)}function O(a,b){return b=="in"?u(D):u(F,P)}function P(a,b){return a==";"?u(Q):b=="in"?u(D):u(D,B(";"),Q)}function Q(a){a!=")"&&u(D)}function R(a,b){if(a=="variable")return v(b),u(R);if(a=="(")return u(z(")"),x,J(S,")"),A,C,y)}function S(a,b){if(a=="variable")return v(b),u()}var c=a.indentUnit,d=b.json,e=function(){function a(a){return{type:a,style:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("operator"),f={type:"atom",style:"atom"};return{"if":b,"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":d,"delete":d,"throw":d,"var":a("var"),"const":a("var"),let:a("var"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":e,"typeof":e,"instanceof":e,"true":f,"false":f,"null":f,"undefined":f,NaN:f,Infinity:f}}(),f=/[+\-*&%=<>!?|]/,i,j,o={atom:!0,number:!0,variable:!0,string:!0,regexp:!0},s={state:null,column:null,marked:null,cc:null},w={name:"this",next:{name:"arguments"}};return A.lex=!0,{startState:function(a){return{tokenize:l,reAllowed:!0,kwAllowed:!0,cc:[],lexical:new p((a||0)-c,0,"block",!1),localVars:b.localVars,context:b.localVars&&{vars:b.localVars},indented:0}},token:function(a,b){a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation());if(a.eatSpace())return null;var c=b.tokenize(a,b);return i=="comment"?c:(b.reAllowed=i=="operator"||i=="keyword c"||!!i.match(/^[\[{}\(,;:]$/),b.kwAllowed=i!=".",r(b,c,i,j,a))},indent:function(a,b){if(a.tokenize!=l)return 0;var d=b&&b.charAt(0),e=a.lexical;e.type=="stat"&&d=="}"&&(e=e.prev);var f=e.type,g=d==f;return f=="vardef"?e.indented+4:f=="form"&&d=="{"?e.indented:f=="stat"||f=="form"?e.indented+c:e.info=="switch"&&!g?e.indented+(/^(?:case|default)\b/.test(b)?c:2*c):e.align?e.column+(g?0:1):e.indented+(g?0:c)},electricChars:":{}"}}),CodeMirror.defineMIME("text/javascript","javascript"),CodeMirror.defineMIME("application/json",{name:"javascript",json:!0}),CodeMirror.defineMode("xml",function(a,b){function h(a,b){function c(c){return b.tokenize=c,c(a,b)}var d=a.next();if(d=="<"){if(a.eat("!"))return a.eat("[")?a.match("CDATA[")?c(k("atom","]]>")):null:a.match("--")?c(k("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),c(l(1))):null;if(a.eat("?"))return a.eatWhile(/[\w\._\-]/),b.tokenize=k("meta","?>"),"meta";g=a.eat("/")?"closeTag":"openTag",a.eatSpace(),f="";var e;while(e=a.eat(/[^\s\u00a0=<>\"\'\/?]/))f+=e;return b.tokenize=i,"tag"}if(d=="&"){var h;return a.eat("#")?a.eat("x")?h=a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):h=a.eatWhile(/[\d]/)&&a.eat(";"):h=a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),h?"atom":"error"}return a.eatWhile(/[^&<]/),null}function i(a,b){var c=a.next();return c==">"||c=="/"&&a.eat(">")?(b.tokenize=h,g=c==">"?"endTag":"selfcloseTag","tag"):c=="="?(g="equals",null):/[\'\"]/.test(c)?(b.tokenize=j(c),b.tokenize(a,b)):(a.eatWhile(/[^\s\u00a0=<>\"\'\/?]/),"word")}function j(a){return function(b,c){while(!b.eol())if(b.next()==a){c.tokenize=i;break}return"string"}}function k(a,b){return function(c,d){while(!c.eol()){if(c.match(b)){d.tokenize=h;break}c.next()}return a}}function l(a){return function(b,c){var d;while((d=b.next())!=null){if(d=="<")return c.tokenize=l(a+1),c.tokenize(b,c);if(d==">"){if(a==1){c.tokenize=h;break}return c.tokenize=l(a-1),c.tokenize(b,c)}}return"meta"}}function o(){for(var a=arguments.length-1;a>=0;a--)m.cc.push(arguments[a])}function p(){return o.apply(null,arguments),!0}function q(a,b){var c=d.doNotIndent.hasOwnProperty(a)||m.context&&m.context.noIndent;m.context={prev:m.context,tagName:a,indent:m.indented,startOfLine:b,noIndent:c}}function r(){m.context&&(m.context=m.context.prev)}function s(a){if(a=="openTag")return m.tagName=f,p(w,t(m.startOfLine));if(a=="closeTag"){var b=!1;return m.context?m.context.tagName!=f&&(d.implicitlyClosed.hasOwnProperty(m.context.tagName.toLowerCase())&&r(),b=!m.context||m.context.tagName!=f):b=!0,b&&(n="error"),p(u(b))}return p()}function t(a){return function(b){return b=="selfcloseTag"||b=="endTag"&&d.autoSelfClosers.hasOwnProperty(m.tagName.toLowerCase())?(v(m.tagName.toLowerCase()),p()):b=="endTag"?(v(m.tagName.toLowerCase()),q(m.tagName,a),p()):p()}}function u(a){return function(b){return a&&(n="error"),b=="endTag"?(r(),p()):(n="error",p(arguments.callee))}}function v(a){var b;for(;;){if(!m.context)return;b=m.context.tagName.toLowerCase();if(!d.contextGrabbers.hasOwnProperty(b)||!d.contextGrabbers[b].hasOwnProperty(a))return;r()}}function w(a){return a=="word"?(n="attribute",p(x,w)):a=="endTag"||a=="selfcloseTag"?o():(n="error",p(w))}function x(a){return a=="equals"?p(y,w):(d.allowMissing||(n="error"),a=="endTag"||a=="selfcloseTag"?o():p())}function y(a){return a=="string"?p(z):a=="word"&&d.allowUnquoted?(n="string",p()):(n="error",a=="endTag"||a=="selfCloseTag"?o():p())}function z(a){return a=="string"?p(z):o()}var c=a.indentUnit,d=b.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!1}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1},e=b.alignCDATA,f,g,m,n;return{startState:function(){return{tokenize:h,cc:[],indented:0,startOfLine:!0,tagName:null,context:null}},token:function(a,b){a.sol()&&(b.startOfLine=!0,b.indented=a.indentation());if(a.eatSpace())return null;n=g=f=null;var c=b.tokenize(a,b);b.type=g;if((c||g)&&c!="comment"){m=b;for(;;){var d=b.cc.pop()||s;if(d(g||c))break}}return b.startOfLine=!1,n||c},indent:function(a,b,d){var f=a.context;if(a.tokenize!=i&&a.tokenize!=h||f&&f.noIndent)return d?d.match(/^(\s*)/)[0].length:0;if(e&&/<!\[CDATA\[/.test(b))return 0;f&&/^<\//.test(b)&&(f=f.prev);while(f&&!f.startOfLine)f=f.prev;return f?f.indent+c:0},compareStates:function(a,b){if(a.indented!=b.indented||a.tokenize!=b.tokenize)return!1;for(var c=a.context,d=b.context;;c=c.prev,d=d.prev){if(!c||!d)return c==d;if(c.tagName!=d.tagName)return!1}},electricChars:"/"}}),CodeMirror.defineMIME("application/xml","xml"),CodeMirror.mimeModes.hasOwnProperty("text/html")||CodeMirror.defineMIME("text/html",{name:"xml",htmlMode:!0}),CodeMirror.defineMode("htmlmixed",function(a,b){function f(a,b){var f=c.token(a,b.htmlState);return f=="tag"&&a.current()==">"&&b.htmlState.context&&(/^script$/i.test(b.htmlState.context.tagName)?(b.token=h,b.localState=d.startState(c.indent(b.htmlState,"")),b.mode="javascript"):/^style$/i.test(b.htmlState.context.tagName)&&(b.token=i,b.localState=e.startState(c.indent(b.htmlState,"")),b.mode="css")),f}function g(a,b,c){var d=a.current(),e=d.search(b);return e>-1&&a.backUp(d.length-e),c}function h(a,b){return a.match(/^<\/\s*script\s*>/i,!1)?(b.token=f,b.localState=null,b.mode="html",f(a,b)):g(a,/<\/\s*script\s*>/,d.token(a,b.localState))}function i(a,b){return a.match(/^<\/\s*style\s*>/i,!1)?(b.token=f,b.localState=null,b.mode="html",f(a,b)):g(a,/<\/\s*style\s*>/,e.token(a,b.localState))}var c=CodeMirror.getMode(a,{name:"xml",htmlMode:!0}),d=CodeMirror.getMode(a,"javascript"),e=CodeMirror.getMode(a,"css");return{startState:function(){var a=c.startState();return{token:f,localState:null,mode:"html",htmlState:a}},copyState:function(a){if(a.localState)var b=CodeMirror.copyState(a.token==i?e:d,a.localState);return{token:a.token,localState:b,mode:a.mode,htmlState:CodeMirror.copyState(c,a.htmlState)}},token:function(a,b){return b.token(a,b)},indent:function(a,b){return a.token==f||/^\s*<\//.test(b)?c.indent(a.htmlState,b):a.token==h?d.indent(a.localState,b):e.indent(a.localState,b)},compareStates:function(a,b){return a.mode!=b.mode?!1:a.localState?CodeMirror.Pass:c.compareStates(a.htmlState,b.htmlState)},electricChars:"/{}:"}},"xml","javascript","css"),CodeMirror.defineMIME("text/html","htmlmixed"),CodeMirror.defineMode("css",function(a){function d(a,b){return c=b,a}function e(a,b){var c=a.next();if(c=="@")return a.eatWhile(/[\w\\\-]/),d("meta",a.current());if(c=="/"&&a.eat("*"))return b.tokenize=f,f(a,b);if(c=="<"&&a.eat("!"))return b.tokenize=g,g(a,b);if(c!="=")return c!="~"&&c!="|"||!a.eat("=")?c=='"'||c=="'"?(b.tokenize=h(c),b.tokenize(a,b)):c=="#"?(a.eatWhile(/[\w\\\-]/),d("atom","hash")):c=="!"?(a.match(/^\s*\w*/),d("keyword","important")):/\d/.test(c)?(a.eatWhile(/[\w.%]/),d("number","unit")):/[,.+>*\/]/.test(c)?d(null,"select-op"):/[;{}:\[\]]/.test(c)?d(null,c):(a.eatWhile(/[\w\\\-]/),d("variable","variable")):d(null,"compare");d(null,"compare")}function f(a,b){var c=!1,f;while((f=a.next())!=null){if(c&&f=="/"){b.tokenize=e;break}c=f=="*"}return d("comment","comment")}function g(a,b){var c=0,f;while((f=a.next())!=null){if(c>=2&&f==">"){b.tokenize=e;break}c=f=="-"?c+1:0}return d("comment","comment")}function h(a){return function(b,c){var f=!1,g;while((g=b.next())!=null){if(g==a&&!f)break;f=!f&&g=="\\"}return f||(c.tokenize=e),d("string","string")}}var b=a.indentUnit,c;return{startState:function(a){return{tokenize:e,baseIndent:a||0,stack:[]}},token:function(a,b){if(a.eatSpace())return null;var d=b.tokenize(a,b),e=b.stack[b.stack.length-1];if(c=="hash"&&e!="rule")d="string-2";else if(d=="variable")if(e=="rule")d="number";else if(!e||e=="@media{")d="tag";return e=="rule"&&/^[\{\};]$/.test(c)&&b.stack.pop(),c=="{"?e=="@media"?b.stack[b.stack.length-1]="@media{":b.stack.push("{"):c=="}"?b.stack.pop():c=="@media"?b.stack.push("@media"):e=="{"&&c!="comment"&&b.stack.push("rule"),d},indent:function(a,c){var d=a.stack.length;return/^\}/.test(c)&&(d-=a.stack[a.stack.length-1]=="rule"?2:1),a.baseIndent+d*b},electricChars:"}"}}),CodeMirror.defineMIME("text/css","css"),CodeMirror.defineMode("css",function(a){function d(a,b){return c=b,a}function f(a){for(var b=0;b<e.length;b++)if(a===e[b])return!0}function g(a,b){var c=a.next();if(c=="@")return a.eatWhile(/[\w\-]/),d("meta",a.current());if(c=="/"&&a.eat("*"))return b.tokenize=i,i(a,b);if(c=="<"&&a.eat("!"))return b.tokenize=j,j(a,b);if(c!="=")return c!="~"&&c!="|"||!a.eat("=")?c=='"'||c=="'"?(b.tokenize=k(c),b.tokenize(a,b)):c=="/"?a.eat("/")?(b.tokenize=h,h(a,b)):(a.eatWhile(/[\a-zA-Z0-9\-_.\s]/),/\/|\)|#/.test(a.peek()||a.eol()||a.eatSpace()&&a.peek()==")")?d("string","string"):d("number","unit")):c=="!"?(a.match(/^\s*\w*/),d("keyword","important")):/\d/.test(c)?(a.eatWhile(/[\w.%]/),d("number","unit")):/[,+<>*\/]/.test(c)?d(null,"select-op"):/[;{}:\[\]()]/.test(c)?c==":"?(a.eatWhile(/[active|hover|link|visited]/),a.current().match(/active|hover|link|visited/)?d("tag","tag"):d(null,c)):d(null,c):c=="."?(a.eatWhile(/[\a-zA-Z0-9\-_]/),d("tag","tag")):c=="#"?(a.eatWhile(/[A-Za-z0-9]/),a.current().length===4||a.current().length===7?a.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false)!=null?a.current().substring(1)!=a.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false)?d("atom","tag"):(a.eatSpace(),/[\/<>.(){!$%^&*_\-\\?=+\|#'~`]/.test(a.peek())?d("atom","tag"):a.peek()=="}"?d("number","unit"):/[a-zA-Z\\]/.test(a.peek())?d("atom","tag"):a.eol()?d("atom","tag"):d("number","unit")):(a.eatWhile(/[\w\\\-]/),d("atom","tag")):(a.eatWhile(/[\w\\\-]/),d("atom","tag"))):c=="&"?(a.eatWhile(/[\w\-]/),d(null,c)):(a.eatWhile(/[\w\\\-_%.{]/),a.current().match(/http|https/)!=null?(a.eatWhile(/[\w\\\-_%.{:\/]/),d("string","string")):a.peek()=="<"||a.peek()==">"?d("tag","tag"):a.peek().match(/\(/)!=null?d(null,c):a.peek()=="/"&&b.stack[b.stack.length-1]!=undefined?d("string","string"):a.current().match(/\-\d|\-.\d/)?d("number","unit"):f(a.current())?d("tag","tag"):/\/|[\s\)]/.test(a.peek()||a.eol()||a.eatSpace()&&a.peek()=="/")&&a.current().indexOf(".")!==-1?a.current().substring(a.current().length-1,a.current().length)=="{"?(a.backUp(1),d("tag","tag")):a.eatSpace()&&a.peek().match(/[{<>.a-zA-Z]/)!=null||a.eol()?d("tag","tag"):d("string","string"):a.eol()?(a.current().substring(a.current().length-1,a.current().length)=="{"&&a.backUp(1),d("tag","tag")):d("variable","variable")):d(null,"compare");d(null,"compare")}function h(a,b){return a.skipToEnd(),b.tokenize=g,d("comment","comment")}function i(a,b){var c=!1,e;while((e=a.next())!=null){if(c&&e=="/"){b.tokenize=g;break}c=e=="*"}return d("comment","comment")}function j(a,b){var c=0,e;while((e=a.next())!=null){if(c>=2&&e==">"){b.tokenize=g;break}c=e=="-"?c+1:0}return d("comment","comment")}function k(a){return function(b,c){var e=!1,f;while((f=b.next())!=null){if(f==a&&!e)break;e=!e&&f=="\\"}return e||(c.tokenize=g),d("string","string")}}var b=a.indentUnit,c,e=["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","keygen","kbd","label","legend","li","link","map","mark","menu","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr"];return{startState:function(a){return{tokenize:g,baseIndent:a||0,stack:[]}},token:function(a,b){if(a.eatSpace())return null;var d=b.tokenize(a,b),e=b.stack[b.stack.length-1];if(c=="hash"&&e=="rule")d="atom";else if(d=="variable")if(e=="rule")d=null;else if(!e||e=="@media{")d=a.current()=="when"?"variable":a.string.match(/#/g)!=undefined?null:/[\s,|\s\)]/.test(a.peek())?"tag":null;return e=="rule"&&/^[\{\};]$/.test(c)&&b.stack.pop(),c=="{"?e=="@media"?b.stack[b.stack.length-1]="@media{":b.stack.push("{"):c=="}"?b.stack.pop():c=="@media"?b.stack.push("@media"):e=="{"&&c!="comment"&&b.stack.push("rule"),d},indent:function(a,c){var d=a.stack.length;return/^\}/.test(c)&&(d-=a.stack[a.stack.length-1]=="rule"?2:1),a.baseIndent+d*b},electricChars:"}"}}),CodeMirror.defineMIME("text/x-less","less"),CodeMirror.mimeModes.hasOwnProperty("text/css")||CodeMirror.defineMIME("text/css","less"),function(){function f(){c=""}function g(a){c+=a}function h(b){return function(c){a+=b}}function i(){var b=parseInt(a);return a="",b||1}function j(a){for(var b=0,c=i();b<c;++b)a(b,b==c-1)}function k(a){return typeof a=="string"&&(a=CodeMirror.commands[a]),function(b){j(function(){a(b)})}}function l(a,b){for(var c in a)a.hasOwnProperty(c)&&b(c,a[c])}function m(a,b){for(var c in a)b(a[c])}function n(a){return a.slice(0,6)=="Shift-"?a.slice(0,1):a=="Space"?" ":a.length==3&&a[0]=="'"&&a[2]=="'"?a[1]:a.toLowerCase()}function p(a){if(a==" ")return"Space";var b=o.indexOf(a);return b!=-1?"'"+a+"'":a.toLowerCase()==a?a.toUpperCase():"Shift-"+a.toUpperCase()}function s(a,b,c,d){var e=0,f=-1;c>0&&(e=a.length,f=0);var g=e,h=e;a:for(;b!=e;b+=c)for(var i=0;i<d.length;++i)if(d[i].test(a.charAt(b+f))){g=b;for(;b!=e;b+=c)if(!d[i].test(a.charAt(b+f)))break;h=b;break a}return{from:Math.min(g,h),to:Math.max(g,h)}}function t(a,b,c,d){var e=a.getCursor(),f=e.ch,g=a.getLine(e.line),h;for(;;){h=s(g,f,c,b),f=h[d=="end"?"to":"from"];if(f!=e.ch||h.from==h.to)break;f=h[c<0?"from":"to"]}a.setCursor(e.line,h[d=="end"?"to":"from"],!0)}function u(a){var b=a.getCursor(),c=b.ch,d=a.getLine(b.line);CodeMirror.commands.goLineEnd(a),b.line!=a.lineCount()&&(CodeMirror.commands.goLineEnd(a),a.replaceSelection(" ","end"),CodeMirror.commands.delCharRight(a))}function v(a,b){var c=e[b];if(c===undefined)return;var d=a.getCursor().line,f=c>d?d:c,h=c>d?c:d;a.setCursor(f);for(var i=f;i<=h;i++)g("\n"+a.getLine(f)),a.removeLine(f)}function w(a,b){var c=e[b];if(c===undefined)return;var d=a.getCursor().line,f=c>d?d:c,h=c>d?c:d;for(var i=f;i<=h;i++)g("\n"+a.getLine(i));a.setCursor(f)}function x(a){var b=a.getCursor(),c=a.getLine(b.line).search(/\S/);a.setCursor(b.line,c==-1?line.length:c,!0)}function y(a,b,c){var d=a.getCursor(),e=a.getLine(d.line),f,g=n(b),h=c;return h.forward?(f=e.indexOf(g,d.ch+1),f!=-1&&h.inclusive&&(f+=1)):(f=e.lastIndexOf(g,d.ch),f!=-1&&!h.inclusive&&(f+=1)),f}function z(a,b,c){var d=y(a,b,c),e=a.getCursor();d!=-1&&a.setCursor({line:e.line,ch:d})}function A(a,b,c){var d=y(a,b,c),e=a.getCursor();d!==-1&&(c.forward?a.replaceRange("",{line:e.line,ch:e.ch},{line:e.line,ch:d}):a.replaceRange("",{line:e.line,ch:d},{line:e.line,ch:e.ch}))}function B(a){a||console.log("call enterInsertMode with 'cm' as an argument"),i(),a.setOption("keyMap","vim-insert")}function D(b){b[0]=function(b){a.length>0?h("0")(b):CodeMirror.commands.goLineStart(b)};for(var c=1;c<10;++c)b[c]=h(c)}function F(a){CodeMirror.keyMap["vim-prefix-m"][a]=function(b){e[a]=b.getCursor().line},CodeMirror.keyMap["vim-prefix-d'"][a]=function(b){v(b,a)},CodeMirror.keyMap["vim-prefix-y'"][a]=function(b){w(b,a)},CodeMirror.keyMap["vim-prefix-r"][a]=function(b){var c=b.getCursor();b.replaceRange(n(a),{line:c.line,ch:c.ch},{line:c.line,ch:c.ch+1}),CodeMirror.commands.goColumnLeft(b)},l(E,function(b,c){CodeMirror.keyMap["vim-prefix-"+b][a]=function(b){z(b,a,c)},CodeMirror.keyMap["vim-prefix-d"+b][a]=function(b){A(b,a,c)},CodeMirror.keyMap["vim-prefix-c"+b][a]=function(b){A(b,a,c),B(b)}})}var a="",b="f",c="",d=0,e=[],o="~`!@#$%^&*()_-+=[{}]\\|/?.,<>:;\"'1234567890",q=[/\w/,/[^\w\s]/],r=[/\S/],C=CodeMirror.keyMap.vim={"'|'":function(a){a.setCursor(a.getCursor().line,i()-1,!0)},"'^'":function(a){i(),x(a)},A:function(a){a.setCursor(a.getCursor().line,a.getCursor().ch+1,!0),B(a)},"Shift-A":function(a){CodeMirror.commands.goLineEnd(a),B(a)},I:function(a){B(a)},"Shift-I":function(a){x(a),B(a)},O:function(a){CodeMirror.commands.goLineEnd(a),CodeMirror.commands.newlineAndIndent(a),B(a)},"Shift-O":function(a){CodeMirror.commands.goLineStart(a),a.replaceSelection("\n","start"),a.indentLine(a.getCursor().line),B(a)},G:function(a){a.setOption("keyMap","vim-prefix-g")},"Shift-D":function(a){f(),e["Shift-D"]=a.getCursor(!1).line,a.setCursor(a.getCursor(!0).line),v(a,"Shift-D"),e=[]},S:function(a){k(function(a){CodeMirror.commands.delCharRight(a)})(a),B(a)},M:function(a){a.setOption("keyMap","vim-prefix-m"),e=[]},Y:function(a){a.setOption("keyMap","vim-prefix-y"),f(),d=0},"Shift-Y":function(a){f(),e["Shift-D"]=a.getCursor(!1).line,a.setCursor(a.getCursor(!0).line),w(a,"Shift-D"),e=[]},"/":function(a){var c=CodeMirror.commands.find;c&&c(a),b="f"},"'?'":function(a){var c=CodeMirror.commands.find;c&&(c(a),CodeMirror.commands.findPrev(a),b="r")},N:function(a){var c=CodeMirror.commands.findNext;c&&(b!="r"?c(a):CodeMirror.commands.findPrev(a))},"Shift-N":function(a){var c=CodeMirror.commands.findNext;c&&(b!="r"?CodeMirror.commands.findPrev(a):c.findNext(a))},"Shift-G":function(b){a==""?b.setCursor(b.lineCount()):b.setCursor(parseInt(a)-1),i(),CodeMirror.commands.goLineStart(b)},"'$'":function(a){k("goLineEnd")(a),a.getCursor().ch&&CodeMirror.commands.goColumnLeft(a)},nofallthrough:!0,style:"fat-cursor"};m(["d","t","T","f","F","c","r"],function(a){CodeMirror.keyMap.vim[p(a)]=function(b){b.setOption("keyMap","vim-prefix-"+a),f()}}),D(CodeMirror.keyMap.vim),l({H:"goColumnLeft",L:"goColumnRight",J:"goLineDown",K:"goLineUp",Left:"goColumnLeft",Right:"goColumnRight",Down:"goLineDown",Up:"goLineUp",Backspace:"goCharLeft",Space:"goCharRight",B:function(a){t(a,q,-1,"end")},E:function(a){t(a,q,1,"end")},W:function(a){t(a,q,1,"start")},"Shift-B":function(a){t(a,r,-1,"end")},"Shift-E":function(a){t(a,r,1,"end")},"Shift-W":function(a){t(a,r,1,"start")},X:function(a){CodeMirror.commands.delCharRight(a)},P:function(a){var b=a.getCursor().line;c!=""&&(CodeMirror.commands.goLineEnd(a),a.replaceSelection(c,"end")),a.setCursor(b+1)},"Shift-X":function(a){CodeMirror.commands.delCharLeft(a)},"Shift-J":function(a){u(a)},"Shift-P":function(a){var b=a.getCursor().line;c!=""&&(CodeMirror.commands.goLineUp(a),CodeMirror.commands.goLineEnd(a),a.replaceSelection(c,"end")),a.setCursor(b+1)},"'~'":function(a){var b=a.getCursor(),c=a.getRange({line:b.line,ch:b.ch},{line:b.line,ch:b.ch+1});c=c!=c.toLowerCase()?c.toLowerCase():c.toUpperCase(),a.replaceRange(c,{line:b.line,ch:b.ch},{line:b.line,ch:b.ch+1}),a.setCursor(b.line,b.ch+1)},"Ctrl-B":function(a){CodeMirror.commands.goPageUp(a)},"Ctrl-F":function(a){CodeMirror.commands.goPageDown(a)},"Ctrl-P":"goLineUp","Ctrl-N":"goLineDown",U:"undo","Ctrl-R":"redo"},function(a,b){C[a]=k(b)}),m(["vim-prefix-d'","vim-prefix-y'","vim-prefix-df","vim-prefix-dF","vim-prefix-dt","vim-prefix-dT","vim-prefix-c","vim-prefix-cf","vim-prefix-cF","vim-prefix-ct","vim-prefix-cT","vim-prefix-","vim-prefix-f","vim-prefix-F","vim-prefix-t","vim-prefix-T","vim-prefix-r","vim-prefix-m"],function(a){CodeMirror.keyMap[a]={auto:"vim",nofallthrough:!0}}),CodeMirror.keyMap["vim-prefix-g"]={E:k(function(a){t(a,q,-1,"start")}),"Shift-E":k(function(a){t(a,r,-1,"start")}),G:function(a){a.setCursor({line:0,ch:a.getCursor().ch})},auto:"vim",nofallthrough:!0,style:"fat-cursor"},CodeMirror.keyMap["vim-prefix-d"]={D:k(function(a){g("\n"+a.getLine(a.getCursor().line)),a.removeLine(a.getCursor().line)}),"'":function(a){a.setOption("keyMap","vim-prefix-d'"),f()},E:k("delWordRight"),B:k("delWordLeft"),auto:"vim",nofallthrough:!0,style:"fat-cursor"},D(CodeMirror.keyMap["vim-prefix-d"]),CodeMirror.keyMap["vim-prefix-c"]={E:function(a){k("delWordRight")(a),B(a)},B:function(a){k("delWordLeft")(a),B(a)},C:function(a){j(function(b,c){CodeMirror.commands.deleteLine(a),b&&(CodeMirror.commands.delCharRight(a),c&&CodeMirror.commands.deleteLine(a))}),B(a)},auto:"vim",nofallthrough:!0,style:"fat-cursor"},m(["vim-prefix-d","vim-prefix-c","vim-prefix-"],function(a){m(["f","F","T","t"],function(b){CodeMirror.keyMap[a][p(b)]=function(c){c.setOption("keyMap",a+b),f()}})});var E={t:{inclusive:!1,forward:!0},f:{inclusive:!0,forward:!0},T:{inclusive:!1,forward:!1},F:{inclusive:!0,forward:!1}};for(var G=65;G<91;G++){var H=String.fromCharCode(G);F(p(H)),F(p(H.toLowerCase()))}m(o,function(a){F(p(a))}),F("Space"),CodeMirror.keyMap["vim-prefix-y"]={Y:k(function(a){g("\n"+a.getLine(a.getCursor().line+d)),d++}),"'":function(a){a.setOption("keyMap","vim-prefix-y'"),f()},auto:"vim",nofallthrough:!0,style:"fat-cursor"},CodeMirror.keyMap["vim-insert"]={Esc:function(a){a.setCursor(a.getCursor().line,a.getCursor().ch-1,!0),a.setOption("keyMap","vim")},"Ctrl-N":"autocomplete","Ctrl-P":"autocomplete",fallthrough:["default"]}}(),function(){_.def("Luca.tools.ApplicationInspector")["extends"]("Luca.core.Container")["with"]({name:"application_inspector"})}.call(this),function(){var a,b;a=Luca.Model.extend({defaults:{_current:"default",_namespace:"default",_compiled:[]},initialize:function(a){return this.attributes=a!=null?a:{},Luca.Model.prototype.initialize.apply(this,arguments),this.fetch({silent:!0})},requireCompilation:function(){return this.get("_compiled")},bufferKeys:function(){var a,b,c,d;if(this.bufferNames!=null)return this.bufferNames;c=this.attributes,d=[];for(a in c)b=c[a],a.match(/_/)||d.push(a);return d},namespacedBuffer:function(a){return""+this.get("_namespace")+":"+a},bufferValues:function(){return _(this.attributes).pick(this.bufferKeys())},fetch:function(a){var b=this;return a==null&&(a={}),a.silent||(a.silent=!0),_(this.bufferKeys()).each(function(c){var d;d=typeof localStorage!="undefined"&&localStorage!==null?localStorage.getItem(b.namespacedBuffer(c)):void 0;if(d!=null)return b.set(c,d,{silent:a.silent===!0})}),this},persist:function(){var a=this;return _(this.bufferKeys()).each(function(b){var c;return c=a.get(b),typeof localStorage!="undefined"&&localStorage!==null?localStorage.setItem(a.namespacedBuffer(b),c):void 0}),this},currentContent:function(){var a;return a=this.get("_current"),this.get(a)}}),b={coffeescript:function(a){return CoffeeScript.compile(a,{bare:!0})},"default":function(a){return a}},_.def("Luca.tools.CodeEditor")["extends"]("Luca.components.Panel")["with"]({name:"code_editor",id:"editor_container",autoBindEventHandlers:!0,bodyClassName:"codemirror-wrapper",defaultValue:"",compilationEnabled:!1,bufferNamespace:"luca:code",namespace:function(a,b){var c;return b==null&&(b={}),a!=null&&(this.bufferNamespace=a,(c=this.buffers)!=null&&c.set("_namespace",a,{silent:b.silent===!0})),this.bufferNamespace},initialize:function(a){return this.options=a,this._super("initialize",this,arguments),_.bindAll(this,"onCompiledCodeChange","onBufferChange","onEditorChange"
|
15
|
-
,"stripTabs"),this.mode||(this.mode="coffeescript"),this.theme||(this.theme="monokai"),this.keyMap||(this.keyMap="vim"),this.lineWrapping||(this.lineWrapping=!0),this.compiler=b[this.mode]||b["default"],this.setupBuffers()},setWrap:function(a){return this.lineWrapping=a,this.editor.setOption("lineWrapping",this.lineWrapping)},setMode:function(a){return this.mode=a,this.editor.setOption("mode",this.mode),this},setKeyMap:function(a){return this.keyMap=a,this.editor.setOption("keyMap",this.keyMap),this},setTheme:function(a){return this.theme=a,this.editor.setOption("theme",this.theme),this},setupBuffers:function(){var b,c,d=this;return b=_.extend(this.currentBuffers||{},{_compiled:this.compiledBuffers,_namespace:this.namespace()}),this.buffers=new a(b),c=this,_(this.buffers.bufferKeys()).each(function(a){return d.buffers.bind("change:"+a,function(){return d.onBufferChange.apply(d,arguments)})}),_(this.buffers.requireCompilation()).each(function(a){return d.buffers.bind("change:compiled_"+a,d.onCompiledCodeChange)}),this.buffers.bind("change:_current",function(a,b){return c.trigger("buffer:change"),c.editor.setValue(d.buffers.currentContent()||"")}),this.monitorChanges=!0},currentBuffer:function(){return this.buffers.get("_current")},loadBuffer:function(a,b){return b==null&&(b=!0),b&&this.saveBuffer(),this.buffers.set("_current",a)},saveBuffer:function(){return localStorage.setItem(this.buffers.namespacedBuffer(this.currentBuffer()),this.editor.getValue()),this.buffers.set(this.currentBuffer(),this.editor.getValue())},getBuffer:function(a,b){var c,d;return b==null&&(b=!1),a||(a=this.currentBuffer()),c=this.buffers.get(a),b!==!0?c:(d=this.buffers.get("compiled_"+a),_.string.isBlank(d)&&(d=this.compileCode(c,a)),d)},editorOptions:function(){return{mode:this.mode,theme:this.theme,keyMap:this.keyMap,lineNumbers:!0,gutter:!0,autofocus:!0,onChange:this.onEditorChange,onKeyEvent:this.stripTabs,passDelay:50,autoClearEmptyLines:!0,smartIndent:!1,tabSize:2,electricChars:!1}},beforeRender:function(){var a,b;return(b=Luca.components.Panel.prototype.beforeRender)!=null&&b.apply(this,arguments),a={"min-height":this.minHeight,background:"#272822",color:"#f8f8f2"},this.$bodyEl().css(a),this.$html("<textarea></textarea>")},afterRender:function(){var a=this;return _.defer(function(){return a.editor=window.CodeMirror.fromTextArea(a.$("textarea")[0],a.editorOptions()),a.restore(),a.enableTabStripping=!0})},save:function(){return this.saveBuffer()},restore:function(){return this.editor.setValue(""),this.editor.refresh()},replaceTabWithSpace:function(){},stripTabs:function(a,b){var c,d;return(b!=null?b.keyCode:void 0)===9&&(d=this.editor.cursorCoords(),c=this.getValue().replace(/\t/g," "),this.setValue(c),this.editor.setCursor(d)),!1},onEditorChange:function(){if(this.monitorChanges)return this.save()},onBufferChange:function(a,b,c){var d,e=this;return d=a.previousAttributes(),_(this.buffers.bufferKeys()).each(function(a){var b;if(d[a]!==e.buffers.get(a)){if(!_(e.buffers.requireCompilation()).include(a))return e.trigger("code:change:"+a,e.buffers.get(a)),e.buffers.persist(a);b=e.compileCode(e.buffers.get(a),a);if(b.success===!0)return e.buffers.persist(a),e.buffers.set("compiled_"+a,b.compiled,{silent:!0})}}),this.buffers.change()},onCompiledCodeChange:function(a,b,c){var d,e,f,g,h;e=_(a.changedAttributes()).keys(),this.trigger("code:change",e),h=[];for(f=0,g=e.length;f<g;f++)d=e[f],h.push(this.trigger("code:change:"+d,d));return h},compileCode:function(a,b){var c,d;b||(b=this.currentBuffer()),a||(a=this.getBuffer(b,!1)),c="",d={success:!0,compiled:""};try{c=this.compiler.call(this,a),this.trigger("compile:success",a,c),d.compiled=c}catch(e){this.trigger("compile:error",e,a),d.success=!1,d.compiled=this.buffers.get("compiled_"+b)}return d},getCompiledCode:function(a){return a=this.getBuffer(a),_.string.strip(this.compileCode(a))},getValue:function(){return this.editor.getValue()},setValue:function(a){return a=a.replace(/\t/g," "),this.editor.setValue(a)}})}.call(this),function(){var a;a={readOnly:!1,lineNumbers:!0,gutter:!0,autofocus:!1,passDelay:50,autoClearEmptyLines:!0,smartIndent:!1,tabSize:2,electricChars:!1},Luca.define("Luca.tools.CodeMirrorField")["extends"]("Luca.components.Panel")["with"]({bodyClassName:"codemirror-wrapper",preProcessors:[],postProcessors:[],codemirrorOptions:function(){var b,c,d=this;return c=_.clone(a),b={mode:this.mode||"coffeescript",theme:this.theme||"monokai",keyMap:this.keyMap||"basic",lineNumbers:this.lineNumbers!=null?this.lineNumbers:a.lineNumbers,readOnly:this.readOnly!=null?this.readOnly:a.readOnly,gutter:this.gutter!=null?this.gutter:a.gutter,lineWrapping:this.lineWrapping===!0,onChange:function(){var a;return d.trigger("editor:change",d),(a=d.onEditorChange)!=null?a.call(d):void 0}},this.onKeyEvent!=null&&(b.onKeyEvent=_.bind(this.onKeyEvent,this)),_.extend(c,b)},getCodeMirror:function(){return this.instance},getValue:function(a){var b;return a==null&&(a=!0),b=this.getCodeMirror().getValue()},setValue:function(a,b){return a==null&&(a=""),b==null&&(b=!0),this.getCodeMirror().setValue(a)},afterRender:function(){return this.instance=CodeMirror(this.$bodyEl()[0],this.codemirrorOptions()),this.setMaxHeight(),this.setHeight()},setMaxHeight:function(a,b){a==null&&(a=void 0),b==null&&(b=!0),a||(a=this.maxHeight);if(a==null)return;this.$(".CodeMirror-scroll").css("max-height",a);if(b===!0)return this.$(".CodeMirror-scroll").css("height",a)},setHeight:function(a){a==null&&(a=void 0);if(a!=null)return this.$(".CodeMirror-scroll").css("height",a)}})}.call(this),function(){_.def("Luca.tools.CoffeeEditor")["extends"]("Luca.tools.CodeMirrorField")["with"]({name:"coffeescript_editor",autoCompile:!0,compileOptions:{bare:!0},hooks:["editor:change"],initialize:function(a){var b;return this.options=a,Luca.tools.CodeMirrorField.prototype.initialize.apply(this,arguments),_.bindAll(this,"editorChange","toggleSource"),b=this,this.state=new Luca.Model({currentMode:"coffeescript",coffeescript:"",javascript:""}),this.state.bind("change:coffeescript",function(a){var c;return b.trigger("change:coffeescript"),c=a.get("coffeescript"),b.compile(c,function(b){return a.set("javascript",b)})}),this.state.bind("change:javascript",function(a){var c;return(c=b.onJavascriptChange)!=null?c.call(b,a.get("javascript")):void 0}),this.state.bind("change:currentMode",function(a){return a.get("currentMode")==="javascript"?b.setValue(a.get("javascript")):b.setValue(a.get("coffeescript"))})},compile:function(a,b){var c,d;d={},a||(a=this.getValue());try{return c=CoffeeScript.compile(a,this.compileOptions),b!=null&&b.call(this,c),d={success:!0,compiled:c}}catch(e){return this.trigger("compile:error",e,a),d={success:!1,compiled:"",message:e.message}}},toggleMode:function(){if(this.currentMode()==="coffeescript")return this.state.set("currentMode","javascript");if(this.currentMode()==="javascript")return this.state.set("currentMode","coffeescript")},currentMode:function(){return this.state.get("currentMode")},getCoffeescript:function(){return this.state.get("coffeescript")},getJavascript:function(a){var b,c;a==null&&(a=!1),b=this.state.get("javascript");if(a===!0||(b!=null?b.length:void 0)===0)c=this.compile(this.getCoffeescript()),b=c!=null?c.compiled:void 0;return b},editorChange:function(){if(this.autoCompile===!0)return this.state.set(this.currentMode(),this.getValue())}})}.call(this),function(){_.def("Luca.tools.CollectionInspector")["extends"]("Luca.View")["with"]({name:"collection_inspector",className:"collection-inspector"})}.call(this),function(){_.def("Luca.app.Components")["extends"]("Luca.Collection")["with"]({cachedMethods:["namespaces","classes","roots","views","collections","models"],cache_key:"luca_components",name:"components",initialize:function(){return this.model=Luca.app.Component,Luca.Collection.prototype.initialize.apply(this,arguments)},url:function(){return"/luca/source-map.js"},collections:function(){return this.select(function(a){return Luca.isCollectionPrototype(a.definition())})},modelClasses:function(){return this.select(function(a){return Luca.isModelPrototype(a.definition())})},views:function(){return this.select(function(a){return Luca.isViewPrototype(a.definition())})},classes:function(){return _.uniq(this.pluck("className"))},roots:function(){return _.uniq(this.invoke("root"))},namespaces:function(){return _.uniq(this.invoke("namespace"))},asTree:function(){var a,b,c,d;return a=this.classes(),b=this.namespaces(),c=this.roots(),d=_(c).inject(function(a,c){var d;return a[c]||(a[c]={}),d=new RegExp("^"+c),a[c]=_(b).select(function(a){return d.exec(a)&&_(b).include(a)&&a.split(".").length===2}),a},{}),_(d).inject(function(a,b,c){return a[c]={},_(b).each(function(b){return a[c][b]={}}),a},{})}})}.call(this),function(){_.def("Luca.app.Instances")["extends"]("Luca.Collection")["with"]({name:"instances",refresh:function(a){var b;return a==null&&(a={}),b=_(Luca.registry.instances()).map(function(a){return{cid:a.cid,name:a.name,ctype:a.ctype,displayName:a.displayName||a.prototype.displayName,object:a}}),this.reset(b,a)},initialize:function(a,b){return a==null&&(a=[]),this.options=b!=null?b:{},this.model=Luca.app.Instance,Luca.Collection.prototype.initialize.apply(this,arguments)}})}.call(this),function(){var ComponentPicker,bufferNames,compiledBuffers,defaults;defaults={},defaults.setup="# the setup tab contains code which is run every time\n# prior to the 'implementation' run",defaults.component="# the component tab is where you handle the definition of the component\n# that you are trying to test. it will render its output into the\n# output panel of the code tester\n#\n# example definition:\n#\n# _.def('MyComponent').extends('Luca.View').with\n# bodyTemplate: 'sample/welcome'",defaults.teardown="# the teardown tab is where you undo / cleanup any of the operations\n# from setup / implementation",defaults.implementation="# the implementation tab is where you specify options for your component.\n#\n# NOTE: the component tester uses whatever is returned from evalulating\n# the code in this tab. if it responds to render(), it will append\n# render().el to the output panel. if it is an object, then we will attempt\n# to create an instance of the component you defined with the object as",defaults.style="/*\n * customize the styles that effect this component\n * note, all styles here will be scoped to only effect\n * the output panel :)\n*/",defaults.html="",bufferNames=["setup","implementation","component","style","html"],compiledBuffers=["setup","implementation","component"],ComponentPicker=Luca.fields.TypeAheadField.extend({name:"component_picker",label:"Choose a component to edit",initialize:function(){return this.collection=new Luca.collections.Components,this.collection.fetch(),this._super("initialize",this,arguments)},getSource:function(){return this.collection.classes()},change_handler:function(){var a,b,c=this;return b=this.getValue(),a=this.collection.find(function(a){return a.get("className")===b}),a.fetch({success:function(a,b){if((b!=null?b.source.length:void 0)>0)return c.trigger("component:fetched",b.source,b.className)}}),this.hide()},createWrapper:function(){return this.make("div",{"class":"component-picker span4 well",style:"position: absolute; z-index:12000"})},show:function(){return this.$el.parent().show()},hide:function(){return this.$el.parent().hide()},toggle:function(){return this.$el.parent().toggle()}}),_.def("Luca.tools.ComponentTester")["extends"]("Luca.core.Container")["with"]({id:"component_tester",name:"component_tester",autoEvaluateCode:!0,currentSize:1,sizes:[{icon:"resize-full",value:function(){return $(window).height()*.3}},{icon:"resize-small",value:function(){return $(window).height()*.6}}],components:[{ctype:"card_view",name:"component_detail",activeCard:0,components:[{ctype:"panel",name:"component_tester_output",bodyTemplate:"component_tester/help"}]},{ctype:"code_editor",name:"ctester_edit",className:"font-large fixed-height",minHeight:"350px",currentBuffers:defaults,compiledBuffers:["component","setup","implementation"],topToolbar:{buttons:[{icon:"resize-full",align:"right",description:"change the size of the component tester editor",eventId:"toggle:size"},{icon:"pause",align:"right",description:"Toggle auto-evaluation of test script on code change",eventId:"click:autoeval"},{icon:"plus",description:"add a new component to test",eventId:"click:add"},{icon:"folder-open",description:"open an existing component's definition",eventId:"click:open"}]},bottomToolbar:{buttons:[{group:!0,wrapper:"span4",buttons:[{label:"View Javascript",description:"Switch between compiled JS and Coffeescript",eventId:"toggle:mode"}]},{group:!0,wrapper:"span6 offset4",buttons:[{label:"Component",eventId:"edit:component",description:"Edit the component itself"},{label:"Setup",eventId:"edit:setup",description:"Edit the setup for your component test"},{label:"Implementation",eventId:"edit:implementation",description:"Implement your component"},{label:"Markup",eventId:"edit:markup",description:"Edit the HTML produced by the component"},{label:"CSS",eventId:"edit:style",description:"Edit CSS"}]},{group:!0,align:"right",buttons:[{icon:"question-sign",align:"right",eventId:"click:help",description:"Help"},{icon:"cog",align:"right",eventId:"click:settings",description:"component tester settings"},{icon:"eye-close",align:"right",eventId:"click:hide",description:"hide the tester controls"},{icon:"heart",eventId:"click:console",description:"Coffeescript Console",align:"right"}]}]}}],debugMode:!0,componentEvents:{"ctester_edit click:autoeval":"toggleAutoeval","ctester_edit click:refresh":"refreshCode","ctester_edit click:hide":"toggleControls","ctester_edit click:settings":"toggleSettings","ctester_edit click:add":"addComponent","ctester_edit click:open":"openComponent","ctester_edit click:help":"showHelp","ctester_edit click:console":"toggleConsole","ctester_edit eval:error":"onError","ctester_edit eval:success":"onSuccess","ctester_edit edit:setup":"editSetup","ctester_edit edit:teardown":"editTeardown","ctester_edit edit:component":"editComponent","ctester_edit edit:style":"editStyle","ctester_edit edit:markup":"editMarkup","ctester_edit edit:implementation":"editImplementation","ctester_edit toggle:keymap":"toggleKeymap","ctester_edit toggle:mode":"toggleMode","ctester_edit code:change:html":"onMarkupChange","ctester_edit code:change:style":"onStyleChange","ctester_edit toggle:size":"toggleSize"},initialize:function(){var a,b,c;Luca.core.Container.prototype.initialize.apply(this,arguments),c=this.componentEvents;for(a in c)b=c[a],this[b]=_.bind(this[b],this);return this.defer("editComponent").until("after:render")},afterRender:function(){var a,b=this;return a=_.idleMedium(function(){if(b.autoEvaluateCode===!0)return b.applyTestRun()},500),this.getEditor().bind("code:change",a)},getEditor:function(){return Luca("ctester_edit")},getDetail:function(){return Luca("component_detail")},getOutput:function(){return this.getDetail().findComponentByName("component_tester_output")},onError:function(a,b){return console.log("Error in "+b,a,a.message,a.stack)},onSuccess:function(a,b){var c;b==="component"&&(this.componentDefinition=a);if(b==="implementation"){Luca.isBackboneView(a)?c=a:_.isObject(a)&&a.ctype!=null?c=Luca(a):_.isObject(a)&&_.isFunction(this.componentDefinition)&&(c=new this.componentDefinition(a));if(Luca.isBackboneView(c))return this.getOutput().$html(c.render().el)}},applyTestRun:function(){var a,b,c,d;this.getOutput().$html(""),c=this.getTestRun(),d=[];for(a in c)b=c[a],d.push(this.evaluateCode(b,a));return d},toggleConsole:function(a){var b;return this.developmentConsole=Luca("coffeescript-console",function(){return new Luca.tools.DevelopmentConsole({name:"coffeescript-console"})}),this.consoleContainerAppended||(b=this.make("div",{id:"devtools-console-wrapper","class":"devtools-console-container modal",style:"width:900px;height:650px;"},this.developmentConsole.el),$("body").append(b),this.consoleContainerAppended=!0,this.developmentConsole.render()),$("#devtools-console-wrapper").modal({backdrop:!1,show:!0})},toggleAutoeval:function(a){var b,c;return this.autoEvaluateCode=this.autoEvaluateCode!==!0,!this.started&&this.autoEvaluateCode===!0&&(this.started=!0,this.applyTestRun()),c=a.children("i").eq(0),b=this.autoEvaluateCode?"icon-pause":"icon-play",c.removeClass(),c.addClass(b),this},showEditor:function(a){return this.getEditor().$(".toolbar-container.top").toggle(a),this.getEditor().$(".codemirror-wrapper").toggle(a),this.trigger("controls:toggled")},toggleKeymap:function(a){var b;return b=this.getEditor().keyMap==="vim"?"basic":"vim",this.getEditor().setKeyMap(b),a.html(_.string.capitalize(b))},toggleMode:function(a){var b;return b=this.getEditor().mode==="coffeescript"?"javascript":"coffeescript",this.getEditor().setMode(b),a.html(_.string.capitalize(b==="coffeescript"?"View Javascript":"View Coffeescript")),this.editBuffer(this.currentBufferName,b==="javascript")},toggleSize:function(a){var b,c,d,e;return c=this.currentSize++%this.sizes.length,e=this.sizes[c].value(),d=this.sizes[c].icon,a!=null&&(b=a.children("i").eq(0),b.removeClass().addClass("icon-"+d)),this.$(".codemirror-wrapper").css("height",""+parseInt(e)+"px"),this.getEditor().refresh()},toggleControls:function(a){var b=this;return this.bind("controls:toggled",function(){var c,d;return d=a.children("i").eq(0),d.removeClass(),c=b.getEditor().$(".toolbar-container.top").is(":visible")?"icon-eye-close":"icon-eye-open",d.addClass(c)}),this.showEditor(),this},toggleSettings:function(){return this},setValue:function(a,b){var c;return b==null&&(b="component"),c=this.getEditor().editor.getOption("mode")==="javascript",this.editBuffer(b,c,!1).getEditor().setValue(a)},editBuffer:function(a,b,c){var d;return this.currentBufferName=a,b==null&&(b=!1),c==null&&(c=!0),this.showEditor(!0),this.highlight(this.currentBufferName),d=b?"compiled_"+this.currentBufferName:this.currentBufferName,this.getEditor().loadBuffer(d,c),this},editMarkup:function(){return this.getEditor().setMode("htmlmixed"),this.getEditor().setWrap(!0),this.editBuffer("html").setValue(this.getOutput().$html(),"html")},editStyle:function(){return this.getEditor().setMode("css"),this.editBuffer("style")},editComponent:function(){return this.getEditor().setMode("coffeescript"),this.editBuffer("component")},editTeardown:function(){return this.getEditor().setMode("coffeescript"),this.editBuffer("teardown")},editSetup:function(){return this.getEditor().setMode("coffeescript"),this.editBuffer("setup")},editImplementation:function(){return this.getEditor().setMode("coffeescript"),this.editBuffer("implementation")},getTestRun:function(){var a,b,c,d,e,f;b=this.getEditor(),c={},f=["component","setup","implementation"];for(d=0,e=f.length;d<e;d++)a=f[d],c[a]=b.getBuffer(a,!0);return c},getContext:function(){return Luca.util.resolve(this.context||(this.context="window"))},evaluateCode:function(code,bufferId,compile){var compiled,evaluator,result;compile==null&&(compile=!1),code||(code=this.getEditor().getValue()),compiled=compile===!0?this.getEditor().compileCode(code):code,evaluator=function(){return eval(compiled)};try{return result=evaluator.call(this.getContext()),this.onSuccess(result,bufferId,code)}catch(error){return this.onError(error,bufferId,code)}},onMarkupChange:function(){if(this.autoEvaluateCode===!0)return this.getOutput().$html(this.getEditor().getValue())},onStyleChange:function(){var a,b,c;if(this.autoEvaluateCode===!0){$("#component-tester-stylesheet").remove(),a=(c=this.getEditor())!=null?c.getValue():void 0;if(a)return b=this.make("style",{type:"text/css",id:"component-tester-stylesheet"}),$("head").append(b),$(b).append(a)}},showHelp:function(){return this.getOutput().$html(Luca.template("component_tester/help",this))},addComponent:function(a){},openComponent:function(a){var b=this;this.componentPicker||(this.componentPicker=new ComponentPicker),this.componentPicker.bind("component:fetched",function(a,c){return b.setEditorNamespace(c).setValue(a,"component")});if(!this.getEditor().$(".component-picker").length>0){this.getEditor().$(".codemirror-wrapper").before(this.componentPicker.createWrapper()),this.getEditor().$(".component-picker").html(this.componentPicker.render().el),this.componentPicker.show();return}return this.componentPicker.toggle()},highlight:function(a){return this.$("a.btn[data-eventid='edit:"+a+"']").siblings().css("font-weight","normal"),this.$("a.btn[data-eventid='edit:"+a+"']").css("font-weight","bold")},setEditorNamespace:function(a){return this.getEditor().namespace(a),this.getEditor().buffers.fetch(),this}})}.call(this),function(){var codeMirrorOptions,_base;codeMirrorOptions={readOnly:!0,autoFocus:!1,theme:"monokai",mode:"javascript"},Luca.define("Luca.tools.DevelopmentConsole")["extends"]("Luca.core.Container")["with"]({className:"luca-ui-console",name:"console",history:[],historyIndex:0,componentEvents:{"code_input key:keyup":"historyUp","code_input key:keydown":"historyDown","code_input key:enter":"runCommand"},compileOptions:{bare:!0},components:[{ctype:"code_mirror_field",additionalClassNames:"clearfix",name:"code_output",readOnly:!0,lineNumbers:!1,mode:"javascript",lineWrapping:!0,gutter:!1},{ctype:"text_field",name:"code_input",lineNumbers:!1,height:"30px",maxHeight:"30px",gutter:!1,autoBindEventHandlers:!0,hideLabel:!0,prepend:"Coffee>",events:{"keypress input":"onKeyEvent","keydown input":"onKeyEvent"},onKeyEvent:function(a){a.type==="keypress"&&a.keyCode===Luca.keys.ENTER&&this.trigger("key:enter",this.getValue()),a.type==="keydown"&&a.keyCode===Luca.keys.KEYUP&&this.trigger("key:keyup");if(a.type==="keydown"&&a.keyCode===Luca.keys.KEYDOWN)return this.trigger("key:keydown")},afterRender:function(){return this.$("input").focus()}}],afterRender:function(){return this.$container().modal({backdrop:!1}),this.$container.css},show:function(a){return a==null&&(a={}),this.$container().modal("show"),this},getContext:function(){return window},initialize:function(){return this._super("initialize",this,arguments),_.bindAll(this,"historyUp","historyDown","onSuccess","onError","runCommand")},saveHistory:function(a){return(a!=null?a.length:void 0)>0&&this.history.push(a),this.historyIndex=0},historyUp:function(){var a;return this.historyIndex-=1,this.historyIndex<0&&(this.historyIndex=0),a=Luca("code_input").getValue(),Luca("code_input").setValue(this.history[this.historyIndex]||a)},historyDown:function(){var a;return this.historyIndex+=1,this.historyIndex>this.history.length-1&&(this.historyIndex=this.history.length-1),a=Luca("code_input").getValue(),Luca("code_input").setValue(this.history[this.historyIndex]||a)},append:function(a,b,c){var d,e,f,g;return c==null&&(c=!1),e=Luca("code_output"),d=e.getValue(),a!=null&&(g="// "+a),f=c||a.match(/^console\.log/)?[d,b]:[d,g,b],e.setValue(_.compact(f).join("\n")),e.getCodeMirror().scrollTo(0,9e4)},onSuccess:function(a,b,c){var d;return this.saveHistory(c),d=JSON.stringify(a,null," "),d||(d=typeof a.toString=="function"?a.toString():void 0),this.append(b,d||"undefined")},onError:function(a,b,c){return this.append(b,"// ERROR: "+a.message)},evaluateCode:function(code,raw){var dev,evaluator,output,result;if(!((code!=null?code.length:void 0)>0))return;raw=_.string.strip(raw),output=Luca("code_output"),dev=this,evaluator=function(){var console,log,old_console,result;old_console=window.console,console={log:function(){var a,b,c,d;d=[];for(b=0,c=arguments.length;b<c;b++)a=arguments[b],d.push(dev.append(void 0,a,!0));return d}},log=console.log;try{result=eval(code)}catch(error){throw window.console=old_console,error}return window.console=old_console,result};try{result=evaluator.call(this.getContext());if(!raw.match(/^console\.log/))return this.onSuccess(result,code,raw)}catch(error){return this.onError(error,code,raw)}},runCommand:function(){var a,b,c,d;return c=this,a=_.bind(Luca.tools.CoffeeEditor.prototype.compile,this),d=Luca("code_input").getValue(),b=a(d,function(a){return c.evaluateCode(a,d)})}}),(_base=Luca.util).launchers||(_base.launchers={}),Luca.util.launchers.developmentConsole=function(a){var b=this;return a==null&&(a="luca-development-console"),this._lucaDevConsole=Luca(a,function(){var c;return b.$el.append(Backbone.View.prototype.make("div",{id:""+a+"-wrapper","class":"modal fade"})),c=new Luca.tools.DevelopmentConsole({name:a,container:"#"+a+"-wrapper"}),c.render()}),this._lucaDevConsole.show()}}.call(this),function(){_.def("Luca.app.Component")["extends"]("Luca.Model")["with"]({root:function(){return this.get("className").split(".")[0]},className:function(){return this.get("className")},instances:function(){return Luca.registry.findInstancesByClassName(this.className())},definitionPrototype:function(){var a;return(a=this.definition())!=null?a.prototype:void 0},parentClasses:function(){return Luca.parentClasses(this.className())},definition:function(){return Luca.util.resolve(this.className())},namespace:function(){var a;return this.get("className")==null?"":(a=this.get("className").split("."),a.pop(),a.join("."))}})}.call(this),function(){_.def("Luca.app.Instance")["extends"]("Luca.Model")["with"]({version:1})}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["component_tester/help"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<h1>Component Tester</h1>\n<p>This is a tool that enables you to build and test Luca components in an isolated sandbox environment. The editor is currently enabled with vim keybindings</p>\n<h3>Setup</h3>\n<p>This is where you setup any data requirements needed for the test to work. This is run every time before the implementation code is ran.</p>\n<h3>Teardown</h3>\n<p>This is where you clean up after the tests. This will be run every time after the implementation code is ran.</p>\n<h3>Definitions</h3>\n<p>This is where you define the component you will be testing. This is usually the code you will be shipping once you have completed testing.</p>\n<h3>Implementation</h3>\n<p>This is where you create an instance of the component and specify any of the necessary configuration settings. The component will be rendered into the output panel of the component tester.</p>\n");return __p.join("")}}.call(this),function(){}.call(this);
|
15
|
+
,"stripTabs"),this.mode||(this.mode="coffeescript"),this.theme||(this.theme="monokai"),this.keyMap||(this.keyMap="vim"),this.lineWrapping||(this.lineWrapping=!0),this.compiler=b[this.mode]||b["default"],this.setupBuffers()},setWrap:function(a){return this.lineWrapping=a,this.editor.setOption("lineWrapping",this.lineWrapping)},setMode:function(a){return this.mode=a,this.editor.setOption("mode",this.mode),this},setKeyMap:function(a){return this.keyMap=a,this.editor.setOption("keyMap",this.keyMap),this},setTheme:function(a){return this.theme=a,this.editor.setOption("theme",this.theme),this},setupBuffers:function(){var b,c,d=this;return b=_.extend(this.currentBuffers||{},{_compiled:this.compiledBuffers,_namespace:this.namespace()}),this.buffers=new a(b),c=this,_(this.buffers.bufferKeys()).each(function(a){return d.buffers.bind("change:"+a,function(){return d.onBufferChange.apply(d,arguments)})}),_(this.buffers.requireCompilation()).each(function(a){return d.buffers.bind("change:compiled_"+a,d.onCompiledCodeChange)}),this.buffers.bind("change:_current",function(a,b){return c.trigger("buffer:change"),c.editor.setValue(d.buffers.currentContent()||"")}),this.monitorChanges=!0},currentBuffer:function(){return this.buffers.get("_current")},loadBuffer:function(a,b){return b==null&&(b=!0),b&&this.saveBuffer(),this.buffers.set("_current",a)},saveBuffer:function(){return localStorage.setItem(this.buffers.namespacedBuffer(this.currentBuffer()),this.editor.getValue()),this.buffers.set(this.currentBuffer(),this.editor.getValue())},getBuffer:function(a,b){var c,d;return b==null&&(b=!1),a||(a=this.currentBuffer()),c=this.buffers.get(a),b!==!0?c:(d=this.buffers.get("compiled_"+a),_.string.isBlank(d)&&(d=this.compileCode(c,a)),d)},editorOptions:function(){return{mode:this.mode,theme:this.theme,keyMap:this.keyMap,lineNumbers:!0,gutter:!0,autofocus:!0,onChange:this.onEditorChange,onKeyEvent:this.stripTabs,passDelay:50,autoClearEmptyLines:!0,smartIndent:!1,tabSize:2,electricChars:!1}},beforeRender:function(){var a,b;return(b=Luca.components.Panel.prototype.beforeRender)!=null&&b.apply(this,arguments),a={"min-height":this.minHeight,background:"#272822",color:"#f8f8f2"},this.$bodyEl().css(a),this.$html("<textarea></textarea>")},afterRender:function(){var a=this;return _.defer(function(){return a.editor=window.CodeMirror.fromTextArea(a.$("textarea")[0],a.editorOptions()),a.restore(),a.enableTabStripping=!0})},save:function(){return this.saveBuffer()},restore:function(){return this.editor.setValue(""),this.editor.refresh()},replaceTabWithSpace:function(){},stripTabs:function(a,b){var c,d;return(b!=null?b.keyCode:void 0)===9&&(d=this.editor.cursorCoords(),c=this.getValue().replace(/\t/g," "),this.setValue(c),this.editor.setCursor(d)),!1},onEditorChange:function(){if(this.monitorChanges)return this.save()},onBufferChange:function(a,b,c){var d,e=this;return d=a.previousAttributes(),_(this.buffers.bufferKeys()).each(function(a){var b;if(d[a]!==e.buffers.get(a)){if(!_(e.buffers.requireCompilation()).include(a))return e.trigger("code:change:"+a,e.buffers.get(a)),e.buffers.persist(a);b=e.compileCode(e.buffers.get(a),a);if(b.success===!0)return e.buffers.persist(a),e.buffers.set("compiled_"+a,b.compiled,{silent:!0})}}),this.buffers.change()},onCompiledCodeChange:function(a,b,c){var d,e,f,g,h;e=_(a.changedAttributes()).keys(),this.trigger("code:change",e),h=[];for(f=0,g=e.length;f<g;f++)d=e[f],h.push(this.trigger("code:change:"+d,d));return h},compileCode:function(a,b){var c,d;b||(b=this.currentBuffer()),a||(a=this.getBuffer(b,!1)),c="",d={success:!0,compiled:""};try{c=this.compiler.call(this,a),this.trigger("compile:success",a,c),d.compiled=c}catch(e){this.trigger("compile:error",e,a),d.success=!1,d.compiled=this.buffers.get("compiled_"+b)}return d},getCompiledCode:function(a){return a=this.getBuffer(a),_.string.strip(this.compileCode(a))},getValue:function(){return this.editor.getValue()},setValue:function(a){return a=a.replace(/\t/g," "),this.editor.setValue(a)}})}.call(this),function(){var a;a={readOnly:!1,lineNumbers:!0,gutter:!0,autofocus:!1,passDelay:50,autoClearEmptyLines:!0,smartIndent:!1,tabSize:2,electricChars:!1},Luca.define("Luca.tools.CodeMirrorField")["extends"]("Luca.components.Panel")["with"]({bodyClassName:"codemirror-wrapper",preProcessors:[],postProcessors:[],codemirrorOptions:function(){var b,c,d=this;return c=_.clone(a),b={mode:this.mode||"coffeescript",theme:this.theme||"monokai",keyMap:this.keyMap||"basic",lineNumbers:this.lineNumbers!=null?this.lineNumbers:a.lineNumbers,readOnly:this.readOnly!=null?this.readOnly:a.readOnly,gutter:this.gutter!=null?this.gutter:a.gutter,lineWrapping:this.lineWrapping===!0,onChange:function(){var a;return d.trigger("editor:change",d),(a=d.onEditorChange)!=null?a.call(d):void 0}},this.onKeyEvent!=null&&(b.onKeyEvent=_.bind(this.onKeyEvent,this)),_.extend(c,b)},getCodeMirror:function(){return this.instance},getValue:function(a){var b;return a==null&&(a=!0),b=this.getCodeMirror().getValue()},setValue:function(a,b){return a==null&&(a=""),b==null&&(b=!0),this.getCodeMirror().setValue(a)},afterRender:function(){return this.instance=CodeMirror(this.$bodyEl()[0],this.codemirrorOptions()),this.setMaxHeight(),this.setHeight()},setMaxHeight:function(a,b){a==null&&(a=void 0),b==null&&(b=!0),a||(a=this.maxHeight);if(a==null)return;this.$(".CodeMirror-scroll").css("max-height",a);if(b===!0)return this.$(".CodeMirror-scroll").css("height",a)},setHeight:function(a){a==null&&(a=void 0);if(a!=null)return this.$(".CodeMirror-scroll").css("height",a)}})}.call(this),function(){_.def("Luca.tools.CoffeeEditor")["extends"]("Luca.tools.CodeMirrorField")["with"]({name:"coffeescript_editor",autoCompile:!0,compileOptions:{bare:!0},hooks:["editor:change"],initialize:function(a){var b;return this.options=a,Luca.tools.CodeMirrorField.prototype.initialize.apply(this,arguments),_.bindAll(this,"editorChange","toggleSource"),b=this,this.state=new Luca.Model({currentMode:"coffeescript",coffeescript:"",javascript:""}),this.state.bind("change:coffeescript",function(a){var c;return b.trigger("change:coffeescript"),c=a.get("coffeescript"),b.compile(c,function(b){return a.set("javascript",b)})}),this.state.bind("change:javascript",function(a){var c;return(c=b.onJavascriptChange)!=null?c.call(b,a.get("javascript")):void 0}),this.state.bind("change:currentMode",function(a){return a.get("currentMode")==="javascript"?b.setValue(a.get("javascript")):b.setValue(a.get("coffeescript"))})},compile:function(a,b){var c,d;d={},a||(a=this.getValue());try{return c=CoffeeScript.compile(a,this.compileOptions),b!=null&&b.call(this,c),d={success:!0,compiled:c}}catch(e){return this.trigger("compile:error",e,a),d={success:!1,compiled:"",message:e.message}}},toggleMode:function(){if(this.currentMode()==="coffeescript")return this.state.set("currentMode","javascript");if(this.currentMode()==="javascript")return this.state.set("currentMode","coffeescript")},currentMode:function(){return this.state.get("currentMode")},getCoffeescript:function(){return this.state.get("coffeescript")},getJavascript:function(a){var b,c;a==null&&(a=!1),b=this.state.get("javascript");if(a===!0||(b!=null?b.length:void 0)===0)c=this.compile(this.getCoffeescript()),b=c!=null?c.compiled:void 0;return b},editorChange:function(){if(this.autoCompile===!0)return this.state.set(this.currentMode(),this.getValue())}})}.call(this),function(){_.def("Luca.tools.CollectionInspector")["extends"]("Luca.View")["with"]({name:"collection_inspector",className:"collection-inspector"})}.call(this),function(){_.def("Luca.app.Components")["extends"]("Luca.Collection")["with"]({cachedMethods:["namespaces","classes","roots","views","collections","models"],cache_key:"luca_components",name:"components",initialize:function(){return this.model=Luca.app.Component,Luca.Collection.prototype.initialize.apply(this,arguments)},url:function(){return"/luca/source-map.js"},collections:function(){return this.select(function(a){return Luca.isCollectionPrototype(a.definition())})},modelClasses:function(){return this.select(function(a){return Luca.isModelPrototype(a.definition())})},views:function(){return this.select(function(a){return Luca.isViewPrototype(a.definition())})},classes:function(){return _.uniq(this.pluck("className"))},roots:function(){return _.uniq(this.invoke("root"))},namespaces:function(){return _.uniq(this.invoke("namespace"))},asTree:function(){var a,b,c,d;return a=this.classes(),b=this.namespaces(),c=this.roots(),d=_(c).inject(function(a,c){var d;return a[c]||(a[c]={}),d=new RegExp("^"+c),a[c]=_(b).select(function(a){return d.exec(a)&&_(b).include(a)&&a.split(".").length===2}),a},{}),_(d).inject(function(a,b,c){return a[c]={},_(b).each(function(b){return a[c][b]={}}),a},{})}})}.call(this),function(){_.def("Luca.app.Instances")["extends"]("Luca.Collection")["with"]({name:"instances",refresh:function(a){var b;return a==null&&(a={}),b=_(Luca.registry.instances()).map(function(a){return{cid:a.cid,name:a.name,ctype:a.ctype,displayName:a.displayName||a.prototype.displayName,object:a}}),this.reset(b,a)},initialize:function(a,b){return a==null&&(a=[]),this.options=b!=null?b:{},this.model=Luca.app.Instance,Luca.Collection.prototype.initialize.apply(this,arguments)}})}.call(this),function(){var ComponentPicker,bufferNames,compiledBuffers,defaults;defaults={},defaults.setup="# the setup tab contains code which is run every time\n# prior to the 'implementation' run",defaults.component="# the component tab is where you handle the definition of the component\n# that you are trying to test. it will render its output into the\n# output panel of the code tester\n#\n# example definition:\n#\n# _.def('MyComponent').extends('Luca.View').with\n# bodyTemplate: 'sample/welcome'",defaults.teardown="# the teardown tab is where you undo / cleanup any of the operations\n# from setup / implementation",defaults.implementation="# the implementation tab is where you specify options for your component.\n#\n# NOTE: the component tester uses whatever is returned from evalulating\n# the code in this tab. if it responds to render(), it will append\n# render().el to the output panel. if it is an object, then we will attempt\n# to create an instance of the component you defined with the object as",defaults.style="/*\n * customize the styles that effect this component\n * note, all styles here will be scoped to only effect\n * the output panel :)\n*/",defaults.html="",bufferNames=["setup","implementation","component","style","html"],compiledBuffers=["setup","implementation","component"],ComponentPicker=Luca.fields.TypeAheadField.extend({name:"component_picker",label:"Choose a component to edit",initialize:function(){return this.collection=new Luca.collections.Components,this.collection.fetch(),this._super("initialize",this,arguments)},getSource:function(){return this.collection.classes()},change_handler:function(){var a,b,c=this;return b=this.getValue(),a=this.collection.find(function(a){return a.get("className")===b}),a.fetch({success:function(a,b){if((b!=null?b.source.length:void 0)>0)return c.trigger("component:fetched",b.source,b.className)}}),this.hide()},createWrapper:function(){return this.make("div",{"class":"component-picker span4 well",style:"position: absolute; z-index:12000"})},show:function(){return this.$el.parent().show()},hide:function(){return this.$el.parent().hide()},toggle:function(){return this.$el.parent().toggle()}}),_.def("Luca.tools.ComponentTester")["extends"]("Luca.core.Container")["with"]({id:"component_tester",name:"component_tester",autoEvaluateCode:!0,currentSize:1,sizes:[{icon:"resize-full",value:function(){return $(window).height()*.3}},{icon:"resize-small",value:function(){return $(window).height()*.6}}],components:[{ctype:"card_view",name:"component_detail",activeCard:0,components:[{ctype:"panel",name:"component_tester_output",bodyTemplate:"component_tester/help"}]},{ctype:"code_editor",name:"ctester_edit",className:"font-large fixed-height",minHeight:"350px",currentBuffers:defaults,compiledBuffers:["component","setup","implementation"],topToolbar:{buttons:[{icon:"resize-full",align:"right",description:"change the size of the component tester editor",eventId:"toggle:size"},{icon:"pause",align:"right",description:"Toggle auto-evaluation of test script on code change",eventId:"click:autoeval"},{icon:"plus",description:"add a new component to test",eventId:"click:add"},{icon:"folder-open",description:"open an existing component's definition",eventId:"click:open"}]},bottomToolbar:{buttons:[{group:!0,wrapper:"span4",buttons:[{label:"View Javascript",description:"Switch between compiled JS and Coffeescript",eventId:"toggle:mode"}]},{group:!0,wrapper:"span6 offset4",buttons:[{label:"Component",eventId:"edit:component",description:"Edit the component itself"},{label:"Setup",eventId:"edit:setup",description:"Edit the setup for your component test"},{label:"Implementation",eventId:"edit:implementation",description:"Implement your component"},{label:"Markup",eventId:"edit:markup",description:"Edit the HTML produced by the component"},{label:"CSS",eventId:"edit:style",description:"Edit CSS"}]},{group:!0,align:"right",buttons:[{icon:"question-sign",align:"right",eventId:"click:help",description:"Help"},{icon:"cog",align:"right",eventId:"click:settings",description:"component tester settings"},{icon:"eye-close",align:"right",eventId:"click:hide",description:"hide the tester controls"},{icon:"heart",eventId:"click:console",description:"Coffeescript Console",align:"right"}]}]}}],debugMode:!0,componentEvents:{"ctester_edit click:autoeval":"toggleAutoeval","ctester_edit click:refresh":"refreshCode","ctester_edit click:hide":"toggleControls","ctester_edit click:settings":"toggleSettings","ctester_edit click:add":"addComponent","ctester_edit click:open":"openComponent","ctester_edit click:help":"showHelp","ctester_edit click:console":"toggleConsole","ctester_edit eval:error":"onError","ctester_edit eval:success":"onSuccess","ctester_edit edit:setup":"editSetup","ctester_edit edit:teardown":"editTeardown","ctester_edit edit:component":"editComponent","ctester_edit edit:style":"editStyle","ctester_edit edit:markup":"editMarkup","ctester_edit edit:implementation":"editImplementation","ctester_edit toggle:keymap":"toggleKeymap","ctester_edit toggle:mode":"toggleMode","ctester_edit code:change:html":"onMarkupChange","ctester_edit code:change:style":"onStyleChange","ctester_edit toggle:size":"toggleSize"},initialize:function(){var a,b,c;Luca.core.Container.prototype.initialize.apply(this,arguments),c=this.componentEvents;for(a in c)b=c[a],this[b]=_.bind(this[b],this);return this.defer("editComponent").until("after:render")},afterRender:function(){var a,b=this;return a=_.idleMedium(function(){if(b.autoEvaluateCode===!0)return b.applyTestRun()},500),this.getEditor().bind("code:change",a)},getEditor:function(){return Luca("ctester_edit")},getDetail:function(){return Luca("component_detail")},getOutput:function(){return this.getDetail().findComponentByName("component_tester_output")},onError:function(a,b){return console.log("Error in "+b,a,a.message,a.stack)},onSuccess:function(a,b){var c;b==="component"&&(this.componentDefinition=a);if(b==="implementation"){Luca.isBackboneView(a)?c=a:_.isObject(a)&&a.ctype!=null?c=Luca(a):_.isObject(a)&&_.isFunction(this.componentDefinition)&&(c=new this.componentDefinition(a));if(Luca.isBackboneView(c))return this.getOutput().$html(c.render().el)}},applyTestRun:function(){var a,b,c,d;this.getOutput().$html(""),c=this.getTestRun(),d=[];for(a in c)b=c[a],d.push(this.evaluateCode(b,a));return d},toggleConsole:function(a){var b;return this.developmentConsole=Luca("coffeescript-console",function(){return new Luca.tools.DevelopmentConsole({name:"coffeescript-console"})}),this.consoleContainerAppended||(b=this.make("div",{id:"devtools-console-wrapper","class":"devtools-console-container modal",style:"width:900px;height:650px;"},this.developmentConsole.el),$("body").append(b),this.consoleContainerAppended=!0,this.developmentConsole.render()),$("#devtools-console-wrapper").modal({backdrop:!1,show:!0})},toggleAutoeval:function(a){var b,c;return this.autoEvaluateCode=this.autoEvaluateCode!==!0,!this.started&&this.autoEvaluateCode===!0&&(this.started=!0,this.applyTestRun()),c=a.children("i").eq(0),b=this.autoEvaluateCode?"icon-pause":"icon-play",c.removeClass(),c.addClass(b),this},showEditor:function(a){return this.getEditor().$(".toolbar-container.top").toggle(a),this.getEditor().$(".codemirror-wrapper").toggle(a),this.trigger("controls:toggled")},toggleKeymap:function(a){var b;return b=this.getEditor().keyMap==="vim"?"basic":"vim",this.getEditor().setKeyMap(b),a.html(_.string.capitalize(b))},toggleMode:function(a){var b;return b=this.getEditor().mode==="coffeescript"?"javascript":"coffeescript",this.getEditor().setMode(b),a.html(_.string.capitalize(b==="coffeescript"?"View Javascript":"View Coffeescript")),this.editBuffer(this.currentBufferName,b==="javascript")},toggleSize:function(a){var b,c,d,e;return c=this.currentSize++%this.sizes.length,e=this.sizes[c].value(),d=this.sizes[c].icon,a!=null&&(b=a.children("i").eq(0),b.removeClass().addClass("icon-"+d)),this.$(".codemirror-wrapper").css("height",""+parseInt(e)+"px"),this.getEditor().refresh()},toggleControls:function(a){var b=this;return this.bind("controls:toggled",function(){var c,d;return d=a.children("i").eq(0),d.removeClass(),c=b.getEditor().$(".toolbar-container.top").is(":visible")?"icon-eye-close":"icon-eye-open",d.addClass(c)}),this.showEditor(),this},toggleSettings:function(){return this},setValue:function(a,b){var c;return b==null&&(b="component"),c=this.getEditor().editor.getOption("mode")==="javascript",this.editBuffer(b,c,!1).getEditor().setValue(a)},editBuffer:function(a,b,c){var d;return this.currentBufferName=a,b==null&&(b=!1),c==null&&(c=!0),this.showEditor(!0),this.highlight(this.currentBufferName),d=b?"compiled_"+this.currentBufferName:this.currentBufferName,this.getEditor().loadBuffer(d,c),this},editMarkup:function(){return this.getEditor().setMode("htmlmixed"),this.getEditor().setWrap(!0),this.editBuffer("html").setValue(this.getOutput().$html(),"html")},editStyle:function(){return this.getEditor().setMode("css"),this.editBuffer("style")},editComponent:function(){return this.getEditor().setMode("coffeescript"),this.editBuffer("component")},editTeardown:function(){return this.getEditor().setMode("coffeescript"),this.editBuffer("teardown")},editSetup:function(){return this.getEditor().setMode("coffeescript"),this.editBuffer("setup")},editImplementation:function(){return this.getEditor().setMode("coffeescript"),this.editBuffer("implementation")},getTestRun:function(){var a,b,c,d,e,f;b=this.getEditor(),c={},f=["component","setup","implementation"];for(d=0,e=f.length;d<e;d++)a=f[d],c[a]=b.getBuffer(a,!0);return c},getContext:function(){return Luca.util.resolve(this.context||(this.context="window"))},evaluateCode:function(code,bufferId,compile){var compiled,evaluator,result;compile==null&&(compile=!1),code||(code=this.getEditor().getValue()),compiled=compile===!0?this.getEditor().compileCode(code):code,evaluator=function(){return eval(compiled)};try{return result=evaluator.call(this.getContext()),this.onSuccess(result,bufferId,code)}catch(error){return this.onError(error,bufferId,code)}},onMarkupChange:function(){if(this.autoEvaluateCode===!0)return this.getOutput().$html(this.getEditor().getValue())},onStyleChange:function(){var a,b,c;if(this.autoEvaluateCode===!0){$("#component-tester-stylesheet").remove(),a=(c=this.getEditor())!=null?c.getValue():void 0;if(a)return b=this.make("style",{type:"text/css",id:"component-tester-stylesheet"}),$("head").append(b),$(b).append(a)}},showHelp:function(){return this.getOutput().$html(Luca.template("component_tester/help",this))},addComponent:function(a){},openComponent:function(a){var b=this;this.componentPicker||(this.componentPicker=new ComponentPicker),this.componentPicker.bind("component:fetched",function(a,c){return b.setEditorNamespace(c).setValue(a,"component")});if(!this.getEditor().$(".component-picker").length>0){this.getEditor().$(".codemirror-wrapper").before(this.componentPicker.createWrapper()),this.getEditor().$(".component-picker").html(this.componentPicker.render().el),this.componentPicker.show();return}return this.componentPicker.toggle()},highlight:function(a){return this.$("a.btn[data-eventid='edit:"+a+"']").siblings().css("font-weight","normal"),this.$("a.btn[data-eventid='edit:"+a+"']").css("font-weight","bold")},setEditorNamespace:function(a){return this.getEditor().namespace(a),this.getEditor().buffers.fetch(),this}})}.call(this),function(){var developmentConsole,_base;developmentConsole=Luca.register("Luca.tools.DevelopmentConsole"),developmentConsole["extends"]("Luca.core.Container"),developmentConsole.defines({className:"luca-ui-console",name:"console",history:[],historyIndex:0,width:1e3,componentEvents:{"input key:keyup":"historyUp","input key:keydown":"historyDown","input key:enter":"runCommand"},compileOptions:{bare:!0},components:[{type:"code_mirror_field",role:"code_mirror",additionalClassNames:"clearfix",name:"code_output",readOnly:!0,lineNumbers:!1,mode:"javascript",lineWrapping:!0,gutter:!1},{type:"text_field",name:"code_input",role:"input",lineNumbers:!1,height:"30px",maxHeight:"30px",gutter:!1,autoBindEventHandlers:!0,hideLabel:!0,prepend:"Coffee>",events:{"keypress input":"onKeyEvent","keydown input":"onKeyEvent"},onKeyEvent:function(a){a.type==="keypress"&&a.keyCode===Luca.keys.ENTER&&this.trigger("key:enter",this.getValue()),a.type==="keydown"&&a.keyCode===Luca.keys.KEYUP&&this.trigger("key:keyup");if(a.type==="keydown"&&a.keyCode===Luca.keys.KEYDOWN)return this.trigger("key:keydown")},afterRender:function(){return this.$("input").focus()}}],afterRender:function(){var a;this.$container().modal({backdrop:!1});if(this.width!=null)return a=parseInt(this.width)*.5*-1,this.$container().css("width",this.width).css("margin-left",parseInt(a))},show:function(a){return a==null&&(a={}),this.$container().modal("show"),this},getContext:function(){return window},initialize:function(){return this._super("initialize",this,arguments),_.bindAll(this,"historyUp","historyDown","onSuccess","onError","runCommand")},saveHistory:function(a){return(a!=null?a.length:void 0)>0&&this.history.push(a),this.historyIndex=0},historyUp:function(){var a;return this.historyIndex-=1,this.historyIndex<0&&(this.historyIndex=0),a=this.getInput().getValue(),this.getInput().setValue(this.history[this.historyIndex]||a)},historyDown:function(){var a;return this.historyIndex+=1,this.historyIndex>this.history.length-1&&(this.historyIndex=this.history.length-1),a=this.getInput().getValue(),this.getInput().setValue(this.history[this.historyIndex]||a)},append:function(a,b,c){var d,e,f,g;return c==null&&(c=!1),e=this.getCodeMirror(),d=e.getValue(),a!=null&&(g="// "+a),f=c||a.match(/^console\.log/)?[d,b]:[d,g,b],e.setValue(_.compact(f).join("\n")),e.getCodeMirror().scrollTo(0,9e4)},onSuccess:function(a,b,c){var d;this.saveHistory(c),d="";if(_.isArray(a)||_.isObject(a)||_.isString(a)||_.isNumber(a))d=JSON.stringify(a,null," ");return d||(d=typeof a.toString=="function"?a.toString():void 0),this.append(b,d||"undefined")},onError:function(a,b,c){return this.append(b,"// ERROR: "+a.message)},evaluateCode:function(code,raw){var dev,evaluator,output,result;if(!((code!=null?code.length:void 0)>0))return;raw=_.string.strip(raw),output=this.getCodeMirror(),dev=this,evaluator=function(){var console,log,old_console,result;old_console=window.console,console={log:function(){var a,b,c,d;d=[];for(b=0,c=arguments.length;b<c;b++)a=arguments[b],d.push(dev.append(void 0,a,!0));return d}},log=console.log;try{result=eval(code)}catch(error){throw window.console=old_console,error}return window.console=old_console,result};try{result=evaluator.call(this.getContext()),Luca.isComponent(result)?result=Luca.util.inspectComponent(result):Luca.isComponentPrototype(result)&&(result=Luca.util.inspectComponentPrototype(result));if(!raw.match(/^console\.log/))return this.onSuccess(result,code,raw)}catch(error){return this.onError(error,code,raw)}},runCommand:function(){var a,b,c,d;return c=this,a=_.bind(Luca.tools.CoffeeEditor.prototype.compile,this),d=this.getInput().getValue(),b=a(d,function(a){return c.evaluateCode(a,d)})}}),(_base=Luca.util).launchers||(_base.launchers={}),Luca.util.inspectComponentPrototype=function(a){var b;return b=Luca.registry.findInstancesByClass(a)},Luca.util.inspectComponent=function(a){return _.isString(a)&&(a=Luca(a)),{name:a.name,instanceOf:a.displayName,subclassOf:a._superClass().prototype.displayName,inheritsFrom:Luca.parentClasses(a)}},Luca.util.launchers.developmentConsole=function(a){var b=this;return a==null&&(a="luca-development-console"),this._lucaDevConsole=Luca(a,function(){var c;return b.$el.append(Backbone.View.prototype.make("div",{id:""+a+"-wrapper","class":"modal fade large"})),c=new Luca.tools.DevelopmentConsole({name:a,container:"#"+a+"-wrapper"}),c.render(),c.getCodeMirror().setHeight(602)}),this._lucaDevConsole.show()}}.call(this),function(){_.def("Luca.app.Component")["extends"]("Luca.Model")["with"]({root:function(){return this.get("className").split(".")[0]},className:function(){return this.get("className")},instances:function(){return Luca.registry.findInstancesByClassName(this.className())},definitionPrototype:function(){var a;return(a=this.definition())!=null?a.prototype:void 0},parentClasses:function(){return Luca.parentClasses(this.className())},definition:function(){return Luca.util.resolve(this.className())},namespace:function(){var a;return this.get("className")==null?"":(a=this.get("className").split("."),a.pop(),a.join("."))}})}.call(this),function(){_.def("Luca.app.Instance")["extends"]("Luca.Model")["with"]({version:1})}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["component_tester/help"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<h1>Component Tester</h1>\n<p>This is a tool that enables you to build and test Luca components in an isolated sandbox environment. The editor is currently enabled with vim keybindings</p>\n<h3>Setup</h3>\n<p>This is where you setup any data requirements needed for the test to work. This is run every time before the implementation code is ran.</p>\n<h3>Teardown</h3>\n<p>This is where you clean up after the tests. This will be run every time after the implementation code is ran.</p>\n<h3>Definitions</h3>\n<p>This is where you define the component you will be testing. This is usually the code you will be shipping once you have completed testing.</p>\n<h3>Implementation</h3>\n<p>This is where you create an instance of the component and specify any of the necessary configuration settings. The component will be rendered into the output panel of the component tester.</p>\n");return __p.join("")}}.call(this),function(){}.call(this);
|