Current File : /home/pacjaorg/public_html/kmm/media/vendor/codemirror/addon/tern/tern.min.js
(function(c){typeof exports=="object"&&typeof module=="object"?c(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){"use strict";c.TernServer=function(e){var t=this;this.options=e||{};var n=this.options.plugins||(this.options.plugins={});n.doc_comment||(n.doc_comment=!0),this.docs=Object.create(null),this.options.useWorker?this.server=new te(this):this.server=new tern.Server({getFile:function(o,i){return S(t,o,i)},async:!0,defs:this.options.defs||[],plugins:n}),this.trackChange=function(o,i){z(t,o,i)},this.cachedArgHints=null,this.activeArgHints=null,this.jumpStack=[],this.getHint=function(o,i){return _(t,o,i)},this.getHint.async=!0},c.TernServer.prototype={addDoc:function(e,t){var n={doc:t,name:e,changed:null};return this.server.addFile(e,H(this,n)),c.on(t,"change",this.trackChange),this.docs[e]=n},delDoc:function(e){var t=L(this,e);t&&(c.off(t.doc,"change",this.trackChange),delete this.docs[t.name],this.server.delFile(t.name))},hideDoc:function(e){C(this);var t=L(this,e);t&&t.changed&&j(this,t)},complete:function(e){e.showHint({hint:this.getHint})},showType:function(e,t,n){O(this,e,t,"type",n)},showDocs:function(e,t,n){O(this,e,t,"documentation",n)},updateArgHints:function(e){X(this,e)},jumpToDef:function(e){J(this,e)},jumpBack:function(e){$(this,e)},rename:function(e){Q(this,e)},selectName:function(e){U(this,e)},request:function(e,t,n,o){var i=this,r=x(this,e.getDoc()),s=P(this,r,t,o),a=s.query&&this.options.queryOptions&&this.options.queryOptions[s.query.type];if(a)for(var l in a)s.query[l]=a[l];this.server.request(s,function(f,u){!f&&i.options.responseFilter&&(u=i.options.responseFilter(r,t,s,f,u)),n(f,u)})},destroy:function(){C(this),this.worker&&(this.worker.terminate(),this.worker=null)}};var d=c.Pos,m="CodeMirror-Tern-",N=250;function S(e,t,n){var o=e.docs[t];o?n(H(e,o)):e.options.getFile?e.options.getFile(t,n):n(null)}function x(e,t,n){for(var o in e.docs){var i=e.docs[o];if(i.doc==t)return i}if(!n){for(var r=0;;++r)if(o="[doc"+(r||"")+"]",!e.docs[o]){n=o;break}}return e.addDoc(n,t)}function L(e,t){if(typeof t=="string")return e.docs[t];if(t instanceof c&&(t=t.getDoc()),t instanceof c.Doc)return x(e,t)}function z(e,t,n){var o=x(e,t),i=e.cachedArgHints;i&&i.doc==t&&D(i.start,n.to)>=0&&(e.cachedArgHints=null);var r=o.changed;r==null&&(o.changed=r={from:n.from.line,to:n.from.line});var s=n.from.line+(n.text.length-1);n.from.line<r.to&&(r.to=r.to-(n.to.line-s)),s>=r.to&&(r.to=s+1),r.from>n.from.line&&(r.from=n.from.line),t.lineCount()>N&&n.to-r.from>100&&setTimeout(function(){o.changed&&o.changed.to-o.changed.from>100&&j(e,o)},200)}function j(e,t){e.server.request({files:[{type:"full",name:t.name,text:H(e,t)}]},function(n){n?window.console.error(n):t.changed=null})}function _(e,t,n){e.request(t,{type:"completions",types:!0,docs:!0,urls:!0},function(o,i){if(o)return b(e,t,o);var r=[],s="",a=i.start,l=i.end;t.getRange(d(a.line,a.ch-2),a)=='["'&&t.getRange(l,d(l.line,l.ch+2))!='"]'&&(s='"]');for(var f=0;f<i.completions.length;++f){var u=i.completions[f],p=V(u.type);i.guess&&(p+=" "+m+"guess"),r.push({text:u.name+s,displayText:u.displayName||u.name,className:p,data:u})}var h={from:a,to:l,list:r},g=null;c.on(h,"close",function(){T(g)}),c.on(h,"update",function(){T(g)}),c.on(h,"select",function(v,w){T(g);var k=e.options.completionTip?e.options.completionTip(v.data):v.data.doc;k&&(g=F(w.parentNode.getBoundingClientRect().right+window.pageXOffset,w.getBoundingClientRect().top+window.pageYOffset,k,t,m+"hint-doc"))}),n(h)})}function V(e){var t;return e=="?"?t="unknown":e=="number"||e=="string"||e=="bool"?t=e:/^fn\(/.test(e)?t="fn":/^\[/.test(e)?t="array":t="object",m+"completion "+m+"completion-"+t}function O(e,t,n,o,i){e.request(t,o,function(r,s){if(r)return b(e,t,r);if(e.options.typeTip)var a=e.options.typeTip(s);else{var a=y("span",null,y("strong",null,s.type||"not found"));if(s.doc&&a.appendChild(document.createTextNode(" \u2014 "+s.doc)),s.url){a.appendChild(document.createTextNode(" "));var l=a.appendChild(y("a",null,"[docs]"));l.href=s.url,l.target="_blank"}}I(t,a,e),i&&i()},n)}function X(e,t){if(C(e),!t.somethingSelected()){var n=t.getTokenAt(t.getCursor()).state,o=c.innerMode(t.getMode(),n);if(o.mode.name=="javascript"){var i=o.state.lexical;if(i.info=="call"){for(var r,s=i.pos||0,a=t.getOption("tabSize"),l=t.getCursor().line,f=Math.max(0,l-9),u=!1;l>=f;--l){for(var p=t.getLine(l),h=0,g=0;;){var v=p.indexOf("	",g);if(v==-1)break;h+=a-(v+h)%a-1,g=v+1}if(r=i.column-h,p.charAt(r)=="("){u=!0;break}}if(u){var w=d(l,r),k=e.cachedArgHints;if(k&&k.doc==t.getDoc()&&D(w,k.start)==0)return R(e,t,s);e.request(t,{type:"type",preferFunction:!0,end:w},function(ne,A){ne||!A.type||!/^fn\(/.test(A.type)||(e.cachedArgHints={start:w,type:Y(A.type),name:A.exprName||A.name||"fn",guess:A.guess,doc:t.getDoc()},R(e,t,s))})}}}}}function R(e,t,n){C(e);for(var o=e.cachedArgHints,i=o.type,r=y("span",o.guess?m+"fhint-guess":null,y("span",m+"fname",o.name),"("),s=0;s<i.args.length;++s){s&&r.appendChild(document.createTextNode(", "));var a=i.args[s];r.appendChild(y("span",m+"farg"+(s==n?" "+m+"farg-current":""),a.name||"?")),a.type!="?"&&(r.appendChild(document.createTextNode(":\xA0")),r.appendChild(y("span",m+"type",a.type)))}r.appendChild(document.createTextNode(i.rettype?") ->\xA0":")")),i.rettype&&r.appendChild(y("span",m+"type",i.rettype));var l=t.cursorCoords(null,"page"),f=e.activeArgHints=F(l.right+1,l.bottom,r,t);setTimeout(function(){f.clear=W(t,function(){e.activeArgHints==f&&C(e)})},20)}function Y(e){var t=[],n=3;function o(s){for(var a=0,l=n;;){var f=e.charAt(n);if(s.test(f)&&!a)return e.slice(l,n);/[{\[\(]/.test(f)?++a:/[}\]\)]/.test(f)&&--a,++n}}if(e.charAt(n)!=")")for(;;){var i=e.slice(n).match(/^([^, \(\[\{]+): /);if(i&&(n+=i[0].length,i=i[1]),t.push({name:i,type:o(/[\),]/)}),e.charAt(n)==")")break;n+=2}var r=e.slice(n).match(/^\) -> (.*)$/);return{args:t,rettype:r&&r[1]}}function J(e,t){function n(o){var i={type:"definition",variable:o||null},r=x(e,t.getDoc());e.server.request(P(e,r,i),function(s,a){if(s)return b(e,t,s);if(!a.file&&a.url){window.open(a.url);return}if(a.file){var l=e.docs[a.file],f;if(l&&(f=G(l.doc,a))){e.jumpStack.push({file:r.name,start:t.getCursor("from"),end:t.getCursor("to")}),E(e,r,l,f.start,f.end);return}}b(e,t,"Could not find a definition.")})}K(t)?n():B(t,"Jump to variable",function(o){o&&n(o)})}function $(e,t){var n=e.jumpStack.pop(),o=n&&e.docs[n.file];o&&E(e,x(e,t.getDoc()),o,n.start,n.end)}function E(e,t,n,o,i){n.doc.setSelection(o,i),t!=n&&e.options.switchToDoc&&(C(e),e.options.switchToDoc(n.name,n.doc))}function G(e,t){for(var n=t.context.slice(0,t.contextOffset).split(`
`),o=t.start.line-(n.length-1),i=d(o,(n.length==1?t.start.ch:e.getLine(o).length)-n[0].length),r=e.getLine(o).slice(i.ch),s=o+1;s<e.lineCount()&&r.length<t.context.length;++s)r+=`
`+e.getLine(s);if(r.slice(0,t.context.length)==t.context)return t;for(var a=e.getSearchCursor(t.context,0,!1),l,f=1/0;a.findNext();){var u=a.from(),p=Math.abs(u.line-i.line)*1e4;p||(p=Math.abs(u.ch-i.ch)),p<f&&(l=u,f=p)}if(!l)return null;if(n.length==1?l.ch+=n[0].length:l=d(l.line+(n.length-1),n[n.length-1].length),t.start.line==t.end.line)var h=d(l.line,l.ch+(t.end.ch-t.start.ch));else var h=d(l.line+(t.end.line-t.start.line),t.end.ch);return{start:l,end:h}}function K(e){var t=e.getCursor("end"),n=e.getTokenAt(t);return n.start<t.ch&&n.type=="comment"?!1:/[\w)\]]/.test(e.getLine(t.line).slice(Math.max(t.ch-1,0),t.ch+1))}function Q(e,t){var n=t.getTokenAt(t.getCursor());if(!/\w/.test(n.string))return b(e,t,"Not at a variable");B(t,"New name for "+n.string,function(o){e.request(t,{type:"rename",newName:o,fullDocs:!0},function(i,r){if(i)return b(e,t,i);q(e,r.changes)})})}function U(e,t){var n=x(e,t.doc).name;e.request(t,{type:"refs"},function(o,i){if(o)return b(e,t,o);for(var r=[],s=0,a=t.getCursor(),l=0;l<i.refs.length;l++){var f=i.refs[l];f.file==n&&(r.push({anchor:f.start,head:f.end}),D(a,f.start)>=0&&D(a,f.end)<=0&&(s=r.length-1))}t.setSelections(r,s)})}var Z=0;function q(e,t){for(var n=Object.create(null),o=0;o<t.length;++o){var i=t[o];(n[i.file]||(n[i.file]=[])).push(i)}for(var r in n){var s=e.docs[r],a=n[r];if(s){a.sort(function(f,u){return D(u.start,f.start)});for(var l="*rename"+ ++Z,o=0;o<a.length;++o){var i=a[o];s.doc.replaceRange(i.text,i.start,i.end,l)}}}}function P(e,t,n,o){var i=[],r=0,s=!n.fullDocs;s||delete n.fullDocs,typeof n=="string"&&(n={type:n}),n.lineCharPositions=!0,n.end==null&&(n.end=o||t.doc.getCursor("end"),t.doc.somethingSelected()&&(n.start=t.doc.getCursor("start")));var a=n.start||n.end;if(t.changed)if(t.doc.lineCount()>N&&s!==!1&&t.changed.to-t.changed.from<100&&t.changed.from<=a.line&&t.changed.to>n.end.line){i.push(M(t,a,n.end)),n.file="#0";var r=i[0].offsetLines;n.start!=null&&(n.start=d(n.start.line- -r,n.start.ch)),n.end=d(n.end.line-r,n.end.ch)}else i.push({type:"full",name:t.name,text:H(e,t)}),n.file=t.name,t.changed=null;else n.file=t.name;for(var l in e.docs){var f=e.docs[l];f.changed&&f!=t&&(i.push({type:"full",name:f.name,text:H(e,f)}),f.changed=null)}return{query:n,files:i}}function M(e,t,n){for(var o=e.doc,i=null,r=null,s,a=4,l=t.line-1,f=Math.max(0,l-50);l>=f;--l){var u=o.getLine(l),p=u.search(/\bfunction\b/);if(!(p<0)){var h=c.countColumn(u,null,a);i!=null&&i<=h||(i=h,r=l)}}r==null&&(r=f);var g=Math.min(o.lastLine(),n.line+20);if(i==null||i==c.countColumn(o.getLine(t.line),null,a))s=g;else for(s=n.line+1;s<g;++s){var h=c.countColumn(o.getLine(s),null,a);if(h<=i)break}var v=d(r,0);return{type:"part",name:e.name,offsetLines:v.line,text:o.getRange(v,d(s,n.line==s?null:0))}}var D=c.cmpPos;function y(e,t){var n=document.createElement(e);t&&(n.className=t);for(var o=2;o<arguments.length;++o){var i=arguments[o];typeof i=="string"&&(i=document.createTextNode(i)),n.appendChild(i)}return n}function B(e,t,n){if(e.openDialog){var o=document.createDocumentFragment();o.appendChild(document.createTextNode(t+": "));var i=document.createElement("input");i.type="text",o.appendChild(i),e.openDialog(o,n)}else n(prompt(t,""))}function I(e,t,n){e.state.ternTooltip&&T(e.state.ternTooltip);var o=e.cursorCoords(),i=e.state.ternTooltip=F(o.right+1,o.bottom,t,e);function r(){l=!0,a||s()}function s(){e.state.ternTooltip=null,i.parentNode&&ee(i),f()}var a=!1,l=!1;c.on(i,"mousemove",function(){a=!0}),c.on(i,"mouseout",function(u){var p=u.relatedTarget||u.toElement;(!p||!c.contains(i,p))&&(l?s():a=!1)}),setTimeout(r,n.options.hintDelay?n.options.hintDelay:1700);var f=W(e,s)}function W(e,t){return e.on("cursorActivity",t),e.on("blur",t),e.on("scroll",t),e.on("setDoc",t),function(){e.off("cursorActivity",t),e.off("blur",t),e.off("scroll",t),e.off("setDoc",t)}}function F(e,t,n,o,i){var r=y("div",m+"tooltip "+(i||""),n);r.style.left=e+"px",r.style.top=t+"px";var s=((o.options||{}).hintOptions||{}).container||document.body;s.appendChild(r);var a=o.cursorCoords(),l=window.innerWidth,f=window.innerHeight,u=r.getBoundingClientRect(),p=document.querySelector(".CodeMirror-hints"),h=u.bottom-f,g=u.right-l;if(p&&g>0){r.style.left=0;var u=r.getBoundingClientRect();r.style.left=(e=e-p.offsetWidth-u.width)+"px",g=u.right-l}if(h>0){var v=u.bottom-u.top,w=a.top-(a.bottom-u.top);w-v>0?r.style.top=a.top-v+"px":v>f&&(r.style.height=f-5+"px",r.style.top=a.bottom-u.top+"px")}return g>0&&(u.right-u.left>l&&(r.style.width=l-5+"px",g-=u.right-u.left-l),r.style.left=e-g+"px"),r}function T(e){var t=e&&e.parentNode;t&&t.removeChild(e)}function ee(e){e.style.opacity="0",setTimeout(function(){T(e)},1100)}function b(e,t,n){e.options.showError?e.options.showError(t,n):I(t,String(n),e)}function C(e){e.activeArgHints&&(e.activeArgHints.clear&&e.activeArgHints.clear(),T(e.activeArgHints),e.activeArgHints=null)}function H(e,t){var n=t.doc.getValue();return e.options.fileFilter&&(n=e.options.fileFilter(n,t.name,t.doc)),n}function te(e){var t=e.worker=new Worker(e.options.workerScript);t.postMessage({type:"init",defs:e.options.defs,plugins:e.options.plugins,scripts:e.options.workerDeps});var n=0,o={};function i(r,s){s&&(r.id=++n,o[n]=s),t.postMessage(r)}t.onmessage=function(r){var s=r.data;s.type=="getFile"?S(e,s.name,function(a,l){i({type:"getFile",err:String(a),text:l,id:s.id})}):s.type=="debug"?window.console.log(s.message):s.id&&o[s.id]&&(o[s.id](s.err,s.body),delete o[s.id])},t.onerror=function(r){for(var s in o)o[s](r);o={}},this.addFile=function(r,s){i({type:"add",name:r,text:s})},this.delFile=function(r){i({type:"del",name:r})},this.request=function(r,s){i({type:"req",body:r},s)}}});
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!