From 5167ac2d6f7bf84708dec0e251e2fab8bc5c10d9 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 10 Jan 2024 05:57:25 -0500 Subject: [PATCH] Restore Dev/Troubleshooting Mode warning after redesign Show label after tabs menu, and adjust Troubleshooting Mode color for dark mode --- chrome/content/zotero/zoteroPane.js | 41 ++++++++++++++++------------- scss/components/_toolbar.scss | 15 +++++++++++ 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 68efc70888..2c055a2423 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -450,28 +450,31 @@ var ZoteroPane = new function() // Show warning in toolbar for 'dev' channel builds and troubleshooting mode try { + let afterElement = 'zotero-tb-tabs-menu'; let isDevBuild = Zotero.version.includes('-dev'); + let isSafeMode = Services.appinfo.inSafeMode; // Uncomment to test //isDevBuild = true; - if (isDevBuild) { - let label = document.createXULElement('label'); - label.setAttribute('style', 'font-weight: bold; color: red; cursor: pointer; margin: 0 .5em 0 1em'); - label.onclick = function () { - Zotero.launchURL('https://www.zotero.org/support/kb/test_builds'); - }; - label.value = 'TEST BUILD — DO NOT USE'; - let syncError = document.getElementById('zotero-tb-sync-error'); - syncError.parentNode.insertBefore(label, syncError); - } - else if (Services.appinfo.inSafeMode) { - let label = document.createElement('span'); - label.setAttribute('style', 'font-weight: bold; color: darkblue; cursor: pointer; margin-right: .5em'); - label.onclick = function () { - Zotero.Utilities.Internal.quit(true); - }; - label.textContent = 'Troubleshooting Mode'; - let syncStop = document.getElementById('zotero-tb-sync-stop'); - syncStop.parentNode.insertBefore(label, syncStop); + //isSafeMode = true; + if (isDevBuild || isSafeMode) { + let label = document.createElement('div'); + label.className = "toolbar-mode-warning"; + let msg = ''; + if (isDevBuild) { + label.onclick = function () { + Zotero.launchURL('https://www.zotero.org/support/kb/test_builds'); + }; + msg = 'TEST BUILD — DO NOT USE'; + } + else if (isSafeMode) { + label.classList.add('safe-mode'); + label.onclick = function () { + Zotero.Utilities.Internal.quit(true); + }; + msg = 'Troubleshooting Mode'; + } + label.textContent = msg; + document.getElementById(afterElement).after(label); } } catch (e) { diff --git a/scss/components/_toolbar.scss b/scss/components/_toolbar.scss index af7356dfd9..c2aa7f8582 100644 --- a/scss/components/_toolbar.scss +++ b/scss/components/_toolbar.scss @@ -113,3 +113,18 @@ .zotero-tb-button { -moz-user-focus: normal; } + +/* Label in toolbar for dev mode or troubleshooting mode */ +.toolbar-mode-warning { + font-weight: bold; + cursor: pointer; + margin: 0 .8em 0 .2em; + color: red; + + &.safe-mode { + color: darkblue; + @media (prefers-color-scheme: dark) { + color: lightblue; + } + } +}