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(
20 XObject.extend(this,opts);
27 * url {String} url for link..
31 * text {String} text to show on link.
37 * alias {String} not sure?
41 * src {String} not sure?
52 target : function(targetName) {
53 if (typeof(targetName) != 'undefined') this.targetName = targetName;
56 inner : function(inner) {
57 if (typeof(inner) != 'undefined') this.innerName = inner;
60 withText : function(text) {
61 if (typeof(text) != 'undefined') this.text = text;
64 toSrc : function(filename) {
65 if (typeof(filename) != 'undefined') this.src = filename;
69 toSymbol : function(alias) {
70 if (typeof(alias) != 'undefined') {
71 this.alias = new String(alias);
75 toClass : function(alias) {
76 this.classLink = true;
77 return this.toSymbol(alias);
79 toFile : function(file) {
80 if (typeof(file) != 'undefined') this.file = file;
84 toString : function() {
89 return this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i,
90 function(match, prematch, symbolName, postmatch) {
91 var symbolNames = symbolName.split("|");
93 for (var i = 0, l = symbolNames.length; i < l; i++) {
94 thisLink.alias = symbolNames[i];
95 links.push(thisLink._makeSymbolLink(symbolNames[i]));
97 return prematch+links.join("|")+postmatch;
102 return thisLink._makeLink(this.url);
105 return thisLink._makeSrcLink(this.src);
108 return thisLink._makeFileLink(this.file);
119 /** Create a link to a snother symbol. */
120 _makeSymbolLink : function(alias) {
122 // look for '/' in alias..
123 if (/\//.test(alias)) {
124 var bits = alias.split('/');
126 for(var i=0; i < bits.length; i++) {
130 ret += this._makeSymbolLink(bits[i]);
138 var linkBase = Link.base+ imports.JSDOC.BuildDocs.BuildDocs.symbolsDir;
139 var linkTo = Link.symbolSet.getSymbol(alias);
141 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
143 // is it an internal link?
144 if (alias.charAt(0) == "#") {
146 fullLinkPath = alias;
148 // if there is no symbol by that name just return the name unaltered
149 } else if (!linkTo) {
151 if (typeof(Link.builtins[alias]) != 'undefined') {
152 return "<a href=\""+ Link.builtins[alias]+"\""+target+">"+alias+"</a>";
155 return this.text || alias;
158 // it's a symbol in another file
161 if (!linkTo.is("CONSTRUCTOR") && !linkTo.isNamespace) { // it's a method or property
162 linkPath = escape(linkTo.memberOf) || "_global_";
163 linkPath += imports.JSDOC.Options.Options.ext + "#" + Link.symbolNameToLinkName(linkTo);
166 linkPath = escape(linkTo.alias);
167 linkPath += imports.JSDOC.Options.Options.ext + (this.classLink? "":"#" + Link.hashPrefix + "constructor");
169 //linkPath = linkBase + linkPath;
170 fullLinkPath = linkBase + linkPath;
173 var linkText = this.text || alias;
175 var link = {linkPath: linkPath, linkText: linkText, fullLinkPath: fullLinkPath};
177 //if (typeof JSDOC.PluginManager != "undefined") {
178 // JSDOC.PluginManager.run("onSymbolLink", link);
181 return "<a href=\""+link.fullLinkPath+"\""+target+" roo:cls=\""+link.linkPath+"\">"+link.linkText+"</a>";
185 /** Create a link to a source file. */
186 _makeSrcLink : function(srcFilePath) {
187 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
189 // transform filepath into a filename
190 var srcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, "."); // was _
191 var lsrcFile = srcFilePath.replace(/\.\.?[\\\/]/g, "").replace(/[:\\\/]/g, ".");
192 var outFilePath = Link.base + '/symbols/' + srcFile.replace(/.js$/, '') +
193 imports.JSDOC.Options.Options.publishExt;
195 if (!this.text) this.text = srcFilePath; //FilePath.fileName(srcFilePath);
196 return "<a href=\""+outFilePath+"\""+target+" roo:cls=\"src/"+lsrcFile+"\">"+this.text+"</a>";
199 /** Create a link to a source file. */
200 _makeFileLink : function(filePath) {
201 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
203 var outFilePath = Link.base + filePath;
205 if (!this.text) this.text = filePath;
206 return "<a href=\""+outFilePath+"\""+target+">"+this.text+"</a>";
209 /** very basic link... */
210 _makeLink : function(url) {
211 var target = (this.targetName)? " target=\""+this.targetName+"\"" : "";
213 if (!this.text) this.text = url;
214 return "<a href=\""+url+"\""+target+">"+this.text+"</a>";
222 /** prefixed for hashes */
223 Link.hashPrefix = "";
225 /** Appended to the front of relative link paths. */
228 Link.symbolNameToLinkName = function(symbol) {
230 if (symbol.isStatic) linker = ".";
231 else if (symbol.isInner) linker = "-";
233 return Link.hashPrefix+linker+symbol.name;
238 'Object' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
239 'Object...' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Object',
240 'Function' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function',
241 'String' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:String',
242 'Number' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Number',
243 'Boolean' : 'http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Boolean',
244 'HTMLElement' : 'http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037'