From 2e99fc12dc90bc59d303c6b614c713b980d98245 Mon Sep 17 00:00:00 2001 From: Farruco Sanjurjo Date: Mon, 20 Dec 2010 11:12:13 +0100 Subject: [PATCH] ESC keypress event is now handled * If you press the ESC key while adding a dependency (before it's consolidated) the depency line will be removed FEA: ItEr02S03MigracionZK5 --- .../resources/web/js/ganttz/DependencyComponent.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ganttzk/src/main/resources/web/js/ganttz/DependencyComponent.js b/ganttzk/src/main/resources/web/js/ganttz/DependencyComponent.js index 79e79c855..cb995cd0f 100644 --- a/ganttzk/src/main/resources/web/js/ganttz/DependencyComponent.js +++ b/ganttzk/src/main/resources/web/js/ganttz/DependencyComponent.js @@ -133,7 +133,7 @@ ganttz.DependencyComponentBase = zk.$extends(zk.Widget,{ // Second segment not used var depmid = this._findImageElement('mid'); var depmidcss; - + if (yend > yorig) depmidcss = {top : yorig, height : yend - yorig}; else @@ -266,9 +266,13 @@ ganttz.UnlinkedDependencyComponent = zk.$extends(ganttz.DependencyComponentBase, }, bind_ : function(){ this.$supers('bind_', arguments); + /*We use document.documentElement as the DOM element to attach this listener + * because document.documentElement always gets the key events (in all browsers)*/ + this.domListen_(document.documentElement,'onKeyup','_handleKeyUp'); this._updateArrow(); }, unbind_ : function(){ + this.domUnlisten_(document.documentElement,'onKeyup','_handleKeyUp'); this.domUnlisten_(this._WGTganttpanel.$n(), 'onMousemove', '_updateArrow'); this.domUnlisten_(this._WGTganttpanel.$n(), 'onClick', '_consolidateDependency'); this.$supers('unbind_', arguments); @@ -323,6 +327,13 @@ ganttz.UnlinkedDependencyComponent = zk.$extends(ganttz.DependencyComponentBase, var pos1 = YAHOO.util.Dom.getXY('listtasks'); return { left : this._WGTganttpanel.getXMouse() - pos1[0], top: this._WGTganttpanel.getYMouse() - pos1[1]}; + }, + _handleKeyUp: function(event){ + if ( event.keyCode != 27 ) + return; + + event.stop(); + ganttz.DependencyList.getInstance().removeChild(this); } })