Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / pkgs / resizable-debug.js
1 /*!
2  * Ext JS Library 3.0.0
3  * Copyright(c) 2006-2009 Ext JS, LLC
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /**\r
8  * @class Ext.Resizable\r
9  * @extends Ext.util.Observable\r
10  * <p>Applies drag handles to an element to make it resizable. The drag handles are inserted into the element \r
11  * and positioned absolute. Some elements, such as a textarea or image, don't support this. To overcome that, you can wrap\r
12  * the textarea in a div and set 'resizeChild' to true (or to the id of the element), <b>or</b> set wrap:true in your config and\r
13  * the element will be wrapped for you automatically.</p>\r
14  * <p>Here is the list of valid resize handles:</p>\r
15  * <pre>\r
16 Value   Description\r
17 ------  -------------------\r
18  'n'     north\r
19  's'     south\r
20  'e'     east\r
21  'w'     west\r
22  'nw'    northwest\r
23  'sw'    southwest\r
24  'se'    southeast\r
25  'ne'    northeast\r
26  'all'   all\r
27 </pre>\r
28  * <p>Here's an example showing the creation of a typical Resizable:</p>\r
29  * <pre><code>\r
30 var resizer = new Ext.Resizable('element-id', {\r
31     handles: 'all',\r
32     minWidth: 200,\r
33     minHeight: 100,\r
34     maxWidth: 500,\r
35     maxHeight: 400,\r
36     pinned: true\r
37 });\r
38 resizer.on('resize', myHandler);\r
39 </code></pre>\r
40  * <p>To hide a particular handle, set its display to none in CSS, or through script:<br>\r
41  * resizer.east.setDisplayed(false);</p>\r
42  * @constructor\r
43  * Create a new resizable component\r
44  * @param {Mixed} el The id or element to resize\r
45  * @param {Object} config configuration options\r
46   */\r
47 Ext.Resizable = function(el, config){\r
48     this.el = Ext.get(el);\r
49     \r
50     if(config && config.wrap){\r
51         config.resizeChild = this.el;\r
52         this.el = this.el.wrap(typeof config.wrap == 'object' ? config.wrap : {cls:'xresizable-wrap'});\r
53         this.el.id = this.el.dom.id = config.resizeChild.id + '-rzwrap';\r
54         this.el.setStyle('overflow', 'hidden');\r
55         this.el.setPositioning(config.resizeChild.getPositioning());\r
56         config.resizeChild.clearPositioning();\r
57         if(!config.width || !config.height){\r
58             var csize = config.resizeChild.getSize();\r
59             this.el.setSize(csize.width, csize.height);\r
60         }\r
61         if(config.pinned && !config.adjustments){\r
62             config.adjustments = 'auto';\r
63         }\r
64     }\r
65 \r
66     /**\r
67      * The proxy Element that is resized in place of the real Element during the resize operation.\r
68      * This may be queried using {@link Ext.Element#getBox} to provide the new area to resize to.\r
69      * Read only.\r
70      * @type Ext.Element.\r
71      * @property proxy\r
72      */\r
73     this.proxy = this.el.createProxy({tag: 'div', cls: 'x-resizable-proxy', id: this.el.id + '-rzproxy'}, Ext.getBody());\r
74     this.proxy.unselectable();\r
75     this.proxy.enableDisplayMode('block');\r
76 \r
77     Ext.apply(this, config);\r
78     \r
79     if(this.pinned){\r
80         this.disableTrackOver = true;\r
81         this.el.addClass('x-resizable-pinned');\r
82     }\r
83     // if the element isn't positioned, make it relative\r
84     var position = this.el.getStyle('position');\r
85     if(position != 'absolute' && position != 'fixed'){\r
86         this.el.setStyle('position', 'relative');\r
87     }\r
88     if(!this.handles){ // no handles passed, must be legacy style\r
89         this.handles = 's,e,se';\r
90         if(this.multiDirectional){\r
91             this.handles += ',n,w';\r
92         }\r
93     }\r
94     if(this.handles == 'all'){\r
95         this.handles = 'n s e w ne nw se sw';\r
96     }\r
97     var hs = this.handles.split(/\s*?[,;]\s*?| /);\r
98     var ps = Ext.Resizable.positions;\r
99     for(var i = 0, len = hs.length; i < len; i++){\r
100         if(hs[i] && ps[hs[i]]){\r
101             var pos = ps[hs[i]];\r
102             this[pos] = new Ext.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent);\r
103         }\r
104     }\r
105     // legacy\r
106     this.corner = this.southeast;\r
107     \r
108     if(this.handles.indexOf('n') != -1 || this.handles.indexOf('w') != -1){\r
109         this.updateBox = true;\r
110     }   \r
111    \r
112     this.activeHandle = null;\r
113     \r
114     if(this.resizeChild){\r
115         if(typeof this.resizeChild == 'boolean'){\r
116             this.resizeChild = Ext.get(this.el.dom.firstChild, true);\r
117         }else{\r
118             this.resizeChild = Ext.get(this.resizeChild, true);\r
119         }\r
120     }\r
121     \r
122     if(this.adjustments == 'auto'){\r
123         var rc = this.resizeChild;\r
124         var hw = this.west, he = this.east, hn = this.north, hs = this.south;\r
125         if(rc && (hw || hn)){\r
126             rc.position('relative');\r
127             rc.setLeft(hw ? hw.el.getWidth() : 0);\r
128             rc.setTop(hn ? hn.el.getHeight() : 0);\r
129         }\r
130         this.adjustments = [\r
131             (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),\r
132             (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1 \r
133         ];\r
134     }\r
135     \r
136     if(this.draggable){\r
137         this.dd = this.dynamic ? \r
138             this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});\r
139         this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);\r
140     }\r
141     \r
142     this.addEvents(\r
143         /**\r
144          * @event beforeresize\r
145          * Fired before resize is allowed. Set {@link #enabled} to false to cancel resize.\r
146          * @param {Ext.Resizable} this\r
147          * @param {Ext.EventObject} e The mousedown event\r
148          */\r
149         'beforeresize',\r
150         /**\r
151          * @event resize\r
152          * Fired after a resize.\r
153          * @param {Ext.Resizable} this\r
154          * @param {Number} width The new width\r
155          * @param {Number} height The new height\r
156          * @param {Ext.EventObject} e The mouseup event\r
157          */\r
158         'resize'\r
159     );\r
160     \r
161     if(this.width !== null && this.height !== null){\r
162         this.resizeTo(this.width, this.height);\r
163     }else{\r
164         this.updateChildSize();\r
165     }\r
166     if(Ext.isIE){\r
167         this.el.dom.style.zoom = 1;\r
168     }\r
169     Ext.Resizable.superclass.constructor.call(this);\r
170 };\r
171 \r
172 Ext.extend(Ext.Resizable, Ext.util.Observable, {\r
173 \r
174     /**\r
175      * @cfg {Array/String} adjustments String 'auto' or an array [width, height] with values to be <b>added</b> to the\r
176      * resize operation's new size (defaults to <tt>[0, 0]</tt>)\r
177      */\r
178     adjustments : [0, 0],\r
179     /**\r
180      * @cfg {Boolean} animate True to animate the resize (not compatible with dynamic sizing, defaults to false)\r
181      */\r
182     animate : false,\r
183     /**\r
184      * @cfg {Mixed} constrainTo Constrain the resize to a particular element\r
185      */\r
186     /**\r
187      * @cfg {Boolean} disableTrackOver True to disable mouse tracking. This is only applied at config time. (defaults to false)\r
188      */\r
189     disableTrackOver : false,\r
190     /**\r
191      * @cfg {Boolean} draggable Convenience to initialize drag drop (defaults to false)\r
192      */\r
193     draggable: false,\r
194     /**\r
195      * @cfg {Number} duration Animation duration if animate = true (defaults to 0.35)\r
196      */\r
197     duration : 0.35,\r
198     /**\r
199      * @cfg {Boolean} dynamic True to resize the element while dragging instead of using a proxy (defaults to false)\r
200      */\r
201     dynamic : false,\r
202     /**\r
203      * @cfg {String} easing Animation easing if animate = true (defaults to <tt>'easingOutStrong'</tt>)\r
204      */\r
205     easing : 'easeOutStrong',\r
206     /**\r
207      * @cfg {Boolean} enabled False to disable resizing (defaults to true)\r
208      */\r
209     enabled : true,\r
210     /**\r
211      * @property enabled Writable. False if resizing is disabled.\r
212      * @type Boolean \r
213      */\r
214     /**\r
215      * @cfg {String} handles String consisting of the resize handles to display (defaults to undefined).\r
216      * Specify either <tt>'all'</tt> or any of <tt>'n s e w ne nw se sw'</tt>.\r
217      */\r
218     handles : false,\r
219     /**\r
220      * @cfg {Boolean} multiDirectional <b>Deprecated</b>.  Deprecated style of adding multi-direction resize handles.\r
221      */\r
222     multiDirectional : false,\r
223     /**\r
224      * @cfg {Number} height The height of the element in pixels (defaults to null)\r
225      */\r
226     height : null,\r
227     /**\r
228      * @cfg {Number} width The width of the element in pixels (defaults to null)\r
229      */\r
230     width : null,\r
231     /**\r
232      * @cfg {Number} heightIncrement The increment to snap the height resize in pixels\r
233      * (only applies if <code>{@link #dynamic}==true</code>). Defaults to <tt>0</tt>.\r
234      */\r
235     heightIncrement : 0,\r
236     /**\r
237      * @cfg {Number} widthIncrement The increment to snap the width resize in pixels\r
238      * (only applies if <code>{@link #dynamic}==true</code>). Defaults to <tt>0</tt>.\r
239      */\r
240     widthIncrement : 0,\r
241     /**\r
242      * @cfg {Number} minHeight The minimum height for the element (defaults to 5)\r
243      */\r
244     minHeight : 5,\r
245     /**\r
246      * @cfg {Number} minWidth The minimum width for the element (defaults to 5)\r
247      */\r
248     minWidth : 5,\r
249     /**\r
250      * @cfg {Number} maxHeight The maximum height for the element (defaults to 10000)\r
251      */\r
252     maxHeight : 10000,\r
253     /**\r
254      * @cfg {Number} maxWidth The maximum width for the element (defaults to 10000)\r
255      */\r
256     maxWidth : 10000,\r
257     /**\r
258      * @cfg {Number} minX The minimum x for the element (defaults to 0)\r
259      */\r
260     minX: 0,\r
261     /**\r
262      * @cfg {Number} minY The minimum x for the element (defaults to 0)\r
263      */\r
264     minY: 0,\r
265     /**\r
266      * @cfg {Boolean} pinned True to ensure that the resize handles are always visible, false to display them only when the\r
267      * user mouses over the resizable borders. This is only applied at config time. (defaults to false)\r
268      */\r
269     pinned : false,\r
270     /**\r
271      * @cfg {Boolean} preserveRatio True to preserve the original ratio between height\r
272      * and width during resize (defaults to false)\r
273      */\r
274     preserveRatio : false,\r
275     /**\r
276      * @cfg {Boolean/String/Element} resizeChild True to resize the first child, or id/element to resize (defaults to false) \r
277      */ \r
278     resizeChild : false,\r
279     /**\r
280      * @cfg {Boolean} transparent True for transparent handles. This is only applied at config time. (defaults to false)\r
281      */\r
282     transparent: false,\r
283     /**\r
284      * @cfg {Ext.lib.Region} resizeRegion Constrain the resize to a particular region\r
285      */\r
286     /**\r
287      * @cfg {Boolean} wrap True to wrap an element with a div if needed (required for textareas and images, defaults to false)\r
288      * in favor of the handles config option (defaults to false)\r
289      */\r
290 \r
291     \r
292     /**\r
293      * Perform a manual resize and fires the 'resize' event.\r
294      * @param {Number} width\r
295      * @param {Number} height\r
296      */\r
297     resizeTo : function(width, height){\r
298         this.el.setSize(width, height);\r
299         this.updateChildSize();\r
300         this.fireEvent('resize', this, width, height, null);\r
301     },\r
302 \r
303     // private\r
304     startSizing : function(e, handle){\r
305         this.fireEvent('beforeresize', this, e);\r
306         if(this.enabled){ // 2nd enabled check in case disabled before beforeresize handler\r
307 \r
308             if(!this.overlay){\r
309                 this.overlay = this.el.createProxy({tag: 'div', cls: 'x-resizable-overlay', html: '&#160;'}, Ext.getBody());\r
310                 this.overlay.unselectable();\r
311                 this.overlay.enableDisplayMode('block');\r
312                 this.overlay.on({\r
313                     scope: this,\r
314                     mousemove: this.onMouseMove,\r
315                     mouseup: this.onMouseUp\r
316                 });\r
317             }\r
318             this.overlay.setStyle('cursor', handle.el.getStyle('cursor'));\r
319 \r
320             this.resizing = true;\r
321             this.startBox = this.el.getBox();\r
322             this.startPoint = e.getXY();\r
323             this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],\r
324                             (this.startBox.y + this.startBox.height) - this.startPoint[1]];\r
325 \r
326             this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));\r
327             this.overlay.show();\r
328 \r
329             if(this.constrainTo) {\r
330                 var ct = Ext.get(this.constrainTo);\r
331                 this.resizeRegion = ct.getRegion().adjust(\r
332                     ct.getFrameWidth('t'),\r
333                     ct.getFrameWidth('l'),\r
334                     -ct.getFrameWidth('b'),\r
335                     -ct.getFrameWidth('r')\r
336                 );\r
337             }\r
338 \r
339             this.proxy.setStyle('visibility', 'hidden'); // workaround display none\r
340             this.proxy.show();\r
341             this.proxy.setBox(this.startBox);\r
342             if(!this.dynamic){\r
343                 this.proxy.setStyle('visibility', 'visible');\r
344             }\r
345         }\r
346     },\r
347 \r
348     // private\r
349     onMouseDown : function(handle, e){\r
350         if(this.enabled){\r
351             e.stopEvent();\r
352             this.activeHandle = handle;\r
353             this.startSizing(e, handle);\r
354         }          \r
355     },\r
356 \r
357     // private\r
358     onMouseUp : function(e){\r
359         this.activeHandle = null;\r
360         var size = this.resizeElement();\r
361         this.resizing = false;\r
362         this.handleOut();\r
363         this.overlay.hide();\r
364         this.proxy.hide();\r
365         this.fireEvent('resize', this, size.width, size.height, e);\r
366     },\r
367 \r
368     // private\r
369     updateChildSize : function(){\r
370         if(this.resizeChild){\r
371             var el = this.el;\r
372             var child = this.resizeChild;\r
373             var adj = this.adjustments;\r
374             if(el.dom.offsetWidth){\r
375                 var b = el.getSize(true);\r
376                 child.setSize(b.width+adj[0], b.height+adj[1]);\r
377             }\r
378             // Second call here for IE\r
379             // The first call enables instant resizing and\r
380             // the second call corrects scroll bars if they\r
381             // exist\r
382             if(Ext.isIE){\r
383                 setTimeout(function(){\r
384                     if(el.dom.offsetWidth){\r
385                         var b = el.getSize(true);\r
386                         child.setSize(b.width+adj[0], b.height+adj[1]);\r
387                     }\r
388                 }, 10);\r
389             }\r
390         }\r
391     },\r
392 \r
393     // private\r
394     snap : function(value, inc, min){\r
395         if(!inc || !value){\r
396             return value;\r
397         }\r
398         var newValue = value;\r
399         var m = value % inc;\r
400         if(m > 0){\r
401             if(m > (inc/2)){\r
402                 newValue = value + (inc-m);\r
403             }else{\r
404                 newValue = value - m;\r
405             }\r
406         }\r
407         return Math.max(min, newValue);\r
408     },\r
409 \r
410     /**\r
411      * <p>Performs resizing of the associated Element. This method is called internally by this\r
412      * class, and should not be called by user code.</p>\r
413      * <p>If a Resizable is being used to resize an Element which encapsulates a more complex UI\r
414      * component such as a Panel, this method may be overridden by specifying an implementation\r
415      * as a config option to provide appropriate behaviour at the end of the resize operation on\r
416      * mouseup, for example resizing the Panel, and relaying the Panel's content.</p>\r
417      * <p>The new area to be resized to is available by examining the state of the {@link #proxy}\r
418      * Element. Example:\r
419 <pre><code>\r
420 new Ext.Panel({\r
421     title: 'Resize me',\r
422     x: 100,\r
423     y: 100,\r
424     renderTo: Ext.getBody(),\r
425     floating: true,\r
426     frame: true,\r
427     width: 400,\r
428     height: 200,\r
429     listeners: {\r
430         render: function(p) {\r
431             new Ext.Resizable(p.getEl(), {\r
432                 handles: 'all',\r
433                 pinned: true,\r
434                 transparent: true,\r
435                 resizeElement: function() {\r
436                     var box = this.proxy.getBox();\r
437                     p.updateBox(box);\r
438                     if (p.layout) {\r
439                         p.doLayout();\r
440                     }\r
441                     return box;\r
442                 }\r
443            });\r
444        }\r
445     }\r
446 }).show();\r
447 </code></pre>\r
448      */\r
449     resizeElement : function(){\r
450         var box = this.proxy.getBox();\r
451         if(this.updateBox){\r
452             this.el.setBox(box, false, this.animate, this.duration, null, this.easing);\r
453         }else{\r
454             this.el.setSize(box.width, box.height, this.animate, this.duration, null, this.easing);\r
455         }\r
456         this.updateChildSize();\r
457         if(!this.dynamic){\r
458             this.proxy.hide();\r
459         }\r
460         return box;\r
461     },\r
462 \r
463     // private\r
464     constrain : function(v, diff, m, mx){\r
465         if(v - diff < m){\r
466             diff = v - m;    \r
467         }else if(v - diff > mx){\r
468             diff = v - mx; \r
469         }\r
470         return diff;                \r
471     },\r
472 \r
473     // private\r
474     onMouseMove : function(e){\r
475         if(this.enabled && this.activeHandle){\r
476             try{// try catch so if something goes wrong the user doesn't get hung\r
477 \r
478             if(this.resizeRegion && !this.resizeRegion.contains(e.getPoint())) {\r
479                 return;\r
480             }\r
481 \r
482             //var curXY = this.startPoint;\r
483             var curSize = this.curSize || this.startBox,\r
484                 x = this.startBox.x, y = this.startBox.y,\r
485                 ox = x, \r
486                 oy = y,\r
487                 w = curSize.width, \r
488                 h = curSize.height,\r
489                 ow = w, \r
490                 oh = h,\r
491                 mw = this.minWidth, \r
492                 mh = this.minHeight,\r
493                 mxw = this.maxWidth, \r
494                 mxh = this.maxHeight,\r
495                 wi = this.widthIncrement,\r
496                 hi = this.heightIncrement,\r
497                 eventXY = e.getXY(),\r
498                 diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0])),\r
499                 diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1])),\r
500                 pos = this.activeHandle.position,\r
501                 tw,\r
502                 th;\r
503             \r
504             switch(pos){\r
505                 case 'east':\r
506                     w += diffX; \r
507                     w = Math.min(Math.max(mw, w), mxw);\r
508                     break;\r
509                 case 'south':\r
510                     h += diffY;\r
511                     h = Math.min(Math.max(mh, h), mxh);\r
512                     break;\r
513                 case 'southeast':\r
514                     w += diffX; \r
515                     h += diffY;\r
516                     w = Math.min(Math.max(mw, w), mxw);\r
517                     h = Math.min(Math.max(mh, h), mxh);\r
518                     break;\r
519                 case 'north':\r
520                     diffY = this.constrain(h, diffY, mh, mxh);\r
521                     y += diffY;\r
522                     h -= diffY;\r
523                     break;\r
524                 case 'west':\r
525                     diffX = this.constrain(w, diffX, mw, mxw);\r
526                     x += diffX;\r
527                     w -= diffX;\r
528                     break;\r
529                 case 'northeast':\r
530                     w += diffX; \r
531                     w = Math.min(Math.max(mw, w), mxw);\r
532                     diffY = this.constrain(h, diffY, mh, mxh);\r
533                     y += diffY;\r
534                     h -= diffY;\r
535                     break;\r
536                 case 'northwest':\r
537                     diffX = this.constrain(w, diffX, mw, mxw);\r
538                     diffY = this.constrain(h, diffY, mh, mxh);\r
539                     y += diffY;\r
540                     h -= diffY;\r
541                     x += diffX;\r
542                     w -= diffX;\r
543                     break;\r
544                case 'southwest':\r
545                     diffX = this.constrain(w, diffX, mw, mxw);\r
546                     h += diffY;\r
547                     h = Math.min(Math.max(mh, h), mxh);\r
548                     x += diffX;\r
549                     w -= diffX;\r
550                     break;\r
551             }\r
552             \r
553             var sw = this.snap(w, wi, mw);\r
554             var sh = this.snap(h, hi, mh);\r
555             if(sw != w || sh != h){\r
556                 switch(pos){\r
557                     case 'northeast':\r
558                         y -= sh - h;\r
559                     break;\r
560                     case 'north':\r
561                         y -= sh - h;\r
562                         break;\r
563                     case 'southwest':\r
564                         x -= sw - w;\r
565                     break;\r
566                     case 'west':\r
567                         x -= sw - w;\r
568                         break;\r
569                     case 'northwest':\r
570                         x -= sw - w;\r
571                         y -= sh - h;\r
572                     break;\r
573                 }\r
574                 w = sw;\r
575                 h = sh;\r
576             }\r
577             \r
578             if(this.preserveRatio){\r
579                 switch(pos){\r
580                     case 'southeast':\r
581                     case 'east':\r
582                         h = oh * (w/ow);\r
583                         h = Math.min(Math.max(mh, h), mxh);\r
584                         w = ow * (h/oh);\r
585                        break;\r
586                     case 'south':\r
587                         w = ow * (h/oh);\r
588                         w = Math.min(Math.max(mw, w), mxw);\r
589                         h = oh * (w/ow);\r
590                         break;\r
591                     case 'northeast':\r
592                         w = ow * (h/oh);\r
593                         w = Math.min(Math.max(mw, w), mxw);\r
594                         h = oh * (w/ow);\r
595                     break;\r
596                     case 'north':\r
597                         tw = w;\r
598                         w = ow * (h/oh);\r
599                         w = Math.min(Math.max(mw, w), mxw);\r
600                         h = oh * (w/ow);\r
601                         x += (tw - w) / 2;\r
602                         break;\r
603                     case 'southwest':\r
604                         h = oh * (w/ow);\r
605                         h = Math.min(Math.max(mh, h), mxh);\r
606                         tw = w;\r
607                         w = ow * (h/oh);\r
608                         x += tw - w;\r
609                         break;\r
610                     case 'west':\r
611                         th = h;\r
612                         h = oh * (w/ow);\r
613                         h = Math.min(Math.max(mh, h), mxh);\r
614                         y += (th - h) / 2;\r
615                         tw = w;\r
616                         w = ow * (h/oh);\r
617                         x += tw - w;\r
618                        break;\r
619                     case 'northwest':\r
620                         tw = w;\r
621                         th = h;\r
622                         h = oh * (w/ow);\r
623                         h = Math.min(Math.max(mh, h), mxh);\r
624                         w = ow * (h/oh);\r
625                         y += th - h;\r
626                         x += tw - w;\r
627                         break;\r
628                         \r
629                 }\r
630             }\r
631             this.proxy.setBounds(x, y, w, h);\r
632             if(this.dynamic){\r
633                 this.resizeElement();\r
634             }\r
635             }catch(ex){}\r
636         }\r
637     },\r
638 \r
639     // private\r
640     handleOver : function(){\r
641         if(this.enabled){\r
642             this.el.addClass('x-resizable-over');\r
643         }\r
644     },\r
645 \r
646     // private\r
647     handleOut : function(){\r
648         if(!this.resizing){\r
649             this.el.removeClass('x-resizable-over');\r
650         }\r
651     },\r
652     \r
653     /**\r
654      * Returns the element this component is bound to.\r
655      * @return {Ext.Element}\r
656      */\r
657     getEl : function(){\r
658         return this.el;\r
659     },\r
660     \r
661     /**\r
662      * Returns the resizeChild element (or null).\r
663      * @return {Ext.Element}\r
664      */\r
665     getResizeChild : function(){\r
666         return this.resizeChild;\r
667     },\r
668     \r
669     /**\r
670      * Destroys this resizable. If the element was wrapped and \r
671      * removeEl is not true then the element remains.\r
672      * @param {Boolean} removeEl (optional) true to remove the element from the DOM\r
673      */\r
674     destroy : function(removeEl){\r
675         Ext.destroy(this.dd, this.overlay, this.proxy);\r
676         this.overlay = null;\r
677         this.proxy = null;\r
678         \r
679         var ps = Ext.Resizable.positions;\r
680         for(var k in ps){\r
681             if(typeof ps[k] != 'function' && this[ps[k]]){\r
682                 this[ps[k]].destroy();\r
683             }\r
684         }\r
685         if(removeEl){\r
686             this.el.update('');\r
687             Ext.destroy(this.el);\r
688             this.el = null;\r
689         }\r
690         this.purgeListeners();\r
691     },\r
692 \r
693     syncHandleHeight : function(){\r
694         var h = this.el.getHeight(true);\r
695         if(this.west){\r
696             this.west.el.setHeight(h);\r
697         }\r
698         if(this.east){\r
699             this.east.el.setHeight(h);\r
700         }\r
701     }\r
702 });\r
703 \r
704 // private\r
705 // hash to map config positions to true positions\r
706 Ext.Resizable.positions = {\r
707     n: 'north', s: 'south', e: 'east', w: 'west', se: 'southeast', sw: 'southwest', nw: 'northwest', ne: 'northeast'\r
708 };\r
709 \r
710 // private\r
711 Ext.Resizable.Handle = function(rz, pos, disableTrackOver, transparent){\r
712     if(!this.tpl){\r
713         // only initialize the template if resizable is used\r
714         var tpl = Ext.DomHelper.createTemplate(\r
715             {tag: 'div', cls: 'x-resizable-handle x-resizable-handle-{0}'}\r
716         );\r
717         tpl.compile();\r
718         Ext.Resizable.Handle.prototype.tpl = tpl;\r
719     }\r
720     this.position = pos;\r
721     this.rz = rz;\r
722     this.el = this.tpl.append(rz.el.dom, [this.position], true);\r
723     this.el.unselectable();\r
724     if(transparent){\r
725         this.el.setOpacity(0);\r
726     }\r
727     this.el.on('mousedown', this.onMouseDown, this);\r
728     if(!disableTrackOver){\r
729         this.el.on({\r
730             scope: this,\r
731             mouseover: this.onMouseOver,\r
732             mouseout: this.onMouseOut\r
733         });\r
734     }\r
735 };\r
736 \r
737 // private\r
738 Ext.Resizable.Handle.prototype = {\r
739     // private\r
740     afterResize : function(rz){\r
741         // do nothing    \r
742     },\r
743     // private\r
744     onMouseDown : function(e){\r
745         this.rz.onMouseDown(this, e);\r
746     },\r
747     // private\r
748     onMouseOver : function(e){\r
749         this.rz.handleOver(this, e);\r
750     },\r
751     // private\r
752     onMouseOut : function(e){\r
753         this.rz.handleOut(this, e);\r
754     },\r
755     // private\r
756     destroy : function(){\r
757         Ext.destroy(this.el);\r
758         this.el = null;\r
759     }\r
760 };\r