File Manager

Current Directory: /home/astoriaah/www/old15/media/editors/codemirror/addon/hint
Viewing File: /home/astoriaah/www/old15/media/editors/codemirror/addon/hint/show-hint.min.js
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function e(t,e,i,n){if(t.async){var o=++h;t(e,function(t){h==o&&n(t)},i)}else n(t(e,i))}function i(t,e){this.cm=t,this.options=this.buildOptions(e),this.widget=this.onClose=null}function n(t){return"string"==typeof t?t:t.text}function o(t,e){function i(t,i){var o;o="string"!=typeof i?function(t){return i(t,e)}:n.hasOwnProperty(i)?n[i]:i,s[t]=o}var n={Up:function(){e.moveFocus(-1)},Down:function(){e.moveFocus(1)},PageUp:function(){e.moveFocus(-e.menuSize()+1,!0)},PageDown:function(){e.moveFocus(e.menuSize()-1,!0)},Home:function(){e.setFocus(0)},End:function(){e.setFocus(e.length-1)},Enter:e.pick,Tab:e.pick,Esc:e.close},o=t.options.customKeys,s=o?{}:n;if(o)for(var c in o)o.hasOwnProperty(c)&&i(c,o[c]);var l=t.options.extraKeys;if(l)for(var c in l)l.hasOwnProperty(c)&&i(c,l[c]);return s}function s(t,e){for(;e&&e!=t;){if("LI"===e.nodeName.toUpperCase()&&e.parentNode==t)return e;e=e.parentNode}}function c(e,i){this.completion=e,this.data=i;var c=this,h=e.cm,a=this.hints=document.createElement("ul");a.className="CodeMirror-hints",this.selectedHint=i.selectedHint||0;for(var f=i.list,u=0;u<f.length;++u){var d=a.appendChild(document.createElement("li")),p=f[u],m=l+(u!=this.selectedHint?"":" "+r);null!=p.className&&(m=p.className+" "+m),d.className=m,p.render?p.render(d,i,p):d.appendChild(document.createTextNode(p.displayText||n(p))),d.hintId=u}var g=h.cursorCoords(e.options.alignWithWord?i.from:null),v=g.left,w=g.bottom,y=!0;a.style.left=v+"px",a.style.top=w+"px";var C=window.innerWidth||Math.max(document.body.offsetWidth,document.documentElement.offsetWidth),H=window.innerHeight||Math.max(document.body.offsetHeight,document.documentElement.offsetHeight);(e.options.container||document.body).appendChild(a);var b=a.getBoundingClientRect(),x=b.bottom-H;if(x>0){var k=b.bottom-b.top,A=g.top-(g.bottom-b.top);if(A-k>0)a.style.top=(w=g.top-k)+"px",y=!1;else if(k>H){a.style.height=H-5+"px",a.style.top=(w=g.bottom-b.top)+"px";var T=h.getCursor();i.from.ch!=T.ch&&(g=h.cursorCoords(T),a.style.left=(v=g.left)+"px",b=a.getBoundingClientRect())}}var N=b.right-C;if(N>0&&(b.right-b.left>C&&(a.style.width=C-5+"px",N-=b.right-b.left-C),a.style.left=(v=g.left-N)+"px"),h.addKeyMap(this.keyMap=o(e,{moveFocus:function(t,e){c.changeActive(c.selectedHint+t,e)},setFocus:function(t){c.changeActive(t)},menuSize:function(){return c.screenAmount()},length:f.length,close:function(){e.close()},pick:function(){c.pick()},data:i})),e.options.closeOnUnfocus){var O;h.on("blur",this.onBlur=function(){O=setTimeout(function(){e.close()},100)}),h.on("focus",this.onFocus=function(){clearTimeout(O)})}var S=h.getScrollInfo();return h.on("scroll",this.onScroll=function(){var t=h.getScrollInfo(),i=h.getWrapperElement().getBoundingClientRect(),n=w+S.top-t.top,o=n-(window.pageYOffset||(document.documentElement||document.body).scrollTop);return y||(o+=a.offsetHeight),o<=i.top||o>=i.bottom?e.close():(a.style.top=n+"px",void(a.style.left=v+S.left-t.left+"px"))}),t.on(a,"dblclick",function(t){var e=s(a,t.target||t.srcElement);e&&null!=e.hintId&&(c.changeActive(e.hintId),c.pick())}),t.on(a,"click",function(t){var i=s(a,t.target||t.srcElement);i&&null!=i.hintId&&(c.changeActive(i.hintId),e.options.completeOnSingleClick&&c.pick())}),t.on(a,"mousedown",function(){setTimeout(function(){h.focus()},20)}),t.signal(i,"select",f[0],a.firstChild),!0}var l="CodeMirror-hint",r="CodeMirror-hint-active";t.showHint=function(t,e,i){if(!e)return t.showHint(i);i&&i.async&&(e.async=!0);var n={hint:e};if(i)for(var o in i)n[o]=i[o];return t.showHint(n)};var h=0;t.defineExtension("showHint",function(n){if(!(this.listSelections().length>1||this.somethingSelected())){this.state.completionActive&&this.state.completionActive.close();var o=this.state.completionActive=new i(this,n),s=o.options.hint;if(s)return t.signal(this,"startCompletion",this),e(s,this,o.options,function(t){o.showHints(t)})}}),i.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.widget&&this.widget.close(),this.onClose&&this.onClose(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(e,i){var o=e.list[i];o.hint?o.hint(this.cm,e,o):this.cm.replaceRange(n(o),o.from||e.from,o.to||e.to,"complete"),t.signal(e,"pick",o),this.close()},showHints:function(t){return t&&t.list.length&&this.active()?void(this.options.completeSingle&&1==t.list.length?this.pick(t,0):this.showWidget(t)):this.close()},showWidget:function(i){function n(){h||(h=!0,f.close(),f.cm.off("cursorActivity",r),i&&t.signal(i,"close"))}function o(){h||(t.signal(i,"update"),e(f.options.hint,f.cm,f.options,s))}function s(t){if(i=t,!h){if(!i||!i.list.length)return n();f.widget&&f.widget.close(),f.widget=new c(f,i)}}function l(){a&&(g(a),a=0)}function r(){l();var t=f.cm.getCursor(),e=f.cm.getLine(t.line);t.line!=d.line||e.length-t.ch!=p-d.ch||t.ch<d.ch||f.cm.somethingSelected()||t.ch&&u.test(e.charAt(t.ch-1))?f.close():(a=m(o),f.widget&&f.widget.close())}this.widget=new c(this,i),t.signal(i,"shown");var h,a=0,f=this,u=this.options.closeCharacters,d=this.cm.getCursor(),p=this.cm.getLine(d.line).length,m=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},g=window.cancelAnimationFrame||clearTimeout;this.cm.on("cursorActivity",r),this.onClose=n},buildOptions:function(t){var e=this.cm.options.hintOptions,i={};for(var n in a)i[n]=a[n];if(e)for(var n in e)void 0!==e[n]&&(i[n]=e[n]);if(t)for(var n in t)void 0!==t[n]&&(i[n]=t[n]);return i}},c.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 t=this.completion.cm;this.completion.options.closeOnUnfocus&&(t.off("blur",this.onBlur),t.off("focus",this.onFocus)),t.off("scroll",this.onScroll)}},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(e,i){if(e>=this.data.list.length?e=i?this.data.list.length-1:0:0>e&&(e=i?0:this.data.list.length-1),this.selectedHint!=e){var n=this.hints.childNodes[this.selectedHint];n.className=n.className.replace(" "+r,""),n=this.hints.childNodes[this.selectedHint=e],n.className+=" "+r,n.offsetTop<this.hints.scrollTop?this.hints.scrollTop=n.offsetTop-3:n.offsetTop+n.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=n.offsetTop+n.offsetHeight-this.hints.clientHeight+3),t.signal(this.data,"select",this.data.list[this.selectedHint],n)}},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1}},t.registerHelper("hint","auto",function(e,i){var n,o=e.getHelpers(e.getCursor(),"hint");if(o.length)for(var s=0;s<o.length;s++){var c=o[s](e,i);if(c&&c.list.length)return c}else if(n=e.getHelper(e.getCursor(),"hintWords")){if(n)return t.hint.fromList(e,{words:n})}else if(t.hint.anyword)return t.hint.anyword(e,i)}),t.registerHelper("hint","fromList",function(e,i){for(var n=e.getCursor(),o=e.getTokenAt(n),s=[],c=0;c<i.words.length;c++){var l=i.words[c];l.slice(0,o.string.length)==o.string&&s.push(l)}return s.length?{list:s,from:t.Pos(n.line,o.start),to:t.Pos(n.line,o.end)}:void 0}),t.commands.autocomplete=t.showHint;var a={hint:t.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnUnfocus:!0,completeOnSingleClick:!1,container:null,customKeys:null,extraKeys:null};t.defineOption("hintOptions",null)});