1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
* Ext JS Library 3.4.0
* Copyright(c) 2006-2011 Sencha Inc.
* licensing@sencha.com
* http://www.sencha.com/license
*/
<div id="cls-Ext.form.Radio"></div>/**
* @class Ext.form.Radio
* @extends Ext.form.Checkbox
* Single radio field. Same as Checkbox, but provided as a convenience for automatically setting the input type.
* Radio grouping is handled automatically by the browser if you give each radio in a group the same name.
* @constructor
* Creates a new Radio
* @param {Object} config Configuration options
* @xtype radio
*/
Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
inputType: 'radio',
<div id="method-Ext.form.Radio-markInvalid"></div>/**
* Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
* @method
*/
markInvalid : Ext.emptyFn,
<div id="method-Ext.form.Radio-clearInvalid"></div>/**
* Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
* @method
*/
clearInvalid : Ext.emptyFn,
<div id="method-Ext.form.Radio-getGroupValue"></div>/**
* If this radio is part of a group, it will return the selected value
* @return {String}
*/
getGroupValue : function(){
var p = this.el.up('form') || Ext.getBody();
var c = p.child('input[name="'+this.el.dom.name+'"]:checked', true);
return c ? c.value : null;
},
<div id="method-Ext.form.Radio-setValue"></div>/**
* Sets either the checked/unchecked status of this Radio, or, if a string value
* is passed, checks a sibling Radio of the same name whose value is the value specified.
* @param value {String/Boolean} Checked value, or the value of the sibling radio button to check.
* @return {Ext.form.Field} this
*/
setValue : function(v){
var checkEl,
els,
radio;
if (typeof v == 'boolean') {
Ext.form.Radio.superclass.setValue.call(this, v);
} else if (this.rendered) {
checkEl = this.getCheckEl();
radio = checkEl.child('input[name="' + this.el.dom.name + '"][value="' + v + '"]', true);
if(radio){
Ext.getCmp(radio.id).setValue(true);
}
}
if(this.rendered && this.checked){
checkEl = checkEl || this.getCheckEl();
els = this.getCheckEl().select('input[name="' + this.el.dom.name + '"]');
els.each(function(el){
if(el.dom.id != this.id){
Ext.getCmp(el.dom.id).setValue(false);
}
}, this);
}
return this;
},
// private
getCheckEl: function(){
if(this.inGroup){
return this.el.up('.x-form-radio-group');
}
return this.el.up('form') || Ext.getBody();
}
});
Ext.reg('radio', Ext.form.Radio);
</pre>
</body>
</html>
|