1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-12-22 15:28:55 -05:00
wallabag/vendor/full-text-rss/admin/codemirror/codemirror.js

1 line
58 KiB
JavaScript
Raw Normal View History

2013-12-10 10:19:15 -05:00
var CodeMirror=function(){"use strict";function e(r,i){function un(e){if(s.onDragEvent&&s.onDragEvent(ln,I(e)))return;U(e)}function fn(e){return e>=0&&e<At.size}function cn(e){return D(At,e)}function hn(e,t){Vt=!0;var n=t-e.height;for(var r=e;r;r=r.parent)r.height+=n}function pn(e){var t={line:0,ch:0};Mn(t,{line:At.size-1,ch:cn(At.size-1).text.length},pt(e),t,t),qt=!0}function dn(e){var t=[];return At.iter(0,At.size,function(e){t.push(e.text)}),t.join(e||"\n")}function vn(e){R.scrollTop!=Bt&&(Bt=St.scrollTop=R.scrollTop,rr([]))}function mn(e){s.fixedGutter&&bt.style.left!=St.scrollLeft+"px"&&(bt.style.left=St.scrollLeft+"px"),St.scrollTop!=Bt&&(Bt=St.scrollTop,R.scrollTop!=Bt&&(R.scrollTop=Bt),rr([])),s.onScroll&&s.onScroll(ln)}function gn(e){function u(t){g&&(St.draggable=!1),jt=!1,l(),c(),Math.abs(e.clientX-t.clientX)+Math.abs(e.clientY-t.clientY)<10&&(q(t),hr(n.line,n.ch,!0),Qn())}function m(e){if(i=="single")fr(n,e);else if(i=="double"){var t=br(e);it(e,d)?fr(t.from,v):fr(d,t.to)}else i=="triple"&&(it(e,d)?fr(v,dr({line:e.line,ch:0})):fr(d,dr({line:e.line+1,ch:0})))}function y(e){var t=Zr(e,!0);if(t&&!rt(t,a)){Mt||An(),a=t,m(t),qt=!1;var n=nr();if(t.line>=n.to||t.line<n.from)f=setTimeout(hi(function(){y(e)}),150)}}function b(e){clearTimeout(f);var t=Zr(e);t&&m(t),q(e),Qn(),qt=!0,w(),l()}ar(X(e,"shiftKey"));for(var t=z(e);t!=xt;t=t.parentNode)if(t.parentNode==Et&&t!=wt)return;for(var t=z(e);t!=xt;t=t.parentNode)if(t.parentNode==yt)return s.onGutterClick&&s.onGutterClick(ln,ct(yt.childNodes,t)+Kt,e),q(e);var n=Zr(e);switch(W(e)){case 3:h&&ei(e);return;case 2:n&&hr(n.line,n.ch,!0),setTimeout(Qn,20),q(e);return}if(!n){z(e)==St&&q(e);return}Mt||An();var r=+(new Date),i="single";if(Ht&&Ht.time>r-400&&rt(Ht.pos,n))i="triple",q(e),setTimeout(Qn,20),wr(n.line);else if(Pt&&Pt.time>r-400&&rt(Pt.pos,n)){i="double",Ht={time:r,pos:n},q(e);var o=br(n);fr(o.from,o.to)}else Pt={time:r,pos:n};var a=n,f;if(s.dragDrop&&K&&!s.readOnly&&!rt(_t.from,_t.to)&&!it(n,_t.from)&&!it(_t.to,n)&&i=="single"){g&&(St.draggable=!0);var l=V(document,"mouseup",hi(u),!0),c=V(St,"drop",hi(u),!0);jt=!0,St.dragDrop&&St.dragDrop();return}q(e),i=="single"&&hr(n.line,n.ch,!0);var d=_t.from,v=_t.to,w=V(document,"mousemove",hi(function(e){clearTimeout(f),q(e),!p&&!W(e)?b(e):y(e)}),!0),l=V(document,"mouseup",hi(b),!0)}function yn(e){for(var t=z(e);t!=xt;t=t.parentNode)if(t.parentNode==yt)return q(e);q(e)}function bn(e){if(s.onDragEvent&&s.onDragEvent(ln,I(e)))return;q(e);var t=Zr(e,!0),n=e.dataTransfer.files;if(!t||s.readOnly)return;if(n&&n.length&&window.FileReader&&window.File){var r=n.length,i=Array(r),o=0,u=function(e,n){var s=new FileReader;s.onload=function(){i[n]=s.result,++o==r&&(t=dr(t),hi(function(){var e=qn(i.join(""),t,t);fr(t,e)})())},s.readAsText(e)};for(var a=0;a<r;++a)u(n[a],a)}else{if(jt&&!it(t,_t.from)&&!it(_t.to,t))return;try{var i=e.dataTransfer.getData("Text");i&&pi(function(){var e=_t.from,n=_t.to;fr(t,t),jt&&qn("",e,n),Rn(i),Qn()})}catch(e){}}}function wn(e){var t=Wn();e.dataTransfer.setData("Text",t);if(h||y||b){var n=ot("img");n.scr="data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs=",e.dataTransfer.setDragImage(n,0,0)}}function En(e,t){if(typeof e=="string"){e=u[e];if(!e)return!1}var n=Dt;try{s.readOnly&&(It=!0),t&&(Dt=null),e(ln)}catch(r){if(r!=J)throw r;return!1}finally{Dt=n,It=!1}return!0}function xn(e){function u(){o=!0}var t=f(s.keyMap),n=t.auto;clearTimeout(Sn),n&&!c(e)&&(Sn=setTimeout(function(){f(s.keyMap)==t&&(s.keyMap=n.call?n.call(null,ln):n)},50));var r=vt[X(e,"keyCode")],i=!1;if(r==null||e.altGraphKey)return!1;X(e,"altKey")&&(r="Alt-"+r),X(e,"ctrlKey")&&(r="Ctrl-"+r),X(e,"metaKey")&&(r="Cmd-"+r);var o=!1;return X(e,"shiftKey")?i=l("Shift-"+r,s.extraKeys,s.keyMap,function(e){return En(e,!0)},u)||l(r,s.extraKeys,s.keyMap,function(e){if(typeof e=="string"&&/^go[A-Z]/.test(e))return En(e)},u):i=l(r,s.extraKeys,s.keyMap,En,u),o&&(i=!1),i&&(q(e),ti(),p&&(e.oldKeyCode=e.keyCode,e.keyCode=0)),i}function Tn(e,t){var n=l("'"+t+"'",s.extraKeys,s.keyMap,function(e){return En(e,!0)});return n&&(q(e),ti()),n}function