X-Git-Url: http://git.roojs.org/?p=gnome.introspection-doc-generator;a=blobdiff_plain;f=JsTemplate%2FLink.js;h=e70c3f2603301391818eb449b1b5fc3543c876d4;hp=888f3a211a9f5113c179bb6b02b21c18e76064b1;hb=7824527be9d63723b229b78bd1984ecec44f1bc4;hpb=e2775684853d2377df9e4ccd0a80dc7fc23efe0f diff --git a/JsTemplate/Link.js b/JsTemplate/Link.js index 888f3a2..e70c3f2 100644 --- a/JsTemplate/Link.js +++ b/JsTemplate/Link.js @@ -23,10 +23,26 @@ Link = XObject.define( 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 : "", @@ -66,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 = []; @@ -82,14 +98,16 @@ Link = XObject.define( } ); } - else if (this.src) { - linkString = thisLink._makeSrcLink(this.src); + if (this.url) { + return thisLink._makeLink(this.url); } - else if (this.file) { - linkString = thisLink._makeFileLink(this.file); + if (this.src) { + return thisLink._makeSrcLink(this.src); + } + if (this.file) { + return thisLink._makeFileLink(this.file); } - return linkString; }, @@ -186,7 +204,16 @@ Link = XObject.define( if (!this.text) this.text = filePath; return ""+this.text+""; + }, + + /** very basic link... */ + _makeLink : function(url) { + var target = (this.targetName)? " target=\""+this.targetName+"\"" : ""; + + if (!this.text) this.text = url; + return ""+this.text+""; } + });