3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.WindowGroup"></div>/**
15 * @class Ext.WindowGroup
16 * An object that represents a group of {@link Ext.Window} instances and provides z-order management
17 * and window activation behavior.
20 Ext.WindowGroup = function(){
26 var sortWindows = function(d1, d2){
27 return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
31 var orderWindows = function(){
32 var a = accessList, len = a.length;
35 var seed = a[0].manager.zseed;
36 for(var i = 0; i < len; i++){
38 if(win && !win.hidden){
39 win.setZIndex(seed + (i*10));
47 var setActiveWin = function(win){
50 front.setActive(false);
60 var activateLast = function(){
61 for(var i = accessList.length-1; i >=0; --i) {
62 if(!accessList[i].hidden){
63 setActiveWin(accessList[i]);
72 <div id="prop-Ext.WindowGroup-zseed"></div>/**
73 * The starting z-index for windows (defaults to 9000)
74 * @type Number The z-index value
79 register : function(win){
82 win.on('hide', activateLast);
86 unregister : function(win){
88 win.un('hide', activateLast);
89 accessList.remove(win);
92 <div id="method-Ext.WindowGroup-get"></div>/**
93 * Gets a registered window by id.
94 * @param {String/Object} id The id of the window or a {@link Ext.Window} instance
95 * @return {Ext.Window}
98 return typeof id == "object" ? id : list[id];
101 <div id="method-Ext.WindowGroup-bringToFront"></div>/**
102 * Brings the specified window to the front of any other active windows.
103 * @param {String/Object} win The id of the window or a {@link Ext.Window} instance
104 * @return {Boolean} True if the dialog was brought to the front, else false
105 * if it was already in front
107 bringToFront : function(win){
110 win._lastAccess = new Date().getTime();
117 <div id="method-Ext.WindowGroup-sendToBack"></div>/**
118 * Sends the specified window to the back of other active windows.
119 * @param {String/Object} win The id of the window or a {@link Ext.Window} instance
120 * @return {Ext.Window} The window
122 sendToBack : function(win){
124 win._lastAccess = -(new Date().getTime());
129 <div id="method-Ext.WindowGroup-hideAll"></div>/**
130 * Hides all windows in the group.
132 hideAll : function(){
134 if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
140 <div id="method-Ext.WindowGroup-getActive"></div>/**
141 * Gets the currently-active window in the group.
142 * @return {Ext.Window} The active window
144 getActive : function(){
148 <div id="method-Ext.WindowGroup-getBy"></div>/**
149 * Returns zero or more windows in the group using the custom search function passed to this method.
150 * The function should accept a single {@link Ext.Window} reference as its only argument and should
151 * return true if the window matches the search criteria, otherwise it should return false.
152 * @param {Function} fn The search function
153 * @param {Object} scope (optional) The scope in which to execute the function (defaults to the window
154 * that gets passed to the function if not specified)
155 * @return {Array} An array of zero or more matching windows
157 getBy : function(fn, scope){
159 for(var i = accessList.length-1; i >=0; --i) {
160 var win = accessList[i];
161 if(fn.call(scope||win, win) !== false){
168 <div id="method-Ext.WindowGroup-each"></div>/**
169 * Executes the specified function once for every window in the group, passing each
170 * window as the only parameter. Returning false from the function will stop the iteration.
171 * @param {Function} fn The function to execute for each item
172 * @param {Object} scope (optional) The scope in which to execute the function
174 each : function(fn, scope){
176 if(list[id] && typeof list[id] != "function"){
177 if(fn.call(scope || list[id], list[id]) === false){
187 <div id="cls-Ext.WindowMgr"></div>/**
188 * @class Ext.WindowMgr
189 * @extends Ext.WindowGroup
190 * The default global window group that is available automatically. To have more than one group of windows
191 * with separate z-order stacks, create additional instances of {@link Ext.WindowGroup} as needed.
194 Ext.WindowMgr = new Ext.WindowGroup();</pre>