Bug 948896 - Move inline scripts and styles into separate file for mobile/android/chrome/content/aboutDownloads.xhtml (about:downloads). r=margaret
authorMadushan Nishantha <j.l.madushan@gmail.com>
Tue, 18 Feb 2014 09:20:25 -0500
changeset 169696 2cc946bb55c479aa99bece8b0cabf9c12ab1f14b
parent 169695 1ca7f4e8fd0fc16c798fdff16c410c0cd165c8af
child 169697 627fac32b0d50a3f57e45d4a3db921799a5461e9
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmargaret
bugs948896
milestone30.0a1
Bug 948896 - Move inline scripts and styles into separate file for mobile/android/chrome/content/aboutDownloads.xhtml (about:downloads). r=margaret
mobile/android/chrome/content/aboutDownloads.js
mobile/android/chrome/content/aboutDownloads.xhtml
--- a/mobile/android/chrome/content/aboutDownloads.js
+++ b/mobile/android/chrome/content/aboutDownloads.js
@@ -39,16 +39,23 @@ XPCOMUtils.defineLazyGetter(window, "gCh
     .QueryInterface(Ci.nsIDOMChromeWindow));
 
 
 var ContextMenus = {
   target: null,
 
   init: function() {
     document.addEventListener("contextmenu", this, false);
+    document.getElementById("contextmenu-open").addEventListener("click", this.open.bind(this), false);
+    document.getElementById("contextmenu-retry").addEventListener("click", this.retry.bind(this), false);
+    document.getElementById("contextmenu-remove").addEventListener("click", this.remove.bind(this), false);
+    document.getElementById("contextmenu-pause").addEventListener("click", this.pause.bind(this), false);
+    document.getElementById("contextmenu-resume").addEventListener("click", this.resume.bind(this), false);
+    document.getElementById("contextmenu-cancel").addEventListener("click", this.cancel.bind(this), false);
+    document.getElementById("contextmenu-removeall").addEventListener("click", this.removeAll.bind(this), false);
     this.items = [
       { name: "open", states: [Downloads._dlmgr.DOWNLOAD_FINISHED] },
       { name: "retry", states: [Downloads._dlmgr.DOWNLOAD_FAILED, Downloads._dlmgr.DOWNLOAD_CANCELED] },
       { name: "remove", states: [Downloads._dlmgr.DOWNLOAD_FINISHED,Downloads._dlmgr.DOWNLOAD_FAILED, Downloads._dlmgr.DOWNLOAD_CANCELED] },
       { name: "removeall", states: [Downloads._dlmgr.DOWNLOAD_FINISHED,Downloads._dlmgr.DOWNLOAD_FAILED, Downloads._dlmgr.DOWNLOAD_CANCELED] },
       { name: "pause", states: [Downloads._dlmgr.DOWNLOAD_DOWNLOADING] },
       { name: "resume", states: [Downloads._dlmgr.DOWNLOAD_PAUSED] },
       { name: "cancel", states: [Downloads._dlmgr.DOWNLOAD_DOWNLOADING, Downloads._dlmgr.DOWNLOAD_NOTSTARTED, Downloads._dlmgr.DOWNLOAD_QUEUED, Downloads._dlmgr.DOWNLOAD_PAUSED] },
@@ -594,8 +601,13 @@ let Downloads = {
 
   QueryInterface: function (aIID) {
     if (!aIID.equals(Ci.nsIDownloadProgressListener) &&
         !aIID.equals(Ci.nsISupports))
       throw Components.results.NS_ERROR_NO_INTERFACE;
     return this;
   }
 }
+
+document.addEventListener("DOMContentLoaded", Downloads.init.bind(Downloads), true);
+window.addEventListener("unload", Downloads.uninit.bind(Downloads), false);
+
+
--- a/mobile/android/chrome/content/aboutDownloads.xhtml
+++ b/mobile/android/chrome/content/aboutDownloads.xhtml
@@ -19,25 +19,25 @@
 <head>
   <title>&aboutDownloads.title;</title>
   <meta name="viewport" content="width=device-width; user-scalable=0" />
   <link rel="icon" type="image/png" sizes="64x64" href="chrome://branding/content/favicon64.png" />
   <link rel="stylesheet" href="chrome://browser/skin/aboutBase.css" type="text/css"/>
   <link rel="stylesheet" href="chrome://browser/skin/aboutDownloads.css" type="text/css"/>
 </head>
 
-<body dir="&locale.dir;" onload="Downloads.init();" onunload="Downloads.uninit();">
+<body dir="&locale.dir;">
   <menu type="context" id="downloadmenu">
-    <menuitem id="contextmenu-open" label="&aboutDownloads.open;" onclick="ContextMenus.open();"></menuitem>
-    <menuitem id="contextmenu-retry" label="&aboutDownloads.retry;" onclick="ContextMenus.retry();"></menuitem>
-    <menuitem id="contextmenu-remove" label="&aboutDownloads.remove;" onclick="ContextMenus.remove();"></menuitem>
-    <menuitem id="contextmenu-pause" label="&aboutDownloads.pause;" onclick="ContextMenus.pause();"></menuitem>
-    <menuitem id="contextmenu-resume" label="&aboutDownloads.resume;" onclick="ContextMenus.resume();"></menuitem>
-    <menuitem id="contextmenu-cancel" label="&aboutDownloads.cancel;" onclick="ContextMenus.cancel();"></menuitem>
-    <menuitem id="contextmenu-removeall" label="&aboutDownloads.removeAll;" onclick="ContextMenus.removeAll();"></menuitem>
+    <menuitem id="contextmenu-open" label="&aboutDownloads.open;"></menuitem>
+    <menuitem id="contextmenu-retry" label="&aboutDownloads.retry;"></menuitem>
+    <menuitem id="contextmenu-remove" label="&aboutDownloads.remove;"></menuitem>
+    <menuitem id="contextmenu-pause" label="&aboutDownloads.pause;"></menuitem>
+    <menuitem id="contextmenu-resume" label="&aboutDownloads.resume;"></menuitem>
+    <menuitem id="contextmenu-cancel" label="&aboutDownloads.cancel;"></menuitem>
+    <menuitem id="contextmenu-removeall" label="&aboutDownloads.removeAll;"></menuitem>
   </menu>
 
   <div class="header">
     <div>&aboutDownloads.header;</div>
   </div>
   <ul id="private-downloads-list" class="list"></ul>
   <ul id="normal-downloads-list" class="list"></ul>
   <span id="no-downloads-indicator">&aboutDownloads.empty;</span>