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(
34 * eg. '/var/www/xxx:symbol'
40 target : function(targetName) {
41 if (typeof(targetName) != 'undefined') this.targetName = targetName;
44 inner : function(inner) {
45 if (typeof(inner) != 'undefined') this.innerName = inner;
48 withText : function(text) {
49 if (typeof(text) != 'undefined') this.text = text;
52 toSrc : function(filename) {
53 if (typeof(filename) != 'undefined') this.src = filename;
59 toSymbol : function(alias) {
60 if (typeof(alias) != 'undefined') {
61 this.alias = new String(alias);
65 toClass : function(alias) {
66 this.classLink = true;
67 return this.toSymbol(alias);
69 toFile : function(file) {
70 if (typeof(file) != 'undefined') this.file = file;
74 toString : function() {
79 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
80 function(match, prematch, symbolName, postmatch) {
81 var symbolNames = symbolName.split("|");
83 for (var i = 0, l = symbolNames.length; i < l; i++) {
84 thisLink.alias = symbolNames[i];
85 links.push(thisLink._makeSymbolLink(symbolNames[i]));
87 return prematch+links.join("|")+postmatch;
92 linkString = thisLink._makeSrcLink(this.src);
95 linkString = thisLink._makeFileLink(this.file);
107 /** Create a link to a snother symbol. */
108 _makeSymbolLink : function(alias) {
110 // look for '/' in alias..
111 if (/\//.test(alias)) {
112 var bits = alias.split('/');
114 for(var i=0; i < bits.length; i++) {
118 ret += this._makeSymbolLink(bits[i]);
126 var linkBase = Link.base+ imports.JSDOC.BuildDocs.BuildDocs.symbolsDir;
127 var linkTo = Link.symbolSet.getSymbol(alias);
129 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
131 // is it an internal link?
132 if (alias.charAt(0) == "#") {
134 fullLinkPath = alias;
136 // if there is no symbol by that name just return the name unaltered
137 } else if (!linkTo) {
139 if (typeof(Link.builtins[alias]) != 'undefined') {
140 return "<a href=\""+ Link.builtins[alias]+"\""+target+">"+alias+"</a>";
143 return this.text || alias;
146 // it's a symbol in another file
149 if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
150 linkPath = escape(linkTo.memberOf) || "_global_";
151 linkPath += imports.JSDOC.Options.Options.ext + "#" + Link.symbolNameToLinkName(linkTo);
154 linkPath = escape(linkTo.alias);
155 linkPath += imports.JSDOC.Options.Options.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
157 //linkPath = linkBase + linkPath;
158 fullLinkPath = linkBase + linkPath;
161 var linkText = this.text || alias;
163 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
165 //if (typeof JSDOC.PluginManager != "undefined") {
166 // JSDOC.PluginManager.run("onSymbolLink", link);
169 return "<a href=\""+link.fullLinkPath+"\""+target+" roo:cls=\""+link.linkPath+"\">"+link.linkText+"</a>";
173 /** Create a link to a source file. */
174 _makeSrcLink : function(srcFilePath) {
175 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
177 // transform filepath into a filename
178 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
179 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
180 var outFilePath = Link.base + '/symbols/' + srcFile.replace(/.js$/, '') +
181 imports.JSDOC.Options.Options.publishExt;
183 if (!this.text) this.text = srcFilePath; //FilePath.fileName(srcFilePath);
184 return "<a href=\""+outFilePath+"\""+target+" roo:cls=\"src/"+lsrcFile+"\">"+this.text+"</a>";
187 /** Create a link to a source file. */
188 _makeFileLink : function(filePath) {
189 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
191 var outFilePath = Link.base + filePath;
193 if (!this.text) this.text = filePath;
194 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
201 /** prefixed for hashes */
202 Link.hashPrefix = "";
204 /** Appended to the front of relative link paths. */
207 Link.symbolNameToLinkName = function(symbol) {
209 if (symbol.isStatic) linker = ".";
210 else if (symbol.isInner) linker = "-";
212 return Link.hashPrefix+linker+symbol.name;
217 'Object' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
218 'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
219 'Function' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function',
220 'String' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String',
221 'Number' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Number',
222 'Boolean' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean',
223 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'