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(
36 target : function(targetName) {
37 if (typeof(targetName) != 'undefined') this.targetName = targetName;
40 inner : function(inner) {
41 if (typeof(inner) != 'undefined') this.innerName = inner;
44 withText : function(text) {
45 if (typeof(text) != 'undefined') this.text = text;
48 toSrc : function(filename) {
49 if (typeof(filename) != 'undefined') this.src = filename;
55 toSymbol : function(alias) {
56 if (typeof(alias) != 'undefined') {
57 this.alias = new String(alias);
61 toClass : function(alias) {
62 this.classLink = true;
63 return this.toSymbol(alias);
65 toFile : function(file) {
66 if (typeof(file) != 'undefined') this.file = file;
70 toString : function() {
75 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
76 function(match, prematch, symbolName, postmatch) {
77 var symbolNames = symbolName.split("|");
79 for (var i = 0, l = symbolNames.length; i < l; i++) {
80 thisLink.alias = symbolNames[i];
81 links.push(thisLink._makeSymbolLink(symbolNames[i]));
83 return prematch+links.join("|")+postmatch;
88 linkString = thisLink._makeSrcLink(this.src);
91 linkString = thisLink._makeFileLink(this.file);
103 /** Create a link to a snother symbol. */
104 _makeSymbolLink : function(alias) {
106 // look for '/' in alias..
107 if (/\//.test(alias)) {
108 var bits = alias.split('/');
110 for(var i=0; i < bits.length; i++) {
114 ret += this._makeSymbolLink(bits[i]);
122 var linkBase = Link.base+ imports.JSDOC.BuildDocs.BuildDocs.symbolsDir;
123 var linkTo = Link.symbolSet.getSymbol(alias);
125 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
127 // is it an internal link?
128 if (alias.charAt(0) == "#") {
130 fullLinkPath = alias;
132 // if there is no symbol by that name just return the name unaltered
133 } else if (!linkTo) {
135 if (typeof(Link.builtins[alias]) != 'undefined') {
136 return "<a href=\""+ Link.builtins[alias]+"\""+target+">"+alias+"</a>";
139 return this.text || alias;
142 // it's a symbol in another file
145 if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
146 linkPath = escape(linkTo.memberOf) || "_global_";
147 linkPath += imports.JSDOC.Options.Options.ext + "#" + Link.symbolNameToLinkName(linkTo);
150 linkPath = escape(linkTo.alias);
151 linkPath += imports.JSDOC.Options.Options.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
153 //linkPath = linkBase + linkPath;
154 fullLinkPath = linkBase + linkPath;
157 var linkText = this.text || alias;
159 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
161 //if (typeof JSDOC.PluginManager != "undefined") {
162 // JSDOC.PluginManager.run("onSymbolLink", link);
165 return "<a href=\""+link.fullLinkPath+"\""+target+" roo:cls=\""+link.linkPath+"\">"+link.linkText+"</a>";
169 /** Create a link to a source file. */
170 _makeSrcLink : function(srcFilePath) {
171 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
173 // transform filepath into a filename
174 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
175 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
176 var outFilePath = Link.base + '/symbols/' + srcFile.replace(/.js$/, '') +
177 imports.JSDOC.Options.Options.publishExt;
179 if (!this.text) this.text = srcFilePath; //FilePath.fileName(srcFilePath);
180 return "<a href=\""+outFilePath+"\""+target+" roo:cls=\"src/"+lsrcFile+"\">"+this.text+"</a>";
183 /** Create a link to a source file. */
184 _makeFileLink : function(filePath) {
185 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
187 var outFilePath = Link.base + filePath;
189 if (!this.text) this.text = filePath;
190 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
197 /** prefixed for hashes */
198 Link.hashPrefix = "";
200 /** Appended to the front of relative link paths. */
203 Link.symbolNameToLinkName = function(symbol) {
205 if (symbol.isStatic) linker = ".";
206 else if (symbol.isInner) linker = "-";
208 return Link.hashPrefix+linker+symbol.name;
213 'Object' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
214 'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
215 'Function' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function',
216 'String' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String',
217 'Number' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Number',
218 'Boolean' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean',
219 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'