1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * @class Ext.form.FieldSet |
---|
11 | * @extends Ext.Panel |
---|
12 | * Standard container used for grouping form fields. |
---|
13 | * @constructor |
---|
14 | * @param {Object} config Configuration options |
---|
15 | */ |
---|
16 | Ext.form.FieldSet = Ext.extend(Ext.Panel, { |
---|
17 | /** |
---|
18 | * @cfg {Mixed} checkboxToggle True to render a checkbox into the fieldset frame just in front of the legend, |
---|
19 | * or a DomHelper config object to create the checkbox. (defaults to false). |
---|
20 | * The fieldset will be expanded or collapsed when the checkbox is toggled. |
---|
21 | */ |
---|
22 | /** |
---|
23 | * @cfg {String} checkboxName The name to assign to the fieldset's checkbox if {@link #checkboxToggle} = true |
---|
24 | * (defaults to '[checkbox id]-checkbox'). |
---|
25 | */ |
---|
26 | /** |
---|
27 | * @cfg {Number} labelWidth The width of labels. This property cascades to child containers. |
---|
28 | */ |
---|
29 | /** |
---|
30 | * @cfg {String} itemCls A css class to apply to the x-form-item of fields. This property cascades to child containers. |
---|
31 | */ |
---|
32 | /** |
---|
33 | * @cfg {String} baseCls The base CSS class applied to the fieldset (defaults to 'x-fieldset'). |
---|
34 | */ |
---|
35 | baseCls:'x-fieldset', |
---|
36 | /** |
---|
37 | * @cfg {String} layout The {@link Ext.Container#layout} to use inside the fieldset (defaults to 'form'). |
---|
38 | */ |
---|
39 | layout: 'form', |
---|
40 | /** |
---|
41 | * @cfg {Boolean} animCollapse |
---|
42 | * True to animate the transition when the panel is collapsed, false to skip the animation (defaults to false). |
---|
43 | */ |
---|
44 | animCollapse: false, |
---|
45 | |
---|
46 | // private |
---|
47 | onRender : function(ct, position){ |
---|
48 | if(!this.el){ |
---|
49 | this.el = document.createElement('fieldset'); |
---|
50 | this.el.id = this.id; |
---|
51 | if (this.title || this.header || this.checkboxToggle) { |
---|
52 | this.el.appendChild(document.createElement('legend')).className = 'x-fieldset-header'; |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | Ext.form.FieldSet.superclass.onRender.call(this, ct, position); |
---|
57 | |
---|
58 | if(this.checkboxToggle){ |
---|
59 | var o = typeof this.checkboxToggle == 'object' ? |
---|
60 | this.checkboxToggle : |
---|
61 | {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'}; |
---|
62 | this.checkbox = this.header.insertFirst(o); |
---|
63 | this.checkbox.dom.checked = !this.collapsed; |
---|
64 | this.checkbox.on('click', this.onCheckClick, this); |
---|
65 | } |
---|
66 | }, |
---|
67 | |
---|
68 | // private |
---|
69 | onCollapse : function(doAnim, animArg){ |
---|
70 | if(this.checkbox){ |
---|
71 | this.checkbox.dom.checked = false; |
---|
72 | } |
---|
73 | Ext.form.FieldSet.superclass.onCollapse.call(this, doAnim, animArg); |
---|
74 | |
---|
75 | }, |
---|
76 | |
---|
77 | // private |
---|
78 | onExpand : function(doAnim, animArg){ |
---|
79 | if(this.checkbox){ |
---|
80 | this.checkbox.dom.checked = true; |
---|
81 | } |
---|
82 | Ext.form.FieldSet.superclass.onExpand.call(this, doAnim, animArg); |
---|
83 | }, |
---|
84 | |
---|
85 | /* //protected |
---|
86 | * This function is called by the fieldset's checkbox when it is toggled (only applies when |
---|
87 | * checkboxToggle = true). This method should never be called externally, but can be |
---|
88 | * overridden to provide custom behavior when the checkbox is toggled if needed. |
---|
89 | */ |
---|
90 | onCheckClick : function(){ |
---|
91 | this[this.checkbox.dom.checked ? 'expand' : 'collapse'](); |
---|
92 | }, |
---|
93 | |
---|
94 | // private |
---|
95 | beforeDestroy : function(){ |
---|
96 | if(this.checkbox){ |
---|
97 | this.checkbox.un('click', this.onCheckClick, this); |
---|
98 | } |
---|
99 | Ext.form.FieldSet.superclass.beforeDestroy.call(this); |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * @cfg {String/Number} activeItem |
---|
104 | * @hide |
---|
105 | */ |
---|
106 | /** |
---|
107 | * @cfg {Mixed} applyTo |
---|
108 | * @hide |
---|
109 | */ |
---|
110 | /** |
---|
111 | * @cfg {Object/Array} bbar |
---|
112 | * @hide |
---|
113 | */ |
---|
114 | /** |
---|
115 | * @cfg {Boolean} bodyBorder |
---|
116 | * @hide |
---|
117 | */ |
---|
118 | /** |
---|
119 | * @cfg {Boolean} border |
---|
120 | * @hide |
---|
121 | */ |
---|
122 | /** |
---|
123 | * @cfg {Boolean/Number} bufferResize |
---|
124 | * @hide |
---|
125 | */ |
---|
126 | /** |
---|
127 | * @cfg {String} buttonAlign |
---|
128 | * @hide |
---|
129 | */ |
---|
130 | /** |
---|
131 | * @cfg {Array} buttons |
---|
132 | * @hide |
---|
133 | */ |
---|
134 | /** |
---|
135 | * @cfg {Boolean} collapseFirst |
---|
136 | * @hide |
---|
137 | */ |
---|
138 | /** |
---|
139 | * @cfg {String} defaultType |
---|
140 | * @hide |
---|
141 | */ |
---|
142 | /** |
---|
143 | * @cfg {String} disabledClass |
---|
144 | * @hide |
---|
145 | */ |
---|
146 | /** |
---|
147 | * @cfg {String} elements |
---|
148 | * @hide |
---|
149 | */ |
---|
150 | /** |
---|
151 | * @cfg {Boolean} floating |
---|
152 | * @hide |
---|
153 | */ |
---|
154 | /** |
---|
155 | * @cfg {Boolean} footer |
---|
156 | * @hide |
---|
157 | */ |
---|
158 | /** |
---|
159 | * @cfg {Boolean} frame |
---|
160 | * @hide |
---|
161 | */ |
---|
162 | /** |
---|
163 | * @cfg {Boolean} header |
---|
164 | * @hide |
---|
165 | */ |
---|
166 | /** |
---|
167 | * @cfg {Boolean} headerAsText |
---|
168 | * @hide |
---|
169 | */ |
---|
170 | /** |
---|
171 | * @cfg {Boolean} hideCollapseTool |
---|
172 | * @hide |
---|
173 | */ |
---|
174 | /** |
---|
175 | * @cfg {String} iconCls |
---|
176 | * @hide |
---|
177 | */ |
---|
178 | /** |
---|
179 | * @cfg {Boolean/String} shadow |
---|
180 | * @hide |
---|
181 | */ |
---|
182 | /** |
---|
183 | * @cfg {Number} shadowOffset |
---|
184 | * @hide |
---|
185 | */ |
---|
186 | /** |
---|
187 | * @cfg {Boolean} shim |
---|
188 | * @hide |
---|
189 | */ |
---|
190 | /** |
---|
191 | * @cfg {Object/Array} tbar |
---|
192 | * @hide |
---|
193 | */ |
---|
194 | /** |
---|
195 | * @cfg {Boolean} titleCollapse |
---|
196 | * @hide |
---|
197 | */ |
---|
198 | /** |
---|
199 | * @cfg {Array} tools |
---|
200 | * @hide |
---|
201 | */ |
---|
202 | /** |
---|
203 | * @cfg {String} xtype |
---|
204 | * @hide |
---|
205 | */ |
---|
206 | /** |
---|
207 | * @property header |
---|
208 | * @hide |
---|
209 | */ |
---|
210 | /** |
---|
211 | * @property footer |
---|
212 | * @hide |
---|
213 | */ |
---|
214 | /** |
---|
215 | * @method focus |
---|
216 | * @hide |
---|
217 | */ |
---|
218 | /** |
---|
219 | * @method getBottomToolbar |
---|
220 | * @hide |
---|
221 | */ |
---|
222 | /** |
---|
223 | * @method getTopToolbar |
---|
224 | * @hide |
---|
225 | */ |
---|
226 | /** |
---|
227 | * @method setIconClass |
---|
228 | * @hide |
---|
229 | */ |
---|
230 | /** |
---|
231 | * @event activate |
---|
232 | * @hide |
---|
233 | */ |
---|
234 | /** |
---|
235 | * @event beforeclose |
---|
236 | * @hide |
---|
237 | */ |
---|
238 | /** |
---|
239 | * @event bodyresize |
---|
240 | * @hide |
---|
241 | */ |
---|
242 | /** |
---|
243 | * @event close |
---|
244 | * @hide |
---|
245 | */ |
---|
246 | /** |
---|
247 | * @event deactivate |
---|
248 | * @hide |
---|
249 | */ |
---|
250 | }); |
---|
251 | Ext.reg('fieldset', Ext.form.FieldSet); |
---|
252 | |
---|