Project

General

Profile

« Previous | Next » 

Revision 1263

Added by Dietmar over 14 years ago

updated YUI 2.4.1 to 2.8.0r4

View differences:

dragdrop.js
1 1
/*
2
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
2
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
3 3
Code licensed under the BSD License:
4 4
http://developer.yahoo.net/yui/license.txt
5
version: 2.4.1
5
version: 2.8.0r4
6 6
*/
7 7
/**
8 8
 * The drag and drop utility provides a framework for building drag and drop
......
30 30
 */
31 31
YAHOO.util.DragDropMgr = function() {
32 32

  
33
    var Event = YAHOO.util.Event;
33
    var Event = YAHOO.util.Event,
34
        Dom = YAHOO.util.Dom;
34 35

  
35 36
    return {
36

  
37 37
        /**
38
        * This property is used to turn on global use of the shim element on all DragDrop instances, defaults to false for backcompat. (Use: YAHOO.util.DDM.useShim = true)
39
        * @property useShim
40
        * @type Boolean
41
        * @static
42
        */
43
        useShim: false,
44
        /**
45
        * This property is used to determine if the shim is active over the screen, default false.
46
        * @private
47
        * @property _shimActive
48
        * @type Boolean
49
        * @static
50
        */
51
        _shimActive: false,
52
        /**
53
        * This property is used when useShim is set on a DragDrop object to store the current state of DDM.useShim so it can be reset when a drag operation is done.
54
        * @private
55
        * @property _shimState
56
        * @type Boolean
57
        * @static
58
        */
59
        _shimState: false,
60
        /**
61
        * This property is used when useShim is set to true, it will set the opacity on the shim to .5 for debugging. Use: (YAHOO.util.DDM._debugShim = true;)
62
        * @private
63
        * @property _debugShim
64
        * @type Boolean
65
        * @static
66
        */
67
        _debugShim: false,
68
        /**
69
        * This method will create a shim element (giving it the id of yui-ddm-shim), it also attaches the mousemove and mouseup listeners to it and attaches a scroll listener on the window
70
        * @private
71
        * @method _sizeShim
72
        * @static
73
        */
74
        _createShim: function() {
75
            var s = document.createElement('div');
76
            s.id = 'yui-ddm-shim';
77
            if (document.body.firstChild) {
78
                document.body.insertBefore(s, document.body.firstChild);
79
            } else {
80
                document.body.appendChild(s);
81
            }
82
            s.style.display = 'none';
83
            s.style.backgroundColor = 'red';
84
            s.style.position = 'absolute';
85
            s.style.zIndex = '99999';
86
            Dom.setStyle(s, 'opacity', '0');
87
            this._shim = s;
88
            Event.on(s, "mouseup",   this.handleMouseUp, this, true);
89
            Event.on(s, "mousemove", this.handleMouseMove, this, true);
90
            Event.on(window, 'scroll', this._sizeShim, this, true);
91
        },
92
        /**
93
        * This method will size the shim, called from activate and on window scroll event
94
        * @private
95
        * @method _sizeShim
96
        * @static
97
        */
98
        _sizeShim: function() {
99
            if (this._shimActive) {
100
                var s = this._shim;
101
                s.style.height = Dom.getDocumentHeight() + 'px';
102
                s.style.width = Dom.getDocumentWidth() + 'px';
103
                s.style.top = '0';
104
                s.style.left = '0';
105
            }
106
        },
107
        /**
108
        * This method will create the shim element if needed, then show the shim element, size the element and set the _shimActive property to true
109
        * @private
110
        * @method _activateShim
111
        * @static
112
        */
113
        _activateShim: function() {
114
            if (this.useShim) {
115
                if (!this._shim) {
116
                    this._createShim();
117
                }
118
                this._shimActive = true;
119
                var s = this._shim,
120
                    o = '0';
121
                if (this._debugShim) {
122
                    o = '.5';
123
                }
124
                Dom.setStyle(s, 'opacity', o);
125
                this._sizeShim();
126
                s.style.display = 'block';
127
            }
128
        },
129
        /**
130
        * This method will hide the shim element and set the _shimActive property to false
131
        * @private
132
        * @method _deactivateShim
133
        * @static
134
        */
135
        _deactivateShim: function() {
136
            this._shim.style.display = 'none';
137
            this._shimActive = false;
138
        },
139
        /**
140
        * The HTML element created to use as a shim over the document to track mouse movements
141
        * @private
142
        * @property _shim
143
        * @type HTMLElement
144
        * @static
145
        */
146
        _shim: null,
147
        /**
38 148
         * Two dimensional Array of registered DragDrop objects.  The first 
39 149
         * dimension is the DragDrop item group, the second the DragDrop 
40 150
         * object.
......
228 338

  
229 339
            this.init();
230 340

  
231

  
232 341
            Event.on(document, "mouseup",   this.handleMouseUp, this, true);
233 342
            Event.on(document, "mousemove", this.handleMouseMove, this, true);
234 343
            Event.on(window,   "unload",    this._onUnload, this, true);
......
398 507
         */
399 508
        _remove: function(oDD) {
400 509
            for (var g in oDD.groups) {
401
                if (g && this.ids[g][oDD.id]) {
402
                    delete this.ids[g][oDD.id];
510
                if (g) {
511
                    var item = this.ids[g];
512
                    if (item && item[oDD.id]) {
513
                        delete item[oDD.id];
514
                    }
403 515
                }
516
                
404 517
            }
405 518
            delete this.handleIds[oDD.id];
406 519
        },
......
536 649
         * @static
537 650
         */
538 651
        handleMouseDown: function(e, oDD) {
652
            //this._activateShim();
539 653

  
540 654
            this.currentTarget = YAHOO.util.Event.getTarget(e);
541 655

  
......
562 676
        },
563 677

  
564 678
        /**
565
         * Fired when either the drag pixel threshol or the mousedown hold 
679
         * Fired when either the drag pixel threshold or the mousedown hold 
566 680
         * time threshold has been met.
567 681
         * @method startDrag
568 682
         * @param x {int} the X position of the original mousedown
......
570 684
         * @static
571 685
         */
572 686
        startDrag: function(x, y) {
687
            if (this.dragCurrent && this.dragCurrent.useShim) {
688
                this._shimState = this.useShim;
689
                this.useShim = true;
690
            }
691
            this._activateShim();
573 692
            clearTimeout(this.clickTimeout);
574 693
            var dc = this.dragCurrent;
575
            if (dc) {
694
            if (dc && dc.events.b4StartDrag) {
576 695
                dc.b4StartDrag(x, y);
696
                dc.fireEvent('b4StartDragEvent', { x: x, y: y });
577 697
            }
578
            if (dc) {
698
            if (dc && dc.events.startDrag) {
579 699
                dc.startDrag(x, y);
700
                dc.fireEvent('startDragEvent', { x: x, y: y });
580 701
            }
581 702
            this.dragThreshMet = true;
582 703
        },
......
595 716

  
596 717
                if (this.dragThreshMet) {
597 718
                    if (this.fromTimeout) {
719
                        this.fromTimeout = false;
598 720
                        this.handleMouseMove(e);
599 721
                    }
600 722
                    this.fromTimeout = false;
......
643 765
         * @static
644 766
         */
645 767
        stopDrag: function(e, silent) {
646

  
768
            var dc = this.dragCurrent;
647 769
            // Fire the drag end event for the item that was dragged
648
            if (this.dragCurrent && !silent) {
770
            if (dc && !silent) {
649 771
                if (this.dragThreshMet) {
650
                    this.dragCurrent.b4EndDrag(e);
651
                    this.dragCurrent.endDrag(e);
772
                    if (dc.events.b4EndDrag) {
773
                        dc.b4EndDrag(e);
774
                        dc.fireEvent('b4EndDragEvent', { e: e });
775
                    }
776
                    if (dc.events.endDrag) {
777
                        dc.endDrag(e);
778
                        dc.fireEvent('endDragEvent', { e: e });
779
                    }
652 780
                }
781
                if (dc.events.mouseUp) {
782
                    dc.onMouseUp(e);
783
                    dc.fireEvent('mouseUpEvent', { e: e });
784
                }
785
            }
653 786

  
654
                this.dragCurrent.onMouseUp(e);
787
            if (this._shimActive) {
788
                this._deactivateShim();
789
                if (this.dragCurrent && this.dragCurrent.useShim) {
790
                    this.useShim = this._shimState;
791
                    this._shimState = false;
792
                }
655 793
            }
656 794

  
657 795
            this.dragCurrent = null;
......
673 811
         * @static
674 812
         */
675 813
        handleMouseMove: function(e) {
676
            
814

  
677 815
            var dc = this.dragCurrent;
678 816
            if (dc) {
679 817

  
......
683 821
                if (YAHOO.util.Event.isIE && !e.button) {
684 822
                    this.stopEvent(e);
685 823
                    return this.handleMouseUp(e);
824
                } else {
825
                    if (e.clientX < 0 || e.clientY < 0) {
826
                        //This will stop the element from leaving the viewport in FF, Opera & Safari
827
                        //Not turned on yet
828
                        //this.stopEvent(e);
829
                        //return false;
830
                    }
686 831
                }
687 832

  
688 833
                if (!this.dragThreshMet) {
......
695 840
                }
696 841

  
697 842
                if (this.dragThreshMet) {
698
                    dc.b4Drag(e);
699
                    if (dc) {
843
                    if (dc && dc.events.b4Drag) {
844
                        dc.b4Drag(e);
845
                        dc.fireEvent('b4DragEvent', { e: e});
846
                    }
847
                    if (dc && dc.events.drag) {
700 848
                        dc.onDrag(e);
849
                        dc.fireEvent('dragEvent', { e: e});
701 850
                    }
702 851
                    if (dc) {
703 852
                        this.fireEvents(e, false);
......
732 881
                pt = new YAHOO.util.Point(x,y),
733 882
                pos = dc.getTargetCoord(pt.x, pt.y),
734 883
                el = dc.getDragEl(),
884
                events = ['out', 'over', 'drop', 'enter'],
735 885
                curRegion = new YAHOO.util.Region( pos.y, 
736 886
                                               pos.x + el.offsetWidth,
737 887
                                               pos.y + el.offsetHeight, 
738 888
                                               pos.x ),
739 889
            
740 890
                oldOvers = [], // cache the previous dragOver array
741
                outEvts   = [],
742
                overEvts  = [],
743
                dropEvts  = [],
744
                enterEvts = [],
745 891
                inGroupsObj  = {},
746
                inGroups  = [];
892
                inGroups  = [],
893
                data = {
894
                    outEvts: [],
895
                    overEvts: [],
896
                    dropEvts: [],
897
                    enterEvts: []
898
                };
747 899

  
748 900

  
749 901
            // Check to see if the object(s) we were hovering over is no longer 
......
756 908
                    continue;
757 909
                }
758 910
                if (! this.isOverTarget(pt, ddo, this.mode, curRegion)) {
759
                    outEvts.push( ddo );
911
                    data.outEvts.push( ddo );
760 912
                }
761 913

  
762 914
                oldOvers[i] = true;
......
780 932
                            inGroupsObj[sGroup] = true;
781 933
                            // look for drop interactions
782 934
                            if (isDrop) {
783
                                dropEvts.push( oDD );
935
                                data.dropEvts.push( oDD );
784 936
                            // look for drag enter and drag over interactions
785 937
                            } else {
786 938

  
787 939
                                // initial drag over: dragEnter fires
788 940
                                if (!oldOvers[oDD.id]) {
789
                                    enterEvts.push( oDD );
941
                                    data.enterEvts.push( oDD );
790 942
                                // subsequent drag overs: dragOver fires
791 943
                                } else {
792
                                    overEvts.push( oDD );
944
                                    data.overEvts.push( oDD );
793 945
                                }
794 946

  
795 947
                                this.dragOvers[oDD.id] = oDD;
......
800 952
            }
801 953

  
802 954
            this.interactionInfo = {
803
                out:       outEvts,
804
                enter:     enterEvts,
805
                over:      overEvts,
806
                drop:      dropEvts,
955
                out:       data.outEvts,
956
                enter:     data.enterEvts,
957
                over:      data.overEvts,
958
                drop:      data.dropEvts,
807 959
                point:     pt,
808 960
                draggedRegion:    curRegion,
809 961
                sourceRegion: this.locationCache[dc.id],
......
816 968
            }
817 969

  
818 970
            // notify about a drop that did not find a target
819
            if (isDrop && !dropEvts.length) {
971
            if (isDrop && !data.dropEvts.length) {
820 972
                this.interactionInfo.validDrop = false;
821
                dc.onInvalidDrop(e);
973
                if (dc.events.invalidDrop) {
974
                    dc.onInvalidDrop(e);
975
                    dc.fireEvent('invalidDropEvent', { e: e });
976
                }
822 977
            }
823

  
824

  
825
            if (this.mode) {
826
                if (outEvts.length) {
827
                    dc.b4DragOut(e, outEvts);
828
                    if (dc) {
829
                        dc.onDragOut(e, outEvts);
830
                    }
978
            for (i = 0; i < events.length; i++) {
979
                var tmp = null;
980
                if (data[events[i] + 'Evts']) {
981
                    tmp = data[events[i] + 'Evts'];
831 982
                }
832

  
833
                if (enterEvts.length) {
834
                    if (dc) {
835
                        dc.onDragEnter(e, enterEvts, inGroups);
983
                if (tmp && tmp.length) {
984
                    var type = events[i].charAt(0).toUpperCase() + events[i].substr(1),
985
                        ev = 'onDrag' + type,
986
                        b4 = 'b4Drag' + type,
987
                        cev = 'drag' + type + 'Event',
988
                        check = 'drag' + type;
989
                    if (this.mode) {
990
                        if (dc.events[b4]) {
991
                            dc[b4](e, tmp, inGroups);
992
                            dc.fireEvent(b4 + 'Event', { event: e, info: tmp, group: inGroups });
993
                            
994
                        }
995
                        if (dc.events[check]) {
996
                            dc[ev](e, tmp, inGroups);
997
                            dc.fireEvent(cev, { event: e, info: tmp, group: inGroups });
998
                        }
999
                    } else {
1000
                        for (var b = 0, len = tmp.length; b < len; ++b) {
1001
                            if (dc.events[b4]) {
1002
                                dc[b4](e, tmp[b].id, inGroups[0]);
1003
                                dc.fireEvent(b4 + 'Event', { event: e, info: tmp[b].id, group: inGroups[0] });
1004
                            }
1005
                            if (dc.events[check]) {
1006
                                dc[ev](e, tmp[b].id, inGroups[0]);
1007
                                dc.fireEvent(cev, { event: e, info: tmp[b].id, group: inGroups[0] });
1008
                            }
1009
                        }
836 1010
                    }
837 1011
                }
838

  
839
                if (overEvts.length) {
840
                    if (dc) {
841
                        dc.b4DragOver(e, overEvts, inGroups);
842
                    }
843

  
844
                    if (dc) {
845
                        dc.onDragOver(e, overEvts, inGroups);
846
                    }
847
                }
848

  
849
                if (dropEvts.length) {
850
                    if (dc) {
851
                        dc.b4DragDrop(e, dropEvts, inGroups);
852
                    }
853
                    if (dc) {
854
                        dc.onDragDrop(e, dropEvts, inGroups);
855
                    }
856
                }
857

  
858
            } else {
859
                // fire dragout events
860
                var len = 0;
861
                for (i=0, len=outEvts.length; i<len; ++i) {
862
                    if (dc) {
863
                        dc.b4DragOut(e, outEvts[i].id, inGroups[0]);
864
                    }
865
                    if (dc) {
866
                        dc.onDragOut(e, outEvts[i].id, inGroups[0]);
867
                    }
868
                }
869
                 
870
                // fire enter events
871
                for (i=0,len=enterEvts.length; i<len; ++i) {
872
                    // dc.b4DragEnter(e, oDD.id);
873

  
874
                    if (dc) {
875
                        dc.onDragEnter(e, enterEvts[i].id, inGroups[0]);
876
                    }
877
                }
878
         
879
                // fire over events
880
                for (i=0,len=overEvts.length; i<len; ++i) {
881
                    if (dc) {
882
                        dc.b4DragOver(e, overEvts[i].id, inGroups[0]);
883
                    }
884
                    if (dc) {
885
                        dc.onDragOver(e, overEvts[i].id, inGroups[0]);
886
                    }
887
                }
888

  
889
                // fire drop events
890
                for (i=0, len=dropEvts.length; i<len; ++i) {
891
                    if (dc) {
892
                        dc.b4DragDrop(e, dropEvts[i].id, inGroups[0]);
893
                    }
894
                    if (dc) {
895
                        dc.onDragDrop(e, dropEvts[i].id, inGroups[0]);
896
                    }
897
                }
898

  
899 1012
            }
900 1013
        },
901 1014

  
......
1088 1201

  
1089 1202
            oTarget.overlap = null;
1090 1203

  
1204

  
1091 1205
            // Get the current location of the drag element, this is the
1092 1206
            // location of the mouse event less the delta that represents
1093 1207
            // where the original mousedown happened on the element.  We
......
1488 1602
};
1489 1603

  
1490 1604
YAHOO.util.DragDrop.prototype = {
1491

  
1492 1605
    /**
1606
     * An Object Literal containing the events that we will be using: mouseDown, b4MouseDown, mouseUp, b4StartDrag, startDrag, b4EndDrag, endDrag, mouseUp, drag, b4Drag, invalidDrop, b4DragOut, dragOut, dragEnter, b4DragOver, dragOver, b4DragDrop, dragDrop
1607
     * By setting any of these to false, then event will not be fired.
1608
     * @property events
1609
     * @type object
1610
     */
1611
    events: null,
1612
    /**
1613
    * @method on
1614
    * @description Shortcut for EventProvider.subscribe, see <a href="YAHOO.util.EventProvider.html#subscribe">YAHOO.util.EventProvider.subscribe</a>
1615
    */
1616
    on: function() {
1617
        this.subscribe.apply(this, arguments);
1618
    },
1619
    /**
1493 1620
     * The id of the element associated with this object.  This is what we 
1494 1621
     * refer to as the "linked element" because the size and position of 
1495 1622
     * this element is used to determine when the drag and drop objects have 
......
1621 1748
    dragOnly: false,
1622 1749

  
1623 1750
    /**
1751
     * If this flag is true, a shim will be placed over the screen/viewable area to track mouse events. Should help with dragging elements over iframes and other controls.
1752
     * @property useShim
1753
     * @type Boolean
1754
     */
1755
    useShim: false,
1756

  
1757
    /**
1624 1758
     * Cached reference to the linked element
1625 1759
     * @property _domRef
1626 1760
     * @private
......
1964 2098
        this.initTarget(id, sGroup, config);
1965 2099
        Event.on(this._domRef || this.id, "mousedown", 
1966 2100
                        this.handleMouseDown, this, true);
2101

  
1967 2102
        // Event.on(this.id, "selectstart", Event.preventDefault);
2103
        for (var i in this.events) {
2104
            this.createEvent(i + 'Event');
2105
        }
2106
        
1968 2107
    },
1969 2108

  
1970 2109
    /**
......
1980 2119
        // configuration attributes 
1981 2120
        this.config = config || {};
1982 2121

  
2122
        this.events = {};
2123

  
1983 2124
        // create a local reference to the drag and drop manager
1984 2125
        this.DDM = YAHOO.util.DDM;
1985 2126

  
......
2027 2168
     * @method applyConfig
2028 2169
     */
2029 2170
    applyConfig: function() {
2171
        this.events = {
2172
            mouseDown: true,
2173
            b4MouseDown: true,
2174
            mouseUp: true,
2175
            b4StartDrag: true,
2176
            startDrag: true,
2177
            b4EndDrag: true,
2178
            endDrag: true,
2179
            drag: true,
2180
            b4Drag: true,
2181
            invalidDrop: true,
2182
            b4DragOut: true,
2183
            dragOut: true,
2184
            dragEnter: true,
2185
            b4DragOver: true,
2186
            dragOver: true,
2187
            b4DragDrop: true,
2188
            dragDrop: true
2189
        };
2190
        
2191
        if (this.config.events) {
2192
            for (var i in this.config.events) {
2193
                if (this.config.events[i] === false) {
2194
                    this.events[i] = false;
2195
                }
2196
            }
2197
        }
2030 2198

  
2199

  
2031 2200
        // configurable properties: 
2032 2201
        //    padding, isTarget, maintainOffset, primaryButtonOnly
2033 2202
        this.padding           = this.config.padding || [0, 0, 0, 0];
......
2035 2204
        this.maintainOffset    = (this.config.maintainOffset);
2036 2205
        this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
2037 2206
        this.dragOnly = ((this.config.dragOnly === true) ? true : false);
2207
        this.useShim = ((this.config.useShim === true) ? true : false);
2038 2208
    },
2039 2209

  
2040 2210
    /**
......
2082 2252
        var el = this.getEl();
2083 2253

  
2084 2254
        if (!this.DDM.verifyEl(el)) {
2255
            if (el && el.style && (el.style.display == 'none')) {
2256
            } else {
2257
            }
2085 2258
            return;
2086 2259
        }
2087 2260

  
......
2232 2405

  
2233 2406

  
2234 2407
        // firing the mousedown events prior to calculating positions
2235
        var b4Return = this.b4MouseDown(e);
2236
        var mDownReturn = this.onMouseDown(e);
2408
        var b4Return = this.b4MouseDown(e),
2409
        b4Return2 = true;
2237 2410

  
2238
        if ((b4Return === false) || (mDownReturn === false)) {
2411
        if (this.events.b4MouseDown) {
2412
            b4Return2 = this.fireEvent('b4MouseDownEvent', e);
2413
        }
2414
        var mDownReturn = this.onMouseDown(e),
2415
            mDownReturn2 = true;
2416
        if (this.events.mouseDown) {
2417
            mDownReturn2 = this.fireEvent('mouseDownEvent', e);
2418
        }
2419

  
2420
        if ((b4Return === false) || (mDownReturn === false) || (b4Return2 === false) || (mDownReturn2 === false)) {
2239 2421
            return;
2240 2422
        }
2241 2423

  
......
2276 2458
     * @description Method validates that the clicked element
2277 2459
     * was indeed the handle or a valid child of the handle
2278 2460
     * @param {Event} e 
2279
     * @private
2280 2461
     */
2281 2462
    clickValidator: function(e) {
2282
        var target = Event.getTarget(e);
2463
        var target = YAHOO.util.Event.getTarget(e);
2283 2464
        return ( this.isValidHandleChild(target) &&
2284 2465
                    (this.id == this.handleElId || 
2285 2466
                        this.DDM.handleWasClicked(target, this.id)) );
......
2621 2802
    }
2622 2803

  
2623 2804
};
2805
YAHOO.augment(YAHOO.util.DragDrop, YAHOO.util.EventProvider);
2624 2806

  
2807
/**
2808
* @event mouseDownEvent
2809
* @description Provides access to the mousedown event. The mousedown does not always result in a drag operation.
2810
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2811
*/
2812

  
2813
/**
2814
* @event b4MouseDownEvent
2815
* @description Provides access to the mousedown event, before the mouseDownEvent gets fired. Returning false will cancel the drag.
2816
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2817
*/
2818

  
2819
/**
2820
* @event mouseUpEvent
2821
* @description Fired from inside DragDropMgr when the drag operation is finished.
2822
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2823
*/
2824

  
2825
/**
2826
* @event b4StartDragEvent
2827
* @description Fires before the startDragEvent, returning false will cancel the startDrag Event.
2828
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2829
*/
2830

  
2831
/**
2832
* @event startDragEvent
2833
* @description Occurs after a mouse down and the drag threshold has been met. The drag threshold default is either 3 pixels of mouse movement or 1 full second of holding the mousedown. 
2834
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2835
*/
2836

  
2837
/**
2838
* @event b4EndDragEvent
2839
* @description Fires before the endDragEvent. Returning false will cancel.
2840
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2841
*/
2842

  
2843
/**
2844
* @event endDragEvent
2845
* @description Fires on the mouseup event after a drag has been initiated (startDrag fired).
2846
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2847
*/
2848

  
2849
/**
2850
* @event dragEvent
2851
* @description Occurs every mousemove event while dragging.
2852
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2853
*/
2854
/**
2855
* @event b4DragEvent
2856
* @description Fires before the dragEvent.
2857
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2858
*/
2859
/**
2860
* @event invalidDropEvent
2861
* @description Fires when the dragged objects is dropped in a location that contains no drop targets.
2862
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2863
*/
2864
/**
2865
* @event b4DragOutEvent
2866
* @description Fires before the dragOutEvent
2867
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2868
*/
2869
/**
2870
* @event dragOutEvent
2871
* @description Fires when a dragged object is no longer over an object that had the onDragEnter fire. 
2872
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2873
*/
2874
/**
2875
* @event dragEnterEvent
2876
* @description Occurs when the dragged object first interacts with another targettable drag and drop object.
2877
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2878
*/
2879
/**
2880
* @event b4DragOverEvent
2881
* @description Fires before the dragOverEvent.
2882
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2883
*/
2884
/**
2885
* @event dragOverEvent
2886
* @description Fires every mousemove event while over a drag and drop object.
2887
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2888
*/
2889
/**
2890
* @event b4DragDropEvent 
2891
* @description Fires before the dragDropEvent
2892
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2893
*/
2894
/**
2895
* @event dragDropEvent
2896
* @description Fires when the dragged objects is dropped on another.
2897
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2898
*/
2625 2899
})();
2626 2900
/**
2627 2901
 * A DragDrop implementation where the linked element follows the 
......
2645 2919

  
2646 2920
    /**
2647 2921
     * When set to true, the utility automatically tries to scroll the browser
2648
     * window wehn a drag and drop element is dragged near the viewport boundary.
2922
     * window when a drag and drop element is dragged near the viewport boundary.
2649 2923
     * Defaults to true.
2650 2924
     * @property scroll
2651 2925
     * @type boolean
......
2711 2985
        if (!this.deltaSetXY) {
2712 2986
            var aCoord = [oCoord.x, oCoord.y];
2713 2987
            YAHOO.util.Dom.setXY(el, aCoord);
2988

  
2714 2989
            var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
2715 2990
            var newTop  = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
2716 2991

  
......
2718 2993
        } else {
2719 2994
            YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");
2720 2995
            YAHOO.util.Dom.setStyle(el, "top",  (oCoord.y + this.deltaSetXY[1]) + "px");
2721
            //el.style.left = (oCoord.x + this.deltaSetXY[0]) + "px";
2722
            //el.style.top = (oCoord.y + this.deltaSetXY[1]) + "px";
2723 2996
        }
2724 2997
        
2725 2998
        this.cachePosition(oCoord.x, oCoord.y);
2726
        //DAV
2727 2999
        var self = this;
2728 3000
        setTimeout(function() {
2729 3001
            self.autoScroll.call(self, oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
......
2887 3159

  
2888 3160
    */
2889 3161

  
3162
/**
3163
* @event mouseDownEvent
3164
* @description Provides access to the mousedown event. The mousedown does not always result in a drag operation.
3165
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3166
*/
3167

  
3168
/**
3169
* @event b4MouseDownEvent
3170
* @description Provides access to the mousedown event, before the mouseDownEvent gets fired. Returning false will cancel the drag.
3171
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3172
*/
3173

  
3174
/**
3175
* @event mouseUpEvent
3176
* @description Fired from inside DragDropMgr when the drag operation is finished.
3177
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3178
*/
3179

  
3180
/**
3181
* @event b4StartDragEvent
3182
* @description Fires before the startDragEvent, returning false will cancel the startDrag Event.
3183
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3184
*/
3185

  
3186
/**
3187
* @event startDragEvent
3188
* @description Occurs after a mouse down and the drag threshold has been met. The drag threshold default is either 3 pixels of mouse movement or 1 full second of holding the mousedown. 
3189
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3190
*/
3191

  
3192
/**
3193
* @event b4EndDragEvent
3194
* @description Fires before the endDragEvent. Returning false will cancel.
3195
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3196
*/
3197

  
3198
/**
3199
* @event endDragEvent
3200
* @description Fires on the mouseup event after a drag has been initiated (startDrag fired).
3201
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3202
*/
3203

  
3204
/**
3205
* @event dragEvent
3206
* @description Occurs every mousemove event while dragging.
3207
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3208
*/
3209
/**
3210
* @event b4DragEvent
3211
* @description Fires before the dragEvent.
3212
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3213
*/
3214
/**
3215
* @event invalidDropEvent
3216
* @description Fires when the dragged objects is dropped in a location that contains no drop targets.
3217
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3218
*/
3219
/**
3220
* @event b4DragOutEvent
3221
* @description Fires before the dragOutEvent
3222
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3223
*/
3224
/**
3225
* @event dragOutEvent
3226
* @description Fires when a dragged object is no longer over an object that had the onDragEnter fire. 
3227
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3228
*/
3229
/**
3230
* @event dragEnterEvent
3231
* @description Occurs when the dragged object first interacts with another targettable drag and drop object.
3232
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3233
*/
3234
/**
3235
* @event b4DragOverEvent
3236
* @description Fires before the dragOverEvent.
3237
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3238
*/
3239
/**
3240
* @event dragOverEvent
3241
* @description Fires every mousemove event while over a drag and drop object.
3242
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3243
*/
3244
/**
3245
* @event b4DragDropEvent 
3246
* @description Fires before the dragDropEvent
3247
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3248
*/
3249
/**
3250
* @event dragDropEvent
3251
* @description Fires when the dragged objects is dropped on another.
3252
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3253
*/
2890 3254
});
2891 3255
/**
2892 3256
 * A DragDrop implementation that inserts an empty, bordered div into
......
3113 3477
    toString: function() {
3114 3478
        return ("DDProxy " + this.id);
3115 3479
    }
3480
/**
3481
* @event mouseDownEvent
3482
* @description Provides access to the mousedown event. The mousedown does not always result in a drag operation.
3483
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3484
*/
3116 3485

  
3486
/**
3487
* @event b4MouseDownEvent
3488
* @description Provides access to the mousedown event, before the mouseDownEvent gets fired. Returning false will cancel the drag.
3489
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3490
*/
3491

  
3492
/**
3493
* @event mouseUpEvent
3494
* @description Fired from inside DragDropMgr when the drag operation is finished.
3495
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3496
*/
3497

  
3498
/**
3499
* @event b4StartDragEvent
3500
* @description Fires before the startDragEvent, returning false will cancel the startDrag Event.
3501
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3502
*/
3503

  
3504
/**
3505
* @event startDragEvent
3506
* @description Occurs after a mouse down and the drag threshold has been met. The drag threshold default is either 3 pixels of mouse movement or 1 full second of holding the mousedown. 
3507
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3508
*/
3509

  
3510
/**
3511
* @event b4EndDragEvent
3512
* @description Fires before the endDragEvent. Returning false will cancel.
3513
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3514
*/
3515

  
3516
/**
3517
* @event endDragEvent
3518
* @description Fires on the mouseup event after a drag has been initiated (startDrag fired).
3519
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3520
*/
3521

  
3522
/**
3523
* @event dragEvent
3524
* @description Occurs every mousemove event while dragging.
3525
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3526
*/
3527
/**
3528
* @event b4DragEvent
3529
* @description Fires before the dragEvent.
3530
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3531
*/
3532
/**
3533
* @event invalidDropEvent
3534
* @description Fires when the dragged objects is dropped in a location that contains no drop targets.
3535
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3536
*/
3537
/**
3538
* @event b4DragOutEvent
3539
* @description Fires before the dragOutEvent
3540
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3541
*/
3542
/**
3543
* @event dragOutEvent
3544
* @description Fires when a dragged object is no longer over an object that had the onDragEnter fire. 
3545
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3546
*/
3547
/**
3548
* @event dragEnterEvent
3549
* @description Occurs when the dragged object first interacts with another targettable drag and drop object.
3550
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3551
*/
3552
/**
3553
* @event b4DragOverEvent
3554
* @description Fires before the dragOverEvent.
3555
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3556
*/
3557
/**
3558
* @event dragOverEvent
3559
* @description Fires every mousemove event while over a drag and drop object.
3560
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3561
*/
3562
/**
3563
* @event b4DragDropEvent 
3564
* @description Fires before the dragDropEvent
3565
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3566
*/
3567
/**
3568
* @event dragDropEvent
3569
* @description Fires when the dragged objects is dropped on another.
3570
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3571
*/
3572

  
3117 3573
});
3118 3574
/**
3119 3575
 * A DragDrop implementation that does not move, but can be a drop 
......
3142 3598
        return ("DDTarget " + this.id);
3143 3599
    }
3144 3600
});
3145
YAHOO.register("dragdrop", YAHOO.util.DragDropMgr, {version: "2.4.1", build: "742"});
3601
YAHOO.register("dragdrop", YAHOO.util.DragDropMgr, {version: "2.8.0r4", build: "2449"});

Also available in: Unified diff