Hello andreip,

I'd like you to do a code review.  Please execute
        g4 diff -c 8202205

or point your web browser to
        http://mondrian/8202205

to review the following code:

Change 8202205 by [EMAIL PROTECTED] on 2008/09/08 13:07:15 *pending*

        Changes the behaviour of the settings dialog, so that if a user changes 
the settings back to their original values, the 'Apply' button is disabled.
        
        This is a fix for issue 658.
        
        R=andreip
        [EMAIL PROTECTED]
        DELTA=19  (12 added, 0 deleted, 7 changed)
        OCL=8202205

Affected files ...

... 
//depot/googleclient/gears/opensource/gears/ui/common/settings_dialog.html_m4#1 
edit

19 delta lines: 12 added, 0 deleted, 7 changed

If you can't do the review, please let me know as soon as possible.  During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately.  Visit
http://www/eng/code_review.html for more information.

This is a semiautomated message from "g4 mail".  Complaints or suggestions?
Mail [EMAIL PROTECTED]
Change 8202205 by [EMAIL PROTECTED] on 2008/09/08 13:07:15 *pending*

        Changes the behaviour of the settings dialog, so that if a user changes 
the settings back to their original values, the 'Apply' button is disabled.
        
        This is a fix for issue 658.

Affected files ...

... 
//depot/googleclient/gears/opensource/gears/ui/common/settings_dialog.html_m4#1 
edit

==== 
//depot/googleclient/gears/opensource/gears/ui/common/settings_dialog.html_m4#1 
- 
c:\MyDocs\Gears1/googleclient/gears/opensource/gears/ui/common/settings_dialog.html_m4
 ====
# action=edit type=text
--- googleclient/gears/opensource/gears/ui/common/settings_dialog.html_m4       
2008-09-08 13:10:23.000000000 +0100
+++ googleclient/gears/opensource/gears/ui/common/settings_dialog.html_m4       
2008-09-08 13:09:22.000000000 +0100
@@ -220,14 +220,14 @@
             </td>
             <td width="50%" align="right" valign="middle">
               <input type="BUTTON" id="confirm-button"
-               onclick="saveAndClose(calculateDiff()); return false;"></input>
+               onclick="saveAndClose(result); return false;"></input>
             </td>
           </div>
 ~,m4_dnl
 ~
           <td nowrap="true" align="right" valign="middle">
             <button id="confirm-button" class="custom"
-                onclick="saveAndClose(calculateDiff()); return false;"
+                onclick="saveAndClose(result); return false;"
               ></button
             ><button id="cancel-button" accesskey="C" class="custom"
                 onclick="saveAndClose(null); return false;"
@@ -256,6 +256,7 @@
   var debug = false;
   var permissions;
   var originalPermissions;
+  var result = { modifiedOrigins: [] };
 
   // Must match values in permission_db.h
   var PERMISSION_NOT_SET = 0;
@@ -292,7 +293,7 @@
     var applyText = dom.getElementById("string-apply");
     if (applyText) {
       window.pie_dialog.SetButton(applyText.innerText, 
-        "saveAndClose(calculateDiff());");
+        "saveAndClose(result);");
     }
     var cancelText = dom.getElementById("string-cancel");
     if (cancelText) {
@@ -489,6 +490,8 @@
     updatePermission(index, "localStorage", PERMISSION_NOT_SET);
     updatePermission(index, "locationData", PERMISSION_NOT_SET);
     updatePermissionsList();
+    result.modifiedOrigins = calculateDiff();
+    updateButtonStatus();
 
     // Return false to prevent the default link action (scrolling up to top of
     // page in this case).
@@ -501,8 +504,17 @@
           permissionState) {
         permissions[index][permissionClass].permissionState =
           permissionState;
-        enableButton(dom.getElementById("confirm-button"));
+        result.modifiedOrigins = calculateDiff();
+        updateButtonStatus();
       }
+    }
+  }
+
+  function updateButtonStatus() {
+    if (result.modifiedOrigins.length > 0) {
+      enableButton(dom.getElementById("confirm-button"));
+    } else {
+      disableButton(dom.getElementById("confirm-button"));
     }
   }
 
@@ -524,7 +536,7 @@
 
   function calculateDiff() {
     var permissionClasses = ["localStorage", "locationData"];
-    var result = { "modifiedOrigins": [] };
+    var modifiedOrigins = [];
     for (var index = 0; index < originalPermissions.length; index++) {
       var originalOriginData = originalPermissions[index];
       var originData = permissions[index];
@@ -549,11 +561,11 @@
         }
         if (modified) {
           modifiedOriginData.name = originData.name;
-          result.modifiedOrigins.push(modifiedOriginData);
+          modifiedOrigins.push(modifiedOriginData);
         }
       }
     }
-    return result;
+    return modifiedOrigins;
   }
 
 </script>

Reply via email to