details:   https://code.openbravo.com/erp/devel/pi/rev/058f482a9f01
changeset: 18565:058f482a9f01
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Tue Nov 20 12:48:26 2012 +0100
summary:   Related to issue 21776: Reverted previous changeset

details:   https://code.openbravo.com/erp/devel/pi/rev/120e4b62fcd6
changeset: 18566:120e4b62fcd6
user:      David Baz Fayos <david.baz <at> openbravo.com>
date:      Tue Nov 20 13:32:36 2012 +0100
summary:   Fixed issue 21776: Prevent 'Backspace' key propagation
(as a browser 'go back' shortcut) in all cases

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/classic/ob-classic-compatibility.js
 |   2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-keyboard-manager.js
    |  47 +++++++--
 web/js/utils.js                                                                
                                      |  15 +++
 3 files changed, 52 insertions(+), 12 deletions(-)

diffs (108 lines):

diff -r f34a7b1836ab -r 120e4b62fcd6 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/classic/ob-classic-compatibility.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/classic/ob-classic-compatibility.js
      Tue Nov 20 11:13:15 2012 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/classic/ob-classic-compatibility.js
      Tue Nov 20 13:32:36 2012 +0100
@@ -248,7 +248,7 @@
 
           if (LKS.list[i].execLevel) {
             for (j = 0; j < LKS.list[i].execLevel.length; j++) {
-              if (LKS.list[i].execLevel[j] === 'Canvas' && LKS.list[i].id !== 
'Canvas_Avoid_Backspace') {
+              if (LKS.list[i].execLevel[j] === 'Canvas') {
                 isCanvasShortcut = true;
                 break;
               }
diff -r f34a7b1836ab -r 120e4b62fcd6 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-keyboard-manager.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-keyboard-manager.js
 Tue Nov 20 11:13:15 2012 +0100
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/utilities/ob-keyboard-manager.js
 Tue Nov 20 13:32:36 2012 +0100
@@ -347,17 +347,6 @@
   // Initialize KeyboardManager object
   keyboardMgr = O.KeyboardManager = new KeyboardManager();
 
-  // To avoid default browser behavior that makes "Backspace" key go to 
previous html page
-  O.KeyboardManager.Shortcuts.set('Canvas_Avoid_Backspace', 'Canvas', function 
() {
-    if (document.activeElement && 
(document.activeElement.tagName.toLowerCase() === 'div' || 
document.activeElement.tagName.toLowerCase() === 'body')) {
-      return false;
-    } else {
-      return true;
-    }
-  }, null, {
-    "key": "Backspace"
-  });
-
   // To fix issue https://issues.openbravo.com/view.php?id=21786
   isc.ComboBoxItem.getPrototype()._originalKeyDown = 
isc.ComboBoxItem.getPrototype().keyDown;
   isc.ComboBoxItem.getPrototype().keyDown = function () {
@@ -376,6 +365,10 @@
     return response;
   };
 
+  O.KeyboardManager.Shortcuts.origWindowOnKeyDown = null;
+  O.KeyboardManager.Shortcuts.origWindowOnKeyUp = null;
+  O.KeyboardManager.Shortcuts.isOrigWindowOnKeyDownSet = false;
+
   /* isc.Page.setEvent('keyPress', 
'OB.KeyboardManager.Shortcuts.monitor('Canvas')'); // Discart due to Chrome 
event propagation problems http://forums.smartclient.com/showthread.php?p=65578 
*/
   isc.Canvas.getPrototype()._originalKeyDown = 
isc.Canvas.getPrototype().keyDown;
   isc.Canvas.getPrototype().keyDown = function () {
@@ -386,6 +379,38 @@
     },
         response;
 
+    // Special case to avoid "BACKSPACE" key resulting in a browser shortcut 
that performs a browser history "Go back".
+    // Issue: https://issues.openbravo.com/view.php?id=21776
+    if (isc.EH.getKey() === 'Backspace' && !isc.EH.ctrlKeyDown() && 
!isc.EH.altKeyDown() && !isc.EH.shiftKeyDown()) {
+      if (!O.KeyboardManager.Shortcuts.isOrigWindowOnKeyDownSet) {
+        var avoidBackspace, restoreOriginals;
+
+        O.KeyboardManager.Shortcuts.isOrigWindowOnKeyDownSet = true;
+        O.KeyboardManager.Shortcuts.origWindowOnKeyDown = window.onkeydown;
+        O.KeyboardManager.Shortcuts.origWindowOnKeyUp = window.onkeyup;
+
+        avoidBackspace = function (e) {
+          if (e.keyCode === 8) {
+            if (document.activeElement && 
(document.activeElement.tagName.toLowerCase() === 'div' || 
document.activeElement.tagName.toLowerCase() === 'body')) {
+              return false;
+            } else {
+              return true;
+            }
+          } else {
+            return true;
+          }
+        };
+
+        restoreOriginals = function (e) {
+          window.onkeydown = O.KeyboardManager.Shortcuts.origWindowOnKeyDown;
+          window.onkeyup = O.KeyboardManager.Shortcuts.origWindowOnKeyUp;
+          O.KeyboardManager.Shortcuts.isOrigWindowOnKeyDownSet = false;
+        };
+
+        window.onkeydown = avoidBackspace;
+        window.onkeyup = restoreOriginals;
+      }
+    }
     if (isc.Event.getKey() === 'Space') {
       OB.KeyboardManager.Shortcuts.isSpacePressed = true;
     }
diff -r f34a7b1836ab -r 120e4b62fcd6 web/js/utils.js
--- a/web/js/utils.js   Tue Nov 20 11:13:15 2012 +0100
+++ b/web/js/utils.js   Tue Nov 20 13:32:36 2012 +0100
@@ -1490,6 +1490,21 @@
     return true;
   }
 
+  // To avoid BACKSPACE ("go back" browser shortcut) propagation
+  if (pressedKeyCode === 8 && !pushedKey.ctrlKey && !pushedKey.altKey && 
!pushedKey.shiftKey) {
+    if (document.activeElement && document.activeElement.tagName.toLowerCase() 
!== 'input' && document.activeElement.tagName.toLowerCase() !== 'textarea') {
+      return false;
+    } else if (document.activeElement &&
+      document.activeElement.tagName.toLowerCase() === 'input' &&
+      (document.activeElement.type.toLowerCase() === 'button' ||
+      document.activeElement.type.toLowerCase() === 'checkbox' ||
+      document.activeElement.type.toLowerCase() === 'radio' ||
+      document.activeElement.type.toLowerCase() === 'file' ||
+      document.activeElement.type.toLowerCase() === 'submit')) {
+      return false;
+    }
+  }
+
   var keyCode = pushedKey.keyCode ? pushedKey.keyCode : pushedKey.which ? 
pushedKey.which : pushedKey.charCode;
   if (isKeyboardLocked==false) {
     var keyTarget = pushedKey.target ? pushedKey.target: pushedKey.srcElement;

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to