From 50df192add69e844f9738adcf370f09675e2465a Mon Sep 17 00:00:00 2001 From: Frederik Braun Date: Wed, 18 Dec 2013 12:59:21 +0100 Subject: [PATCH] Bug 948894 - Move inline scripts for about:apps into AboutApps.js. r=mleibovic --- mobile/android/chrome/content/aboutApps.js | 16 +++++++++++++--- mobile/android/chrome/content/aboutApps.xhtml | 10 +++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/mobile/android/chrome/content/aboutApps.js b/mobile/android/chrome/content/aboutApps.js index 343077e429a..f2cc471425b 100644 --- a/mobile/android/chrome/content/aboutApps.js +++ b/mobile/android/chrome/content/aboutApps.js @@ -23,15 +23,17 @@ XPCOMUtils.defineLazyGetter(window, "gChromeWin", function() .getInterface(Ci.nsIDOMWindow) .QueryInterface(Ci.nsIDOMChromeWindow)); +document.addEventListener("DOMContentLoaded", onLoad, false); + var AppsUI = { uninstall: null, shortcut: null }; -function openLink(aElement) { +function openLink(aEvent) { try { let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter); - let url = formatter.formatURLPref(aElement.getAttribute("pref")); + let url = formatter.formatURLPref(aEvent.target.getAttribute("pref")); let BrowserApp = gChromeWin.BrowserApp; BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }); } catch (ex) {} @@ -41,7 +43,9 @@ var ContextMenus = { target: null, init: function() { - document.addEventListener("contextmenu", ContextMenus, false); + document.addEventListener("contextmenu", this, false); + document.getElementById("addToHomescreenLabel").addEventListener("click", this.addToHomescreen, false); + document.getElementById("uninstallLabel").addEventListener("click", this.uninstall, false); }, handleEvent: function(event) { @@ -82,6 +86,11 @@ function onLoad(aEvent) { link.setAttribute("href", url); } catch (e) {} + let elmts = document.querySelectorAll("[pref]"); + for (let i = 0; i < elmts.length; i++) { + elmts[i]..addEventListener("click", openLink, false)); + } + navigator.mozApps.mgmt.oninstall = onInstall; navigator.mozApps.mgmt.onuninstall = onUninstall; updateList(); @@ -155,3 +164,4 @@ function onUninstall(aEvent) { document.getElementById("main-container").classList.add("hidden"); } } + diff --git a/mobile/android/chrome/content/aboutApps.xhtml b/mobile/android/chrome/content/aboutApps.xhtml index d863aaa9db5..13eba766a48 100644 --- a/mobile/android/chrome/content/aboutApps.xhtml +++ b/mobile/android/chrome/content/aboutApps.xhtml @@ -27,16 +27,16 @@ - + - - + +
&aboutApps.header;
-
+
-
+
&aboutApps.browseMarketplace;