-<html>\r
-<head>\r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.Window"></div>/**
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body onload="prettyPrint();">
+ <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.3.1
+ * Copyright(c) 2006-2010 Sencha Inc.
+ * licensing@sencha.com
+ * http://www.sencha.com/license
+ */
+<div id="cls-Ext.Window"></div>/**
* @class Ext.Window
* @extends Ext.Panel
* <p>A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
* {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
* restored to their prior size, and can be {@link #minimize}d.</p>
- * <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
+ * <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
* grouping, activation, to front, to back and other application-specific behavior.</p>
* <p>By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
* specify {@link Ext.Component#renderTo renderTo}.</p>
* A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
*/
<div id="cfg-Ext.Window-defaultButton"></div>/**
- * @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
+ * <p>Specifies a Component to receive focus when this Window is focussed.</p>
+ * <p>This may be one of:</p><div class="mdetail-params"><ul>
+ * <li>The index of a footer Button.</li>
+ * <li>The id of a Component.</li>
+ * <li>A Component.</li>
+ * </ul></div>
*/
<div id="cfg-Ext.Window-onEsc"></div>/**
* @cfg {Function} onEsc
*/
<div id="cfg-Ext.Window-collapsed"></div>/**
* @cfg {Boolean} collapsed
- * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
- * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
+ * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
+ * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
* will always be expanded when shown.
*/
<div id="cfg-Ext.Window-maximized"></div>/**
* @cfg {Boolean} maximized
* True to initially display the window in a maximized state. (Defaults to false).
*/
-
+
<div id="cfg-Ext.Window-baseCls"></div>/**
* @cfg {String} baseCls
* The base CSS class to apply to this panel's element (defaults to 'x-window').
<div id="cfg-Ext.Window-constrain"></div>/**
* @cfg {Boolean} constrain
* True to constrain the window within its containing element, false to allow it to fall outside of its
- * containing element. By default the window will be rendered to document.body. To render and constrain the
+ * containing element. By default the window will be rendered to document.body. To render and constrain the
* window within another element specify {@link #renderTo}.
* (defaults to false). Optionally the header only can be constrained using {@link #constrainHeader}.
*/
constrain : false,
<div id="cfg-Ext.Window-constrainHeader"></div>/**
* @cfg {Boolean} constrainHeader
- * True to constrain the window header within its containing element (allowing the window body to fall outside
- * of its containing element) or false to allow the header to fall outside its containing element (defaults to
+ * True to constrain the window header within its containing element (allowing the window body to fall outside
+ * of its containing element) or false to allow the header to fall outside its containing element (defaults to
* false). Optionally the entire window can be constrained using {@link #constrain}.
*/
constrainHeader : false,
* {@link #collapsed}) when displayed (defaults to true).
*/
expandOnShow : true,
+
+ <div id="cfg-Ext.Window-showAnimDuration"></div>/**
+ * @cfg {Number} showAnimDuration The number of seconds that the window show animation takes if enabled.
+ * Defaults to 0.25
+ */
+ showAnimDuration: 0.25,
+
+ <div id="cfg-Ext.Window-hideAnimDuration"></div>/**
+ * @cfg {Number} hideAnimDuration The number of seconds that the window hide animation takes if enabled.
+ * Defaults to 0.25
+ */
+ hideAnimDuration: 0.25,
// inherited docs, same default
collapsible : false,
<div id="cfg-Ext.Window-initHidden"></div>/**
* @cfg {Boolean} initHidden
* True to hide the window until show() is explicitly called (defaults to true).
+ * @deprecated
*/
- initHidden : true,
- <div id="cfg-Ext.Window-monitorResize"></div>/**
- * @cfg {Boolean} monitorResize @hide
- * This is automatically managed based on the value of constrain and constrainToHeader
- */
- monitorResize : true,
+ initHidden : undefined,
+
+ <div id="cfg-Ext.Window-hidden"></div>/**
+ * @cfg {Boolean} hidden
+ * Render this component hidden (default is <tt>true</tt>). If <tt>true</tt>, the
+ * {@link #hide} method will be called internally.
+ */
+ hidden : true,
// The following configs are set to provide the basic functionality of a window.
// Changing them would require additional code to handle correctly and should
// private
initComponent : function(){
+ this.initTools();
Ext.Window.superclass.initComponent.call(this);
this.addEvents(
<div id="event-Ext.Window-activate"></div>/**
* @event activate
- * Fires after the window has been visually activated via {@link setActive}.
+ * Fires after the window has been visually activated via {@link #setActive}.
* @param {Ext.Window} this
*/
<div id="event-Ext.Window-deactivate"></div>/**
* @event deactivate
- * Fires after the window has been visually deactivated via {@link setActive}.
+ * Fires after the window has been visually deactivated via {@link #setActive}.
* @param {Ext.Window} this
*/
<div id="event-Ext.Window-resize"></div>/**
*/
'restore'
);
- if(this.initHidden === false){
- this.show();
- }else{
+ // for backwards compat, this should be removed at some point
+ if(Ext.isDefined(this.initHidden)){
+ this.hidden = this.initHidden;
+ }
+ if(this.hidden === false){
this.hidden = true;
+ this.show();
}
},
this.mask.hide();
this.mon(this.mask, 'click', this.focus, this);
}
- this.initTools();
+ if(this.maximizable){
+ this.mon(this.header, 'dblclick', this.toggleMaximize, this);
+ }
},
// private
minHeight:this.minHeight,
handles: this.resizeHandles || 'all',
pinned: true,
- resizeElement : this.resizerAction
+ resizeElement : this.resizerAction,
+ handleCls: 'x-window-handle'
});
this.resizer.window = this;
this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
initDraggable : function(){
<div id="prop-Ext.Window-dd"></div>/**
- * If this Window is configured {@link #draggable}, this property will contain
- * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.
+ * <p>If this Window is configured {@link #draggable}, this property will contain
+ * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.</p>
+ * <p>This has implementations of <code>startDrag</code>, <code>onDrag</code> and <code>endDrag</code>
+ * which perform the dragging action. If extra logic is needed at these points, use
+ * {@link Function#createInterceptor createInterceptor} or {@link Function#createSequence createSequence} to
+ * augment the existing implementations.</p>
* @type Ext.dd.DD
* @property dd
*/
},
// private
- onEsc : function(){
+ onEsc : function(k, e){
+ e.stopEvent();
this[this.closeAction]();
},
// private
beforeDestroy : function(){
- if (this.rendered){
+ if(this.rendered){
this.hide();
- if(this.doAnchor){
- Ext.EventManager.removeResizeListener(this.doAnchor, this);
- Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
- }
+ this.clearAnchor();
Ext.destroy(
this.focusEl,
this.resizer,
handler: this.restore.createDelegate(this, []),
hidden:true
});
- this.mon(this.header, 'dblclick', this.toggleMaximize, this);
}
if(this.closable){
this.addTool({
this.updateBox(box);
}else{
this.setSize(box);
+ if (Ext.isIE6 && Ext.isStrict) {
+ this.doLayout();
+ }
}
this.focus();
this.updateHandles();
this.saveState();
- this.doLayout();
- this.fireEvent('resize', this, box.width, box.height);
},
<div id="method-Ext.Window-focus"></div>/**
* window itself will receive focus.
*/
focus : function(){
- var f = this.focusEl, db = this.defaultButton, t = typeof db;
- if(t != 'undefined'){
- if(t == 'number' && this.fbar){
+ var f = this.focusEl,
+ db = this.defaultButton,
+ t = typeof db,
+ el,
+ ct;
+ if(Ext.isDefined(db)){
+ if(Ext.isNumber(db) && this.fbar){
f = this.fbar.items.get(db);
- }else if(t == 'string'){
+ }else if(Ext.isString(db)){
f = Ext.getCmp(db);
}else{
f = db;
}
+ el = f.getEl();
+ ct = Ext.getDom(this.container);
+ if (el && ct) {
+ if (ct != document.body && !Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
+ return;
+ }
+ }
}
f = f || this.focusEl;
f.focus.defer(10, f);
* @param {String/Element} animateTarget (optional) The target element or id from which the window should
* animate while opening (defaults to null with no animation)
* @param {Function} callback (optional) A callback function to call after the window is displayed
- * @param {Object} scope (optional) The scope in which to execute the callback
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
* @return {Ext.Window} this
*/
show : function(animateTarget, cb, scope){
this.on('show', cb, scope, {single:true});
}
this.hidden = false;
- if(animateTarget !== undefined){
+ if(Ext.isDefined(animateTarget)){
this.setAnimateTarget(animateTarget);
}
this.beforeShow();
// private
afterShow : function(isAnim){
+ if (this.isDestroyed){
+ return false;
+ }
this.proxy.hide();
this.el.setStyle('display', 'block');
this.el.show();
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);
}
var sz = this.getSize();
this.onResize(sz.width, sz.height);
}
+ this.onShow();
this.fireEvent('show', this);
},
this.proxy.show();
this.proxy.setBox(this.animateTarget.getBox());
this.proxy.setOpacity(0);
- var b = this.getBox(false);
- b.callback = this.afterShow.createDelegate(this, [true], false);
- b.scope = this;
- b.duration = 0.25;
- b.easing = 'easeNone';
- b.opacity = 0.5;
- b.block = true;
+ var b = this.getBox();
this.el.setStyle('display', 'none');
- this.proxy.shift(b);
+ this.proxy.shift(Ext.apply(b, {
+ callback: this.afterShow.createDelegate(this, [true], false),
+ scope: this,
+ easing: 'easeNone',
+ duration: this.showAnimDuration,
+ opacity: 0.5
+ }));
},
<div id="method-Ext.Window-hide"></div>/**
* @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 (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
* @return {Ext.Window} this
*/
hide : function(animateTarget, cb, scope){
if(this.keyMap){
this.keyMap.disable();
}
+ this.onHide();
this.fireEvent('hide', this);
},
var tb = this.getBox(false);
this.proxy.setBox(tb);
this.el.hide();
- var b = this.animateTarget.getBox();
- b.callback = this.afterHide;
- b.scope = this;
- b.duration = 0.25;
- b.easing = 'easeNone';
- b.block = true;
- b.opacity = 0;
- this.proxy.shift(b);
+ this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
+ callback: this.afterHide,
+ scope: this,
+ duration: this.hideAnimDuration,
+ easing: 'easeNone',
+ opacity: 0
+ }));
},
+ <div id="prop-Ext.Window-onShow"></div>/**
+ * Method that is called immediately before the <code>show</code> event is fired.
+ * Defaults to <code>Ext.emptyFn</code>.
+ */
+ onShow : Ext.emptyFn,
+
+ <div id="prop-Ext.Window-onHide"></div>/**
+ * Method that is called immediately before the <code>hide</code> event is fired.
+ * Defaults to <code>Ext.emptyFn</code>.
+ */
+ onHide : Ext.emptyFn,
+
// private
onWindowResize : function(){
if(this.maximized){
}
if(show !== false){
this.el.show();
- this.focus();
- if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
+ this.focus.defer(10, this);
+ if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
this.cascade(this.setAutoScroll);
}
}
*/
close : function(){
if(this.fireEvent('beforeclose', this) !== false){
- this.hide(null, function(){
- this.fireEvent('close', this);
- this.destroy();
- }, this);
+ if(this.hidden){
+ this.doClose();
+ }else{
+ this.hide(null, this.doClose, this);
+ }
}
},
+ // private
+ doClose : function(){
+ this.fireEvent('close', this);
+ this.destroy();
+ },
+
<div id="method-Ext.Window-maximize"></div>/**
* Fits the window within its current container and automatically replaces
* the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
*/
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;
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');
// private
fitContainer : function(){
- var vs = this.container.getViewSize();
+ var vs = this.container.getViewSize(false);
this.setSize(vs.width, vs.height);
},
<div id="method-Ext.Window-alignTo"></div>/**
* 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
*/
* @return {Ext.Window} this
*/
anchorTo : function(el, alignment, offsets, monitorScroll){
- if(this.doAnchor){
- Ext.EventManager.removeResizeListener(this.doAnchor, this);
- Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
- }
- this.doAnchor = function(){
- this.alignTo(el, alignment, offsets);
- };
- Ext.EventManager.onWindowResize(this.doAnchor, this);
-
- var tm = typeof monitorScroll;
- if(tm != 'undefined'){
- Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
- {buffer: tm == 'number' ? monitorScroll : 50});
- }
- this.doAnchor();
- return this;
+ this.clearAnchor();
+ this.anchorTarget = {
+ el: el,
+ alignment: alignment,
+ offsets: offsets
+ };
+
+ Ext.EventManager.onWindowResize(this.doAnchor, this);
+ var tm = typeof monitorScroll;
+ if(tm != 'undefined'){
+ Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
+ {buffer: tm == 'number' ? monitorScroll : 50});
+ }
+ return this.doAnchor();
+ },
+
+ /**
+ * Performs the anchor, using the saved anchorTarget property.
+ * @return {Ext.Window} this
+ * @private
+ */
+ doAnchor : function(){
+ var o = this.anchorTarget;
+ this.alignTo(o.el, o.alignment, o.offsets);
+ return this;
+ },
+
+ <div id="method-Ext.Window-clearAnchor"></div>/**
+ * Removes any existing anchor from this window. See {@link #anchorTo}.
+ * @return {Ext.Window} this
+ */
+ clearAnchor : function(){
+ if(this.anchorTarget){
+ Ext.EventManager.removeResizeListener(this.doAnchor, this);
+ Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
+ delete this.anchorTarget;
+ }
+ return this;
},
<div id="method-Ext.Window-toFront"></div>/**
<div id="method-Ext.Window-setActive"></div>/**
* Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
- * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred.
+ * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
+ * called internally by {@link Ext.WindowMgr}.
* @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
*/
setActive : function(active){
Ext.reg('window', Ext.Window);
// private - custom Window DD implementation
-Ext.Window.DD = function(win){
- this.win = win;
- Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
- this.setHandleElId(win.header.id);
- this.scroll = false;
-};
-
-Ext.extend(Ext.Window.DD, Ext.dd.DD, {
+Ext.Window.DD = Ext.extend(Ext.dd.DD, {
+
+ constructor : function(win){
+ this.win = win;
+ Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
+ this.setHandleElId(win.header.id);
+ this.scroll = false;
+ },
+
moveOnly:true,
headerOffsets:[100, 25],
startDrag : function(){
var w = this.win;
- this.proxy = w.ghost();
+ this.proxy = w.ghost(w.initialConfig.cls);
if(w.constrain !== false){
var so = w.el.shadowOffset;
this.constrainTo(w.container, {right: so, left: so, bottom: so});
this.win.saveState();
}
});
-</pre> \r
-</body>\r
+</pre>
+</body>
</html>
\ No newline at end of file