Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / src / tree / ViewDragZone.js
1 Ext.define('Ext.tree.ViewDragZone', {
2     extend: 'Ext.view.DragZone',
3
4     isPreventDrag: function(e, record) {
5         return (record.get('allowDrag') === false) || !!e.getTarget(this.view.expanderSelector);
6     },
7     
8     afterRepair: function() {
9         var me = this,
10             view = me.view,
11             selectedRowCls = view.selectedItemCls,
12             records = me.dragData.records,
13             fly = Ext.fly;
14         
15         if (Ext.enableFx && me.repairHighlight) {
16             // Roll through all records and highlight all the ones we attempted to drag.
17             Ext.Array.forEach(records, function(record) {
18                 // anonymous fns below, don't hoist up unless below is wrapped in
19                 // a self-executing function passing in item.
20                 var item = view.getNode(record);
21                 
22                 // We must remove the selected row class before animating, because
23                 // the selected row class declares !important on its background-color.
24                 fly(item.firstChild).highlight(me.repairHighlightColor, {
25                     listeners: {
26                         beforeanimate: function() {
27                             if (view.isSelected(item)) {
28                                 fly(item).removeCls(selectedRowCls);
29                             }
30                         },
31                         afteranimate: function() {
32                             if (view.isSelected(item)) {
33                                 fly(item).addCls(selectedRowCls);
34                             }
35                         }
36                     }
37                 });
38             });
39         }
40         me.dragging = false;
41     }
42 });