3 * Copyright(c) 2006-2009 Ext JS, LLC
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/Button} defaultButton
54 * The id / index of a button or a button instance to focus when this window received the focus.
57 * @cfg {Function} onEsc
58 * Allows override of the built-in processing for the escape key. Default action
59 * is to close the Window (performing whatever action is specified in {@link #closeAction}.
60 * To prevent the Window closing when the escape key is pressed, specify this as
61 * Ext.emptyFn (See {@link Ext#emptyFn}).
64 * @cfg {Boolean} collapsed
65 * True to render the window collapsed, false to render it expanded (defaults to false). Note that if
66 * {@link #expandOnShow} is true (the default) it will override the <tt>collapsed</tt> config and the window
67 * will always be expanded when shown.
70 * @cfg {Boolean} maximized
71 * True to initially display the window in a maximized state. (Defaults to false).
75 * @cfg {String} baseCls
76 * The base CSS class to apply to this panel's element (defaults to 'x-window').
80 * @cfg {Boolean} resizable
81 * True to allow user resizing at each edge and corner of the window, false to disable resizing (defaults to true).
85 * @cfg {Boolean} draggable
86 * True to allow the window to be dragged by the header bar, false to disable dragging (defaults to true). Note
87 * that by default the window will be centered in the viewport, so if dragging is disabled the window may need
88 * to be positioned programmatically after render (e.g., myWindow.setPosition(100, 100);).
92 * @cfg {Boolean} closable
93 * <p>True to display the 'close' tool button and allow the user to close the window, false to
94 * hide the button and disallow closing the window (defaults to true).</p>
95 * <p>By default, when close is requested by either clicking the close button in the header
96 * or pressing ESC when the Window has focus, the {@link #close} method will be called. This
97 * will <i>{@link Ext.Component#destroy destroy}</i> the Window and its content meaning that
98 * it may not be reused.</p>
99 * <p>To make closing a Window <i>hide</i> the Window so that it may be reused, set
100 * {@link #closeAction} to 'hide'.
104 * @cfg {String} closeAction
105 * <p>The action to take when the close header tool is clicked:
106 * <div class="mdetail-params"><ul>
107 * <li><b><code>'{@link #close}'</code></b> : <b>Default</b><div class="sub-desc">
108 * {@link #close remove} the window from the DOM and {@link Ext.Component#destroy destroy}
109 * it and all descendant Components. The window will <b>not</b> be available to be
110 * redisplayed via the {@link #show} method.
112 * <li><b><code>'{@link #hide}'</code></b> : <div class="sub-desc">
113 * {@link #hide} the window by setting visibility to hidden and applying negative offsets.
114 * The window will be available to be redisplayed via the {@link #show} method.
117 * <p><b>Note:</b> This setting does not affect the {@link #close} method
118 * which will always {@link Ext.Component#destroy destroy} the window. To
119 * programatically <i>hide</i> a window, call {@link #hide}.</p>
121 closeAction : 'close',
123 * @cfg {Boolean} constrain
124 * True to constrain the window within its containing element, false to allow it to fall outside of its
125 * containing element. By default the window will be rendered to document.body. To render and constrain the
126 * window within another element specify {@link #renderTo}.
127 * (defaults to false). Optionally the header only can be constrained using {@link #constrainHeader}.
131 * @cfg {Boolean} constrainHeader
132 * True to constrain the window header within its containing element (allowing the window body to fall outside
133 * of its containing element) or false to allow the header to fall outside its containing element (defaults to
134 * false). Optionally the entire window can be constrained using {@link #constrain}.
136 constrainHeader : false,
138 * @cfg {Boolean} plain
139 * True to render the window body with a transparent background so that it will blend into the framing
140 * elements, false to add a lighter background color to visually highlight the body element and separate it
141 * more distinctly from the surrounding frame (defaults to false).
145 * @cfg {Boolean} minimizable
146 * True to display the 'minimize' tool button and allow the user to minimize the window, false to hide the button
147 * and disallow minimizing the window (defaults to false). Note that this button provides no implementation --
148 * the behavior of minimizing a window is implementation-specific, so the minimize event must be handled and a
149 * custom minimize behavior implemented for this option to be useful.
153 * @cfg {Boolean} maximizable
154 * True to display the 'maximize' tool button and allow the user to maximize the window, false to hide the button
155 * and disallow maximizing the window (defaults to false). Note that when a window is maximized, the tool button
156 * will automatically change to a 'restore' button with the appropriate behavior already built-in that will
157 * restore the window to its previous size.
161 * @cfg {Number} minHeight
162 * The minimum height in pixels allowed for this window (defaults to 100). Only applies when resizable = true.
166 * @cfg {Number} minWidth
167 * The minimum width in pixels allowed for this window (defaults to 200). Only applies when resizable = true.
171 * @cfg {Boolean} expandOnShow
172 * True to always expand the window when it is displayed, false to keep it in its current state (which may be
173 * {@link #collapsed}) when displayed (defaults to true).
177 // inherited docs, same default
181 * @cfg {Boolean} initHidden
182 * True to hide the window until show() is explicitly called (defaults to true).
186 * @cfg {Boolean} monitorResize @hide
187 * This is automatically managed based on the value of constrain and constrainToHeader
189 monitorResize : true,
191 // The following configs are set to provide the basic functionality of a window.
192 // Changing them would require additional code to handle correctly and should
193 // usually only be done in subclasses that can provide custom behavior. Changing them
194 // may have unexpected or undesirable results.
195 /** @cfg {String} elements @hide */
196 elements : 'header,body',
197 /** @cfg {Boolean} frame @hide */
199 /** @cfg {Boolean} floating @hide */
203 initComponent : function(){
204 Ext.Window.superclass.initComponent.call(this);
208 * Fires after the window has been visually activated via {@link setActive}.
209 * @param {Ext.Window} this
213 * Fires after the window has been visually deactivated via {@link setActive}.
214 * @param {Ext.Window} this
218 * Fires after the window has been resized.
219 * @param {Ext.Window} this
220 * @param {Number} width The window's new width
221 * @param {Number} height The window's new height
226 * Fires after the window has been maximized.
227 * @param {Ext.Window} this
232 * Fires after the window has been minimized.
233 * @param {Ext.Window} this
238 * Fires after the window has been restored to its original size after being maximized.
239 * @param {Ext.Window} this
243 if(this.initHidden === false){
251 getState : function(){
252 return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
256 onRender : function(ct, position){
257 Ext.Window.superclass.onRender.call(this, ct, position);
260 this.el.addClass('x-window-plain');
263 // this element allows the Window to be focused for keyboard events
264 this.focusEl = this.el.createChild({
265 tag: 'a', href:'#', cls:'x-dlg-focus',
266 tabIndex:'-1', html: ' '});
267 this.focusEl.swallowEvent('click', true);
269 this.proxy = this.el.createProxy('x-window-proxy');
270 this.proxy.enableDisplayMode('block');
273 this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
274 this.mask.enableDisplayMode('block');
276 this.mon(this.mask, 'click', this.focus, this);
282 initEvents : function(){
283 Ext.Window.superclass.initEvents.call(this);
284 if(this.animateTarget){
285 this.setAnimateTarget(this.animateTarget);
289 this.resizer = new Ext.Resizable(this.el, {
290 minWidth: this.minWidth,
291 minHeight:this.minHeight,
292 handles: this.resizeHandles || 'all',
294 resizeElement : this.resizerAction
296 this.resizer.window = this;
297 this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
301 this.header.addClass('x-window-draggable');
303 this.mon(this.el, 'mousedown', this.toFront, this);
304 this.manager = this.manager || Ext.WindowMgr;
305 this.manager.register(this);
307 this.maximized = false;
311 var km = this.getKeyMap();
312 km.on(27, this.onEsc, this);
317 initDraggable : function(){
319 * If this Window is configured {@link #draggable}, this property will contain
320 * an instance of {@link Ext.dd.DD} which handles dragging the Window's DOM Element.
324 this.dd = new Ext.Window.DD(this);
329 this[this.closeAction]();
333 beforeDestroy : function(){
337 Ext.EventManager.removeResizeListener(this.doAnchor, this);
338 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
348 Ext.Window.superclass.beforeDestroy.call(this);
352 onDestroy : function(){
354 this.manager.unregister(this);
356 Ext.Window.superclass.onDestroy.call(this);
360 initTools : function(){
361 if(this.minimizable){
364 handler: this.minimize.createDelegate(this, [])
367 if(this.maximizable){
370 handler: this.maximize.createDelegate(this, [])
374 handler: this.restore.createDelegate(this, []),
377 this.mon(this.header, 'dblclick', this.toggleMaximize, this);
382 handler: this[this.closeAction].createDelegate(this, [])
388 resizerAction : function(){
389 var box = this.proxy.getBox();
391 this.window.handleResize(box);
396 beforeResize : function(){
397 this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); // 40 is a magic minimum content size?
398 this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
399 this.resizeBox = this.el.getBox();
403 updateHandles : function(){
404 if(Ext.isIE && this.resizer){
405 this.resizer.syncHandleHeight();
411 handleResize : function(box){
412 var rz = this.resizeBox;
413 if(rz.x != box.x || rz.y != box.y){
419 this.updateHandles();
422 this.fireEvent('resize', this, box.width, box.height);
426 * Focuses the window. If a defaultButton is set, it will receive focus, otherwise the
427 * window itself will receive focus.
430 var f = this.focusEl, db = this.defaultButton, t = typeof db;
431 if(t != 'undefined'){
432 if(t == 'number' && this.fbar){
433 f = this.fbar.items.get(db);
434 }else if(t == 'string'){
440 f = f || this.focusEl;
441 f.focus.defer(10, f);
445 * Sets the target element from which the window should animate while opening.
446 * @param {String/Element} el The target element or id
448 setAnimateTarget : function(el){
450 this.animateTarget = el;
454 beforeShow : function(){
455 delete this.el.lastXY;
456 delete this.el.lastLT;
457 if(this.x === undefined || this.y === undefined){
458 var xy = this.el.getAlignToXY(this.container, 'c-c');
459 var pos = this.el.translatePoints(xy[0], xy[1]);
460 this.x = this.x === undefined? pos.left : this.x;
461 this.y = this.y === undefined? pos.top : this.y;
463 this.el.setLeftTop(this.x, this.y);
465 if(this.expandOnShow){
470 Ext.getBody().addClass('x-body-masked');
471 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
477 * Shows the window, rendering it first if necessary, or activates it and brings it to front if hidden.
478 * @param {String/Element} animateTarget (optional) The target element or id from which the window should
479 * animate while opening (defaults to null with no animation)
480 * @param {Function} callback (optional) A callback function to call after the window is displayed
481 * @param {Object} scope (optional) The scope in which to execute the callback
482 * @return {Ext.Window} this
484 show : function(animateTarget, cb, scope){
486 this.render(Ext.getBody());
488 if(this.hidden === false){
492 if(this.fireEvent('beforeshow', this) === false){
496 this.on('show', cb, scope, {single:true});
499 if(animateTarget !== undefined){
500 this.setAnimateTarget(animateTarget);
503 if(this.animateTarget){
512 afterShow : function(isAnim){
514 this.el.setStyle('display', 'block');
519 if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
520 this.cascade(this.setAutoScroll);
523 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
524 Ext.EventManager.onWindowResize(this.onWindowResize, this);
529 this.keyMap.enable();
532 this.updateHandles();
533 if(isAnim && (Ext.isIE || Ext.isWebKit)){
534 var sz = this.getSize();
535 this.onResize(sz.width, sz.height);
537 this.fireEvent('show', this);
541 animShow : function(){
543 this.proxy.setBox(this.animateTarget.getBox());
544 this.proxy.setOpacity(0);
545 var b = this.getBox(false);
546 b.callback = this.afterShow.createDelegate(this, [true], false);
549 b.easing = 'easeNone';
552 this.el.setStyle('display', 'none');
557 * Hides the window, setting it to invisible and applying negative offsets.
558 * @param {String/Element} animateTarget (optional) The target element or id to which the window should
559 * animate while hiding (defaults to null with no animation)
560 * @param {Function} callback (optional) A callback function to call after the window is hidden
561 * @param {Object} scope (optional) The scope in which to execute the callback
562 * @return {Ext.Window} this
564 hide : function(animateTarget, cb, scope){
565 if(this.hidden || this.fireEvent('beforehide', this) === false){
569 this.on('hide', cb, scope, {single:true});
572 if(animateTarget !== undefined){
573 this.setAnimateTarget(animateTarget);
577 Ext.getBody().removeClass('x-body-masked');
579 if(this.animateTarget){
589 afterHide : function(){
591 if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
592 Ext.EventManager.removeResizeListener(this.onWindowResize, this);
595 this.keyMap.disable();
597 this.fireEvent('hide', this);
601 animHide : function(){
602 this.proxy.setOpacity(0.5);
604 var tb = this.getBox(false);
605 this.proxy.setBox(tb);
607 var b = this.animateTarget.getBox();
608 b.callback = this.afterHide;
611 b.easing = 'easeNone';
618 onWindowResize : function(){
623 this.mask.setSize('100%', '100%');
624 var force = this.mask.dom.offsetHeight;
625 this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
631 doConstrain : function(){
632 if(this.constrain || this.constrainHeader){
636 right:this.el.shadowOffset,
637 left:this.el.shadowOffset,
638 bottom:this.el.shadowOffset
641 var s = this.getSize();
643 right:-(s.width - 100),
644 bottom:-(s.height - 25)
648 var xy = this.el.getConstrainToXY(this.container, true, offsets);
650 this.setPosition(xy[0], xy[1]);
655 // private - used for dragging
656 ghost : function(cls){
657 var ghost = this.createGhost(cls);
658 var box = this.getBox(true);
659 ghost.setLeftTop(box.x, box.y);
660 ghost.setWidth(box.width);
662 this.activeGhost = ghost;
667 unghost : function(show, matchPosition){
668 if(!this.activeGhost) {
674 if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
675 this.cascade(this.setAutoScroll);
678 if(matchPosition !== false){
679 this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
681 this.activeGhost.hide();
682 this.activeGhost.remove();
683 delete this.activeGhost;
687 * Placeholder method for minimizing the window. By default, this method simply fires the {@link #minimize} event
688 * since the behavior of minimizing a window is application-specific. To implement custom minimize behavior,
689 * either the minimize event can be handled or this method can be overridden.
690 * @return {Ext.Window} this
692 minimize : function(){
693 this.fireEvent('minimize', this);
698 * <p>Closes the Window, removes it from the DOM, {@link Ext.Component#destroy destroy}s
699 * the Window object and all its descendant Components. The {@link Ext.Panel#beforeclose beforeclose}
700 * event is fired before the close happens and will cancel the close action if it returns false.<p>
701 * <p><b>Note:</b> This method is not affected by the {@link #closeAction} setting which
702 * only affects the action triggered when clicking the {@link #closable 'close' tool in the header}.
703 * To hide the Window without destroying it, call {@link #hide}.</p>
706 if(this.fireEvent('beforeclose', this) !== false){
707 this.hide(null, function(){
708 this.fireEvent('close', this);
715 * Fits the window within its current container and automatically replaces
716 * the {@link #maximizable 'maximize' tool button} with the 'restore' tool button.
717 * Also see {@link #toggleMaximize}.
718 * @return {Ext.Window} this
720 maximize : function(){
723 this.restoreSize = this.getSize();
724 this.restorePos = this.getPosition(true);
725 if (this.maximizable){
726 this.tools.maximize.hide();
727 this.tools.restore.show();
729 this.maximized = true;
730 this.el.disableShadow();
735 if(this.collapsible){
736 this.tools.toggle.hide();
738 this.el.addClass('x-window-maximized');
739 this.container.addClass('x-window-maximized-ct');
741 this.setPosition(0, 0);
743 this.fireEvent('maximize', this);
749 * Restores a {@link #maximizable maximized} window back to its original
750 * size and position prior to being maximized and also replaces
751 * the 'restore' tool button with the 'maximize' tool button.
752 * Also see {@link #toggleMaximize}.
753 * @return {Ext.Window} this
755 restore : function(){
757 this.el.removeClass('x-window-maximized');
758 this.tools.restore.hide();
759 this.tools.maximize.show();
760 this.setPosition(this.restorePos[0], this.restorePos[1]);
761 this.setSize(this.restoreSize.width, this.restoreSize.height);
762 delete this.restorePos;
763 delete this.restoreSize;
764 this.maximized = false;
765 this.el.enableShadow(true);
770 if(this.collapsible){
771 this.tools.toggle.show();
773 this.container.removeClass('x-window-maximized-ct');
776 this.fireEvent('restore', this);
782 * A shortcut method for toggling between {@link #maximize} and {@link #restore} based on the current maximized
783 * state of the window.
784 * @return {Ext.Window} this
786 toggleMaximize : function(){
787 return this[this.maximized ? 'restore' : 'maximize']();
791 fitContainer : function(){
792 var vs = this.container.getViewSize();
793 this.setSize(vs.width, vs.height);
797 // z-index is managed by the WindowManager and may be overwritten at any time
798 setZIndex : function(index){
800 this.mask.setStyle('z-index', index);
802 this.el.setZIndex(++index);
806 this.resizer.proxy.setStyle('z-index', ++index);
809 this.lastZIndex = index;
813 * Aligns the window to the specified element
814 * @param {Mixed} element The element to align to.
815 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details).
816 * @param {Array} offsets (optional) Offset the positioning by [x, y]
817 * @return {Ext.Window} this
819 alignTo : function(element, position, offsets){
820 var xy = this.el.getAlignToXY(element, position, offsets);
821 this.setPagePosition(xy[0], xy[1]);
826 * Anchors this window to another element and realigns it when the window is resized or scrolled.
827 * @param {Mixed} element The element to align to.
828 * @param {String} position The position to align to (see {@link Ext.Element#alignTo} for more details)
829 * @param {Array} offsets (optional) Offset the positioning by [x, y]
830 * @param {Boolean/Number} monitorScroll (optional) true to monitor body scroll and reposition. If this parameter
831 * is a number, it is used as the buffer delay (defaults to 50ms).
832 * @return {Ext.Window} this
834 anchorTo : function(el, alignment, offsets, monitorScroll){
836 Ext.EventManager.removeResizeListener(this.doAnchor, this);
837 Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
839 this.doAnchor = function(){
840 this.alignTo(el, alignment, offsets);
842 Ext.EventManager.onWindowResize(this.doAnchor, this);
844 var tm = typeof monitorScroll;
845 if(tm != 'undefined'){
846 Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
847 {buffer: tm == 'number' ? monitorScroll : 50});
854 * Brings this window to the front of any other visible windows
855 * @param {Boolean} e (optional) Specify <tt>false</tt> to prevent the window from being focused.
856 * @return {Ext.Window} this
858 toFront : function(e){
859 if(this.manager.bringToFront(this)){
860 if(!e || !e.getTarget().focus){
868 * Makes this the active window by showing its shadow, or deactivates it by hiding its shadow. This method also
869 * fires the {@link #activate} or {@link #deactivate} event depending on which action occurred.
870 * @param {Boolean} active True to activate the window, false to deactivate it (defaults to false)
872 setActive : function(active){
875 this.el.enableShadow(true);
877 this.fireEvent('activate', this);
879 this.el.disableShadow();
880 this.fireEvent('deactivate', this);
885 * Sends this window to the back of (lower z-index than) any other visible windows
886 * @return {Ext.Window} this
889 this.manager.sendToBack(this);
894 * Centers this window in the viewport
895 * @return {Ext.Window} this
898 var xy = this.el.getAlignToXY(this.container, 'c-c');
899 this.setPagePosition(xy[0], xy[1]);
904 * @cfg {Boolean} autoWidth @hide
907 Ext.reg('window', Ext.Window);
909 // private - custom Window DD implementation
910 Ext.Window.DD = function(win){
912 Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
913 this.setHandleElId(win.header.id);
917 Ext.extend(Ext.Window.DD, Ext.dd.DD, {
919 headerOffsets:[100, 25],
920 startDrag : function(){
922 this.proxy = w.ghost();
923 if(w.constrain !== false){
924 var so = w.el.shadowOffset;
925 this.constrainTo(w.container, {right: so, left: so, bottom: so});
926 }else if(w.constrainHeader !== false){
927 var s = this.proxy.getSize();
928 this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
931 b4Drag : Ext.emptyFn,
933 onDrag : function(e){
934 this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
937 endDrag : function(e){
939 this.win.saveState();
943 * @class Ext.WindowGroup
944 * An object that represents a group of {@link Ext.Window} instances and provides z-order management
945 * and window activation behavior.
948 Ext.WindowGroup = function(){
954 var sortWindows = function(d1, d2){
955 return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
959 var orderWindows = function(){
960 var a = accessList, len = a.length;
963 var seed = a[0].manager.zseed;
964 for(var i = 0; i < len; i++){
966 if(win && !win.hidden){
967 win.setZIndex(seed + (i*10));
975 var setActiveWin = function(win){
978 front.setActive(false);
988 var activateLast = function(){
989 for(var i = accessList.length-1; i >=0; --i) {
990 if(!accessList[i].hidden){
991 setActiveWin(accessList[i]);
1001 * The starting z-index for windows (defaults to 9000)
1002 * @type Number The z-index value
1007 register : function(win){
1009 accessList.push(win);
1010 win.on('hide', activateLast);
1014 unregister : function(win){
1015 delete list[win.id];
1016 win.un('hide', activateLast);
1017 accessList.remove(win);
1021 * Gets a registered window by id.
1022 * @param {String/Object} id The id of the window or a {@link Ext.Window} instance
1023 * @return {Ext.Window}
1026 return typeof id == "object" ? id : list[id];
1030 * Brings the specified window to the front of any other active windows.
1031 * @param {String/Object} win The id of the window or a {@link Ext.Window} instance
1032 * @return {Boolean} True if the dialog was brought to the front, else false
1033 * if it was already in front
1035 bringToFront : function(win){
1036 win = this.get(win);
1038 win._lastAccess = new Date().getTime();
1046 * Sends the specified window to the back of other active windows.
1047 * @param {String/Object} win The id of the window or a {@link Ext.Window} instance
1048 * @return {Ext.Window} The window
1050 sendToBack : function(win){
1051 win = this.get(win);
1052 win._lastAccess = -(new Date().getTime());
1058 * Hides all windows in the group.
1060 hideAll : function(){
1061 for(var id in list){
1062 if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
1069 * Gets the currently-active window in the group.
1070 * @return {Ext.Window} The active window
1072 getActive : function(){
1077 * Returns zero or more windows in the group using the custom search function passed to this method.
1078 * The function should accept a single {@link Ext.Window} reference as its only argument and should
1079 * return true if the window matches the search criteria, otherwise it should return false.
1080 * @param {Function} fn The search function
1081 * @param {Object} scope (optional) The scope in which to execute the function (defaults to the window
1082 * that gets passed to the function if not specified)
1083 * @return {Array} An array of zero or more matching windows
1085 getBy : function(fn, scope){
1087 for(var i = accessList.length-1; i >=0; --i) {
1088 var win = accessList[i];
1089 if(fn.call(scope||win, win) !== false){
1097 * Executes the specified function once for every window in the group, passing each
1098 * window as the only parameter. Returning false from the function will stop the iteration.
1099 * @param {Function} fn The function to execute for each item
1100 * @param {Object} scope (optional) The scope in which to execute the function
1102 each : function(fn, scope){
1103 for(var id in list){
1104 if(list[id] && typeof list[id] != "function"){
1105 if(fn.call(scope || list[id], list[id]) === false){
1116 * @class Ext.WindowMgr
1117 * @extends Ext.WindowGroup
1118 * The default global window group that is available automatically. To have more than one group of windows
1119 * with separate z-order stacks, create additional instances of {@link Ext.WindowGroup} as needed.
1122 Ext.WindowMgr = new Ext.WindowGroup();/**
1123 * @class Ext.MessageBox
1124 * <p>Utility class for generating different styles of message boxes. The alias Ext.Msg can also be used.<p/>
1125 * <p>Note that the MessageBox is asynchronous. Unlike a regular JavaScript <code>alert</code> (which will halt
1126 * browser execution), showing a MessageBox will not cause the code to stop. For this reason, if you have code
1127 * that should only run <em>after</em> some user feedback from the MessageBox, you must use a callback function
1128 * (see the <code>function</code> parameter for {@link #show} for more details).</p>
1129 * <p>Example usage:</p>
1132 Ext.Msg.alert('Status', 'Changes saved successfully.');
1134 // Prompt for user data and process the result using a callback:
1135 Ext.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
1137 // process text value and close...
1141 // Show a dialog using config options:
1143 title:'Save Changes?',
1144 msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
1145 buttons: Ext.Msg.YESNOCANCEL,
1148 icon: Ext.MessageBox.QUESTION
1153 Ext.MessageBox = function(){
1154 var dlg, opt, mask, waitTimer;
1155 var bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl;
1156 var buttons, activeTextEl, bwidth, iconCls = '';
1159 var handleButton = function(button){
1160 if(dlg.isVisible()){
1163 Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value, opt], 1);
1168 var handleHide = function(){
1170 dlg.el.removeClass(opt.cls);
1172 progressBar.reset();
1176 var handleEsc = function(d, k, e){
1177 if(opt && opt.closable !== false){
1187 var updateButtons = function(b){
1190 buttons["ok"].hide();
1191 buttons["cancel"].hide();
1192 buttons["yes"].hide();
1193 buttons["no"].hide();
1196 dlg.footer.dom.style.display = '';
1197 for(var k in buttons){
1198 if(typeof buttons[k] != "function"){
1201 buttons[k].setText(typeof b[k] == "string" ? b[k] : Ext.MessageBox.buttonText[k]);
1202 width += buttons[k].el.getWidth()+15;
1213 * Returns a reference to the underlying {@link Ext.Window} element
1214 * @return {Ext.Window} The window
1216 getDialog : function(titleText){
1218 dlg = new Ext.Window({
1223 constrainHeader:true,
1224 minimizable : false,
1225 maximizable : false,
1229 buttonAlign:"center",
1237 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
1240 handleButton("cancel");
1245 var bt = this.buttonText;
1246 //TODO: refactor this block into a buttons config to pass into the Window constructor
1247 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
1248 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
1249 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
1250 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
1251 buttons["ok"].hideMode = buttons["yes"].hideMode = buttons["no"].hideMode = buttons["cancel"].hideMode = 'offsets';
1252 dlg.render(document.body);
1253 dlg.getEl().addClass('x-window-dlg');
1255 bodyEl = dlg.body.createChild({
1256 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>'
1258 iconEl = Ext.get(bodyEl.dom.firstChild);
1259 var contentEl = bodyEl.dom.childNodes[1];
1260 msgEl = Ext.get(contentEl.firstChild);
1261 textboxEl = Ext.get(contentEl.childNodes[2].firstChild);
1262 textboxEl.enableDisplayMode();
1263 textboxEl.addKeyListener([10,13], function(){
1264 if(dlg.isVisible() && opt && opt.buttons){
1267 }else if(opt.buttons.yes){
1268 handleButton("yes");
1272 textareaEl = Ext.get(contentEl.childNodes[2].childNodes[1]);
1273 textareaEl.enableDisplayMode();
1274 progressBar = new Ext.ProgressBar({
1277 bodyEl.createChild({cls:'x-clear'});
1283 * Updates the message box body text
1284 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
1285 * the XHTML-compliant non-breaking space character '&#160;')
1286 * @return {Ext.MessageBox} this
1288 updateText : function(text){
1289 if(!dlg.isVisible() && !opt.width){
1290 dlg.setSize(this.maxWidth, 100); // resize first so content is never clipped from previous shows
1292 msgEl.update(text || ' ');
1294 var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0;
1295 var mw = msgEl.getWidth() + msgEl.getMargins('lr');
1296 var fw = dlg.getFrameWidth('lr');
1297 var bw = dlg.body.getFrameWidth('lr');
1298 if (Ext.isIE && iw > 0){
1299 //3 pixels get subtracted in the icon CSS for an IE margin issue,
1300 //so we have to add it back here for the overall width to be consistent
1303 var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth),
1304 Math.max(opt.minWidth || this.minWidth, bwidth || 0));
1306 if(opt.prompt === true){
1307 activeTextEl.setWidth(w-iw-fw-bw);
1309 if(opt.progress === true || opt.wait === true){
1310 progressBar.setSize(w-iw-fw-bw);
1312 if(Ext.isIE && w == bwidth){
1313 w += 4; //Add offset when the content width is smaller than the buttons.
1315 dlg.setSize(w, 'auto').center();
1320 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
1321 * initiated via {@link Ext.MessageBox#progress} or {@link Ext.MessageBox#wait},
1322 * or by calling {@link Ext.MessageBox#show} with progress: true.
1323 * @param {Number} value Any number between 0 and 1 (e.g., .5, defaults to 0)
1324 * @param {String} progressText The progress text to display inside the progress bar (defaults to '')
1325 * @param {String} msg The message box's body text is replaced with the specified string (defaults to undefined
1326 * so that any existing body text will not get overwritten by default unless a new value is passed in)
1327 * @return {Ext.MessageBox} this
1329 updateProgress : function(value, progressText, msg){
1330 progressBar.updateProgress(value, progressText);
1332 this.updateText(msg);
1338 * Returns true if the message box is currently displayed
1339 * @return {Boolean} True if the message box is visible, else false
1341 isVisible : function(){
1342 return dlg && dlg.isVisible();
1346 * Hides the message box if it is displayed
1347 * @return {Ext.MessageBox} this
1350 var proxy = dlg ? dlg.activeGhost : null;
1351 if(this.isVisible() || proxy){
1355 // unghost is a private function, but i saw no better solution
1356 // to fix the locking problem when dragging while it closes
1357 dlg.unghost(false, false);
1364 * Displays a new message box, or reinitializes an existing message box, based on the config options
1365 * passed in. All display functions (e.g. prompt, alert, etc.) on MessageBox call this function internally,
1366 * although those calls are basic shortcuts and do not support all of the config options allowed here.
1367 * @param {Object} config The following config options are supported: <ul>
1368 * <li><b>animEl</b> : String/Element<div class="sub-desc">An id or Element from which the message box should animate as it
1369 * opens and closes (defaults to undefined)</div></li>
1370 * <li><b>buttons</b> : Object/Boolean<div class="sub-desc">A button config object (e.g., Ext.MessageBox.OKCANCEL or {ok:'Foo',
1371 * cancel:'Bar'}), or false to not show any buttons (defaults to false)</div></li>
1372 * <li><b>closable</b> : Boolean<div class="sub-desc">False to hide the top-right close button (defaults to true). Note that
1373 * progress and wait dialogs will ignore this property and always hide the close button as they can only
1374 * be closed programmatically.</div></li>
1375 * <li><b>cls</b> : String<div class="sub-desc">A custom CSS class to apply to the message box's container element</div></li>
1376 * <li><b>defaultTextHeight</b> : Number<div class="sub-desc">The default height in pixels of the message box's multiline textarea
1377 * if displayed (defaults to 75)</div></li>
1378 * <li><b>fn</b> : Function<div class="sub-desc">A callback function which is called when the dialog is dismissed either
1379 * by clicking on the configured buttons, or on the dialog close button, or by pressing
1380 * the return button to enter input.
1381 * <p>Progress and wait dialogs will ignore this option since they do not respond to user
1382 * actions and can only be closed programmatically, so any required function should be called
1383 * by the same code after it closes the dialog. Parameters passed:<ul>
1384 * <li><b>buttonId</b> : String<div class="sub-desc">The ID of the button pressed, one of:<div class="sub-desc"><ul>
1385 * <li><tt>ok</tt></li>
1386 * <li><tt>yes</tt></li>
1387 * <li><tt>no</tt></li>
1388 * <li><tt>cancel</tt></li>
1389 * </ul></div></div></li>
1390 * <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>
1391 * or <tt><a href="#show-option-multiline" ext:member="show-option-multiline" ext:cls="Ext.MessageBox">multiline</a></tt> is true</div></li>
1392 * <li><b>opt</b> : Object<div class="sub-desc">The config object passed to show.</div></li>
1393 * </ul></p></div></li>
1394 * <li><b>scope</b> : Object<div class="sub-desc">The scope of the callback function</div></li>
1395 * <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
1396 * dialog (e.g. Ext.MessageBox.WARNING or 'custom-class') (defaults to '')</div></li>
1397 * <li><b>iconCls</b> : String<div class="sub-desc">The standard {@link Ext.Window#iconCls} to
1398 * add an optional header icon (defaults to '')</div></li>
1399 * <li><b>maxWidth</b> : Number<div class="sub-desc">The maximum width in pixels of the message box (defaults to 600)</div></li>
1400 * <li><b>minWidth</b> : Number<div class="sub-desc">The minimum width in pixels of the message box (defaults to 100)</div></li>
1401 * <li><b>modal</b> : Boolean<div class="sub-desc">False to allow user interaction with the page while the message box is
1402 * displayed (defaults to true)</div></li>
1403 * <li><b>msg</b> : String<div class="sub-desc">A string that will replace the existing message box body text (defaults to the
1404 * XHTML-compliant non-breaking space character '&#160;')</div></li>
1405 * <li><a id="show-option-multiline"></a><b>multiline</b> : Boolean<div class="sub-desc">
1406 * True to prompt the user to enter multi-line text (defaults to false)</div></li>
1407 * <li><b>progress</b> : Boolean<div class="sub-desc">True to display a progress bar (defaults to false)</div></li>
1408 * <li><b>progressText</b> : String<div class="sub-desc">The text to display inside the progress bar if progress = true (defaults to '')</div></li>
1409 * <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>
1410 * <li><b>proxyDrag</b> : Boolean<div class="sub-desc">True to display a lightweight proxy while dragging (defaults to false)</div></li>
1411 * <li><b>title</b> : String<div class="sub-desc">The title text</div></li>
1412 * <li><b>value</b> : String<div class="sub-desc">The string value to set into the active textbox element if displayed</div></li>
1413 * <li><b>wait</b> : Boolean<div class="sub-desc">True to display a progress bar (defaults to false)</div></li>
1414 * <li><b>waitConfig</b> : Object<div class="sub-desc">A {@link Ext.ProgressBar#waitConfig} object (applies only if wait = true)</div></li>
1415 * <li><b>width</b> : Number<div class="sub-desc">The width of the dialog in pixels</div></li>
1421 msg: 'Please enter your address:',
1423 buttons: Ext.MessageBox.OKCANCEL,
1426 animEl: 'addAddressBtn',
1427 icon: Ext.MessageBox.INFO
1430 * @return {Ext.MessageBox} this
1432 show : function(options){
1433 if(this.isVisible()){
1437 var d = this.getDialog(opt.title || " ");
1439 d.setTitle(opt.title || " ");
1440 var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);
1441 d.tools.close.setDisplayed(allowClose);
1442 activeTextEl = textboxEl;
1443 opt.prompt = opt.prompt || (opt.multiline ? true : false);
1448 textareaEl.setHeight(typeof opt.multiline == "number" ?
1449 opt.multiline : this.defaultTextHeight);
1450 activeTextEl = textareaEl;
1459 activeTextEl.dom.value = opt.value || "";
1461 d.focusEl = activeTextEl;
1463 var bs = opt.buttons;
1467 }else if(bs && bs.yes){
1468 db = buttons["yes"];
1475 d.setIconClass(opt.iconCls);
1477 this.setIcon(opt.icon);
1479 d.el.addClass(opt.cls);
1481 d.proxyDrag = opt.proxyDrag === true;
1482 d.modal = opt.modal !== false;
1483 d.mask = opt.modal !== false ? mask : false;
1485 d.on('show', function(){
1486 //workaround for window internally enabling keymap in afterShow
1487 d.keyMap.setDisabled(allowClose !== true);
1489 this.setIcon(opt.icon);
1490 bwidth = updateButtons(opt.buttons);
1491 progressBar.setVisible(opt.progress === true || opt.wait === true);
1492 this.updateProgress(0, opt.progressText);
1493 this.updateText(opt.msg);
1494 if(opt.wait === true){
1495 progressBar.wait(opt.waitConfig);
1498 }, this, {single:true});
1500 // force it to the end of the z-index stack so it gets a cursor in FF
1501 document.body.appendChild(dlg.el.dom);
1502 d.setAnimateTarget(opt.animEl);
1509 * Adds the specified icon to the dialog. By default, the class 'ext-mb-icon' is applied for default
1510 * styling, and the class passed in is expected to supply the background image url. Pass in empty string ('')
1511 * to clear any existing icon. The following built-in icon classes are supported, but you can also pass
1512 * in a custom class name:
1515 Ext.MessageBox.WARNING
1516 Ext.MessageBox.QUESTION
1517 Ext.MessageBox.ERROR
1519 * @param {String} icon A CSS classname specifying the icon's background image url, or empty string to clear the icon
1520 * @return {Ext.MessageBox} this
1522 setIcon : function(icon){
1523 if(icon && icon != ''){
1524 iconEl.removeClass('x-hidden');
1525 iconEl.replaceClass(iconCls, icon);
1526 bodyEl.addClass('x-dlg-icon');
1529 iconEl.replaceClass(iconCls, 'x-hidden');
1530 bodyEl.removeClass('x-dlg-icon');
1537 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
1538 * the user. You are responsible for updating the progress bar as needed via {@link Ext.MessageBox#updateProgress}
1539 * and closing the message box when the process is complete.
1540 * @param {String} title The title bar text
1541 * @param {String} msg The message box body text
1542 * @param {String} progressText (optional) The text to display inside the progress bar (defaults to '')
1543 * @return {Ext.MessageBox} this
1545 progress : function(title, msg, progressText){
1552 minWidth: this.minProgressWidth,
1553 progressText: progressText
1559 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
1560 * interaction while waiting for a long-running process to complete that does not have defined intervals.
1561 * You are responsible for closing the message box when the process is complete.
1562 * @param {String} msg The message box body text
1563 * @param {String} title (optional) The title bar text
1564 * @param {Object} config (optional) A {@link Ext.ProgressBar#waitConfig} object
1565 * @return {Ext.MessageBox} this
1567 wait : function(msg, title, config){
1575 minWidth: this.minProgressWidth,
1582 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript alert prompt).
1583 * If a callback function is passed it will be called after the user clicks the button, and the
1584 * id of the button that was clicked will be passed as the only parameter to the callback
1585 * (could also be the top-right close button).
1586 * @param {String} title The title bar text
1587 * @param {String} msg The message box body text
1588 * @param {Function} fn (optional) The callback function invoked after the message box is closed
1589 * @param {Object} scope (optional) The scope of the callback function
1590 * @return {Ext.MessageBox} this
1592 alert : function(title, msg, fn, scope){
1604 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's confirm).
1605 * If a callback function is passed it will be called after the user clicks either button,
1606 * and the id of the button that was clicked will be passed as the only parameter to the callback
1607 * (could also be the top-right close button).
1608 * @param {String} title The title bar text
1609 * @param {String} msg The message box body text
1610 * @param {Function} fn (optional) The callback function invoked after the message box is closed
1611 * @param {Object} scope (optional) The scope of the callback function
1612 * @return {Ext.MessageBox} this
1614 confirm : function(title, msg, fn, scope){
1618 buttons: this.YESNO,
1627 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's prompt).
1628 * The prompt can be a single-line or multi-line textbox. If a callback function is passed it will be called after the user
1629 * clicks either button, and the id of the button that was clicked (could also be the top-right
1630 * close button) and the text that was entered will be passed as the two parameters to the callback.
1631 * @param {String} title The title bar text
1632 * @param {String} msg The message box body text
1633 * @param {Function} fn (optional) The callback function invoked after the message box is closed
1634 * @param {Object} scope (optional) The scope of the callback function
1635 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
1636 * property, or the height in pixels to create the textbox (defaults to false / single-line)
1637 * @param {String} value (optional) Default value of the text input element (defaults to '')
1638 * @return {Ext.MessageBox} this
1640 prompt : function(title, msg, fn, scope, multiline, value){
1644 buttons: this.OKCANCEL,
1649 multiline: multiline,
1656 * Button config that displays a single OK button
1661 * Button config that displays a single Cancel button
1664 CANCEL : {cancel:true},
1666 * Button config that displays OK and Cancel buttons
1669 OKCANCEL : {ok:true, cancel:true},
1671 * Button config that displays Yes and No buttons
1674 YESNO : {yes:true, no:true},
1676 * Button config that displays Yes, No and Cancel buttons
1679 YESNOCANCEL : {yes:true, no:true, cancel:true},
1681 * The CSS class that provides the INFO icon image
1684 INFO : 'ext-mb-info',
1686 * The CSS class that provides the WARNING icon image
1689 WARNING : 'ext-mb-warning',
1691 * The CSS class that provides the QUESTION icon image
1694 QUESTION : 'ext-mb-question',
1696 * The CSS class that provides the ERROR icon image
1699 ERROR : 'ext-mb-error',
1702 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
1705 defaultTextHeight : 75,
1707 * The maximum width in pixels of the message box (defaults to 600)
1712 * The minimum width in pixels of the message box (defaults to 110)
1717 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
1718 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
1721 minProgressWidth : 250,
1723 * An object containing the default button text strings that can be overriden for localized language support.
1724 * Supported properties are: ok, cancel, yes and no. Generally you should include a locale-specific
1725 * resource file for handling language support across the framework.
1726 * Customize the default text like so: Ext.MessageBox.buttonText.yes = "oui"; //french
1739 * Shorthand for {@link Ext.MessageBox}
1741 Ext.Msg = Ext.MessageBox;/**
\r
1742 * @class Ext.dd.PanelProxy
\r
1743 * A custom drag proxy implementation specific to {@link Ext.Panel}s. This class is primarily used internally
\r
1744 * for the Panel's drag drop implementation, and should never need to be created directly.
\r
1746 * @param panel The {@link Ext.Panel} to proxy for
\r
1747 * @param config Configuration options
\r
1749 Ext.dd.PanelProxy = function(panel, config){
\r
1750 this.panel = panel;
\r
1751 this.id = this.panel.id +'-ddproxy';
\r
1752 Ext.apply(this, config);
\r
1755 Ext.dd.PanelProxy.prototype = {
\r
1757 * @cfg {Boolean} insertProxy True to insert a placeholder proxy element while dragging the panel,
\r
1758 * false to drag with no proxy (defaults to true).
\r
1760 insertProxy : true,
\r
1762 // private overrides
\r
1763 setStatus : Ext.emptyFn,
\r
1764 reset : Ext.emptyFn,
\r
1765 update : Ext.emptyFn,
\r
1766 stop : Ext.emptyFn,
\r
1767 sync: Ext.emptyFn,
\r
1770 * Gets the proxy's element
\r
1771 * @return {Element} The proxy's element
\r
1773 getEl : function(){
\r
1774 return this.ghost;
\r
1778 * Gets the proxy's ghost element
\r
1779 * @return {Element} The proxy's ghost element
\r
1781 getGhost : function(){
\r
1782 return this.ghost;
\r
1786 * Gets the proxy's element
\r
1787 * @return {Element} The proxy's element
\r
1789 getProxy : function(){
\r
1790 return this.proxy;
\r
1796 hide : function(){
\r
1799 this.proxy.remove();
\r
1800 delete this.proxy;
\r
1802 this.panel.el.dom.style.display = '';
\r
1803 this.ghost.remove();
\r
1804 delete this.ghost;
\r
1811 show : function(){
\r
1813 this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
\r
1814 this.ghost.setXY(this.panel.el.getXY())
\r
1815 if(this.insertProxy){
\r
1816 this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
\r
1817 this.proxy.setSize(this.panel.getSize());
\r
1819 this.panel.el.dom.style.display = 'none';
\r
1824 repair : function(xy, callback, scope){
\r
1826 if(typeof callback == "function"){
\r
1827 callback.call(scope || this);
\r
1832 * Moves the proxy to a different position in the DOM. This is typically called while dragging the Panel
\r
1833 * to keep the proxy sync'd to the Panel's location.
\r
1834 * @param {HTMLElement} parentNode The proxy's parent DOM node
\r
1835 * @param {HTMLElement} before (optional) The sibling node before which the proxy should be inserted (defaults
\r
1836 * to the parent's last child if not specified)
\r
1838 moveProxy : function(parentNode, before){
\r
1840 parentNode.insertBefore(this.proxy.dom, before);
\r
1845 // private - DD implementation for Panels
\r
1846 Ext.Panel.DD = function(panel, cfg){
\r
1847 this.panel = panel;
\r
1848 this.dragData = {panel: panel};
\r
1849 this.proxy = new Ext.dd.PanelProxy(panel, cfg);
\r
1850 Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
\r
1851 var h = panel.header;
\r
1853 this.setHandleElId(h.id);
\r
1855 (h ? h : this.panel.body).setStyle('cursor', 'move');
\r
1856 this.scroll = false;
\r
1859 Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
\r
1860 showFrame: Ext.emptyFn,
\r
1861 startDrag: Ext.emptyFn,
\r
1862 b4StartDrag: function(x, y) {
\r
1863 this.proxy.show();
\r
1865 b4MouseDown: function(e) {
\r
1866 var x = e.getPageX();
\r
1867 var y = e.getPageY();
\r
1868 this.autoOffset(x, y);
\r
1870 onInitDrag : function(x, y){
\r
1871 this.onStartDrag(x, y);
\r
1874 createFrame : Ext.emptyFn,
\r
1875 getDragEl : function(e){
\r
1876 return this.proxy.ghost.dom;
\r
1878 endDrag : function(e){
\r
1879 this.proxy.hide();
\r
1880 this.panel.saveState();
\r
1883 autoOffset : function(x, y) {
\r
1884 x -= this.startPageX;
\r
1885 y -= this.startPageY;
\r
1886 this.setDelta(x, y);
\r