You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.5 KiB

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