Web Interface For Lite Argus Control modules
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.

157 lines
6.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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.CardLayout"></div>/**
  16. * @class Ext.layout.CardLayout
  17. * @extends Ext.layout.FitLayout
  18. * <p>This layout manages multiple child Components, each fitted to the Container, where only a single child Component can be
  19. * visible at any given time. This layout style is most commonly used for wizards, tab implementations, etc.
  20. * This class is intended to be extended or created via the layout:'card' {@link Ext.Container#layout} config,
  21. * and should generally not need to be created directly via the new keyword.</p>
  22. * <p>The CardLayout's focal method is {@link #setActiveItem}. Since only one panel is displayed at a time,
  23. * the only way to move from one Component to the next is by calling setActiveItem, passing the id or index of
  24. * the next panel to display. The layout itself does not provide a user interface for handling this navigation,
  25. * so that functionality must be provided by the developer.</p>
  26. * <p>In the following example, a simplistic wizard setup is demonstrated. A button bar is added
  27. * to the footer of the containing panel to provide navigation buttons. The buttons will be handled by a
  28. * common navigation routine -- for this example, the implementation of that routine has been ommitted since
  29. * it can be any type of custom logic. Note that other uses of a CardLayout (like a tab control) would require a
  30. * completely different implementation. For serious implementations, a better approach would be to extend
  31. * CardLayout to provide the custom functionality needed. Example usage:</p>
  32. * <pre><code>
  33. var navHandler = function(direction){
  34. // This routine could contain business logic required to manage the navigation steps.
  35. // It would call setActiveItem as needed, manage navigation button state, handle any
  36. // branching logic that might be required, handle alternate actions like cancellation
  37. // or finalization, etc. A complete wizard implementation could get pretty
  38. // sophisticated depending on the complexity required, and should probably be
  39. // done as a subclass of CardLayout in a real-world implementation.
  40. };
  41. var card = new Ext.Panel({
  42. title: 'Example Wizard',
  43. layout:'card',
  44. activeItem: 0, // make sure the active item is set on the container config!
  45. bodyStyle: 'padding:15px',
  46. defaults: {
  47. // applied to each contained panel
  48. border:false
  49. },
  50. // just an example of one possible navigation scheme, using buttons
  51. bbar: [
  52. {
  53. id: 'move-prev',
  54. text: 'Back',
  55. handler: navHandler.createDelegate(this, [-1]),
  56. disabled: true
  57. },
  58. '->', // greedy spacer so that the buttons are aligned to each side
  59. {
  60. id: 'move-next',
  61. text: 'Next',
  62. handler: navHandler.createDelegate(this, [1])
  63. }
  64. ],
  65. // the panels (or "cards") within the layout
  66. items: [{
  67. id: 'card-0',
  68. html: '&lt;h1&gt;Welcome to the Wizard!&lt;/h1&gt;&lt;p&gt;Step 1 of 3&lt;/p&gt;'
  69. },{
  70. id: 'card-1',
  71. html: '&lt;p&gt;Step 2 of 3&lt;/p&gt;'
  72. },{
  73. id: 'card-2',
  74. html: '&lt;h1&gt;Congratulations!&lt;/h1&gt;&lt;p&gt;Step 3 of 3 - Complete&lt;/p&gt;'
  75. }]
  76. });
  77. </code></pre>
  78. */
  79. Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
  80. <div id="cfg-Ext.layout.CardLayout-deferredRender"></div>/**
  81. * @cfg {Boolean} deferredRender
  82. * True to render each contained item at the time it becomes active, false to render all contained items
  83. * as soon as the layout is rendered (defaults to false). If there is a significant amount of content or
  84. * a lot of heavy controls being rendered into panels that are not displayed by default, setting this to
  85. * true might improve performance.
  86. */
  87. deferredRender : false,
  88. <div id="cfg-Ext.layout.CardLayout-layoutOnCardChange"></div>/**
  89. * @cfg {Boolean} layoutOnCardChange
  90. * True to force a layout of the active item when the active card is changed. Defaults to false.
  91. */
  92. layoutOnCardChange : false,
  93. <div id="cfg-Ext.layout.CardLayout-renderHidden"></div>/**
  94. * @cfg {Boolean} renderHidden @hide
  95. */
  96. // private
  97. renderHidden : true,
  98. type: 'card',
  99. <div id="method-Ext.layout.CardLayout-setActiveItem"></div>/**
  100. * Sets the active (visible) item in the layout.
  101. * @param {String/Number} item The string component id or numeric index of the item to activate
  102. */
  103. setActiveItem : function(item){
  104. var ai = this.activeItem,
  105. ct = this.container;
  106. item = ct.getComponent(item);
  107. // Is this a valid, different card?
  108. if(item && ai != item){
  109. // Changing cards, hide the current one
  110. if(ai){
  111. ai.hide();
  112. if (ai.hidden !== true) {
  113. return false;
  114. }
  115. ai.fireEvent('deactivate', ai);
  116. }
  117. var layout = item.doLayout && (this.layoutOnCardChange || !item.rendered);
  118. // Change activeItem reference
  119. this.activeItem = item;
  120. // The container is about to get a recursive layout, remove any deferLayout reference
  121. // because it will trigger a redundant layout.
  122. delete item.deferLayout;
  123. // Show the new component
  124. item.show();
  125. this.layout();
  126. if(layout){
  127. item.doLayout();
  128. }
  129. item.fireEvent('activate', item);
  130. }
  131. },
  132. // private
  133. renderAll : function(ct, target){
  134. if(this.deferredRender){
  135. this.renderItem(this.activeItem, undefined, target);
  136. }else{
  137. Ext.layout.CardLayout.superclass.renderAll.call(this, ct, target);
  138. }
  139. }
  140. });
  141. Ext.Container.LAYOUTS['card'] = Ext.layout.CardLayout;
  142. </pre>
  143. </body>
  144. </html>