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.

222 lines
8.3 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-WindowGroup-method-constructor'><span id='Ext-WindowGroup'>/**
  19. </span></span> * @class Ext.WindowGroup
  20. * An object that manages a group of {@link Ext.Window} instances and provides z-order management
  21. * and window activation behavior.
  22. * @constructor
  23. */
  24. Ext.WindowGroup = function(){
  25. var list = {};
  26. var accessList = [];
  27. var front = null;
  28. // private
  29. var sortWindows = function(d1, d2){
  30. return (!d1._lastAccess || d1._lastAccess &lt; d2._lastAccess) ? -1 : 1;
  31. };
  32. // private
  33. var orderWindows = function(){
  34. var a = accessList, len = a.length;
  35. if(len &gt; 0){
  36. a.sort(sortWindows);
  37. var seed = a[0].manager.zseed;
  38. for(var i = 0; i &lt; len; i++){
  39. var win = a[i];
  40. if(win &amp;&amp; !win.hidden){
  41. win.setZIndex(seed + (i*10));
  42. }
  43. }
  44. }
  45. activateLast();
  46. };
  47. // private
  48. var setActiveWin = function(win){
  49. if(win != front){
  50. if(front){
  51. front.setActive(false);
  52. }
  53. front = win;
  54. if(win){
  55. win.setActive(true);
  56. }
  57. }
  58. };
  59. // private
  60. var activateLast = function(){
  61. for(var i = accessList.length-1; i &gt;=0; --i) {
  62. if(!accessList[i].hidden){
  63. setActiveWin(accessList[i]);
  64. return;
  65. }
  66. }
  67. // none to activate
  68. setActiveWin(null);
  69. };
  70. return {
  71. <span id='Ext-WindowGroup-property-zseed'> /**
  72. </span> * The starting z-index for windows in this WindowGroup (defaults to 9000)
  73. * @type Number The z-index value
  74. */
  75. zseed : 9000,
  76. <span id='Ext-WindowGroup-method-register'> /**
  77. </span> * &lt;p&gt;Registers a {@link Ext.Window Window} with this WindowManager. This should not
  78. * need to be called under normal circumstances. Windows are automatically registered
  79. * with a {@link Ext.Window#manager manager} at construction time.&lt;/p&gt;
  80. * &lt;p&gt;Where this may be useful is moving Windows between two WindowManagers. For example,
  81. * to bring the Ext.MessageBox dialog under the same manager as the Desktop's
  82. * WindowManager in the desktop sample app:&lt;/p&gt;&lt;code&gt;&lt;pre&gt;
  83. var msgWin = Ext.MessageBox.getDialog();
  84. MyDesktop.getDesktop().getManager().register(msgWin);
  85. &lt;/pre&gt;&lt;/code&gt;
  86. * @param {Window} win The Window to register.
  87. */
  88. register : function(win){
  89. if(win.manager){
  90. win.manager.unregister(win);
  91. }
  92. win.manager = this;
  93. list[win.id] = win;
  94. accessList.push(win);
  95. win.on('hide', activateLast);
  96. },
  97. <span id='Ext-WindowGroup-method-unregister'> /**
  98. </span> * &lt;p&gt;Unregisters a {@link Ext.Window Window} from this WindowManager. This should not
  99. * need to be called. Windows are automatically unregistered upon destruction.
  100. * See {@link #register}.&lt;/p&gt;
  101. * @param {Window} win The Window to unregister.
  102. */
  103. unregister : function(win){
  104. delete win.manager;
  105. delete list[win.id];
  106. win.un('hide', activateLast);
  107. accessList.remove(win);
  108. },
  109. <span id='Ext-WindowGroup-method-get'> /**
  110. </span> * Gets a registered window by id.
  111. * @param {String/Object} id The id of the window or a {@link Ext.Window} instance
  112. * @return {Ext.Window}
  113. */
  114. get : function(id){
  115. return typeof id == &quot;object&quot; ? id : list[id];
  116. },
  117. <span id='Ext-WindowGroup-method-bringToFront'> /**
  118. </span> * Brings the specified window to the front of any other active windows in this WindowGroup.
  119. * @param {String/Object} win The id of the window or a {@link Ext.Window} instance
  120. * @return {Boolean} True if the dialog was brought to the front, else false
  121. * if it was already in front
  122. */
  123. bringToFront : function(win){
  124. win = this.get(win);
  125. if(win != front){
  126. win._lastAccess = new Date().getTime();
  127. orderWindows();
  128. return true;
  129. }
  130. return false;
  131. },
  132. <span id='Ext-WindowGroup-method-sendToBack'> /**
  133. </span> * Sends the specified window to the back of other active windows in this WindowGroup.
  134. * @param {String/Object} win The id of the window or a {@link Ext.Window} instance
  135. * @return {Ext.Window} The window
  136. */
  137. sendToBack : function(win){
  138. win = this.get(win);
  139. win._lastAccess = -(new Date().getTime());
  140. orderWindows();
  141. return win;
  142. },
  143. <span id='Ext-WindowGroup-method-hideAll'> /**
  144. </span> * Hides all windows in this WindowGroup.
  145. */
  146. hideAll : function(){
  147. for(var id in list){
  148. if(list[id] &amp;&amp; typeof list[id] != &quot;function&quot; &amp;&amp; list[id].isVisible()){
  149. list[id].hide();
  150. }
  151. }
  152. },
  153. <span id='Ext-WindowGroup-method-getActive'> /**
  154. </span> * Gets the currently-active window in this WindowGroup.
  155. * @return {Ext.Window} The active window
  156. */
  157. getActive : function(){
  158. return front;
  159. },
  160. <span id='Ext-WindowGroup-method-getBy'> /**
  161. </span> * Returns zero or more windows in this WindowGroup using the custom search function passed to this method.
  162. * The function should accept a single {@link Ext.Window} reference as its only argument and should
  163. * return true if the window matches the search criteria, otherwise it should return false.
  164. * @param {Function} fn The search function
  165. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the function is executed. Defaults to the Window being tested.
  166. * that gets passed to the function if not specified)
  167. * @return {Array} An array of zero or more matching windows
  168. */
  169. getBy : function(fn, scope){
  170. var r = [];
  171. for(var i = accessList.length-1; i &gt;=0; --i) {
  172. var win = accessList[i];
  173. if(fn.call(scope||win, win) !== false){
  174. r.push(win);
  175. }
  176. }
  177. return r;
  178. },
  179. <span id='Ext-WindowGroup-method-each'> /**
  180. </span> * Executes the specified function once for every window in this WindowGroup, passing each
  181. * window as the only parameter. Returning false from the function will stop the iteration.
  182. * @param {Function} fn The function to execute for each item
  183. * @param {Object} scope (optional) The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the function is executed. Defaults to the current Window in the iteration.
  184. */
  185. each : function(fn, scope){
  186. for(var id in list){
  187. if(list[id] &amp;&amp; typeof list[id] != &quot;function&quot;){
  188. if(fn.call(scope || list[id], list[id]) === false){
  189. return;
  190. }
  191. }
  192. }
  193. }
  194. };
  195. };
  196. <span id='Ext-WindowMgr'>/**
  197. </span> * @class Ext.WindowMgr
  198. * @extends Ext.WindowGroup
  199. * The default global window group that is available automatically. To have more than one group of windows
  200. * with separate z-order stacks, create additional instances of {@link Ext.WindowGroup} as needed.
  201. * @singleton
  202. */
  203. Ext.WindowMgr = new Ext.WindowGroup();</pre>
  204. </body>
  205. </html>