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(
35 target : function(targetName) {
36 if (typeof(targetName) != 'undefined') this.targetName = targetName;
39 inner : function(inner) {
40 if (typeof(inner) != 'undefined') this.innerName = inner;
43 withText : function(text) {
44 if (typeof(text) != 'undefined') this.text = text;
47 toSrc : function(filename) {
48 if (typeof(filename) != 'undefined') this.src = filename;
52 toSymbol : function(alias) {
53 if (typeof(alias) != 'undefined') {
54 this.alias = new String(alias);
58 toClass : function(alias) {
59 this.classLink = true;
60 return this.toSymbol(alias);
62 toFile : function(file) {
63 if (typeof(file) != 'undefined') this.file = file;
67 toString : function() {
72 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
73 function(match, prematch, symbolName, postmatch) {
74 var symbolNames = symbolName.split("|");
76 for (var i = 0, l = symbolNames.length; i < l; i++) {
77 thisLink.alias = symbolNames[i];
78 links.push(thisLink._makeSymbolLink(symbolNames[i]));
80 return prematch+links.join("|")+postmatch;
85 linkString = thisLink._makeSrcLink(this.src);
88 linkString = thisLink._makeFileLink(this.file);
100 /** Create a link to a snother symbol. */
101 _makeSymbolLink : function(alias) {
103 // look for '/' in alias..
104 if (/\//.test(alias)) {
105 var bits = alias.split('/');
107 for(var i=0; i < bits.length; i++) {
111 ret += this._makeSymbolLink(bits[i]);
119 var linkBase = Link.base+ imports.JSDOC.BuildDocs.BuildDocs.symbolsDir;
120 var linkTo = Link.symbolSet.getSymbol(alias);
122 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
124 // is it an internal link?
125 if (alias.charAt(0) == "#") {
127 fullLinkPath = alias;
129 // if there is no symbol by that name just return the name unaltered
130 } else if (!linkTo) {
132 if (typeof(Link.builtins[alias]) != 'undefined') {
133 return "<a href=\""+ Link.builtins[alias]+"\""+target+">"+alias+"</a>";
136 return this.text || alias;
139 // it's a symbol in another file
142 if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
143 linkPath = escape(linkTo.memberOf) || "_global_";
144 linkPath += imports.JSDOC.Options.Options.ext + "#" + Link.symbolNameToLinkName(linkTo);
147 linkPath = escape(linkTo.alias);
148 linkPath += imports.JSDOC.Options.Options.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
150 //linkPath = linkBase + linkPath;
151 fullLinkPath = linkBase + linkPath;
154 var linkText = this.text || alias;
156 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
158 //if (typeof JSDOC.PluginManager != "undefined") {
159 // JSDOC.PluginManager.run("onSymbolLink", link);
162 return "<a href=\""+link.fullLinkPath+"\""+target+" roo:cls=\""+link.linkPath+"\">"+link.linkText+"</a>";
166 /** Create a link to a source file. */
167 _makeSrcLink : function(srcFilePath) {
168 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
170 // transform filepath into a filename
171 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
172 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
173 var outFilePath = Link.base + '/symbols/' + srcFile.replace(/.js$/, '') +
174 imports.JSDOC.Options.Options.publishExt;
176 if (!this.text) this.text = srcFilePath; //FilePath.fileName(srcFilePath);
177 return "<a href=\""+outFilePath+"\""+target+" roo:cls=\"src/"+lsrcFile+"\">"+this.text+"</a>";
180 /** Create a link to a source file. */
181 _makeFileLink : function(filePath) {
182 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
184 var outFilePath = Link.base + filePath;
186 if (!this.text) this.text = filePath;
187 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
194 /** prefixed for hashes */
195 Link.hashPrefix = "";
197 /** Appended to the front of relative link paths. */
200 Link.symbolNameToLinkName = function(symbol) {
202 if (symbol.isStatic) linker = ".";
203 else if (symbol.isInner) linker = "-";
205 return Link.hashPrefix+linker+symbol.name;
210 'Object' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
211 'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
212 'Function' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function',
213 'String' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String',
214 'Number' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Number',
215 'Boolean' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean',
216 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'