widgets/ComboBoxAdder.js
[Pman.Core] / widgets / ComboBoxAdder.js
1
2 //<script type="text/javascript">
3 /**
4  * 
5  * old combobox adder.. 
6  * this is all incorporated into the new combobox, however the API is different..
7  * 
8  * to make this work on the new combo, you just implement a 'add' handler.
9  */
10
11
12
13
14
15 Ext.form.ComboBoxAdder = function(config){
16     
17     if (typeof(config.listeners.adderclick) != 'undefined') {
18         config.listeners.add = config.listeners.adderclick;
19     }
20      
21 }
22  
23 Ext.extend(Ext.form.ComboBoxAdder, Ext.form.ComboBox);
24
25
26
27 Ext.form.TextFieldAdder = function(config){
28     
29     Ext.form.TextFieldAdder.superclass.constructor.call(this, config);
30     this.on('select', function(cb, rec, ix) {
31         cb.lastData = rec.data;
32     });
33     this.addEvents({
34         'adderclick' : true
35     });
36 }
37  
38 Ext.extend(Ext.form.TextFieldAdder, Ext.form.TextField, { 
39     lastData : false,
40     //onAddClick: function() { },
41     
42     onRender : function(ct, position) 
43     {
44         Ext.form.TextFieldAdder.superclass.onRender.call(this, ct, position); 
45          this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
46         this.adder = this.wrap.createChild(
47             {tag: 'img', src: Ext.BLANK_IMAGE_URL, cls: 'x-form-textfield-adder'});  
48         var _t = this;
49         this.adder.on('click', function(e) {
50             _t.fireEvent('adderclick', this, e);
51         }, _t);
52     }
53     
54 });
55
56
57 Ext.form.TextFieldAdderMinus = function(config){
58     
59     Ext.form.TextFieldAdder.superclass.constructor.call(this, config);
60     this.on('select', function(cb, rec, ix) {
61         cb.lastData = rec.data;
62     });
63     this.addEvents({
64         'adderclick' : true,
65         'minusclick' : true
66     });
67 }
68  
69 Ext.extend(Ext.form.TextFieldAdderMinus, Ext.form.TextField, { 
70     lastData : false,
71     //onAddClick: function() { },
72     
73     onRender : function(ct, position) 
74     {
75         Ext.form.TextFieldAdder.superclass.onRender.call(this, ct, position); 
76          this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
77         this.adder = this.wrap.createChild(
78             {tag: 'img', src: Ext.BLANK_IMAGE_URL, width: 16, cls: 'x-form-textfield-adder'});  
79         this.minus = this.wrap.createChild(
80             {tag: 'img', src: Ext.BLANK_IMAGE_URL, width: 16, cls: 'x-form-textfield-minus'});  
81         var _t = this;
82         this.adder.on('click', function(e) {
83             _t.fireEvent('adderclick', this, e);
84         }, _t);
85         this.minus.on('click', function(e) {
86             _t.fireEvent('minusclick', this, e);
87         }, _t);
88     }
89     
90 });
91