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.

136 lines
4.6 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-RadioGroup-method-constructor'><span id='Ext-form-RadioGroup'>/**
  19. </span></span> * @class Ext.form.RadioGroup
  20. * @extends Ext.form.CheckboxGroup
  21. * A grouping container for {@link Ext.form.Radio} controls.
  22. * @constructor
  23. * Creates a new RadioGroup
  24. * @param {Object} config Configuration options
  25. * @xtype radiogroup
  26. */
  27. Ext.form.RadioGroup = Ext.extend(Ext.form.CheckboxGroup, {
  28. <span id='Ext-form-RadioGroup-cfg-items'> /**
  29. </span> * @cfg {Array} items An Array of {@link Ext.form.Radio Radio}s or Radio config objects
  30. * to arrange in the group.
  31. */
  32. <span id='Ext-form-RadioGroup-cfg-allowBlank'> /**
  33. </span> * @cfg {Boolean} allowBlank True to allow every item in the group to be blank (defaults to true).
  34. * If allowBlank = false and no items are selected at validation time, {@link @blankText} will
  35. * be used as the error text.
  36. */
  37. allowBlank : true,
  38. <span id='Ext-form-RadioGroup-cfg-blankText'> /**
  39. </span> * @cfg {String} blankText Error text to display if the {@link #allowBlank} validation fails
  40. * (defaults to 'You must select one item in this group')
  41. */
  42. blankText : 'You must select one item in this group',
  43. <span id='Ext-form-RadioGroup-property-defaultType'> // private
  44. </span> defaultType : 'radio',
  45. <span id='Ext-form-RadioGroup-property-groupCls'> // private
  46. </span> groupCls : 'x-form-radio-group',
  47. <span id='Ext-form-RadioGroup-event-change'> /**
  48. </span> * @event change
  49. * Fires when the state of a child radio changes.
  50. * @param {Ext.form.RadioGroup} this
  51. * @param {Ext.form.Radio} checked The checked radio
  52. */
  53. <span id='Ext-form-RadioGroup-method-getValue'> /**
  54. </span> * Gets the selected {@link Ext.form.Radio} in the group, if it exists.
  55. * @return {Ext.form.Radio} The selected radio.
  56. */
  57. getValue : function(){
  58. var out = null;
  59. this.eachItem(function(item){
  60. if(item.checked){
  61. out = item;
  62. return false;
  63. }
  64. });
  65. return out;
  66. },
  67. <span id='Ext-form-RadioGroup-method-onSetValue'> /**
  68. </span> * Sets the checked radio in the group.
  69. * @param {String/Ext.form.Radio} id The radio to check.
  70. * @param {Boolean} value The value to set the radio.
  71. * @return {Ext.form.RadioGroup} this
  72. */
  73. onSetValue : function(id, value){
  74. if(arguments.length &gt; 1){
  75. var f = this.getBox(id);
  76. if(f){
  77. f.setValue(value);
  78. if(f.checked){
  79. this.eachItem(function(item){
  80. if (item !== f){
  81. item.setValue(false);
  82. }
  83. });
  84. }
  85. }
  86. }else{
  87. this.setValueForItem(id);
  88. }
  89. },
  90. <span id='Ext-form-RadioGroup-method-setValueForItem'> setValueForItem : function(val){
  91. </span> val = String(val).split(',')[0];
  92. this.eachItem(function(item){
  93. item.setValue(val == item.inputValue);
  94. });
  95. },
  96. <span id='Ext-form-RadioGroup-method-fireChecked'> // private
  97. </span> fireChecked : function(){
  98. if(!this.checkTask){
  99. this.checkTask = new Ext.util.DelayedTask(this.bufferChecked, this);
  100. }
  101. this.checkTask.delay(10);
  102. },
  103. <span id='Ext-form-RadioGroup-method-bufferChecked'> // private
  104. </span> bufferChecked : function(){
  105. var out = null;
  106. this.eachItem(function(item){
  107. if(item.checked){
  108. out = item;
  109. return false;
  110. }
  111. });
  112. this.fireEvent('change', this, out);
  113. },
  114. <span id='Ext-form-RadioGroup-method-onDestroy'> onDestroy : function(){
  115. </span> if(this.checkTask){
  116. this.checkTask.cancel();
  117. this.checkTask = null;
  118. }
  119. Ext.form.RadioGroup.superclass.onDestroy.call(this);
  120. }
  121. });
  122. Ext.reg('radiogroup', Ext.form.RadioGroup);
  123. </pre>
  124. </body>
  125. </html>