mirror of
https://github.com/zen-browser/desktop.git
synced 2025-09-06 03:18:19 +00:00
Add warning for unsafed shortcuts
This commit is contained in:
2
l10n
2
l10n
Submodule l10n updated: b379e854c7...51317dbe46
@@ -757,18 +757,32 @@ var gZenCKSSettings = {
|
|||||||
const value = event.target.getAttribute(KEYBIND_ATTRIBUTE_KEY);
|
const value = event.target.getAttribute(KEYBIND_ATTRIBUTE_KEY);
|
||||||
this._currentActionID = event.target.getAttribute('data-id');
|
this._currentActionID = event.target.getAttribute('data-id');
|
||||||
event.target.classList.add(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
|
event.target.classList.add(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
|
||||||
|
this._hasSafed = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
input.addEventListener('editDone', (event) => {
|
input.addEventListener('editDone', (event) => {
|
||||||
const target = event.target;
|
const target = event.target;
|
||||||
target.classList.add(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
|
target.classList.add(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
|
||||||
this._editDone(target);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
input.addEventListener('blur', (event) => {
|
input.addEventListener('blur', (event) => {
|
||||||
const target = event.target;
|
const target = event.target;
|
||||||
target.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
|
target.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
|
||||||
this._editDone(target);
|
if (!this._hasSafed) {
|
||||||
|
target.classList.add(`${ZEN_CKS_INPUT_FIELD_CLASS}-unsafed`);
|
||||||
|
if (!target.nextElementSibling) {
|
||||||
|
target.after(window.MozXULElement.parseXULToFragment(`
|
||||||
|
<label class="${ZEN_CKS_CLASS_BASE}-unsafed" data-l10n-id="zen-key-unsafed"></label>
|
||||||
|
`));
|
||||||
|
target.value = 'Not set';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-unsafed`);
|
||||||
|
const sibling = target.nextElementSibling;
|
||||||
|
if (sibling && sibling.classList.contains(`${ZEN_CKS_CLASS_BASE}-unsafed`)) {
|
||||||
|
sibling.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const groupElem = wrapper.querySelector(`[data-group="${ZEN_CKS_GROUP_PREFIX}-${group}"]`);
|
const groupElem = wrapper.querySelector(`[data-group="${ZEN_CKS_GROUP_PREFIX}-${group}"]`);
|
||||||
@@ -829,16 +843,16 @@ var gZenCKSSettings = {
|
|||||||
}
|
}
|
||||||
if (hasConflicts && !input.nextElementSibling) {
|
if (hasConflicts && !input.nextElementSibling) {
|
||||||
input.after(window.MozXULElement.parseXULToFragment(`
|
input.after(window.MozXULElement.parseXULToFragment(`
|
||||||
<label class="${ZEN_CKS_CLASS_BASE}-conflict">Conflict with another shortcut</label>
|
<label class="${ZEN_CKS_CLASS_BASE}-conflict" data-l10n-id="zen-key-conflict"></label>
|
||||||
`));
|
`));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
|
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
|
||||||
input.blur();
|
|
||||||
|
|
||||||
this._editDone(this._latestValidKey, this._latestModifier);
|
this._editDone(this._latestValidKey, this._latestModifier);
|
||||||
this._latestValidKey = null;
|
this._latestValidKey = null;
|
||||||
this._latestModifier = null;
|
this._latestModifier = null;
|
||||||
|
this._hasSafed = true;
|
||||||
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-invalid`);
|
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-invalid`);
|
||||||
input.classList.add(`${ZEN_CKS_INPUT_FIELD_CLASS}-valid`);
|
input.classList.add(`${ZEN_CKS_INPUT_FIELD_CLASS}-valid`);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -856,10 +870,12 @@ var gZenCKSSettings = {
|
|||||||
this._resetShortcut(input);
|
this._resetShortcut(input);
|
||||||
this._latestValidKey = null;
|
this._latestValidKey = null;
|
||||||
this._latestModifier = null;
|
this._latestModifier = null;
|
||||||
|
this._hasSafed = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._latestModifier = modifiers;
|
this._latestModifier = modifiers;
|
||||||
|
this._hasSafed = false;
|
||||||
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-invalid`);
|
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-invalid`);
|
||||||
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-not-set`);
|
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-not-set`);
|
||||||
input.value = modifiers.toUserString() + shortcut;
|
input.value = modifiers.toUserString() + shortcut;
|
||||||
|
@@ -367,10 +367,20 @@ groupbox h2 {
|
|||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.zenCKSOption-unsafed {
|
||||||
|
color: yellow;
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.zenCKSOption-input.zenCKSOption-input-invalid {
|
.zenCKSOption-input.zenCKSOption-input-invalid {
|
||||||
border-color: red;
|
border-color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.zenCKSOption-input.zenCKSOption-input-unsafed {
|
||||||
|
border-color: yellow;
|
||||||
|
}
|
||||||
|
|
||||||
.zenCKSOption-input.zenCKSOption-input-valid {
|
.zenCKSOption-input.zenCKSOption-input-valid {
|
||||||
border-color: green;
|
border-color: green;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user