JsTemplate/Link.js
[gnome.introspection-doc-generator] / JsTemplate / Link.js
index d4cec0d..3f1b391 100644 (file)
@@ -13,52 +13,80 @@ XObject  = imports.XObject.XObject;
        @constructor
 */
 Link = XObject.define(
-    function () {
-        this.alias = "";
-        this.src = "";
-        this.file = "";
-        this.text = "";
-        this.innerName = "";
-        this.classLink = false;
-        this.targetName = "";
+    /*
+    * constructor
+    */ 
+    function (opts) {
+        XObject.extend(this,opts);
         
-        this.target = function(targetName) {
+    }, 
+    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 : "",
+        
+        innerName : "",
+        classLink : false,
+        targetName : "",
+    
+        
+        
+        target : function(targetName) {
             if (typeof(targetName) != 'undefined') this.targetName = targetName;
             return this;
-        }
-        this.inner = function(inner) {
+        },
+        inner : function(inner) {
             if (typeof(inner) != 'undefined') this.innerName = inner;
             return this;
-        }
-        this.withText = function(text) {
+        },
+        withText : function(text) {
             if (typeof(text) != 'undefined') this.text = text;
             return this;
-        }
-        this.toSrc = function(filename) {
+        },
+        toSrc : function(filename) {
             if (typeof(filename) != 'undefined') this.src = filename;
+            
             return this;
-        }
-        this.toSymbol = function(alias) {
+        },
+        toSymbol : function(alias) {
             if (typeof(alias) != 'undefined') {
                 this.alias = new String(alias);
             }
             return this;
-        }
-        this.toClass = function(alias) {
+        },
+        toClass : function(alias) {
             this.classLink = true;
             return this.toSymbol(alias);
-        }
-        this.toFile = function(file) {
+        },
+        toFile : function(file) {
             if (typeof(file) != 'undefined') this.file = file;
             return this;
-        }
+        },
         
-        this.toString = function() {
+        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 = [];
@@ -70,18 +98,23 @@ 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;
-        }
-    }, 
-    Object,
-    {
+        },
+        
+        
+        
+        
+        
+        
         
         /** Create a link to a snother symbol. */
         _makeSymbolLink : function(alias) {