Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / ViewDragZone.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="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../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">Ext.define('Ext.tree.ViewDragZone', {
19     extend: 'Ext.view.DragZone',
20
21     isPreventDrag: function(e, record) {
22         return (record.get('allowDrag') === false) || !!e.getTarget(this.view.expanderSelector);
23     },
24     
25     afterRepair: function() {
26         var me = this,
27             view = me.view,
28             selectedRowCls = view.selectedItemCls,
29             records = me.dragData.records,
30             fly = Ext.fly;
31         
32         if (Ext.enableFx &amp;&amp; me.repairHighlight) {
33             // Roll through all records and highlight all the ones we attempted to drag.
34             Ext.Array.forEach(records, function(record) {
35                 // anonymous fns below, don't hoist up unless below is wrapped in
36                 // a self-executing function passing in item.
37                 var item = view.getNode(record);
38                 
39                 // We must remove the selected row class before animating, because
40                 // the selected row class declares !important on its background-color.
41                 fly(item.firstChild).highlight(me.repairHighlightColor, {
42                     listeners: {
43                         beforeanimate: function() {
44                             if (view.isSelected(item)) {
45                                 fly(item).removeCls(selectedRowCls);
46                             }
47                         },
48                         afteranimate: function() {
49                             if (view.isSelected(item)) {
50                                 fly(item).addCls(selectedRowCls);
51                             }
52                         }
53                     }
54                 });
55             });
56         }
57         me.dragging = false;
58     }
59 });</pre>
60 </body>
61 </html>