From e3069eaaed280a86389c69094aaab23d0be76bf8 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Mon, 30 May 2011 14:44:08 +0200 Subject: [PATCH] jsdoc template: Use CodeMirror for code highlighting. --- .../jsdoc/static/resources/css/codemirror.css | 110 +++ .../jsdoc/static/resources/css/lighter.css | 115 --- .../jsdoc/static/resources/js/codemirror.js | 1 + .../jsdoc/static/resources/js/lighter.js | 826 ------------------ .../jsdoc/static/resources/js/reference.js | 166 +++- .../templates/jsdoc/templates/html.tmpl | 4 +- 6 files changed, 261 insertions(+), 961 deletions(-) create mode 100644 build/jsdoc-toolkit/templates/jsdoc/static/resources/css/codemirror.css delete mode 100644 build/jsdoc-toolkit/templates/jsdoc/static/resources/css/lighter.css create mode 100644 build/jsdoc-toolkit/templates/jsdoc/static/resources/js/codemirror.js delete mode 100644 build/jsdoc-toolkit/templates/jsdoc/static/resources/js/lighter.js diff --git a/build/jsdoc-toolkit/templates/jsdoc/static/resources/css/codemirror.css b/build/jsdoc-toolkit/templates/jsdoc/static/resources/css/codemirror.css new file mode 100644 index 00000000..d0869c77 --- /dev/null +++ b/build/jsdoc-toolkit/templates/jsdoc/static/resources/css/codemirror.css @@ -0,0 +1,110 @@ +.CodeMirror, +.CodeMirror textarea, +.CodeMirror pre { + font-family: Menlo, Consolas, "Vera Mono", monospace; + font-size: 12px; +} + +.CodeMirror { + overflow: auto; + height: 100%; +} + +.CodeMirror-gutter { + position: absolute; + left: 0; + top: 0; + min-width: 30px; + height: 100%; + background-color: #f4f4f4; + border-right: 1px solid #999; +} + +.CodeMirror-gutter-text { + color: #aaa; + text-align: right; + padding: 2px 8px 2px 8px; /* 2px required for CodeMirror-selected */ +} + +.CodeMirror-gutter-text pre { + font-size: 10px; +} + +.CodeMirror-lines { + background: #ffffff; + padding: 2px 0 2px 8px; /* 2px required for CodeMirror-selected */ +} + +.CodeMirror-lines pre.highlight { + background-color: #edf5fc; +} + +/* +.CodeMirror-lines pre:hover { + background-color: #edf5fc; +} + +.CodeMirror-lines pre.highlight:hover { + background-color: #ffffff; +} +*/ + +.CodeMirror pre { + line-height: 16px; + margin: 0; + padding: 0; + background: transparent; + font-family: inherit; +} + +.CodeMirror-cursor { + z-index: 10; + position: absolute; + visibility: hidden; + border-left: 1px solid #7c7c7c !important; + height: 16px; +} + +.CodeMirror-focused .CodeMirror-cursor { + visibility: visible; +} + +span.CodeMirror-selected { + background: #ccc !important; + color: HighlightText !important; + padding: 2px 0 2px 0; +} + +.CodeMirror-focused span.CodeMirror-selected { + background: Highlight !important; +} + +.CodeMirror-matchingbracket { + background: #e3fc8d !important; +} + +.CodeMirror-nonmatchingbracket { + color: #d62a28 !important; +} + +/* JavaScript */ + +span.js-comment { + color: #8c868f; +} +span.js-keyword { + color: #ff7800; +} +span.js-atom { + color: #3b5bb5; +} +span.js-string { + color: #409b1c; +} +span.js-variable { + color: #000000; +} +span.js-variabledef, +span.js-localvariable { + color: #3a4a64 /*#687687;*/ +} diff --git a/build/jsdoc-toolkit/templates/jsdoc/static/resources/css/lighter.css b/build/jsdoc-toolkit/templates/jsdoc/static/resources/css/lighter.css deleted file mode 100644 index 39fcdc84..00000000 --- a/build/jsdoc-toolkit/templates/jsdoc/static/resources/css/lighter.css +++ /dev/null @@ -1,115 +0,0 @@ -ol.ltLighter { - font-family: Menlo, Consolas, "Vera Mono", monospace; - font-size: 10px; - overflow: auto; - white-space: pre-wrap; - word-wrap: break-word; -} - -ol.ltLighter { - white-space: -moz-pre-wrap; -} - -ol.ltLighter { - white-space: -pre-wrap; -} - -ol.ltLighter { - white-space: -o-pre-wrap; -} - -ol.ltLighter { - color: #939393; - list-style: decimal-leading-zero; - background-color: #f4f4f4; - margin-left: 0; - padding-left: 0; -} - -ol.ltLighter li { - border-left: 1px solid #939393; - padding: 0 3px 0 10px; - background-color: #fff; - padding-left: 15px; - padding-right: 5px; - margin-left: 40px; -} - -ol.ltLighter .ltfirst { - padding-top: 5px; -} - -ol.ltLighter .ltlast { - padding-bottom: 5px; -} - -ol.ltLighter .alt { - background-color: #edf5fc; -} - -ol.ltLighter span { - color: black; - font-size: 11px; -} - -ol.ltLighter .de1 { -} - -ol.ltLighter .de2 { -} - -ol.ltLighter .kw1 { - color: #1b609a; -} - -ol.ltLighter .kw2 { - color: #9a6f1b; -} - -ol.ltLighter .kw3 { - color: #784e0c; -} - -ol.ltLighter .co1 { - color: #888888; -} - -ol.ltLighter .co2 { - color: #888888; -} - -ol.ltLighter .st0 { - color: #489a1b; -} - -ol.ltLighter .st1 { - color: #70483d; -} - -ol.ltLighter .st2 { - color: #70483d; -} - -ol.ltLighter .nu0 { - color: #70483d; -} - -ol.ltLighter .me0 { - color: #666666; -} - -ol.ltLighter .br0 { - color: #444444; -} - -ol.ltLighter .sy0 { - color: #444444; -} - -ol.ltLighter .es0 { - color: #444444; -} - -ol.ltLighter .re0 { - color: #784e0c; -} \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/codemirror.js b/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/codemirror.js new file mode 100644 index 00000000..9339a758 --- /dev/null +++ b/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/codemirror.js @@ -0,0 +1 @@ +var CodeMirror=function(){function D(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c=0&&d>=0;--c,--d)if(a.charAt(c)!=b.charAt(d))break;return d+1}function B(a){return a.replace(/[<>&]/g,function(a){return a=="&"?"&":a=="<"?"<":">"})}function A(a){return{line:a.line,ch:a.ch}}function z(a,b){return a.linea&&d.push(h.slice(a-f,Math.min(h.length,b-f)),c[e+1]),i>=a&&(g=1)):g==1&&(i>b?d.push(h.slice(0,b-f),c[e+1]):d.push(h,c[e+1])),f=i}}function g(a,b){this.styles=b||[a,null],this.stateAfter=null,this.text=a,this.marked=this.gutterMarker=this.className=null}function f(a){this.pos=this.start=0,this.string=a}function e(a,b,c){return a.startState?a.startState(b,c):!0}function d(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function a(b,c){function cG(a,b,c){this.atOccurrence=!1,c==null&&(c=typeof a=="string"&&a==a.toLowerCase()),b&&typeof b=="object"?b=bX(b):b={line:0,ch:0},this.pos={from:b,to:b};if(typeof a!="string")this.matches=function(b,c){if(b){var d=S[c.line].text.slice(0,c.ch),e=d.match(a),f=0;while(e){var g=d.indexOf(e[0]);f+=g,d=d.slice(g+1);var h=d.match(a);if(h)e=h;else break}}else var d=S[c.line].text.slice(c.ch),e=d.match(a),f=e&&c.ch+d.indexOf(e[0]);if(e)return{from:{line:c.line,ch:f},to:{line:c.line,ch:f+e[0].length},match:e}};else{c&&(a=a.toLowerCase());var d=c?function(a){return a.toLowerCase()}:function(a){return a},e=a.split("\n");e.length==1?this.matches=function(b,c){var e=d(S[c.line].text),f=a.length,g;if(b?c.ch>=f&&(g=e.lastIndexOf(a,c.ch-f))!=-1:(g=e.indexOf(a,c.ch))!=-1)return{from:{line:c.line,ch:g},to:{line:c.line,ch:g+f}}}:this.matches=function(a,b){var c=b.line,f=a?e.length-1:0,g=e[f],h=d(S[c].text),i=a?h.indexOf(g)+g.length:h.lastIndexOf(g);if(!(a?i>=b.ch||i!=g.length:i<=b.ch||i!=h.length-g.length))for(;;){if(a?!c:c==S.length-1)return;h=d(S[c+=a?-1:1].text),g=e[a?--f:++f];if(f>0&&f=S.length)continue;var c=cy(b),g=c&&S[c-1].stateAfter;g?g=d(R,g):g=e(R);for(var h=c,i=S.length;ha){T.push(h),cB(f.workDelay),_.push({from:b,to:h});return}var l=j.highlight(R,g);j.stateAfter=d(R,g);if(k&&!l&&j.text)break}_.push({from:b,to:h})}}function cz(a){var b=cy(a),c=b&&S[b-1].stateAfter;c?c=d(R,c):c=e(R);for(var f=b;fe;--d){if(d==0)return 0;var f=S[d-1];if(f.stateAfter)return d;var g=f.indentation();if(c==null||b>g)c=d,b=g}return c}function cx(a){function p(a,b,c){if(!!a.text){var d=a.styles,e=g?0:a.text.length-1,f;for(var i=g?0:d.length-2,j=g?d.length:-2;i!=j;i+=2*h){var k=d[i];if(d[i+1]!=null&&d[i+1]!=m){e+=h*k.length;continue}for(var l=g?0:k.length-1,p=g?k.length:-1;l!=p;l+=h,e+=h)if(e>=b&&e"==g)n.push(f);else{if(n.pop()!=q.charAt(0))return{pos:e,match:!1};if(!n.length)return{pos:e,match:!0}}}}}}var b=W.inverted?W.from:W.to,c=S[b.line],d=b.ch-1,e=d>=0&&cw[c.text.charAt(d)]||cw[c.text.charAt(++d)];if(!!e){var f=e.charAt(0),g=e.charAt(1)==">",h=g?1:-1,i=c.styles;for(var j=d+1,k=0,l=i.length;kl.clientWidth||e-c.top>l.clientHeight))return null;var f=w(L),g=bd+Math.floor((e-f.top)/cq());return bX({line:g,ch:cn(bW(g),d-f.left)})}function cs(){return L.offsetLeft}function cr(){return L.offsetTop}function cq(){var a=N.childNodes.length;if(a)return N.offsetHeight/a;v.innerHTML="
x
";return v.firstChild.offsetHeight||1}function cp(a){var b=co(a,!0),c=w(L);return{x:c.left+b.x,y:c.top+b.y,yBot:c.top+b.yBot}}function co(a,b){var c=cq(),d=a.line-(b?bd:0);return{x:cm(a.line,a.ch),y:d*c,yBot:(d+1)*c}}function cn(a,b){function e(a){v.innerHTML="
"+c.getHTML(null,null,!1,a)+"
";return v.firstChild.firstChild.offsetWidth}if(b<=0)return 0;var c=S[a],d=c.text,f=0,g=0,h=d.length,i,j=Math.min(h,Math.ceil(b/cl("x")));for(;;){var k=e(j);if(k<=b&&ji)return h;j=Math.floor(h*.8),k=e(j),kb-g?f:h;var l=Math.ceil((f+h)/2),m=e(l);m>b?(h=l,i=m):(f=l,g=m)}}function cm(a,b){if(b==0)return 0;v.innerHTML="
"+S[a].getHTML(null,null,!1,b)+"
";return v.firstChild.firstChild.offsetWidth}function cl(a){v.innerHTML="
x
",v.firstChild.firstChild.firstChild.nodeValue=a;return v.firstChild.firstChild.offsetWidth||10}function ck(a){if(typeof a=="number"){var b=a;a=S[a];if(!a)return null}else{var b=D(S,a);if(b==-1)return null}var c=a.gutterMarker;return{line:b,text:a.text,markerText:c&&c.text,markerClass:c&&c.style}}function cj(a,b){if(typeof a=="number"){var c=a;a=S[bW(a)]}else{var c=D(S,a);if(c==-1)return null}a.className=b,_.push({from:c,to:c+1});return a}function ci(a){typeof a=="number"&&(a=S[bW(a)]),a.gutterMarker=null,bR()}function ch(a,b,c){typeof a=="number"&&(a=S[bW(a)]),a.gutterMarker={text:b,style:c},bR();return a}function cg(a,b,c){function e(a,b,c,e){var a=S[a],f=a.addMark(b,c,e);f.line=a,d.push(f)}a=bX(a),b=bX(b);var d=[];if(a.line==b.line)e(a.line,a.ch,b.ch,c);else{e(a.line,a.ch,null,c);for(var f=a.line+1,g=b.line;f-1&&(a==null&&(a=f),b=f)}a!=null&&_.push({from:a,to:b+1})}}function cf(){var a=f.gutter||f.lineNumbers;H.style.display=a?"":"none",a?bR():N.parentNode.style.marginLeft=0}function ce(){R=a.getMode(f,f.mode);for(var b=0,c=S.length;b0&&/\w/.test(b.charAt(c-1)))--c;while(d=S.length)return{line:S.length-1,ch:S[S.length-1].text.length};var b=a.ch,c=S[a.line].text.length;return b==null||b>c?{line:a.line,ch:c}:b<0?{line:a.line,ch:0}:a}function bW(a){return Math.max(0,Math.min(a,S.length-1))}function bV(a,b,c){var d=bX({line:a,ch:b||0});(c?bT:bU)(d,d)}function bU(a,b,c,d){if(!y(W.from,a)||!y(W.to,b)){if(z(b,a)){var e=b;b=a,a=e}var f=y(W.to,b),g=y(W.from,a);y(a,b)?W.inverted=!1:f&&!g?W.inverted=!0:g&&!f&&(W.inverted=!1),c==null&&(c=W.from.line,d=W.to.line),y(a,b)?y(W.from,W.to)||_.push({from:c,to:d+1}):y(W.from,W.to)?_.push({from:a.line,to:b.line+1}):(y(a,W.from)||(a.line':"
",g,"
")}H.style.display="none",I.innerHTML=c.join("");var h=String(S.length).length,i=I.firstChild,j=x(i),k="";while(j.length+k.length0;--k)N.removeChild(j?j.previousSibling:N.lastChild);else if(i){for(var k=Math.max(0,i);k>0;--k)N.insertBefore(document.createElement("pre"),j);for(var k=Math.max(0,-i);k>0;--k)N.removeChild(j?j.previousSibling:N.lastChild)}var l=N.childNodes[h.domStart+d],m=b=h.from;for(var k=h.from;kj.from&&f.push({from:j.from,to:e.from,domStart:j.domStart}),e.to=n)break;if(j.domStart>p||j.from>r)o.push({from:r,to:j.from,domSize:j.domStart-p,domStart:p}),s+=j.from-r;r=j.to,p=j.domStart+(j.to-j.from)}if(p!=q||r!=n)s+=Math.abs(n-r),o.push({from:r,to:n,domSize:q-p,domStart:p});if(!o.length)return;N.style.display="none",s>(k.to-k.from)*.3?bP(m=Math.max(k.from-10,0),n=Math.min(k.to+7,S.length)):bQ(o),N.style.display="";var t=m!=bd||n!=be||bf!=l.clientHeight;bd=m,be=n,B.style.top=m*cq()+"px",t&&(bf=l.clientHeight,u.style.height=S.length*cq()+2*cr()+"px",bR());var v=cl(bj);L.style.width=v>l.clientWidth?v+"px":"";if(N.childNodes.length!=be-bd)throw new Error("BAD PATCH! "+JSON.stringify(o)+" size="+(be-bd)+" nodes="+N.childNodes.length);bS()}}function bN(){var a=cq(),b=l.scrollTop-cr();return{from:Math.min(S.length,Math.max(0,Math.floor(b/a))),to:Math.min(S.length,Math.ceil((b+l.clientHeight)/a))}}function bM(a,b,c,d){var e=cs(),g=cr();b+=g,d+=g,a+=e,c+=e;var h=l.clientHeight,i=l.scrollTop,j=!1,k=!0;bi+h&&(l.scrollTop=d+10-h,j=!0);var m=l.clientWidth,n=l.scrollLeft;am+n&&(l.scrollLeft=c+10-m,j=!0,c>u.clientWidth&&(k=!1)),j&&f.onScroll&&f.onScroll(bl);return k}function bL(){var a=co(W.inverted?W.from:W.to);return bM(a.x,a.y,a.x,a.yBot)}function bK(){var a=[],b=Math.max(0,W.from.line-1),c=Math.min(S.length,W.to.line+2);for(var d=b;d=a)return{line:c,ch:a-d};++c,d=e+1}}var a=!1,b=K.value,c=F(K);if(!c)return!1;var a=bh.text!=b,d=Y,e=a||c.start!=bh.start||c.end!=(d?bh.start:bh.end);if(!e&&!d)return!1;if(a){X=Y=null;if(f.readOnly){$=!0;return"changed"}}var h=g(c.start,bh.from),i=g(c.end,bh.from);if(d){h=c.start==d.anchor?i:h,i=X?W.to:c.start==d.anchor?h:i;if(!z(h,i)){Y=null,W.inverted=!1;var j=h;h=i,i=j}}h.line==i.line&&h.line==W.from.line&&h.line==W.to.line&&!X&&($=!1);if(a){var k=0,l=b.length,m=Math.min(l,bh.text.length),n,o=bh.from,p=-1;while(k-1?k-p:k,r=bh.to-1,s=bh.text.length;for(;;){n=bh.text.charAt(s),n=="\n"&&r--;if(b.charAt(l)!=n){++l,++s;break}if(s<=k||l<=k)break;--l,--s}var p=bh.text.lastIndexOf("\n",s-1),t=p==-1?s:s-p-1;bw({line:o,ch:q},{line:r,ch:t},E(b.slice(k,l)),h,i);if(o!=r||h.line!=o)$=!0}else bU(h,i);bh.text=b,bh.start=c.start,bh.end=c.end;return a?"changed":e?"moved":!1}function bI(a){function c(){cC();var d=bJ();d=="moved"&&a&&(t[a]=!0),!d&&!b?(b=!0,O.set(80,c)):(bG=!1,bH()),cD()}var b=!1;bG=!0,O.set(20,c)}function bH(){bG||O.set(2e3,function(){cC(),bJ(),V&&bH(),cD()})}function bF(){return bE(W.from,W.to)}function bE(a,b){var c=a.line,d=b.line;if(c==d)return S[c].text.slice(a.ch,b.ch);var e=[S[c].text.slice(a.ch)];for(var f=c+1;fh&&(bj=o,h=o.length,f=!1)}if(f){h=0;for(var i=0,n=S.length;ih&&(h=o.length,bj=o)}}var p=[],q=c.length-j-1;for(var i=0,o=T.length;ib.line&&p.push(r+q)}c.length&&p.push(a.line),T=p,cB(100),_.push({from:a.line,to:b.line+1,diff:q}),ba={from:a,to:b,text:c},bU(d,e,s(W.from.line),s(W.to.line)),u.style.height=S.length*cq()+2*cr()+"px"}function bz(){bx(U.undone,U.done)}function by(){bx(U.done,U.undone)}function bx(a,b){var c=a.pop();if(c){var d=[],e=c.start+c.added;for(var f=c.start;ff.undoDepth)U.done.shift()}bA(a,b,c,d,e)}function bv(){V&&f.onBlur&&f.onBlur(bl),clearInterval(Q),X=null,V=!1,l.className=l.className.replace(" CodeMirror-focused","")}function bu(){!V&&f.onFocus&&f.onFocus(bl),V=!0,bH(),l.className.search(/\bCodeMirror-focused\b/)==-1&&(l.className+=" CodeMirror-focused"),cv()}function bt(a){if(!f.onKeyEvent||!f.onKeyEvent(bl,k(a.e))){if(f.electricChars&&R.electricChars){var b=String.fromCharCode(a.e.charCode==null?a.e.keyCode:a.e.charCode);R.electricChars.indexOf(b)>-1&&setTimeout(cF(function(){cd(W.to.line,"smart")}),50)}var c=a.e.keyCode;c==13?(f.readOnly||cb(),a.stop()):!a.e.ctrlKey&&!a.e.altKey&&!a.e.metaKey&&c==9&&f.tabMode!="default"?a.stop():bI(bg)}}function bs(a){Y&&(Y=null,$=!0),a.e.keyCode==16&&(X=null)}function br(a){V||bu();var b=a.e.keyCode,c=(s?a.e.metaKey:a.e.ctrlKey)&&!a.e.altKey,d=a.e.ctrlKey||a.e.altKey||a.e.metaKey;b==16||a.e.shiftKey?X=X||(W.inverted?W.to:W.from):X=null;if(!f.onKeyEvent||!f.onKeyEvent(bl,k(a.e))){if(b==33||b==34){bY(b==34);return a.stop()}if(c&&(b==36||b==35||s&&(b==38||b==40))){bZ(b==36||b==38);return a.stop()}if(c&&b==65){b$();return a.stop()}if(!f.readOnly){if(!d&&b==13)return;if(!d&&b==9&&cc(a.e.shiftKey))return a.stop();if(c&&b==90){by();return a.stop()}if(c&&(a.e.shiftKey&&b==90||b==89)){bz();return a.stop()}}bg=(c?"c":"")+b;if(W.inverted&&t.hasOwnProperty(bg)){var e=F(K);e&&(Y={anchor:e.start},G(K,e.start,e.start))}bI(bg)}}function bq(a){var b=ct(a,!0),c=a.e.dataTransfer.files;if(!!b&&!f.readOnly)if(c&&c.length&&window.FileReader&&window.File){var d=c.length,e=Array(d),g=0;for(var h=0;h=c.to||b.line=0&&a",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},cE=0;cG.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(a){function d(a){var c={line:a,ch:0};b.pos={from:c,to:c},b.atOccurrence=!1;return!1}var b=this,c=bX(a?this.pos.from:this.pos.to);for(;;){if(this.pos=this.matches(a,c)){this.atOccurrence=!0;return this.pos.match||!0}if(a){if(!c.line)return d(0);c={line:c.line-1,ch:S[c.line-1].text.length}}else{if(c.line==S.length-1)return d(S.length);c={line:c.line+1,ch:0}}}},from:function(){if(this.atOccurrence)return A(this.pos.from)},to:function(){if(this.atOccurrence)return A(this.pos.to)}};return bl}a.defaults={value:"",mode:null,indentUnit:2,indentWithTabs:!1,tabMode:"classic",enterMode:"indent",electricChars:!0,onKeyEvent:null,lineNumbers:!1,gutter:!1,firstLineNumber:1,readOnly:!1,onChange:null,onCursorActivity:null,onGutterClick:null,onFocus:null,onBlur:null,onScroll:null,matchBrackets:!1,workTime:100,workDelay:200,undoDepth:40,tabindex:null};var b={},c={};a.defineMode=function(c,d){!a.defaults.mode&&c!="null"&&(a.defaults.mode=c),b[c]=d},a.defineMIME=function(a,b){c[a]=b},a.getMode=function(d,e){typeof e=="string"&&c.hasOwnProperty(e)&&(e=c[e]);if(typeof e=="string")var f=e,g={};else var f=e.name,g=e;var h=b[f];if(!h){window.console&&console.warn("No mode "+f+" found, falling back to plain text.");return a.getMode(d,"text/plain")}return h(d,g)},a.listModes=function(){var a=[];for(var c in b)b.propertyIsEnumerable(c)&&a.push(c);return a},a.listMIMEs=function(){var a=[];for(var b in c)c.propertyIsEnumerable(b)&&a.push(b);return a},a.fromTextArea=function(b,c){function d(){b.value=h.getValue()}c||(c={}),c.value=b.value,!c.tabindex&&b.tabindex&&(c.tabindex=b.tabindex);if(b.form){var e=m(b.form,"submit",d,!0);if(typeof b.form.submit=="function"){var f=b.form.submit;function g(){d(),b.form.submit=f,b.form.submit(),b.form.submit=g}b.form.submit=g}}b.style.display="none";var h=a(function(a){b.parentNode.insertBefore(a,b.nextSibling)},c);h.save=d,h.toTextArea=function(){d(),b.parentNode.removeChild(h.getWrapperElement()),b.style.display="",b.form&&(e(),typeof b.form.submit=="function"&&(b.form.submit=f))};return h},a.startState=e,a.copyState=d,f.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return this.pos==0},peek:function(){return this.string.charAt(this.pos)},next:function(){if(this.posb},eatSpace:function(){var a=this.pos;while(/[\s\u00a0]/.test(this.string.charAt(this.pos)))++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);if(b>-1){this.pos=b;return!0}},backUp:function(a){this.pos-=a},column:function(){return v(this.string,this.start)},indentation:function(){return v(this.string)},match:function(a,b,c){if(typeof a!="string"){var e=this.string.slice(this.pos).match(a);e&&b!==!1&&(this.pos+=e[0].length);return e}function d(a){return c?a.toLowerCase():a}if(d(this.string).indexOf(d(a),this.pos)==this.pos){b!==!1&&(this.pos+=a.length);return!0}},current:function(){return this.string.slice(this.start,this.pos)}},g.prototype={replace:function(a,b,c){var d=[],e=this.marked;h(0,a,this.styles,d),c&&d.push(c,null),h(b,this.text.length,this.styles,d),this.styles=d,this.text=this.text.slice(0,a)+c+this.text.slice(b),this.stateAfter=null;if(e){var f=c.length-(b-a),g=this.text.length;function i(a){return a<=Math.min(b,b+f)?a:a+f}for(var j=0;j=g?l=!0:(k.from=i(k.from),k.to!=null&&(k.to=i(k.to)));if(l||k.from>=k.to)e.splice(j,1),j--}}},split:function(a,b){var c=[b,null];h(a,this.text.length,this.styles,c);return new g(b+this.text.slice(a),c)},addMark:function(a,b,c){var d=this.marked,e={from:a,to:b,style:c};this.marked==null&&(this.marked=[]),this.marked.push(e),this.marked.sort(function(a,b){return a.from-b.from});return e},removeMark:function(a){var b=this.marked;if(!!b)for(var c=0;c5e3){d[e++]=this.text.slice(c.pos),d[e++]=null;break}}d.length!=e&&(d.length=e,g=!0),e&&d[e-2]!=i&&(g=!0);return g},getTokenAt:function(a,b,c){var d=this.text,e=new f(d);while(e.pos',B(a),""):e.push(B(a)))}var e=[];c&&e.push(this.className?'
':"
");var g=this.styles,h=this.text,i=this.marked;a==b&&(a=null);var j=h.length;d!=null&&(j=Math.min(d,j));if(!h&&d==null)f(" ",a!=null&&b==null?"CodeMirror-selected":null);else if(!i&&a==null)for(var k=0,l=0;lj&&(m=m.slice(0,j-l)),l+=n,f(m,g[k+1])}else{var o=0,k=0,p="",q,r=0,s=-1,t=null;function u(){i&&(s+=1,t=so)v=a;else if(b==null||b>o)w=" CodeMirror-selected",b!=null&&(v=Math.min(v,b));while(t&&t.to!=null&&t.to<=o)u();t&&(t.from>o?v=Math.min(v,t.from):(w+=" "+t.style,t.to!=null&&(v=Math.min(v,t.to))));for(;;){var x=o+p.length,y=q;w&&(y=q?q+w:w),f(x>v?p.slice(0,v-o):p,y);if(x>=v){p=p.slice(v-o),o=v;break}o=x,p=g[k++],q=g[k++]}}a!=null&&b==null&&f(" ","CodeMirror-selected")}c&&e.push("
");return e.join("")}},i.prototype={addChange:function(a,b,c){this.undone.length=0;var d=+(new Date),e=this.done[this.done.length-1];if(d-this.time>400||!e||e.start>a+b||e.start+e.added=0;--g)e.old.unshift(c[g]);e.added+=e.start-a,e.start=a}else e.start-1&&(q="\r\n")})();var r=8,s=/Mac/.test(navigator.platform),t={};for(var u=35;u<=40;++u)t[u]=t["c"+u]=!0;if("\n\nb".split(/\n/).length!=3)var E=function(a){var b=0,c,d=[];while((c=a.indexOf("\n",b))>-1)d.push(a.slice(b,a.charAt(c-1)=="\r"?c-1:c)),b=c+1;d.push(a.slice(b));return d};else var E=function(a){return a.split(/\r?\n/)};if(window.getSelection)var F=function(a){try{return{start:a.selectionStart,end:a.selectionEnd}}catch(b){return null}},G=function(a,b,c){try{a.setSelectionRange(b,c)}catch(d){}};else var F=function(a){try{var b=document.selection.createRange()}catch(c){return null}if(!b||b.parentElement()!=a)return null;var d=a.value,e=d.length,f=a.createTextRange();f.moveToBookmark(b.getBookmark());var g=a.createTextRange();g.collapse(!1);if(f.compareEndPoints("StartToEnd",g)>-1)return{start:e,end:e};var h=-f.moveStart("character",-e);for(var i=d.indexOf("\r");i>-1&&i-1)return{start:h,end:e};var j=-f.moveEnd("character",-e);for(var i=d.indexOf("\r");i>-1&&i-1&&h-1&&h=0;a--)s.cc.push(arguments[a])}function r(a,b,c,e,f){var g=a.cc;s.state=a,s.stream=f,s.marked=null,s.cc=g,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);for(;;){var h=g.length?g.pop():d?D:C;if(h(c,e)){while(g.length&&g[g.length-1].lex)g.pop()();if(s.marked)return s.marked;if(c=="variable"&&q(a,e))return"js-localvariable";return b}}}function q(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0}function p(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,d!=null&&(this.align=d)}function n(a,b){var c=!1,d;while(d=a.next()){if(d=="/"&&c){b.tokenize=l;break}c=d=="*"}return k("comment","js-comment")}function m(a){return function(b,c){h(b,a)||(c.tokenize=l);return k("string","js-string")}}function l(a,b){var c=a.next();if(c=='"'||c=="'")return g(a,b,m(c));if(/[\[\]{}\(\),;\:\.]/.test(c))return k(c);if(c=="0"&&a.eat(/x/i)){a.eatWhile(/[\da-f]/i);return k("number","js-atom")}if(/\d/.test(c)){a.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);return k("number","js-atom")}if(c=="/"){if(a.eat("*"))return g(a,b,n);if(a.eat("/")){a.skipToEnd();return k("comment","js-comment")}if(b.reAllowed){h(a,"/"),a.eatWhile(/[gimy]/);return k("regexp","js-string")}a.eatWhile(f);return k("operator",null,a.current())}if(f.test(c)){a.eatWhile(f);return k("operator",null,a.current())}a.eatWhile(/[\w\$_]/);var d=a.current(),i=e.propertyIsEnumerable(d)&&e[d];return i?k(i.type,i.style,d):k("variable","js-variable",d)}function k(a,b,c){i=a,j=c;return b}function h(a,b){var c=!1,d;while((d=a.next())!=null){if(d==b&&!c)return!1;c=!c&&d=="\\"}return c}function g(a,b,c){b.tokenize=c;return c(a,b)}var c=a.indentUnit,d=b.json,e=function(){function a(a){return{type:a,style:"js-keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),e=a("operator"),f={type:"atom",style:"js-atom"};return{"if":b,"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":d,"delete":d,"throw":d,"var":a("var"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":e,"typeof":e,"instanceof":e,"true":f,"false":f,"null":f,"undefined":f,NaN:f,Infinity:f}}(),f=/[+\-*&%=<>!?|]/,i,j,o={atom:!0,number:!0,variable:!0,string:!0,regexp:!0},s={state:null,column:null,marked:null,cc:null},w={name:"this",next:{name:"arguments"}};A.lex=!0;return{startState:function(a){return{tokenize:l,reAllowed:!0,cc:[],lexical:new p((a||0)-c,0,"block",!1),localVars:null,context:null,indented:0}},token:function(a,b){a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation());if(a.eatSpace())return null;var c=b.tokenize(a,b);if(i=="comment")return c;b.reAllowed=i=="operator"||i=="keyword c"||i.match(/^[\[{}\(,;:]$/);return r(b,c,i,j,a)},indent:function(a,b){if(a.tokenize!=l)return 0;var d=b&&b.charAt(0),e=a.lexical,f=e.type,g=d==f;return f=="vardef"?e.indented+4:f=="form"&&d=="{"?e.indented:f=="stat"||f=="form"?e.indented+c:e.info=="switch"&&!g?e.indented+(/^(?:case|default)\b/.test(b)?c:2*c):e.align?e.column+(g?0:1):e.indented+(g?0:c)},electricChars:":{}"}}),CodeMirror.defineMIME("text/javascript","javascript"),CodeMirror.defineMIME("application/json",{name:"javascript",json:!0}) \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/lighter.js b/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/lighter.js deleted file mode 100644 index 53a9deaa..00000000 --- a/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/lighter.js +++ /dev/null @@ -1,826 +0,0 @@ -/** - * Script: - * Fuel.js - Language definition engine for Lighter.js - * - * License: - * MIT-style license. - * - * Author: - * José Prado - * - * Copyright: - * Copyright (©) 2009 [Jose Prado](http://pradador.com/). - * - * Changelog: - * 2009/03/21 (1.0.0) - * - Initial Release - * - */ -Fuel = Base.extend(Callback, { - - options: { - matchType: 'standard', - strict: false - }, - language: '', - defaultFlame: 'standard', - - patterns: new Hash(), - keywords: new Hash(), - rules: new Hash(), - delimiters: new Hash({ - start: null, - end: null - }), - - /************************ - * Common Regex Rules - ***********************/ - common: { - slashComments: /(?:^|[^\\])\/\/.*$/gm, // Matches a C style single-line comment. - poundComments: /#.*$/gm, // Matches a Perl style single-line comment. - multiComments: /\/\*[\s\S]*?\*\//gm, // Matches a C style multi-line comment. - aposStrings: /'[^'\\]*(?:\\.[^'\\]*)*'/gm, // Matches a string enclosed by single quotes. - quotedStrings: /"[^"\\]*(?:\\.[^"\\]*)*"/gm, // Matches a string enclosed by double quotes. - strings: /'[^'\\]*(?:\\.[^'\\]*)*'|"[^"\\]*(?:\\.[^"\\]*)*"/gm, // Matches both. - properties: /\.([\w]+)\s*/gi, // Matches a property: .property style. - methodCalls: /\.([\w]+)\s*\(/gm, // Matches a method call: .methodName() style. - functionCalls: /\b([\w]+)\s*\(/gm, // Matches a function call: functionName() style. - brackets: /\{|\}|\(|\)|\[|\]/g, // Matches any of the common brackets. - numbers: /\b((?:(\d+)?\.)?[0-9]+|0x[0-9A-F]+)\b/gi // Matches integers, decimals, hexadecimals. - }, - - /************************ - * Fuel Constructor - ***********************/ - initialize: function(lighter, flame, options, wicks) { - this.setOptions(options); - this.wicks = wicks || []; - // Set Lighter/Fuel/Flame relationship. - this.lighter = lighter; - this.flame = flame; - - // Set builder object for matchType. - this.builder = new Hash({ - 'standard': this.findMatches, - 'lazy': this.findMatchesLazy - }); - - // Add delimiter rules if not in strict mode - if (!options.strict) { - if (this.delimiters.start) this.addFuel('delimBeg', this.delimiters.start, 'de1'); - if (this.delimiters.end) this.addFuel('delimEnd', this.delimiters.end, 'de2'); - } - - // Set Keyword Rules from this.keywords object. - this.keywords.each(function(keywordSet, ruleName) { - if (keywordSet.csv != '') { - this.addFuel(ruleName, this.csvToRegExp(keywordSet.csv, "g"), keywordSet.alias); - } - }, this); - - // Set Rules from this.patterns object. - this.patterns.each(function(regex, ruleName) { - this.addFuel(ruleName, regex.pattern, regex.alias); - }, this); - - /** Process source code based on match type. */ - var codeBeg = 0, - codeEnd = lighter.code.length, - codeSeg = '', - delim = this.delimiters, - matches = [], - match = null, - endMatch = null; - - if (!options.strict) { - // Find matches through the complete source code. - matches.append(this.builder[options.matchType].bind(this, lighter.code)()); - } else if (delim.start && delim.end) { - // Find areas between language delimiters and find matches there. - while ((match = delim.start.exec(lighter.code)) != null ) { - delim.end.lastIndex = delim.start.lastIndex; - if ((endMatch = delim.end.exec(lighter.code)) != null ) { - matches.push(new Wick(match[0], 'de1', match.index)); - codeBeg = delim.start.lastIndex; - codeEnd = endMatch.index-1; - codeSeg = lighter.code.substring(codeBeg, codeEnd); - matches.append(this.builder[options.matchType].bind(this, codeSeg, codeBeg)()); - matches.push(new Wick(endMatch[0], 'de2', endMatch.index)); - } - } - } - this.wicks = matches; - }, - - /************************ - * Regex Helper methods. - ***********************/ - addFuel: function(fuelName, RegEx, className) { - this.rules[fuelName] = RegEx; - this.flame.addAlias(fuelName, className); - }, - csvToRegExp: function(csv, mod) {return new RegExp('\\b(' + csv.replace(/,\s*/g, '|') + ')\\b', mod);}, - delimitedRegex: function(beg, esc, end, mod, suffix) { - beg = beg.escapeRegExp(); - if (esc) esc = esc.escapeRegExp(); - end = (end) ? end.escapeRegExp() : beg; - pat = (esc) ? beg+"[^"+end+esc+'\\n]*(?:'+esc+'.[^'+end+esc+'\\n]*)*'+end : beg+"[^"+end+'\\n]*'+end; - return new RegExp(pat+(suffix || ''), mod || ''); - }, - strictRegex: function() { - var regex = '('; - for (var i = 0; i < arguments.length; i++) { - regex += arguments[i].escapeRegExp(); - regex += (i < arguments.length - 1) ? '|' : ''; - } - regex += ')'; - return new RegExp(regex, "gim"); - }, - - /************************ - * Match finding Methods - ***********************/ - findMatches: function(code, offset) { - var wicks = [], - startIndex = 0, - matchIndex = code.length - insertIndex = 0, - match = null, - type = null, - newWick = null, - rule = null, - rules = {}, - currentMatch = null, - futureMatch = null; - - offset = (offset) ? offset : 0; - this.rules.each(function(regex, rule) { - rules[rule] = {pattern: regex, enabled: true, lastIndex: 0}; - }, this); - - while(startIndex < code.length) { - matchIndex = code.length; - match = null; - for (rule in rules) { - rules[rule].pattern.lastIndex = startIndex; - currentMatch = rules[rule].pattern.exec(code); - if (currentMatch === null) { - delete rules[rule]; - } else { - if (currentMatch.index < matchIndex) { - match = currentMatch; - type = rule; - matchIndex = currentMatch.index; - } else if (currentMatch.index == matchIndex && match[0].length < currentMatch[0].length) { - match = currentMatch; - type = rule; - matchIndex = currentMatch.index; - } - rules[rule].nextIndex = rules[rule].pattern.lastIndex - currentMatch[0].length; - } - } - if (match != null) { - index = (match[1] && match[0].contains(match[1])) ? match.index + match[0].indexOf(match[1]) : match.index; - newWick = new Wick(match[1] || match[0], type, index+offset); - wicks.push(newWick); - - futureMatch = rules[type].pattern.exec(code); - if (!futureMatch) { - rules[type].nextIndex = code.length; - } else { - rules[type].nextIndex = rules[type].pattern.lastIndex - futureMatch[0].length; - } - - var min = code.length; - for (rule in rules) { - if (rules[rule].nextIndex < min) { - min = rules[rule].nextIndex; - } - } - startIndex = Math.max(min, newWick.end - offset); - } else { - break; - } - } - return wicks; - }, - findMatchesLazy: function(code, offset) { - var wicks = this.wicks, - match = null - index = 0; - - offset = (offset) ? offset : 0; - - this.rules.each(function(regex, rule) { - while ((match = regex.exec(code)) != null) { - index = (match[1] && match[0].contains(match[1])) ? match.index + match[0].indexOf(match[1]) : match.index; - wicks.push(new Wick(match[1] || match[0], rule, index + offset)); - } - }, this); - return this.purgeWicks(wicks); - }, - purgeWicks: function(wicks) { - wicks = wicks.sort(this.compareWicks); - for (var i = 0, j = 0; i < wicks.length; i++) { - if (wicks[i] == null) continue; - for (j = i+1; j < wicks.length && wicks[i] != null; j++) { - if (wicks[j] == null) {continue;} - else if (wicks[j].isBeyond(wicks[i])) {break;} - else if (wicks[j].overlaps(wicks[i])) {wicks[i] = null;} - else if (wicks[i].contains(wicks[j])) {wicks[j] = null;} - } - } - return wicks.compact(); - }, - compareWicks: function(wick1, wick2) {return wick1.index - wick2.index;} -}); - -Fuel.standard = Fuel.extend({initialize: function(lighter, flame, options, wicks) {this.base(lighter, flame, options, wicks);}}); - -var Wick = Base.extend({ - - initialize: function(match, type, index) { - this.text = match; - this.type = type; - this.index = index; - this.length = this.text.length; - this.end = this.index + this.length; - }, - contains: function(wick) {return (wick.index >= this.index && wick.index < this.end);}, - isBeyond: function(wick) {return (this.index >= wick.end);}, - overlaps: function(wick) {return (this.index == wick.index && this.length > wick.length);}, - toString: function() {return this.index+' - '+this.text+' - '+this.end;} -}); - - -/** - * Script: - * Flame.js - Theme Engine for Lighter.js - * - * License: - * MIT-style license. - * - * Author: - * José Prado - * - * Copyright: - * Copyright (©) 2009 [Jose Prado](http://pradador.com/). - * - * Changelog: - * 2009/03/21 (1.0.0) - * - Initial Release - * - */ -Flame = Base.extend(Callback, { - - shortName: 'lt', - aliases: new Hash(), - containers: new Hash(), - common: new Hash(), - layout: new Hash(), - styles: new Hash(), - - - defaultStyles: new Hash({ - de1: new Hash({}), // Beginning delimiter - de2: new Hash({}), // End delimiter - kw1: new Hash({'color': '#1b609a'}), // Keywords 1 - kw2: new Hash({'color': '#9a6f1b'}), // Keywords 2 - kw3: new Hash({'color': '#784e0c'}), // Keywords 3 - co1: new Hash({'color': '#888888'}), // Comments 1 - co2: new Hash({'color': '#888888'}), // Comments 2 - st0: new Hash({'color': '#489a1b'}), // Strings 1 - st1: new Hash({'color': '#70483d'}), // Strings 2 - st2: new Hash({'color': '#70483d'}), // Strings 3 - nu0: new Hash({'color': '#70483d'}), // Numbers - me0: new Hash({'color': '#666666'}), // Methods and Functions - br0: new Hash({'color': '#444444'}), // Brackets - sy0: new Hash({'color': '#444444'}), // Symbols - es0: new Hash({'color': '#444444'}), // Escape characters - re0: new Hash({'color': '#784e0c'}) // Regular Expressions - }), - defaultCommon: new Hash({ - 'font-family': 'Monaco, Courier, Monospace', - 'font-size': '10px', - 'overflow': 'auto', - 'white-space': 'pre-wrap', - 'word-wrap': 'break-word' - }), - layout: new Hash({ - 'numColor': new Hash({'background-color': '#f2f2f2'}), - 'lineColor': new Hash({'background-color': '#fff'}), - 'numStyles': new Hash({ - 'color': '#939393', - 'font-size': '10px', - 'list-style': 'decimal-leading-zero' - }), - 'lineStyles': new Hash({ - 'border-top': '1px solid #fff', - 'border-bottom': '1px solid #fff', - 'border-left': '1px solid #939393', - 'padding': '0 3px 0 10px' - }), - 'alt': new Hash({ - 'border-top': '1px solid #eee', - 'border-bottom': '1px solid #eee', - 'background-color': '#F4F8FC' - }), - 'top': new Hash({'padding-top': '5px'}), - 'right': new Hash({'padding-right': '5px'}), - 'bottom': new Hash({'padding-bottom': '5px'}), - 'left': new Hash({'padding-left': '15px'}), - 'codeStyles': new Hash({ - 'color': 'black', - 'font-size': '10px' - }) - }), - fixes: new Hash({ - 'div': new Hash({ - 'div': new Hash({ - 'clear': 'left', - 'overflow': 'auto' - }), - 'num': new Hash({ - 'display': 'block', - 'float': 'left', - 'text-align': 'center', - 'width': '30px' - }), - 'line': new Hash({ - 'display': 'block', - 'margin-left': '30px' - }) - }), - 'table': new Hash({ - 'num': new Hash({ - 'text-align': 'center', - 'width': '30px' - }) - }), - 'ol': new Hash({ - 'ol': new Hash({ - 'margin-left': '0', - 'padding-left': '0' - }), - 'li': new Hash({ - 'margin-left': '40px' - }) - }) - }), - - initialize: function(lighter, fuel) { - - // Setup Lighter/Fuel/Flame trio. - this.lighter = lighter; - this.fuel = fuel; - - this.common.merge(this.defaultCommon); - this.styles.merge(this.defaultStyles); - - // Map general styles to their aliases. - this.defaultStyles.each(function(style, key) { - this.addAlias(key); - }, this); - - // Insert stylesheet if in jsStyles mode - if (this.lighter.options.jsStyles && !$('style#lighter_' + this.lighter.options.mode)) this.injectTag(); - }, - addAlias: function(key, alias) {this.aliases[key] = alias || key;}, - injectTag: function() { - var type = this.lighter.options.mode, - pfx = type+'.'+this.shortName+this.lighter.name, - pfx2 = pfx+' .'+this.shortName, - - numCSS = this.layout['numStyles'].merge(this.layout.numColor), - lineCSS = this.layout['lineStyles'].merge(this.layout.lineColor), - padCSS = this.layout.left.merge(this.layout.right); - this.styleTag = new HtmlElement("style").setProperty('type','text/css').setProperty('id', 'lighter_' + this.lighter.options.mode).insertInside(DomElement.get('head')); - - // General white-space/font styles. - this.addCSS(pfx, this.common); - this.addCSS(pfx, new Hash({'white-space': '-moz-pre-wrap'})); - this.addCSS(pfx, new Hash({'white-space': '-pre-wrap'})); - this.addCSS(pfx, new Hash({'white-space': '-o-pre-wrap'})); - - // Case specific styles for a common general style. - switch (type) { - case "pre": - padCSS = padCSS.merge(this.layout.top).merge(this.layout.bottom); - this.addCSS(pfx, this.layout.lineColor.merge(padCSS)); - this.addCSS(pfx+' span', this.layout['codeStyles']); - break; - case "ol": - this.addCSS(pfx, numCSS.merge(this.fixes['ol']['ol'])); - this.addCSS(pfx+' li', lineCSS.merge(padCSS).merge(this.fixes['ol']['li'])); - this.addCSS(pfx2+'first', this.layout['top']); - this.addCSS(pfx2+'last', this.layout['bottom']); - this.addCSS(pfx+' .alt', this.layout['alt']); - this.addCSS(pfx+' span', this.layout['codeStyles']); - break; - case "div": - numCSS = numCSS.merge(this.fixes.div.num), - lineCSS = lineCSS.merge(this.fixes.div.line); - this.addCSS(pfx2+'num', numCSS); - this.addCSS(pfx2+'line', lineCSS.merge(padCSS)); - this.addCSS(pfx+' div', this.fixes['div']['div'].merge(this.layout.numColor)); - this.addCSS(pfx2+'first', this.layout['top']); - this.addCSS(pfx2+'last', this.layout['bottom']); - this.addCSS(pfx+' .alt', this.layout['alt']); - this.addCSS(pfx+' span', this.layout['codeStyles']); - break; - case "table": - numCSS = numCSS.merge(this.fixes['table']['num']); - this.addCSS(pfx2+'num', numCSS); - this.addCSS(pfx2+'line', lineCSS.merge(padCSS)); - this.addCSS(pfx2+'first', this.layout['top']); - this.addCSS(pfx2+'last', this.layout['bottom']); - this.addCSS(pfx+' .alt', this.layout['alt']); - this.addCSS(pfx+' span', this.layout['codeStyles']); - break; - default: - } - - this.styles.each(function(stylesHash, styleName) { - this.addCSS(pfx+' .'+styleName, stylesHash); - }, this); - }, - /** Code from horseweapon @ http://forum.mootools.net/viewtopic.php?id=6635 */ - addCSS: function(styleName, stylesHash) { - //Create the CSS rule - var newStyle = "\n" + styleName + " {\n"; - if (stylesHash) { - stylesHash.each(function(value, attribute) { - newStyle += "\t" + attribute + ": " + value + ";\n"; - }); - } - newStyle += "}\n"; - // Insert into Flame's styleTag. - if (browserTrident()) { - this.styleTag.$.styleSheet.cssText += newStyle; - } else { - this.styleTag.appendText(newStyle); - } - } - -}); - -Flame.standard = Flame.extend({initialize: function(lighter, fuel) {this.base(lighter, fuel);}}); - - -/** - * Script: - * Flame.js - Syntax Highlighter written in MooTools. - * - * License: - * MIT-style license. - * - * Author: - * José Prado - * - * Copyright: - * Copyright (©) 2009 [Jose Prado](http://pradador.com/). - * - * Changelog: - * 2009/03/21 (1.0.0) - * - Initial Release - * - */ - -var $time = Date.now || function(){ - return +new Date; -}; - -function browserTrident(){ - return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? 5 : 4); -} - -Lighter = Base.extend(Callback, { - name: 'Lighter', - options: { - altLines: '', // Pseudo-selector enabled. - container: null, - editable: false, - flame: 'standard', - fuel: 'standard', - id: null, - indent: -1, - jsStyles: true, - matchType: "standard", - mode: "pre", - path: "./", - strict: false - }, - - /*************************** - * Lighter Initialization - **************************/ - initialize: function(codeblock, options) { - this.setOptions(options); - options = this.options; - this.id = options.id || this.name + '_' + $time(); - this.codeblock = $(codeblock) - this.code = codeblock.get('html').chop().replace(/</gim, '<').replace(/>/gim, '>').replace(/&/gim, '&'); - if(this.options.container) - this.container = $(this.options.container); - // Indent code if user option is set. - if (options.indent > -1) this.code = this.code.tabToSpaces(options.indent); - - // Set builder options. - this.builder = new Hash({ - 'pre': this.createLighter.bind(this), - 'ol': this.createLighterWithLines.bind(this, ['ol'], ['li']), - 'div': this.createLighterWithLines.bind(this, ['div'], ['div', 'span'], true, 'span'), - 'table': this.createLighterWithLines.bind(this, ['table', 'tbody'], ['tr', 'td'], true, 'td') - }); - - // Extract fuel/flame names. Precedence: className > options > standard. - var ff = this.codeblock.get('class').split(':'); - if (!ff[0]) ff[0] = this.options.fuel; - if (!ff[1]) ff[1] = this.options.flame; - - // Load flame to start chain of loads. - this.loadFlameSrc(ff); - }, - loadFlameSrc: function(ff) { - if (!$check(Flame[ff[1]])) { - var flameScript = Asset.script(this.options.path+'Flames/Flame.'+ff[1]+'.js', { - onLoad: function() { - this.loadFlame(ff); - }.bind(this), - onError: function() { - ff[1] = 'standard'; - this.loadFlame(ff) - }.bind(this) - }); - } else { - this.loadFlame(ff); - } - }, - loadFlame: function(ff) { - this.flame = new Flame[ff[1]](this); - this.loadFuelSrc(ff); - }, - loadFuelSrc: function(ff) { - if (!$check(Fuel[ff[0]])) { - var fuelScript = Asset.script(this.options.path+'Fuels/Fuel.'+ff[0]+'.js', { - onLoad: function() { - this.loadFuel(ff); - }.bind(this), - onError: function() { - ff[0] = 'standard'; - this.loadFuel(ff); - }.bind(this) - }); - } else { - this.loadFuel(ff); - } - }, - loadFuel: function(ff) { - this.fuel = new Fuel[ff[0]](this, this.flame, { - matchType: this.options.matchType, - strict: this.options.strict - }); - this.light(); - }, - light: function() { - // Build highlighted code object. - this.element = this.toElement(); - // Insert lighter in the right spot. - if (this.container) { - this.container.removeChildren(); - this.element.insertInside(this.container); - } else { - this.codeblock.setStyle('display', 'none'); - this.codeblock.injectAfter(this.element); - } - }, - - /*************************** - * Lighter creation methods - **************************/ - createLighter: function() { - var lighter = new HtmlElement('pre', {'class': this.flame.shortName + this.name}), - pointer = 0; - - // If no matches were found, insert code plain text. - if (this.fuel.wicks[0] == undefined) { - lighter.appendText(this.code); - } else { - this.fuel.wicks.each(function(match) { - lighter.appendText(this.code.substring(pointer, match.index)); - this.insertAndKeepEl(lighter, match.text, match.type); - pointer = match.index + match.text.length; - }, this); - // Add last unmatched code segment if it exists. - if (pointer < this.code.length) { - lighter.appendText(this.code.substring(pointer, this.code.length)); - } - } - - //lighter.set('text', lighter.get('html')); - return lighter; - }, - createLighterWithLines: function(parent, child, addLines, lineType) { - var lighter = new HtmlElement(parent[0], {'class': this.flame.shortName + this.name, 'id': this.id}), - newLine = new HtmlElement(child[0]), - lineNum = 1, - pointer = 0, - text = null; - if (parent[0] == "table") lighter.set("cellpadding", 0).set("cellspacing", 0).set("border", 0); - if (parent[1]) lighter = new HtmlElement(parent[1]).insertInside(lighter); - if (child[1]) newLine = new HtmlElement(child[1]).insertInside(newLine); - newLine.addClass(this.flame.shortName + 'line'); - if (addLines) lineNum = this.insertLineNum(newLine, lineNum, lineType); - this.fuel.wicks.each(function(match) { - // Create and insert un-matched source code bits. - if (pointer != match.index) { - text = this.code.substring(pointer, match.index).split('\n'); - for (var i = 0; i < text.length; i++) { - if (i < text.length - 1) { - if (text[i] == '') text[i] = ' '; - newLine = this.insertAndMakeEl(newLine, lighter, text[i], child); - if (addLines) lineNum = this.insertLineNum(newLine, lineNum, lineType); - } else { - this.insertAndKeepEl(newLine, text[i]); - } - } - } - - // Create and insert matched symbol. - text = match.text.split('\n'); - for (i = 0; i < text.length; i++) { - if (i < text.length - 1) { - newLine = this.insertAndMakeEl(newLine, lighter, text[i], child, match.type); - - if (addLines) lineNum = this.insertLineNum(newLine, lineNum, lineType); - } else { - this.insertAndKeepEl(newLine, text[i], match.type); - } - } - - pointer = match.end; - }, this); - - // Add last unmatched code segment if it exists. - if (pointer <= this.code.length) { - text = this.code.substring(pointer, this.code.length).split('\n'); - for (var i = 0; i < text.length; i++) { - newLine = this.insertAndMakeEl(newLine, lighter, text[i], child); - if (addLines) lineNum = this.insertLineNum(newLine, lineNum, lineType); - } - } - - // Add alternate line styles based on pseudo-selector. - if (this.options.altLines !== '') { - if (this.options.altLines == 'hover') { - lighter.getElements('.'+this.flame.shortName+'line').addEvents({ - 'mouseover': function() {this.toggleClass('alt');}, - 'mouseout': function() {this.toggleClass('alt');} - }); - } else { - if (child[1]) { - lighter.getChildren(':'+this.options.altLines).getElement('.'+this.flame.shortName+'line').addClass('alt'); - } else { - lighter.getChildren(':'+this.options.altLines).addClass('alt'); - } - } - } - // Add first/last line classes based on mode. - if (child[1]) { - lighter.getFirst().getChildren().addClass(this.flame.shortName+'first'); - lighter.getLast().getChildren().addClass(this.flame.shortName+'last'); - } else { - lighter.getFirst().addClass(this.flame.shortName+'first'); - lighter.getLast().addClass(this.flame.shortName+'last'); - } - - if (parent[1]) lighter = lighter.getParent(); - return lighter; - }, - /** Helper function to insert new code segment into existing line. */ - insertAndKeepEl: function(el, text, alias) { - if (text.length > 0) { - var span = new HtmlElement('span'); - span.set('text', text); - if (alias) {span.addClass(this.flame.aliases[alias]);} - span.insertInside(el); - } - }, - /** Helper function to insert new code segment into existing line and create new line. */ - insertAndMakeEl: function(el, group, text, child, alias) { - this.insertAndKeepEl(el, text, alias); - if (child[1]) el = el.getParent(); - el.insertInside(group); - - var newLine = new HtmlElement(child[0]); - if (child[1]) newLine = new HtmlElement(child[1]).insertInside(newLine); - newLine.addClass(this.flame.shortName+'line'); - return newLine; - }, - /** Helper funciton to insert line number into line. */ - insertLineNum: function(el, lineNum, lineType) { - var newNum = new HtmlElement(lineType, { - 'text': lineNum++, - 'class': this.flame.shortName+ 'num' - }); - newNum.insertTop(el.getParent()); - return lineNum; - }, - - /****************** - * Element Methods - ******************/ - toElement: function() { - if (!this.element) { - this.element = this.builder[this.options.mode](); - if (this.options.editable) {this.element.set('contenteditable', 'true');} - } - - return this.element; - }, - replaces: function(element){ - element = $(element, true); - element.parentNode.replaceChild(this.toElement(), element); - - return this; - } - -}); -/** Element Native extensions */ -HtmlElement.inject({ - light: function(options) { - return new Lighter(this, options); - } -}); - -/** String Native extensions */ -String.inject({ - chop: function() {return this.replace(/(^\s*\n|\n\s*$)/gi, '');}, - tabToSpaces: function(spaces) { - for (var i = 0, indent = ''; i < spaces; i++) {indent += ' ';} - return this.replace(/\t/g, indent); - } -}); - - -/** - * Script: - * Fuel.js.js - JavaScript language file for Lighter.js - * - * License: - * MIT-style license. - * - * Author: - * José Prado - * - * Copyright: - * Copyright (©) 2009 [Jose Prado](http://pradador.com/). - * - * Changelog: - * 2009/03/21 (1.0.0) - * - Initial Release - * - */ -Fuel.js = Fuel.extend({ - language: 'js', - - initialize: function(lighter, flame, options) { - - // Keywords Rule Set - this.keywords = new Hash({ - commonKeywords: { - csv: "as, break, case, catch, continue, delete, do, else, eval, finally, for, if, in, is, instanceof, return, switch, this, throw, try, typeof, void, while, write, with", - alias: 'kw1' - }, - langKeywords: { - csv: "class, const, default, debugger, export, extends, false, function, import, namespace, new, null, package, private, protected, public, super, true, use, var", - alias: 'kw2' - }, - windowKeywords: { - csv: "alert, back, blur, close, confirm, focus, forward, home, navigate, onblur, onerror, onfocus, onload, onmove, onresize, onunload, open, print, prompt, scroll, status, stop", - alias: 'kw3' - } - }); - - // RegEx Rule Set - this.patterns = new Hash({ - 'slashComments': {pattern: this.common.slashComments, alias: 'co1'}, - 'multiComments': {pattern: this.common.multiComments, alias: 'co2'}, - 'strings': {pattern: this.common.strings, alias: 'st0'}, - 'methodCalls': {pattern: this.common.properties, alias: 'me0'}, - 'brackets': {pattern: this.common.brackets, alias: 'br0'}, - 'numbers': {pattern: /\b((([0-9]+)?\.)?[0-9_]+([e][-+]?[0-9]+)?|0x[A-F0-9]+)\b/gi, alias: 'nu0'}, - 'regex': {pattern: this.delimitedRegex("/", "\\", "/", "g", "[gimy]*"), alias: 're0'}, - 'symbols': {pattern: /\+|-|\*|\/|%|!|@|&|\||\^|\<|\>|=|,|\.|;|\?|:/g, alias: 'sy0'} - }); - - // Delimiters - this.delimiters = new Hash({ - start: this.strictRegex('') - }); - - this.base(lighter, flame, options); - } -}); \ No newline at end of file diff --git a/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/reference.js b/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/reference.js index 72c7e4df..941bfd82 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/reference.js +++ b/build/jsdoc-toolkit/templates/jsdoc/static/resources/js/reference.js @@ -1,23 +1,150 @@ -// This is identical with server sided code -var lighterSettings = { - altLines: 'hover', - indent: 4, - mode: 'ol', - fuel: 'js', - jsStyles: false -}; +function createCodeMirror(place, options, source) { + return new CodeMirror(place, Hash.create({}, { + lineNumbers: true, + matchBrackets: true, + indentUnit: 4, + tabMode: 'shift', + value: source.getText().replace(/\t/gi, ' ').match( + // Remove first & last empty line + /^\s*?[\n\r]?([\u0000-\uffff]*?)[\n\r]?\s*?$/)[1] + }, options)); +} + +Code = HtmlElement.extend({ + _class: 'code', + + initialize: function() { + // Only format this element if it is visible, otherwise wait until + // it is made visible and then call format() manually. + if (this.getBounds().height != 0) { + this.format(); + } + }, + + format: function() { + var that = this; + var start = this.getProperty('start'); + var highlight = this.getProperty('highlight'); + var editor = createCodeMirror(function(el) { + that.replaceWith(el); + }, { + lineNumbers: !this.hasParent('.resource-text'), + firstLineNumber: (start || 1).toInt(), + readOnly: true + }, this); + if (highlight) { + var highlights = highlight.split(','); + for (var i = 0, l = highlights.length; i < l; i++) { + var highlight = highlights[i].split('-'); + var hlStart = highlight[0].toInt() - 1; + var hlEnd = highlight.length == 2 + ? highlight[1].toInt() - 1 : hlStart; + if (start) { + hlStart -= start - 1; + hlEnd -= start - 1; + } + for (var j = hlStart; j <= hlEnd; j++) { + editor.setLineClass(j, 'highlight'); + } + } + } + return editor; + } +}); + + +PaperScript = HtmlElement.extend({ + _class: 'paperscript', + + initialize: function() { + var script = $('script', this); + if (script) { + var canvas = $('canvas', this); + var button = $('.button', this); + if (!button) + return; + var source = this.injectBottom('div', { + className: 'source hidden', + }); + var width, height; + var editor = null; + var hasBorders = true; + function resize() { + if (canvas.hasClass('hidden')) { + // Can't get correct dimensions from hidden canvas, + // so calculate again. + var size = $window.getScrollSize(); + var offset = source.getOffset(); + width = size.width - offset.x; + height = size.height - offset.y; + } else { + width = canvas.getWidth(); + height = canvas.getHeight(); + } + source.set({ + width: width - (hasBorders ? 2 : 1), + height: height - (hasBorders ? 2 : 0) + }); + } + if (canvas.getProperty('resize')) { + $window.addEvents({ + resize: resize + }); + hasBorders = false; + source.setStyles({ + borderWidth: '0 0 0 1px' + }); + } else { + this.addClass('small'); + } + button.addEvents({ + click: function(event) { + var show = source.hasClass('hidden'); + resize(); + canvas.modifyClass('hidden', show); + source.modifyClass('hidden', !show); + this.setText(show ? 'Run' : 'Source'); + if (show && !editor) { + editor = createCodeMirror(source.$, { + /* + onKeyEvent: function(editor, event) { + event = new DomEvent(event); + if (event.type == 'keydown') { + var pos = editor.getCursor(); + pos.ch += 4; + editor.setCursor(pos); + event.stop(); + } + }, + */ + }, script); + } else if (!show) { + var scope = paper.PaperScope.get(script.$); + if (scope) { + // Update script to edited version + script.setText(editor.getValue()); + // Clear scope first, then evaluate a new script. + scope.clear(); + scope.evaluate(script.$); + } + } + this.setStyle('right', + $('.CodeMirror', source).getScrollSize().height > height // Remove padding + ? 24 : 8); + event.stop(); + }, + + mousedown: function(event) { + event.stop(); + } + }) + } + } +}); $document.addEvent('domready', function() { var h = unescape(document.location.hash); if (h) scrollToElement(h.substring(1)); - var code = $$('.text pre, .reference-class pre'); - if (code.length) { - code.light(lighterSettings).each(function(obj, i) { - var start =code[i].getProperty('start'); - if (start) - obj.element.setProperty('start', start); - }); - } }); var lastMemberId = null; @@ -34,8 +161,11 @@ function toggleMember(id, scrollTo) { lastMemberId = v && id; link.modifyClass('hidden', v); desc.modifyClass('hidden', !v); - if (!desc.code && v) - desc.code = $$('pre', desc).light(lighterSettings); + if (!desc.editor && v) { + desc.editor = $$('pre.code', desc).each(function(code) { + code.format(); + }); + } if (scrollTo) scrollToMember(id); return false; diff --git a/build/jsdoc-toolkit/templates/jsdoc/templates/html.tmpl b/build/jsdoc-toolkit/templates/jsdoc/templates/html.tmpl index b89e2298..f6b5fa43 100644 --- a/build/jsdoc-toolkit/templates/jsdoc/templates/html.tmpl +++ b/build/jsdoc-toolkit/templates/jsdoc/templates/html.tmpl @@ -5,9 +5,9 @@ - + - +