X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=JsTemplate%2FLink.js;h=5be54d1a637763a33711f2da771d3a9232a17808;hp=913d72de3da386619b6076036803c83057736004;hb=b061b486c6315b60a8a0ba1b46f8163f08bd1756;hpb=ddf9b16d2638ea4f90b11cd1ac1793e4968fc5fe diff --git a/JsTemplate/Link.js b/JsTemplate/Link.js index 913d72d..5be54d1 100644 --- a/JsTemplate/Link.js +++ b/JsTemplate/Link.js @@ -16,21 +16,37 @@ Link = XObject.define( /* * constructor */ - function () { + function (opts) { + XObject.extend(this,opts); }, Object, { + /** + * url {String} url for link.. + */ + url: "", + /** + * text {String} text to show on link. + */ + + text : "", + + /** + * alias {String} not sure? + */ alias : "", + /** + * src {String} not sure? + */ src : "", file : "", - text : "", + innerName : "", classLink : false, targetName : "", - srcReplace : false, - + target : function(targetName) { @@ -47,8 +63,6 @@ Link = XObject.define( }, toSrc : function(filename) { if (typeof(filename) != 'undefined') this.src = filename; - if (this.srcReplace( - return this; }, @@ -68,11 +82,11 @@ Link = XObject.define( }, toString : function() { - var linkString; + var thisLink = this; if (this.alias) { - linkString = this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i, + return this.alias.replace(/(^|[^a-z$0-9_#.:-])([|a-z$0-9_#.:-]+)($|[^a-z$0-9_#.:-])/i, function(match, prematch, symbolName, postmatch) { var symbolNames = symbolName.split("|"); var links = []; @@ -84,14 +98,16 @@ Link = XObject.define( } ); } - else if (this.src) { - linkString = thisLink._makeSrcLink(this.src); + if (this.url) { + return thisLink._makeLink(this.url); + } + if (this.src) { + return thisLink._makeSrcLink(this.src); } - else if (this.file) { - linkString = thisLink._makeFileLink(this.file); + if (this.file) { + return thisLink._makeFileLink(this.file); } - return linkString; }, @@ -186,9 +202,20 @@ Link = XObject.define( var outFilePath = Link.base + filePath; + if (!this.text) this.text = filePath; + return ""+this.text+""; + }, + + /** very basic link... */ + _makeFileLink : function(filePath) { + var target = (this.targetName)? " target=\""+this.targetName+"\"" : ""; + + var outFilePath = Link.base + filePath; + if (!this.text) this.text = filePath; return ""+this.text+""; } + });