diff --git a/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml b/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml index 10c12434a5..541f452a1f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml +++ b/org.adempiere.ui.zk/WEB-INF/src/metainfo/zk/lang-addon.xml @@ -48,7 +48,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI). - + diff --git a/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/tree.js b/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/tree.js new file mode 100644 index 0000000000..a9e98c8e2b --- /dev/null +++ b/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/tree.js @@ -0,0 +1,131 @@ +zk.afterLoad("zul.sel", function () { + var _tWgt = {}, + _tiWgt = {}; + zk.override(zul.sel.Treerow.prototype, _tiWgt, { + getDragOptions_: function (map) { + var copy = map.constructor(), + wgt = this; + // clone map + for (var attr in map) { + if (map.hasOwnProperty(attr)) copy[attr] = map[attr]; + } + // change functions as needed + var oldChange = copy.change, + oldEnd = copy.endeffect; + copy.change = function (drag, pt, evt) { + var tree = wgt.getTree(); + oldChange(drag, pt, evt); + tree.triggerAutoScroll(evt.pageX, evt.pageY); + }; + copy.endeffect = function (drag, evt) { + var tree = wgt.getTree(); + oldEnd(drag, evt); + tree.stopAutoScroll(); + } + return copy; + } + }); + + zk.override(zul.sel.Tree.prototype, _tWgt, { + scrollValue: 10, + scrollDelay: 0, + initialScrollDelay: 200, + currentY: 0, + previousY: 0, + delayCount: 0, + speedGap: 50, + speedGapCounter: 0, + triggerAutoScroll: function (x, y) { + var $n = jq(this.$n()), + offset = $n.offset(), + top = offset.top + (this.$n('head')? 10 : 0), + bottom = $n.outerHeight(true); + if (y < top) + this.startScrollToTop(y); + else if (y > bottom) + this.startScrollToBottom(y); + else + this.stopAutoScroll(); + }, + stopAutoScroll: function () { + this.clearScrollToTopTimer(); + this.clearScrollToBottomTimer(); + }, + startScrollToTop: function (y) { + var wgt = this; + this.clearScrollToBottomTimer(); + if (!this._scrollToTopTimer) { + this.scrollDelay = this.initialScrollDelay; + this.previousY = this.currentY = y; + this.delayCount = this.speedGapCounter = 0; + this._scrollToTopTimer = setInterval(function () { + wgt.delayCount = wgt.delayCount + 5; + if (wgt.delayCount >= wgt.scrollDelay) { + wgt.delayCount = 0; + wgt.speedGapCounter++; + wgt.$n('body').scrollTop -= wgt.scrollValue; + if (wgt.speedGapCounter == 5) { + wgt.speedGapCounter = 0; + if (wgt.scrollDelay > wgt.speedGap) { + wgt.scrollDelay = wgt.scrollDelay - wgt.speedGap; + } else if (wgt.scrollDelay == wgt.speedGap) { + wgt.scrollDelay = 10; + } + } + } + }, 5); + } else { + this.previousY = this.currentY; + this.currentY = y; + if (this.previousY != this.currentY) { + this.scrollDelay = this.initialScrollDelay; + this.speedGapCounter = 0; + } + } + }, + startScrollToBottom: function (y) { + var wgt = this; + this.clearScrollToTopTimer(); + if (!this._scrollToBottomTimer) { + this.scrollDelay = this.initialScrollDelay; + this.previousY = this.currentY = y; + this.delayCount = this.speedGapCounter = 0; + this._scrollToBottomTimer = setInterval(function () { + wgt.delayCount = wgt.delayCount + 5; + if (wgt.delayCount >= wgt.scrollDelay) { + wgt.delayCount = 0; + wgt.speedGapCounter++; + wgt.$n('body').scrollTop += wgt.scrollValue; + if (wgt.speedGapCounter == 5) { + wgt.speedGapCounter = 0; + if (wgt.scrollDelay > wgt.speedGap) { + wgt.scrollDelay = wgt.scrollDelay - wgt.speedGap; + } else if (wgt.scrollDelay == wgt.speedGap) { + wgt.scrollDelay = 10; + } + } + } + }, 5); + } else { + this.previousY = this.currentY; + this.currentY = y; + if (this.previousY != this.currentY) { + this.scrollDelay = this.initialScrollDelay; + this.speedGapCounter = 0; + } + } + }, + clearScrollToTopTimer: function () { + var timer = this._scrollToTopTimer; + if (timer) + clearInterval(timer); + this._scrollToTopTimer = null; + }, + clearScrollToBottomTimer: function () { + var timer = this._scrollToBottomTimer; + if (timer) + clearInterval(timer); + this._scrollToBottomTimer = null; + } + }); +}); \ No newline at end of file diff --git a/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/zk.wpd b/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/zk.wpd index b3b9c0e20a..ad2b81f95c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/zk.wpd +++ b/org.adempiere.ui.zk/WEB-INF/src/web/js/org/idempiere/commons/zk.wpd @@ -4,4 +4,5 @@