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.

116 lines
4.8 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-layout-MenuLayout'>/**
  19. </span> * @class Ext.layout.MenuLayout
  20. * @extends Ext.layout.ContainerLayout
  21. * &lt;p&gt;Layout manager used by {@link Ext.menu.Menu}. Generally this class should not need to be used directly.&lt;/p&gt;
  22. */
  23. Ext.layout.MenuLayout = Ext.extend(Ext.layout.ContainerLayout, {
  24. <span id='Ext-layout-MenuLayout-property-monitorResize'> monitorResize : true,
  25. </span>
  26. <span id='Ext-layout-MenuLayout-property-type'> type: 'menu',
  27. </span>
  28. <span id='Ext-layout-MenuLayout-method-setContainer'> setContainer : function(ct){
  29. </span> this.monitorResize = !ct.floating;
  30. // This event is only fired by the menu in IE, used so we don't couple
  31. // the menu with the layout.
  32. ct.on('autosize', this.doAutoSize, this);
  33. Ext.layout.MenuLayout.superclass.setContainer.call(this, ct);
  34. },
  35. <span id='Ext-layout-MenuLayout-method-renderItem'> renderItem : function(c, position, target){
  36. </span> if (!this.itemTpl) {
  37. this.itemTpl = Ext.layout.MenuLayout.prototype.itemTpl = new Ext.XTemplate(
  38. '&lt;li id=&quot;{itemId}&quot; class=&quot;{itemCls}&quot;&gt;',
  39. '&lt;tpl if=&quot;needsIcon&quot;&gt;',
  40. '&lt;img alt=&quot;{altText}&quot; src=&quot;{icon}&quot; class=&quot;{iconCls}&quot;/&gt;',
  41. '&lt;/tpl&gt;',
  42. '&lt;/li&gt;'
  43. );
  44. }
  45. if(c &amp;&amp; !c.rendered){
  46. if(Ext.isNumber(position)){
  47. position = target.dom.childNodes[position];
  48. }
  49. var a = this.getItemArgs(c);
  50. // The Component's positionEl is the &lt;li&gt; it is rendered into
  51. c.render(c.positionEl = position ?
  52. this.itemTpl.insertBefore(position, a, true) :
  53. this.itemTpl.append(target, a, true));
  54. // Link the containing &lt;li&gt; to the item.
  55. c.positionEl.menuItemId = c.getItemId();
  56. // If rendering a regular Component, and it needs an icon,
  57. // move the Component rightwards.
  58. if (!a.isMenuItem &amp;&amp; a.needsIcon) {
  59. c.positionEl.addClass('x-menu-list-item-indent');
  60. }
  61. this.configureItem(c);
  62. }else if(c &amp;&amp; !this.isValidParent(c, target)){
  63. if(Ext.isNumber(position)){
  64. position = target.dom.childNodes[position];
  65. }
  66. target.dom.insertBefore(c.getActionEl().dom, position || null);
  67. }
  68. },
  69. <span id='Ext-layout-MenuLayout-method-getItemArgs'> getItemArgs : function(c) {
  70. </span> var isMenuItem = c instanceof Ext.menu.Item,
  71. canHaveIcon = !(isMenuItem || c instanceof Ext.menu.Separator);
  72. return {
  73. isMenuItem: isMenuItem,
  74. needsIcon: canHaveIcon &amp;&amp; (c.icon || c.iconCls),
  75. icon: c.icon || Ext.BLANK_IMAGE_URL,
  76. iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
  77. itemId: 'x-menu-el-' + c.id,
  78. itemCls: 'x-menu-list-item ',
  79. altText: c.altText || ''
  80. };
  81. },
  82. <span id='Ext-layout-MenuLayout-method-isValidParent'> // Valid if the Component is in a &lt;li&gt; which is part of our target &lt;ul&gt;
  83. </span> isValidParent : function(c, target) {
  84. return c.el.up('li.x-menu-list-item', 5).dom.parentNode === (target.dom || target);
  85. },
  86. <span id='Ext-layout-MenuLayout-method-onLayout'> onLayout : function(ct, target){
  87. </span> Ext.layout.MenuLayout.superclass.onLayout.call(this, ct, target);
  88. this.doAutoSize();
  89. },
  90. <span id='Ext-layout-MenuLayout-method-doAutoSize'> doAutoSize : function(){
  91. </span> var ct = this.container, w = ct.width;
  92. if(ct.floating){
  93. if(w){
  94. ct.setWidth(w);
  95. }else if(Ext.isIE9m){
  96. ct.setWidth(Ext.isStrict &amp;&amp; (Ext.isIE7 || Ext.isIE8 || Ext.isIE9) ? 'auto' : ct.minWidth);
  97. var el = ct.getEl(), t = el.dom.offsetWidth; // force recalc
  98. ct.setWidth(ct.getLayoutTarget().getWidth() + el.getFrameWidth('lr'));
  99. }
  100. }
  101. }
  102. });
  103. Ext.Container.LAYOUTS['menu'] = Ext.layout.MenuLayout;
  104. </pre>
  105. </body>
  106. </html>