Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / src / tree / ViewDragZone.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 Ext.define('Ext.tree.ViewDragZone', {
16     extend: 'Ext.view.DragZone',
17
18     isPreventDrag: function(e, record) {
19         return (record.get('allowDrag') === false) || !!e.getTarget(this.view.expanderSelector);
20     },
21     
22     afterRepair: function() {
23         var me = this,
24             view = me.view,
25             selectedRowCls = view.selectedItemCls,
26             records = me.dragData.records,
27             fly = Ext.fly;
28         
29         if (Ext.enableFx && me.repairHighlight) {
30             // Roll through all records and highlight all the ones we attempted to drag.
31             Ext.Array.forEach(records, function(record) {
32                 // anonymous fns below, don't hoist up unless below is wrapped in
33                 // a self-executing function passing in item.
34                 var item = view.getNode(record);
35                 
36                 // We must remove the selected row class before animating, because
37                 // the selected row class declares !important on its background-color.
38                 fly(item.firstChild).highlight(me.repairHighlightColor, {
39                     listeners: {
40                         beforeanimate: function() {
41                             if (view.isSelected(item)) {
42                                 fly(item).removeCls(selectedRowCls);
43                             }
44                         },
45                         afteranimate: function() {
46                             if (view.isSelected(item)) {
47                                 fly(item).addCls(selectedRowCls);
48                             }
49                         }
50                     }
51                 });
52             });
53         }
54         me.dragging = false;
55     }
56 });