()
| 869 | }, |
| 870 | |
| 871 | async _initializeCKS() { |
| 872 | let wrapper = document.getElementById(ZEN_CKS_WRAPPER_ID); |
| 873 | wrapper.innerHTML = ""; |
| 874 | |
| 875 | let shortcuts = await gZenKeyboardShortcutsManager.getModifiableShortcuts(); |
| 876 | |
| 877 | if (!shortcuts) { |
| 878 | throw Error("No shortcuts defined!"); |
| 879 | } |
| 880 | |
| 881 | // Generate section per each group |
| 882 | for (let group of VALID_SHORTCUT_GROUPS) { |
| 883 | let groupClass = `${ZEN_CKS_GROUP_PREFIX}-${group}`; |
| 884 | if (!wrapper.querySelector(`[data-group="${groupClass}"]`)) { |
| 885 | let groupElem = document.createElement("h2"); |
| 886 | groupElem.setAttribute("data-group", groupClass); |
| 887 | document.l10n.setAttributes(groupElem, groupClass); |
| 888 | wrapper.appendChild(groupElem); |
| 889 | } |
| 890 | } |
| 891 | |
| 892 | for (let shortcut of shortcuts) { |
| 893 | const keyID = shortcut.getID(); |
| 894 | const action = shortcut.getAction(); |
| 895 | const l10nID = shortcut.getL10NID(); |
| 896 | const group = shortcut.getGroup(); |
| 897 | const keyInString = shortcut.toDisplayString(); |
| 898 | |
| 899 | const labelValue = zenMissingKeyboardShortcutL10n[keyID] ?? l10nID; |
| 900 | |
| 901 | if ( |
| 902 | zenIgnoreKeyboardShortcutIDs.includes(keyID) || |
| 903 | zenIgnoreKeyboardShortcutL10n.includes(labelValue) || |
| 904 | shortcut.shouldBeEmpty |
| 905 | ) { |
| 906 | continue; |
| 907 | } |
| 908 | |
| 909 | let fragment = window.MozXULElement.parseXULToFragment(` |
| 910 | <hbox class="${ZEN_CKS_CLASS_BASE}"> |
| 911 | <label class="${ZEN_CKS_LABEL_CLASS}" for="${ZEN_CKS_CLASS_BASE}-${keyID}"></label> |
| 912 | <vbox flex="1"> |
| 913 | <html:input readonly="1" class="${ZEN_CKS_INPUT_FIELD_CLASS}" id="${ZEN_CKS_INPUT_FIELD_CLASS}-${keyID}" /> |
| 914 | </vbox> |
| 915 | </hbox> |
| 916 | `); |
| 917 | |
| 918 | const label = fragment.querySelector(`.${ZEN_CKS_LABEL_CLASS}`); |
| 919 | if (!labelValue) { |
| 920 | label.textContent = action; // Just in case |
| 921 | } else { |
| 922 | document.l10n.setAttributes(label, labelValue); |
| 923 | } |
| 924 | |
| 925 | let input = fragment.querySelector(`.${ZEN_CKS_INPUT_FIELD_CLASS}`); |
| 926 | if (keyInString && !shortcut.isEmpty()) { |
| 927 | input.value = keyInString; |
| 928 | } else { |
nothing calls this directly
no test coverage detected