Browse Source

[#1074] Make Language Specific Favicons Optional
- adds noDocSpecificIcon property to app settings
- adds option to user Settings page
- updates setFaviconForDoc method to return early when setting is active

Aoibhe Wilson 10 months ago
parent
commit
5add0f9b62

+ 2 - 0
assets/javascripts/app/settings.js

@@ -16,6 +16,7 @@ app.Settings = class Settings {
     "autoInstall",
     "spaceScroll",
     "spaceTimeout",
+    "noDocSpecificIcon",
   ];
 
   static INTERNAL_KEYS = ["count", "schema", "version", "news"];
@@ -38,6 +39,7 @@ app.Settings = class Settings {
     theme: "auto",
     spaceScroll: 1,
     spaceTimeout: 0.5,
+    noDocSpecificIcon: false,
   };
 
   constructor() {

+ 1 - 1
assets/javascripts/lib/favicon.js

@@ -19,7 +19,7 @@ const withImage = function (url, action) {
 };
 
 this.setFaviconForDoc = function (doc) {
-  if (currentSlug === doc.slug) {
+  if (currentSlug === doc.slug || app.settings.get("noDocSpecificIcon")) {
     return;
   }
 

+ 6 - 0
assets/javascripts/templates/pages/settings_tmpl.js

@@ -66,6 +66,12 @@ app.templates.settingsPage = (settings) => `\
       }>Enable tracking cookies
       <small>With this checked, we enable Google Analytics and Gauges to collect anonymous traffic information.</small>
     </label>
+    <label class="_settings-label _hide-on-mobile">
+      <input type="checkbox" form="settings" name="noDocSpecificIcon"${
+        settings.noDocSpecificIcon ? " checked" : ""
+      }>Disable Language-specific Doc Favicons
+      <small>With this checked, we will display the default DevDocs icon for all pages.</small>
+    </label>
   </div>
 </div>
 

+ 1 - 0
assets/javascripts/views/content/settings_page.js

@@ -20,6 +20,7 @@ app.views.SettingsPage = class SettingsPage extends app.View {
     settings.analyticsConsent = app.settings.get("analyticsConsent");
     settings.spaceScroll = app.settings.get("spaceScroll");
     settings.spaceTimeout = app.settings.get("spaceTimeout");
+    settings.noDocSpecificIcon = app.settings.get("noDocSpecificIcon");
     settings.autoSupported = app.settings.autoSupported;
     for (var layout of app.Settings.LAYOUTS) {
       settings[layout] = app.settings.hasLayout(layout);