add docblock for password
[roojs1] / Roo / bootstrap / Link.js
index d16053d..aebb2d7 100644 (file)
@@ -9,11 +9,17 @@
 /**
  * @class Roo.bootstrap.Link
  * @extends Roo.bootstrap.Component
- * Bootstrap Link Class
+ * @children Roo.bootstrap.Component
+ * Bootstrap Link Class (eg. '<a href>')
  * @cfg {String} alt image alternative text
  * @cfg {String} href a tag href
  * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
  * @cfg {String} html the content of the link.
+ * @cfg {String} anchor name for the anchor link
+ * @cfg {String} fa - favicon
+
+ * @cfg {Boolean} preventDefault (true | false) default false
 
  * 
  * @constructor
@@ -39,20 +45,42 @@ Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component,  {
     
     href: false,
     target: false,
+    preventDefault: false,
+    anchor : false,
+    alt : false,
+    fa: false,
+
 
-    getAutoCreate : function(){
+    getAutoCreate : function()
+    {
+        var html = this.html || '';
         
+        if (this.fa !== false) {
+            html = '<i class="fa fa-' + this.fa + '"></i>';
+        }
         var cfg = {
-            tag: 'a',
-            html : this.html || 'html-missing'
+            tag: 'a'
+        };
+        // anchor's do not require html/href...
+        if (this.anchor === false) {
+            cfg.html = html;
+            cfg.href = this.href || '#';
+        } else {
+            cfg.name = this.anchor;
+            if (this.html !== false || this.fa !== false) {
+                cfg.html = html;
+            }
+            if (this.href !== false) {
+                cfg.href = this.href;
+            }
         }
         
-        
-        if(this.alt){
+        if(this.alt !== false){
             cfg.alt = this.alt;
         }
-        cfg.href = this.href || '#';
-        if(this.target){
+        
+        
+        if(this.target !== false) {
             cfg.target = this.target;
         }
         
@@ -61,13 +89,16 @@ Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component,  {
     
     initEvents: function() {
         
-        if(!this.href){
+        if(!this.href || this.preventDefault){
             this.el.on('click', this.onClick, this);
         }
     },
     
     onClick : function(e)
     {
+        if(this.preventDefault){
+            e.preventDefault();
+        }
         //Roo.log('img onclick');
         this.fireEvent('click', this, e);
     }