Issue 17113: Add a copy of showIf definition to obShowIf
authorIván Perdomo <ivan.perdomo@openbravo.com>
Thu, 12 May 2011 18:52:58 +0200
changeset 12139 1c3a638a6b50
parent 12138 ab9973f3e5b8
child 12140 67e716398e7a
Issue 17113: Add a copy of showIf definition to obShowIf
- This reference copy is used in the showIf of the section. Somehow the item
showIf function definition gets set to null
- Fixes several JSLint warnings
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Thu May 12 18:52:55 2011 +0200
+++ b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Thu May 12 18:52:58 2011 +0200
@@ -70,6 +70,7 @@
   
   _original_init: isc.FormItem.getPrototype().init,
   init: function() {
+    this.obShowIf = this.showIf; // Copy the reference of showIf definition
     OB.Utilities.addRequiredSuffixToBaseStyle(this);
     // and continue with the original init
     this._original_init();
@@ -188,19 +189,21 @@
   // Shows or hides the quantity box and updates the hint to reflect the current value.
   // overridden to solve: https://issues.openbravo.com/view.php?id=16295
   updateEditor : function () {
-  
-      if (!this.valueField || !this.quantityField) return;
-      
+
+      if (!this.valueField || !this.quantityField) {
+        return;
+      }
+
       var focusItem,
           selectionRange,
           mustRefocus = false;
-          
+
       if (this.valueField.hasFocus) {
           focusItem = this.valueField;
           selectionRange = this.valueField.getSelectionRange();
       } else if (this.quantityField.hasFocus) {
           focusItem = this.quantityField;
-          selectionRange = this.quantityField.getSelectionRange()
+          selectionRange = this.quantityField.getSelectionRange();
       }
       
       var value = this.valueField.getValue(),
@@ -242,8 +245,8 @@
       // If we redrew the form to show or hide the qty field, we may need to refocus and
       // reset the selection range
       
-      if (mustRefocus && focusItem != null) {
-          if (!showQuantity && focusItem == this.quantityField) {
+      if (mustRefocus && focusItem !== null) {
+          if (!showQuantity && focusItem === this.quantityField) {
               this.valueField.focusInItem();
           } else {
               if (selectionRange) {
@@ -286,7 +289,7 @@
       this._handleError(response, request);
     }
   }
-})
+});
 
 // uncomment this code and put a breakpoint to get a better control
 // on from where async operations are started