X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..6e39d509471fe9b4e2660e0d1631b350d0c66f40:/pkgs/window-debug.js diff --git a/pkgs/window-debug.js b/pkgs/window-debug.js index 7273d54e..0461d5e3 100644 --- a/pkgs/window-debug.js +++ b/pkgs/window-debug.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.0.3 + * Ext JS Library 3.1.0 * Copyright(c) 2006-2009 Ext JS, LLC * licensing@extjs.com * http://www.extjs.com/license @@ -50,8 +50,13 @@ Ext.Window = Ext.extend(Ext.Panel, { * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}). */ /** - * @cfg {String/Number/Button} defaultButton - * The id / index of a button or a button instance to focus when this window received the focus. + * @cfg {String/Number/Component} defaultButton + *
Specifies a Component to receive focus when this Window is focussed.
+ *This may be one of:
this
reference) in which the callback is executed. Defaults to this Window.
* @return {Ext.Window} this
*/
show : function(animateTarget, cb, scope){
@@ -529,7 +533,7 @@ Ext.Window = Ext.extend(Ext.Panel, {
if(this.maximized){
this.fitContainer();
}
- if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
+ if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
this.cascade(this.setAutoScroll);
}
@@ -547,6 +551,7 @@ Ext.Window = Ext.extend(Ext.Panel, {
var sz = this.getSize();
this.onResize(sz.width, sz.height);
}
+ this.onShow();
this.fireEvent('show', this);
},
@@ -571,7 +576,7 @@ Ext.Window = Ext.extend(Ext.Panel, {
* @param {String/Element} animateTarget (optional) The target element or id to which the window should
* animate while hiding (defaults to null with no animation)
* @param {Function} callback (optional) A callback function to call after the window is hidden
- * @param {Object} scope (optional) The scope in which to execute the callback
+ * @param {Object} scope (optional) The scope (this
reference) in which the callback is executed. Defaults to this Window.
* @return {Ext.Window} this
*/
hide : function(animateTarget, cb, scope){
@@ -607,6 +612,7 @@ Ext.Window = Ext.extend(Ext.Panel, {
if(this.keyMap){
this.keyMap.disable();
}
+ this.onHide();
this.fireEvent('hide', this);
},
@@ -626,6 +632,18 @@ Ext.Window = Ext.extend(Ext.Panel, {
}));
},
+ /**
+ * Method that is called immediately before the show
event is fired.
+ * Defaults to Ext.emptyFn
.
+ */
+ onShow : Ext.emptyFn,
+
+ /**
+ * Method that is called immediately before the hide
event is fired.
+ * Defaults to Ext.emptyFn
.
+ */
+ onHide : Ext.emptyFn,
+
// private
onWindowResize : function(){
if(this.maximized){
@@ -683,7 +701,7 @@ Ext.Window = Ext.extend(Ext.Panel, {
if(show !== false){
this.el.show();
this.focus();
- if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
+ if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
this.cascade(this.setAutoScroll);
}
}
@@ -723,7 +741,7 @@ Ext.Window = Ext.extend(Ext.Panel, {
}
}
},
-
+
// private
doClose : function(){
this.fireEvent('close', this);
@@ -773,9 +791,14 @@ Ext.Window = Ext.extend(Ext.Panel, {
*/
restore : function(){
if(this.maximized){
+ var t = this.tools;
this.el.removeClass('x-window-maximized');
- this.tools.restore.hide();
- this.tools.maximize.show();
+ if(t.restore){
+ t.restore.hide();
+ }
+ if(t.maximize){
+ t.maximize.show();
+ }
this.setPosition(this.restorePos[0], this.restorePos[1]);
this.setSize(this.restoreSize.width, this.restoreSize.height);
delete this.restorePos;
@@ -786,8 +809,8 @@ Ext.Window = Ext.extend(Ext.Panel, {
if(this.dd){
this.dd.unlock();
}
- if(this.collapsible){
- this.tools.toggle.show();
+ if(this.collapsible && t.toggle){
+ t.toggle.show();
}
this.container.removeClass('x-window-maximized-ct');
@@ -808,7 +831,7 @@ Ext.Window = Ext.extend(Ext.Panel, {
// private
fitContainer : function(){
- var vs = this.container.getViewSize();
+ var vs = this.container.getViewSize(false);
this.setSize(vs.width, vs.height);
},
@@ -831,7 +854,7 @@ Ext.Window = Ext.extend(Ext.Panel, {
/**
* Aligns the window to the specified element
* @param {Mixed} element The element to align to.
- * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details).
+ * @param {String} position (optional, defaults to "tl-bl?") The position to align to (see {@link Ext.Element#alignTo} for more details).
* @param {Array} offsets (optional) Offset the positioning by [x, y]
* @return {Ext.Window} this
*/
@@ -961,7 +984,7 @@ Ext.extend(Ext.Window.DD, Ext.dd.DD, {
});
/**
* @class Ext.WindowGroup
- * An object that represents a group of {@link Ext.Window} instances and provides z-order management
+ * An object that manages a group of {@link Ext.Window} instances and provides z-order management
* and window activation behavior.
* @constructor
*/
@@ -1018,20 +1041,42 @@ Ext.WindowGroup = function(){
return {
/**
- * The starting z-index for windows (defaults to 9000)
+ * The starting z-index for windows in this WindowGroup (defaults to 9000)
* @type Number The z-index value
*/
zseed : 9000,
- // private
+ /**
+ * Registers a {@link Ext.Window Window} with this WindowManager. This should not + * need to be called under normal circumstances. Windows are automatically registered + * with a {@link Ext.Window#manager manager} at construction time.
+ *Where this may be useful is moving Windows between two WindowManagers. For example, + * to bring the Ext.MessageBox dialog under the same manager as the Desktop's + * WindowManager in the desktop sample app:
+var msgWin = Ext.MessageBox.getDialog();
+MyDesktop.getDesktop().getManager().register(msgWin);
+
+ * @param {Window} win The Window to register.
+ */
register : function(win){
+ if(win.manager){
+ win.manager.unregister(win);
+ }
+ win.manager = this;
+
list[win.id] = win;
accessList.push(win);
win.on('hide', activateLast);
},
- // private
+ /**
+ * Unregisters a {@link Ext.Window Window} from this WindowManager. This should not + * need to be called. Windows are automatically unregistered upon destruction. + * See {@link #register}.
+ * @param {Window} win The Window to unregister. + */ unregister : function(win){ + delete win.manager; delete list[win.id]; win.un('hide', activateLast); accessList.remove(win); @@ -1047,7 +1092,7 @@ Ext.WindowGroup = function(){ }, /** - * Brings the specified window to the front of any other active windows. + * Brings the specified window to the front of any other active windows in this WindowGroup. * @param {String/Object} win The id of the window or a {@link Ext.Window} instance * @return {Boolean} True if the dialog was brought to the front, else false * if it was already in front @@ -1063,7 +1108,7 @@ Ext.WindowGroup = function(){ }, /** - * Sends the specified window to the back of other active windows. + * Sends the specified window to the back of other active windows in this WindowGroup. * @param {String/Object} win The id of the window or a {@link Ext.Window} instance * @return {Ext.Window} The window */ @@ -1075,7 +1120,7 @@ Ext.WindowGroup = function(){ }, /** - * Hides all windows in the group. + * Hides all windows in this WindowGroup. */ hideAll : function(){ for(var id in list){ @@ -1086,7 +1131,7 @@ Ext.WindowGroup = function(){ }, /** - * Gets the currently-active window in the group. + * Gets the currently-active window in this WindowGroup. * @return {Ext.Window} The active window */ getActive : function(){ @@ -1094,11 +1139,11 @@ Ext.WindowGroup = function(){ }, /** - * Returns zero or more windows in the group using the custom search function passed to this method. + * Returns zero or more windows in this WindowGroup using the custom search function passed to this method. * The function should accept a single {@link Ext.Window} reference as its only argument and should * return true if the window matches the search criteria, otherwise it should return false. * @param {Function} fn The search function - * @param {Object} scope (optional) The scope in which to execute the function (defaults to the window + * @param {Object} scope (optional) The scope (this
reference) in which the function is executed. Defaults to the Window being tested.
* that gets passed to the function if not specified)
* @return {Array} An array of zero or more matching windows
*/
@@ -1114,10 +1159,10 @@ Ext.WindowGroup = function(){
},
/**
- * Executes the specified function once for every window in the group, passing each
+ * Executes the specified function once for every window in this WindowGroup, passing each
* window as the only parameter. Returning false from the function will stop the iteration.
* @param {Function} fn The function to execute for each item
- * @param {Object} scope (optional) The scope in which to execute the function
+ * @param {Object} scope (optional) The scope (this
reference) in which the function is executed. Defaults to the current Window in the iteration.
*/
each : function(fn, scope){
for(var id in list){
@@ -1173,10 +1218,12 @@ Ext.Msg.show({
Ext.MessageBox = function(){
var dlg, opt, mask, waitTimer,
bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl,
- buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '';
+ buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '',
+ buttonNames = ['ok', 'yes', 'no', 'cancel'];
// private
var handleButton = function(button){
+ buttons[button].blur();
if(dlg.isVisible()){
dlg.hide();
handleHide();
@@ -1189,7 +1236,7 @@ Ext.MessageBox = function(){
if(opt && opt.cls){
dlg.el.removeClass(opt.cls);
}
- progressBar.reset();
+ progressBar.reset();
};
// private
@@ -1205,26 +1252,25 @@ Ext.MessageBox = function(){
// private
var updateButtons = function(b){
- var width = 0;
+ var width = 0,
+ cfg;
if(!b){
- buttons["ok"].hide();
- buttons["cancel"].hide();
- buttons["yes"].hide();
- buttons["no"].hide();
+ Ext.each(buttonNames, function(name){
+ buttons[name].hide();
+ });
return width;
}
dlg.footer.dom.style.display = '';
- for(var k in buttons){
- if(!Ext.isFunction(buttons[k])){
- if(b[k]){
- buttons[k].show();
- buttons[k].setText(Ext.isString(b[k]) ? b[k] : Ext.MessageBox.buttonText[k]);
- width += buttons[k].el.getWidth()+15;
- }else{
- buttons[k].hide();
- }
+ Ext.iterate(buttons, function(name, btn){
+ cfg = b[name];
+ if(cfg){
+ btn.show();
+ btn.setText(Ext.isString(cfg) ? cfg : Ext.MessageBox.buttonText[name]);
+ width += btn.getEl().getWidth() + 15;
+ }else{
+ btn.hide();
}
- }
+ });
return width;
};
@@ -1235,6 +1281,16 @@ Ext.MessageBox = function(){
*/
getDialog : function(titleText){
if(!dlg){
+ var btns = [];
+
+ buttons = {};
+ Ext.each(buttonNames, function(name){
+ btns.push(buttons[name] = new Ext.Button({
+ text: this.buttonText[name],
+ handler: handleButton.createCallback(name),
+ hideMode: 'offsets'
+ }));
+ }, this);
dlg = new Ext.Window({
autoCreate : true,
title:titleText,
@@ -1259,16 +1315,12 @@ Ext.MessageBox = function(){
}else{
handleButton("cancel");
}
- }
+ },
+ fbar: new Ext.Toolbar({
+ items: btns,
+ enableOverflow: false
+ })
});
- buttons = {};
- var bt = this.buttonText;
- //TODO: refactor this block into a buttons config to pass into the Window constructor
- buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
- buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
- buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
- buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
- buttons["ok"].hideMode = buttons["yes"].hideMode = buttons["no"].hideMode = buttons["cancel"].hideMode = 'offsets';
dlg.render(document.body);
dlg.getEl().addClass('x-window-dlg');
mask = dlg.mask;
@@ -1508,18 +1560,16 @@ Ext.Msg.show({
// force it to the end of the z-index stack so it gets a cursor in FF
document.body.appendChild(dlg.el.dom);
d.setAnimateTarget(opt.animEl);
+ //workaround for window internally enabling keymap in afterShow
+ d.on('show', function(){
+ if(allowClose === true){
+ d.keyMap.enable();
+ }else{
+ d.keyMap.disable();
+ }
+ }, this, {single:true});
d.show(opt.animEl);
}
-
- //workaround for window internally enabling keymap in afterShow
- d.on('show', function(){
- if(allowClose === true){
- d.keyMap.enable();
- }else{
- d.keyMap.disable();
- }
- }, this, {single:true});
-
if(opt.wait === true){
progressBar.wait(opt.waitConfig);
}
@@ -1612,7 +1662,7 @@ Ext.MessageBox.ERROR
* @param {String} title The title bar text
* @param {String} msg The message box body text
* @param {Function} fn (optional) The callback function invoked after the message box is closed
- * @param {Object} scope (optional) The scope of the callback function
+ * @param {Object} scope (optional) The scope (this
reference) in which the callback is executed. Defaults to the browser wnidow.
* @return {Ext.MessageBox} this
*/
alert : function(title, msg, fn, scope){
@@ -1634,7 +1684,7 @@ Ext.MessageBox.ERROR
* @param {String} title The title bar text
* @param {String} msg The message box body text
* @param {Function} fn (optional) The callback function invoked after the message box is closed
- * @param {Object} scope (optional) The scope of the callback function
+ * @param {Object} scope (optional) The scope (this
reference) in which the callback is executed. Defaults to the browser wnidow.
* @return {Ext.MessageBox} this
*/
confirm : function(title, msg, fn, scope){
@@ -1657,7 +1707,7 @@ Ext.MessageBox.ERROR
* @param {String} title The title bar text
* @param {String} msg The message box body text
* @param {Function} fn (optional) The callback function invoked after the message box is closed
- * @param {Object} scope (optional) The scope of the callback function
+ * @param {Object} scope (optional) The scope (this
reference) in which the callback is executed. Defaults to the browser wnidow.
* @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
* property, or the height in pixels to create the textbox (defaults to false / single-line)
* @param {String} value (optional) Default value of the text input element (defaults to '')