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

📄 dragdrop.js

📁 原名JSPackager
💻 JS
📖 第 1 页 / 共 2 页
字号:
dc.b4DragDrop(e, dropEvts[i].id);dc.onDragDrop(e, dropEvts[i].id);}}};this.getBestMatch = function (dds) {var winner = null;var len = dds.length;if (len == 1) {winner = dds[0];} else {for (var i = 0; i < len; ++i) {var dd = dds[i];if (dd.cursorIsOver) {winner = dd;break;} else {if (!winner || winner.overlap.getArea() < dd.overlap.getArea()) {winner = dd;}}}}return winner;};this.refreshCache = function (groups) {for (sGroup in groups) {if ("string" != typeof sGroup) {continue;}for (i in this.ids[sGroup]) {var oDD = this.ids[sGroup][i];if (this.isTypeOfDD(oDD)) {var loc = this.getLocation(oDD);if (loc) {this.locationCache[oDD.id] = loc;} else {delete this.locationCache[oDD.id];}}}}};this.verifyEl = function (el) {try {if (el) {var parent = el.offsetParent;if (parent) {return true;}}}catch (e) {}return false;};this.getLocation = function (oDD) {if (!this.isTypeOfDD(oDD)) {return null;}var el = oDD.getEl();var aPos = null;try {aPos = YAHOO.util.Dom.getXY(el);}catch (e) {}if (!aPos) {return null;}x1 = aPos[0];x2 = x1 + el.offsetWidth;y1 = aPos[1];y2 = y1 + el.offsetHeight;var t = y1 - oDD.padding[0];var r = x2 + oDD.padding[1];var b = y2 + oDD.padding[2];var l = x1 - oDD.padding[3];return new YAHOO.util.Region(t, r, b, l);};this.isOverTarget = function (pt, oTarget, intersect) {var loc = this.locationCache[oTarget.id];if (!loc || !this.useCache) {loc = this.getLocation(oTarget);this.locationCache[oTarget.id] = loc;}if (!loc) {return false;}oTarget.cursorIsOver = loc.contains(pt);var dc = this.dragCurrent;if (!dc || (!intersect && !dc.constrainX && !dc.constrainY)) {return oTarget.cursorIsOver;}oTarget.overlap = null;var pos = dc.getTargetCoord(pt.x, pt.y);var el = dc.getDragEl();var 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;}};this._onUnload = function (e, me) {this.unregAll();};this.unregAll = function () {if (this.dragCurrent) {this.stopDrag();this.dragCurrent = null;}this._execOnAll("unreg", []);for (i in this.elementCache) {delete this.elementCache[i];}this.elementCache = {};this.ids = {};};this.elementCache = {};this.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;};this.getElement = function (id) {return YAHOO.util.Dom.get(id);};this.getCss = function (id) {var el = YAHOO.util.Dom.get(id);return (el) ? el.style : null;};this.ElementWrapper = function (el) {this.el = el || null;this.id = this.el && el.id;this.css = this.el && el.style;};this.getPosX = function (el) {return YAHOO.util.Dom.getX(el);};this.getPosY = function (el) {return YAHOO.util.Dom.getY(el);};this.swapNode = function (n1, n2) {if (n1.swapNode) {n1.swapNode(n2);} else {var p = n2.parentNode;var s = n2.nextSibling;n1.parentNode.replaceChild(n2, n1);p.insertBefore(n1, s);}};this.getScroll = function () {var t, l;if (document.documentElement && document.documentElement.scrollTop) {t = document.documentElement.scrollTop;l = document.documentElement.scrollLeft;} else {if (document.body) {t = document.body.scrollTop;l = document.body.scrollLeft;}}return {top:t, left:l};};this.getStyle = function (el, styleProp) {return YAHOO.util.Dom.getStyle(el, styleProp);};this.getScrollTop = function () {return this.getScroll().top;};this.getScrollLeft = function () {return this.getScroll().left;};this.moveToEl = function (moveEl, targetEl) {var aCoord = YAHOO.util.Dom.getXY(targetEl);YAHOO.util.Dom.setXY(moveEl, aCoord);};this.getClientHeight = function () {return YAHOO.util.Dom.getClientHeight();};this.getClientWidth = function () {return YAHOO.util.Dom.getClientWidth();};this.numericSort = function (a, b) {return (a - b);};this._timeoutCount = 0;this._addListeners = function () {if (YAHOO.util.Event && document) {this._onLoad();} else {if (this._timeoutCount > 1000) {} else {var DDM = YAHOO.util.DDM;setTimeout(function () {DDM._addListeners();}, 10);if (document && document.body) {this._timeoutCount += 1;}}}};this.handleWasClicked = function (node, id) {if (this.isHandle(id, node.id)) {return true;} else {var p = node.parentNode;while (p) {if (this.isHandle(id, p.id)) {return true;} else {p = p.parentNode;}}}return false;};}();YAHOO.util.DDM = YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();}YAHOO.util.DD = function (id, sGroup, config) {if (id) {this.init(id, sGroup, config);}};YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop);YAHOO.util.DD.prototype.scroll = true;YAHOO.util.DD.prototype.autoOffset = function (iPageX, iPageY) {var x = iPageX - this.startPageX;var y = iPageY - this.startPageY;this.setDelta(x, y);};YAHOO.util.DD.prototype.setDelta = function (iDeltaX, iDeltaY) {this.deltaX = iDeltaX;this.deltaY = iDeltaY;};YAHOO.util.DD.prototype.setDragElPos = function (iPageX, iPageY) {var el = this.getDragEl();this.alignElWithMouse(el, iPageX, iPageY);};YAHOO.util.DD.prototype.alignElWithMouse = function (el, iPageX, iPageY) {var oCoord = this.getTargetCoord(iPageX, iPageY);if (!this.deltaSetXY) {var aCoord = [oCoord.x, oCoord.y];YAHOO.util.Dom.setXY(el, aCoord);var newLeft = parseInt(YAHOO.util.Dom.getStyle(el, "left"), 10);var newTop = parseInt(YAHOO.util.Dom.getStyle(el, "top"), 10);this.deltaSetXY = [newLeft - oCoord.x, newTop - oCoord.y];} else {YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px");}this.cachePosition(oCoord.x, oCoord.y);this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);};YAHOO.util.DD.prototype.cachePosition = function (iPageX, iPageY) {if (iPageX) {this.lastPageX = iPageX;this.lastPageY = iPageY;} else {var aCoord = YAHOO.util.Dom.getXY(this.getEl());this.lastPageX = aCoord[0];this.lastPageY = aCoord[1];}};YAHOO.util.DD.prototype.autoScroll = function (x, y, h, w) {if (this.scroll) {var clientH = this.DDM.getClientHeight();var clientW = this.DDM.getClientWidth();var st = this.DDM.getScrollTop();var sl = this.DDM.getScrollLeft();var bot = h + y;var right = w + x;var toBot = (clientH + st - y - this.deltaY);var toRight = (clientW + sl - x - this.deltaX);var thresh = 40;var scrAmt = (document.all) ? 80 : 30;if (bot > clientH && toBot < thresh) {window.scrollTo(sl, st + scrAmt);}if (y < st && st > 0 && y - st < thresh) {window.scrollTo(sl, st - scrAmt);}if (right > clientW && toRight < thresh) {window.scrollTo(sl + scrAmt, st);}if (x < sl && sl > 0 && x - sl < thresh) {window.scrollTo(sl - scrAmt, st);}}};YAHOO.util.DD.prototype.getTargetCoord = function (iPageX, iPageY) {var x = iPageX - this.deltaX;var y = iPageY - this.deltaY;if (this.constrainX) {if (x < this.minX) {x = this.minX;}if (x > this.maxX) {x = this.maxX;}}if (this.constrainY) {if (y < this.minY) {y = this.minY;}if (y > this.maxY) {y = this.maxY;}}x = this.getTick(x, this.xTicks);y = this.getTick(y, this.yTicks);return {x:x, y:y};};YAHOO.util.DD.prototype.applyConfig = function () {YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll = (this.config.scroll !== false);};YAHOO.util.DD.prototype.b4MouseDown = function (e) {this.autoOffset(YAHOO.util.Event.getPageX(e), YAHOO.util.Event.getPageY(e));};YAHOO.util.DD.prototype.b4Drag = function (e) {this.setDragElPos(YAHOO.util.Event.getPageX(e), YAHOO.util.Event.getPageY(e));};YAHOO.util.DD.prototype.toString = function () {return ("DD " + this.id);};YAHOO.util.DDProxy = function (id, sGroup, config) {if (id) {this.init(id, sGroup, config);this.initFrame();}};YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD);YAHOO.util.DDProxy.dragElId = "ygddfdiv";YAHOO.util.DDProxy.prototype.resizeFrame = true;YAHOO.util.DDProxy.prototype.centerFrame = false;YAHOO.util.DDProxy.prototype.createFrame = function () {var self = this;var body = document.body;if (!body || !body.firstChild) {setTimeout(function () {self.createFrame();}, 50);return;}var div = this.getDragEl();if (!div) {div = document.createElement("div");div.id = this.dragElId;var s = div.style;s.position = "absolute";s.visibility = "hidden";s.cursor = "move";s.border = "2px solid #aaa";s.zIndex = 999;body.insertBefore(div, body.firstChild);}};YAHOO.util.DDProxy.prototype.initFrame = function () {this.createFrame();};YAHOO.util.DDProxy.prototype.applyConfig = function () {YAHOO.util.DDProxy.superclass.applyConfig.call(this);this.resizeFrame = (this.config.resizeFrame !== false);this.centerFrame = (this.config.centerFrame);this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId);};YAHOO.util.DDProxy.prototype.showFrame = function (iPageX, iPageY) {var el = this.getEl();var dragEl = this.getDragEl();var s = dragEl.style;this._resizeProxy();if (this.centerFrame) {this.setDelta(Math.round(parseInt(s.width, 10) / 2), Math.round(parseInt(s.height, 10) / 2));}this.setDragElPos(iPageX, iPageY);YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible");};YAHOO.util.DDProxy.prototype._resizeProxy = function () {var DOM = YAHOO.util.Dom;var el = this.getEl();var dragEl = this.getDragEl();if (this.resizeFrame) {var bt = parseInt(DOM.getStyle(dragEl, "borderTopWidth"), 10);var br = parseInt(DOM.getStyle(dragEl, "borderRightWidth"), 10);var bb = parseInt(DOM.getStyle(dragEl, "borderBottomWidth"), 10);var bl = parseInt(DOM.getStyle(dragEl, "borderLeftWidth"), 10);if (isNaN(bt)) {bt = 0;}if (isNaN(br)) {br = 0;}if (isNaN(bb)) {bb = 0;}if (isNaN(bl)) {bl = 0;}var newWidth = el.offsetWidth - br - bl;var newHeight = el.offsetHeight - bt - bb;DOM.setStyle(dragEl, "width", newWidth + "px");DOM.setStyle(dragEl, "height", newHeight + "px");}};YAHOO.util.DDProxy.prototype.b4MouseDown = function (e) {var x = YAHOO.util.Event.getPageX(e);var y = YAHOO.util.Event.getPageY(e);this.autoOffset(x, y);this.setDragElPos(x, y);};YAHOO.util.DDProxy.prototype.b4StartDrag = function (x, y) {this.showFrame(x, y);};YAHOO.util.DDProxy.prototype.b4EndDrag = function (e) {YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden");};YAHOO.util.DDProxy.prototype.endDrag = function (e) {var DOM = YAHOO.util.Dom;var lel = this.getEl();var del = this.getDragEl();DOM.setStyle(del, "visibility", "");DOM.setStyle(lel, "visibility", "hidden");YAHOO.util.DDM.moveToEl(lel, del);DOM.setStyle(del, "visibility", "hidden");DOM.setStyle(lel, "visibility", "");};YAHOO.util.DDProxy.prototype.toString = function () {return ("DDProxy " + this.id);};YAHOO.util.DDTarget = function (id, sGroup, config) {if (id) {this.initTarget(id, sGroup, config);}};YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop);YAHOO.util.DDTarget.prototype.toString = function () {return ("DDTarget " + this.id);};

⌨️ 快捷键说明

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