Bug 948879 - Add about.js and move inline js to it from about: page. r=gavin, r=ttaubert

This commit is contained in:
Afshin Mehrabani 2013-12-20 11:37:48 -05:00
parent 35d4903547
commit 61834d3019
3 changed files with 36 additions and 34 deletions

32
toolkit/content/about.js Normal file
View File

@ -0,0 +1,32 @@
/* 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/. */
// get release notes and vendor URL from prefs
var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"]
.getService(Components.interfaces.nsIURLFormatter);
var releaseNotesURL = formatter.formatURLPref("app.releaseNotesURL");
if (releaseNotesURL != "about:blank") {
var relnotes = document.getElementById("releaseNotesURL");
relnotes.setAttribute("href", releaseNotesURL);
relnotes.parentNode.removeAttribute("hidden");
}
var vendorURL = formatter.formatURLPref("app.vendorURL");
if (vendorURL != "about:blank") {
var vendor = document.getElementById("vendorURL");
vendor.setAttribute("href", vendorURL);
}
// insert the version of the XUL application (!= XULRunner platform version)
var versionNum = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo)
.version;
var version = document.getElementById("version");
version.textContent += " " + versionNum;
// append user agent
var ua = navigator.userAgent;
if (ua) {
document.getElementById("buildID").textContent += " " + ua;
}

View File

@ -24,7 +24,7 @@
<div id="aboutLogoContainer">
<a id="vendorURL">
<img src="about:logo" alt="&brandShortName;"/>
<p id="version"></p>
<p id="version">&about.version;</p>
</a>
</div>
@ -33,39 +33,8 @@
<li>&about.license.beforeTheLink;<a href="about:license">&about.license.linkTitle;</a>&about.license.afterTheLink;</li>
<li hidden="true">&about.relnotes.beforeTheLink;<a id="releaseNotesURL">&about.relnotes.linkTitle;</a>&about.relnotes.afterTheLink;</li>
<li>&about.buildconfig.beforeTheLink;<a href="about:buildconfig">&about.buildconfig.linkTitle;</a>&about.buildconfig.afterTheLink;</li>
<script type="application/javascript">
// get release notes and vendor URL from prefs
var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"]
.getService(Components.interfaces.nsIURLFormatter);
var releaseNotesURL = formatter.formatURLPref("app.releaseNotesURL");
if (releaseNotesURL != "about:blank") {
var relnotes = document.getElementById("releaseNotesURL");
relnotes.setAttribute("href", releaseNotesURL);
relnotes.parentNode.removeAttribute("hidden");
}
var vendorURL = formatter.formatURLPref("app.vendorURL");
if (vendorURL != "about:blank") {
var vendor = document.getElementById("vendorURL");
vendor.setAttribute("href", vendorURL);
}
// insert the version of the XUL application (!= XULRunner platform version)
var versionNum = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo)
.version;
var version = document.getElementById("version");
version.appendChild(document.createTextNode("&about.version; " + versionNum));
// append user agent
var ua = navigator.userAgent;
if (ua) {
var list = document.getElementById("aboutPageList");
var listItem = list.appendChild(document.createElement("li"));
listItem.appendChild(document.createTextNode("&about.buildIdentifier;"));
listItem.appendChild(document.createTextNode(ua));
}
</script>
<li id="buildID">&about.buildIdentifier;</li>
<script type="application/javascript" src="chrome://global/content/about.js"/>
</ul>
</body>

View File

@ -10,6 +10,7 @@ toolkit.jar:
* content/global/xul.css (xul.css)
content/global/textbox.css (textbox.css)
content/global/menulist.css (menulist.css)
content/global/about.js (about.js)
content/global/about.xhtml (about.xhtml)
content/global/aboutAbout.xhtml (aboutAbout.xhtml)
content/global/aboutRights.xhtml (aboutRights.xhtml)