[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbutton/master] Bug 20614: Add links to Tor Browser User Manual



commit 24e2f3aa02b40274e20e27aa568c076bd74f7b2f
Author: Arthur Edelstein <arthuredelstein@xxxxxxxxx>
Date:   Fri Nov 11 20:03:15 2016 -0800

    Bug 20614: Add links to Tor Browser User Manual
---
 src/chrome/content/aboutTor/aboutTor.xhtml | 13 ++++++++++++-
 src/chrome/content/menu-overlay.xul        | 11 ++++++++++-
 src/chrome/content/torbutton.js            | 31 +++++++++++++++++++++++++++++-
 src/chrome/locale/en/aboutTor.dtd          |  2 ++
 src/chrome/locale/en/torbutton.dtd         |  2 ++
 src/chrome/skin/aboutTor.css               |  9 ++++-----
 6 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/src/chrome/content/aboutTor/aboutTor.xhtml b/src/chrome/content/aboutTor/aboutTor.xhtml
index 2fffb2a..2c823b5 100644
--- a/src/chrome/content/aboutTor/aboutTor.xhtml
+++ b/src/chrome/content/aboutTor/aboutTor.xhtml
@@ -241,7 +241,18 @@ window.addEventListener("pageshow", function() {
     <div class="bubble">
       <h1>&aboutTor.whatnextQuestion.label;</h1>
       <p>&aboutTor.whatnextAnswer.label;</p>
-      <a class="tips" href="&aboutTor.whatnext.link;">&aboutTor.whatnext.label;</a>
+      <ul>
+        <li>
+          <a href="&aboutTor.whatnext.link;">
+            &aboutTor.whatnext.label;
+          </a>
+        </li>
+        <li class="showForManual">
+          <a href="&aboutTor.torbrowser_user_manual.link;">
+            &aboutTor.torbrowser_user_manual.label;
+          </a>
+        </li>
+      </ul>
     </div>
 
     <div class="bubble">
diff --git a/src/chrome/content/menu-overlay.xul b/src/chrome/content/menu-overlay.xul
index ceadf85..8067b5c 100644
--- a/src/chrome/content/menu-overlay.xul
+++ b/src/chrome/content/menu-overlay.xul
@@ -1,9 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?> <!-- -*- Mode: HTML -*- -->
 
-<!-- Bug 18905: Hide unused help menu items -->
+<!DOCTYPE overlay SYSTEM "chrome://torbutton/locale/torbutton.dtd">
+
 <overlay id="torbutton-menu-overlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";>
   <menupopup id="menu_HelpPopup">
+    <!-- Bug 18905: Hide unused help menu items -->
     <menuitem id="menu_openHelp" removeelement="true"/>
     <menuitem id="menu_openTour" removeelement="true"/>
     <menuitem id="healthReport" removeelement="true"/>
@@ -14,5 +16,12 @@
     <!-- dummy elements to avoid 'getElementById' errors -->
     <box id="menu_HelpPopup_reportPhishingtoolmenu"/>
     <box id="menu_HelpPopup_reportPhishingErrortoolmenu"/>
+    <!-- Add Tor Browser manual link -->
+    <menuitem name="torBrowserUserManual"
+              id="torBrowserUserManual"
+              position="1"
+              label="&torbutton.torbrowser_user_manual.label;"
+              accesskey="&torbutton.torbrowser_user_manual.accesskey;"
+              oncommand="torbutton_open_torbrowser_user_manual()" />
   </menupopup>
 </overlay>
diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 7de599d..139cb41 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -12,6 +12,7 @@ let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
 let { showDialog } = Cu.import("resource://torbutton/modules/utils.js", {});
 let { unescapeTorString } = Cu.import("resource://torbutton/modules/utils.js", {});
 let SecurityPrefs = Cu.import("resource://torbutton/modules/security-prefs.js", {});
+let { bindPrefAndInit } = Cu.import("resource://torbutton/modules/utils.js", {});
 
 const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion";
 const k_tb_browser_update_needed_pref = "extensions.torbutton.updateNeeded";
@@ -362,7 +363,7 @@ function torbutton_init() {
     window.addEventListener("aftercustomization", function() {
       torbutton_update_all_abouttor_pages(undefined, undefined);
     }, false);
-    
+
     //setting up context menu
     //var contextMenu = document.getElementById("contentAreaContextMenu");
     //if (contextMenu)
@@ -399,6 +400,8 @@ function torbutton_init() {
 
     quantizeBrowserSize(window, 100, 100);
 
+    torbutton_init_user_manual_links();
+
     torbutton_log(3, 'init completed');
 }
 
@@ -630,6 +633,11 @@ function torbutton_update_abouttor_doc(aDoc, aTorOn, aUpdateNeeded) {
     else
       aDoc.body.removeAttribute("torNeedsUpdate");
 
+    if (torbutton_show_torbrowser_manual())
+      aDoc.body.setAttribute("showmanual", "yes");
+    else
+      aDoc.body.removeAttribute("showmanual");
+
     // Display product name and TBB version.
     try {
       const kBrandBundle = "chrome://branding/locale/brand.properties";
@@ -2437,5 +2445,26 @@ function torbutton_update_noscript_button()
   }, 0);
 }
 
+// Opens the Tor Browser User Manual in a new tab
+function torbutton_open_torbrowser_user_manual() {
+  gBrowser.selectedTab = gBrowser.addTab("https://tb-manual.torproject.org";);
+}
+
+// Returns true if we should show the tor browser manual.
+function torbutton_show_torbrowser_manual() {
+  let locale = torbutton_get_general_useragent_locale();
+  return locale.startsWith("en");
+}
+
+// Makes sure the item in the Help Menu and the link in about:tor
+// for the Tor Browser User Manual are only visible when
+// torbutton_show_torbrowser_manual() returns true.
+function torbutton_init_user_manual_links() {
+  let menuitem = document.getElementById("torBrowserUserManual");
+  bindPrefAndInit("general.useragent.locale", val => {
+    menuitem.hidden = !torbutton_show_torbrowser_manual();
+    torbutton_update_all_abouttor_pages(undefined, undefined);
+  });
+}
 
 //vim:set ts=4
diff --git a/src/chrome/locale/en/aboutTor.dtd b/src/chrome/locale/en/aboutTor.dtd
index 12313c4..9e44fc2 100644
--- a/src/chrome/locale/en/aboutTor.dtd
+++ b/src/chrome/locale/en/aboutTor.dtd
@@ -32,6 +32,8 @@
 <!ENTITY aboutTor.whatnextAnswer.label "Tor is NOT all you need to browse anonymously! You may need to change some of your browsing habits to ensure your identity stays safe.">
 <!ENTITY aboutTor.whatnext.label "Tips On Staying Anonymous »">
 <!ENTITY aboutTor.whatnext.link "https://www.torproject.org/download/download.html.en#warning";>
+<!ENTITY aboutTor.torbrowser_user_manual.label "Tor Browser User Manual »">
+<!ENTITY aboutTor.torbrowser_user_manual.link "https://tb-manual.torproject.org";>
 <!ENTITY aboutTor.helpInfo1.label "You Can Help!">
 <!ENTITY aboutTor.helpInfo2.label "There are many ways you can help make the Tor Network faster and stronger:">
 <!ENTITY aboutTor.helpInfo3.label "Run a Tor Relay Node »">
diff --git a/src/chrome/locale/en/torbutton.dtd b/src/chrome/locale/en/torbutton.dtd
index 97a994f..c67ec6e 100644
--- a/src/chrome/locale/en/torbutton.dtd
+++ b/src/chrome/locale/en/torbutton.dtd
@@ -59,3 +59,5 @@
 <!ENTITY torbutton.prefs.sec_webfonts_desc "Some fonts and icons may display incorrectly.">
 <!ENTITY torbutton.prefs.sec_webfonts_desc_tooltip "Website-provided font files are blocked.">
 <!ENTITY torbutton.circuit_display.title "Tor circuit for this site">
+<!ENTITY torbutton.torbrowser_user_manual.label "Tor Browser User Manual">
+<!ENTITY torbutton.torbrowser_user_manual.accesskey "M">
diff --git a/src/chrome/skin/aboutTor.css b/src/chrome/skin/aboutTor.css
index 0a196dc..3f747a9 100644
--- a/src/chrome/skin/aboutTor.css
+++ b/src/chrome/skin/aboutTor.css
@@ -132,6 +132,10 @@ body[toron] .top h1 {
   color: #600060;
 }
 
+body:not([showmanual]) .showForManual {
+  display: none;
+}
+
 div.hideIfTorIsUpToDate,
 body .top div.hideIfTorIsUpToDate h1 {
   color: black;
@@ -201,11 +205,6 @@ body .top div.hideIfTorIsUpToDate h1.hideIfTorOff {
   margin-bottom: 10px;
 }
 
-#middle a.tips {
-  display: block;
-  margin-top: 1.6em;
-}
-
 #middle ul {
   padding: 5px 0 0 22px;
 }

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits