3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
10 * <p>A specialized panel intended for use as an application window. Windows are floated, {@link #resizable}, and
11 * {@link #draggable} by default. Windows can be {@link #maximizable maximized} to fill the viewport,
12 * restored to their prior size, and can be {@link #minimize}d.</p>
13 * <p>Windows can also be linked to a {@link Ext.WindowGroup} or managed by the {@link Ext.WindowMgr} to provide
14 * grouping, activation, to front, to back and other application-specific behavior.</p>
15 * <p>By default, Windows will be rendered to document.body. To {@link #constrain} a Window to another element
16 * specify {@link Ext.Component#renderTo renderTo}.</p>
17 * <p><b>Note:</b> By default, the <code>{@link #closable close}</code> header tool <i>destroys</i> the Window resulting in
18 * destruction of any child Components. This makes the Window object, and all its descendants <b>unusable</b>. To enable
19 * re-use of a Window, use <b><code>{@link #closeAction closeAction: 'hide'}</code></b>.</p>
21 * @param {Object} config The config object
24 Ext.Window = Ext.extend(Ext.Panel, {
27 * The X position of the left edge of the window on initial showing. Defaults to centering the Window within
28 * the width of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
32 * The Y position of the top edge of the window on initial showing. Defaults to centering the Window within
33 * the height of the Window's container {@link Ext.Element Element) (The Element that the Window is rendered to).
36 * @cfg {Boolean} modal
37 * True to make the window modal and mask everything behind it when displayed, false to display it without
38 * restricting access to other UI elements (defaults to false).
41 * @cfg {String/Element} animateTarget
42 * Id or element from which the window should animate while opening (defaults to null with no animation).
45 * @cfg {String} resizeHandles
46 * A valid {@link Ext.Resizable} handles config string (defaults to 'all'). Only applies when resizable = true.
49 * @cfg {Ext.WindowGroup} manager
50 * A reference to the WindowGroup that should manage this window (defaults to {@link Ext.WindowMgr}).
53 * @cfg {String/Number/Component} defaultButton
54 * <p>Specifies a Component to receive focus when this Window is focussed.</p>
55 * <p>This may be one of:</p><div class="mdetail-params"><ul>
56 * <li>The index of a footer Button.</li>
57 * <li>The id of a Component.</li>
58 * <li>A Component.</li>
62 * @cfg {Function} onEsc
63 * Allows override of the built-in processing for the escape key. Default action
64 * is to close the Window (performing whatever action is specified in {@link #closeAction}.
65 * To prevent the Window closing when the escape key is pressed, specify this as
66 * Ext.emptyFn (See {@link Ext#emptyFn}).
69 * @cfg {Boolean} collapsed
70 * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
71 * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
72 * will always be expanded when shown.
75 * @cfg {Boolean} maximized
76 * True to initially display the window in a maximized state. (Defaults to false).
80 * @cfg {String} baseCls
81 * The base CSS class to apply to this panel's element (defaults to 'x-window').
85 * @cfg {Boolean} resizable
86 * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
90 * @cfg {Boolean} draggable
91 * True to allow the window to be dragged by the header bar, false to disable dragging (defaults to true). Note
92 * that by default the window will be centered in the viewport, so if dragging is disabled the window may need
93 * to be positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).
97 * @cfg {Boolean} closable
98 * <p>True to display the 'close' tool button and allow the user to close the window, false to
99 * hide the button and disallow closing the window (defaults to true).</p>
100 * <p>By default, when close is requested by either clicking the close button in the header
101 * or pressing ESC when the Window has focus, the {@link #close} method will be called. This
102 * will <i>{@link Ext.Component#destroy destroy}</i> the Window and its content meaning that
103 * it may not be reused.</p>
104 * <p>To make closing a Window <i>hide</i> the Window so that it may be reused, set
105 * {@link #closeAction} to 'hide'.
109 * @cfg {String} closeAction
110 * <p>The action to take when the close header tool is clicked:
111 * <div class="mdetail-params"><ul>
112 * <li><b><code>'{@link #close}'</code></b> : <b>Default</b><div class="sub-desc">
113 * {@link #close remove} the window from the DOM and {@link Ext.Component#destroy destroy}
114 * it and all descendant Components. The window will <b>not</b> be available to be
115 * redisplayed via the {@link #show} method.
117 * <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
118 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
119 * The window will be available to be redisplayed via the {@link #show} method.
122 * <p><b>Note:</b> This setting does not affect the {@link #close} method
123 * which will always {@link Ext.Component#destroy destroy} the window. To
124 * programatically <i>hide</i> a window, call {@link #hide}.</p>
126 closeAction : 'close',
128 * @cfg {Boolean} constrain
129 * True to constrain the window within its containing element, false to allow it to fall outside of its
130 * containing element. By default the window will be rendered to document.body. To render and constrain the
131 * window within another element specify {@link #renderTo}.
132 * (defaults to false). Optionally the header only can be constrained using {@link #constrainHeader}.
136 * @cfg {Boolean} constrainHeader
137 * True to constrain the window header within its containing element (allowing the window body to fall outside
138 * of its containing element) or false to allow the header to fall outside its containing element (defaults to
139 * false). Optionally the entire window can be constrained using {@link #constrain}.
141 constrainHeader : false,
143 * @cfg {Boolean} plain
144 * True to render the window body with a transparent background so that it will blend into the framing
145 * elements, false to add a lighter background color to visually highlight the body element and separate it
146 * more distinctly from the surrounding frame (defaults to false).
150 * @cfg {Boolean} minimizable
151 * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button
152 * and disallow minimizing the window (defaults to false). Note that this button provides no implementation --
153 * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a
154 * custom minimize behavior implemented for this option to be useful.
158 * @cfg {Boolean} maximizable
159 * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button
160 * and disallow maximizing the window (defaults to false). Note that when a window is maximized, the tool button
161 * will automatically change to a 'restore' button with the appropriate behavior already built-in that will
162 * restore the window to its previous size.
166 * @cfg {Number} minHeight
167 * The minimum height in pixels allowed for this window (defaults to 100). Only applies when resizable = true.
171 * @cfg {Number} minWidth
172 * The minimum width in pixels allowed for this window (defaults to 200). Only applies when resizable = true.
176 * @cfg {Boolean} expandOnShow
177 * True to always expand the window when it is displayed, false to keep it in its current state (which may be
178 * {@link #collapsed}) when displayed (defaults to true).
182 // inherited docs, same default
186 * @cfg {Boolean} initHidden
187 * True to hide the window until show() is explicitly called (defaults to true).
190 initHidden : undefined,
193 * @cfg {Boolean} hidden
194 * Render this component hidden (default is <tt>true</tt>). If <tt>true</tt>, the
195 * {@link #hide} method will be called internally.
199 // The following configs are set to provide the basic functionality of a window.
200 // Changing them would require additional code to handle correctly and should
201 // usually only be done in subclasses that can provide custom behavior. Changing them
202 // may have unexpected or undesirable results.
203 /** @cfg {String} elements @hide */
204 elements : 'header,body',
205 /** @cfg {Boolean} frame @hide */
207 /** @cfg {Boolean} floating @hide */
211 initComponent : function(){
213 Ext.Window.superclass.initComponent.call(this);
217 * Fires after the window has been visually activated via {@link #setActive}.
218 * @param {Ext.Window} this
222 * Fires after the window has been visually deactivated via {@link #setActive}.
223 * @param {Ext.Window} this
227 * Fires after the window has been resized.
228 * @param {Ext.Window} this
229 * @param {Number} width The window's new width
230 * @param {Number} height The window's new height
235 * Fires after the window has been maximized.
236 * @param {Ext.Window} this
241 * Fires after the window has been minimized.
242 * @param {Ext.Window} this
247 * Fires after the window has been restored to its original size after being maximized.
248 * @param {Ext.Window} this
252 // for backwards compat, this should be removed at some point
253 if(Ext.isDefined(this.initHidden)){
254 this.hidden = this.initHidden;
256 if(this.hidden === false){
263 getState : function(){
264 return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
268 onRender : function(ct, position){
269 Ext.Window.superclass.onRender.call(this, ct, position);
272 this.el.addClass('x-window-plain');
275 // this element allows the Window to be focused for keyboard events
276 this.focusEl = this.el.createChild({
277 tag: 'a', href:'#', cls:'x-dlg-focus',
278 tabIndex:'-1', html: ' '});
279 this.focusEl.swallowEvent('click', true);
281 this.proxy = this.el.createProxy('x-window-proxy');
282 this.proxy.enableDisplayMode('block');
285 this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
286 this.mask.enableDisplayMode('block');
288 this.mon(this.mask, 'click', this.focus, this);
290 if(this.maximizable){
291 this.mon(this.header, 'dblclick', this.toggleMaximize, this);
296 initEvents : function(){
297 Ext.Window.superclass.initEvents.call(this);
298 if(this.animateTarget){
299 this.setAnimateTarget(this.animateTarget);
303 this.resizer = new Ext.Resizable(this.el, {
304 minWidth: this.minWidth,
305 minHeight:this.minHeight,
306 handles: this.resizeHandles || 'all',
308 resizeElement : this.resizerAction,
309 handleCls: 'x-window-handle'
311 this.resizer.window = this;
312 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
316 this.header.addClass('x-window-draggable');
318 this.mon(this.el, 'mousedown', this.toFront, this);
319 this.manager = this.manager || Ext.WindowMgr;
320 this.manager.register(this);
322 this.maximized = false;
326 var km = this.getKeyMap();
327 km.on(27, this.onEsc, this);
332 initDraggable : function(){
334 * <p>If this Window is configured {@link #draggable}, this property will contain
335 * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.</p>
336 * <p>This has implementations of <code>startDrag</code>, <code>onDrag</code> and <code>endDrag</code>
337 * which perform the dragging action. If extra logic is needed at these points, use
338 * {@link Function#createInterceptor createInterceptor} or {@link Function#createSequence createSequence} to
339 * augment the existing implementations.</p>
343 this.dd = new Ext.Window.DD(this);
347 onEsc : function(k, e){
349 this[this.closeAction]();
353 beforeDestroy : function(){
365 Ext.Window.superclass.beforeDestroy.call(this);
369 onDestroy : function(){
371 this.manager.unregister(this);
373 Ext.Window.superclass.onDestroy.call(this);
377 initTools : function(){
378 if(this.minimizable){
381 handler: this.minimize.createDelegate(this, [])
384 if(this.maximizable){
387 handler: this.maximize.createDelegate(this, [])
391 handler: this.restore.createDelegate(this, []),
398 handler: this[this.closeAction].createDelegate(this, [])
404 resizerAction : function(){
405 var box = this.proxy.getBox();
407 this.window.handleResize(box);
412 beforeResize : function(){
413 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
414 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
415 this.resizeBox = this.el.getBox();
419 updateHandles : function(){
420 if(Ext.isIE && this.resizer){
421 this.resizer.syncHandleHeight();
427 handleResize : function(box){
428 var rz = this.resizeBox;
429 if(rz.x != box.x || rz.y != box.y){
433 if (Ext.isIE6 && Ext.isStrict) {
438 this.updateHandles();
443 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
444 * window itself will receive focus.
447 var f = this.focusEl,
448 db = this.defaultButton,
452 if(Ext.isDefined(db)){
453 if(Ext.isNumber(db) && this.fbar){
454 f = this.fbar.items.get(db);
455 }else if(Ext.isString(db)){
461 ct = Ext.getDom(this.container);
463 if (!Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
468 f = f || this.focusEl;
469 f.focus.defer(10, f);
473 * Sets the target element from which the window should animate while opening.
474 * @param {String/Element} el The target element or id
476 setAnimateTarget : function(el){
478 this.animateTarget = el;
482 beforeShow : function(){
483 delete this.el.lastXY;
484 delete this.el.lastLT;
485 if(this.x === undefined || this.y === undefined){
486 var xy = this.el.getAlignToXY(this.container, 'c-c');
487 var pos = this.el.translatePoints(xy[0], xy[1]);
488 this.x = this.x === undefined? pos.left : this.x;
489 this.y = this.y === undefined? pos.top : this.y;
491 this.el.setLeftTop(this.x, this.y);
493 if(this.expandOnShow){
498 Ext.getBody().addClass('x-body-masked');
499 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
505 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
506 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
507 * animate while opening (defaults to null with no animation)
508 * @param {Function} callback (optional) A callback function to call after the window is displayed
509 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
510 * @return {Ext.Window} this
512 show : function(animateTarget, cb, scope){
514 this.render(Ext.getBody());
516 if(this.hidden === false){
520 if(this.fireEvent('beforeshow', this) === false){
524 this.on('show', cb, scope, {single:true});
527 if(Ext.isDefined(animateTarget)){
528 this.setAnimateTarget(animateTarget);
531 if(this.animateTarget){
540 afterShow : function(isAnim){
541 if (this.isDestroyed){
545 this.el.setStyle('display', 'block');
550 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
551 this.cascade(this.setAutoScroll);
554 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
555 Ext.EventManager.onWindowResize(this.onWindowResize, this);
560 this.keyMap.enable();
563 this.updateHandles();
564 if(isAnim && (Ext.isIE || Ext.isWebKit)){
565 var sz = this.getSize();
566 this.onResize(sz.width, sz.height);
569 this.fireEvent('show', this);
573 animShow : function(){
575 this.proxy.setBox(this.animateTarget.getBox());
576 this.proxy.setOpacity(0);
577 var b = this.getBox();
578 this.el.setStyle('display', 'none');
579 this.proxy.shift(Ext.apply(b, {
580 callback: this.afterShow.createDelegate(this, [true], false),
589 * Hides the window, setting it to invisible and applying negative offsets.
590 * @param {String/Element} animateTarget (optional) The target element or id to which the window should
591 * animate while hiding (defaults to null with no animation)
592 * @param {Function} callback (optional) A callback function to call after the window is hidden
593 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Window.
594 * @return {Ext.Window} this
596 hide : function(animateTarget, cb, scope){
597 if(this.hidden || this.fireEvent('beforehide', this) === false){
601 this.on('hide', cb, scope, {single:true});
604 if(animateTarget !== undefined){
605 this.setAnimateTarget(animateTarget);
609 Ext.getBody().removeClass('x-body-masked');
611 if(this.animateTarget){
621 afterHide : function(){
623 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
624 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
627 this.keyMap.disable();
630 this.fireEvent('hide', this);
634 animHide : function(){
635 this.proxy.setOpacity(0.5);
637 var tb = this.getBox(false);
638 this.proxy.setBox(tb);
640 this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
641 callback: this.afterHide,
650 * Method that is called immediately before the <code>show</code> event is fired.
651 * Defaults to <code>Ext.emptyFn</code>.
653 onShow : Ext.emptyFn,
656 * Method that is called immediately before the <code>hide</code> event is fired.
657 * Defaults to <code>Ext.emptyFn</code>.
659 onHide : Ext.emptyFn,
662 onWindowResize : function(){
667 this.mask.setSize('100%', '100%');
668 var force = this.mask.dom.offsetHeight;
669 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
675 doConstrain : function(){
676 if(this.constrain || this.constrainHeader){
680 right:this.el.shadowOffset,
681 left:this.el.shadowOffset,
682 bottom:this.el.shadowOffset
685 var s = this.getSize();
687 right:-(s.width - 100),
688 bottom:-(s.height - 25)
692 var xy = this.el.getConstrainToXY(this.container, true, offsets);
694 this.setPosition(xy[0], xy[1]);
699 // private - used for dragging
700 ghost : function(cls){
701 var ghost = this.createGhost(cls);
702 var box = this.getBox(true);
703 ghost.setLeftTop(box.x, box.y);
704 ghost.setWidth(box.width);
706 this.activeGhost = ghost;
711 unghost : function(show, matchPosition){
712 if(!this.activeGhost) {
717 this.focus.defer(10, this);
718 if(Ext.isMac && Ext.isGecko2){ // work around stupid FF 2.0/Mac scroll bar bug
719 this.cascade(this.setAutoScroll);
722 if(matchPosition !== false){
723 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
725 this.activeGhost.hide();
726 this.activeGhost.remove();
727 delete this.activeGhost;
731 * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
732 * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
733 * either the minimize event can be handled or this method can be overridden.
734 * @return {Ext.Window} this
736 minimize : function(){
737 this.fireEvent('minimize', this);
742 * <p>Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
743 * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
744 * event is fired before the close happens and will cancel the close action if it returns false.<p>
745 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
746 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
747 * To hide the Window without destroying it, call {@link #hide}.</p>
750 if(this.fireEvent('beforeclose', this) !== false){
754 this.hide(null, this.doClose, this);
760 doClose : function(){
761 this.fireEvent('close', this);
766 * Fits the window within its current container and automatically replaces
767 * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
768 * Also see {@link #toggleMaximize}.
769 * @return {Ext.Window} this
771 maximize : function(){
774 this.restoreSize = this.getSize();
775 this.restorePos = this.getPosition(true);
776 if (this.maximizable){
777 this.tools.maximize.hide();
778 this.tools.restore.show();
780 this.maximized = true;
781 this.el.disableShadow();
786 if(this.collapsible){
787 this.tools.toggle.hide();
789 this.el.addClass('x-window-maximized');
790 this.container.addClass('x-window-maximized-ct');
792 this.setPosition(0, 0);
794 this.fireEvent('maximize', this);
800 * Restores a {@link #maximizable maximized} window back to its original
801 * size and position prior to being maximized and also replaces
802 * the 'restore' tool button with the 'maximize' tool button.
803 * Also see {@link #toggleMaximize}.
804 * @return {Ext.Window} this
806 restore : function(){
809 this.el.removeClass('x-window-maximized');
816 this.setPosition(this.restorePos[0], this.restorePos[1]);
817 this.setSize(this.restoreSize.width, this.restoreSize.height);
818 delete this.restorePos;
819 delete this.restoreSize;
820 this.maximized = false;
821 this.el.enableShadow(true);
826 if(this.collapsible && t.toggle){
829 this.container.removeClass('x-window-maximized-ct');
832 this.fireEvent('restore', this);
838 * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
839 * state of the window.
840 * @return {Ext.Window} this
842 toggleMaximize : function(){
843 return this[this.maximized ? 'restore' : 'maximize']();
847 fitContainer : function(){
848 var vs = this.container.getViewSize(false);
849 this.setSize(vs.width, vs.height);
853 // z-index is managed by the WindowManager and may be overwritten at any time
854 setZIndex : function(index){
856 this.mask.setStyle('z-index', index);
858 this.el.setZIndex(++index);
862 this.resizer.proxy.setStyle('z-index', ++index);
865 this.lastZIndex = index;
869 * Aligns the window to the specified element
870 * @param {Mixed} element The element to align to.
871 * @param {String} position (optional, defaults to "tl-bl?") The position to align to (see {@link Ext.Element#alignTo} for more details).
872 * @param {Array} offsets (optional) Offset the positioning by [x, y]
873 * @return {Ext.Window} this
875 alignTo : function(element, position, offsets){
876 var xy = this.el.getAlignToXY(element, position, offsets);
877 this.setPagePosition(xy[0], xy[1]);
882 * Anchors this window to another element and realigns it when the window is resized or scrolled.
883 * @param {Mixed} element The element to align to.
884 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
885 * @param {Array} offsets (optional) Offset the positioning by [x, y]
886 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
887 * is a number, it is used as the buffer delay (defaults to 50ms).
888 * @return {Ext.Window} this
890 anchorTo : function(el, alignment, offsets, monitorScroll){
892 this.anchorTarget = {
894 alignment: alignment,
898 Ext.EventManager.onWindowResize(this.doAnchor, this);
899 var tm = typeof monitorScroll;
900 if(tm != 'undefined'){
901 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
902 {buffer: tm == 'number' ? monitorScroll : 50});
904 return this.doAnchor();
908 * Performs the anchor, using the saved anchorTarget property.
909 * @return {Ext.Window} this
912 doAnchor : function(){
913 var o = this.anchorTarget;
914 this.alignTo(o.el, o.alignment, o.offsets);
919 * Removes any existing anchor from this window. See {@link #anchorTo}.
920 * @return {Ext.Window} this
922 clearAnchor : function(){
923 if(this.anchorTarget){
924 Ext.EventManager.removeResizeListener(this.doAnchor, this);
925 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
926 delete this.anchorTarget;
932 * Brings this window to the front of any other visible windows
933 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
934 * @return {Ext.Window} this
936 toFront : function(e){
937 if(this.manager.bringToFront(this)){
938 if(!e || !e.getTarget().focus){
946 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
947 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred. This method is
948 * called internally by {@link Ext.WindowMgr}.
949 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
951 setActive : function(active){
954 this.el.enableShadow(true);
956 this.fireEvent('activate', this);
958 this.el.disableShadow();
959 this.fireEvent('deactivate', this);
964 * Sends this window to the back of (lower z-index than) any other visible windows
965 * @return {Ext.Window} this
968 this.manager.sendToBack(this);
973 * Centers this window in the viewport
974 * @return {Ext.Window} this
977 var xy = this.el.getAlignToXY(this.container, 'c-c');
978 this.setPagePosition(xy[0], xy[1]);
983 * @cfg {Boolean} autoWidth @hide
986 Ext.reg('window', Ext.Window);
988 // private - custom Window DD implementation
989 Ext.Window.DD = function(win){
991 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
992 this.setHandleElId(win.header.id);
996 Ext.extend(Ext.Window.DD, Ext.dd.DD, {
998 headerOffsets:[100, 25],
999 startDrag : function(){
1001 this.proxy = w.ghost();
1002 if(w.constrain !== false){
1003 var so = w.el.shadowOffset;
1004 this.constrainTo(w.container, {right: so, left: so, bottom: so});
1005 }else if(w.constrainHeader !== false){
1006 var s = this.proxy.getSize();
1007 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
1010 b4Drag : Ext.emptyFn,
1012 onDrag : function(e){
1013 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
1016 endDrag : function(e){
1018 this.win.saveState();
1022 * @class Ext.WindowGroup
1023 * An object that manages a group of {@link Ext.Window} instances and provides z-order management
1024 * and window activation behavior.
1027 Ext.WindowGroup = function(){
1029 var accessList = [];
1033 var sortWindows = function(d1, d2){
1034 return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
1038 var orderWindows = function(){
1039 var a = accessList, len = a.length;
1041 a.sort(sortWindows);
1042 var seed = a[0].manager.zseed;
1043 for(var i = 0; i < len; i++){
1045 if(win && !win.hidden){
1046 win.setZIndex(seed + (i*10));
1054 var setActiveWin = function(win){
1057 front.setActive(false);
1061 win.setActive(true);
1067 var activateLast = function(){
1068 for(var i = accessList.length-1; i >=0; --i) {
1069 if(!accessList[i].hidden){
1070 setActiveWin(accessList[i]);
1080 * The starting z-index for windows in this WindowGroup (defaults to 9000)
1081 * @type Number The z-index value
1086 * <p>Registers a {@link Ext.Window Window} with this WindowManager. This should not
1087 * need to be called under normal circumstances. Windows are automatically registered
1088 * with a {@link Ext.Window#manager manager} at construction time.</p>
1089 * <p>Where this may be useful is moving Windows between two WindowManagers. For example,
1090 * to bring the Ext.MessageBox dialog under the same manager as the Desktop's
1091 * WindowManager in the desktop sample app:</p><code><pre>
1092 var msgWin = Ext.MessageBox.getDialog();
1093 MyDesktop.getDesktop().getManager().register(msgWin);
1095 * @param {Window} win The Window to register.
1097 register : function(win){
1099 win.manager.unregister(win);
1104 accessList.push(win);
1105 win.on('hide', activateLast);
1109 * <p>Unregisters a {@link Ext.Window Window} from this WindowManager. This should not
1110 * need to be called. Windows are automatically unregistered upon destruction.
1111 * See {@link #register}.</p>
1112 * @param {Window} win The Window to unregister.
1114 unregister : function(win){
1116 delete list[win.id];
1117 win.un('hide', activateLast);
1118 accessList.remove(win);
1122 * Gets a registered window by id.
1123 * @param {String/Object} id The id of the window or a {@link Ext.Window} instance
1124 * @return {Ext.Window}
1127 return typeof id == "object" ? id : list[id];
1131 * Brings the specified window to the front of any other active windows in this WindowGroup.
1132 * @param {String/Object} win The id of the window or a {@link Ext.Window} instance
1133 * @return {Boolean} True if the dialog was brought to the front, else false
1134 * if it was already in front
1136 bringToFront : function(win){
1137 win = this.get(win);
1139 win._lastAccess = new Date().getTime();
1147 * Sends the specified window to the back of other active windows in this WindowGroup.
1148 * @param {String/Object} win The id of the window or a {@link Ext.Window} instance
1149 * @return {Ext.Window} The window
1151 sendToBack : function(win){
1152 win = this.get(win);
1153 win._lastAccess = -(new Date().getTime());
1159 * Hides all windows in this WindowGroup.
1161 hideAll : function(){
1162 for(var id in list){
1163 if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
1170 * Gets the currently-active window in this WindowGroup.
1171 * @return {Ext.Window} The active window
1173 getActive : function(){
1178 * Returns zero or more windows in this WindowGroup using the custom search function passed to this method.
1179 * The function should accept a single {@link Ext.Window} reference as its only argument and should
1180 * return true if the window matches the search criteria, otherwise it should return false.
1181 * @param {Function} fn The search function
1182 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the Window being tested.
1183 * that gets passed to the function if not specified)
1184 * @return {Array} An array of zero or more matching windows
1186 getBy : function(fn, scope){
1188 for(var i = accessList.length-1; i >=0; --i) {
1189 var win = accessList[i];
1190 if(fn.call(scope||win, win) !== false){
1198 * Executes the specified function once for every window in this WindowGroup, passing each
1199 * window as the only parameter. Returning false from the function will stop the iteration.
1200 * @param {Function} fn The function to execute for each item
1201 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the current Window in the iteration.
1203 each : function(fn, scope){
1204 for(var id in list){
1205 if(list[id] && typeof list[id] != "function"){
1206 if(fn.call(scope || list[id], list[id]) === false){
1217 * @class Ext.WindowMgr
1218 * @extends Ext.WindowGroup
1219 * The default global window group that is available automatically. To have more than one group of windows
1220 * with separate z-order stacks, create additional instances of {@link Ext.WindowGroup} as needed.
1223 Ext.WindowMgr = new Ext.WindowGroup();/**
1224 * @class Ext.MessageBox
1225 * <p>Utility class for generating different styles of message boxes. The alias Ext.Msg can also be used.<p/>
1226 * <p>Note that the MessageBox is asynchronous. Unlike a regular JavaScript <code>alert</code> (which will halt
1227 * browser execution), showing a MessageBox will not cause the code to stop. For this reason, if you have code
1228 * that should only run <em>after</em> some user feedback from the MessageBox, you must use a callback function
1229 * (see the <code>function</code> parameter for {@link #show} for more details).</p>
1230 * <p>Example usage:</p>
1233 Ext.Msg.alert('Status', 'Changes saved successfully.');
1235 // Prompt for user data and process the result using a callback:
1236 Ext.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
1238 // process text value and close...
1242 // Show a dialog using config options:
1244 title:'Save Changes?',
1245 msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
1246 buttons: Ext.Msg.YESNOCANCEL,
1249 icon: Ext.MessageBox.QUESTION
1254 Ext.MessageBox = function(){
1255 var dlg, opt, mask, waitTimer,
1256 bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl,
1257 buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '',
1258 buttonNames = ['ok', 'yes', 'no', 'cancel'];
1261 var handleButton = function(button){
1262 buttons[button].blur();
1263 if(dlg.isVisible()){
1266 Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value, opt], 1);
1271 var handleHide = function(){
1273 dlg.el.removeClass(opt.cls);
1275 progressBar.reset();
1279 var handleEsc = function(d, k, e){
1280 if(opt && opt.closable !== false){
1290 var updateButtons = function(b){
1294 Ext.each(buttonNames, function(name){
1295 buttons[name].hide();
1299 dlg.footer.dom.style.display = '';
1300 Ext.iterate(buttons, function(name, btn){
1304 btn.setText(Ext.isString(cfg) ? cfg : Ext.MessageBox.buttonText[name]);
1305 width += btn.getEl().getWidth() + 15;
1315 * Returns a reference to the underlying {@link Ext.Window} element
1316 * @return {Ext.Window} The window
1318 getDialog : function(titleText){
1323 Ext.each(buttonNames, function(name){
1324 btns.push(buttons[name] = new Ext.Button({
1325 text: this.buttonText[name],
1326 handler: handleButton.createCallback(name),
1330 dlg = new Ext.Window({
1335 constrainHeader:true,
1336 minimizable : false,
1337 maximizable : false,
1341 buttonAlign:"center",
1349 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
1352 handleButton("cancel");
1355 fbar: new Ext.Toolbar({
1357 enableOverflow: false
1360 dlg.render(document.body);
1361 dlg.getEl().addClass('x-window-dlg');
1363 bodyEl = dlg.body.createChild({
1364 html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><div class="ext-mb-fix-cursor"><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div></div>'
1366 iconEl = Ext.get(bodyEl.dom.firstChild);
1367 var contentEl = bodyEl.dom.childNodes[1];
1368 msgEl = Ext.get(contentEl.firstChild);
1369 textboxEl = Ext.get(contentEl.childNodes[2].firstChild);
1370 textboxEl.enableDisplayMode();
1371 textboxEl.addKeyListener([10,13], function(){
1372 if(dlg.isVisible() && opt && opt.buttons){
1375 }else if(opt.buttons.yes){
1376 handleButton("yes");
1380 textareaEl = Ext.get(contentEl.childNodes[2].childNodes[1]);
1381 textareaEl.enableDisplayMode();
1382 progressBar = new Ext.ProgressBar({
1385 bodyEl.createChild({cls:'x-clear'});
1391 * Updates the message box body text
1392 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
1393 * the XHTML-compliant non-breaking space character '&#160;')
1394 * @return {Ext.MessageBox} this
1396 updateText : function(text){
1397 if(!dlg.isVisible() && !opt.width){
1398 dlg.setSize(this.maxWidth, 100); // resize first so content is never clipped from previous shows
1400 msgEl.update(text || ' ');
1402 var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0,
1403 mw = msgEl.getWidth() + msgEl.getMargins('lr'),
1404 fw = dlg.getFrameWidth('lr'),
1405 bw = dlg.body.getFrameWidth('lr'),
1408 if (Ext.isIE && iw > 0){
1409 //3 pixels get subtracted in the icon CSS for an IE margin issue,
1410 //so we have to add it back here for the overall width to be consistent
1413 w = Math.max(Math.min(opt.width || iw+mw+fw+bw, opt.maxWidth || this.maxWidth),
1414 Math.max(opt.minWidth || this.minWidth, bwidth || 0));
1416 if(opt.prompt === true){
1417 activeTextEl.setWidth(w-iw-fw-bw);
1419 if(opt.progress === true || opt.wait === true){
1420 progressBar.setSize(w-iw-fw-bw);
1422 if(Ext.isIE && w == bwidth){
1423 w += 4; //Add offset when the content width is smaller than the buttons.
1425 dlg.setSize(w, 'auto').center();
1430 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
1431 * initiated via {@link Ext.MessageBox#progress} or {@link Ext.MessageBox#wait},
1432 * or by calling {@link Ext.MessageBox#show} with progress: true.
1433 * @param {Number} value Any number between 0 and 1 (e.g., .5, defaults to 0)
1434 * @param {String} progressText The progress text to display inside the progress bar (defaults to '')
1435 * @param {String} msg The message box's body text is replaced with the specified string (defaults to undefined
1436 * so that any existing body text will not get overwritten by default unless a new value is passed in)
1437 * @return {Ext.MessageBox} this
1439 updateProgress : function(value, progressText, msg){
1440 progressBar.updateProgress(value, progressText);
1442 this.updateText(msg);
1448 * Returns true if the message box is currently displayed
1449 * @return {Boolean} True if the message box is visible, else false
1451 isVisible : function(){
1452 return dlg && dlg.isVisible();
1456 * Hides the message box if it is displayed
1457 * @return {Ext.MessageBox} this
1460 var proxy = dlg ? dlg.activeGhost : null;
1461 if(this.isVisible() || proxy){
1465 // unghost is a private function, but i saw no better solution
1466 // to fix the locking problem when dragging while it closes
1467 dlg.unghost(false, false);
1474 * Displays a new message box, or reinitializes an existing message box, based on the config options
1475 * passed in. All display functions (e.g. prompt, alert, etc.) on MessageBox call this function internally,
1476 * although those calls are basic shortcuts and do not support all of the config options allowed here.
1477 * @param {Object} config The following config options are supported: <ul>
1478 * <li><b>animEl</b> : String/Element<div class="sub-desc">An id or Element from which the message box should animate as it
1479 * opens and closes (defaults to undefined)</div></li>
1480 * <li><b>buttons</b> : Object/Boolean<div class="sub-desc">A button config object (e.g., Ext.MessageBox.OKCANCEL or {ok:'Foo',
1481 * cancel:'Bar'}), or false to not show any buttons (defaults to false)</div></li>
1482 * <li><b>closable</b> : Boolean<div class="sub-desc">False to hide the top-right close button (defaults to true). Note that
1483 * progress and wait dialogs will ignore this property and always hide the close button as they can only
1484 * be closed programmatically.</div></li>
1485 * <li><b>cls</b> : String<div class="sub-desc">A custom CSS class to apply to the message box's container element</div></li>
1486 * <li><b>defaultTextHeight</b> : Number<div class="sub-desc">The default height in pixels of the message box's multiline textarea
1487 * if displayed (defaults to 75)</div></li>
1488 * <li><b>fn</b> : Function<div class="sub-desc">A callback function which is called when the dialog is dismissed either
1489 * by clicking on the configured buttons, or on the dialog close button, or by pressing
1490 * the return button to enter input.
1491 * <p>Progress and wait dialogs will ignore this option since they do not respond to user
1492 * actions and can only be closed programmatically, so any required function should be called
1493 * by the same code after it closes the dialog. Parameters passed:<ul>
1494 * <li><b>buttonId</b> : String<div class="sub-desc">The ID of the button pressed, one of:<div class="sub-desc"><ul>
1495 * <li><tt>ok</tt></li>
1496 * <li><tt>yes</tt></li>
1497 * <li><tt>no</tt></li>
1498 * <li><tt>cancel</tt></li>
1499 * </ul></div></div></li>
1500 * <li><b>text</b> : String<div class="sub-desc">Value of the input field if either <tt><a href="#show-option-prompt" ext:member="show-option-prompt" ext:cls="Ext.MessageBox">prompt</a></tt>
1501 * or <tt><a href="#show-option-multiline" ext:member="show-option-multiline" ext:cls="Ext.MessageBox">multiline</a></tt> is true</div></li>
1502 * <li><b>opt</b> : Object<div class="sub-desc">The config object passed to show.</div></li>
1503 * </ul></p></div></li>
1504 * <li><b>scope</b> : Object<div class="sub-desc">The scope of the callback function</div></li>
1505 * <li><b>icon</b> : String<div class="sub-desc">A CSS class that provides a background image to be used as the body icon for the
1506 * dialog (e.g. Ext.MessageBox.WARNING or 'custom-class') (defaults to '')</div></li>
1507 * <li><b>iconCls</b> : String<div class="sub-desc">The standard {@link Ext.Window#iconCls} to
1508 * add an optional header icon (defaults to '')</div></li>
1509 * <li><b>maxWidth</b> : Number<div class="sub-desc">The maximum width in pixels of the message box (defaults to 600)</div></li>
1510 * <li><b>minWidth</b> : Number<div class="sub-desc">The minimum width in pixels of the message box (defaults to 100)</div></li>
1511 * <li><b>modal</b> : Boolean<div class="sub-desc">False to allow user interaction with the page while the message box is
1512 * displayed (defaults to true)</div></li>
1513 * <li><b>msg</b> : String<div class="sub-desc">A string that will replace the existing message box body text (defaults to the
1514 * XHTML-compliant non-breaking space character '&#160;')</div></li>
1515 * <li><a id="show-option-multiline"></a><b>multiline</b> : Boolean<div class="sub-desc">
1516 * True to prompt the user to enter multi-line text (defaults to false)</div></li>
1517 * <li><b>progress</b> : Boolean<div class="sub-desc">True to display a progress bar (defaults to false)</div></li>
1518 * <li><b>progressText</b> : String<div class="sub-desc">The text to display inside the progress bar if progress = true (defaults to '')</div></li>
1519 * <li><a id="show-option-prompt"></a><b>prompt</b> : Boolean<div class="sub-desc">True to prompt the user to enter single-line text (defaults to false)</div></li>
1520 * <li><b>proxyDrag</b> : Boolean<div class="sub-desc">True to display a lightweight proxy while dragging (defaults to false)</div></li>
1521 * <li><b>title</b> : String<div class="sub-desc">The title text</div></li>
1522 * <li><b>value</b> : String<div class="sub-desc">The string value to set into the active textbox element if displayed</div></li>
1523 * <li><b>wait</b> : Boolean<div class="sub-desc">True to display a progress bar (defaults to false)</div></li>
1524 * <li><b>waitConfig</b> : Object<div class="sub-desc">A {@link Ext.ProgressBar#waitConfig} object (applies only if wait = true)</div></li>
1525 * <li><b>width</b> : Number<div class="sub-desc">The width of the dialog in pixels</div></li>
1531 msg: 'Please enter your address:',
1533 buttons: Ext.MessageBox.OKCANCEL,
1536 animEl: 'addAddressBtn',
1537 icon: Ext.MessageBox.INFO
1540 * @return {Ext.MessageBox} this
1542 show : function(options){
1543 if(this.isVisible()){
1547 var d = this.getDialog(opt.title || " ");
1549 d.setTitle(opt.title || " ");
1550 var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);
1551 d.tools.close.setDisplayed(allowClose);
1552 activeTextEl = textboxEl;
1553 opt.prompt = opt.prompt || (opt.multiline ? true : false);
1558 textareaEl.setHeight(Ext.isNumber(opt.multiline) ? opt.multiline : this.defaultTextHeight);
1559 activeTextEl = textareaEl;
1568 activeTextEl.dom.value = opt.value || "";
1570 d.focusEl = activeTextEl;
1572 var bs = opt.buttons;
1576 }else if(bs && bs.yes){
1577 db = buttons["yes"];
1584 d.setIconClass(opt.iconCls);
1586 this.setIcon(Ext.isDefined(opt.icon) ? opt.icon : bufferIcon);
1587 bwidth = updateButtons(opt.buttons);
1588 progressBar.setVisible(opt.progress === true || opt.wait === true);
1589 this.updateProgress(0, opt.progressText);
1590 this.updateText(opt.msg);
1592 d.el.addClass(opt.cls);
1594 d.proxyDrag = opt.proxyDrag === true;
1595 d.modal = opt.modal !== false;
1596 d.mask = opt.modal !== false ? mask : false;
1598 // force it to the end of the z-index stack so it gets a cursor in FF
1599 document.body.appendChild(dlg.el.dom);
1600 d.setAnimateTarget(opt.animEl);
1601 //workaround for window internally enabling keymap in afterShow
1602 d.on('show', function(){
1603 if(allowClose === true){
1608 }, this, {single:true});
1611 if(opt.wait === true){
1612 progressBar.wait(opt.waitConfig);
1618 * Adds the specified icon to the dialog. By default, the class 'ext-mb-icon' is applied for default
1619 * styling, and the class passed in is expected to supply the background image url. Pass in empty string ('')
1620 * to clear any existing icon. This method must be called before the MessageBox is shown.
1621 * The following built-in icon classes are supported, but you can also pass in a custom class name:
1624 Ext.MessageBox.WARNING
1625 Ext.MessageBox.QUESTION
1626 Ext.MessageBox.ERROR
1628 * @param {String} icon A CSS classname specifying the icon's background image url, or empty string to clear the icon
1629 * @return {Ext.MessageBox} this
1631 setIcon : function(icon){
1636 bufferIcon = undefined;
1637 if(icon && icon != ''){
1638 iconEl.removeClass('x-hidden');
1639 iconEl.replaceClass(iconCls, icon);
1640 bodyEl.addClass('x-dlg-icon');
1643 iconEl.replaceClass(iconCls, 'x-hidden');
1644 bodyEl.removeClass('x-dlg-icon');
1651 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
1652 * the user. You are responsible for updating the progress bar as needed via {@link Ext.MessageBox#updateProgress}
1653 * and closing the message box when the process is complete.
1654 * @param {String} title The title bar text
1655 * @param {String} msg The message box body text
1656 * @param {String} progressText (optional) The text to display inside the progress bar (defaults to '')
1657 * @return {Ext.MessageBox} this
1659 progress : function(title, msg, progressText){
1666 minWidth: this.minProgressWidth,
1667 progressText: progressText
1673 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
1674 * interaction while waiting for a long-running process to complete that does not have defined intervals.
1675 * You are responsible for closing the message box when the process is complete.
1676 * @param {String} msg The message box body text
1677 * @param {String} title (optional) The title bar text
1678 * @param {Object} config (optional) A {@link Ext.ProgressBar#waitConfig} object
1679 * @return {Ext.MessageBox} this
1681 wait : function(msg, title, config){
1689 minWidth: this.minProgressWidth,
1696 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript alert prompt).
1697 * If a callback function is passed it will be called after the user clicks the button, and the
1698 * id of the button that was clicked will be passed as the only parameter to the callback
1699 * (could also be the top-right close button).
1700 * @param {String} title The title bar text
1701 * @param {String} msg The message box body text
1702 * @param {Function} fn (optional) The callback function invoked after the message box is closed
1703 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.
1704 * @return {Ext.MessageBox} this
1706 alert : function(title, msg, fn, scope){
1713 minWidth: this.minWidth
1719 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's confirm).
1720 * If a callback function is passed it will be called after the user clicks either button,
1721 * and the id of the button that was clicked will be passed as the only parameter to the callback
1722 * (could also be the top-right close button).
1723 * @param {String} title The title bar text
1724 * @param {String} msg The message box body text
1725 * @param {Function} fn (optional) The callback function invoked after the message box is closed
1726 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.
1727 * @return {Ext.MessageBox} this
1729 confirm : function(title, msg, fn, scope){
1733 buttons: this.YESNO,
1736 icon: this.QUESTION,
1737 minWidth: this.minWidth
1743 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's prompt).
1744 * The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after the user
1745 * clicks either button, and the id of the button that was clicked (could also be the top-right
1746 * close button) and the text that was entered will be passed as the two parameters to the callback.
1747 * @param {String} title The title bar text
1748 * @param {String} msg The message box body text
1749 * @param {Function} fn (optional) The callback function invoked after the message box is closed
1750 * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.
1751 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
1752 * property, or the height in pixels to create the textbox (defaults to false / single-line)
1753 * @param {String} value (optional) Default value of the text input element (defaults to '')
1754 * @return {Ext.MessageBox} this
1756 prompt : function(title, msg, fn, scope, multiline, value){
1760 buttons: this.OKCANCEL,
1762 minWidth: this.minPromptWidth,
1765 multiline: multiline,
1772 * Button config that displays a single OK button
1777 * Button config that displays a single Cancel button
1780 CANCEL : {cancel:true},
1782 * Button config that displays OK and Cancel buttons
1785 OKCANCEL : {ok:true, cancel:true},
1787 * Button config that displays Yes and No buttons
1790 YESNO : {yes:true, no:true},
1792 * Button config that displays Yes, No and Cancel buttons
1795 YESNOCANCEL : {yes:true, no:true, cancel:true},
1797 * The CSS class that provides the INFO icon image
1800 INFO : 'ext-mb-info',
1802 * The CSS class that provides the WARNING icon image
1805 WARNING : 'ext-mb-warning',
1807 * The CSS class that provides the QUESTION icon image
1810 QUESTION : 'ext-mb-question',
1812 * The CSS class that provides the ERROR icon image
1815 ERROR : 'ext-mb-error',
1818 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
1821 defaultTextHeight : 75,
1823 * The maximum width in pixels of the message box (defaults to 600)
1828 * The minimum width in pixels of the message box (defaults to 100)
1833 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
1834 * for setting a different minimum width than text-only dialogs may need (defaults to 250).
1837 minProgressWidth : 250,
1839 * The minimum width in pixels of the message box if it is a prompt dialog. This is useful
1840 * for setting a different minimum width than text-only dialogs may need (defaults to 250).
1843 minPromptWidth: 250,
1845 * An object containing the default button text strings that can be overriden for localized language support.
1846 * Supported properties are: ok, cancel, yes and no. Generally you should include a locale-specific
1847 * resource file for handling language support across the framework.
1848 * Customize the default text like so: Ext.MessageBox.buttonText.yes = "oui"; //french
1861 * Shorthand for {@link Ext.MessageBox}
1863 Ext.Msg = Ext.MessageBox;/**
1864 * @class Ext.dd.PanelProxy
1865 * A custom drag proxy implementation specific to {@link Ext.Panel}s. This class is primarily used internally
1866 * for the Panel's drag drop implementation, and should never need to be created directly.
1868 * @param panel The {@link Ext.Panel} to proxy for
1869 * @param config Configuration options
1871 Ext.dd.PanelProxy = function(panel, config){
1873 this.id = this.panel.id +'-ddproxy';
1874 Ext.apply(this, config);
1877 Ext.dd.PanelProxy.prototype = {
1879 * @cfg {Boolean} insertProxy True to insert a placeholder proxy element while dragging the panel,
1880 * false to drag with no proxy (defaults to true).
1884 // private overrides
1885 setStatus : Ext.emptyFn,
1886 reset : Ext.emptyFn,
1887 update : Ext.emptyFn,
1892 * Gets the proxy's element
1893 * @return {Element} The proxy's element
1900 * Gets the proxy's ghost element
1901 * @return {Element} The proxy's ghost element
1903 getGhost : function(){
1908 * Gets the proxy's element
1909 * @return {Element} The proxy's element
1911 getProxy : function(){
1921 this.proxy.remove();
1924 this.panel.el.dom.style.display = '';
1925 this.ghost.remove();
1935 this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
1936 this.ghost.setXY(this.panel.el.getXY());
1937 if(this.insertProxy){
1938 this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
1939 this.proxy.setSize(this.panel.getSize());
1941 this.panel.el.dom.style.display = 'none';
1946 repair : function(xy, callback, scope){
1948 if(typeof callback == "function"){
1949 callback.call(scope || this);
1954 * Moves the proxy to a different position in the DOM. This is typically called while dragging the Panel
1955 * to keep the proxy sync'd to the Panel's location.
1956 * @param {HTMLElement} parentNode The proxy's parent DOM node
1957 * @param {HTMLElement} before (optional) The sibling node before which the proxy should be inserted (defaults
1958 * to the parent's last child if not specified)
1960 moveProxy : function(parentNode, before){
1962 parentNode.insertBefore(this.proxy.dom, before);
1967 // private - DD implementation for Panels
1968 Ext.Panel.DD = function(panel, cfg){
1970 this.dragData = {panel: panel};
1971 this.proxy = new Ext.dd.PanelProxy(panel, cfg);
1972 Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
1973 var h = panel.header;
1975 this.setHandleElId(h.id);
1977 (h ? h : this.panel.body).setStyle('cursor', 'move');
1978 this.scroll = false;
1981 Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
1982 showFrame: Ext.emptyFn,
1983 startDrag: Ext.emptyFn,
1984 b4StartDrag: function(x, y) {
1987 b4MouseDown: function(e) {
1988 var x = e.getPageX();
1989 var y = e.getPageY();
1990 this.autoOffset(x, y);
1992 onInitDrag : function(x, y){
1993 this.onStartDrag(x, y);
1996 createFrame : Ext.emptyFn,
1997 getDragEl : function(e){
1998 return this.proxy.ghost.dom;
2000 endDrag : function(e){
2002 this.panel.saveState();
2005 autoOffset : function(x, y) {
2006 x -= this.startPageX;
2007 y -= this.startPageY;
2008 this.setDelta(x, y);