Bug 948897 - Move inline scripts and styles into separate file for mobile/android/chrome/content/aboutFeedback.xhtml. r=mbrubeck
authorNeil Bleasdale <nb.mozd@gmail.com>
Mon, 06 Jan 2014 15:18:01 -0500
changeset 162254 a27c76ef0c1ed3e680682950df38d3a25e08600f
parent 162253 64c3bdede7dd7f510f95909b7393ca5c88019ddf
child 162255 841238b6a1077dbb111e8a2d2e3f845a8c057afd
push idunknown
push userunknown
push dateunknown
reviewersmbrubeck
bugs948897
milestone29.0a1
Bug 948897 - Move inline scripts and styles into separate file for mobile/android/chrome/content/aboutFeedback.xhtml. r=mbrubeck
mobile/android/chrome/content/aboutFeedback.js
mobile/android/chrome/content/aboutFeedback.xhtml
mobile/android/chrome/jar.mn
new file mode 100644
--- /dev/null
+++ b/mobile/android/chrome/content/aboutFeedback.js
@@ -0,0 +1,116 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+let Cc = Components.classes;
+let Ci = Components.interfaces;
+let Cu = Components.utils;
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+function dump(a) {
+  Services.console.logStringMessage(a);
+}
+
+function sendMessageToJava(aMessage) {
+  Services.androidBridge.handleGeckoMessage(JSON.stringify(aMessage));
+}
+
+function init() {
+  let sumoLink = Services.urlFormatter.formatURLPref("app.support.baseURL");
+  document.getElementById("sumo-link").href = sumoLink;
+
+  window.addEventListener("popstate", function (aEvent) {
+	updateActiveSection(aEvent.state ? aEvent.state.section : "intro")
+  }, false);
+
+  // Fill "Last visited site" input with most recent history entry URL.
+  Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
+	document.getElementById("last-url").value = aData;
+  }, "Feedback:LastUrl", false);
+
+  sendMessageToJava({ type: "Feedback:LastUrl" });
+}
+
+function uninit() {
+  Services.obs.removeObserver(this, "Feedback:LastUrl");
+}
+
+function switchSection(aSection) {
+  history.pushState({ section: aSection }, aSection);
+  updateActiveSection(aSection);
+}
+
+function updateActiveSection(aSection) {
+  document.querySelector("section[active]").removeAttribute("active");
+  document.getElementById(aSection).setAttribute("active", true);
+}
+
+function openPlayStore() {
+  sendMessageToJava({ type: "Feedback:OpenPlayStore" });
+
+  window.close();
+}
+
+function maybeLater() {
+  window.close();
+
+  sendMessageToJava({ type: "Feedback:MaybeLater" });
+}
+
+function sendFeedback(aEvent) {
+  // Prevent the page from reloading.
+  aEvent.preventDefault();
+
+  let section = history.state.section;
+
+  // Sanity check.
+  if (section != "sad") {
+	Cu.reportError("Trying to send feedback from an invalid section: " + section);
+	return;
+  }
+
+  let sectionElement = document.getElementById(section);
+  let descriptionElement = sectionElement.querySelector(".description");
+
+  // Bail if the description value isn't valid. HTML5 form validation will take care
+  // of showing an error message for us.
+  if (!descriptionElement.validity.valid)
+	return;
+
+  let data = new FormData();
+  data.append("description", descriptionElement.value);
+  data.append("_type", 2);
+
+  let urlElement = document.getElementById("last-url");
+  // Bail if the URL value isn't valid. HTML5 form validation will take care
+  // of showing an error message for us.
+  if (!urlElement.validity.valid)
+	return;
+
+  // Only send a URL string if the user provided one.
+  if (urlElement.value) {
+	data.append("add_url", true);
+	data.append("url", urlElement.value);
+  }
+
+  let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
+  data.append("device", sysInfo.get("device"));
+  data.append("manufacturer", sysInfo.get("manufacturer"));
+
+  let req = new XMLHttpRequest();
+  req.addEventListener("error", function() {
+	Cu.reportError("Error sending feedback to input.mozilla.org: " + req.statusText);
+  }, false);
+  req.addEventListener("abort", function() {
+	Cu.reportError("Aborted sending feedback to input.mozilla.org: " + req.statusText);
+  }, false);
+
+  let postURL = Services.urlFormatter.formatURLPref("app.feedback.postURL");
+  req.open("POST", postURL, true);
+  req.send(data);
+
+  switchSection("thanks-" + section);
+}
--- a/mobile/android/chrome/content/aboutFeedback.xhtml
+++ b/mobile/android/chrome/content/aboutFeedback.xhtml
@@ -69,123 +69,11 @@
   <section id="thanks-sad">
     <h1 class="header">&sad.thanksHeader;</h1>
     <div class="message-box-bottom">
       <div class="message">&sad.thanksMessageTop;</div>
       <div class="message">&sad.thanksMessageBottom;</div>
     </div>
   </section>
 
-  <script type="application/javascript;version=1.8"><![CDATA[
-    let Cc = Components.classes;
-    let Ci = Components.interfaces;
-    let Cu = Components.utils;
-
-    Cu.import("resource://gre/modules/Services.jsm");
-
-    function dump(a) {
-      Services.console.logStringMessage(a);
-    }
-
-    function sendMessageToJava(aMessage) {
-      Services.androidBridge.handleGeckoMessage(JSON.stringify(aMessage));
-    }
-
-    function init() {
-      let sumoLink = Services.urlFormatter.formatURLPref("app.support.baseURL");
-      document.getElementById("sumo-link").href = sumoLink;
-
-      window.addEventListener("popstate", function (aEvent) {
-        updateActiveSection(aEvent.state ? aEvent.state.section : "intro")
-      }, false);
-
-      // Fill "Last visited site" input with most recent history entry URL.
-      Services.obs.addObserver(function observer(aSubject, aTopic, aData) {
-        document.getElementById("last-url").value = aData;
-      }, "Feedback:LastUrl", false);
-
-      sendMessageToJava({ type: "Feedback:LastUrl" });
-    }
-
-    function uninit() {
-      Services.obs.removeObserver(this, "Feedback:LastUrl");
-    }
-
-    function switchSection(aSection) {
-      history.pushState({ section: aSection }, aSection);
-      updateActiveSection(aSection);
-    }
-
-    function updateActiveSection(aSection) {
-      document.querySelector("section[active]").removeAttribute("active");
-      document.getElementById(aSection).setAttribute("active", true);
-    }
-
-    function openPlayStore() {
-      sendMessageToJava({ type: "Feedback:OpenPlayStore" });
-
-      window.close();
-    }
-
-    function maybeLater() {
-      window.close();
-
-      sendMessageToJava({ type: "Feedback:MaybeLater" });
-    }
-
-    function sendFeedback(aEvent) {
-      // Prevent the page from reloading.
-      aEvent.preventDefault();
-
-      let section = history.state.section;
-
-      // Sanity check.
-      if (section != "sad") {
-        Cu.reportError("Trying to send feedback from an invalid section: " + section);
-        return;
-      }
-
-      let sectionElement = document.getElementById(section);
-      let descriptionElement = sectionElement.querySelector(".description");
-
-      // Bail if the description value isn't valid. HTML5 form validation will take care
-      // of showing an error message for us.
-      if (!descriptionElement.validity.valid)
-        return;
-
-      let data = new FormData();
-      data.append("description", descriptionElement.value);
-      data.append("_type", 2);
-
-      let urlElement = document.getElementById("last-url");
-      // Bail if the URL value isn't valid. HTML5 form validation will take care
-      // of showing an error message for us.
-      if (!urlElement.validity.valid)
-        return;
-
-      // Only send a URL string if the user provided one.
-      if (urlElement.value) {
-        data.append("add_url", true);
-        data.append("url", urlElement.value);
-      }
-
-      let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
-      data.append("device", sysInfo.get("device"));
-      data.append("manufacturer", sysInfo.get("manufacturer"));
-
-      let req = new XMLHttpRequest();
-      req.addEventListener("error", function() {
-        Cu.reportError("Error sending feedback to input.mozilla.org: " + req.statusText);
-      }, false);
-      req.addEventListener("abort", function() {
-        Cu.reportError("Aborted sending feedback to input.mozilla.org: " + req.statusText);
-      }, false);
-
-      let postURL = Services.urlFormatter.formatURLPref("app.feedback.postURL");
-      req.open("POST", postURL, true);
-      req.send(data);
-
-      switchSection("thanks-" + section);
-    }
-  ]]></script>
-
+  <script type="application/javascript;version=1.8" src="chrome://browser/content/aboutFeedback.js"></script>
 </body>
 </html>
--- a/mobile/android/chrome/jar.mn
+++ b/mobile/android/chrome/jar.mn
@@ -11,16 +11,17 @@ chrome.jar:
   content/config.xhtml                 (content/config.xhtml)
   content/config.js                    (content/config.js)
   content/aboutAddons.xhtml            (content/aboutAddons.xhtml)
   content/aboutAddons.js               (content/aboutAddons.js)
   content/aboutCertError.xhtml         (content/aboutCertError.xhtml)
   content/aboutDownloads.xhtml         (content/aboutDownloads.xhtml)
   content/aboutDownloads.js            (content/aboutDownloads.js)
   content/aboutFeedback.xhtml          (content/aboutFeedback.xhtml)
+  content/aboutFeedback.js	       (content/aboutFeedback.js)
   content/aboutPrivateBrowsing.xhtml   (content/aboutPrivateBrowsing.xhtml)
   content/aboutReader.html             (content/aboutReader.html)
   content/aboutReader.js               (content/aboutReader.js)
   content/Readability.js               (content/Readability.js)
   content/JSDOMParser.js               (content/JSDOMParser.js)
   content/readerWorker.js              (content/readerWorker.js)
   content/aboutHome.xhtml              (content/aboutHome.xhtml)
   content/aboutRights.xhtml            (content/aboutRights.xhtml)