Bug 1241436 - Update the "email me" checkbox in accordance with the email input field in the tab crash reporter. r=felipe draft
authorCervantes Yu <cyu@mozilla.com>
Tue, 26 Jul 2016 18:29:54 +0800
changeset 396556 dd53064b3060c639416f735d7787c071328fe236
parent 396555 1576e7bc1bec7232e9e4ba78cce62526b1a6380b
child 527241 c139a7d0d2e2efe4025da65a299a4f4345d9adb4
push id25044
push usercyu@mozilla.com
push dateThu, 04 Aug 2016 03:01:24 +0000
reviewersfelipe
bugs1241436
milestone51.0a1
Bug 1241436 - Update the "email me" checkbox in accordance with the email input field in the tab crash reporter. r=felipe MozReview-Commit-ID: EnIe7NRwMes
browser/base/content/aboutTabCrashed.js
--- a/browser/base/content/aboutTabCrashed.js
+++ b/browser/base/content/aboutTabCrashed.js
@@ -81,25 +81,32 @@ var AboutTabCrashed = {
       case "DOMContentLoaded": {
         this.onDOMContentLoaded();
         break;
       }
       case "click": {
         this.onClick(event);
         break;
       }
+      case "input": {
+        this.onInput(event);
+        break;
+      }
     }
   },
 
   onDOMContentLoaded() {
     this.CLICK_TARGETS.forEach((targetID) => {
       let el = document.getElementById(targetID);
       el.addEventListener("click", this);
     });
 
+    // For setting "emailMe" checkbox automatically on email value change.
+    document.getElementById("email").addEventListener("input", this);
+
     // Error pages are loaded as LOAD_BACKGROUND, so they don't get load events.
     let event = new CustomEvent("AboutTabCrashedLoad", {bubbles:true});
     document.dispatchEvent(event);
 
     sendAsyncMessage("Load");
   },
 
   onClick(event) {
@@ -121,16 +128,24 @@ var AboutTabCrashed = {
 
       case "sendReport": {
         this.showCrashReportUI(event.target.checked);
         break;
       }
     }
   },
 
+  onInput(event) {
+    switch(event.target.id) {
+      case "email": {
+        document.getElementById("emailMe").checked = !!event.target.value;
+        break;
+      }
+    }
+  },
   /**
    * After this page tells the parent that it has loaded, the parent
    * will respond with whether or not a crash report is available. This
    * method handles that message.
    *
    * @param message
    *        The message from the parent, which should contain a data
    *        Object property with the following properties: