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.
16 Link = XObject.define(
21 XObject.extend(this,opts);
28 * url {String} url for link..
32 * text {String} text to show on link.
38 * alias {String} not sure?
42 * src {String} not sure?
53 target : function(targetName) {
54 if (typeof(targetName) != 'undefined') this.targetName = targetName;
57 inner : function(inner) {
58 if (typeof(inner) != 'undefined') this.innerName = inner;
61 withText : function(text) {
62 if (typeof(text) != 'undefined') this.text = text;
65 toSrc : function(filename) {
66 if (typeof(filename) != 'undefined') this.src = filename;
70 toSymbol : function(alias) {
71 if (typeof(alias) != 'undefined') {
72 this.alias = new String(alias);
76 toClass : function(alias) {
77 this.classLink = true;
78 return this.toSymbol(alias);
80 toFile : function(file) {
81 if (typeof(file) != 'undefined') this.file = file;
85 toString : function() {
90 return this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
91 function(match, prematch, symbolName, postmatch) {
92 var symbolNames = symbolName.split("|");
94 for (var i = 0, l = symbolNames.length; i < l; i++) {
95 thisLink.alias = symbolNames[i];
96 links.push(thisLink._makeSymbolLink(symbolNames[i]));
98 return prematch+links.join("|")+postmatch;
103 return thisLink._makeLink(this.url);
106 return thisLink._makeSrcLink(this.src);
109 return thisLink._makeFileLink(this.file);
120 /** Create a link to a snother symbol. */
121 _makeSymbolLink : function(alias)
123 //print(JSON.stringify(alias));
124 // look for '/' in alias..
125 if (/\//.test(alias)) {
126 var bits = alias.split('/');
128 for(var i=0; i < bits.length; i++) {
132 ret += this._makeSymbolLink(bits[i]);
141 var linkTo = Link.symbolSet.getSymbol(alias);
144 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
146 // is it an internal link?
147 if (alias.charAt(0) == "#") {
149 fullLinkPath = alias;
151 // if there is no symbol by that name just return the name unaltered
152 } else if (!linkTo) {
154 if (typeof(Link.builtins[alias]) != 'undefined') {
155 return "<a href=\""+ Link.builtins[alias]+"\""+target+">"+alias+"</a>";
158 return this.text || alias;
161 // it's a symbol in another file
164 if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
165 linkPath = escape(linkTo.memberOf) || "_global_";
166 linkPath += '.html#' + Link.symbolNameToLinkName(linkTo);
169 linkPath = escape(linkTo.alias);
170 linkPath += '.html' + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
172 //linkPath = linkBase + linkPath;
173 fullLinkPath = linkBase + linkPath;
176 var linkText = this.text || alias;
178 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
180 //if (typeof JSDOC.PluginManager != "undefined") {
181 // JSDOC.PluginManager.run("onSymbolLink", link);
184 return "<a href=\""+link.fullLinkPath+"\""+target+" roo:cls=\""+link.linkPath+"\">"+link.linkText+"</a>";
188 /** Create a link to a source file. */
189 _makeSrcLink : function(srcFilePath) {
190 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
192 // transform filepath into a filename
193 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
194 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
195 var outFilePath = Link.base + '/symbols/' + srcFile.replace(/.js$/, '') +
196 imports.JSDOC.Options.Options.publishExt;
198 if (!this.text) this.text = srcFilePath; //FilePath.fileName(srcFilePath);
199 return "<a href=\""+outFilePath+"\""+target+" roo:cls=\"src/"+lsrcFile+"\">"+this.text+"</a>";
202 /** Create a link to a source file. */
203 _makeFileLink : function(filePath) {
204 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
206 var outFilePath = Link.base + filePath;
208 if (!this.text) this.text = filePath;
209 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
212 /** very basic link... */
213 _makeLink : function(url) {
214 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
216 if (!this.text) this.text = url;
217 return "<a href=\""+url+"\""+target+">"+this.text+"</a>";
225 /** prefixed for hashes */
226 Link.hashPrefix = "";
228 /** Appended to the front of relative link paths. */
231 Link.symbolNameToLinkName = function(symbol) {
233 if (symbol.isStatic) linker = ".";
234 else if (symbol.isInner) linker = "-";
236 return Link.hashPrefix+linker+symbol.name;
241 'Object' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
242 'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
243 'Function' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function',
244 'String' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String',
245 'Number' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Number',
246 'Boolean' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean',
247 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'