postal.js/lib/report/assets/scripts/bundles/codemirror.js

3 lines
89 KiB
JavaScript
Raw Permalink Normal View History

window.CodeMirror=function(){"use strict";function t(i,o){if(!(this instanceof t))return new t(i,o);this.options=o=o||{};for(var a in ti)!o.hasOwnProperty(a)&&ti.hasOwnProperty(a)&&(o[a]=ti[a]);h(o);var u=this.display=e(i);u.wrapper.CodeMirror=this,l(this),o.autofocus&&!$r&&J(this),this.view=n(new An([new Mn([yn("",null,q(u))])])),this.nextOpId=0,r(this),s(this),o.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),this.setValue(o.value||""),Er&&setTimeout(or(Q,this,!0),20),this.view.history=jn(),ee(this);var c;try{c=document.activeElement==u.input}catch(f){}c||o.autofocus&&!$r?setTimeout(or(me,this),20):ye(this),Y(this,function(){for(var t in Jr)Jr.propertyIsEnumerable(t)&&Jr[t](this,o[t],ei);for(var e=0;oi.length>e;++e)oi[e](this)})()}function e(t){var e={},n=e.input=lr("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none;");n.setAttribute("wrap","off"),n.setAttribute("autocorrect","off"),n.setAttribute("autocapitalize","off"),e.inputDiv=lr("div",[n],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),e.scrollbarH=lr("div",[lr("div",null,null,"height: 1px")],"CodeMirror-hscrollbar"),e.scrollbarV=lr("div",[lr("div",null,null,"width: 1px")],"CodeMirror-vscrollbar"),e.scrollbarFiller=lr("div",null,"CodeMirror-scrollbar-filler"),e.lineDiv=lr("div"),e.selectionDiv=lr("div",null,null,"position: relative; z-index: 1"),e.cursor=lr("pre"," ","CodeMirror-cursor"),e.otherCursor=lr("pre"," ","CodeMirror-cursor CodeMirror-secondarycursor"),e.measure=lr("div",null,"CodeMirror-measure"),e.lineSpace=lr("div",[e.measure,e.selectionDiv,e.lineDiv,e.cursor,e.otherCursor],null,"position: relative; outline: none"),e.mover=lr("div",[lr("div",[e.lineSpace],"CodeMirror-lines")],null,"position: relative"),e.sizer=lr("div",[e.mover],"CodeMirror-sizer"),e.heightForcer=lr("div"," ",null,"position: absolute; height: "+ci+"px"),e.gutters=lr("div",null,"CodeMirror-gutters"),e.lineGutter=null;var r=lr("div",[e.sizer,e.heightForcer,e.gutters],null,"position: relative; min-height: 100%");return e.scroller=lr("div",[r],"CodeMirror-scroll"),e.scroller.setAttribute("tabIndex","-1"),e.wrapper=lr("div",[e.inputDiv,e.scrollbarH,e.scrollbarV,e.scrollbarFiller,e.scroller],"CodeMirror"),Br&&(e.gutters.style.zIndex=-1,e.scroller.style.paddingRight=0),t.appendChild?t.appendChild(e.wrapper):t(e.wrapper),qr&&(n.style.width="0px"),Hr||(e.scroller.draggable=!0),zr?(e.inputDiv.style.height="1px",e.inputDiv.style.position="absolute"):Br&&(e.scrollbarH.style.minWidth=e.scrollbarV.style.minWidth="18px"),e.viewOffset=e.showingFrom=e.showingTo=e.lastSizeC=0,e.lineNumWidth=e.lineNumInnerWidth=e.lineNumChars=null,e.prevInput="",e.alignWidgets=!1,e.pollingFast=!1,e.poll=new Qn,e.draggingText=!1,e.cachedCharWidth=e.cachedTextHeight=null,e.measureLineCache=[],e.measureLineCachePos=0,e.inaccurateSelection=!1,e.pasteIncoming=!1,e}function n(t){var e={line:0,ch:0};return{doc:t,frontier:0,highlight:new Qn,sel:{from:e,to:e,head:e,anchor:e,shift:!1,extend:!1},scrollTop:0,scrollLeft:0,overwrite:!1,focused:!1,maxLine:En(t,0),maxLineLength:0,maxLineChanged:!1,suppressEdits:!1,goalColumn:null,cantEdit:!1,keyMaps:[]}}function r(e){var n=e.view.doc;e.view.mode=t.getMode(e.options,e.options.mode),n.iter(0,n.size,function(t){t.stateAfter=null}),e.view.frontier=0,N(e,100)}function i(t){var e=t.view.doc,n=q(t.display);if(t.options.lineWrapping){t.display.wrapper.className+=" CodeMirror-wrap";var r=t.display.scroller.clientWidth/$(t.display)-3;e.iter(0,e.size,function(t){if(0!=t.height){var e=Math.ceil(t.text.length/r)||1;1!=e&&Bn(t,e*n)}}),t.display.sizer.style.minWidth=""}else t.display.wrapper.className=t.display.wrapper.className.replace(" CodeMirror-wrap",""),c(t.view),e.iter(0,e.size,function(t){0!=t.height&&Bn(t,n)});U(t,0,e.size),j(t),setTimeout(function(){f(t.display,t.view.doc.height)},100)}function o(t){var e=ai[t.options.keyMap].style;t.display.wrapper.className=t.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(e?" cm-keymap-"+e:"")}function s(t){t.display.wrapper.className=t.display.wrapper.clas
var e=r.input.value=" "+(Se(i.from,i.to)?"":r.input.value),n=0;r.prevInput=" ",r.input.selectionStart=1,r.input.selectionEnd=e.length,Zr=setTimeout(function o(){" "==r.prevInput&&0==r.input.selectionStart?Y(t,si.selectAll)(t):10>n++?Zr=setTimeout(o,500):Q(t)},200)}}var r=t.display,i=t.view.sel,o=re(t,e),s=r.scroller.scrollTop;if(o&&!jr){(Se(i.from,i.to)||Te(o,i.from)||!Te(o,i.to))&&Y(t,Be)(t,o,o);var a=r.input.style.cssText;r.inputDiv.style.position="absolute",r.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: white; outline: none;"+"border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",J(t),Q(t,!0),Se(i.from,i.to)&&(r.input.value=r.prevInput=" "),Ar?(qn(e),Yn(window,"mouseup",function l(){Un(window,"mouseup",l),setTimeout(n,20)})):setTimeout(n,50)}}function be(t,e,n,r,i,o){var s=Xr&&sn(t.view.doc,e,n);if(!s)return we(t,e,n,r,i,o);for(var a=s.length-1;a>=1;--a)we(t,s[a].from,s[a].to,[""],o);return s.length?we(t,s[0].from,s[0].to,r,i,o):void 0}function we(t,e,n,r,i,o){if(!t.view.suppressEdits){var s=t.view,a=s.doc,l=[];a.iter(e.line,n.line+1,function(t){l.push(gn(t.text,t.markedSpans))});var u=s.sel.from,c=s.sel.to,h=on(dn(l[0]),dn(er(l)),e.ch,n.ch,r),f=ke(t,e,n,h,i,o);return s.history&&In(t,e.line,r.length,l,o,u,c,s.sel.from,s.sel.to),f}}function Ce(t,e){var n=t.view.doc,r=t.view.history,i=("undo"==e?r.done:r.undone).pop();if(i){for(var o={events:[],fromBefore:i.fromAfter,toBefore:i.toAfter,fromAfter:i.fromBefore,toAfter:i.toBefore},s=i.events.length-1;s>=0;s-=1){r.dirtyCounter+="undo"==e?-1:1;var a=i.events[s],l=[],u=a.start+a.added;n.iter(a.start,u,function(t){l.push(gn(t.text,t.markedSpans))}),o.events.push({start:a.start,added:a.old.length,old:l});var c=s?null:{from:i.fromBefore,to:i.toBefore};ke(t,{line:a.start,ch:0},{line:u-1,ch:En(n,u-1).text.length},a.old,c,e)}("undo"==e?r.undone:r.done).push(o)}}function ke(t,e,n,r,i,o){var s=t.view,a=s.doc,l=t.display;if(!s.suppressEdits){var c=n.line-e.line,h=En(a,e.line),f=En(a,n.line),p=!1,d=e.line;t.options.lineWrapping||(d=Dn(cn(a,h)),a.iter(d,n.line+1,function(t){return u(a,t)==s.maxLineLength?(p=!0,!0):void 0}));var g=er(r),v=q(l);if(0==e.ch&&0==n.ch&&""==pn(g)){for(var m=[],y=0,x=r.length-1;x>y;++y)m.push(yn(pn(r[y]),dn(r[y]),v));xn(t,f,f.text,dn(g)),c&&a.remove(e.line,c,t),m.length&&a.insert(e.line,m)}else if(h==f)if(1==r.length)xn(t,h,h.text.slice(0,e.ch)+pn(r[0])+h.text.slice(n.ch),dn(r[0]));else{for(var m=[],y=1,x=r.length-1;x>y;++y)m.push(yn(pn(r[y]),dn(r[y]),v));m.push(yn(pn(g)+h.text.slice(n.ch),dn(g),v)),xn(t,h,h.text.slice(0,e.ch)+pn(r[0]),dn(r[0])),a.insert(e.line+1,m)}else if(1==r.length)xn(t,h,h.text.slice(0,e.ch)+pn(r[0])+f.text.slice(n.ch),dn(r[0])),a.remove(e.line+1,c,t);else{var m=[];xn(t,h,h.text.slice(0,e.ch)+pn(r[0]),dn(r[0])),xn(t,f,pn(g)+f.text.slice(n.ch),dn(g));for(var y=1,x=r.length-1;x>y;++y)m.push(yn(pn(r[y]),dn(r[y]),v));c>1&&a.remove(e.line+1,c-1,t),a.insert(e.line+1,m)}if(t.options.lineWrapping){var b=Math.max(5,l.scroller.clientWidth/$(l)-3);a.iter(e.line,e.line+r.length,function(t){if(0!=t.height){var e=(Math.ceil(t.text.length/b)||1)*v;e!=t.height&&Bn(t,e)}})}else a.iter(d,e.line+r.length,function(t){var e=u(a,t);e>s.maxLineLength&&(s.maxLine=t,s.maxLineLength=e,s.maxLineChanged=!0,p=!1)}),p&&(t.curOp.updateMaxLine=!0);s.frontier=Math.min(s.frontier,e.line),N(t,400);var w=r.length-c-1;if(U(t,e.line,n.line+1,w),Zn(t,"change")){for(var y=0;r.length>y;++y)"string"!=typeof r[y]&&(r[y]=r[y].text);var C={from:e,to:n,text:r,origin:o};if(t.curOp.textChanged){for(var k=t.curOp.textChanged;k.next;k=k.next);k.next=C}else t.curOp.textChanged=C}var _,S,T={line:e.line+r.length-1,ch:pn(g).length+(1==r.length?e.ch:0)};if(i&&"string"!=typeof i)i.from?(_=i.from,S=i.to):_=S=i;else if("end"==i)_=S=T;else if("start"==i)_=S=e;else if("around"==i)_=e,S=T;else{var L=function(t){if(Te(t,e))return t;if(!Te(n,t))return T;var r=t.line+w,i=t.ch;return t.line==n.line&&(i+=pn(g).length-(n.ch-(n.line==e.line?e.ch:0))),{line:r,ch:i}};_=L(s
},triggerOnKeyDown:Y(null,ge),execCommand:function(t){return si[t](this)},moveH:Y(null,function(t,e){var n=this.view.sel,r=0>t?n.from:n.to;(n.shift||n.extend||Se(n.from,n.to))&&(r=Pe(this,t,e,!0)),Ee(this,r,r,t)}),deleteH:Y(null,function(t,e){var n=this.view.sel;Se(n.from,n.to)?_e(this,"",n.from,Pe(this,t,e,!1),"delete"):_e(this,"",n.from,n.to,"delete"),this.curOp.userSelChange=!0}),moveV:Y(null,function(t,e){var n,r=this.view,i=r.doc,o=this.display,s=r.sel.head,a=W(this,s,"div"),l=a.left;if(null!=r.goalColumn&&(l=r.goalColumn),"page"==e){var u=Math.min(o.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);n=a.top+t*u}else"line"==e&&(n=t>0?a.bottom+3:a.top-3);do{var c=P(this,l,n);n+=5*t}while(c.outside&&(0>t?n>0:i.height>n));"page"==e&&(o.scrollbarV.scrollTop+=z(this,c,"div").top-a.top),Ee(this,c,c,t),r.goalColumn=l}),toggleOverwrite:function(){(this.view.overwrite=!this.view.overwrite)?this.display.cursor.className+=" CodeMirror-overwrite":this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror-overwrite","")},posFromIndex:function(t){var e,n=0,r=this.view.doc;return r.iter(0,r.size,function(r){var i=r.text.length+1;return i>t?(e=t,!0):(t-=i,++n,void 0)}),Me(r,{line:n,ch:e})},indexFromPos:function(t){if(0>t.line||0>t.ch)return 0;var e=t.ch;return this.view.doc.iter(0,t.line,function(t){e+=t.text.length+1}),e},scrollTo:function(t,e){null!=t&&(this.display.scrollbarH.scrollLeft=this.display.scroller.scrollLeft=t),null!=e&&(this.display.scrollbarV.scrollTop=this.display.scroller.scrollTop=e),y(this,[])},getScrollInfo:function(){var t=this.display.scroller,e=ci;return{left:t.scrollLeft,top:t.scrollTop,height:t.scrollHeight-e,width:t.scrollWidth-e,clientHeight:t.clientHeight-e,clientWidth:t.clientWidth-e}},scrollIntoView:function(t){"number"==typeof t&&(t={line:t,ch:0}),t=t?Me(this.view.doc,t):this.view.sel.head,Oe(this,t)},setSize:function(t,e){function n(t){return"number"==typeof t||/^\d+$/.test(t+"")?t+"px":t}null!=t&&(this.display.wrapper.style.width=n(t)),null!=e&&(this.display.wrapper.style.height=n(e)),this.refresh()},on:function(t,e){Yn(this,t,e)},off:function(t,e){Un(this,t,e)},operation:function(t){return Y(this,t)()},refresh:function(){j(this),this.display.scroller.scrollHeight>this.view.scrollTop&&(this.display.scrollbarV.scrollTop=this.display.scroller.scrollTop=this.view.scrollTop),y(this,!0)},getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};var Jr=t.optionHandlers={},ti=t.defaults={},ei=t.Init={toString:function(){return"CodeMirror.Init"}};$e("value","",function(t,e){t.setValue(e)},!0),$e("mode",null,r,!0),$e("indentUnit",2,r,!0),$e("indentWithTabs",!1),$e("smartIndent",!0),$e("tabSize",4,function(t){r(t),j(t),y(t,!0)},!0),$e("electricChars",!0),$e("theme","default",function(t){s(t),a(t)},!0),$e("keyMap","default",o),$e("extraKeys",null),$e("onKeyEvent",null),$e("onDragEvent",null),$e("lineWrapping",!1,i,!0),$e("gutters",[],function(t){h(t.options),a(t)},!0),$e("lineNumbers",!1,function(t){h(t.options),a(t)},!0),$e("firstLineNumber",1,a,!0),$e("lineNumberFormatter",function(t){return t},a,!0),$e("showCursorWhenSelecting",!1,_,!0),$e("readOnly",!1,function(t,e){"nocursor"==e?(ye(t),t.display.input.blur()):e||Q(t,!0)}),$e("dragDrop",!0),$e("cursorBlinkRate",530),$e("cursorHeight",1),$e("workTime",100),$e("workDelay",100),$e("flattenSpans",!0),$e("pollInterval",100),$e("undoDepth",40),$e("viewportMargin",10,function(t){t.refresh()},!0),$e("tabindex",null,function(t,e){t.display.input.tabIndex=e||""}),$e("autofocus",null);var ni=t.modes={},ri=t.mimeModes={};t.defineMode=function(e,n){if(t.defaults.mode||"null"==e||(t.defaults.mode=e),arguments.length>2){n.dependencies=[];for(var r=2;arguments.length>r;++r)n.dependencies.push(arguments[r])}ni[e]=n},t.defineMIME=function(t,e){ri[t]=e},t.resolveMode=function(e){if("string"==typeof e&&ri.hasOwnProperty(e))e=ri[e];else if("string"==typeof e