mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Event bug fixes
This commit is contained in:
parent
e9d7a8363c
commit
d6159cc154
3 changed files with 22 additions and 9 deletions
|
@ -166,6 +166,8 @@ class Manager {
|
||||||
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
|
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
|
||||||
this.addListeners("#clr-io,#btn-close-all-tabs", "click", this.input.clearAllIoClick, this.input);
|
this.addListeners("#clr-io,#btn-close-all-tabs", "click", this.input.clearAllIoClick, this.input);
|
||||||
this.addListeners("#open-file,#open-folder", "change", this.input.inputOpen, this.input);
|
this.addListeners("#open-file,#open-folder", "change", this.input.inputOpen, this.input);
|
||||||
|
document.getElementById("btn-open-file").addEventListener("click", this.input.inputOpenClick.bind(this.input));
|
||||||
|
document.getElementById("btn-open-folder").addEventListener("click", this.input.folderOpenClick.bind(this.input));
|
||||||
this.addListeners("#input-wrapper", "dragover", this.input.inputDragover, this.input);
|
this.addListeners("#input-wrapper", "dragover", this.input.inputDragover, this.input);
|
||||||
this.addListeners("#input-wrapper", "dragleave", this.input.inputDragleave, this.input);
|
this.addListeners("#input-wrapper", "dragleave", this.input.inputDragleave, this.input);
|
||||||
this.addListeners("#input-wrapper", "drop", this.input.inputDrop, this.input);
|
this.addListeners("#input-wrapper", "drop", this.input.inputDrop, this.input);
|
||||||
|
@ -187,8 +189,6 @@ class Manager {
|
||||||
document.getElementById("input-num-results").addEventListener("keyup", this.input.filterTabSearch.bind(this.input));
|
document.getElementById("input-num-results").addEventListener("keyup", this.input.filterTabSearch.bind(this.input));
|
||||||
document.getElementById("input-filter-refresh").addEventListener("click", this.input.filterTabSearch.bind(this.input));
|
document.getElementById("input-filter-refresh").addEventListener("click", this.input.filterTabSearch.bind(this.input));
|
||||||
this.addDynamicListener(".input-filter-result", "click", this.input.filterItemClick, this.input);
|
this.addDynamicListener(".input-filter-result", "click", this.input.filterItemClick, this.input);
|
||||||
document.getElementById("btn-open-file").addEventListener("click", this.input.inputOpenClick.bind(this.input));
|
|
||||||
document.getElementById("btn-open-folder").addEventListener("click", this.input.folderOpenClick.bind(this.input));
|
|
||||||
|
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
|
|
|
@ -138,7 +138,6 @@ class PanelGroup {
|
||||||
this.dom = undefined;
|
this.dom = undefined;
|
||||||
this.classes = "";
|
this.classes = "";
|
||||||
this.panels = [];
|
this.panels = [];
|
||||||
this.bufferWidth = 0;
|
|
||||||
this.syncClasses();
|
this.syncClasses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,6 +158,7 @@ class PanelGroup {
|
||||||
if (this.dom) {
|
if (this.dom) {
|
||||||
this.dom.remove();
|
this.dom.remove();
|
||||||
this.dom = undefined;
|
this.dom = undefined;
|
||||||
|
this.setScrollerMargin(0);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -171,21 +171,30 @@ class PanelGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
let curDOM = this.dom.firstChild;
|
let curDOM = this.dom.firstChild;
|
||||||
|
let bufferWidth = 0;
|
||||||
for (const panel of this.panels) {
|
for (const panel of this.panels) {
|
||||||
|
bufferWidth += panel.width;
|
||||||
if (panel.dom.parentNode === this.dom) {
|
if (panel.dom.parentNode === this.dom) {
|
||||||
while (curDOM !== panel.dom) curDOM = rm(curDOM);
|
while (curDOM !== panel.dom) curDOM = rm(curDOM);
|
||||||
curDOM = curDOM.nextSibling;
|
curDOM = curDOM.nextSibling;
|
||||||
} else {
|
} else {
|
||||||
this.dom.insertBefore(panel.dom, curDOM);
|
this.dom.insertBefore(panel.dom, curDOM);
|
||||||
this.bufferWidth = panel.width;
|
|
||||||
panel.dom.style.width = panel.width + "px";
|
panel.dom.style.width = panel.width + "px";
|
||||||
this.dom.style.width = this.bufferWidth + "px";
|
this.dom.style.width = bufferWidth + "px";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (curDOM) curDOM = rm(curDOM);
|
while (curDOM) curDOM = rm(curDOM);
|
||||||
|
|
||||||
|
this.setScrollerMargin(bufferWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the margin of the cm-scroller element to make room for the panel
|
||||||
|
*/
|
||||||
|
setScrollerMargin(width) {
|
||||||
|
const parent = this.container || this.view.dom;
|
||||||
const margin = this.left ? "marginLeft" : "marginRight";
|
const margin = this.left ? "marginLeft" : "marginRight";
|
||||||
parent.querySelector(".cm-scroller").style[margin] = this.bufferWidth + "px";
|
parent.querySelector(".cm-scroller").style[margin] = width + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -805,10 +805,11 @@ class InputWaiter {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Dragleave often fires when moving between lines in the editor.
|
// Dragleave often fires when moving between lines in the editor.
|
||||||
// If the target element is within the input-text element, we are still on target.
|
// If the from element is within the input-text element, we are still on target.
|
||||||
if (!this.inputTextEl.contains(e.target))
|
if (!this.inputTextEl.contains(e.fromElement)) {
|
||||||
e.target.closest("#input-text").classList.remove("dropping-file");
|
e.target.closest("#input-text").classList.remove("dropping-file");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for input drop events.
|
* Handler for input drop events.
|
||||||
|
@ -994,6 +995,9 @@ class InputWaiter {
|
||||||
if (changeOutput) {
|
if (changeOutput) {
|
||||||
this.manager.output.changeTab(inputNum, false);
|
this.manager.output.changeTab(inputNum, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set cursor focus to current tab
|
||||||
|
this.inputEditorView.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1108,7 +1112,7 @@ class InputWaiter {
|
||||||
* @param {number} inputNum - The inputNum of the new tab
|
* @param {number} inputNum - The inputNum of the new tab
|
||||||
* @param {boolean} [changeTab=true] - If true, changes to the new tab once it's been added
|
* @param {boolean} [changeTab=true] - If true, changes to the new tab once it's been added
|
||||||
*/
|
*/
|
||||||
addTab(inputNum, changeTab = true) {
|
addTab(inputNum, changeTab=true) {
|
||||||
const tabsWrapper = document.getElementById("input-tabs"),
|
const tabsWrapper = document.getElementById("input-tabs"),
|
||||||
numTabs = tabsWrapper.children.length;
|
numTabs = tabsWrapper.children.length;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue