Related to issue 13887: Added MDI KS compatibility in classic ob tabs
authorDavid Baz Fayos <david.baz@openbravo.com>
Thu, 12 Aug 2010 13:37:32 +0200
changeset 8117 ba616948bd77
parent 8116 fb4fc8956f75
child 8118 ef6183fd79e5
Related to issue 13887: Added MDI KS compatibility in classic ob tabs
src/org/openbravo/erpCommon/security/Login_F1.html
web/js/shortcuts.js
web/js/utils.js
--- a/src/org/openbravo/erpCommon/security/Login_F1.html	Thu Aug 12 11:43:07 2010 +0200
+++ b/src/org/openbravo/erpCommon/security/Login_F1.html	Thu Aug 12 13:37:32 2010 +0200
@@ -111,7 +111,7 @@
       clearForm();
     } catch (e) {}
     setWindowElementFocus('firstElement');
-    if ((!revisionControl('7928')) || (isOpsInstance() != isOpsInstanceCached())) {
+    if ((!revisionControl('8117')) || (isOpsInstance() != isOpsInstanceCached())) {
       alert(cacheMsg);
     }
 
--- a/web/js/shortcuts.js	Thu Aug 12 11:43:07 2010 +0200
+++ b/web/js/shortcuts.js	Thu Aug 12 13:37:32 2010 +0200
@@ -45,14 +45,10 @@
 * Defines the keys array for all the application.
 */
 function getShortcuts(type) {
-  // note these methods/variables are defined in utils.js
-  setMDIEnvironment();
-  var inMDIEnvironment = (isWindowInMDITab || isWindowInMDIContext); 
-  
   if (type==null || type=="" || type=="null") {
   } else if (type=='applicationCommonKeys') {
     // don't override browser shortcuts in case of MDI environment
-    if (!inMDIEnvironment) {
+    if (!isWindowInMDIContext) {
       this.keyArray.splice(keyArray.length-1, 0,
           new keyArrayItem("M", "executeMenuButton('buttonExpand');executeMenuButton('buttonCollapse');", null, "ctrlKey+shiftKey", false, 'onkeydown'),
           new keyArrayItem("U", "executeMenuButton('buttonUserOptions');", null, "ctrlKey", false, 'onkeydown'),
@@ -64,6 +60,16 @@
           new keyArrayItem("R", "executeWindowButton('buttonRefresh');", null, "ctrlKey", false, 'onkeydown'),
           new keyArrayItem("BACKSPACE", "executeWindowButton('buttonBack');", null, "ctrlKey+shiftKey", false, 'onkeydown')
         );
+    } else {
+      var LayoutMDI = getFrame('LayoutMDI');
+      if (typeof LayoutMDI.OB.Layout.ClassicOBCompatibility.Keyboard === "object" && typeof LayoutMDI.OB.Layout.ClassicOBCompatibility.Keyboard.getMDIKS === "function") {
+        var MDIKeyJSON = LayoutMDI.OB.Layout.ClassicOBCompatibility.Keyboard.getMDIKS();
+        for (var i=0; i<MDIKeyJSON.length; i++) {
+          this.keyArray.splice(keyArray.length-1, 0,
+              new keyArrayItem(MDIKeyJSON[i].key, [MDIKeyJSON[i].action, MDIKeyJSON[i].funcParam], null, MDIKeyJSON[i].auxKey, false, 'onkeydown')
+          );
+        }
+      }
     }
   } else if (type=='menuSpecificKeys') {
       this.keyArray.splice(keyArray.length-1, 0,
--- a/web/js/utils.js	Thu Aug 12 11:43:07 2010 +0200
+++ b/web/js/utils.js	Thu Aug 12 13:37:32 2010 +0200
@@ -62,6 +62,7 @@
 
 var isCtrlPressed = null;
 var isAltPressed = null;
+var isShiftPressed = null;
 var isTabBlocked = false;
 var pressedKeyCode = null;
 var isInputFile = false;
@@ -88,7 +89,7 @@
 * Return a number that would be checked at the Login screen to know if the file is cached with the correct version
 */
 function getCurrentRevision() {
-  var number = '7928';
+  var number = '8117';
   return number;
 }
 
@@ -1409,8 +1410,10 @@
   var thereIsShortcut = false;
   isCtrlPressed = false;
   isAltPressed = false;
+  isShiftPressed = false;
   if (pushedKey.ctrlKey) isCtrlPressed = true;
   if (pushedKey.altKey) isAltPressed = true;
+  if (pushedKey.shiftKey) isShiftPressed = true;
   pressedKeyCode = pushedKey.keyCode;
   if (isTabPressed == true && isInputFile == true) {
     return true;
@@ -1442,7 +1445,12 @@
               if (keyArray[i].field==null || (keyTarget!=null && keyTarget.name!=null && isIdenticalField(keyArray[i].field, keyTarget.name))) {
                 var evalfuncTrl = replaceEventString(keyArray[i].evalfunc, keyTarget.name, keyArray[i].field);
                 try {
-                  eval(evalfuncTrl);
+                  if (!isWindowInMDIContext || typeof keyArray[i].evalfunc !== "object") {
+                    eval(evalfuncTrl);
+                  } else {
+                    var LayoutMDI = getFrame('LayoutMDI');
+                    LayoutMDI.OB.Layout.ClassicOBCompatibility.Keyboard.executeKSFunction(keyArray[i].evalfunc[0], keyArray[i].evalfunc[1]);
+                  }
                   thereIsShortcut = true;
                   if (propagateEnter == false && keyArray[i].key == 'ENTER') { // Special ENTER case logic to not propagate if there is default action
                     propagateEnter = true;
@@ -1467,9 +1475,15 @@
             if ((keyArray[i].auxKey == "ctrlKey" && pushedKey.ctrlKey && !pushedKey.altKey && !pushedKey.shiftKey) ||
                 (keyArray[i].auxKey == "altKey" && !pushedKey.ctrlKey && pushedKey.altKey && !pushedKey.shiftKey) ||
                 (keyArray[i].auxKey == "shiftKey" && !pushedKey.ctrlKey && !pushedKey.altKey && pushedKey.shiftKey) ||
-                (keyArray[i].auxKey == "ctrlKey+shiftKey" && pushedKey.ctrlKey && !pushedKey.altKey && pushedKey.shiftKey)) {
+                (keyArray[i].auxKey == "ctrlKey+shiftKey" && pushedKey.ctrlKey && !pushedKey.altKey && pushedKey.shiftKey) ||
+                (keyArray[i].auxKey == "ctrlKey+altKey" && pushedKey.ctrlKey && pushedKey.altKey && !pushedKey.shiftKey)) {
               try {
-                eval(evalfuncTrl);
+                if (!isWindowInMDIContext || typeof keyArray[i].evalfunc !== "object") {
+                  eval(evalfuncTrl);
+                } else {
+                  var LayoutMDI = getFrame('LayoutMDI');
+                  LayoutMDI.OB.Layout.ClassicOBCompatibility.Keyboard.executeKSFunction(keyArray[i].evalfunc[0], keyArray[i].evalfunc[1]);
+                }
                 thereIsShortcut = true;
                 startKeyPressEvent();
                 if ((!keyArray[i].propagateKey || isGridFocused) && !(keyArray[i].key == 'TAB' && isOBTabBehavior == false)) {
@@ -1509,7 +1523,12 @@
               if (keyArray[i].field==null || (keyTarget!=null && keyTarget.name!=null && isIdenticalField(keyArray[i].field, keyTarget.name))) {
                 var evalfuncTrl = replaceEventString(keyArray[i].evalfunc, keyTarget.name, keyArray[i].field);
                 try {
-                  eval(evalfuncTrl);
+                  if (!isWindowInMDIContext || typeof keyArray[i].evalfunc !== "object") {
+                    eval(evalfuncTrl);
+                  } else {
+                    var LayoutMDI = getFrame('LayoutMDI');
+                    LayoutMDI.OB.Layout.ClassicOBCompatibility.Keyboard.executeKSFunction(keyArray[i].evalfunc[0], keyArray[i].evalfunc[1]);
+                  }
                   thereIsShortcut = true;
                   if ((!keyArray[i].propagateKey || isGridFocused) && !(keyArray[i].key == 'TAB' && isOBTabBehavior == false)) {
                     return false;
@@ -1530,9 +1549,15 @@
             if ((keyArray[i].auxKey == "ctrlKey" && pushedKey.ctrlKey && !pushedKey.altKey && !pushedKey.shiftKey) ||
                 (keyArray[i].auxKey == "altKey" && !pushedKey.ctrlKey && pushedKey.altKey && !pushedKey.shiftKey) ||
                 (keyArray[i].auxKey == "shiftKey" && !pushedKey.ctrlKey && !pushedKey.altKey && pushedKey.shiftKey) ||
-                (keyArray[i].auxKey == "ctrlKey+shiftKey" && pushedKey.ctrlKey && !pushedKey.altKey && pushedKey.shiftKey)) {
+                (keyArray[i].auxKey == "ctrlKey+shiftKey" && pushedKey.ctrlKey && !pushedKey.altKey && pushedKey.shiftKey) ||
+                (keyArray[i].auxKey == "ctrlKey+altKey" && pushedKey.ctrlKey && pushedKey.altKey && !pushedKey.shiftKey)) {
               try {
-                eval(evalfuncTrl);
+                if (!isWindowInMDIContext || typeof keyArray[i].evalfunc !== "object") {
+                  eval(evalfuncTrl);
+                } else {
+                  var LayoutMDI = getFrame('LayoutMDI');
+                  LayoutMDI.OB.Layout.ClassicOBCompatibility.Keyboard.executeKSFunction(keyArray[i].evalfunc[0], keyArray[i].evalfunc[1]);
+                }
                 thereIsShortcut = true;
                 startKeyPressEvent();
                 if ((!keyArray[i].propagateKey || isGridFocused) && !(keyArray[i].key == 'TAB' && isOBTabBehavior == false)) {