Split.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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-button-Split'>/**
  19. </span> * A split button that provides a built-in dropdown arrow that can fire an event separately from the default click event
  20. * of the button. Typically this would be used to display a dropdown menu that provides additional options to the
  21. * primary button action, but any custom handler can provide the arrowclick implementation. Example usage:
  22. *
  23. * @example
  24. * // display a dropdown menu:
  25. * Ext.create('Ext.button.Split', {
  26. * renderTo: Ext.getBody(),
  27. * text: 'Options',
  28. * // handle a click on the button itself
  29. * handler: function() {
  30. * alert(&quot;The button was clicked&quot;);
  31. * },
  32. * menu: new Ext.menu.Menu({
  33. * items: [
  34. * // these will render as dropdown menu items when the arrow is clicked:
  35. * {text: 'Item 1', handler: function(){ alert(&quot;Item 1 clicked&quot;); }},
  36. * {text: 'Item 2', handler: function(){ alert(&quot;Item 2 clicked&quot;); }}
  37. * ]
  38. * })
  39. * });
  40. *
  41. * Instead of showing a menu, you can provide any type of custom functionality you want when the dropdown
  42. * arrow is clicked:
  43. *
  44. * Ext.create('Ext.button.Split', {
  45. * renderTo: 'button-ct',
  46. * text: 'Options',
  47. * handler: optionsHandler,
  48. * arrowHandler: myCustomHandler
  49. * });
  50. *
  51. */
  52. Ext.define('Ext.button.Split', {
  53. /* Begin Definitions */
  54. alias: 'widget.splitbutton',
  55. extend: 'Ext.button.Button',
  56. alternateClassName: 'Ext.SplitButton',
  57. /* End Definitions */
  58. <span id='Ext-button-Split-cfg-arrowHandler'> /**
  59. </span> * @cfg {Function} arrowHandler
  60. * A function called when the arrow button is clicked (can be used instead of click event)
  61. * @cfg {Ext.button.Split} arrowHandler.this
  62. * @cfg {Event} arrowHandler.e The click event
  63. */
  64. <span id='Ext-button-Split-cfg-arrowTooltip'> /**
  65. </span> * @cfg {String} arrowTooltip
  66. * The title attribute of the arrow
  67. */
  68. // private
  69. arrowCls : 'split',
  70. split : true,
  71. // private
  72. initComponent : function(){
  73. this.callParent();
  74. <span id='Ext-button-Split-event-arrowclick'> /**
  75. </span> * @event arrowclick
  76. * Fires when this button's arrow is clicked.
  77. * @param {Ext.button.Split} this
  78. * @param {Event} e The click event
  79. */
  80. this.addEvents(&quot;arrowclick&quot;);
  81. },
  82. <span id='Ext-button-Split-method-setArrowHandler'> /**
  83. </span> * Sets this button's arrow click handler.
  84. * @param {Function} handler The function to call when the arrow is clicked
  85. * @param {Object} scope (optional) Scope for the function passed above
  86. */
  87. setArrowHandler : function(handler, scope){
  88. this.arrowHandler = handler;
  89. this.scope = scope;
  90. },
  91. // private
  92. onClick : function(e, t) {
  93. var me = this;
  94. e.preventDefault();
  95. if (!me.disabled) {
  96. if (me.overMenuTrigger) {
  97. me.maybeShowMenu();
  98. me.fireEvent(&quot;arrowclick&quot;, me, e);
  99. if (me.arrowHandler) {
  100. me.arrowHandler.call(me.scope || me, me, e);
  101. }
  102. } else {
  103. me.doToggle();
  104. me.fireHandler(e);
  105. }
  106. }
  107. }
  108. });</pre>
  109. </body>
  110. </html>