Web UI for ARGUS server
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.

112 lines
4.0 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.layout.MenuLayout"></div>/**
  16. * @class Ext.layout.MenuLayout
  17. * @extends Ext.layout.ContainerLayout
  18. * <p>Layout manager used by {@link Ext.menu.Menu}. Generally this class should not need to be used directly.</p>
  19. */
  20. Ext.layout.MenuLayout = Ext.extend(Ext.layout.ContainerLayout, {
  21. monitorResize : true,
  22. type: 'menu',
  23. setContainer : function(ct){
  24. this.monitorResize = !ct.floating;
  25. // This event is only fired by the menu in IE, used so we don't couple
  26. // the menu with the layout.
  27. ct.on('autosize', this.doAutoSize, this);
  28. Ext.layout.MenuLayout.superclass.setContainer.call(this, ct);
  29. },
  30. renderItem : function(c, position, target){
  31. if (!this.itemTpl) {
  32. this.itemTpl = Ext.layout.MenuLayout.prototype.itemTpl = new Ext.XTemplate(
  33. '<li id="{itemId}" class="{itemCls}">',
  34. '<tpl if="needsIcon">',
  35. '<img alt="{altText}" src="{icon}" class="{iconCls}"/>',
  36. '</tpl>',
  37. '</li>'
  38. );
  39. }
  40. if(c && !c.rendered){
  41. if(Ext.isNumber(position)){
  42. position = target.dom.childNodes[position];
  43. }
  44. var a = this.getItemArgs(c);
  45. // The Component's positionEl is the <li> it is rendered into
  46. c.render(c.positionEl = position ?
  47. this.itemTpl.insertBefore(position, a, true) :
  48. this.itemTpl.append(target, a, true));
  49. // Link the containing <li> to the item.
  50. c.positionEl.menuItemId = c.getItemId();
  51. // If rendering a regular Component, and it needs an icon,
  52. // move the Component rightwards.
  53. if (!a.isMenuItem && a.needsIcon) {
  54. c.positionEl.addClass('x-menu-list-item-indent');
  55. }
  56. this.configureItem(c);
  57. }else if(c && !this.isValidParent(c, target)){
  58. if(Ext.isNumber(position)){
  59. position = target.dom.childNodes[position];
  60. }
  61. target.dom.insertBefore(c.getActionEl().dom, position || null);
  62. }
  63. },
  64. getItemArgs : function(c) {
  65. var isMenuItem = c instanceof Ext.menu.Item,
  66. canHaveIcon = !(isMenuItem || c instanceof Ext.menu.Separator);
  67. return {
  68. isMenuItem: isMenuItem,
  69. needsIcon: canHaveIcon && (c.icon || c.iconCls),
  70. icon: c.icon || Ext.BLANK_IMAGE_URL,
  71. iconCls: 'x-menu-item-icon ' + (c.iconCls || ''),
  72. itemId: 'x-menu-el-' + c.id,
  73. itemCls: 'x-menu-list-item ',
  74. altText: c.altText || ''
  75. };
  76. },
  77. // Valid if the Component is in a <li> which is part of our target <ul>
  78. isValidParent : function(c, target) {
  79. return c.el.up('li.x-menu-list-item', 5).dom.parentNode === (target.dom || target);
  80. },
  81. onLayout : function(ct, target){
  82. Ext.layout.MenuLayout.superclass.onLayout.call(this, ct, target);
  83. this.doAutoSize();
  84. },
  85. doAutoSize : function(){
  86. var ct = this.container, w = ct.width;
  87. if(ct.floating){
  88. if(w){
  89. ct.setWidth(w);
  90. }else if(Ext.isIE){
  91. ct.setWidth(Ext.isStrict && (Ext.isIE7 || Ext.isIE8) ? 'auto' : ct.minWidth);
  92. var el = ct.getEl(), t = el.dom.offsetWidth; // force recalc
  93. ct.setWidth(ct.getLayoutTarget().getWidth() + el.getFrameWidth('lr'));
  94. }
  95. }
  96. }
  97. });
  98. Ext.Container.LAYOUTS['menu'] = Ext.layout.MenuLayout;
  99. </pre>
  100. </body>
  101. </html>