fix split button [re]activation

This commit is contained in:
tophf 2022-01-22 21:59:48 +03:00
parent 0e31557748
commit 60f59e9f06
4 changed files with 6 additions and 10 deletions

View File

@ -32,7 +32,7 @@ function SourceEditor() {
$('#header').on('wheel', headerOnScroll);
$('#sections').textContent = '';
$('#sections').appendChild($create('.single-editor'));
$('#save-button').onauxclick = e => e.detail === 'tpl' && saveTemplate();
$('#save-button').on('split-btn', saveTemplate);
const cm = cmFactory.create($('.single-editor'));
const sectionFinder = MozSectionFinder(cm);

View File

@ -98,7 +98,7 @@
prevPedal.classList.remove('active');
window.off('keydown', splitMenuEscape);
}
if (pedal && pedal !== prevPedal) {
if (pedal) {
const menu = $create(SPLIT_BTN_MENU,
Array.from(pedal.attributes, ({name, value}) =>
name.startsWith('menu-') &&
@ -110,13 +110,14 @@
setTimeout(splitMenu);
}
});
pedal.on('mousedown', e => e.preventDefault());
pedal.classList.toggle('active');
pedal.after(menu);
moveFocus(menu, 0);
focusAccessibility.toggle(menu.firstChild, focusAccessibility.get(pedal));
}
if (entry) {
prevPedal.previousElementSibling.dispatchEvent(new CustomEvent('auxclick', {
prevPedal.previousElementSibling.dispatchEvent(new CustomEvent('split-btn', {
detail: entry.__cmd,
bubbles: true,
}));

View File

@ -17,8 +17,7 @@
Object.assign($('#file-all-styles'), {
onclick: exportToFile,
oncontextmenu: exportToFile,
onauxclick: exportToFile,
});
}).on('split-btn', exportToFile);
$('#unfile-all-styles').onclick = () => importFromFile({fileTypeFilter: '.json'});
Object.assign(document.body, {
@ -339,9 +338,6 @@ async function importFromString(jsonString) {
/** @param {MouseEvent} e */
async function exportToFile(e) {
if (e.type === 'auxclick' && !e.detail) {
return;
}
e.preventDefault();
await require(['/js/storage-util']);
const keepDupSections = e.type === 'contextmenu' || e.shiftKey || e.detail === 'compat';

View File

@ -103,8 +103,7 @@ async function initPopup(frames) {
Object.assign($('#popup-manage-button'), {
onclick: Events.openManager,
oncontextmenu: Events.openManager,
onauxclick: Events.openManager,
});
}).on('split-btn', Events.openManager);
$('#popup-options-button').onclick = () => {
API.openManage({options: true});