Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / docs / source / DragZone2.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-grid-header-DragZone'>/**
19 </span> * @class Ext.grid.header.DragZone
20  * @extends Ext.dd.DragZone
21  * @private
22  */
23 Ext.define('Ext.grid.header.DragZone', {
24     extend: 'Ext.dd.DragZone',
25     colHeaderCls: Ext.baseCSSPrefix + 'column-header',
26     maxProxyWidth: 120,
27
28     constructor: function(headerCt) {
29         this.headerCt = headerCt;
30         this.ddGroup =  this.getDDGroup();
31         this.callParent([headerCt.el]);
32         this.proxy.el.addCls(Ext.baseCSSPrefix + 'grid-col-dd');
33     },
34
35     getDDGroup: function() {
36         return 'header-dd-zone-' + this.headerCt.up('[scrollerOwner]').id;
37     },
38
39     getDragData: function(e) {
40         var header = e.getTarget('.'+this.colHeaderCls),
41             headerCmp;
42
43         if (header) {
44             headerCmp = Ext.getCmp(header.id);
45             if (!this.headerCt.dragging &amp;&amp; headerCmp.draggable &amp;&amp; !(headerCmp.isOnLeftEdge(e) || headerCmp.isOnRightEdge(e))) {
46                 var ddel = document.createElement('div');
47                 ddel.innerHTML = Ext.getCmp(header.id).text;
48                 return {
49                     ddel: ddel,
50                     header: headerCmp
51                 };
52             }
53         }
54         return false;
55     },
56
57     onBeforeDrag: function() {
58         return !(this.headerCt.dragging || this.disabled);
59     },
60
61     onInitDrag: function() {
62         this.headerCt.dragging = true;
63         this.callParent(arguments);
64     },
65
66     onDragDrop: function() {
67         this.headerCt.dragging = false;
68         this.callParent(arguments);
69     },
70
71     afterRepair: function() {
72         this.callParent();
73         this.headerCt.dragging = false;
74     },
75
76     getRepairXY: function() {
77         return this.dragData.header.el.getXY();
78     },
79     
80     disable: function() {
81         this.disabled = true;
82     },
83     
84     enable: function() {
85         this.disabled = false;
86     }
87 });
88 </pre>
89 </body>
90 </html>