fix #7653 styling on password entry
[roojs1] / Roo / bootstrap / form / Password.js
1 /**
2  * @class Roo.bootstrap.form.Password
3  * @extends Roo.bootstrap.form.Input
4  * Bootstrap Password class
5  * 
6  * 
7  * 
8  * 
9  * @constructor
10  * Create a new Password
11  * @param {Object} config The config object
12  */
13
14 Roo.bootstrap.form.Password = function(config){
15     Roo.bootstrap.form.Password.superclass.constructor.call(this, config);
16
17     this.inputType = 'password';
18 };
19
20 Roo.extend(Roo.bootstrap.form.Password, Roo.bootstrap.form.Input, {
21
22     onRender : function(ct, position)
23     {
24         Roo.bootstrap.form.SecurePass.superclass.onRender.call(this, ct, position);
25
26         this.el.addClass('form-password');
27
28         this.wrap = this.inputEl().wrap({
29             cls : 'password-wrap'
30         });
31
32         this.toggle = this.wrap.createChild({
33             tag : 'Button',
34             cls : 'password-toggle'
35         });
36
37
38         this.toggleEl().addClass('password-hidden');
39
40         this.toggleEl().on('click', this.onToggleClick, this);;
41     },
42
43     toggleEl: function()
44     {
45         return this.el.select('button.password-toggle',true).first();
46     },
47
48     onToggleClick : function(e) 
49     {
50         var input = this.inputEl();
51         var toggle = this.toggleEl();
52
53         toggle.removeClass(['password-visible', 'password-hidden']);
54
55         if(input.attr('type') == 'password') {
56             input.attr('type', 'text');
57             toggle.addClass('password-visible');
58         }
59         else {
60             input.attr('type', 'password');
61             toggle.addClass('password-hidden');
62         }
63     }
64 });