mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 17:30:14 +02:00
refactor: Disable Firefox shortcuts in ZenKeyboardShortcuts
This commit is contained in:
parent
f349477728
commit
b1d5b8e642
2 changed files with 29 additions and 3 deletions
|
@ -135,10 +135,35 @@ var gZenKeyboardShortcuts = {
|
||||||
_initShortcuts() {
|
_initShortcuts() {
|
||||||
if (window.location.href == "chrome://browser/content/browser.xhtml") {
|
if (window.location.href == "chrome://browser/content/browser.xhtml") {
|
||||||
Services.prefs.addObserver(kZKSStorageKey, this._initSavedShortcuts.bind(this));
|
Services.prefs.addObserver(kZKSStorageKey, this._initSavedShortcuts.bind(this));
|
||||||
|
Services.prefs.addObserver("zen.keyboard.shortcuts.disable-firefox", this._disableFirefoxShortcuts.bind(this));
|
||||||
this._initSavedShortcuts();
|
this._initSavedShortcuts();
|
||||||
|
this._disableFirefoxShortcuts();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_disableFirefoxShortcuts() {
|
||||||
|
let disable = Services.prefs.getBoolPref("zen.keyboard.shortcuts.disable-firefox");
|
||||||
|
let keySet = document.getElementById("mainKeyset");
|
||||||
|
if (!keySet) {
|
||||||
|
throw new Error("Zen CKS: No main keyset found");
|
||||||
|
}
|
||||||
|
if (disable) {
|
||||||
|
console.log("Zen CKS: Disabling Firefox shortcuts");
|
||||||
|
for (let child of keySet.children) {
|
||||||
|
if (!child.id.startsWith("zen-key_")) {
|
||||||
|
child.setAttribute("disabled", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_getCommandAttribute(action) {
|
||||||
|
if (action.startsWith("command:")) {
|
||||||
|
return `command="${action.substring(8)}"`;
|
||||||
|
}
|
||||||
|
return `oncommand="${action}"`;
|
||||||
|
},
|
||||||
|
|
||||||
_createShortcutElement(_action) {
|
_createShortcutElement(_action) {
|
||||||
let shortcut = this._savedShortcuts[_action];
|
let shortcut = this._savedShortcuts[_action];
|
||||||
if (!shortcut) {
|
if (!shortcut) {
|
||||||
|
@ -163,8 +188,8 @@ var gZenKeyboardShortcuts = {
|
||||||
<key
|
<key
|
||||||
id="zen-key_${_action}"
|
id="zen-key_${_action}"
|
||||||
class="zen-keyboard-shortcut"
|
class="zen-keyboard-shortcut"
|
||||||
keycode="${keycode}"
|
keycode="${key}"
|
||||||
oncommand="${action}"
|
${this._getCommandAttribute(action)}
|
||||||
modifiers="${modifiers}"/>
|
modifiers="${modifiers}"/>
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
@ -174,7 +199,7 @@ var gZenKeyboardShortcuts = {
|
||||||
id="zen-key_${_action}"
|
id="zen-key_${_action}"
|
||||||
class="zen-keyboard-shortcut"
|
class="zen-keyboard-shortcut"
|
||||||
key="${key}"
|
key="${key}"
|
||||||
oncommand="${action}"
|
${this._getCommandAttribute(action)}
|
||||||
modifiers="${modifiers}"/>
|
modifiers="${modifiers}"/>
|
||||||
`);
|
`);
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,6 +3,7 @@ const kZenAccentColorConfigKey = "zen.theme.accent-color";
|
||||||
|
|
||||||
var gZenThemeBuilder = {
|
var gZenThemeBuilder = {
|
||||||
init() {
|
init() {
|
||||||
|
return; // TODO:
|
||||||
this._mouseMoveListener = this._handleThumbMouseMove.bind(this);
|
this._mouseMoveListener = this._handleThumbMouseMove.bind(this);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this._initBuilderUI();
|
this._initBuilderUI();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue