ext-all-debug.js
资源名称:demo.zip [点击查看]
上传用户:chliyg
上传日期:2016-05-15
资源大小:3196k
文件大小:951k
源码类别:
Jsp/Servlet
开发平台:
Java
- this.DDM.refreshCache(this.groups);
- var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
- if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
- } else {
- if (this.clickValidator(e)) {
- this.setStartPosition();
- this.b4MouseDown(e);
- this.onMouseDown(e);
- this.DDM.handleMouseDown(e, this);
- this.DDM.stopEvent(e);
- } else {
- }
- }
- },
- clickValidator: function(e) {
- var target = e.getTarget();
- return ( this.isValidHandleChild(target) &&
- (this.id == this.handleElId ||
- this.DDM.handleWasClicked(target, this.id)) );
- },
- addInvalidHandleType: function(tagName) {
- var type = tagName.toUpperCase();
- this.invalidHandleTypes[type] = type;
- },
- addInvalidHandleId: function(id) {
- if (typeof id !== "string") {
- id = Ext.id(id);
- }
- this.invalidHandleIds[id] = id;
- },
- addInvalidHandleClass: function(cssClass) {
- this.invalidHandleClasses.push(cssClass);
- },
- removeInvalidHandleType: function(tagName) {
- var type = tagName.toUpperCase();
- delete this.invalidHandleTypes[type];
- },
- removeInvalidHandleId: function(id) {
- if (typeof id !== "string") {
- id = Ext.id(id);
- }
- delete this.invalidHandleIds[id];
- },
- removeInvalidHandleClass: function(cssClass) {
- for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
- if (this.invalidHandleClasses[i] == cssClass) {
- delete this.invalidHandleClasses[i];
- }
- }
- },
- isValidHandleChild: function(node) {
- var valid = true;
- var nodeName;
- try {
- nodeName = node.nodeName.toUpperCase();
- } catch(e) {
- nodeName = node.nodeName;
- }
- valid = valid && !this.invalidHandleTypes[nodeName];
- valid = valid && !this.invalidHandleIds[node.id];
- for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
- valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
- }
- return valid;
- },
- setXTicks: function(iStartX, iTickSize) {
- this.xTicks = [];
- this.xTickSize = iTickSize;
- var tickMap = {};
- for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
- if (!tickMap[i]) {
- this.xTicks[this.xTicks.length] = i;
- tickMap[i] = true;
- }
- }
- for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
- if (!tickMap[i]) {
- this.xTicks[this.xTicks.length] = i;
- tickMap[i] = true;
- }
- }
- this.xTicks.sort(this.DDM.numericSort) ;
- },
- setYTicks: function(iStartY, iTickSize) {
- this.yTicks = [];
- this.yTickSize = iTickSize;
- var tickMap = {};
- for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
- if (!tickMap[i]) {
- this.yTicks[this.yTicks.length] = i;
- tickMap[i] = true;
- }
- }
- for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
- if (!tickMap[i]) {
- this.yTicks[this.yTicks.length] = i;
- tickMap[i] = true;
- }
- }
- this.yTicks.sort(this.DDM.numericSort) ;
- },
- setXConstraint: function(iLeft, iRight, iTickSize) {
- this.leftConstraint = iLeft;
- this.rightConstraint = iRight;
- this.minX = this.initPageX - iLeft;
- this.maxX = this.initPageX + iRight;
- if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
- this.constrainX = true;
- },
- clearConstraints: function() {
- this.constrainX = false;
- this.constrainY = false;
- this.clearTicks();
- },
- clearTicks: function() {
- this.xTicks = null;
- this.yTicks = null;
- this.xTickSize = 0;
- this.yTickSize = 0;
- },
- setYConstraint: function(iUp, iDown, iTickSize) {
- this.topConstraint = iUp;
- this.bottomConstraint = iDown;
- this.minY = this.initPageY - iUp;
- this.maxY = this.initPageY + iDown;
- if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
- this.constrainY = true;
- },
- resetConstraints: function() {
- if (this.initPageX || this.initPageX === 0) {
- var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
- var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
- this.setInitPosition(dx, dy);
- } else {
- this.setInitPosition();
- }
- if (this.constrainX) {
- this.setXConstraint( this.leftConstraint,
- this.rightConstraint,
- this.xTickSize );
- }
- if (this.constrainY) {
- this.setYConstraint( this.topConstraint,
- this.bottomConstraint,
- this.yTickSize );
- }
- },
- getTick: function(val, tickArray) {
- if (!tickArray) {
- return val;
- } else if (tickArray[0] >= val) {
- return tickArray[0];
- } else {
- for (var i=0, len=tickArray.length; i<len; ++i) {
- var next = i + 1;
- if (tickArray[next] && tickArray[next] >= val) {
- var diff1 = val - tickArray[i];
- var diff2 = tickArray[next] - val;
- return (diff2 > diff1) ? tickArray[i] : tickArray[next];
- }
- }
- return tickArray[tickArray.length - 1];
- }
- },
- toString: function() {
- return ("DragDrop " + this.id);
- }
- };
- })();
- if (!Ext.dd.DragDropMgr) {
- Ext.dd.DragDropMgr = function() {
- var Event = Ext.EventManager;
- return {
- ids: {},
- handleIds: {},
- dragCurrent: null,
- dragOvers: {},
- deltaX: 0,
- deltaY: 0,
- preventDefault: true,
- stopPropagation: true,
- initialized: false,
- locked: false,
- init: function() {
- this.initialized = true;
- },
- POINT: 0,
- INTERSECT: 1,
- mode: 0,
- _execOnAll: function(sMethod, args) {
- for (var i in this.ids) {
- for (var j in this.ids[i]) {
- var oDD = this.ids[i][j];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
- oDD[sMethod].apply(oDD, args);
- }
- }
- },
- _onLoad: function() {
- this.init();
- Event.on(document, "mouseup", this.handleMouseUp, this, true);
- Event.on(document, "mousemove", this.handleMouseMove, this, true);
- Event.on(window, "unload", this._onUnload, this, true);
- Event.on(window, "resize", this._onResize, this, true);
- },
- _onResize: function(e) {
- this._execOnAll("resetConstraints", []);
- },
- lock: function() { this.locked = true; },
- unlock: function() { this.locked = false; },
- isLocked: function() { return this.locked; },
- locationCache: {},
- useCache: true,
- clickPixelThresh: 3,
- clickTimeThresh: 350,
- dragThreshMet: false,
- clickTimeout: null,
- startX: 0,
- startY: 0,
- regDragDrop: function(oDD, sGroup) {
- if (!this.initialized) { this.init(); }
- if (!this.ids[sGroup]) {
- this.ids[sGroup] = {};
- }
- this.ids[sGroup][oDD.id] = oDD;
- },
- removeDDFromGroup: function(oDD, sGroup) {
- if (!this.ids[sGroup]) {
- this.ids[sGroup] = {};
- }
- var obj = this.ids[sGroup];
- if (obj && obj[oDD.id]) {
- delete obj[oDD.id];
- }
- },
- _remove: function(oDD) {
- for (var g in oDD.groups) {
- if (g && this.ids[g][oDD.id]) {
- delete this.ids[g][oDD.id];
- }
- }
- delete this.handleIds[oDD.id];
- },
- regHandle: function(sDDId, sHandleId) {
- if (!this.handleIds[sDDId]) {
- this.handleIds[sDDId] = {};
- }
- this.handleIds[sDDId][sHandleId] = sHandleId;
- },
- isDragDrop: function(id) {
- return ( this.getDDById(id) ) ? true : false;
- },
- getRelated: function(p_oDD, bTargetsOnly) {
- var oDDs = [];
- for (var i in p_oDD.groups) {
- for (j in this.ids[i]) {
- var dd = this.ids[i][j];
- if (! this.isTypeOfDD(dd)) {
- continue;
- }
- if (!bTargetsOnly || dd.isTarget) {
- oDDs[oDDs.length] = dd;
- }
- }
- }
- return oDDs;
- },
- isLegalTarget: function (oDD, oTargetDD) {
- var targets = this.getRelated(oDD, true);
- for (var i=0, len=targets.length;i<len;++i) {
- if (targets[i].id == oTargetDD.id) {
- return true;
- }
- }
- return false;
- },
- isTypeOfDD: function (oDD) {
- return (oDD && oDD.__ygDragDrop);
- },
- isHandle: function(sDDId, sHandleId) {
- return ( this.handleIds[sDDId] &&
- this.handleIds[sDDId][sHandleId] );
- },
- getDDById: function(id) {
- for (var i in this.ids) {
- if (this.ids[i][id]) {
- return this.ids[i][id];
- }
- }
- return null;
- },
- handleMouseDown: function(e, oDD) {
- if(Ext.QuickTips){
- Ext.QuickTips.disable();
- }
- this.currentTarget = e.getTarget();
- this.dragCurrent = oDD;
- var el = oDD.getEl();
- this.startX = e.getPageX();
- this.startY = e.getPageY();
- this.deltaX = this.startX - el.offsetLeft;
- this.deltaY = this.startY - el.offsetTop;
- this.dragThreshMet = false;
- this.clickTimeout = setTimeout(
- function() {
- var DDM = Ext.dd.DDM;
- DDM.startDrag(DDM.startX, DDM.startY);
- },
- this.clickTimeThresh );
- },
- startDrag: function(x, y) {
- clearTimeout(this.clickTimeout);
- if (this.dragCurrent) {
- this.dragCurrent.b4StartDrag(x, y);
- this.dragCurrent.startDrag(x, y);
- }
- this.dragThreshMet = true;
- },
- handleMouseUp: function(e) {
- if(Ext.QuickTips){
- Ext.QuickTips.enable();
- }
- if (! this.dragCurrent) {
- return;
- }
- clearTimeout(this.clickTimeout);
- if (this.dragThreshMet) {
- this.fireEvents(e, true);
- } else {
- }
- this.stopDrag(e);
- this.stopEvent(e);
- },
- stopEvent: function(e){
- if(this.stopPropagation) {
- e.stopPropagation();
- }
- if (this.preventDefault) {
- e.preventDefault();
- }
- },
- stopDrag: function(e) {
- if (this.dragCurrent) {
- if (this.dragThreshMet) {
- this.dragCurrent.b4EndDrag(e);
- this.dragCurrent.endDrag(e);
- }
- this.dragCurrent.onMouseUp(e);
- }
- this.dragCurrent = null;
- this.dragOvers = {};
- },
- handleMouseMove: function(e) {
- if (! this.dragCurrent) {
- return true;
- }
- if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
- this.stopEvent(e);
- return this.handleMouseUp(e);
- }
- if (!this.dragThreshMet) {
- var diffX = Math.abs(this.startX - e.getPageX());
- var diffY = Math.abs(this.startY - e.getPageY());
- if (diffX > this.clickPixelThresh ||
- diffY > this.clickPixelThresh) {
- this.startDrag(this.startX, this.startY);
- }
- }
- if (this.dragThreshMet) {
- this.dragCurrent.b4Drag(e);
- this.dragCurrent.onDrag(e);
- if(!this.dragCurrent.moveOnly){
- this.fireEvents(e, false);
- }
- }
- this.stopEvent(e);
- return true;
- },
- fireEvents: function(e, isDrop) {
- var dc = this.dragCurrent;
- if (!dc || dc.isLocked()) {
- return;
- }
- var pt = e.getPoint();
- var oldOvers = [];
- var outEvts = [];
- var overEvts = [];
- var dropEvts = [];
- var enterEvts = [];
- for (var i in this.dragOvers) {
- var ddo = this.dragOvers[i];
- if (! this.isTypeOfDD(ddo)) {
- continue;
- }
- if (! this.isOverTarget(pt, ddo, this.mode)) {
- outEvts.push( ddo );
- }
- oldOvers[i] = true;
- delete this.dragOvers[i];
- }
- for (var sGroup in dc.groups) {
- if ("string" != typeof sGroup) {
- continue;
- }
- for (i in this.ids[sGroup]) {
- var oDD = this.ids[sGroup][i];
- if (! this.isTypeOfDD(oDD)) {
- continue;
- }
- if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
- if (this.isOverTarget(pt, oDD, this.mode)) {
- if (isDrop) {
- dropEvts.push( oDD );
- } else {
- if (!oldOvers[oDD.id]) {
- enterEvts.push( oDD );
- } else {
- overEvts.push( oDD );
- }
- this.dragOvers[oDD.id] = oDD;
- }
- }
- }
- }
- }
- if (this.mode) {
- if (outEvts.length) {
- dc.b4DragOut(e, outEvts);
- dc.onDragOut(e, outEvts);
- }
- if (enterEvts.length) {
- dc.onDragEnter(e, enterEvts);
- }
- if (overEvts.length) {
- dc.b4DragOver(e, overEvts);
- dc.onDragOver(e, overEvts);
- }
- if (dropEvts.length) {
- dc.b4DragDrop(e, dropEvts);
- dc.onDragDrop(e, dropEvts);
- }
- } else {
- var len = 0;
- for (i=0, len=outEvts.length; i<len; ++i) {
- dc.b4DragOut(e, outEvts[i].id);
- dc.onDragOut(e, outEvts[i].id);
- }
- for (i=0,len=enterEvts.length; i<len; ++i) {
- dc.onDragEnter(e, enterEvts[i].id);
- }
- for (i=0,len=overEvts.length; i<len; ++i) {
- dc.b4DragOver(e, overEvts[i].id);
- dc.onDragOver(e, overEvts[i].id);
- }
- for (i=0, len=dropEvts.length; i<len; ++i) {
- dc.b4DragDrop(e, dropEvts[i].id);
- dc.onDragDrop(e, dropEvts[i].id);
- }
- }
- if (isDrop && !dropEvts.length) {
- dc.onInvalidDrop(e);
- }
- },
- 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;
- },
- refreshCache: function(groups) {
- for (var sGroup in groups) {
- if ("string" != typeof sGroup) {
- continue;
- }
- for (var 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];
- }
- }
- }
- }
- },
- verifyEl: function(el) {
- if (el) {
- var parent;
- if(Ext.isIE){
- try{
- parent = el.offsetParent;
- }catch(e){}
- }else{
- parent = el.offsetParent;
- }
- if (parent) {
- return true;
- }
- }
- return false;
- },
- getLocation: function(oDD) {
- if (! this.isTypeOfDD(oDD)) {
- return null;
- }
- var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
- try {
- pos= Ext.lib.Dom.getXY(el);
- } catch (e) { }
- if (!pos) {
- 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 Ext.lib.Region( t, r, b, l );
- },
- 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 || !dc.getTargetCoord ||
- (!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 Ext.lib.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;
- }
- },
- _onUnload: function(e, me) {
- Ext.dd.DragDropMgr.unregAll();
- },
- unregAll: function() {
- 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 = {};
- },
- elementCache: {},
- getElWrapper: function(id) {
- var oWrapper = this.elementCache[id];
- if (!oWrapper || !oWrapper.el) {
- oWrapper = this.elementCache[id] =
- new this.ElementWrapper(Ext.getDom(id));
- }
- return oWrapper;
- },
- getElement: function(id) {
- return Ext.getDom(id);
- },
- getCss: function(id) {
- var el = Ext.getDom(id);
- return (el) ? el.style : null;
- },
- ElementWrapper: function(el) {
- this.el = el || null;
- this.id = this.el && el.id;
- this.css = this.el && el.style;
- },
- getPosX: function(el) {
- return Ext.lib.Dom.getX(el);
- },
- getPosY: function(el) {
- return Ext.lib.Dom.getY(el);
- },
- 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);
- }
- }
- },
- 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 {
- }
- return { top: t, left: l };
- },
- getStyle: function(el, styleProp) {
- return Ext.fly(el).getStyle(styleProp);
- },
- getScrollTop: function () { return this.getScroll().top; },
- getScrollLeft: function () { return this.getScroll().left; },
- moveToEl: function (moveEl, targetEl) {
- var aCoord = Ext.lib.Dom.getXY(targetEl);
- Ext.lib.Dom.setXY(moveEl, aCoord);
- },
- numericSort: function(a, b) { return (a - b); },
- _timeoutCount: 0,
- _addListeners: function() {
- var DDM = Ext.dd.DDM;
- if ( Ext.lib.Event && document ) {
- DDM._onLoad();
- } else {
- if (DDM._timeoutCount > 2000) {
- } else {
- setTimeout(DDM._addListeners, 10);
- if (document && document.body) {
- DDM._timeoutCount += 1;
- }
- }
- }
- },
- 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;
- }
- };
- }();
- Ext.dd.DDM = Ext.dd.DragDropMgr;
- Ext.dd.DDM._addListeners();
- }
- Ext.dd.DD = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- }
- };
- Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
- scroll: true,
- autoOffset: function(iPageX, iPageY) {
- var x = iPageX - this.startPageX;
- var y = iPageY - this.startPageY;
- this.setDelta(x, y);
- },
- setDelta: function(iDeltaX, iDeltaY) {
- this.deltaX = iDeltaX;
- this.deltaY = iDeltaY;
- },
- setDragElPos: function(iPageX, iPageY) {
- var el = this.getDragEl();
- this.alignElWithMouse(el, iPageX, iPageY);
- },
- alignElWithMouse: function(el, iPageX, iPageY) {
- var oCoord = this.getTargetCoord(iPageX, iPageY);
- var fly = el.dom ? el : Ext.fly(el, '_dd');
- if (!this.deltaSetXY) {
- var aCoord = [oCoord.x, oCoord.y];
- fly.setXY(aCoord);
- var newLeft = fly.getLeft(true);
- var newTop = fly.getTop(true);
- this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
- } else {
- fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
- }
- this.cachePosition(oCoord.x, oCoord.y);
- this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
- return oCoord;
- },
- cachePosition: function(iPageX, iPageY) {
- if (iPageX) {
- this.lastPageX = iPageX;
- this.lastPageY = iPageY;
- } else {
- var aCoord = Ext.lib.Dom.getXY(this.getEl());
- this.lastPageX = aCoord[0];
- this.lastPageY = aCoord[1];
- }
- },
- autoScroll: function(x, y, h, w) {
- if (this.scroll) {
- var clientH = Ext.lib.Dom.getViewHeight();
- var clientW = Ext.lib.Dom.getViewWidth();
- 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);
- }
- }
- },
- 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};
- },
- applyConfig: function() {
- Ext.dd.DD.superclass.applyConfig.call(this);
- this.scroll = (this.config.scroll !== false);
- },
- b4MouseDown: function(e) {
- this.autoOffset(e.getPageX(),
- e.getPageY());
- },
- b4Drag: function(e) {
- this.setDragElPos(e.getPageX(),
- e.getPageY());
- },
- toString: function() {
- return ("DD " + this.id);
- }
- });
- Ext.dd.DDProxy = function(id, sGroup, config) {
- if (id) {
- this.init(id, sGroup, config);
- this.initFrame();
- }
- };
- Ext.dd.DDProxy.dragElId = "ygddfdiv";
- Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
- resizeFrame: true,
- centerFrame: false,
- 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);
- }
- },
- initFrame: function() {
- this.createFrame();
- },
- applyConfig: function() {
- Ext.dd.DDProxy.superclass.applyConfig.call(this);
- this.resizeFrame = (this.config.resizeFrame !== false);
- this.centerFrame = (this.config.centerFrame);
- this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
- },
- 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);
- Ext.fly(dragEl).show();
- },
- _resizeProxy: function() {
- if (this.resizeFrame) {
- var el = this.getEl();
- Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
- }
- },
- b4MouseDown: function(e) {
- var x = e.getPageX();
- var y = e.getPageY();
- this.autoOffset(x, y);
- this.setDragElPos(x, y);
- },
- b4StartDrag: function(x, y) {
- this.showFrame(x, y);
- },
- b4EndDrag: function(e) {
- Ext.fly(this.getDragEl()).hide();
- },
- endDrag: function(e) {
- var lel = this.getEl();
- var del = this.getDragEl();
- del.style.visibility = "";
- this.beforeMove();
- lel.style.visibility = "hidden";
- Ext.dd.DDM.moveToEl(lel, del);
- del.style.visibility = "hidden";
- lel.style.visibility = "";
- this.afterDrag();
- },
- beforeMove : function(){
- },
- afterDrag : function(){
- },
- toString: function() {
- return ("DDProxy " + this.id);
- }
- });
- Ext.dd.DDTarget = function(id, sGroup, config) {
- if (id) {
- this.initTarget(id, sGroup, config);
- }
- };
- Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
- toString: function() {
- return ("DDTarget " + this.id);
- }
- });
- Ext.dd.DragTracker = function(config){
- Ext.apply(this, config);
- this.addEvents(
- 'mousedown',
- 'mouseup',
- 'mousemove',
- 'dragstart',
- 'dragend',
- 'drag'
- );
- this.dragRegion = new Ext.lib.Region(0,0,0,0);
- if(this.el){
- this.initEl(this.el);
- }
- }
- Ext.extend(Ext.dd.DragTracker, Ext.util.Observable, {
- active: false,
- tolerance: 5,
- autoStart: false,
- initEl: function(el){
- this.el = Ext.get(el);
- el.on('mousedown', this.onMouseDown, this,
- this.delegate ? {delegate: this.delegate} : undefined);
- },
- destroy : function(){
- this.el.un('mousedown', this.onMouseDown, this);
- },
- onMouseDown: function(e, target){
- if(this.fireEvent('mousedown', this, e) !== false && this.onBeforeStart(e) !== false){
- this.startXY = this.lastXY = e.getXY();
- this.dragTarget = this.delegate ? target : this.el.dom;
- e.preventDefault();
- var doc = Ext.getDoc();
- doc.on('mouseup', this.onMouseUp, this);
- doc.on('mousemove', this.onMouseMove, this);
- doc.on('selectstart', this.stopSelect, this);
- if(this.autoStart){
- this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this);
- }
- }
- },
- onMouseMove: function(e, target){
- e.preventDefault();
- var xy = e.getXY(), s = this.startXY;
- this.lastXY = xy;
- if(!this.active){
- if(Math.abs(s[0]-xy[0]) > this.tolerance || Math.abs(s[1]-xy[1]) > this.tolerance){
- this.triggerStart();
- }else{
- return;
- }
- }
- this.fireEvent('mousemove', this, e);
- this.onDrag(e);
- this.fireEvent('drag', this, e);
- },
- onMouseUp: function(e){
- var doc = Ext.getDoc();
- doc.un('mousemove', this.onMouseMove, this);
- doc.un('mouseup', this.onMouseUp, this);
- doc.un('selectstart', this.stopSelect, this);
- e.preventDefault();
- this.clearStart();
- this.active = false;
- delete this.elRegion;
- this.fireEvent('mouseup', this, e);
- this.onEnd(e);
- this.fireEvent('dragend', this, e);
- },
- triggerStart: function(isTimer){
- this.clearStart();
- this.active = true;
- this.onStart(this.startXY);
- this.fireEvent('dragstart', this, this.startXY);
- },
- clearStart : function(){
- if(this.timer){
- clearTimeout(this.timer);
- delete this.timer;
- }
- },
- stopSelect : function(e){
- e.stopEvent();
- return false;
- },
- onBeforeStart : function(e){
- },
- onStart : function(xy){
- },
- onDrag : function(e){
- },
- onEnd : function(e){
- },
- getDragTarget : function(){
- return this.dragTarget;
- },
- getDragCt : function(){
- return this.el;
- },
- getXY : function(constrain){
- return constrain ?
- this.constrainModes[constrain].call(this, this.lastXY) : this.lastXY;
- },
- getOffset : function(constrain){
- var xy = this.getXY(constrain);
- var s = this.startXY;
- return [s[0]-xy[0], s[1]-xy[1]];
- },
- constrainModes: {
- 'point' : function(xy){
- if(!this.elRegion){
- this.elRegion = this.getDragCt().getRegion();
- }
- var dr = this.dragRegion;
- dr.left = xy[0];
- dr.top = xy[1];
- dr.right = xy[0];
- dr.bottom = xy[1];
- dr.constrainTo(this.elRegion);
- return [dr.left, dr.top];
- }
- }
- });
- Ext.dd.ScrollManager = function(){
- var ddm = Ext.dd.DragDropMgr;
- var els = {};
- var dragEl = null;
- var proc = {};
- var onStop = function(e){
- dragEl = null;
- clearProc();
- };
- var triggerRefresh = function(){
- if(ddm.dragCurrent){
- ddm.refreshCache(ddm.dragCurrent.groups);
- }
- };
- var doScroll = function(){
- if(ddm.dragCurrent){
- var dds = Ext.dd.ScrollManager;
- var inc = proc.el.ddScrollConfig ?
- proc.el.ddScrollConfig.increment : dds.increment;
- if(!dds.animate){
- if(proc.el.scroll(proc.dir, inc)){
- triggerRefresh();
- }
- }else{
- proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
- }
- }
- };
- var clearProc = function(){
- if(proc.id){
- clearInterval(proc.id);
- }
- proc.id = 0;
- proc.el = null;
- proc.dir = "";
- };
- var startProc = function(el, dir){
- clearProc();
- proc.el = el;
- proc.dir = dir;
- var freq = (el.ddScrollConfig && el.ddScrollConfig.frequency) ?
- el.ddScrollConfig.frequency : Ext.dd.ScrollManager.frequency;
- proc.id = setInterval(doScroll, freq);
- };
- var onFire = function(e, isDrop){
- if(isDrop || !ddm.dragCurrent){ return; }
- var dds = Ext.dd.ScrollManager;
- if(!dragEl || dragEl != ddm.dragCurrent){
- dragEl = ddm.dragCurrent;
- dds.refreshCache();
- }
- var xy = Ext.lib.Event.getXY(e);
- var pt = new Ext.lib.Point(xy[0], xy[1]);
- for(var id in els){
- var el = els[id], r = el._region;
- var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
- if(r && r.contains(pt) && el.isScrollable()){
- if(r.bottom - pt.y <= c.vthresh){
- if(proc.el != el){
- startProc(el, "down");
- }
- return;
- }else if(r.right - pt.x <= c.hthresh){
- if(proc.el != el){
- startProc(el, "left");
- }
- return;
- }else if(pt.y - r.top <= c.vthresh){
- if(proc.el != el){
- startProc(el, "up");
- }
- return;
- }else if(pt.x - r.left <= c.hthresh){
- if(proc.el != el){
- startProc(el, "right");
- }
- return;
- }
- }
- }
- clearProc();
- };
- ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
- ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
- return {
- register : function(el){
- if(Ext.isArray(el)){
- for(var i = 0, len = el.length; i < len; i++) {
- this.register(el[i]);
- }
- }else{
- el = Ext.get(el);
- els[el.id] = el;
- }
- },
- unregister : function(el){
- if(Ext.isArray(el)){
- for(var i = 0, len = el.length; i < len; i++) {
- this.unregister(el[i]);
- }
- }else{
- el = Ext.get(el);
- delete els[el.id];
- }
- },
- vthresh : 25,
- hthresh : 25,
- increment : 100,
- frequency : 500,
- animate: true,
- animDuration: .4,
- refreshCache : function(){
- for(var id in els){
- if(typeof els[id] == 'object'){ els[id]._region = els[id].getRegion();
- }
- }
- }
- };
- }();
- Ext.dd.Registry = function(){
- var elements = {};
- var handles = {};
- var autoIdSeed = 0;
- var getId = function(el, autogen){
- if(typeof el == "string"){
- return el;
- }
- var id = el.id;
- if(!id && autogen !== false){
- id = "extdd-" + (++autoIdSeed);
- el.id = id;
- }
- return id;
- };
- return {
- register : function(el, data){
- data = data || {};
- if(typeof el == "string"){
- el = document.getElementById(el);
- }
- data.ddel = el;
- elements[getId(el)] = data;
- if(data.isHandle !== false){
- handles[data.ddel.id] = data;
- }
- if(data.handles){
- var hs = data.handles;
- for(var i = 0, len = hs.length; i < len; i++){
- handles[getId(hs[i])] = data;
- }
- }
- },
- unregister : function(el){
- var id = getId(el, false);
- var data = elements[id];
- if(data){
- delete elements[id];
- if(data.handles){
- var hs = data.handles;
- for(var i = 0, len = hs.length; i < len; i++){
- delete handles[getId(hs[i], false)];
- }
- }
- }
- },
- getHandle : function(id){
- if(typeof id != "string"){ id = id.id;
- }
- return handles[id];
- },
- getHandleFromEvent : function(e){
- var t = Ext.lib.Event.getTarget(e);
- return t ? handles[t.id] : null;
- },
- getTarget : function(id){
- if(typeof id != "string"){ id = id.id;
- }
- return elements[id];
- },
- getTargetFromEvent : function(e){
- var t = Ext.lib.Event.getTarget(e);
- return t ? elements[t.id] || handles[t.id] : null;
- }
- };
- }();
- Ext.dd.StatusProxy = function(config){
- Ext.apply(this, config);
- this.id = this.id || Ext.id();
- this.el = new Ext.Layer({
- dh: {
- id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
- {tag: "div", cls: "x-dd-drop-icon"},
- {tag: "div", cls: "x-dd-drag-ghost"}
- ]
- },
- shadow: !config || config.shadow !== false
- });
- this.ghost = Ext.get(this.el.dom.childNodes[1]);
- this.dropStatus = this.dropNotAllowed;
- };
- Ext.dd.StatusProxy.prototype = {
- dropAllowed : "x-dd-drop-ok",
- dropNotAllowed : "x-dd-drop-nodrop",
- setStatus : function(cssClass){