Project

General

Profile

« Previous | Next » 

Revision 1289

Added by kweitzel over 14 years ago

Branch 2.8.1 merged back into Trunk

View differences:

dragdrop-debug.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
            YAHOO.log('Creating Shim Element', 'info', 'DragDropMgr');
76
            var s = document.createElement('div');
77
            s.id = 'yui-ddm-shim';
78
            if (document.body.firstChild) {
79
                document.body.insertBefore(s, document.body.firstChild);
80
            } else {
81
                document.body.appendChild(s);
82
            }
83
            s.style.display = 'none';
84
            s.style.backgroundColor = 'red';
85
            s.style.position = 'absolute';
86
            s.style.zIndex = '99999';
87
            Dom.setStyle(s, 'opacity', '0');
88
            this._shim = s;
89
            Event.on(s, "mouseup",   this.handleMouseUp, this, true);
90
            Event.on(s, "mousemove", this.handleMouseMove, this, true);
91
            Event.on(window, 'scroll', this._sizeShim, this, true);
92
        },
93
        /**
94
        * This method will size the shim, called from activate and on window scroll event
95
        * @private
96
        * @method _sizeShim
97
        * @static
98
        */
99
        _sizeShim: function() {
100
            if (this._shimActive) {
101
                YAHOO.log('Sizing Shim', 'info', 'DragDropMgr');
102
                var s = this._shim;
103
                s.style.height = Dom.getDocumentHeight() + 'px';
104
                s.style.width = Dom.getDocumentWidth() + 'px';
105
                s.style.top = '0';
106
                s.style.left = '0';
107
            }
108
        },
109
        /**
110
        * This method will create the shim element if needed, then show the shim element, size the element and set the _shimActive property to true
111
        * @private
112
        * @method _activateShim
113
        * @static
114
        */
115
        _activateShim: function() {
116
            if (this.useShim) {
117
                YAHOO.log('Activating Shim', 'info', 'DragDropMgr');
118
                if (!this._shim) {
119
                    this._createShim();
120
                }
121
                this._shimActive = true;
122
                var s = this._shim,
123
                    o = '0';
124
                if (this._debugShim) {
125
                    o = '.5';
126
                }
127
                Dom.setStyle(s, 'opacity', o);
128
                this._sizeShim();
129
                s.style.display = 'block';
130
            }
131
        },
132
        /**
133
        * This method will hide the shim element and set the _shimActive property to false
134
        * @private
135
        * @method _deactivateShim
136
        * @static
137
        */
138
        _deactivateShim: function() {
139
            YAHOO.log('Deactivating Shim', 'info', 'DragDropMgr');
140
            this._shim.style.display = 'none';
141
            this._shimActive = false;
142
        },
143
        /**
144
        * The HTML element created to use as a shim over the document to track mouse movements
145
        * @private
146
        * @property _shim
147
        * @type HTMLElement
148
        * @static
149
        */
150
        _shim: null,
151
        /**
38 152
         * Two dimensional Array of registered DragDrop objects.  The first 
39 153
         * dimension is the DragDrop item group, the second the DragDrop 
40 154
         * object.
......
229 343
            this.init();
230 344

  
231 345
            YAHOO.log("DragDropMgr onload", "info", "DragDropMgr");
232

  
233 346
            Event.on(document, "mouseup",   this.handleMouseUp, this, true);
234 347
            Event.on(document, "mousemove", this.handleMouseMove, this, true);
235 348
            Event.on(window,   "unload",    this._onUnload, this, true);
......
400 513
         */
401 514
        _remove: function(oDD) {
402 515
            for (var g in oDD.groups) {
403
                if (g && this.ids[g][oDD.id]) {
404
                    delete this.ids[g][oDD.id];
405
                    //YAHOO.log("NEW LEN " + this.ids.length, "warn");
516
                if (g) {
517
                    var item = this.ids[g];
518
                    if (item && item[oDD.id]) {
519
                        delete item[oDD.id];
520
                    }
406 521
                }
522
                
407 523
            }
408 524
            delete this.handleIds[oDD.id];
409 525
        },
......
539 655
         * @static
540 656
         */
541 657
        handleMouseDown: function(e, oDD) {
658
            //this._activateShim();
542 659

  
543 660
            this.currentTarget = YAHOO.util.Event.getTarget(e);
544 661

  
......
565 682
        },
566 683

  
567 684
        /**
568
         * Fired when either the drag pixel threshol or the mousedown hold 
685
         * Fired when either the drag pixel threshold or the mousedown hold 
569 686
         * time threshold has been met.
570 687
         * @method startDrag
571 688
         * @param x {int} the X position of the original mousedown
......
573 690
         * @static
574 691
         */
575 692
        startDrag: function(x, y) {
693
            if (this.dragCurrent && this.dragCurrent.useShim) {
694
                this._shimState = this.useShim;
695
                this.useShim = true;
696
            }
697
            this._activateShim();
576 698
            YAHOO.log("firing drag start events", "info", "DragDropMgr");
577 699
            clearTimeout(this.clickTimeout);
578 700
            var dc = this.dragCurrent;
579
            if (dc) {
701
            if (dc && dc.events.b4StartDrag) {
580 702
                dc.b4StartDrag(x, y);
703
                dc.fireEvent('b4StartDragEvent', { x: x, y: y });
581 704
            }
582
            if (dc) {
705
            if (dc && dc.events.startDrag) {
583 706
                dc.startDrag(x, y);
707
                dc.fireEvent('startDragEvent', { x: x, y: y });
584 708
            }
585 709
            this.dragThreshMet = true;
586 710
        },
......
600 724
                if (this.dragThreshMet) {
601 725
                    YAHOO.log("mouseup detected - completing drag", "info", "DragDropMgr");
602 726
                    if (this.fromTimeout) {
603
                        YAHOO.log('fromTimeout is true (mouse didn\'t move), call handleMouseDown so we can get the dragOver event', 'info', 'DragDropMgr');
727
                        YAHOO.log('fromTimeout is true (mouse didn\'t move), call handleMouseMove so we can get the dragOver event', 'info', 'DragDropMgr');
728
                        this.fromTimeout = false;
604 729
                        this.handleMouseMove(e);
605 730
                    }
606 731
                    this.fromTimeout = false;
......
651 776
         */
652 777
        stopDrag: function(e, silent) {
653 778
            // YAHOO.log("mouseup - removing event handlers");
654

  
779
            var dc = this.dragCurrent;
655 780
            // Fire the drag end event for the item that was dragged
656
            if (this.dragCurrent && !silent) {
781
            if (dc && !silent) {
657 782
                if (this.dragThreshMet) {
658 783
                    YAHOO.log("firing endDrag events", "info", "DragDropMgr");
659
                    this.dragCurrent.b4EndDrag(e);
660
                    this.dragCurrent.endDrag(e);
784
                    if (dc.events.b4EndDrag) {
785
                        dc.b4EndDrag(e);
786
                        dc.fireEvent('b4EndDragEvent', { e: e });
787
                    }
788
                    if (dc.events.endDrag) {
789
                        dc.endDrag(e);
790
                        dc.fireEvent('endDragEvent', { e: e });
791
                    }
661 792
                }
793
                if (dc.events.mouseUp) {
794
                    YAHOO.log("firing dragdrop onMouseUp event", "info", "DragDropMgr");
795
                    dc.onMouseUp(e);
796
                    dc.fireEvent('mouseUpEvent', { e: e });
797
                }
798
            }
662 799

  
663
                YAHOO.log("firing dragdrop onMouseUp event", "info", "DragDropMgr");
664
                this.dragCurrent.onMouseUp(e);
800
            if (this._shimActive) {
801
                this._deactivateShim();
802
                if (this.dragCurrent && this.dragCurrent.useShim) {
803
                    this.useShim = this._shimState;
804
                    this._shimState = false;
805
                }
665 806
            }
666 807

  
667 808
            this.dragCurrent = null;
......
684 825
         */
685 826
        handleMouseMove: function(e) {
686 827
            //YAHOO.log("handlemousemove");
687
            
828

  
688 829
            var dc = this.dragCurrent;
689 830
            if (dc) {
690 831
                // YAHOO.log("no current drag obj");
......
697 838
                    YAHOO.log("button failure", "info", "DragDropMgr");
698 839
                    this.stopEvent(e);
699 840
                    return this.handleMouseUp(e);
841
                } else {
842
                    if (e.clientX < 0 || e.clientY < 0) {
843
                        //This will stop the element from leaving the viewport in FF, Opera & Safari
844
                        //Not turned on yet
845
                        //YAHOO.log("Either clientX or clientY is negative, stop the event.", "info", "DragDropMgr");
846
                        //this.stopEvent(e);
847
                        //return false;
848
                    }
700 849
                }
701 850

  
702 851
                if (!this.dragThreshMet) {
......
711 860
                }
712 861

  
713 862
                if (this.dragThreshMet) {
714
                    dc.b4Drag(e);
715
                    if (dc) {
863
                    if (dc && dc.events.b4Drag) {
864
                        dc.b4Drag(e);
865
                        dc.fireEvent('b4DragEvent', { e: e});
866
                    }
867
                    if (dc && dc.events.drag) {
716 868
                        dc.onDrag(e);
869
                        dc.fireEvent('dragEvent', { e: e});
717 870
                    }
718 871
                    if (dc) {
719 872
                        this.fireEvents(e, false);
......
748 901
                pt = new YAHOO.util.Point(x,y),
749 902
                pos = dc.getTargetCoord(pt.x, pt.y),
750 903
                el = dc.getDragEl(),
904
                events = ['out', 'over', 'drop', 'enter'],
751 905
                curRegion = new YAHOO.util.Region( pos.y, 
752 906
                                               pos.x + el.offsetWidth,
753 907
                                               pos.y + el.offsetHeight, 
754 908
                                               pos.x ),
755 909
            
756 910
                oldOvers = [], // cache the previous dragOver array
757
                outEvts   = [],
758
                overEvts  = [],
759
                dropEvts  = [],
760
                enterEvts = [],
761 911
                inGroupsObj  = {},
762
                inGroups  = [];
912
                inGroups  = [],
913
                data = {
914
                    outEvts: [],
915
                    overEvts: [],
916
                    dropEvts: [],
917
                    enterEvts: []
918
                };
763 919

  
764 920

  
765 921
            // Check to see if the object(s) we were hovering over is no longer 
......
772 928
                    continue;
773 929
                }
774 930
                if (! this.isOverTarget(pt, ddo, this.mode, curRegion)) {
775
                    outEvts.push( ddo );
931
                    data.outEvts.push( ddo );
776 932
                }
777 933

  
778 934
                oldOvers[i] = true;
......
797 953
                            inGroupsObj[sGroup] = true;
798 954
                            // look for drop interactions
799 955
                            if (isDrop) {
800
                                dropEvts.push( oDD );
956
                                data.dropEvts.push( oDD );
801 957
                            // look for drag enter and drag over interactions
802 958
                            } else {
803 959

  
804 960
                                // initial drag over: dragEnter fires
805 961
                                if (!oldOvers[oDD.id]) {
806
                                    enterEvts.push( oDD );
962
                                    data.enterEvts.push( oDD );
807 963
                                // subsequent drag overs: dragOver fires
808 964
                                } else {
809
                                    overEvts.push( oDD );
965
                                    data.overEvts.push( oDD );
810 966
                                }
811 967

  
812 968
                                this.dragOvers[oDD.id] = oDD;
......
817 973
            }
818 974

  
819 975
            this.interactionInfo = {
820
                out:       outEvts,
821
                enter:     enterEvts,
822
                over:      overEvts,
823
                drop:      dropEvts,
976
                out:       data.outEvts,
977
                enter:     data.enterEvts,
978
                over:      data.overEvts,
979
                drop:      data.dropEvts,
824 980
                point:     pt,
825 981
                draggedRegion:    curRegion,
826 982
                sourceRegion: this.locationCache[dc.id],
......
833 989
            }
834 990

  
835 991
            // notify about a drop that did not find a target
836
            if (isDrop && !dropEvts.length) {
992
            if (isDrop && !data.dropEvts.length) {
837 993
                YAHOO.log(dc.id + " dropped, but not on a target", "info", "DragDropMgr");
838 994
                this.interactionInfo.validDrop = false;
839
                dc.onInvalidDrop(e);
995
                if (dc.events.invalidDrop) {
996
                    dc.onInvalidDrop(e);
997
                    dc.fireEvent('invalidDropEvent', { e: e });
998
                }
840 999
            }
841

  
842

  
843
            if (this.mode) {
844
                if (outEvts.length) {
845
                    YAHOO.log(dc.id+" onDragOut: " + outEvts, "info", "DragDropMgr");
846
                    dc.b4DragOut(e, outEvts);
847
                    if (dc) {
848
                        dc.onDragOut(e, outEvts);
849
                    }
1000
            for (i = 0; i < events.length; i++) {
1001
                var tmp = null;
1002
                if (data[events[i] + 'Evts']) {
1003
                    tmp = data[events[i] + 'Evts'];
850 1004
                }
851

  
852
                if (enterEvts.length) {
853
                    YAHOO.log(dc.id+" onDragEnter: " + enterEvts + " (group: " + inGroups + ")", "info", "DragDropMgr");
854
                    if (dc) {
855
                        dc.onDragEnter(e, enterEvts, inGroups);
1005
                if (tmp && tmp.length) {
1006
                    var type = events[i].charAt(0).toUpperCase() + events[i].substr(1),
1007
                        ev = 'onDrag' + type,
1008
                        b4 = 'b4Drag' + type,
1009
                        cev = 'drag' + type + 'Event',
1010
                        check = 'drag' + type;
1011
                    if (this.mode) {
1012
                        YAHOO.log(dc.id + ' ' + ev + ': ' + tmp, "info", "DragDropMgr");
1013
                        if (dc.events[b4]) {
1014
                            dc[b4](e, tmp, inGroups);
1015
                            dc.fireEvent(b4 + 'Event', { event: e, info: tmp, group: inGroups });
1016
                            
1017
                        }
1018
                        if (dc.events[check]) {
1019
                            dc[ev](e, tmp, inGroups);
1020
                            dc.fireEvent(cev, { event: e, info: tmp, group: inGroups });
1021
                        }
1022
                    } else {
1023
                        for (var b = 0, len = tmp.length; b < len; ++b) {
1024
                            YAHOO.log(dc.id + ' ' + ev + ': ' + tmp[b].id, "info", "DragDropMgr");
1025
                            if (dc.events[b4]) {
1026
                                dc[b4](e, tmp[b].id, inGroups[0]);
1027
                                dc.fireEvent(b4 + 'Event', { event: e, info: tmp[b].id, group: inGroups[0] });
1028
                            }
1029
                            if (dc.events[check]) {
1030
                                dc[ev](e, tmp[b].id, inGroups[0]);
1031
                                dc.fireEvent(cev, { event: e, info: tmp[b].id, group: inGroups[0] });
1032
                            }
1033
                        }
856 1034
                    }
857 1035
                }
858

  
859
                if (overEvts.length) {
860
                    YAHOO.log(dc.id+" onDragOver: " + overEvts + " (group: " + inGroups + ")", "info", "DragDropMgr");
861
                    if (dc) {
862
                        dc.b4DragOver(e, overEvts, inGroups);
863
                    }
864

  
865
                    if (dc) {
866
                        dc.onDragOver(e, overEvts, inGroups);
867
                    }
868
                }
869

  
870
                if (dropEvts.length) {
871
                    YAHOO.log(dc.id+" onDragDrop: " + dropEvts + " (group: " + inGroups + ")", "info", "DragDropMgr");
872
                    if (dc) {
873
                        dc.b4DragDrop(e, dropEvts, inGroups);
874
                    }
875
                    if (dc) {
876
                        dc.onDragDrop(e, dropEvts, inGroups);
877
                    }
878
                }
879

  
880
            } else {
881
                // fire dragout events
882
                var len = 0;
883
                for (i=0, len=outEvts.length; i<len; ++i) {
884
                    YAHOO.log(dc.id+" onDragOut: " + outEvts[i].id, "info", "DragDropMgr");
885
                    if (dc) {
886
                        dc.b4DragOut(e, outEvts[i].id, inGroups[0]);
887
                    }
888
                    if (dc) {
889
                        dc.onDragOut(e, outEvts[i].id, inGroups[0]);
890
                    }
891
                }
892
                 
893
                // fire enter events
894
                for (i=0,len=enterEvts.length; i<len; ++i) {
895
                    YAHOO.log(dc.id + " onDragEnter " + enterEvts[i].id + " (group: " + inGroups + ")", "info", "DragDropMgr");
896
                    // dc.b4DragEnter(e, oDD.id);
897

  
898
                    if (dc) {
899
                        dc.onDragEnter(e, enterEvts[i].id, inGroups[0]);
900
                    }
901
                }
902
         
903
                // fire over events
904
                for (i=0,len=overEvts.length; i<len; ++i) {
905
                    YAHOO.log(dc.id + " onDragOver " + overEvts[i].id + " (group: " + inGroups + ")", "info", "DragDropMgr");
906
                    if (dc) {
907
                        dc.b4DragOver(e, overEvts[i].id, inGroups[0]);
908
                    }
909
                    if (dc) {
910
                        dc.onDragOver(e, overEvts[i].id, inGroups[0]);
911
                    }
912
                }
913

  
914
                // fire drop events
915
                for (i=0, len=dropEvts.length; i<len; ++i) {
916
                    YAHOO.log(dc.id + " dropped on " + dropEvts[i].id + " (group: " + inGroups + ")", "info", "DragDropMgr");
917
                    if (dc) {
918
                        dc.b4DragDrop(e, dropEvts[i].id, inGroups[0]);
919
                    }
920
                    if (dc) {
921
                        dc.onDragDrop(e, dropEvts[i].id, inGroups[0]);
922
                    }
923
                }
924

  
925 1036
            }
926 1037
        },
927 1038

  
......
1124 1235

  
1125 1236
            oTarget.overlap = null;
1126 1237

  
1238

  
1127 1239
            // Get the current location of the drag element, this is the
1128 1240
            // location of the mouse event less the delta that represents
1129 1241
            // where the original mousedown happened on the element.  We
......
1531 1643
};
1532 1644

  
1533 1645
YAHOO.util.DragDrop.prototype = {
1534

  
1535 1646
    /**
1647
     * 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
1648
     * By setting any of these to false, then event will not be fired.
1649
     * @property events
1650
     * @type object
1651
     */
1652
    events: null,
1653
    /**
1654
    * @method on
1655
    * @description Shortcut for EventProvider.subscribe, see <a href="YAHOO.util.EventProvider.html#subscribe">YAHOO.util.EventProvider.subscribe</a>
1656
    */
1657
    on: function() {
1658
        this.subscribe.apply(this, arguments);
1659
    },
1660
    /**
1536 1661
     * The id of the element associated with this object.  This is what we 
1537 1662
     * refer to as the "linked element" because the size and position of 
1538 1663
     * this element is used to determine when the drag and drop objects have 
......
1664 1789
    dragOnly: false,
1665 1790

  
1666 1791
    /**
1792
     * 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.
1793
     * @property useShim
1794
     * @type Boolean
1795
     */
1796
    useShim: false,
1797

  
1798
    /**
1667 1799
     * Cached reference to the linked element
1668 1800
     * @property _domRef
1669 1801
     * @private
......
2008 2140
        this.initTarget(id, sGroup, config);
2009 2141
        Event.on(this._domRef || this.id, "mousedown", 
2010 2142
                        this.handleMouseDown, this, true);
2143

  
2011 2144
        // Event.on(this.id, "selectstart", Event.preventDefault);
2145
        for (var i in this.events) {
2146
            this.createEvent(i + 'Event');
2147
        }
2148
        
2012 2149
    },
2013 2150

  
2014 2151
    /**
......
2024 2161
        // configuration attributes 
2025 2162
        this.config = config || {};
2026 2163

  
2164
        this.events = {};
2165

  
2027 2166
        // create a local reference to the drag and drop manager
2028 2167
        this.DDM = YAHOO.util.DDM;
2029 2168

  
......
2075 2214
     * @method applyConfig
2076 2215
     */
2077 2216
    applyConfig: function() {
2217
        this.events = {
2218
            mouseDown: true,
2219
            b4MouseDown: true,
2220
            mouseUp: true,
2221
            b4StartDrag: true,
2222
            startDrag: true,
2223
            b4EndDrag: true,
2224
            endDrag: true,
2225
            drag: true,
2226
            b4Drag: true,
2227
            invalidDrop: true,
2228
            b4DragOut: true,
2229
            dragOut: true,
2230
            dragEnter: true,
2231
            b4DragOver: true,
2232
            dragOver: true,
2233
            b4DragDrop: true,
2234
            dragDrop: true
2235
        };
2236
        
2237
        if (this.config.events) {
2238
            for (var i in this.config.events) {
2239
                if (this.config.events[i] === false) {
2240
                    this.events[i] = false;
2241
                }
2242
            }
2243
        }
2078 2244

  
2245

  
2079 2246
        // configurable properties: 
2080 2247
        //    padding, isTarget, maintainOffset, primaryButtonOnly
2081 2248
        this.padding           = this.config.padding || [0, 0, 0, 0];
......
2083 2250
        this.maintainOffset    = (this.config.maintainOffset);
2084 2251
        this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
2085 2252
        this.dragOnly = ((this.config.dragOnly === true) ? true : false);
2253
        this.useShim = ((this.config.useShim === true) ? true : false);
2086 2254
    },
2087 2255

  
2088 2256
    /**
......
2131 2299
        var el = this.getEl();
2132 2300

  
2133 2301
        if (!this.DDM.verifyEl(el)) {
2134
            this.logger.log(this.id + " element is broken");
2302
            if (el && el.style && (el.style.display == 'none')) {
2303
                this.logger.log(this.id + " can not get initial position, element style is display: none");
2304
            } else {
2305
                this.logger.log(this.id + " element is broken");
2306
            }
2135 2307
            return;
2136 2308
        }
2137 2309

  
......
2294 2466
        this.logger.log("firing onMouseDown events");
2295 2467

  
2296 2468
        // firing the mousedown events prior to calculating positions
2297
        var b4Return = this.b4MouseDown(e);
2298
        var mDownReturn = this.onMouseDown(e);
2469
        var b4Return = this.b4MouseDown(e),
2470
        b4Return2 = true;
2299 2471

  
2300
        if ((b4Return === false) || (mDownReturn === false)) {
2472
        if (this.events.b4MouseDown) {
2473
            b4Return2 = this.fireEvent('b4MouseDownEvent', e);
2474
        }
2475
        var mDownReturn = this.onMouseDown(e),
2476
            mDownReturn2 = true;
2477
        if (this.events.mouseDown) {
2478
            mDownReturn2 = this.fireEvent('mouseDownEvent', e);
2479
        }
2480

  
2481
        if ((b4Return === false) || (mDownReturn === false) || (b4Return2 === false) || (mDownReturn2 === false)) {
2301 2482
            this.logger.log('b4MouseDown or onMouseDown returned false, exiting drag');
2302 2483
            return;
2303 2484
        }
......
2342 2523
     * @description Method validates that the clicked element
2343 2524
     * was indeed the handle or a valid child of the handle
2344 2525
     * @param {Event} e 
2345
     * @private
2346 2526
     */
2347 2527
    clickValidator: function(e) {
2348
        var target = Event.getTarget(e);
2528
        var target = YAHOO.util.Event.getTarget(e);
2349 2529
        return ( this.isValidHandleChild(target) &&
2350 2530
                    (this.id == this.handleElId || 
2351 2531
                        this.DDM.handleWasClicked(target, this.id)) );
......
2711 2891
    }
2712 2892

  
2713 2893
};
2894
YAHOO.augment(YAHOO.util.DragDrop, YAHOO.util.EventProvider);
2714 2895

  
2896
/**
2897
* @event mouseDownEvent
2898
* @description Provides access to the mousedown event. The mousedown does not always result in a drag operation.
2899
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2900
*/
2901

  
2902
/**
2903
* @event b4MouseDownEvent
2904
* @description Provides access to the mousedown event, before the mouseDownEvent gets fired. Returning false will cancel the drag.
2905
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2906
*/
2907

  
2908
/**
2909
* @event mouseUpEvent
2910
* @description Fired from inside DragDropMgr when the drag operation is finished.
2911
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2912
*/
2913

  
2914
/**
2915
* @event b4StartDragEvent
2916
* @description Fires before the startDragEvent, returning false will cancel the startDrag Event.
2917
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2918
*/
2919

  
2920
/**
2921
* @event startDragEvent
2922
* @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. 
2923
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2924
*/
2925

  
2926
/**
2927
* @event b4EndDragEvent
2928
* @description Fires before the endDragEvent. Returning false will cancel.
2929
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2930
*/
2931

  
2932
/**
2933
* @event endDragEvent
2934
* @description Fires on the mouseup event after a drag has been initiated (startDrag fired).
2935
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2936
*/
2937

  
2938
/**
2939
* @event dragEvent
2940
* @description Occurs every mousemove event while dragging.
2941
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2942
*/
2943
/**
2944
* @event b4DragEvent
2945
* @description Fires before the dragEvent.
2946
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2947
*/
2948
/**
2949
* @event invalidDropEvent
2950
* @description Fires when the dragged objects is dropped in a location that contains no drop targets.
2951
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2952
*/
2953
/**
2954
* @event b4DragOutEvent
2955
* @description Fires before the dragOutEvent
2956
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2957
*/
2958
/**
2959
* @event dragOutEvent
2960
* @description Fires when a dragged object is no longer over an object that had the onDragEnter fire. 
2961
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2962
*/
2963
/**
2964
* @event dragEnterEvent
2965
* @description Occurs when the dragged object first interacts with another targettable drag and drop object.
2966
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2967
*/
2968
/**
2969
* @event b4DragOverEvent
2970
* @description Fires before the dragOverEvent.
2971
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2972
*/
2973
/**
2974
* @event dragOverEvent
2975
* @description Fires every mousemove event while over a drag and drop object.
2976
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2977
*/
2978
/**
2979
* @event b4DragDropEvent 
2980
* @description Fires before the dragDropEvent
2981
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2982
*/
2983
/**
2984
* @event dragDropEvent
2985
* @description Fires when the dragged objects is dropped on another.
2986
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
2987
*/
2715 2988
})();
2716 2989
/**
2717 2990
 * A DragDrop implementation where the linked element follows the 
......
2735 3008

  
2736 3009
    /**
2737 3010
     * When set to true, the utility automatically tries to scroll the browser
2738
     * window wehn a drag and drop element is dragged near the viewport boundary.
3011
     * window when a drag and drop element is dragged near the viewport boundary.
2739 3012
     * Defaults to true.
2740 3013
     * @property scroll
2741 3014
     * @type boolean
......
2804 3077
        if (!this.deltaSetXY) {
2805 3078
            var aCoord = [oCoord.x, oCoord.y];
2806 3079
            YAHOO.util.Dom.setXY(el, aCoord);
3080

  
2807 3081
            var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
2808 3082
            var newTop  = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
2809 3083

  
......
2811 3085
        } else {
2812 3086
            YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");
2813 3087
            YAHOO.util.Dom.setStyle(el, "top",  (oCoord.y + this.deltaSetXY[1]) + "px");
2814
            //el.style.left = (oCoord.x + this.deltaSetXY[0]) + "px";
2815
            //el.style.top = (oCoord.y + this.deltaSetXY[1]) + "px";
2816 3088
        }
2817 3089
        
2818 3090
        this.cachePosition(oCoord.x, oCoord.y);
2819
        //DAV
2820 3091
        var self = this;
2821 3092
        setTimeout(function() {
2822 3093
            self.autoScroll.call(self, oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
......
2991 3262

  
2992 3263
    */
2993 3264

  
3265
/**
3266
* @event mouseDownEvent
3267
* @description Provides access to the mousedown event. The mousedown does not always result in a drag operation.
3268
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3269
*/
3270

  
3271
/**
3272
* @event b4MouseDownEvent
3273
* @description Provides access to the mousedown event, before the mouseDownEvent gets fired. Returning false will cancel the drag.
3274
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3275
*/
3276

  
3277
/**
3278
* @event mouseUpEvent
3279
* @description Fired from inside DragDropMgr when the drag operation is finished.
3280
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3281
*/
3282

  
3283
/**
3284
* @event b4StartDragEvent
3285
* @description Fires before the startDragEvent, returning false will cancel the startDrag Event.
3286
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3287
*/
3288

  
3289
/**
3290
* @event startDragEvent
3291
* @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. 
3292
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3293
*/
3294

  
3295
/**
3296
* @event b4EndDragEvent
3297
* @description Fires before the endDragEvent. Returning false will cancel.
3298
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3299
*/
3300

  
3301
/**
3302
* @event endDragEvent
3303
* @description Fires on the mouseup event after a drag has been initiated (startDrag fired).
3304
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3305
*/
3306

  
3307
/**
3308
* @event dragEvent
3309
* @description Occurs every mousemove event while dragging.
3310
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3311
*/
3312
/**
3313
* @event b4DragEvent
3314
* @description Fires before the dragEvent.
3315
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3316
*/
3317
/**
3318
* @event invalidDropEvent
3319
* @description Fires when the dragged objects is dropped in a location that contains no drop targets.
3320
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3321
*/
3322
/**
3323
* @event b4DragOutEvent
3324
* @description Fires before the dragOutEvent
3325
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3326
*/
3327
/**
3328
* @event dragOutEvent
3329
* @description Fires when a dragged object is no longer over an object that had the onDragEnter fire. 
3330
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3331
*/
3332
/**
3333
* @event dragEnterEvent
3334
* @description Occurs when the dragged object first interacts with another targettable drag and drop object.
3335
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3336
*/
3337
/**
3338
* @event b4DragOverEvent
3339
* @description Fires before the dragOverEvent.
3340
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3341
*/
3342
/**
3343
* @event dragOverEvent
3344
* @description Fires every mousemove event while over a drag and drop object.
3345
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3346
*/
3347
/**
3348
* @event b4DragDropEvent 
3349
* @description Fires before the dragDropEvent
3350
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3351
*/
3352
/**
3353
* @event dragDropEvent
3354
* @description Fires when the dragged objects is dropped on another.
3355
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3356
*/
2994 3357
});
2995 3358
/**
2996 3359
 * A DragDrop implementation that inserts an empty, bordered div into
......
3223 3586
    toString: function() {
3224 3587
        return ("DDProxy " + this.id);
3225 3588
    }
3589
/**
3590
* @event mouseDownEvent
3591
* @description Provides access to the mousedown event. The mousedown does not always result in a drag operation.
3592
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3593
*/
3226 3594

  
3595
/**
3596
* @event b4MouseDownEvent
3597
* @description Provides access to the mousedown event, before the mouseDownEvent gets fired. Returning false will cancel the drag.
3598
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3599
*/
3600

  
3601
/**
3602
* @event mouseUpEvent
3603
* @description Fired from inside DragDropMgr when the drag operation is finished.
3604
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3605
*/
3606

  
3607
/**
3608
* @event b4StartDragEvent
3609
* @description Fires before the startDragEvent, returning false will cancel the startDrag Event.
3610
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3611
*/
3612

  
3613
/**
3614
* @event startDragEvent
3615
* @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. 
3616
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3617
*/
3618

  
3619
/**
3620
* @event b4EndDragEvent
3621
* @description Fires before the endDragEvent. Returning false will cancel.
3622
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3623
*/
3624

  
3625
/**
3626
* @event endDragEvent
3627
* @description Fires on the mouseup event after a drag has been initiated (startDrag fired).
3628
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3629
*/
3630

  
3631
/**
3632
* @event dragEvent
3633
* @description Occurs every mousemove event while dragging.
3634
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3635
*/
3636
/**
3637
* @event b4DragEvent
3638
* @description Fires before the dragEvent.
3639
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3640
*/
3641
/**
3642
* @event invalidDropEvent
3643
* @description Fires when the dragged objects is dropped in a location that contains no drop targets.
3644
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3645
*/
3646
/**
3647
* @event b4DragOutEvent
3648
* @description Fires before the dragOutEvent
3649
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3650
*/
3651
/**
3652
* @event dragOutEvent
3653
* @description Fires when a dragged object is no longer over an object that had the onDragEnter fire. 
3654
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3655
*/
3656
/**
3657
* @event dragEnterEvent
3658
* @description Occurs when the dragged object first interacts with another targettable drag and drop object.
3659
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3660
*/
3661
/**
3662
* @event b4DragOverEvent
3663
* @description Fires before the dragOverEvent.
3664
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3665
*/
3666
/**
3667
* @event dragOverEvent
3668
* @description Fires every mousemove event while over a drag and drop object.
3669
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3670
*/
3671
/**
3672
* @event b4DragDropEvent 
3673
* @description Fires before the dragDropEvent
3674
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3675
*/
3676
/**
3677
* @event dragDropEvent
3678
* @description Fires when the dragged objects is dropped on another.
3679
* @type YAHOO.util.CustomEvent See <a href="YAHOO.util.Element.html#addListener">Element.addListener</a> for more information on listening for this event.
3680
*/
3681

  
3227 3682
});
3228 3683
/**
3229 3684
 * A DragDrop implementation that does not move, but can be a drop 
......
3252 3707
        return ("DDTarget " + this.id);
3253 3708
    }
3254 3709
});
3255
YAHOO.register("dragdrop", YAHOO.util.DragDropMgr, {version: "2.4.1", build: "742"});
3710
YAHOO.register("dragdrop", YAHOO.util.DragDropMgr, {version: "2.8.0r4", build: "2449"});

Also available in: Unified diff