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.

130 lines
5.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-menu-CheckItem-method-constructor'><span id='Ext-menu-CheckItem'>/**
  19. </span></span> * @class Ext.menu.CheckItem
  20. * @extends Ext.menu.Item
  21. * Adds a menu item that contains a checkbox by default, but can also be part of a radio group.
  22. * @constructor
  23. * Creates a new CheckItem
  24. * @param {Object} config Configuration options
  25. * @xtype menucheckitem
  26. */
  27. Ext.menu.CheckItem = Ext.extend(Ext.menu.Item, {
  28. <span id='Ext-menu-CheckItem-cfg-group'> /**
  29. </span> * @cfg {String} group
  30. * All check items with the same group name will automatically be grouped into a single-select
  31. * radio button group (defaults to '')
  32. */
  33. <span id='Ext-menu-CheckItem-cfg-itemCls'> /**
  34. </span> * @cfg {String} itemCls The default CSS class to use for check items (defaults to &quot;x-menu-item x-menu-check-item&quot;)
  35. */
  36. itemCls : &quot;x-menu-item x-menu-check-item&quot;,
  37. <span id='Ext-menu-CheckItem-cfg-groupClass'> /**
  38. </span> * @cfg {String} groupClass The default CSS class to use for radio group check items (defaults to &quot;x-menu-group-item&quot;)
  39. */
  40. groupClass : &quot;x-menu-group-item&quot;,
  41. <span id='Ext-menu-CheckItem-cfg-checked'> /**
  42. </span> * @cfg {Boolean} checked True to initialize this checkbox as checked (defaults to false). Note that
  43. * if this checkbox is part of a radio group (group = true) only the first item in the group that is
  44. * initialized with checked = true will be rendered as checked.
  45. */
  46. checked: false,
  47. <span id='Ext-menu-CheckItem-property-ctype'> // private
  48. </span> ctype: &quot;Ext.menu.CheckItem&quot;,
  49. <span id='Ext-menu-CheckItem-method-initComponent'> initComponent : function(){
  50. </span> Ext.menu.CheckItem.superclass.initComponent.call(this);
  51. this.addEvents(
  52. <span id='Ext-menu-CheckItem-event-beforecheckchange'> /**
  53. </span> * @event beforecheckchange
  54. * Fires before the checked value is set, providing an opportunity to cancel if needed
  55. * @param {Ext.menu.CheckItem} this
  56. * @param {Boolean} checked The new checked value that will be set
  57. */
  58. &quot;beforecheckchange&quot; ,
  59. <span id='Ext-menu-CheckItem-event-checkchange'> /**
  60. </span> * @event checkchange
  61. * Fires after the checked value has been set
  62. * @param {Ext.menu.CheckItem} this
  63. * @param {Boolean} checked The checked value that was set
  64. */
  65. &quot;checkchange&quot;
  66. );
  67. <span id='Ext-menu-CheckItem-method-checkHandler'> /**
  68. </span> * A function that handles the checkchange event. The function is undefined by default, but if an implementation
  69. * is provided, it will be called automatically when the checkchange event fires.
  70. * @param {Ext.menu.CheckItem} this
  71. * @param {Boolean} checked The checked value that was set
  72. * @method checkHandler
  73. */
  74. if(this.checkHandler){
  75. this.on('checkchange', this.checkHandler, this.scope);
  76. }
  77. Ext.menu.MenuMgr.registerCheckable(this);
  78. },
  79. <span id='Ext-menu-CheckItem-method-onRender'> // private
  80. </span> onRender : function(c){
  81. Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);
  82. if(this.group){
  83. this.el.addClass(this.groupClass);
  84. }
  85. if(this.checked){
  86. this.checked = false;
  87. this.setChecked(true, true);
  88. }
  89. },
  90. <span id='Ext-menu-CheckItem-method-destroy'> // private
  91. </span> destroy : function(){
  92. Ext.menu.MenuMgr.unregisterCheckable(this);
  93. Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);
  94. },
  95. <span id='Ext-menu-CheckItem-method-setChecked'> /**
  96. </span> * Set the checked state of this item
  97. * @param {Boolean} checked The new checked value
  98. * @param {Boolean} suppressEvent (optional) True to prevent the checkchange event from firing (defaults to false)
  99. */
  100. setChecked : function(state, suppressEvent){
  101. var suppress = suppressEvent === true;
  102. if(this.checked != state &amp;&amp; (suppress || this.fireEvent(&quot;beforecheckchange&quot;, this, state) !== false)){
  103. Ext.menu.MenuMgr.onCheckChange(this, state);
  104. if(this.container){
  105. this.container[state ? &quot;addClass&quot; : &quot;removeClass&quot;](&quot;x-menu-item-checked&quot;);
  106. }
  107. this.checked = state;
  108. if(!suppress){
  109. this.fireEvent(&quot;checkchange&quot;, this, state);
  110. }
  111. }
  112. },
  113. <span id='Ext-menu-CheckItem-method-handleClick'> // private
  114. </span> handleClick : function(e){
  115. if(!this.disabled &amp;&amp; !(this.checked &amp;&amp; this.group)){// disable unselect on radio item
  116. this.setChecked(!this.checked);
  117. }
  118. Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
  119. }
  120. });
  121. Ext.reg('menucheckitem', Ext.menu.CheckItem);</pre>
  122. </body>
  123. </html>