- md5
- a967bacc06a1b2741fd395b299525ebb
- sha1
- fa05b2cca142515391b3b05f494ff7a271ce3cf4
- sha256
- 533f887e0f8d45c56ef8dfc94c631a511338e3c4ec67d2413230521a545b4350
!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";var e="CodeMirror-hint",i="CodeMirror-hint-active";function n(t,e){if(this.cm=t,this.options=e,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,this.options.updateOnCursorActivity){var i=this;t.on("cursorActivity",this.activityFunc=function(){i.cursorActivity()})}}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)},t.defineExtension("showHint",(function(e){e=function(t,e,i){var n=t.options.hintOptions,o={};for(var s in a)o[s]=a[s];if(n)for(var s in n)void 0!==n[s]&&(o[s]=n[s]);if(i)for(var s in i)void 0!==i[s]&&(o[s]=i[s]);o.hint.resolve&&(o.hint=o.hint.resolve(t,e));return o}(this,this.getCursor("start"),e);var i=this.listSelections();if(!(i.length>1)){if(this.somethingSelected()){if(!e.hint.supportsSelection)return;for(var o=0;o<i.length;o++)if(i[o].head.line!=i[o].anchor.line)return}this.state.completionActive&&this.state.completionActive.close();var s=this.state.completionActive=new n(this,e);s.options.hint&&(t.signal(this,"startCompletion",this),s.update(!0))}})),t.defineExtension("closeHint",(function(){this.state.completionActive&&this.state.completionActive.close()}));var o=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},s=window.cancelAnimationFrame||clearTimeout;function c(t){return"string"==typeof t?t:t.text}function r(t,e){for(;e&&e!=t;){if("LI"===e.nodeName.toUpperCase()&&e.parentNode==t)return e;e=e.parentNode}}function l(n,o){this.id="cm-complete-"+Math.floor(Math.random(1e6)),this.completion=n,this.data=o,this.picked=!1;var s=this,l=n.cm,h=l.getInputField().ownerDocument,a=h.defaultView||h.parentWindow,u=this.hints=h.createElement("ul");u.setAttribute("role","listbox"),u.setAttribute("aria-expanded","true"),u.id=this.id;var d=n.cm.options.theme;u.className="CodeMirror-hints "+d,this.selectedHint=o.selectedHint||0;for(var f=o.list,p=0;p<f.length;++p){var m=u.appendChild(h.createElement("li")),g=f[p],v=e+(p!=this.selectedHint?"":" "+i);null!=g.className&&(v=g.className+" "+v),m.className=v,p==this.selectedHint&&m.setAttribute("aria-selected","true"),m.id=this.id+"-"+p,m.setAttribute("role","option"),g.render?g.render(m,o,g):m.appendChild(h.createTextNode(g.displayText||c(g))),m.hintId=p}var y=n.options.container||h.body,w=l.cursorCoords(n.options.alignWithWord?o.from:null),b=w.left,A=w.bottom,H=!0,C=0,k=0;if(y!==h.body){var x=-1!==["absolute","relative","fixed"].indexOf(a.getComputedStyle(y).position)?y:y.offsetParent,S=x.getBoundingClientRect(),T=h.body.getBoundingClientRect();C=S.left-T.left-x.scrollLeft,k=S.top-T.top-x.scrollTop}u.style.left=b-C+"px",u.style.top=A-k+"px";var F=a.innerWidth||Math.max(h.body.offsetWidth,h.documentElement.offsetWidth),M=a.innerHeight||Math.max(h.body.offsetHeight,h.documentElement.offsetHeight);y.appendChild(u),l.getInputField().setAttribute("aria-autocomplete","list"),l.getInputField().setAttribute("aria-owns",this.id),l.getInputField().setAttribute("aria-activedescendant",this.id+"-"+this.selectedHint);var O,N=n.options.moveOnOverlap?u.getBoundingClientRect():new DOMRect,I=!!n.options.paddingForScrollbar&&u.scrollHeight>u.clientHeight+1;if(setTimeout((function(){O=l.getScrollInfo()})),N.bottom-M>0){var P=N.bottom-N.top,E=N.top-(w.bottom-w.top)-2;M-N.top<E?(P>E&&(u.style.height=(P=E)+"px"),u.style.top=(A=w.top-P)+k+"px",H=!1):u.style.height=M-N.top-2+"px"}var W,R=N.right-F;if(I&&(R+=l.display.nativeBarWidth),R>0&&(N.right-N.left>F&&(u.style.width=F-5+"px",R-=N.right-N.left-F),u.style.left=(b=Math.max(w.left-R-C,0))+"px"),I)for(var B=u.firstChild;B;B=B.nextSibling)B.style.paddingRight=l.display.nativeBarWidth+"px";(l.addKeyMap(this.keyMap=function(t,e){var i={Up:function(){e.moveFocus(-1)},Down:function(){e.moveFocus(1)},PageUp:function(){e.moveFocus(1-e.menuSize(),!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};/Mac/.test(navigator.platform)&&(i["Ctrl-P"]=function(){e.moveFocus(-1)},i["Ctrl-N"]=function(){e.moveFocus(1)});var n=t.options.customKeys,o=n?{}:i;function s(t,n){var s;s="string"!=typeof n?function(t){return n(t,e)}:i.hasOwnProperty(n)?i[n]:n,o[t]=s}if(n)for(var c in n)n.hasOwnProperty(c)&&s(c,n[c]);var r=t.options.extraKeys;if(r)for(var c in r)r.hasOwnProperty(c)&&s(c,r[c]);return o}(n,{moveFocus:function(t,e){s.changeActive(s.selectedHint+t,e)},setFocus:function(t){s.changeActive(t)},menuSize:function(){return s.screenAmount()},length:f.length,close:function(){n.close()},pick:function(){s.pick()},data:o})),n.options.closeOnUnfocus)&&(l.on("blur",this.onBlur=function(){W=setTimeout((function(){n.close()}),100)}),l.on("focus",this.onFocus=function(){clearTimeout(W)}));l.on("scroll",this.onScroll=function(){var t=l.getScrollInfo(),e=l.getWrapperElement().getBoundingClientRect();O||(O=l.getScrollInfo());var i=A+O.top-t.top,o=i-(a.pageYOffset||(h.documentElement||h.body).scrollTop);if(H||(o+=u.offsetHeight),o<=e.top||o>=e.bottom)return n.close();u.style.top=i+"px",u.style.left=b+O.left-t.left+"px"}),t.on(u,"dblclick",(function(t){var e=r(u,t.target||t.srcElement);e&&null!=e.hintId&&(s.changeActive(e.hintId),s.pick())})),t.on(u,"click",(function(t){var e=r(u,t.target||t.srcElement);e&&null!=e.hintId&&(s.changeActive(e.hintId),n.options.completeOnSingleClick&&s.pick())})),t.on(u,"mousedown",(function(){setTimeout((function(){l.focus()}),20)}));var K=this.getSelectedHintRange();return 0===K.from&&0===K.to||this.scrollToActive(),t.signal(o,"select",f[this.selectedHint],u.childNodes[this.selectedHint]),!0}function h(t,e,i,n){if(t.async)t(e,n,i);else{var o=t(e,i);o&&o.then?o.then(n):n(o)}}n.prototype={close:function(){this.active()&&(this.cm.state.completionActive=null,this.tick=null,this.options.updateOnCursorActivity&&this.cm.off("cursorActivity",this.activityFunc),this.widget&&this.data&&t.signal(this.data,"close"),this.widget&&this.widget.close(),t.signal(this.cm,"endCompletion",this.cm))},active:function(){return this.cm.state.completionActive==this},pick:function(e,i){var n=e.list[i],o=this;this.cm.operation((function(){n.hint?n.hint(o.cm,e,n):o.cm.replaceRange(c(n),n.from||e.from,n.to||e.to,"complete"),t.signal(e,"pick",n),o.cm.scrollIntoView()})),this.options.closeOnPick&&this.close()},cursorActivity:function(){this.debounce&&(s(this.debounce),this.debounce=0);var t=this.startPos;this.data&&(t=this.data.from);var e=this.cm.getCursor(),i=this.cm.getLine(e.line);if(e.line!=this.startPos.line||i.length-e.ch!=this.startLen-this.startPos.ch||e.ch<t.ch||this.cm.somethingSelected()||!e.ch||this.options.closeCharacters.test(i.charAt(e.ch-1)))this.close();else{var n=this;this.debounce=o((function(){n.update()})),this.widget&&this.widget.disable()}},update:function(t){if(null!=this.tick){var e=this,i=++this.tick;h(this.options.hint,this.cm,this.options,(function(n){e.tick==i&&e.finishUpdate(n,t)}))}},finishUpdate:function(e,i){this.data&&t.signal(this.data,"update");var n=this.widget&&this.widget.picked||i&&this.options.completeSingle;this.widget&&this.widget.close(),this.data=e,e&&e.list.length&&(n&&1==e.list.length?this.pick(e,0):(this.widget=new l(this,e),t.signal(e,"shown")))}},l.prototype={close:function(){if(this.completion.widget==this){this.completion.widget=null,this.hints.parentNode&&this.hints.parentNode.removeChild(this.hints),this.completion.cm.removeKeyMap(this.keyMap);var t=this.completion.cm.getInputField();t.removeAttribute("aria-activedescendant"),t.removeAttribute("aria-owns");var e=this.completion.cm;this.completion.options.closeOnUnfocus&&(e.off("blur",this.onBlur),e.off("focus",this.onFocus)),e.off("scroll",this.onScroll)}},disable:function(){this.completion.cm.removeKeyMap(this.keyMap);var t=this;this.keyMap={Enter:function(){t.picked=!0}},this.completion.cm.addKeyMap(this.keyMap)},pick:function(){this.completion.pick(this.data,this.selectedHint)},changeActive:function(e,n){if(e>=this.data.list.length?e=n?this.data.list.length-1:0:e<0&&(e=n?0:this.data.list.length-1),this.selectedHint!=e){var o=this.hints.childNodes[this.selectedHint];o&&(o.className=o.className.replace(" "+i,""),o.removeAttribute("aria-selected")),(o=this.hints.childNodes[this.selectedHint=e]).className+=" "+i,o.setAttribute("aria-selected","true"),this.completion.cm.getInputField().setAttribute("aria-activedescendant",o.id),this.scrollToActive(),t.signal(this.data,"select",this.data.list[this.selectedHint],o)}},scrollToActive:function(){var t=this.getSelectedHintRange(),e=this.hints.childNodes[t.from],i=this.hints.childNodes[t.to],n=this.hints.firstChild;e.offsetTop<this.hints.scrollTop?this.hints.scrollTop=e.offsetTop-n.offsetTop:i.offsetTop+i.offsetHeight>this.hints.scrollTop+this.hints.clientHeight&&(this.hints.scrollTop=i.offsetTop+i.offsetHeight-this.hints.clientHeight+n.offsetTop)},screenAmount:function(){return Math.floor(this.hints.clientHeight/this.hints.firstChild.offsetHeight)||1},getSelectedHintRange:function(){var t=this.completion.options.scrollMargin||0;return{from:Math.max(0,this.selectedHint-t),to:Math.min(this.data.list.length-1,this.selectedHint+t)}}},t.registerHelper("hint","auto",{resolve:function(e,i){var n,o=e.getHelpers(i,"hint");if(o.length){var s=function(t,e,i){var n=function(t,e){if(!t.somethingSelected())return e;for(var i=[],n=0;n<e.length;n++)e[n].supportsSelection&&i.push(e[n]);return i}(t,o);!function o(s){if(s==n.length)return e(null);h(n[s],t,i,(function(t){t&&t.list.length>0?e(t):o(s+1)}))}(0)};return s.async=!0,s.supportsSelection=!0,s}return(n=e.getHelper(e.getCursor(),"hintWords"))?function(e){return t.hint.fromList(e,{words:n})}:t.hint.anyword?function(e,i){return t.hint.anyword(e,i)}:function(){}}}),t.registerHelper("hint","fromList",(function(e,i){var n,o=e.getCursor(),s=e.getTokenAt(o),c=t.Pos(o.line,s.start),r=o;s.start<o.ch&&/\w/.test(s.string.charAt(o.ch-s.start-1))?n=s.string.substr(0,o.ch-s.start):(n="",c=o);for(var l=[],h=0;h<i.words.length;h++){var a=i.words[h];a.slice(0,n.length)==n&&l.push(a)}if(l.length)return{list:l,from:c,to:r}})),t.commands.autocomplete=t.showHint;var a={hint:t.hint.auto,completeSingle:!0,alignWithWord:!0,closeCharacters:/[\s()\[\]{};:>,]/,closeOnPick:!0,closeOnUnfocus:!0,updateOnCursorActivity:!0,completeOnSingleClick:!0,container:null,customKeys:null,extraKeys:null,paddingForScrollbar:!0,moveOnOverlap:!0};t.defineOption("hintOptions",null)}));
The same content is in 13 releases, Joomla 4.3.0-beta4 to 4.3.4. See them all, or every version of this file.