-Ext.form.Checkbox = Ext.extend(Ext.form.Field, {
- <div id="cfg-Ext.form.Checkbox-focusClass"></div>/**
- * @cfg {String} focusClass The CSS class to use when the checkbox receives focus (defaults to undefined)
- */
- focusClass : undefined,
- <div id="cfg-Ext.form.Checkbox-fieldClass"></div>/**
- * @cfg {String} fieldClass The default CSS class for the checkbox (defaults to 'x-form-field')
- */
- fieldClass : 'x-form-field',
- <div id="cfg-Ext.form.Checkbox-checked"></div>/**
- * @cfg {Boolean} checked <tt>true</tt> if the checkbox should render initially checked (defaults to <tt>false</tt>)
- */
- checked : false,
- <div id="cfg-Ext.form.Checkbox-boxLabel"></div>/**
- * @cfg {String} boxLabel The text that appears beside the checkbox
- */
- boxLabel: ' ',
- <div id="cfg-Ext.form.Checkbox-autoCreate"></div>/**
- * @cfg {String/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to
- * {tag: 'input', type: 'checkbox', autocomplete: 'off'})
- */
- defaultAutoCreate : { tag: 'input', type: 'checkbox', autocomplete: 'off'},
- <div id="cfg-Ext.form.Checkbox-boxLabel"></div>/**
- * @cfg {String} boxLabel The text that appears beside the checkbox
- */
- <div id="cfg-Ext.form.Checkbox-inputValue"></div>/**
- * @cfg {String} inputValue The value that should go into the generated input element's value attribute
- */
- <div id="cfg-Ext.form.Checkbox-handler"></div>/**
- * @cfg {Function} handler A function called when the {@link #checked} value changes (can be used instead of
- * handling the check event). The handler is passed the following parameters:
- * <div class="mdetail-params"><ul>
- * <li><b>checkbox</b> : Ext.form.Checkbox<div class="sub-desc">The Checkbox being toggled.</div></li>
- * <li><b>checked</b> : Boolean<div class="sub-desc">The new checked state of the checkbox.</div></li>
- * </ul></div>
- */
- <div id="cfg-Ext.form.Checkbox-scope"></div>/**
- * @cfg {Object} scope An object to use as the scope ('this' reference) of the {@link #handler} function
+Ext.define('Ext.form.field.Checkbox', {
+ extend: 'Ext.form.field.Base',
+ alias: ['widget.checkboxfield', 'widget.checkbox'],
+ alternateClassName: 'Ext.form.Checkbox',
+ requires: ['Ext.XTemplate', 'Ext.form.CheckboxManager'],
+
+ fieldSubTpl: [
+ '<tpl if="boxLabel && boxLabelAlign == \'before\'">',
+ '<label class="{boxLabelCls} {boxLabelCls}-{boxLabelAlign}" for="{id}">{boxLabel}</label>',
+ '</tpl>',
+ // Creates not an actual checkbox, but a button which is given aria role="checkbox" and
+ // styled with a custom checkbox image. This allows greater control and consistency in
+ // styling, and using a button allows it to gain focus and handle keyboard nav properly.
+ '<input type="button" id="{id}" ',
+ '<tpl if="tabIdx">tabIndex="{tabIdx}" </tpl>',
+ 'class="{fieldCls} {typeCls}" autocomplete="off" hidefocus="true" />',
+ '<tpl if="boxLabel && boxLabelAlign == \'after\'">',
+ '<label class="{boxLabelCls} {boxLabelCls}-{boxLabelAlign}" for="{id}">{boxLabel}</label>',
+ '</tpl>',
+ {
+ disableFormats: true,
+ compiled: true
+ }
+ ],
+
+ isCheckbox: true,
+
+<span id='Ext-form-field-Checkbox-cfg-focusCls'> /**
+</span> * @cfg {String} focusCls The CSS class to use when the checkbox receives focus
+ * (defaults to <tt>'x-form-cb-focus'</tt>)
+ */
+ focusCls: Ext.baseCSSPrefix + 'form-cb-focus',
+
+<span id='Ext-form-field-Checkbox-cfg-fieldCls'> /**
+</span> * @cfg {String} fieldCls The default CSS class for the checkbox (defaults to <tt>'x-form-field'</tt>)
+ */
+
+<span id='Ext-form-field-Checkbox-cfg-fieldBodyCls'> /**
+</span> * @cfg {String} fieldBodyCls
+ * An extra CSS class to be applied to the body content element in addition to {@link #fieldBodyCls}.
+ * Defaults to 'x-form-cb-wrap.
+ */
+ fieldBodyCls: Ext.baseCSSPrefix + 'form-cb-wrap',
+
+<span id='Ext-form-field-Checkbox-cfg-checked'> /**
+</span> * @cfg {Boolean} checked <tt>true</tt> if the checkbox should render initially checked (defaults to <tt>false</tt>)
+ */
+ checked: false,
+
+<span id='Ext-form-field-Checkbox-cfg-checkedCls'> /**
+</span> * @cfg {String} checkedCls The CSS class added to the component's main element when it is in the checked state.
+ */
+ checkedCls: Ext.baseCSSPrefix + 'form-cb-checked',
+
+<span id='Ext-form-field-Checkbox-cfg-boxLabel'> /**
+</span> * @cfg {String} boxLabel An optional text label that will appear next to the checkbox. Whether it appears before
+ * or after the checkbox is determined by the {@link #boxLabelAlign} config (defaults to after).
+ */
+
+<span id='Ext-form-field-Checkbox-cfg-boxLabelCls'> /**
+</span> * @cfg {String} boxLabelCls The CSS class to be applied to the {@link #boxLabel} element
+ */
+ boxLabelCls: Ext.baseCSSPrefix + 'form-cb-label',
+
+<span id='Ext-form-field-Checkbox-cfg-boxLabelAlign'> /**
+</span> * @cfg {String} boxLabelAlign The position relative to the checkbox where the {@link #boxLabel} should
+ * appear. Recognized values are <tt>'before'</tt> and <tt>'after'</tt>. Defaults to <tt>'after'</tt>.
+ */
+ boxLabelAlign: 'after',
+
+<span id='Ext-form-field-Checkbox-cfg-inputValue'> /**
+</span> * @cfg {String} inputValue The value that should go into the generated input element's value attribute and
+ * should be used as the parameter value when submitting as part of a form. Defaults to <tt>"on"</tt>.
+ */
+ inputValue: 'on',
+
+<span id='Ext-form-field-Checkbox-cfg-uncheckedValue'> /**
+</span> * @cfg {String} uncheckedValue If configured, this will be submitted as the checkbox's value during form
+ * submit if the checkbox is unchecked. By default this is undefined, which results in nothing being
+ * submitted for the checkbox field when the form is submitted (the default behavior of HTML checkboxes).
+ */
+
+<span id='Ext-form-field-Checkbox-cfg-handler'> /**
+</span> * @cfg {Function} handler A function called when the {@link #checked} value changes (can be used instead of
+ * handling the {@link #change change event}). The handler is passed the following parameters:
+ * <div class="mdetail-params"><ul>
+ * <li><b>checkbox</b> : Ext.form.field.Checkbox<div class="sub-desc">The Checkbox being toggled.</div></li>
+ * <li><b>checked</b> : Boolean<div class="sub-desc">The new checked state of the checkbox.</div></li>
+ * </ul></div>
+ */
+
+<span id='Ext-form-field-Checkbox-cfg-scope'> /**
+</span> * @cfg {Object} scope An object to use as the scope ('this' reference) of the {@link #handler} function