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 Ext.form.ComboBoxAdder = function(config){
13     
14     if (typeof(config.listeners.adderclick) != 'undefined') {
15         config.listeners.add = config.listeners.adderclick;
16     }
17      
18 }
19  
20 Ext.extend(Ext.form.ComboBoxAdder, Ext.form.ComboBox);
21
22
23
24 Ext.form.TextFieldAdder = function(config){
25     
26     Ext.form.TextFieldAdder.superclass.constructor.call(this, config);
27     this.on('select', function(cb, rec, ix) {
28         cb.lastData = rec.data;
29     });
30     this.addEvents({
31         'adderclick' : true
32     });
33 }
34  
35 Ext.extend(Ext.form.TextFieldAdder, Ext.form.TextField, { 
36     lastData : false,
37     //onAddClick: function() { },
38     
39     onRender : function(ct, position) 
40     {
41         Ext.form.TextFieldAdder.superclass.onRender.call(this, ct, position); 
42          this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
43         this.adder = this.wrap.createChild(
44             {tag: 'img', src: Ext.BLANK_IMAGE_URL, cls: 'x-form-textfield-adder'});  
45         var _t = this;
46         this.adder.on('click', function(e) {
47             _t.fireEvent('adderclick', this, e);
48         }, _t);
49     }
50     
51 });
52
53
54 Ext.form.TextFieldAdderMinus = function(config){
55     
56     Ext.form.TextFieldAdder.superclass.constructor.call(this, config);
57     this.on('select', function(cb, rec, ix) {
58         cb.lastData = rec.data;
59     });
60     this.addEvents({
61         'adderclick' : true,
62         'minusclick' : true
63     });
64 }
65  
66 Ext.extend(Ext.form.TextFieldAdderMinus, Ext.form.TextField, { 
67     lastData : false,
68     //onAddClick: function() { },
69     
70     onRender : function(ct, position) 
71     {
72         Ext.form.TextFieldAdder.superclass.onRender.call(this, ct, position); 
73          this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
74         this.adder = this.wrap.createChild(
75             {tag: 'img', src: Ext.BLANK_IMAGE_URL, width: 16, cls: 'x-form-textfield-adder'});  
76         this.minus = this.wrap.createChild(
77             {tag: 'img', src: Ext.BLANK_IMAGE_URL, width: 16, cls: 'x-form-textfield-minus'});  
78         var _t = this;
79         this.adder.on('click', function(e) {
80             _t.fireEvent('adderclick', this, e);
81         }, _t);
82         this.minus.on('click', function(e) {
83             _t.fireEvent('minusclick', this, e);
84         }, _t);
85     }
86     
87 });
88