⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dragdrop-debug.js

📁 这是YUI的源码及相关示例。里面有很多很炫的Javascript效果。
💻 JS
📖 第 1 页 / 共 5 页
字号:
                YAHOO.log("getXY failed", "info", "DragDropMgr");                return null;            }            x1 = pos[0];            x2 = x1 + el.offsetWidth;            y1 = pos[1];            y2 = y1 + el.offsetHeight;            t = y1 - oDD.padding[0];            r = x2 + oDD.padding[1];            b = y2 + oDD.padding[2];            l = x1 - oDD.padding[3];            return new YAHOO.util.Region( t, r, b, l );        },        /**         * Checks the cursor location to see if it over the target         * @method isOverTarget         * @param {YAHOO.util.Point} pt The point to evaluate         * @param {DragDrop} oTarget the DragDrop object we are inspecting         * @param {boolean} intersect true if we are in intersect mode         * @param {YAHOO.util.Region} pre-cached location of the dragged element         * @return {boolean} true if the mouse is over the target         * @private         * @static         */        isOverTarget: function(pt, oTarget, intersect, curRegion) {            // use cache if available            var loc = this.locationCache[oTarget.id];            if (!loc || !this.useCache) {                YAHOO.log("cache not populated", "info", "DragDropMgr");                loc = this.getLocation(oTarget);                this.locationCache[oTarget.id] = loc;                YAHOO.log("cache: " + loc, "info", "DragDropMgr");            }            if (!loc) {                YAHOO.log("could not get the location of the element", "info", "DragDropMgr");                return false;            }            //YAHOO.log("loc: " + loc + ", pt: " + pt);            oTarget.cursorIsOver = loc.contains( pt );            // DragDrop is using this as a sanity check for the initial mousedown            // in this case we are done.  In POINT mode, if the drag obj has no            // contraints, we are done. Otherwise we need to evaluate the             // region the target as occupies to determine if the dragged element            // overlaps with it.                        var dc = this.dragCurrent;            if (!dc || (!intersect && !dc.constrainX && !dc.constrainY)) {                //if (oTarget.cursorIsOver) {                    //YAHOO.log("over " + oTarget + ", " + loc + ", " + pt, "warn");                //}                return oTarget.cursorIsOver;            }            oTarget.overlap = null;            // Get the current location of the drag element, this is the            // location of the mouse event less the delta that represents            // where the original mousedown happened on the element.  We            // need to consider constraints and ticks as well.            if (!curRegion) {                var pos = dc.getTargetCoord(pt.x, pt.y);                var el = dc.getDragEl();                curRegion = new YAHOO.util.Region( pos.y,                                                    pos.x + el.offsetWidth,                                                   pos.y + el.offsetHeight,                                                    pos.x );            }            var overlap = curRegion.intersect(loc);            if (overlap) {                oTarget.overlap = overlap;                return (intersect) ? true : oTarget.cursorIsOver;            } else {                return false;            }        },        /**         * unload event handler         * @method _onUnload         * @private         * @static         */        _onUnload: function(e, me) {            this.unregAll();        },        /**         * Cleans up the drag and drop events and objects.         * @method unregAll         * @private         * @static         */        unregAll: function() {            YAHOO.log("unregister all", "info", "DragDropMgr");            if (this.dragCurrent) {                this.stopDrag();                this.dragCurrent = null;            }            this._execOnAll("unreg", []);            //for (var i in this.elementCache) {                //delete this.elementCache[i];            //}            //this.elementCache = {};            this.ids = {};        },        /**         * A cache of DOM elements         * @property elementCache         * @private         * @static         * @deprecated elements are not cached now         */        elementCache: {},                /**         * Get the wrapper for the DOM element specified         * @method getElWrapper         * @param {String} id the id of the element to get         * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element         * @private         * @deprecated This wrapper isn't that useful         * @static         */        getElWrapper: function(id) {            var oWrapper = this.elementCache[id];            if (!oWrapper || !oWrapper.el) {                oWrapper = this.elementCache[id] =                     new this.ElementWrapper(YAHOO.util.Dom.get(id));            }            return oWrapper;        },        /**         * Returns the actual DOM element         * @method getElement         * @param {String} id the id of the elment to get         * @return {Object} The element         * @deprecated use YAHOO.util.Dom.get instead         * @static         */        getElement: function(id) {            return YAHOO.util.Dom.get(id);        },                /**         * Returns the style property for the DOM element (i.e.,          * document.getElById(id).style)         * @method getCss         * @param {String} id the id of the elment to get         * @return {Object} The style property of the element         * @deprecated use YAHOO.util.Dom instead         * @static         */        getCss: function(id) {            var el = YAHOO.util.Dom.get(id);            return (el) ? el.style : null;        },        /**         * Inner class for cached elements         * @class DragDropMgr.ElementWrapper         * @for DragDropMgr         * @private         * @deprecated         */        ElementWrapper: function(el) {                /**                 * The element                 * @property el                 */                this.el = el || null;                /**                 * The element id                 * @property id                 */                this.id = this.el && el.id;                /**                 * A reference to the style property                 * @property css                 */                this.css = this.el && el.style;            },        /**         * Returns the X position of an html element         * @method getPosX         * @param el the element for which to get the position         * @return {int} the X coordinate         * @for DragDropMgr         * @deprecated use YAHOO.util.Dom.getX instead         * @static         */        getPosX: function(el) {            return YAHOO.util.Dom.getX(el);        },        /**         * Returns the Y position of an html element         * @method getPosY         * @param el the element for which to get the position         * @return {int} the Y coordinate         * @deprecated use YAHOO.util.Dom.getY instead         * @static         */        getPosY: function(el) {            return YAHOO.util.Dom.getY(el);         },        /**         * Swap two nodes.  In IE, we use the native method, for others we          * emulate the IE behavior         * @method swapNode         * @param n1 the first node to swap         * @param n2 the other node to swap         * @static         */        swapNode: function(n1, n2) {            if (n1.swapNode) {                n1.swapNode(n2);            } else {                var p = n2.parentNode;                var s = n2.nextSibling;                if (s == n1) {                    p.insertBefore(n1, n2);                } else if (n2 == n1.nextSibling) {                    p.insertBefore(n2, n1);                } else {                    n1.parentNode.replaceChild(n2, n1);                    p.insertBefore(n1, s);                }            }        },        /**         * Returns the current scroll position         * @method getScroll         * @private         * @static         */        getScroll: function () {            var t, l, dde=document.documentElement, db=document.body;            if (dde && (dde.scrollTop || dde.scrollLeft)) {                t = dde.scrollTop;                l = dde.scrollLeft;            } else if (db) {                t = db.scrollTop;                l = db.scrollLeft;            } else {                YAHOO.log("could not get scroll property", "info", "DragDropMgr");            }            return { top: t, left: l };        },        /**         * Returns the specified element style property         * @method getStyle         * @param {HTMLElement} el          the element         * @param {string}      styleProp   the style property         * @return {string} The value of the style property         * @deprecated use YAHOO.util.Dom.getStyle         * @static         */        getStyle: function(el, styleProp) {            return YAHOO.util.Dom.getStyle(el, styleProp);        },        /**         * Gets the scrollTop         * @method getScrollTop         * @return {int} the document's scrollTop         * @static         */        getScrollTop: function () { return this.getScroll().top; },        /**         * Gets the scrollLeft         * @method getScrollLeft         * @return {int} the document's scrollTop         * @static         */        getScrollLeft: function () { return this.getScroll().left; },        /**         * Sets the x/y position of an element to the location of the         * target element.         * @method moveToEl         * @param {HTMLElement} moveEl      The element to move         * @param {HTMLElement} targetEl    The position reference element         * @static         */        moveToEl: function (moveEl, targetEl) {            var aCoord = YAHOO.util.Dom.getXY(targetEl);            YAHOO.log("moveToEl: " + aCoord, "info", "DragDropMgr");            YAHOO.util.Dom.setXY(moveEl, aCoord);        },        /**         * Gets the client height         * @method getClientHeight         * @return {int} client height in px         * @deprecated use YAHOO.util.Dom.getViewportHeight instead         * @static         */        getClientHeight: function() {            return YAHOO.util.Dom.getViewportHeight();        },        /**         * Gets the client width         * @method getClientWidth         * @return {int} client width in px         * @deprecated use YAHOO.util.Dom.getViewportWidth instead         * @static         */        getClientWidth: function() {            return YAHOO.util.Dom.getViewportWidth();        },        /**         * Numeric array sort function         * @method numericSort         * @static         */        numericSort: function(a, b) { return (a - b); },        /**         * Internal counter         * @property _timeoutCount         * @private         * @static         */        _timeoutCount: 0,        /**         * Trying to make the load order less important.  Without this we get         * an error if this file is loaded before the Event Utility.         * @method _addListeners         * @private         * @static         */        _addListeners: function() {            var DDM = YAHOO.util.DDM;            if ( YAHOO.util.Event && document ) {                DDM._onLoad();            } else {                if (DDM._timeoutCount > 2000) {                    YAHOO.log("DragDrop requires the Event Utility", "error", "DragDropMgr");                } else {                    setTimeout(DDM._addListeners, 10);                    if (document && document.body) {                        DDM._timeoutCount += 1;                    }                }            }        },        /**         * Recursively searches the immediate parent and all child nodes for          * the handle element in order to determine wheter or not it was          * clicked.         * @method handleWasClicked         * @param node the html element to inspect         * @static         */        handleWasClicked: function(node, id) {            if (this.isHandle(id, node.id)) {                YAHOO.log("clicked node is a handle", "info", "DragDropMgr");                return true;            } else {                // check to see if this is a text node child of the one we want                var p = node.parentNode;                // YAHOO.log("p: " + p);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -