EVOLUTION-MANAGER
Edit File: show-hint.min.js
!(function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)})((function(a){"use strict";function b(a,b){this.cm=a,this.options=b,this.widget=null,this.debounce=0,this.tick=0,this.startPos=this.cm.getCursor("start"),this.startLen=this.cm.getLine(this.startPos.line).length-this.cm.getSelection().length;var c=this;a.on("cursorActivity",this.activityFunc=function(){c.cursorActivity()})}function c(a,b,c){var d=a.options.hintOptions,e={};for(var f in o)e[f]=o[f];if(d)for(var f in d)void 0!==d[f]&&(e[f]=d[f]);if(c)for(var f in c)void 0!==c[f]&&(e[f]=c[f]);return e.hint.resolve&&(e.hint=e.hint.resolve(a,b)),e}function d(a){return"string"==typeof a?a:a.text}function e(a,b){function c(a,c){var e;e="string"!=typeof c?function(a){return c(a,b)}:d.hasOwnProperty(c)?d[c]:c,f[a]=e}var d={Up:function(){b.moveFocus(-1)},Down:function(){b.moveFocus(1)},PageUp:function(){b.moveFocus(-b.menuSize()+1,!0)},PageDown:function(){b.moveFocus(b.menuSize()-1,!0)},Home:function(){b.setFocus(0)},End:function(){b.setFocus(b.length-1)},Enter:b.pick,Tab:b.pick,Esc:b.close},e=a.options.customKeys,f=e?{}:d;if(e)for(var g in e)e.hasOwnProperty(g)&&c(g,e[g]);var h=a.options.extraKeys;if(h)for(var g in h)h.hasOwnProperty(g)&&c(g,h[g]);return f}function f(a,b){for(;b&&b!=a;){if("LI"===b.nodeName.toUpperCase()&&b.parentNode==a)return b;b=b.parentNode}}function g(b,c){this.completion=b,this.data=c,this.picked=!1;var g=this,h=b.cm,i=this.hints=document.createElement("ul"),j=b.cm.options.theme;i.className="CodeMirror-hints "+j,this.selectedHint=c.selectedHint||0;for(var m=c.list,n=0;n<m.length;++n){var o=i.appendChild(document.createElement("li")),p=m[n],q=k+(n!=this.selectedHint?"":" "+l);null!=p.className&&(q=p.className+" "+q),o.className=q,p.render?p.render(o,c,p):o.appendChild(document.createTextNode(p.displayText||d(p))),o.hintId=n}var r=h.cursorCoords(b.options.alignWithWord?c.from:null),s=r.left,t=r.bottom,u=!0;i.style.left=s+"px",i.style.top=t+"px";var v=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),w=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(b.options.container||document.body).appendChild(i);var x=i.getBoundingClientRect(),y=x.bottom-w,z=i.scrollHeight>i.clientHeight+1,A=h.getScrollInfo();if(y>0){var B=x.bottom-x.top,C=r.top-(r.bottom-x.top);if(C-B>0)i.style.top=(t=r.top-B)+"px",u=!1;else if(B>w){i.style.height=w-5+"px",i.style.top=(t=r.bottom-x.top)+"px";var D=h.getCursor();c.from.ch!=D.ch&&(r=h.cursorCoords(D),i.style.left=(s=r.left)+"px",x=i.getBoundingClientRect())}}var E=x.right-v;if(E>0&&(x.right-x.left>v&&(i.style.width=v-5+"px",E-=x.right-x.left-v),i.style.left=(s=r.left-E)+"px"),z)for(var F=i.firstChild;F;F=F.nextSibling)F.style.paddingRight=h.display.nativeBarWidth+"px";if(h.addKeyMap(this.keyMap=e(b,{moveFocus:function(a,b){g.changeActive(g.selectedHint+a,b)},setFocus:function(a){g.changeActive(a)},menuSize:function(){return g.screenAmount()},length:m.length,close:function(){b.close()},pick:function(){g.pick()},data:c})),b.options.closeOnUnfocus){var G;h.on("blur",this.onBlur=function(){G=setTimeout((function(){b.close()}),100)}),h.on("focus",this.onFocus=function(){clearTimeout(G)})}return h.on("scroll",this.onScroll=function(){var a=h.getScrollInfo(),c=h.getWrapperElement().getBoundingClientRect(),d=t+A.top-a.top,e=d-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return u||(e+=i.offsetHeight),e<=c.top||e>=c.bottom?b.close():(i.style.top=d+"px",void(i.style.left=s+A.left-a.left+"px"))}),a.on(i,"dblclick",(function(a){var b=f(i,a.target||a.srcElement);b&&null!=b.hintId&&(g.changeActive(b.hintId),g.pick())})),a.on(i,"click",(function(a){var c=f(i,a.target||a.srcElement);c&&null!=c.hintId&&(g.changeActive(c.hintId),b.options.completeOnSingleClick&&g.pick())})),a.on(i,"mousedown",(function(){setTimeout((function(){h.focus()}),20)})),a.signal(c,"select",m[this.selectedHint],i.childNodes[this.selectedHint]),!0}function h(a,b){if(!a.somethingSelected())return b;for(var c=[],d=0;d<b.length;d++)b[d].supportsSelection&&c.push(b[d]);return c}function i(a,b,c,d){if(a.async)a(b,d,c);else{var e=a(b,c);e&&e.then?e.then(d):d(e)}}function j(b,c){var d,e=b.getHelpers(c,"hint");if(e.length){var f=function(a,b,c){function d(e){return e==f.length?b(null):void i(f[e],a,c,(function(a){a&&a.list.length>0?b(a):d(e+1)}))}var f=h(a,e);d(0)};return f.async=!0,f.supportsSelection=!0,f}return(d=b.getHelper(b.getCursor(),"hintWords"))?function(b){return a.hint.fromList(b,{words:d})}:a.hint.anyword?function(b,c){return a.hint.anyword(b,c)}:function(){}}var k="CodeMirror-hint",l="CodeMirror-hint-active";a.showHint=function(a,b,c){if(!b)return a.showHint(c);c&&c.async&&(b.async=!0);var d={hint:b};if(c)for(var e in c)d[e]=c[e];return a.showHint(d)},a.defineExtension("showHint",(function(d){d=c(this,this.getCursor("start"),d);var e=this.listSelections();if(!(e.length>1)){if(this.somethingSelected()){if(!d.hint.supportsSelection)return;for(var f=0;f<e.length;f++)if(e[f].head.line!=e[f].anchor.line)return}this.state.completionActive&&this.state.completionActive.close();var g=this.state.completionActive=new b(this,d);g.options.hint&&(a.signal(this,"startCompletion",this),g.update(!0))}}));var m=window.requestAnimationFrame||function(a){return setTimeout(a,1e3/60)},n=window.cancelAnimationFrame||clearTimeout;b.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&a.signal(this.data,"close"),this.widget&&this.widget.close(),a.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(b,c){var e=b.list[c];e.hint?e.hint(this.cm,b,e):this.cm.replaceRange(d(e),e.from||b.from,e.to||b.to,"complete"),a.signal(b,"pick",e),this.close()},cursorActivity:function(){this.debounce&&(n(this.debounce),this.debounce=0);var a=this.cm.getCursor(),b=this.cm.getLine(a.line);if(a.line!=this.startPos.line||b.length-a.ch!=this.startLen-this.startPos.ch||a.ch<this.startPos.ch||this.cm.somethingSelected()||!a.ch||this.options.closeCharacters.test(b.charAt(a.ch-1)))this.close();else{var c=this;this.debounce=m((function(){c.update()})),this.widget&&this.widget.disable()}},update:function(a){if(null!=this.tick){var b=this,c=++this.tick;i(this.options.hint,this.cm,this.options,(function(d){b.tick==c&&b.finishUpdate(d,a)}))}},finishUpdate:function(b,c){this.data&&a.signal(this.data,"update");var d=this.widget&&this.widget.picked||c&&this.options.completeSingle;this.widget&&this.widget.close(),this.data=b,b&&b.list.length&&(d&&1==b.list.length?this.pick(b,0):(this.widget=new g(this,b),a.signal(b,"shown")))}},g.prototype={close:function(){if(this.completion.widget==this){this.completion.widget=null,this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var a=this.completion.cm;this.completion.options.closeOnUnfocus&&(a.off("blur",this.onBlur),a.off("focus",this.onFocus)),a.off("scroll",this.onScroll)}},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var a=this;this.keyMap={Enter:function(){a.picked=!0}},this.completion.cm.addKeyMap(this.keyMap)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(b,c){if(b>=this.data.list.length?b=c?this.data.list.length-1:0:b<0&&(b=c?0:this.data.list.length-1),this.selectedHint!=b){var d=this.hints.childNodes[this.selectedHint];d&&(d.className=d.className.replace(" "+l,"")),d=this.hints.childNodes[this.selectedHint=b],d.className+=" "+l,d.offsetTop<this.hints.scrollTop?this.hints.scrollTop=d.offsetTop-3:d.offsetTop+d.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=d.offsetTop+d.offsetHeight-this.hints.clientHeight+3),a.signal(this.data,"select",this.data.list[this.selectedHint],d)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},a.registerHelper("hint","auto",{resolve:j}),a.registerHelper("hint","fromList",(function(b,c){var d,e=b.getCursor(),f=b.getTokenAt(e),g=a.Pos(e.line,f.start),h=e;f.start<e.ch&&/\w/.test(f.string.charAt(e.ch-f.start-1))?d=f.string.substr(0,e.ch-f.start):(d="",g=e);for(var i=[],j=0;j<c.words.length;j++){var k=c.words[j];k.slice(0,d.length)==d&&i.push(k)}if(i.length)return{list:i,from:g,to:h}})),a.commands.autocomplete=a.showHint;var o={hint:a.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null};a.defineOption("hintOptions",null)}));