1 //<script type="text/javascript">
4 * Generic Template Link handler..
10 /** Handle the creation of HTML links to documented symbols.
19 this.classLink = false;
22 this.target = function(targetName) {
23 if (typeof(targetName) != 'undefined') this.targetName = targetName;
26 this.inner = function(inner) {
27 if (typeof(inner) != 'undefined') this.innerName = inner;
30 this.withText = function(text) {
31 if (typeof(text) != 'undefined') this.text = text;
34 this.toSrc = function(filename) {
35 if (typeof(filename) != 'undefined') this.src = filename;
38 this.toSymbol = function(alias) {
39 if (typeof(alias) != 'undefined') {
40 this.alias = new String(alias);
44 this.toClass = function(alias) {
45 this.classLink = true;
46 return this.toSymbol(alias);
48 this.toFile = function(file) {
49 if (typeof(file) != 'undefined') this.file = file;
53 this.toString = function() {
58 linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
59 function(match, prematch, symbolName, postmatch) {
60 var symbolNames = symbolName.split("|");
62 for (var i = 0, l = symbolNames.length; i < l; i++) {
63 thisLink.alias = symbolNames[i];
64 links.push(thisLink._makeSymbolLink(symbolNames[i]));
66 return prematch+links.join("|")+postmatch;
71 linkString = thisLink._makeSrcLink(this.src);
74 linkString = thisLink._makeFileLink(this.file);
81 /** prefixed for hashes */
84 /** Appended to the front of relative link paths. */
87 Link.symbolNameToLinkName = function(symbol) {
89 if (symbol.isStatic) linker = ".";
90 else if (symbol.isInner) linker = "-";
92 return Link.hashPrefix+linker+symbol.name;
97 'Object' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
98 'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
99 'Function' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function',
100 'String' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String',
101 'Number' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Number',
102 'Boolean' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean',
103 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'
108 /** Create a link to a snother symbol. */
109 Link.prototype._makeSymbolLink = function(alias) {
111 // look for '/' in alias..
112 if (/\//.test(alias)) {
113 var bits = alias.split('/');
115 for(var i=0; i < bits.length; i++) {
119 ret += this._makeSymbolLink(bits[i]);
127 var linkBase = Link.base+JSDOC.publish.conf.symbolsDir;
128 var linkTo = Link.symbolSet.getSymbol(alias);
130 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
132 // is it an internal link?
133 if (alias.charAt(0) == "#") {
135 fullLinkPath = alias;
137 // if there is no symbol by that name just return the name unaltered
138 } else if (!linkTo) {
140 if (typeof(Link.builtins[alias]) != 'undefined') {
141 return "<a href=\""+ Link.builtins[alias]+"\""+target+">"+alias+"</a>";
144 return this.text || alias;
147 // it's a symbol in another file
150 if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
151 linkPath = escape(linkTo.memberOf) || "_global_";
152 linkPath += JSDOC.publish.conf.ext + "#" + Link.symbolNameToLinkName(linkTo);
155 linkPath = escape(linkTo.alias);
156 linkPath += JSDOC.publish.conf.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
158 //linkPath = linkBase + linkPath;
159 fullLinkPath = linkBase + linkPath;
162 var linkText = this.text || alias;
164 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
166 if (typeof JSDOC.PluginManager != "undefined") {
167 JSDOC.PluginManager.run("onSymbolLink", link);
170 return "<a href=\""+link.fullLinkPath+"\""+target+" roo:cls=\""+link.linkPath+"\">"+link.linkText+"</a>";
174 /** Create a link to a source file. */
175 Link.prototype._makeSrcLink = function(srcFilePath) {
176 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
178 // transform filepath into a filename
179 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
180 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
181 var outFilePath = Link.base + JSDOC.publish.conf.srcDir + srcFile.replace(/.js$/, '') + JSDOC.publish.conf.ext;
183 if (!this.text) this.text = 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 Link.prototype._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>";