~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/ext/source/widgets/PanelDD.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Ext JS Library 2.2
 
3
 * Copyright(c) 2006-2008, Ext JS, LLC.
 
4
 * licensing@extjs.com
 
5
 * 
 
6
 * http://extjs.com/license
 
7
 */
 
8
 
 
9
/* // Internal developer documentation -- will not show up in API docs
 
10
 * @class Ext.dd.PanelProxy
 
11
 * A custom drag proxy implementation specific to {@link Ext.Panel}s. This class is primarily used internally
 
12
 * for the Panel's drag drop implementation, and should never need to be created directly.
 
13
 * @constructor
 
14
 * @param panel The {@link Ext.Panel} to proxy for
 
15
 * @param config Configuration options
 
16
 */
 
17
Ext.dd.PanelProxy = function(panel, config){
 
18
    this.panel = panel;
 
19
    this.id = this.panel.id +'-ddproxy';
 
20
    Ext.apply(this, config);
 
21
};
 
22
 
 
23
Ext.dd.PanelProxy.prototype = {
 
24
    /**
 
25
     * @cfg {Boolean} insertProxy True to insert a placeholder proxy element while dragging the panel,
 
26
      * false to drag with no proxy (defaults to true).
 
27
     */
 
28
    insertProxy : true,
 
29
 
 
30
    // private overrides
 
31
    setStatus : Ext.emptyFn,
 
32
    reset : Ext.emptyFn,
 
33
    update : Ext.emptyFn,
 
34
    stop : Ext.emptyFn,
 
35
    sync: Ext.emptyFn,
 
36
 
 
37
    /**
 
38
     * Gets the proxy's element
 
39
     * @return {Element} The proxy's element
 
40
     */
 
41
    getEl : function(){
 
42
        return this.ghost;
 
43
    },
 
44
 
 
45
    /**
 
46
     * Gets the proxy's ghost element
 
47
     * @return {Element} The proxy's ghost element
 
48
     */
 
49
    getGhost : function(){
 
50
        return this.ghost;
 
51
    },
 
52
 
 
53
    /**
 
54
     * Gets the proxy's element
 
55
     * @return {Element} The proxy's element
 
56
     */
 
57
    getProxy : function(){
 
58
        return this.proxy;
 
59
    },
 
60
 
 
61
    /**
 
62
     * Hides the proxy
 
63
     */
 
64
    hide : function(){
 
65
        if(this.ghost){
 
66
            if(this.proxy){
 
67
                this.proxy.remove();
 
68
                delete this.proxy;
 
69
            }
 
70
            this.panel.el.dom.style.display = '';
 
71
            this.ghost.remove();
 
72
            delete this.ghost;
 
73
        }
 
74
    },
 
75
 
 
76
    /**
 
77
     * Shows the proxy
 
78
     */
 
79
    show : function(){
 
80
        if(!this.ghost){
 
81
            this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
 
82
            this.ghost.setXY(this.panel.el.getXY())
 
83
            if(this.insertProxy){
 
84
                this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
 
85
                this.proxy.setSize(this.panel.getSize());
 
86
            }
 
87
            this.panel.el.dom.style.display = 'none';
 
88
        }
 
89
    },
 
90
 
 
91
    // private
 
92
    repair : function(xy, callback, scope){
 
93
        this.hide();
 
94
        if(typeof callback == "function"){
 
95
            callback.call(scope || this);
 
96
        }
 
97
    },
 
98
 
 
99
    /**
 
100
     * Moves the proxy to a different position in the DOM.  This is typically called while dragging the Panel
 
101
     * to keep the proxy sync'd to the Panel's location.
 
102
     * @param {HTMLElement} parentNode The proxy's parent DOM node
 
103
     * @param {HTMLElement} before (optional) The sibling node before which the proxy should be inserted (defaults
 
104
     * to the parent's last child if not specified)
 
105
     */
 
106
    moveProxy : function(parentNode, before){
 
107
        if(this.proxy){
 
108
            parentNode.insertBefore(this.proxy.dom, before);
 
109
        }
 
110
    }
 
111
};
 
112
 
 
113
// private - DD implementation for Panels
 
114
Ext.Panel.DD = function(panel, cfg){
 
115
    this.panel = panel;
 
116
    this.dragData = {panel: panel};
 
117
    this.proxy = new Ext.dd.PanelProxy(panel, cfg);
 
118
    Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
 
119
    var h = panel.header;
 
120
    if(h){
 
121
        this.setHandleElId(h.id);
 
122
    }
 
123
    (h ? h : this.panel.body).setStyle('cursor', 'move');
 
124
    this.scroll = false;
 
125
};
 
126
 
 
127
Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
 
128
    showFrame: Ext.emptyFn,
 
129
    startDrag: Ext.emptyFn,
 
130
    b4StartDrag: function(x, y) {
 
131
        this.proxy.show();
 
132
    },
 
133
    b4MouseDown: function(e) {
 
134
        var x = e.getPageX();
 
135
        var y = e.getPageY();
 
136
        this.autoOffset(x, y);
 
137
    },
 
138
    onInitDrag : function(x, y){
 
139
        this.onStartDrag(x, y);
 
140
        return true;
 
141
    },
 
142
    createFrame : Ext.emptyFn,
 
143
    getDragEl : function(e){
 
144
        return this.proxy.ghost.dom;
 
145
    },
 
146
    endDrag : function(e){
 
147
        this.proxy.hide();
 
148
        this.panel.saveState();
 
149
    },
 
150
 
 
151
    autoOffset : function(x, y) {
 
152
        x -= this.startPageX;
 
153
        y -= this.startPageY;
 
154
        this.setDelta(x, y);
 
155
    }
 
156
});
 
 
b'\\ No newline at end of file'