diff --git a/dist/docs/assets/css/docs.css b/dist/docs/assets/css/docs.css new file mode 100644 index 00000000..7cbe28ca --- /dev/null +++ b/dist/docs/assets/css/docs.css @@ -0,0 +1,414 @@ +@charset "UTF-8"; +form, +img, +ul, +ol, +table, +td, +article, +figure, +figcaption { + margin: 0; + padding: 0; + border: 0; } + +a { + outline: none; + border: 0; } + +ul, +ol { + list-style: none outside none; } + +table { + border-spacing: 0; } + +td { + vertical-align: top; } + +html { + -webkit-text-size-adjust: none; } + +/* Content Styles */ +article { + /* Text Content */ } + article, + article a { + color: #333333; } + article a { + border-bottom: 1px solid; } + article a:hover, + article a:hover em { + background: #e5e5e5; } + article em { + font-style: normal; + background: #efefef; } + article p, + article ul, + article ol { + margin: 0 8px 16px 0; } + article p.small, + article ul.small, + article ol.small { + margin-bottom: 8px; } + article figure, + article .CodeMirror, + article .paperscript { + margin-bottom: 16px; } + article ul, + article ol { + padding: 0; + list-style: none outside none; } + article ul ul, + article ul ol, + article ol ul, + article ol ol { + margin-bottom: 0; } + article ul > li { + margin-left: 1em; + position: relative; } + article ul > li:before { + content: '–'; + position: absolute; + left: -1em; } + article ol { + counter-reset: item; } + article ol > li { + margin-left: 1.5em; + position: relative; } + article ol > li:before { + position: absolute; + left: -1.5em; + content: counter(item,upper-latin) ") "; + counter-increment: item; } + +section { + clear: both; + margin: 0 0 16px; + padding: 0; } + +.column { + width: 260px; + float: left; } + .column + .column { + margin-left: 16px; } + +.row { + clear: both; } + +.donation { + padding-bottom: 16px; } + .donation input, + .donation select { + margin-right: 0.35em; } + +.reference h1, +.reference h2, +.reference h3, +.reference h4 { + font-size: 13px; + font-weight: normal; + margin: 0; } +.reference h1, +.reference h2, +.reference h3 { + height: 18px; + border-bottom: 1px solid; + margin-bottom: 16px; } +.reference h2 a { + font-weight: bold; } +.reference h3 { + margin-top: 16px; + border-bottom-style: dotted; } +.reference h4 { + font-weight: bold; } + .reference h4 .description { + font-weight: normal; } + .reference h4 .description:before { + content: ' — '; } + .reference h4 + ul, .reference h4 + pre, .reference h4 + .paperscript { + margin-top: 8px; + margin-bottom: 16px; } +.reference a tt { + line-height: 17px; } +.reference ul, +.reference p { + margin-bottom: 16px; } +.reference hr { + border: none; + border-bottom: 1px dotted; } +.reference .reference-list ul, +.reference .reference-inherited ul { + margin-left: 16px; } +.reference .reference-inherited ul li { + text-indent: -30px; + padding-left: 30px; } +.reference ul.reference-classes { + padding-bottom: 4px; } + .reference ul.reference-classes li { + margin: 0; + text-indent: 0; } + .reference ul.reference-classes ul { + margin: 0 0 10px 10px; } + .reference ul.reference-classes h2, + .reference ul.reference-classes h3, + .reference ul.reference-classes hr { + margin: 10px 0 10px 0; } + .reference ul.reference-classes .first h2 { + margin-top: 0; } + * html .reference ul.reference-classes img { + margin-top: 5px; } +.reference ul.member-list li { + margin-left: 2em; + margin-bottom: 8px; + text-indent: -2em; } + .reference ul.member-list li:before { + display: none; } +.reference .reference-members { + margin-bottom: 16px; } +.reference .member-group-text { + margin-bottom: 16px; } +.reference .member-description { + border: 1px solid #999; + border-top: 0; + margin: 16px 0 16px 0; } +.reference .member-header { + border-top: 1px solid #999; + padding: 10px; + *zoom: 1; } + .reference .member-header .member-link { + float: left; } + .reference .member-header .member-close { + float: right; } + .reference .member-header:before, .reference .member-header:after { + content: " "; + display: table; } + .reference .member-header:after { + clear: both; } +.reference .member-text { + border-top: 1px dashed #999; + padding: 10px 10px 0 10px; + margin-bottom: -6px; } + .reference .member-text ul ul, + .reference .member-text ul ol, + .reference .member-text ol ul, + .reference .member-text ol ol, + .reference .member-text ul p, + .reference .member-text ol p { + margin-bottom: 8px; } +.reference .member-link { + text-indent: -30px; + padding-left: 30px; } + +body, +select, +input, +textarea { + font-family: "Lucida Grande", Geneva, Verdana, Arial, sans-serif; } + +tt, +pre, +.CodeMirror { + font-family: Menlo, Consolas, "Vera Mono", monospace; + font-size: 12px; + line-height: 17px; } + +body { + background: #fff; + margin: 16px; + font-size: 13px; + line-height: 20px; + color: #333333; + max-width: 540px; } + +select, +input, +textarea { + font-size: 11px; + margin: 0; + color: #000; } + +a { + color: #333333; + text-decoration: none; + border-bottom: 1px solid #333333; } + a:hover { + background: #e5e5e5; } + +img { + border: 0; } + +p { + margin: 0 0 16px 0; } + +ul, +ol { + padding: 0; + margin: 0 0 16px 0; + list-style: none; } + +.clear { + clear: both; } + +.hidden { + display: none; } + +.reference-index, +.reference-index a { + color: #009dec; + border-bottom: 0px; } +.reference-index a:hover { + background: #e3f4fc; } +.reference-index h2, +.reference-index h3, +.reference-index hr { + border-color: #009dec; } + +.reference h1 { + font-size: 18px; + font-weight: normal; + line-height: 24px; + border: none; } + .reference h1 .version { + font-size: 10px; + line-height: 16px; + vertical-align: top; + margin-left: 0.35em; } + +.footer { + margin-top: 16px; } + +.CodeMirror pre { + margin: 0; + padding: 0; + background: transparent; } +.paperscript .CodeMirror { + height: 100%; } + +.CodeMirror-scroll { + min-height: 100%; + overflow: auto; } + +.CodeMirror-gutter { + position: absolute; + left: 0; + top: 0; + min-width: 30px; + height: 100%; + background-color: #f4f4f4; + border-right: 1px solid #999; } + +.CodeMirror-gutter-text { + color: #aaa; + text-align: right; + padding: 2px 8px 2px 8px; } + .CodeMirror-gutter-text pre { + font-size: 10px; } + +.CodeMirror-lines { + background: #ffffff; + padding: 2px 0 2px 8px; } + .CodeMirror-lines pre.highlight { + background-color: #edf5fc; } + +.CodeMirror-cursor { + z-index: 10; + position: absolute; + visibility: hidden; + border-left: 1px solid #7c7c7c !important; + height: 17px; } + +.CodeMirror-selected { + background: #ccc !important; + color: HighlightText !important; + padding: 2px 0 2px 0; } + +.CodeMirror-focused .CodeMirror-cursor { + visibility: visible; } +.CodeMirror-focused .CodeMirror-selected { + background: Highlight !important; } + +.CodeMirror-matchingbracket { + background: #e3fc8d !important; } + +.CodeMirror-nonmatchingbracket { + color: #d62a28 !important; } + +/* JavaScript & HTML Modes */ +span.cm-keyword { + color: #ff7800; } +span.cm-atom, span.cm-number { + color: #3b5bb5; } +span.cm-def, span.cm-variable-2, span.cm-variable-3 { + color: #3a4a64; } +span.cm-variable { + color: #000; } +span.cm-property { + color: #000; } +span.cm-operator { + color: #000; } +span.cm-comment { + color: #8c868f; } +span.cm-string { + color: #409b1c; } +span.cm-meta { + color: #555; } +span.cm-error { + color: #f30; } +span.cm-qualifier { + color: #555; } +span.cm-builtin { + color: #30a; } +span.cm-bracket { + color: #cc7; } +span.cm-tag { + font-weight: bold; + color: #3b5bb5; } +span.cm-attribute { + font-style: italic; + color: #3b5bb5; } + +.paperscript { + position: relative; } + .paperscript .buttons { + position: absolute; + right: 0; + z-index: 1; } + .paperscript .button, + .paperscript .explain { + float: right; + display: none; + font-size: 12px; + line-height: 16px; + padding: 2px 6px; + border-radius: 4px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + margin: 8px 8px 0 0; } + .paperscript .button { + background: #eee; } + .paperscript .explain { + background: #e3f4fc; } + .paperscript .explain, .paperscript:hover .button { + display: inline-block; } + .paperscript .button:hover { + background: #ddd; + cursor: pointer; } + .paperscript .tools { + display: inline; } + .paperscript .source { + overflow: auto; + border: 1px solid #999; } + .paperscript .CodeMirror { + margin: 0 !important; } + .paperscript .CodeMirror-gutter-text, + .paperscript .CodeMirror-lines { + padding-top: 8px; + padding-bottom: 8px; } + .paperscript .canvas { + line-height: 0; } + .paperscript .canvas.border canvas { + border: 1px solid #999; } + .paperscript.split .canvas { + border: 1px solid #999; + border-top: 0; } diff --git a/dist/docs/assets/js/codemirror.js b/dist/docs/assets/js/codemirror.js new file mode 100644 index 00000000..18d2dda5 --- /dev/null +++ b/dist/docs/assets/js/codemirror.js @@ -0,0 +1,4 @@ +window.CodeMirror=function(){"use strict";function CodeMirror(place,givenOptions){var options={},defaults=CodeMirror.defaults;for(var opt in defaults)if(defaults.hasOwnProperty(opt))options[opt]=(givenOptions&&givenOptions.hasOwnProperty(opt)?givenOptions:defaults)[opt];var input=elt("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em");input.setAttribute("wrap","off");input.setAttribute("autocorrect","off");input.setAttribute("autocapitalize","off");var inputDiv=elt("div",[input],null,"overflow: hidden; position: relative; width: 3px; height: 0px;");var scrollbarInner=elt("div",null,"CodeMirror-scrollbar-inner");var scrollbar=elt("div",[scrollbarInner],"CodeMirror-scrollbar");var lineDiv=elt("div"),selectionDiv=elt("div",null,null,"position: relative; z-index: -1");var cursor=elt("pre"," ","CodeMirror-cursor"),widthForcer=elt("pre"," ","CodeMirror-cursor","visibility: hidden");var measure=elt("div",null,null,"position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden;");var lineSpace=elt("div",[measure,cursor,widthForcer,selectionDiv,lineDiv],null,"position: relative; z-index: 0");var gutterText=elt("div",null,"CodeMirror-gutter-text"),gutter=elt("div",[gutterText],"CodeMirror-gutter");var mover=elt("div",[gutter,elt("div",[lineSpace],"CodeMirror-lines")],null,"position: relative");var sizer=elt("div",[mover],null,"position: relative");var scroller=elt("div",[sizer],"CodeMirror-scroll");scroller.setAttribute("tabIndex","-1");var wrapper=elt("div",[inputDiv,scrollbar,scroller],"CodeMirror"+(options.lineWrapping?" CodeMirror-wrap":""));if(place.appendChild)place.appendChild(wrapper);else place(wrapper);themeChanged();keyMapChanged();if(ios)input.style.width="0px";if(!webkit)scroller.draggable=true;lineSpace.style.outline="none";if(options.tabindex!=null)input.tabIndex=options.tabindex;if(options.autofocus)focusInput();if(!options.gutter&&!options.lineNumbers)gutter.style.display="none";if(khtml)inputDiv.style.height="1px",inputDiv.style.position="absolute";if(mac_geLion){scrollbar.style.zIndex=-2;scrollbar.style.visibility="hidden"}else if(ie_lt8)scrollbar.style.minWidth="18px";var poll=new Delayed,highlight=new Delayed,blinker;var mode,doc=new BranchChunk([new LeafChunk([new Line("")])]),frontier=0,focused;loadMode();var sel={from:{line:0,ch:0},to:{line:0,ch:0},inverted:false};var shiftSelecting,lastClick,lastDoubleClick,lastScrollTop=0,draggingText,overwrite=false,suppressEdits=false,pasteIncoming=false;var updateInput,userSelChange,changes,textChanged,selectionChanged,gutterDirty,callbacks;var displayOffset=0,showingFrom=0,showingTo=0,lastSizeC=0;var bracketHighlighted;var maxLine=getLine(0),updateMaxLine=false,maxLineChanged=true;var pollingFast=false;var goalColumn=null;operation(function(){setValue(options.value||"");updateInput=false})();var history=new History;connect(scroller,"mousedown",operation(onMouseDown));connect(scroller,"dblclick",operation(onDoubleClick));connect(lineSpace,"selectstart",e_preventDefault);if(!gecko)connect(scroller,"contextmenu",onContextMenu);connect(scroller,"scroll",onScrollMain);connect(scrollbar,"scroll",onScrollBar);connect(scrollbar,"mousedown",function(){if(focused)setTimeout(focusInput,0)});var resizeHandler=connect(window,"resize",function(){if(wrapper.parentNode)updateDisplay(true);else resizeHandler()},true);connect(input,"keyup",operation(onKeyUp));connect(input,"input",fastPoll);connect(input,"keydown",operation(onKeyDown));connect(input,"keypress",operation(onKeyPress));connect(input,"focus",onFocus);connect(input,"blur",onBlur);function drag_(e){if(options.onDragEvent&&options.onDragEvent(instance,addStop(e)))return;e_stop(e)}if(options.dragDrop){connect(scroller,"dragstart",onDragStart);connect(scroller,"dragenter",drag_);connect(scroller,"dragover",drag_);connect(scroller,"drop",operation(onDrop))}connect(scroller,"paste",function(){focusInput();fastPoll()});connect(input,"paste",function(){pasteIncoming=true;fastPoll()});connect(input,"cut",operation(function(){if(!options.readOnly)replaceSelection("")}));if(khtml)connect(sizer,"mouseup",function(){if(document.activeElement==input)input.blur();focusInput()});var hasFocus;try{hasFocus=document.activeElement==input}catch(e){}if(hasFocus||options.autofocus)setTimeout(onFocus,20);else onBlur();function isLine(l){return l>=0&&lvspace&&pos.y>node.offsetHeight)top=pos.y-node.offsetHeight;if(left+node.offsetWidth>hspace)left=hspace-node.offsetWidth}node.style.top=top+paddingTop()+"px";node.style.left=node.style.right="";if(horiz=="right"){left=sizer.clientWidth-node.offsetWidth;node.style.right="0px"}else{if(horiz=="left")left=0;else if(horiz=="middle")left=(sizer.clientWidth-node.offsetWidth)/2;node.style.left=left+paddingLeft()+"px"}if(scroll)scrollIntoView(left,top,left+node.offsetWidth,top+node.offsetHeight)},lineCount:function(){return doc.size},clipPos:clipPos,getCursor:function(start){if(start==null||start=="head")start=sel.inverted;if(start=="anchor")start=!sel.inverted;if(start=="end")start=false;return copyPos(start?sel.from:sel.to)},somethingSelected:function(){return!posEq(sel.from,sel.to)},setCursor:operation(function(line,ch,user){if(ch==null&&typeof line.line=="number")setCursor(line.line,line.ch,user);else setCursor(line,ch,user)}),setSelection:operation(function(from,to,user){(user?setSelectionUser:setSelection)(clipPos(from),clipPos(to||from))}),getLine:function(line){if(isLine(line))return getLine(line).text},getLineHandle:function(line){if(isLine(line))return getLine(line)},setLine:operation(function(line,text){if(isLine(line))replaceRange(text,{line:line,ch:0},{line:line,ch:getLine(line).text.length})}),removeLine:operation(function(line){if(isLine(line))replaceRange("",{line:line,ch:0},clipPos({line:line+1,ch:0}))}),replaceRange:operation(replaceRange),getRange:function(from,to,lineSep){return getRange(clipPos(from),clipPos(to),lineSep)},triggerOnKeyDown:operation(onKeyDown),execCommand:function(cmd){return commands[cmd](instance)},moveH:operation(moveH),deleteH:operation(deleteH),moveV:operation(moveV),toggleOverwrite:function(){if(overwrite){overwrite=false;cursor.className=cursor.className.replace(" CodeMirror-overwrite","")}else{overwrite=true;cursor.className+=" CodeMirror-overwrite"}},posFromIndex:function(off){var lineNo=0,ch;doc.iter(0,doc.size,function(line){var sz=line.text.length+1;if(sz>off){ch=off;return true}off-=sz;++lineNo});return clipPos({line:lineNo,ch:ch})},indexFromPos:function(coords){if(coords.line<0||coords.ch<0)return 0;var index=coords.ch;doc.iter(0,coords.line,function(line){index+=line.text.length+1});return index},scrollTo:function(x,y){if(x!=null)scroller.scrollLeft=x;if(y!=null)scrollbar.scrollTop=scroller.scrollTop=y;updateDisplay([])},getScrollInfo:function(){return{x:scroller.scrollLeft,y:scrollbar.scrollTop,height:scrollbar.scrollHeight,width:scroller.scrollWidth}},scrollIntoView:function(pos){var coords=localCoords(pos?clipPos(pos):sel.inverted?sel.from:sel.to);scrollIntoView(coords.x,coords.y,coords.x,coords.yBot)},setSize:function(width,height){function interpret(val){val=String(val);return/^\d+$/.test(val)?val+"px":val}if(width!=null)wrapper.style.width=interpret(width);if(height!=null)scroller.style.height=interpret(height);instance.refresh()},operation:function(f){return operation(f)()},compoundChange:function(f){return compoundChange(f)},refresh:function(){updateDisplay(true,null,lastScrollTop);if(scrollbar.scrollHeight>lastScrollTop)scrollbar.scrollTop=lastScrollTop},getInputField:function(){return input},getWrapperElement:function(){return wrapper},getScrollerElement:function(){return scroller},getGutterElement:function(){return gutter}};function getLine(n){return getLineAt(doc,n)}function updateLineHeight(line,height){gutterDirty=true;var diff=height-line.height;for(var n=line;n;n=n.parent)n.height+=diff}function lineContent(line,wrapAt){if(!line.styles)line.highlight(mode,line.stateAfter=getStateBefore(lineNo(line)),options.tabSize);return line.getContent(options.tabSize,wrapAt,options.lineWrapping)}function setValue(code){var top={line:0,ch:0};updateLines(top,{line:doc.size-1,ch:getLine(doc.size-1).text.length},splitLines(code),top,top);updateInput=true}function getValue(lineSep){var text=[];doc.iter(0,doc.size,function(line){text.push(line.text)});return text.join(lineSep||"\n")}function onScrollBar(e){if(Math.abs(scrollbar.scrollTop-lastScrollTop)>1){lastScrollTop=scroller.scrollTop=scrollbar.scrollTop;updateDisplay([])}}function onScrollMain(e){if(options.fixedGutter&&gutter.style.left!=scroller.scrollLeft+"px")gutter.style.left=scroller.scrollLeft+"px";if(Math.abs(scroller.scrollTop-lastScrollTop)>1){lastScrollTop=scroller.scrollTop;if(scrollbar.scrollTop!=lastScrollTop)scrollbar.scrollTop=lastScrollTop;updateDisplay([])}if(options.onScroll)options.onScroll(instance)}function onMouseDown(e){setShift(e_prop(e,"shiftKey"));for(var n=e_target(e);n!=wrapper;n=n.parentNode)if(n.parentNode==sizer&&n!=mover)return;for(var n=e_target(e);n!=wrapper;n=n.parentNode)if(n.parentNode==gutterText){if(options.onGutterClick)options.onGutterClick(instance,indexOf(gutterText.childNodes,n)+showingFrom,e);return e_preventDefault(e)}var start=posFromMouse(e);switch(e_button(e)){case 3:if(gecko)onContextMenu(e);return;case 2:if(start)setCursor(start.line,start.ch,true);setTimeout(focusInput,20);e_preventDefault(e);return}if(!start){if(e_target(e)==scroller)e_preventDefault(e);return}if(!focused)onFocus();var now=+new Date,type="single";if(lastDoubleClick&&lastDoubleClick.time>now-400&&posEq(lastDoubleClick.pos,start)){type="triple";e_preventDefault(e);setTimeout(focusInput,20);selectLine(start.line)}else if(lastClick&&lastClick.time>now-400&&posEq(lastClick.pos,start)){type="double";lastDoubleClick={time:now,pos:start};e_preventDefault(e);var word=findWordAt(start);setSelectionUser(word.from,word.to)}else{lastClick={time:now,pos:start}}function dragEnd(e2){if(webkit)scroller.draggable=false;draggingText=false;up();drop();if(Math.abs(e.clientX-e2.clientX)+Math.abs(e.clientY-e2.clientY)<10){e_preventDefault(e2);setCursor(start.line,start.ch,true);focusInput()}}var last=start,going;if(options.dragDrop&&dragAndDrop&&!options.readOnly&&!posEq(sel.from,sel.to)&&!posLess(start,sel.from)&&!posLess(sel.to,start)&&type=="single"){if(webkit)scroller.draggable=true;var up=connect(document,"mouseup",operation(dragEnd),true);var drop=connect(scroller,"drop",operation(dragEnd),true);draggingText=true;if(scroller.dragDrop)scroller.dragDrop();return}e_preventDefault(e);if(type=="single")setCursor(start.line,start.ch,true);var startstart=sel.from,startend=sel.to;function doSelect(cur){if(type=="single"){setSelectionUser(clipPos(start),cur);return}startstart=clipPos(startstart);startend=clipPos(startend);if(type=="double"){var word=findWordAt(cur);if(posLess(cur,startstart))setSelectionUser(word.from,startend);else setSelectionUser(startstart,word.to)}else if(type=="triple"){if(posLess(cur,startstart))setSelectionUser(startend,clipPos({line:cur.line,ch:0}));else setSelectionUser(startstart,clipPos({line:cur.line+1,ch:0}))}}function extend(e){var cur=posFromMouse(e,true);if(cur&&!posEq(cur,last)){if(!focused)onFocus();last=cur;doSelect(cur);updateInput=false;var visible=visibleLines();if(cur.line>=visible.to||cur.line-1)setTimeout(operation(function(){indentLine(sel.to.line,"smart")}),75)}if(handleCharBinding(e,ch))return;fastPoll()}function onKeyUp(e){if(options.onKeyEvent&&options.onKeyEvent(instance,addStop(e)))return;if(e_prop(e,"keyCode")==16)shiftSelecting=null}function onFocus(){if(options.readOnly=="nocursor")return;if(!focused){if(options.onFocus)options.onFocus(instance);focused=true;if(scroller.className.search(/\bCodeMirror-focused\b/)==-1)scroller.className+=" CodeMirror-focused"}slowPoll();restartBlink()}function onBlur(){if(focused){if(options.onBlur)options.onBlur(instance);focused=false;if(bracketHighlighted)operation(function(){if(bracketHighlighted){bracketHighlighted();bracketHighlighted=null}})();scroller.className=scroller.className.replace(" CodeMirror-focused","")}clearInterval(blinker);setTimeout(function(){if(!focused)shiftSelecting=null},150)}function updateLines(from,to,newText,selFrom,selTo){if(suppressEdits)return;var old=[];doc.iter(from.line,to.line+1,function(line){old.push(newHL(line.text,line.markedSpans))});if(history){history.addChange(from.line,newText.length,old);while(history.done.length>options.undoDepth)history.done.shift()}var lines=updateMarkedSpans(hlSpans(old[0]),hlSpans(lst(old)),from.ch,to.ch,newText);updateLinesNoUndo(from,to,lines,selFrom,selTo)}function unredoHelper(from,to){if(!from.length)return;var set=from.pop(),out=[];for(var i=set.length-1;i>=0;i-=1){var change=set[i];var replaced=[],end=change.start+change.added;doc.iter(change.start,end,function(line){replaced.push(newHL(line.text,line.markedSpans))});out.push({start:change.start,added:change.old.length,old:replaced});var pos={line:change.start+change.old.length-1,ch:editEnd(hlText(lst(replaced)),hlText(lst(change.old)))};updateLinesNoUndo({line:change.start,ch:0},{line:end-1,ch:getLine(end-1).text.length},change.old,pos,pos)}updateInput=true;to.push(out)}function undo(){unredoHelper(history.done,history.undone)}function redo(){unredoHelper(history.undone,history.done)}function updateLinesNoUndo(from,to,lines,selFrom,selTo){if(suppressEdits)return;var recomputeMaxLength=false,maxLineLength=maxLine.text.length;if(!options.lineWrapping)doc.iter(from.line,to.line+1,function(line){if(!line.hidden&&line.text.length==maxLineLength){recomputeMaxLength=true;return true}});if(from.line!=to.line||lines.length>1)gutterDirty=true;var nlines=to.line-from.line,firstLine=getLine(from.line),lastLine=getLine(to.line);var lastHL=lst(lines);if(from.ch==0&&to.ch==0&&hlText(lastHL)==""){var added=[],prevLine=null;for(var i=0,e=lines.length-1;i1)doc.remove(from.line+1,nlines-1,callbacks);doc.insert(from.line+1,added)}if(options.lineWrapping){var perLine=Math.max(5,scroller.clientWidth/charWidth()-3);doc.iter(from.line,from.line+lines.length,function(line){if(line.hidden)return;var guess=Math.ceil(line.text.length/perLine)||1;if(guess!=line.height)updateLineHeight(line,guess)})}else{doc.iter(from.line,from.line+lines.length,function(line){var l=line.text;if(!line.hidden&&l.length>maxLineLength){maxLine=line;maxLineLength=l.length;maxLineChanged=true;recomputeMaxLength=false}});if(recomputeMaxLength)updateMaxLine=true}frontier=Math.min(frontier,from.line);startWorker(400);var lendiff=lines.length-nlines-1;changes.push({from:from.line,to:to.line+1,diff:lendiff});if(options.onChange){for(var i=0;iscroller.offsetHeight?realHeight:false}function updateVerticalScroll(scrollTop){var scrollHeight=needsScrollbar();scrollbar.style.display=scrollHeight?"block":"none";if(scrollHeight){scrollbarInner.style.height=sizer.style.minHeight=scrollHeight+"px";scrollbar.style.height=scroller.clientHeight+"px";if(scrollTop!=null){scrollbar.scrollTop=scroller.scrollTop=scrollTop;if(webkit)setTimeout(function(){if(scrollbar.scrollTop!=scrollTop)return;scrollbar.scrollTop=scrollTop+(scrollTop?-1:1);scrollbar.scrollTop=scrollTop},0)}}else{sizer.style.minHeight=""}mover.style.top=displayOffset*textHeight()+"px"}function computeMaxLength(){maxLine=getLine(0);maxLineChanged=true;var maxLineLength=maxLine.text.length;doc.iter(1,doc.size,function(line){var l=line.text;if(!line.hidden&&l.length>maxLineLength){maxLineLength=l.length;maxLine=line}});updateMaxLine=false}function replaceRange(code,from,to){from=clipPos(from);if(!to)to=from;else to=clipPos(to);code=splitLines(code);function adjustPos(pos){if(posLess(pos,from))return pos;if(!posLess(to,pos))return end;var line=pos.line+code.length-(to.line-from.line)-1;var ch=pos.ch;if(pos.line==to.line)ch+=lst(code).length-(to.ch-(to.line==from.line?from.ch:0));return{line:line,ch:ch}}var end;replaceRange1(code,from,to,function(end1){end=end1;return{from:adjustPos(sel.from),to:adjustPos(sel.to)}});return end}function replaceSelection(code,collapse){replaceRange1(splitLines(code),sel.from,sel.to,function(end){if(collapse=="end")return{from:end,to:end};else if(collapse=="start")return{from:sel.from,to:sel.from};else return{from:sel.from,to:end}})}function replaceRange1(code,from,to,computeSel){var endch=code.length==1?code[0].length+from.ch:lst(code).length;var newSel=computeSel({line:from.line+code.length-1,ch:endch});updateLines(from,to,code,newSel.from,newSel.to)}function getRange(from,to,lineSep){var l1=from.line,l2=to.line;if(l1==l2)return getLine(l1).text.slice(from.ch,to.ch);var code=[getLine(l1).text.slice(from.ch)];doc.iter(l1+1,l2,function(line){code.push(line.text)});code.push(getLine(l2).text.slice(0,to.ch));return code.join(lineSep||"\n")}function getSelection(lineSep){return getRange(sel.from,sel.to,lineSep)}function slowPoll(){if(pollingFast)return;poll.set(options.pollInterval,function(){readInput();if(focused)slowPoll()})}function fastPoll(){var missed=false;pollingFast=true;function p(){var changed=readInput();if(!changed&&!missed){missed=true;poll.set(60,p)}else{pollingFast=false;slowPoll()}}poll.set(20,p)}var prevInput="";function readInput(){if(!focused||hasSelection(input)||options.readOnly)return false;var text=input.value;if(text==prevInput)return false;if(!nestedOperation)startOperation();shiftSelecting=null;var same=0,l=Math.min(prevInput.length,text.length);while(same1e3){input.value=prevInput=""}else prevInput=text;if(!nestedOperation)endOperation();pasteIncoming=false;return true}function resetInput(user){if(!posEq(sel.from,sel.to)){prevInput="";input.value=getSelection();if(focused)selectInput(input)}else if(user)prevInput=input.value=""}function focusInput(){if(options.readOnly!="nocursor"&&(ie_lt9||document.activeElement!=input))input.focus()}function scrollCursorIntoView(){var coords=calculateCursorCoords();scrollIntoView(coords.x,coords.y,coords.x,coords.yBot);if(!focused)return;var box=sizer.getBoundingClientRect(),doScroll=null;if(coords.y+box.top<0)doScroll=true;else if(coords.y+box.top+textHeight()>(window.innerHeight||document.documentElement.clientHeight))doScroll=false;if(doScroll!=null){var hidden=cursor.style.display=="none";if(hidden){cursor.style.display="";cursor.style.left=coords.x+"px";cursor.style.top=coords.y-displayOffset+"px"}cursor.scrollIntoView(doScroll);if(hidden)cursor.style.display="none"}}function calculateCursorCoords(){var cursor=localCoords(sel.inverted?sel.from:sel.to);var x=options.lineWrapping?Math.min(cursor.x,lineSpace.offsetWidth):cursor.x;return{x:x,y:cursor.y,yBot:cursor.yBot}}function scrollIntoView(x1,y1,x2,y2){var scrollPos=calculateScrollPos(x1,y1,x2,y2);if(scrollPos.scrollLeft!=null){scroller.scrollLeft=scrollPos.scrollLeft}if(scrollPos.scrollTop!=null){scrollbar.scrollTop=scroller.scrollTop=scrollPos.scrollTop}}function calculateScrollPos(x1,y1,x2,y2){var pl=paddingLeft(),pt=paddingTop();y1+=pt;y2+=pt;x1+=pl;x2+=pl;var screen=scroller.clientHeight,screentop=scrollbar.scrollTop,result={};var docBottom=needsScrollbar()||Infinity;var atTop=y1docBottom-10;if(y1screentop+screen)result.scrollTop=(atBottom?docBottom:y2)-screen;var screenw=scroller.clientWidth,screenleft=scroller.scrollLeft;var gutterw=options.fixedGutter?gutter.clientWidth:0;var atLeft=x1screenw+screenleft-3){result.scrollLeft=x2+10-screenw}return result}function visibleLines(scrollTop){var lh=textHeight(),top=(scrollTop!=null?scrollTop:scrollbar.scrollTop)-paddingTop();var fromHeight=Math.max(0,Math.floor(top/lh));var toHeight=Math.ceil((top+scroller.clientHeight)/lh);return{from:lineAtHeight(doc,fromHeight),to:lineAtHeight(doc,toHeight)}}function updateDisplay(changes,suppressCallback,scrollTop){if(!scroller.clientWidth){showingFrom=showingTo=displayOffset=0;return}var visible=visibleLines(scrollTop);if(changes!==true&&changes.length==0&&visible.from>showingFrom&&visible.toto&&showingTo-to<20)to=Math.min(doc.size,showingTo);var intact=changes===true?[]:computeIntact([{from:showingFrom,to:showingTo,domStart:0}],changes);var intactLines=0;for(var i=0;ito)range.to=to;if(range.from>=range.to)intact.splice(i--,1);else intactLines+=range.to-range.from}if(intactLines==to-from&&from==showingFrom&&to==showingTo){updateVerticalScroll(scrollTop);return}intact.sort(function(a,b){return a.domStart-b.domStart});var th=textHeight(),gutterDisplay=gutter.style.display;lineDiv.style.display="none";patchDisplay(from,to,intact);lineDiv.style.display=gutter.style.display="";var different=from!=showingFrom||to!=showingTo||lastSizeC!=scroller.clientHeight+th;if(different)lastSizeC=scroller.clientHeight+th;if(from!=showingFrom||to!=showingTo&&options.onViewportChange)setTimeout(function(){if(options.onViewportChange)options.onViewportChange(instance,from,to)});showingFrom=from;showingTo=to;displayOffset=heightAtLine(doc,from);startWorker(100);if(lineDiv.childNodes.length!=showingTo-showingFrom)throw new Error("BAD PATCH! "+JSON.stringify(intact)+" size="+(showingTo-showingFrom)+" nodes="+lineDiv.childNodes.length);function checkHeights(){var curNode=lineDiv.firstChild,heightChanged=false;doc.iter(showingFrom,showingTo,function(line){if(!curNode)return;if(!line.hidden){var height=Math.round(curNode.offsetHeight/th)||1;if(line.height!=height){updateLineHeight(line,height);gutterDirty=heightChanged=true}}curNode=curNode.nextSibling});return heightChanged}if(options.lineWrapping)checkHeights();gutter.style.display=gutterDisplay;if(different||gutterDirty){updateGutter()&&options.lineWrapping&&checkHeights()&&updateGutter()}updateVerticalScroll(scrollTop);updateSelection();if(!suppressCallback&&options.onUpdate)options.onUpdate(instance);return true}function computeIntact(intact,changes){for(var i=0,l=changes.length||0;i=range.to)intact2.push(range);else{if(change.from>range.from)intact2.push({from:range.from,to:change.from,domStart:range.domStart});if(change.todomPos){curNode=killNode(curNode);domPos++}for(var j=0,e=cur.to-cur.from;jj){if(line.hidden)var lineElement=elt("pre");else{var lineElement=lineContent(line);if(line.className)lineElement.className=line.className;if(line.bgClassName){var pre=elt("pre"," ",line.bgClassName,"position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2");lineElement=elt("div",[pre,lineElement],null,"position: relative")}}lineDiv.insertBefore(lineElement,curNode)}else{curNode=curNode.nextSibling}++j})}function updateGutter(){if(!options.gutter&&!options.lineNumbers)return;var hText=mover.offsetHeight,hEditor=scroller.clientHeight;gutter.style.height=(hText-hEditor<2?hEditor:hText)+"px";var fragment=document.createDocumentFragment(),i=showingFrom,normalNode;doc.iter(showingFrom,Math.max(showingTo,showingFrom+1),function(line){if(line.hidden){fragment.appendChild(elt("pre"))}else{var marker=line.gutterMarker;var text=options.lineNumbers?options.lineNumberFormatter(i+options.firstLineNumber):null;if(marker&&marker.text)text=marker.text.replace("%N%",text!=null?text:"");else if(text==null)text=" ";var markerElement=fragment.appendChild(elt("pre",null,marker&&marker.style));markerElement.innerHTML=text;for(var j=1;j2;lineSpace.style.marginLeft=gutter.offsetWidth+"px";gutterDirty=false;return resized}function updateSelection(){var collapsed=posEq(sel.from,sel.to);var fromPos=localCoords(sel.from,true);var toPos=collapsed?fromPos:localCoords(sel.to,true);var headPos=sel.inverted?fromPos:toPos,th=textHeight();var wrapOff=eltOffset(wrapper),lineOff=eltOffset(lineDiv);inputDiv.style.top=Math.max(0,Math.min(scroller.offsetHeight,headPos.y+lineOff.top-wrapOff.top))+"px";inputDiv.style.left=Math.max(0,Math.min(scroller.offsetWidth,headPos.x+lineOff.left-wrapOff.left))+"px";if(collapsed||options.showCursorWhenSelecting){cursor.style.top=headPos.y+"px";cursor.style.left=(options.lineWrapping?Math.min(headPos.x,lineSpace.offsetWidth):headPos.x)+"px";cursor.style.display=""}else{cursor.style.display="none"}if(!collapsed){var sameLine=fromPos.y==toPos.y,fragment=document.createDocumentFragment();var clientWidth=lineSpace.clientWidth||lineSpace.offsetWidth;var clientHeight=lineSpace.clientHeight||lineSpace.offsetHeight;var add=function(left,top,right,height){var rstyle=quirksMode?"width: "+(!right?clientWidth:clientWidth-right-left)+"px":"right: "+(right-1)+"px";fragment.appendChild(elt("div",null,"CodeMirror-selected","position: absolute; left: "+left+"px; top: "+top+"px; "+rstyle+"; height: "+height+"px"))};if(sel.from.ch&&fromPos.y>=0){var right=sameLine?clientWidth-toPos.x:0;add(fromPos.x,fromPos.y,right,th)}var middleStart=Math.max(0,fromPos.y+(sel.from.ch?th:0));var middleHeight=Math.min(toPos.y,clientHeight)-middleStart;if(middleHeight>.2*th)add(0,middleStart,0,middleHeight);if((!sameLine||!sel.from.ch)&&toPos.yoldCh||ch>line.text.length)ch=line.text.length;return{line:lNo,ch:ch}}lNo+=dir}}var line=getLine(pos.line);var toEnd=pos.ch==line.text.length&&pos.ch!=oldCh;if(!line.hidden)return pos;if(pos.line>=oldLine)return getNonHidden(1)||getNonHidden(-1);else return getNonHidden(-1)||getNonHidden(1)}function setCursor(line,ch,user){var pos=clipPos({line:line,ch:ch||0});(user?setSelectionUser:setSelection)(pos,pos)}function clipLine(n){return Math.max(0,Math.min(n,doc.size-1))}function clipPos(pos){if(pos.line<0)return{line:0,ch:0};if(pos.line>=doc.size)return{line:doc.size-1,ch:getLine(doc.size-1).text.length};var ch=pos.ch,linelen=getLine(pos.line).text.length;if(ch==null||ch>linelen)return{line:pos.line,ch:linelen};else if(ch<0)return{line:pos.line,ch:0};else return pos}function findPosH(dir,unit){var end=sel.inverted?sel.from:sel.to,line=end.line,ch=end.ch;var lineObj=getLine(line);function findNextLine(){for(var l=line+dir,e=dir<0?-1:doc.size;l!=e;l+=dir){var lo=getLine(l);if(!lo.hidden){line=l;lineObj=lo;return true}}}function moveOnce(boundToLine){if(ch==(dir<0?0:lineObj.text.length)){if(!boundToLine&&findNextLine())ch=dir<0?lineObj.text.length:0;else return false}else ch+=dir;return true}if(unit=="char")moveOnce();else if(unit=="column")moveOnce(true);else if(unit=="word"){var sawWord=false;for(;;){if(dir<0)if(!moveOnce())break;if(isWordChar(lineObj.text.charAt(ch)))sawWord=true;else if(sawWord){if(dir<0){dir=1;moveOnce()}break}if(dir>0)if(!moveOnce())break}}return{line:line,ch:ch}}function moveH(dir,unit){var pos=dir<0?sel.from:sel.to;if(shiftSelecting||posEq(sel.from,sel.to))pos=findPosH(dir,unit);setCursor(pos.line,pos.ch,true)}function deleteH(dir,unit){if(!posEq(sel.from,sel.to))replaceRange("",sel.from,sel.to);else if(dir<0)replaceRange("",findPosH(dir,unit),sel.to);else replaceRange("",sel.from,findPosH(dir,unit));userSelChange=true}function moveV(dir,unit){var dist=0,pos=localCoords(sel.inverted?sel.from:sel.to,true);if(goalColumn!=null)pos.x=goalColumn;if(unit=="page"){var screen=Math.min(scroller.clientHeight,window.innerHeight||document.documentElement.clientHeight);var target=coordsChar(pos.x,pos.y+screen*dir)}else if(unit=="line"){var th=textHeight();var target=coordsChar(pos.x,pos.y+.5*th+dir*th)}if(unit=="page")scrollbar.scrollTop+=localCoords(target,true).y-pos.y;setCursor(target.line,target.ch,true);goalColumn=pos.x}function findWordAt(pos){var line=getLine(pos.line).text;var start=pos.ch,end=pos.ch;if(line){if(pos.after===false||end==line.length)--start;else++end;var startChar=line.charAt(start);var check=isWordChar(startChar)?isWordChar:/\s/.test(startChar)?function(ch){return/\s/.test(ch)}:function(ch){return!/\s/.test(ch)&&isWordChar(ch)};while(start>0&&check(line.charAt(start-1)))--start;while(end=pos.ch))markers.push(span.marker)}return markers}function addGutterMarker(line,text,className){if(typeof line=="number")line=getLine(clipLine(line));line.gutterMarker={text:text,style:className};gutterDirty=true;return line}function removeGutterMarker(line){if(typeof line=="number")line=getLine(clipLine(line));line.gutterMarker=null;gutterDirty=true}function changeLine(handle,op){var no=handle,line=handle;if(typeof handle=="number")line=getLine(clipLine(handle));else no=lineNo(handle);if(no==null)return null;if(op(line,no))changes.push({from:no,to:no+1});else return null;return line}function setLineClass(handle,className,bgClassName){return changeLine(handle,function(line){if(line.className!=className||line.bgClassName!=bgClassName){line.className=className;line.bgClassName=bgClassName;return true}})}function setLineHidden(handle,hidden){return changeLine(handle,function(line,no){if(line.hidden!=hidden){line.hidden=hidden;if(!options.lineWrapping){if(hidden&&line.text.length==maxLine.text.length){updateMaxLine=true}else if(!hidden&&line.text.length>maxLine.text.length){maxLine=line;updateMaxLine=false}}updateLineHeight(line,hidden?0:1);var fline=sel.from.line,tline=sel.to.line;if(hidden&&(fline==no||tline==no)){var from=fline==no?skipHidden({line:fline,ch:0},fline,0):sel.from;var to=tline==no?skipHidden({line:tline,ch:0},tline,0):sel.to;if(!to)return;setSelection(from,to)}return gutterDirty=true}})}function lineInfo(line){if(typeof line=="number"){if(!isLine(line))return null;var n=line;line=getLine(line);if(!line)return null}else{var n=lineNo(line);if(n==null)return null}var marker=line.gutterMarker;return{line:n,handle:line,text:line.text,markerText:marker&&marker.text,markerClass:marker&&marker.style,lineClass:line.className,bgClass:line.bgClassName}}function measureLine(line,ch){if(ch==0)return{top:0,left:0};var pre=lineContent(line,ch);removeChildrenAndAdd(measure,pre);var anchor=pre.anchor;var top=anchor.offsetTop,left=anchor.offsetLeft;if(ie&&top==0&&left==0){var backup=elt("span","x");anchor.parentNode.insertBefore(backup,anchor.nextSibling);top=backup.offsetTop}return{top:top,left:left}}function localCoords(pos,inLineWrap){var x,lh=textHeight(),y=lh*(heightAtLine(doc,pos.line)-(inLineWrap?displayOffset:0));if(pos.ch==0)x=0;else{var sp=measureLine(getLine(pos.line),pos.ch);x=sp.left;if(options.lineWrapping)y+=Math.max(0,sp.top)}return{x:x,y:y,yBot:y+lh}}function coordsChar(x,y){var th=textHeight(),cw=charWidth(),heightPos=displayOffset+Math.floor(y/th);if(heightPos<0)return{line:0,ch:0};var lineNo=lineAtHeight(doc,heightPos);if(lineNo>=doc.size)return{line:doc.size-1,ch:getLine(doc.size-1).text.length};var lineObj=getLine(lineNo),text=lineObj.text;var tw=options.lineWrapping,innerOff=tw?heightPos-heightAtLine(doc,lineNo):0;if(x<=0&&innerOff==0)return{line:lineNo,ch:0};var wrongLine=false;function getX(len){var sp=measureLine(lineObj,len);if(tw){var off=Math.round(sp.top/th);wrongLine=off!=innerOff;return Math.max(0,sp.left+(off-innerOff)*scroller.clientWidth)}return sp.left}var from=0,fromX=0,to=text.length,toX;var estimated=Math.min(to,Math.ceil((x+innerOff*scroller.clientWidth*.9)/cw));for(;;){var estX=getX(estimated);if(estX<=x&&estimatedtoX)return{line:lineNo,ch:to};estimated=Math.floor(to*.8);estX=getX(estimated);if(estXx){to=middle;toX=middleX;if(wrongLine)toX+=1e3}else{from=middle;fromX=middleX}}}function pageCoords(pos){var local=localCoords(pos,true),off=eltOffset(lineSpace);return{x:off.left+local.x,y:off.top+local.y,yBot:off.top+local.yBot}}var cachedHeight,cachedHeightFor,measurePre;function textHeight(){if(measurePre==null){measurePre=elt("pre");for(var i=0;i<49;++i){measurePre.appendChild(document.createTextNode("x"));measurePre.appendChild(elt("br"))}measurePre.appendChild(document.createTextNode("x"))}var offsetHeight=lineDiv.clientHeight;if(offsetHeight==cachedHeightFor)return cachedHeight;cachedHeightFor=offsetHeight;removeChildrenAndAdd(measure,measurePre.cloneNode(true));cachedHeight=measure.firstChild.offsetHeight/50||1;removeChildren(measure);return cachedHeight}var cachedWidth,cachedWidthFor=0;function charWidth(){if(scroller.clientWidth==cachedWidthFor)return cachedWidth;cachedWidthFor=scroller.clientWidth;var anchor=elt("span","x");var pre=elt("pre",[anchor]);removeChildrenAndAdd(measure,pre);return cachedWidth=anchor.offsetWidth||10}function paddingTop(){return lineSpace.offsetTop}function paddingLeft(){return lineSpace.offsetLeft}function posFromMouse(e,liberal){var offW=eltOffset(scroller,true),x,y;try{x=e.clientX;y=e.clientY}catch(e){return null}if(!liberal&&(x-offW.left>scroller.clientWidth||y-offW.top>scroller.clientHeight))return null;var offL=eltOffset(lineSpace,true);return coordsChar(x-offL.left,y-offL.top)}var detectingSelectAll;function onContextMenu(e){var pos=posFromMouse(e),scrollPos=scrollbar.scrollTop;if(!pos||opera)return;if(posEq(sel.from,sel.to)||posLess(pos,sel.from)||!posLess(pos,sel.to))operation(setCursor)(pos.line,pos.ch);var oldCSS=input.style.cssText;inputDiv.style.position="absolute";input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: white; "+"border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";focusInput();resetInput(true);if(posEq(sel.from,sel.to))input.value=prevInput=" ";function rehide(){inputDiv.style.position="relative";input.style.cssText=oldCSS;if(ie_lt9)scrollbar.scrollTop=scrollPos;slowPoll();if(input.selectionStart!=null){clearTimeout(detectingSelectAll);var extval=input.value=" "+(posEq(sel.from,sel.to)?"":input.value),i=0;prevInput=" ";input.selectionStart=1;input.selectionEnd=extval.length;detectingSelectAll=setTimeout(function poll(){if(prevInput==" "&&input.selectionStart==0)operation(commands.selectAll)(instance);else if(i++<10)detectingSelectAll=setTimeout(poll,500);else resetInput()},200)}}if(gecko){e_stop(e);var mouseup=connect(window,"mouseup",function(){mouseup();setTimeout(rehide,20)},true)}else{setTimeout(rehide,50)}}function restartBlink(){clearInterval(blinker);var on=true;cursor.style.visibility="";blinker=setInterval(function(){cursor.style.visibility=(on=!on)?"":"hidden"},options.cursorBlinkRate)}var matching={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"};function matchBrackets(autoclear){var head=sel.inverted?sel.from:sel.to,line=getLine(head.line),pos=head.ch-1;var match=pos>=0&&matching[line.text.charAt(pos)]||matching[line.text.charAt(++pos)];if(!match)return;var ch=match.charAt(0),forward=match.charAt(1)==">",d=forward?1:-1,st=line.styles;for(var off=pos+1,i=0,e=st.length;i=from&&pos"==forward)stack.push(cur);else if(stack.pop()!=match.charAt(0))return{pos:pos,match:false};else if(!stack.length)return{pos:pos,match:true}}}}}for(var i=head.line,e=forward?Math.min(i+100,doc.size):Math.max(-1,i-100);i!=e;i+=d){var line=getLine(i),first=i==head.line;var found=scan(line,first&&forward?pos+1:0,first&&!forward?pos:line.text.length);if(found)break}if(!found)found={pos:null,match:false};var style=found.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket";var one=markText({line:head.line,ch:pos},{line:head.line,ch:pos+1},style),two=found.pos!=null&&markText({line:i,ch:found.pos},{line:i,ch:found.pos+1},style);var clear=operation(function(){one.clear();two&&two.clear()});if(autoclear)setTimeout(clear,800);else bracketHighlighted=clear}function findStartLine(n){var minindent,minline;for(var search=n,lim=n-40;search>lim;--search){if(search==0)return 0;var line=getLine(search-1);if(line.stateAfter)return search;var indented=line.indentation(options.tabSize);if(minline==null||minindent>indented){minline=search-1;minindent=indented}}return minline}function getStateBefore(n){var pos=findStartLine(n),state=pos&&getLine(pos-1).stateAfter;if(!state)state=startState(mode);else state=copyState(mode,state);doc.iter(pos,n,function(line){line.process(mode,state,options.tabSize);line.stateAfter=pos==n-1||pos%5==0?copyState(mode,state):null});return state}function highlightWorker(){if(frontier>=showingTo)return;var end=+new Date+options.workTime,state=copyState(mode,getStateBefore(frontier));var startFrontier=frontier;doc.iter(frontier,showingTo,function(line){if(frontier>=showingFrom){line.highlight(mode,state,options.tabSize);line.stateAfter=copyState(mode,state)}else{line.process(mode,state,options.tabSize);line.stateAfter=frontier%5==0?copyState(mode,state):null}++frontier;if(+new Date>end){startWorker(options.workDelay);return true}});if(showingTo>startFrontier&&frontier>=showingFrom)operation(function(){changes.push({from:startFrontier,to:frontier})})()}function startWorker(time){if(frontier2){mode.dependencies=[];for(var i=2;i0&&cur.ch=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)||undefined},next:function(){if(this.posstart},eatSpace:function(){var start=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>start},skipToEnd:function(){this.pos=this.string.length},skipTo:function(ch){var found=this.string.indexOf(ch,this.pos);if(found>-1){this.pos=found;return true}},backUp:function(n){this.pos-=n},column:function(){return countColumn(this.string,this.start,this.tabSize)},indentation:function(){return countColumn(this.string,null,this.tabSize)},match:function(pattern,consume,caseInsensitive){if(typeof pattern=="string"){var cased=function(str){return caseInsensitive?str.toLowerCase():str};if(cased(this.string).indexOf(cased(pattern),this.pos)==this.pos){if(consume!==false)this.pos+=pattern.length;return true}}else{var match=this.string.slice(this.pos).match(pattern);if(match&&match.index>0)return null;if(match&&consume!==false)this.pos+=match[0].length;return match}},current:function(){return this.string.slice(this.start,this.pos)}};CodeMirror.StringStream=StringStream;function MarkedSpan(from,to,marker){this.from=from;this.to=to;this.marker=marker}function getMarkedSpanFor(spans,marker){if(spans)for(var i=0;i=startCh:span.to>startCh);(nw||(nw=[])).push({from:span.from,to:endsAfter?null:span.to,marker:marker})}}return nw}function markedSpansAfter(old,endCh){if(old)for(var i=0,nw;i=endCh:span.to>endCh);if(endsAfter||marker.type=="bookmark"&&span.from==endCh){var startsBefore=span.from==null||(marker.inclusiveLeft?span.from<=endCh:span.from0&&first)for(var i=0;i5e3){st[pos++]=this.text.slice(stream.pos);st[pos++]=null;break}}},process:function(mode,state,tabSize){var stream=new StringStream(this.text,tabSize);if(this.text==""&&mode.blankLine)mode.blankLine(state);while(!stream.eol()&&stream.pos<=5e3){mode.token(stream,state);stream.start=stream.pos}},getTokenAt:function(mode,state,tabSize,ch){var txt=this.text,stream=new StringStream(txt,tabSize);while(stream.pos=outPos&&wrapAtwrapAt+10&&/\s/.test(text))span=function(){}}}}var st=this.styles,allText=this.text,marked=this.markedSpans;var len=allText.length;function styleToClass(style){if(!style)return null;return"cm-"+style.replace(/ +/g," cm-")}if(!allText&&wrapAt==null){span(pre," ")}else if(!marked||!marked.length){for(var i=0,ch=0;chlen)str=str.slice(0,len-ch);ch+=l;span(pre,str,styleToClass(style))}}else{marked.sort(function(a,b){return a.from-b.from});var pos=0,i=0,text="",style,sg=0;var nextChange=marked[0].from||0,marks=[],markpos=0;var advanceMarks=function(){var m;while(markposupto?text.slice(0,upto-pos):text,appliedStyle);if(end>=upto){text=text.slice(upto-pos);pos=upto;break}pos=end}text=st[i++];style=styleToClass(st[i++])}}}return pre},cleanUp:function(){this.parent=null;detachMarkedSpans(this)}};function LeafChunk(lines){this.lines=lines;this.parent=null;for(var i=0,e=lines.length,height=0;i50){while(child.lines.length>50){var spilled=child.lines.splice(child.lines.length-25,25);var newleaf=new LeafChunk(spilled);child.height-=newleaf.height;this.children.splice(i+1,0,newleaf);newleaf.parent=this}this.maybeSpill()}break}at-=sz}},maybeSpill:function(){if(this.children.length<=10)return;var me=this;do{var spilled=me.children.splice(me.children.length-5,5);var sibling=new BranchChunk(spilled);if(!me.parent){var copy=new BranchChunk(me.children);copy.parent=me;me.children=[copy,sibling];me=copy}else{me.size-=sibling.size;me.height-=sibling.height;var myIndex=indexOf(me.parent.children,me);me.parent.children.splice(myIndex+1,0,sibling)}sibling.parent=me.parent}while(me.children.length>10);me.parent.maybeSpill()},iter:function(from,to,op){this.iterN(from,to-from,op)},iterN:function(at,n,op){for(var i=0,e=this.children.length;i400||!last||this.closed||last.start>start+old.length||last.start+last.added0;--i)last.old.unshift(old[i-1]);for(var i=endAfter;i>0;--i)last.old.push(old[old.length-i]);if(startBefore)last.start=start;last.added+=added-(old.length-startBefore-endAfter)}this.time=time},startCompound:function(){if(!this.compound++)this.closed=true},endCompound:function(){if(!--this.compound)this.closed=true}};function stopMethod(){e_stop(this)}function addStop(event){if(!event.stop)event.stop=stopMethod;return event}function e_preventDefault(e){if(e.preventDefault)e.preventDefault();else e.returnValue=false}function e_stopPropagation(e){if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true}function e_stop(e){e_preventDefault(e);e_stopPropagation(e)}CodeMirror.e_stop=e_stop;CodeMirror.e_preventDefault=e_preventDefault;CodeMirror.e_stopPropagation=e_stopPropagation;function e_target(e){return e.target||e.srcElement}function e_button(e){var b=e.which;if(b==null){if(e.button&1)b=1;else if(e.button&2)b=3;else if(e.button&4)b=2}if(mac&&e.ctrlKey&&b==1)b=3;return b}function e_prop(e,prop){var overridden=e.override&&e.override.hasOwnProperty(prop);return overridden?e.override[prop]:e[prop]}function connect(node,type,handler,disconnect){if(typeof node.addEventListener=="function"){node.addEventListener(type,handler,false);if(disconnect)return function(){node.removeEventListener(type,handler,false)}}else{var wrapHandler=function(event){handler(event||window.event)};node.attachEvent("on"+type,wrapHandler);if(disconnect)return function(){node.detachEvent("on"+type,wrapHandler)}}}CodeMirror.connect=connect;function Delayed(){this.id=null}Delayed.prototype={set:function(ms,f){clearTimeout(this.id);this.id=setTimeout(f,ms)}};var Pass=CodeMirror.Pass={toString:function(){return"CodeMirror.Pass"}};var dragAndDrop=function(){if(ie_lt9)return false;var div=elt("div");return"draggable"in div||"dragDrop"in div}();var lineSep=function(){var te=elt("textarea");te.value="foo\nbar";if(te.value.indexOf("\r")>-1)return"\r\n";return"\n"}();var spanAffectsWrapping=/^$/;if(gecko)spanAffectsWrapping=/$'/;else if(safari)spanAffectsWrapping=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/;else if(chrome)spanAffectsWrapping=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/;function countColumn(string,end,tabSize){if(end==null){end=string.search(/[^\s\u00a0]/);if(end==-1)end=string.length}for(var i=0,n=0;i=0&&j>=0;--i,--j)if(from.charAt(i)!=to.charAt(j))break;return j+1}function indexOf(collection,elt){if(collection.indexOf)return collection.indexOf(elt);for(var i=0,e=collection.length;i"€"&&(ch.toUpperCase()!=ch.toLowerCase()||nonASCIISingleCaseWordChar.test(ch))}var splitLines="\n\nb".split(/\n/).length!=3?function(string){var pos=0,result=[],l=string.length;while(pos<=l){var nl=string.indexOf("\n",pos);if(nl==-1)nl=string.length;var line=string.slice(pos,string.charAt(nl-1)=="\r"?nl-1:nl);var rt=line.indexOf("\r");if(rt!=-1){result.push(line.slice(0,rt));pos+=rt+1}else{result.push(line);pos=nl+1}}return result}:function(string){return string.split(/\r\n?|\n/)};CodeMirror.splitLines=splitLines;var hasSelection=window.getSelection?function(te){try{return te.selectionStart!=te.selectionEnd}catch(e){return false}}:function(te){try{var range=te.ownerDocument.selection.createRange()}catch(e){}if(!range||range.parentElement()!=te)return false;return range.compareEndPoints("StartToEnd",range)!=0};CodeMirror.defineMode("null",function(){return{token:function(stream){stream.skipToEnd()}}});CodeMirror.defineMIME("text/plain","null");var keyNames={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",109:"-",107:"=",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"};CodeMirror.keyNames=keyNames;!function(){for(var i=0;i<10;i++)keyNames[i+48]=String(i);for(var i=65;i<=90;i++)keyNames[i]=String.fromCharCode(i);for(var i=1;i<=12;i++)keyNames[i+111]=keyNames[i+63235]="F"+i}();CodeMirror.version="2.38";return CodeMirror}();CodeMirror.defineMode("htmlmixed",function(config){var htmlMode=CodeMirror.getMode(config,{name:"xml",htmlMode:true});var jsMode=CodeMirror.getMode(config,"javascript");var cssMode=CodeMirror.getMode(config,"css");function html(stream,state){var style=htmlMode.token(stream,state.htmlState);if(/(?:^|\s)tag(?:\s|$)/.test(style)&&stream.current()==">"&&state.htmlState.context){if(/^script$/i.test(state.htmlState.context.tagName)){state.token=javascript;state.localState=jsMode.startState(htmlMode.indent(state.htmlState,""))}else if(/^style$/i.test(state.htmlState.context.tagName)){state.token=css;state.localState=cssMode.startState(htmlMode.indent(state.htmlState,""))}}return style}function maybeBackup(stream,pat,style){var cur=stream.current();var close=cur.search(pat),m;if(close>-1)stream.backUp(cur.length-close);else if(m=cur.match(/<\/?$/)){stream.backUp(cur.length);if(!stream.match(pat,false))stream.match(cur[0])}return style}function javascript(stream,state){if(stream.match(/^<\/\s*script\s*>/i,false)){state.token=html;state.localState=null;return html(stream,state)}return maybeBackup(stream,/<\/\s*script\s*>/,jsMode.token(stream,state.localState))}function css(stream,state){if(stream.match(/^<\/\s*style\s*>/i,false)){state.token=html;state.localState=null;return html(stream,state)}return maybeBackup(stream,/<\/\s*style\s*>/,cssMode.token(stream,state.localState))}return{startState:function(){var state=htmlMode.startState();return{token:html,localState:null,mode:"html",htmlState:state}},copyState:function(state){if(state.localState)var local=CodeMirror.copyState(state.token==css?cssMode:jsMode,state.localState);return{token:state.token,localState:local,mode:state.mode,htmlState:CodeMirror.copyState(htmlMode,state.htmlState)}},token:function(stream,state){return state.token(stream,state)},indent:function(state,textAfter){if(state.token==html||/^\s*<\//.test(textAfter))return htmlMode.indent(state.htmlState,textAfter);else if(state.token==javascript)return jsMode.indent(state.localState,textAfter);else return cssMode.indent(state.localState,textAfter)},electricChars:"/{}:",innerMode:function(state){var mode=state.token==html?htmlMode:state.token==javascript?jsMode:cssMode;return{state:state.localState||state.htmlState,mode:mode}}}},"xml","javascript","css");CodeMirror.defineMIME("text/html","htmlmixed");CodeMirror.defineMode("javascript",function(config,parserConfig){var indentUnit=config.indentUnit;var jsonMode=parserConfig.json;var isTS=parserConfig.typescript;var keywords=function(){function kw(type){return{type:type,style:"keyword"}}var A=kw("keyword a"),B=kw("keyword b"),C=kw("keyword c");var operator=kw("operator"),atom={type:"atom",style:"atom"};var jsKeywords={"if":A,"while":A,"with":A,"else":B,"do":B,"try":B,"finally":B,"return":C,"break":C,"continue":C,"new":C,"delete":C,"throw":C,"var":kw("var"),"const":kw("var"),let:kw("var"),"function":kw("function"),"catch":kw("catch"),"for":kw("for"),"switch":kw("switch"),"case":kw("case"),"default":kw("default"),"in":operator,"typeof":operator,"instanceof":operator,"true":atom,"false":atom,"null":atom,undefined:atom,NaN:atom,Infinity:atom};if(isTS){var type={type:"variable",style:"variable-3"};var tsKeywords={"interface":kw("interface"),"class":kw("class"),"extends":kw("extends"),constructor:kw("constructor"),"public":kw("public"),"private":kw("private"),"protected":kw("protected"),"static":kw("static"),"super":kw("super"),string:type,number:type,bool:type,any:type};for(var attr in tsKeywords){jsKeywords[attr]=tsKeywords[attr]}}return jsKeywords}();var isOperatorChar=/[+\-*&%=<>!?|]/;function chain(stream,state,f){state.tokenize=f;return f(stream,state)}function nextUntilUnescaped(stream,end){var escaped=false,next;while((next=stream.next())!=null){if(next==end&&!escaped)return false;escaped=!escaped&&next=="\\"}return escaped}var type,content;function ret(tp,style,cont){type=tp;content=cont;return style}function jsTokenBase(stream,state){var ch=stream.next();if(ch=='"'||ch=="'")return chain(stream,state,jsTokenString(ch));else if(/[\[\]{}\(\),;\:\.]/.test(ch))return ret(ch);else if(ch=="0"&&stream.eat(/x/i)){stream.eatWhile(/[\da-f]/i);return ret("number","number")}else if(/\d/.test(ch)||ch=="-"&&stream.eat(/\d/)){stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);return ret("number","number")}else if(ch=="/"){if(stream.eat("*")){return chain(stream,state,jsTokenComment)}else if(stream.eat("/")){stream.skipToEnd();return ret("comment","comment")}else if(state.lastType=="operator"||state.lastType=="keyword c"||/^[\[{}\(,;:]$/.test(state.lastType)){nextUntilUnescaped(stream,"/");stream.eatWhile(/[gimy]/);return ret("regexp","string-2")}else{stream.eatWhile(isOperatorChar);return ret("operator",null,stream.current())}}else if(ch=="#"){stream.skipToEnd();return ret("error","error")}else if(isOperatorChar.test(ch)){stream.eatWhile(isOperatorChar);return ret("operator",null,stream.current())}else{stream.eatWhile(/[\w\$_]/);var word=stream.current(),known=keywords.propertyIsEnumerable(word)&&keywords[word];return known&&state.lastType!="."?ret(known.type,known.style,word):ret("variable","variable",word)}}function jsTokenString(quote){return function(stream,state){if(!nextUntilUnescaped(stream,quote))state.tokenize=jsTokenBase;return ret("string","string")}}function jsTokenComment(stream,state){var maybeEnd=false,ch;while(ch=stream.next()){if(ch=="/"&&maybeEnd){state.tokenize=jsTokenBase;break}maybeEnd=ch=="*"}return ret("comment","comment")}var atomicTypes={atom:true,number:true,variable:true,string:true,regexp:true};function JSLexical(indented,column,type,align,prev,info){this.indented=indented;this.column=column;this.type=type;this.prev=prev;this.info=info;if(align!=null)this.align=align}function inScope(state,varname){for(var v=state.localVars;v;v=v.next)if(v.name==varname)return true}function parseJS(state,style,type,content,stream){var cc=state.cc;cx.state=state;cx.stream=stream;cx.marked=null,cx.cc=cc;if(!state.lexical.hasOwnProperty("align"))state.lexical.align=true;while(true){var combinator=cc.length?cc.pop():jsonMode?expression:statement;if(combinator(type,content)){while(cc.length&&cc[cc.length-1].lex)cc.pop()();if(cx.marked)return cx.marked;if(type=="variable"&&inScope(state,content))return"variable-2";return style}}}var cx={state:null,column:null,marked:null,cc:null};function pass(){for(var i=arguments.length-1;i>=0;i--)cx.cc.push(arguments[i])}function cont(){pass.apply(null,arguments);return true}function register(varname){function inList(list){for(var v=list;v;v=v.next)if(v.name==varname)return true;return false}var state=cx.state;if(state.context){cx.marked="def";if(inList(state.localVars))return;state.localVars={name:varname,next:state.localVars}}else{if(inList(state.globalVars))return;state.globalVars={name:varname,next:state.globalVars}}}var defaultVars={name:"this",next:{name:"arguments"}};function pushcontext(){cx.state.context={prev:cx.state.context,vars:cx.state.localVars};cx.state.localVars=defaultVars}function popcontext(){cx.state.localVars=cx.state.context.vars;cx.state.context=cx.state.context.prev}function pushlex(type,info){var result=function(){var state=cx.state;state.lexical=new JSLexical(state.indented,cx.stream.column(),type,null,state.lexical,info)};result.lex=true;return result}function poplex(){var state=cx.state;if(state.lexical.prev){if(state.lexical.type==")")state.indented=state.lexical.indented;state.lexical=state.lexical.prev}}poplex.lex=true;function expect(wanted){return function expecting(type){if(type==wanted)return cont();else if(wanted==";")return pass();else return cont(arguments.callee)}}function statement(type){if(type=="var")return cont(pushlex("vardef"),vardef1,expect(";"),poplex);if(type=="keyword a")return cont(pushlex("form"),expression,statement,poplex);if(type=="keyword b")return cont(pushlex("form"),statement,poplex);if(type=="{")return cont(pushlex("}"),block,poplex);if(type==";")return cont();if(type=="function")return cont(functiondef);if(type=="for")return cont(pushlex("form"),expect("("),pushlex(")"),forspec1,expect(")"),poplex,statement,poplex);if(type=="variable")return cont(pushlex("stat"),maybelabel);if(type=="switch")return cont(pushlex("form"),expression,pushlex("}","switch"),expect("{"),block,poplex,poplex);if(type=="case")return cont(expression,expect(":"));if(type=="default")return cont(expect(":")); +if(type=="catch")return cont(pushlex("form"),pushcontext,expect("("),funarg,expect(")"),statement,poplex,popcontext);return pass(pushlex("stat"),expression,expect(";"),poplex)}function expression(type){if(atomicTypes.hasOwnProperty(type))return cont(maybeoperator);if(type=="function")return cont(functiondef);if(type=="keyword c")return cont(maybeexpression);if(type=="(")return cont(pushlex(")"),maybeexpression,expect(")"),poplex,maybeoperator);if(type=="operator")return cont(expression);if(type=="[")return cont(pushlex("]"),commasep(expression,"]"),poplex,maybeoperator);if(type=="{")return cont(pushlex("}"),commasep(objprop,"}"),poplex,maybeoperator);return cont()}function maybeexpression(type){if(type.match(/[;\}\)\],]/))return pass();return pass(expression)}function maybeoperator(type,value){if(type=="operator"&&/\+\+|--/.test(value))return cont(maybeoperator);if(type=="operator"&&value=="?")return cont(expression,expect(":"),expression);if(type==";")return;if(type=="(")return cont(pushlex(")"),commasep(expression,")"),poplex,maybeoperator);if(type==".")return cont(property,maybeoperator);if(type=="[")return cont(pushlex("]"),expression,expect("]"),poplex,maybeoperator)}function maybelabel(type){if(type==":")return cont(poplex,statement);return pass(maybeoperator,expect(";"),poplex)}function property(type){if(type=="variable"){cx.marked="property";return cont()}}function objprop(type){if(type=="variable")cx.marked="property";if(atomicTypes.hasOwnProperty(type))return cont(expect(":"),expression)}function commasep(what,end){function proceed(type){if(type==",")return cont(what,proceed);if(type==end)return cont();return cont(expect(end))}return function commaSeparated(type){if(type==end)return cont();else return pass(what,proceed)}}function block(type){if(type=="}")return cont();return pass(statement,block)}function maybetype(type){if(type==":")return cont(typedef);return pass()}function typedef(type){if(type=="variable"){cx.marked="variable-3";return cont()}return pass()}function vardef1(type,value){if(type=="variable"){register(value);return isTS?cont(maybetype,vardef2):cont(vardef2)}return pass()}function vardef2(type,value){if(value=="=")return cont(expression,vardef2);if(type==",")return cont(vardef1)}function forspec1(type){if(type=="var")return cont(vardef1,expect(";"),forspec2);if(type==";")return cont(forspec2);if(type=="variable")return cont(formaybein);return cont(forspec2)}function formaybein(type,value){if(value=="in")return cont(expression);return cont(maybeoperator,forspec2)}function forspec2(type,value){if(type==";")return cont(forspec3);if(value=="in")return cont(expression);return cont(expression,expect(";"),forspec3)}function forspec3(type){if(type!=")")cont(expression)}function functiondef(type,value){if(type=="variable"){register(value);return cont(functiondef)}if(type=="(")return cont(pushlex(")"),pushcontext,commasep(funarg,")"),poplex,statement,popcontext)}function funarg(type,value){if(type=="variable"){register(value);return isTS?cont(maybetype):cont()}}return{startState:function(basecolumn){return{tokenize:jsTokenBase,lastType:null,cc:[],lexical:new JSLexical((basecolumn||0)-indentUnit,0,"block",false),localVars:parserConfig.localVars,globalVars:parserConfig.globalVars,context:parserConfig.localVars&&{vars:parserConfig.localVars},indented:0}},token:function(stream,state){if(stream.sol()){if(!state.lexical.hasOwnProperty("align"))state.lexical.align=false;state.indented=stream.indentation()}if(stream.eatSpace())return null;var style=state.tokenize(stream,state);if(type=="comment")return style;state.lastType=type;return parseJS(state,style,type,content,stream)},indent:function(state,textAfter){if(state.tokenize==jsTokenComment)return CodeMirror.Pass;if(state.tokenize!=jsTokenBase)return 0;var firstChar=textAfter&&textAfter.charAt(0),lexical=state.lexical;if(lexical.type=="stat"&&firstChar=="}")lexical=lexical.prev;var type=lexical.type,closing=firstChar==type;if(type=="vardef")return lexical.indented+(state.lastType=="operator"||state.lastType==","?4:0);else if(type=="form"&&firstChar=="{")return lexical.indented;else if(type=="form")return lexical.indented+indentUnit;else if(type=="stat")return lexical.indented+(state.lastType=="operator"||state.lastType==","?indentUnit:0);else if(lexical.info=="switch"&&!closing)return lexical.indented+(/^(?:case|default)\b/.test(textAfter)?indentUnit:2*indentUnit);else if(lexical.align)return lexical.column+(closing?0:1);else return lexical.indented+(closing?0:indentUnit)},electricChars:":{}",jsonMode:jsonMode}});CodeMirror.defineMIME("text/javascript","javascript");CodeMirror.defineMIME("text/ecmascript","javascript");CodeMirror.defineMIME("application/javascript","javascript");CodeMirror.defineMIME("application/ecmascript","javascript");CodeMirror.defineMIME("application/json",{name:"javascript",json:true});CodeMirror.defineMIME("text/typescript",{name:"javascript",typescript:true});CodeMirror.defineMIME("application/typescript",{name:"javascript",typescript:true});CodeMirror.defineMode("xml",function(config,parserConfig){var indentUnit=config.indentUnit;var Kludges=parserConfig.htmlMode?{autoSelfClosers:{area:true,base:true,br:true,col:true,command:true,embed:true,frame:true,hr:true,img:true,input:true,keygen:true,link:true,meta:true,param:true,source:true,track:true,wbr:true},implicitlyClosed:{dd:true,li:true,optgroup:true,option:true,p:true,rp:true,rt:true,tbody:true,td:true,tfoot:true,th:true,tr:true},contextGrabbers:{dd:{dd:true,dt:true},dt:{dd:true,dt:true},li:{li:true},option:{option:true,optgroup:true},optgroup:{optgroup:true},p:{address:true,article:true,aside:true,blockquote:true,dir:true,div:true,dl:true,fieldset:true,footer:true,form:true,h1:true,h2:true,h3:true,h4:true,h5:true,h6:true,header:true,hgroup:true,hr:true,menu:true,nav:true,ol:true,p:true,pre:true,section:true,table:true,ul:true},rp:{rp:true,rt:true},rt:{rp:true,rt:true},tbody:{tbody:true,tfoot:true},td:{td:true,th:true},tfoot:{tbody:true},th:{td:true,th:true},thead:{tbody:true,tfoot:true},tr:{tr:true}},doNotIndent:{pre:true},allowUnquoted:true,allowMissing:true}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:false,allowMissing:false};var alignCDATA=parserConfig.alignCDATA;var tagName,type;function inText(stream,state){function chain(parser){state.tokenize=parser;return parser(stream,state)}var ch=stream.next();if(ch=="<"){if(stream.eat("!")){if(stream.eat("[")){if(stream.match("CDATA["))return chain(inBlock("atom","]]>"));else return null}else if(stream.match("--"))return chain(inBlock("comment","-->"));else if(stream.match("DOCTYPE",true,true)){stream.eatWhile(/[\w\._\-]/);return chain(doctype(1))}else return null}else if(stream.eat("?")){stream.eatWhile(/[\w\._\-]/);state.tokenize=inBlock("meta","?>");return"meta"}else{var isClose=stream.eat("/");tagName="";var c;while(c=stream.eat(/[^\s\u00a0=<>\"\'\/?]/))tagName+=c;if(!tagName)return"error";type=isClose?"closeTag":"openTag";state.tokenize=inTag;return"tag"}}else if(ch=="&"){var ok;if(stream.eat("#")){if(stream.eat("x")){ok=stream.eatWhile(/[a-fA-F\d]/)&&stream.eat(";")}else{ok=stream.eatWhile(/[\d]/)&&stream.eat(";")}}else{ok=stream.eatWhile(/[\w\.\-:]/)&&stream.eat(";")}return ok?"atom":"error"}else{stream.eatWhile(/[^&<]/);return null}}function inTag(stream,state){var ch=stream.next();if(ch==">"||ch=="/"&&stream.eat(">")){state.tokenize=inText;type=ch==">"?"endTag":"selfcloseTag";return"tag"}else if(ch=="="){type="equals";return null}else if(/[\'\"]/.test(ch)){state.tokenize=inAttribute(ch);return state.tokenize(stream,state)}else{stream.eatWhile(/[^\s\u00a0=<>\"\']/);return"word"}}function inAttribute(quote){return function(stream,state){while(!stream.eol()){if(stream.next()==quote){state.tokenize=inTag;break}}return"string"}}function inBlock(style,terminator){return function(stream,state){while(!stream.eol()){if(stream.match(terminator)){state.tokenize=inText;break}stream.next()}return style}}function doctype(depth){return function(stream,state){var ch;while((ch=stream.next())!=null){if(ch=="<"){state.tokenize=doctype(depth+1);return state.tokenize(stream,state)}else if(ch==">"){if(depth==1){state.tokenize=inText;break}else{state.tokenize=doctype(depth-1);return state.tokenize(stream,state)}}}return"meta"}}var curState,setStyle;function pass(){for(var i=arguments.length-1;i>=0;i--)curState.cc.push(arguments[i])}function cont(){pass.apply(null,arguments);return true}function pushContext(tagName,startOfLine){var noIndent=Kludges.doNotIndent.hasOwnProperty(tagName)||curState.context&&curState.context.noIndent;curState.context={prev:curState.context,tagName:tagName,indent:curState.indented,startOfLine:startOfLine,noIndent:noIndent}}function popContext(){if(curState.context)curState.context=curState.context.prev}function element(type){if(type=="openTag"){curState.tagName=tagName;return cont(attributes,endtag(curState.startOfLine))}else if(type=="closeTag"){var err=false;if(curState.context){if(curState.context.tagName!=tagName){if(Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase())){popContext()}err=!curState.context||curState.context.tagName!=tagName}}else{err=true}if(err)setStyle="error";return cont(endclosetag(err))}return cont()}function endtag(startOfLine){return function(type){if(type=="selfcloseTag"||type=="endTag"&&Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase())){maybePopContext(curState.tagName.toLowerCase());return cont()}if(type=="endTag"){maybePopContext(curState.tagName.toLowerCase());pushContext(curState.tagName,startOfLine);return cont()}return cont()}}function endclosetag(err){return function(type){if(err)setStyle="error";if(type=="endTag"){popContext();return cont()}setStyle="error";return cont(arguments.callee)}}function maybePopContext(nextTagName){var parentTagName;while(true){if(!curState.context){return}parentTagName=curState.context.tagName.toLowerCase();if(!Kludges.contextGrabbers.hasOwnProperty(parentTagName)||!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)){return}popContext()}}function attributes(type){if(type=="word"){setStyle="attribute";return cont(attribute,attributes)}if(type=="endTag"||type=="selfcloseTag")return pass();setStyle="error";return cont(attributes)}function attribute(type){if(type=="equals")return cont(attvalue,attributes);if(!Kludges.allowMissing)setStyle="error";else if(type=="word")setStyle="attribute";return type=="endTag"||type=="selfcloseTag"?pass():cont()}function attvalue(type){if(type=="string")return cont(attvaluemaybe);if(type=="word"&&Kludges.allowUnquoted){setStyle="string";return cont()}setStyle="error";return type=="endTag"||type=="selfCloseTag"?pass():cont()}function attvaluemaybe(type){if(type=="string")return cont(attvaluemaybe);else return pass()}return{startState:function(){return{tokenize:inText,cc:[],indented:0,startOfLine:true,tagName:null,context:null}},token:function(stream,state){if(stream.sol()){state.startOfLine=true;state.indented=stream.indentation()}if(stream.eatSpace())return null;setStyle=type=tagName=null;var style=state.tokenize(stream,state);state.type=type;if((style||type)&&style!="comment"){curState=state;while(true){var comb=state.cc.pop()||element;if(comb(type||style))break}}state.startOfLine=false;return setStyle||style},indent:function(state,textAfter,fullLine){var context=state.context;if(state.tokenize!=inTag&&state.tokenize!=inText||context&&context.noIndent)return fullLine?fullLine.match(/^(\s*)/)[0].length:0;if(alignCDATA&&/ 0 ? this : null; + }, + + findAndSelf: function(selector) { + return this.find(selector).add(this.filter(selector)); + } +}); + +// Little Helpers + +function hyphenate(str) { + return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); +} + +function isVisible(el) { + if (el.is(':hidden')) + return false; + var viewTop = $(window).scrollTop(); + var viewBottom = viewTop + $(window).height(); + var top = el.offset().top; + var bottom = top + el.height(); + return top >= viewTop && bottom <= viewBottom + || top <= viewTop && bottom >= viewTop + || top <= viewBottom && bottom >= viewBottom; +} + +function smoothScrollTo(el, callback) { + $('html, body').animate({ + scrollTop: el.offset().top + }, 250, callback); +} + +var behaviors = {}; + +behaviors.hiDPI = function() { + // Turn off hiDPI for all touch devices for now, until the site is built + // true to scale. + if ($.support.touch) + $('canvas').attr('hidpi', 'off'); +}; + +behaviors.sections = function() { + var toc = $('.toc'); + var checks = []; + var active; + + function update() { + $.each(checks, function() { + if (this()) + return false; + }); + } + + $(document).scroll(update); + $(window).resize(update); + setTimeout(update, 0); + + $('article section').each(function() { + var section = $(this); + var anchor = $('a', section); + // Move content until next section inside section + section.append(section.nextUntil('section')); + var title = anchor.attr('title') || $('h1,h2', section).first().text(); + var id = section.attr('id'); + if (!id) { + id = hyphenate(title) + .replace(/\s+/g, '-') + .replace(/^#/, '') + .replace(/[!"#$%&'\()*+,.\/:;<=>?@\[\\\]\^_`{|}~]+/g, '-') + .replace(/-+/g, '-'); + section.attr('id', id); + anchor.attr('name', id); + } + + function activate() { + if (active) + active.removeClass('active'); + selector.addClass('active'); + active = selector; + } + + // Create table of contents on the fly + if (toc) { + var selector = $('
  • ' + + title + '
  • ').appendTo(toc); + if (section.is('.spacer')) + selector.addClass('spacer'); + $('a', selector).click(function() { + smoothScrollTo(section, function() { + window.location.hash = id; + }); + return false; + }); + + checks.push(function() { + var visible = isVisible(section); + if (visible) + activate(); + return visible; + }); + } + }); + + // Adjust height of last section so that the last anchor aligns perfectly + // with the top of the browser window. + var lastSection = $('article section:last'); + var lastAnchor = $('a[name]', lastSection); + + function resize() { + lastSection.height('auto'); + var bottom = $(document).height() - lastAnchor.offset().top - $(window).height(); + if (bottom < 0) + lastSection.height(lastSection.height() - bottom); + } + + if (lastSection.length && lastAnchor.length) { + $(window).on({ + load: resize, + resize: resize + }); + resize(); + } +}; + +behaviors.sticky = function() { + $('.sticky').each(function() { + me = $(this); + container = $('
    ').append(me.contents()).appendTo(me); + // Insert a div wrapper of which the fixed class is modified depending on position + $(window).scroll(function() { + if (container.is(':visible')) + container.toggleClass('fixed', me.offset().top - $(this).scrollTop() <= 0); + }); + }); +}; + +behaviors.hash = function() { + var hash = unescape(window.location.hash); + if (hash) { + // First see if there's a class member to open + var target = $(hash); + if (target.length) { + if (target.hasClass('member')) + toggleMember(target); + smoothScrollTo(target); + } + } +}; + +behaviors.thumbnails = function() { + var thumbnails = $('.thumbnail'); + var height = 0; + thumbnails.each(function() { + height = Math.max(height, $(this).height()); + }); + $('.thumbnail').height(height); +}; + +behaviors.expandableLists = function() { + $('.expandable-list').each(function() { + var list = $(this); + $('') + .prependTo(list) + .click(function() { + list.toggleClass('expanded'); + }); + }); +}; + +behaviors.referenceClass = function() { + var classes = $('.reference-classes'); + if (classes.length) { + // Mark currently selected class as active. Do it client-sided + // since the menu is generated by jsdocs. + var path = window.location.pathname.toLowerCase(); + $('a[href="' + path + '"]', classes).addClass('active'); + } +}; + +behaviors.hover = function() { + $('.hover').hover(function() { + $('.normal', this).toggleClass('hidden'); + $('.over', this).toggleClass('hidden'); + }); +}; + +behaviors.code = function() { + $('.code:visible, pre:visible code').each(function() { + createCode($(this)); + }); +}; + +behaviors.paperscript = function() { + // Ignore all paperscripts in the automatic load event, and load them + // separately in createPaperScript() when needed. + $('script[type="text/paperscript"]').attr('ignore', 'true'); + $('.paperscript:visible').each(function() { + createPaperScript($(this)); + }); +}; + +function createCodeMirror(place, options, source) { + return new CodeMirror(place, $.extend({}, { + mode: 'javascript', + lineNumbers: true, + matchBrackets: true, + tabSize: 4, + indentUnit: 4, + indentWithTabs: true, + tabMode: 'shift', + value: source.text().match( + // Remove first & last empty line + /^\s*?[\n\r]?([\u0000-\uffff]*?)[\n\r]?\s*?$/)[1] + }, options)); +} + +function createCode(element) { + if (element.data('initialized')) + return; + var start = element.attr('start'); + var highlight = element.attr('highlight'); + var editor = createCodeMirror(function(el) { + element.replaceWith(el); + }, { + lineNumbers: !element.parent('.resource-text').length, + firstLineNumber: parseInt(start || 1, 10), + mode: element.attr('mode') || 'javascript', + readOnly: true + }, element); + if (highlight) { + var highlights = highlight.split(','); + for (var i = 0, l = highlights.length; i < l; i++) { + var highlight = highlights[i].split('-'); + var hlStart = parseInt(highlight[0], 10) - 1; + var hlEnd = highlight.length == 2 + ? parseInt(highlight[1], 10) - 1 : hlStart; + if (start) { + hlStart -= start - 1; + hlEnd -= start - 1; + } + for (var j = hlStart; j <= hlEnd; j++) { + editor.setLineClass(j, 'highlight'); + } + } + } + element.data('initialized', true); +} + +function createPaperScript(element) { + if (element.data('initialized')) + return; + + var script = $('script', element).orNull(), + runButton = $('.button.run', element).orNull(); + if (!script) + return; + // Now load / parse / execute the script + script.removeAttr('ignore'); + var scope = paper.PaperScript.load(script[0]); + if (!runButton) + return; + + var canvas = $('canvas', element), + hasResize = canvas.attr('resize'), + showSplit = element.hasClass('split'), + sourceFirst = element.hasClass('source'), + editor = null, + hasBorders = true, + edited = false, + animateExplain, + explain = $('.explain', element).orNull(), + source = $('