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); $('#header').on('wheel', headerOnScroll);
$('#sections').textContent = ''; $('#sections').textContent = '';
$('#sections').appendChild($create('.single-editor')); $('#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 cm = cmFactory.create($('.single-editor'));
const sectionFinder = MozSectionFinder(cm); const sectionFinder = MozSectionFinder(cm);

View File

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

View File

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