1 //<script type="text/javascript">
3 XObject = imports.XObject.XObject;
6 * Generic Template Link handler..
12 /** Handle the creation of HTML links to documented symbols.
15 Link = XObject.define(
22 this.classLink = false;
25 this.target = function(targetName) {
26 if (typeof(targetName) != 'undefined') this.targetName = targetName;
29 this.inner = function(inner) {
30 if (typeof(inner) != 'undefined') this.innerName = inner;
33 this.withText = function(text) {
34 if (typeof(text) != 'undefined') this.text = text;
37 this.toSrc = function(filename) {
38 if (typeof(filename) != 'undefined') this.src = filename;
41 this.toSymbol = function(alias) {
42 if (typeof(alias) != 'undefined') {
43 this.alias = new String(alias);
47 this.toClass = function(alias) {
48 this.classLink = true;
49 return this.toSymbol(alias);
51 this.toFile = function(file) {
52 if (typeof(file) != 'undefined') this.file = file;
56 this.toString = function() {
61 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
62 function(match, prematch, symbolName, postmatch) {
63 var symbolNames = symbolName.split("|");
65 for (var i = 0, l = symbolNames.length; i < l; i++) {
66 thisLink.alias = symbolNames[i];
67 links.push(thisLink._makeSymbolLink(symbolNames[i]));
69 return prematch+links.join("|")+postmatch;
74 linkString = thisLink._makeSrcLink(this.src);
77 linkString = thisLink._makeFileLink(this.file);
86 /** Create a link to a snother symbol. */
87 _makeSymbolLink : function(alias) {
89 // look for '/' in alias..
90 if (/\//.test(alias)) {
91 var bits = alias.split('/');
93 for(var i=0; i < bits.length; i++) {
97 ret += this._makeSymbolLink(bits[i]);
105 var linkBase = Link.base+ imports.JSDOC.BuildDocs.BuildDocs.symbolsDir;
106 var linkTo = Link.symbolSet.getSymbol(alias);
108 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
110 // is it an internal link?
111 if (alias.charAt(0) == "#") {
113 fullLinkPath = alias;
115 // if there is no symbol by that name just return the name unaltered
116 } else if (!linkTo) {
118 if (typeof(Link.builtins[alias]) != 'undefined') {
119 return "<a href=\""+ Link.builtins[alias]+"\""+target+">"+alias+"</a>";
122 return this.text || alias;
125 // it's a symbol in another file
128 if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
129 linkPath = escape(linkTo.memberOf) || "_global_";
130 linkPath += imports.JSDOC.Options.Options.ext + "#" + Link.symbolNameToLinkName(linkTo);
133 linkPath = escape(linkTo.alias);
134 linkPath += imports.JSDOC.Options.Options.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
136 //linkPath = linkBase + linkPath;
137 fullLinkPath = linkBase + linkPath;
140 var linkText = this.text || alias;
142 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
144 //if (typeof JSDOC.PluginManager != "undefined") {
145 // JSDOC.PluginManager.run("onSymbolLink", link);
148 return "<a href=\""+link.fullLinkPath+"\""+target+" roo:cls=\""+link.linkPath+"\">"+link.linkText+"</a>";
152 /** Create a link to a source file. */
153 _makeSrcLink : function(srcFilePath) {
154 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
156 // transform filepath into a filename
157 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
158 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
159 var outFilePath = Link.base + '/symbols/' + srcFile.replace(/.js$/, '') +
160 imports.JSDOC.Options.Options.publishExt;
162 if (!this.text) this.text = srcFilePath; //FilePath.fileName(srcFilePath);
163 return "<a href=\""+outFilePath+"\""+target+" roo:cls=\"src/"+lsrcFile+"\">"+this.text+"</a>";
166 /** Create a link to a source file. */
167 _makeFileLink : function(filePath) {
168 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
170 var outFilePath = Link.base + filePath;
172 if (!this.text) this.text = filePath;
173 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
180 /** prefixed for hashes */
181 Link.hashPrefix = "";
183 /** Appended to the front of relative link paths. */
186 Link.symbolNameToLinkName = function(symbol) {
188 if (symbol.isStatic) linker = ".";
189 else if (symbol.isInner) linker = "-";
191 return Link.hashPrefix+linker+symbol.name;
196 'Object' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
197 'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
198 'Function' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function',
199 'String' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String',
200 'Number' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Number',
201 'Boolean' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean',
202 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'