mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-10 16:25:01 -04:00
fuse desktop/mobile splitters into one function, update accordingly across files
This commit is contained in:
parent
47c8af7284
commit
bf27cbb641
5 changed files with 32 additions and 76 deletions
|
@ -251,56 +251,40 @@ class App {
|
||||||
if (this.isMobileView()) {
|
if (this.isMobileView()) {
|
||||||
this.setMobileUI();
|
this.setMobileUI();
|
||||||
} else {
|
} else {
|
||||||
this.setDesktopUI(false);
|
this.setDesktopUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set desktop splitters
|
* Set splitter
|
||||||
*
|
*
|
||||||
* @param {boolean} minimise
|
* We don't actually functionally use splitters on mobile, but we leverage the splitters
|
||||||
|
* to create our desired layout. This prevents some problems when resizing
|
||||||
|
* from mobile to desktop and vice versa and reduces code complexity
|
||||||
*/
|
*/
|
||||||
setDesktopSplitter(minimise) {
|
setSplitter() {
|
||||||
if (this.columnSplitter) this.columnSplitter.destroy();
|
if (this.columnSplitter) this.columnSplitter.destroy();
|
||||||
if (this.ioSplitter) this.ioSplitter.destroy();
|
if (this.ioSplitter) this.ioSplitter.destroy();
|
||||||
|
|
||||||
|
const isMobileView = this.isMobileView();
|
||||||
|
|
||||||
this.columnSplitter = Split(["#operations", "#recipe", "#IO"], {
|
this.columnSplitter = Split(["#operations", "#recipe", "#IO"], {
|
||||||
sizes: [20, 40, 40],
|
sizes: isMobileView ? [100, 100, 100] : [20, 40, 40],
|
||||||
minSize: minimise ? [0, 0, 0] : [360, 330, 310],
|
minSize: [360, 330, 310],
|
||||||
gutterSize: 4,
|
gutterSize: isMobileView ? 0 : 4,
|
||||||
expandToMin: true,
|
expandToMin: true,
|
||||||
onDrag: debounce(() => {
|
onDrag: debounce(() => {
|
||||||
this.adjustComponentSizes();
|
if (!isMobileView) {
|
||||||
|
this.manager.input.calcMaxTabs();
|
||||||
|
this.manager.output.calcMaxTabs();
|
||||||
|
}
|
||||||
}, 50, "dragSplitter", this, [])
|
}, 50, "dragSplitter", this, [])
|
||||||
});
|
});
|
||||||
|
|
||||||
this.ioSplitter = Split(["#input", "#output"], {
|
this.ioSplitter = Split(["#input", "#output"], {
|
||||||
direction: "vertical",
|
direction: "vertical",
|
||||||
gutterSize: 4,
|
gutterSize: isMobileView ? 0 : 4,
|
||||||
minSize: minimise ? [0, 0] : [50, 50]
|
minSize: [50, 50]
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set mobile layout
|
|
||||||
*
|
|
||||||
* We don't actually use splitters on mobile, but we leverage the splitters
|
|
||||||
* to create our desired layout. This prevents some problems when resizing
|
|
||||||
* from mobile to desktop and vice versa
|
|
||||||
*/
|
|
||||||
setMobileSplitter() {
|
|
||||||
if (this.columnSplitter) this.columnSplitter.destroy();
|
|
||||||
if (this.ioSplitter) this.ioSplitter.destroy();
|
|
||||||
|
|
||||||
this.columnSplitter = Split(["#operations", "#recipe", "#IO"], {
|
|
||||||
sizes: [100, 100, 100],
|
|
||||||
gutterSize: 0,
|
|
||||||
expandToMin: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.ioSplitter = Split(["#input", "#output"], {
|
|
||||||
direction: "vertical",
|
|
||||||
gutterSize: 0,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +415,6 @@ class App {
|
||||||
updateFavourites(favourites, isExpanded = false) {
|
updateFavourites(favourites, isExpanded = false) {
|
||||||
this.saveFavourites(favourites);
|
this.saveFavourites(favourites);
|
||||||
this.loadFavourites();
|
this.loadFavourites();
|
||||||
|
|
||||||
this.buildFavouritesCategory(isExpanded);
|
this.buildFavouritesCategory(isExpanded);
|
||||||
|
|
||||||
window.dispatchEvent(this.manager.favouritesupdate);
|
window.dispatchEvent(this.manager.favouritesupdate);
|
||||||
|
@ -440,8 +423,7 @@ class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)render only the favourites category after adding
|
* (Re)render only the favourites category after updating favourites
|
||||||
* an operation to favourites
|
|
||||||
*
|
*
|
||||||
* @param {Boolean} isExpanded ( false by default )
|
* @param {Boolean} isExpanded ( false by default )
|
||||||
*/
|
*/
|
||||||
|
@ -579,7 +561,7 @@ class App {
|
||||||
/**
|
/**
|
||||||
* Gets the current recipe configuration.
|
* Gets the current recipe configuration.
|
||||||
*
|
*
|
||||||
* @returns {Object[]}
|
* @returns {Object[]} recipeConfig - The recipe configuration
|
||||||
*/
|
*/
|
||||||
getRecipeConfig() {
|
getRecipeConfig() {
|
||||||
return this.manager.recipe.getConfig();
|
return this.manager.recipe.getConfig();
|
||||||
|
@ -639,25 +621,6 @@ class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the splitter positions to default for desktop UI.
|
|
||||||
*/
|
|
||||||
resetLayout() {
|
|
||||||
this.columnSplitter.setSizes([20, 30, 50]);
|
|
||||||
this.ioSplitter.setSizes([50, 50]);
|
|
||||||
this.adjustComponentSizes();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adjust components to fit their containers.
|
|
||||||
*/
|
|
||||||
adjustComponentSizes() {
|
|
||||||
this.manager.input.calcMaxTabs();
|
|
||||||
this.manager.output.calcMaxTabs();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the compile message ( "notice" in #banner ).
|
* Sets the compile message ( "notice" in #banner ).
|
||||||
*/
|
*/
|
||||||
|
@ -845,7 +808,6 @@ class App {
|
||||||
this.loadURIParams();
|
this.loadURIParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set element visibility
|
* Set element visibility
|
||||||
*
|
*
|
||||||
|
@ -859,23 +821,21 @@ class App {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set desktop UI ( on init and on window resize events )
|
* Set desktop UI ( on init and on window resize events )
|
||||||
*
|
|
||||||
* @param {boolean} minimise
|
|
||||||
*/
|
*/
|
||||||
setDesktopUI(minimise) {
|
setDesktopUI() {
|
||||||
this.setCompileMessage();
|
this.setCompileMessage();
|
||||||
this.setDesktopSplitter(minimise);
|
this.setSplitter();
|
||||||
this.adjustComponentSizes();
|
|
||||||
$("[data-toggle=tooltip]").tooltip("enable");
|
this.manager.input.calcMaxTabs();
|
||||||
|
this.manager.output.calcMaxTabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set mobile UI ( on init and on window resize events )
|
* Set mobile UI ( on init and on window resize events )
|
||||||
*/
|
*/
|
||||||
setMobileUI() {
|
setMobileUI() {
|
||||||
this.setMobileSplitter();
|
this.setSplitter(false);
|
||||||
this.assignAvailableHeight();
|
this.assignAvailableHeight();
|
||||||
$("[data-toggle=tooltip]").tooltip("disable");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -904,7 +864,7 @@ class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a CCategoryList element and append it to #categories
|
* Build a CCategoryList component and append it to #categories
|
||||||
*/
|
*/
|
||||||
buildCategoryList() {
|
buildCategoryList() {
|
||||||
// double-check if the c-category-list already exists,
|
// double-check if the c-category-list already exists,
|
||||||
|
@ -919,8 +879,8 @@ class App {
|
||||||
this.operations,
|
this.operations,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
categoryList.build();
|
|
||||||
|
|
||||||
|
categoryList.build();
|
||||||
document.querySelector("#categories").appendChild(categoryList);
|
document.querySelector("#categories").appendChild(categoryList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ class Manager {
|
||||||
this.addDynamicListener("textarea.arg", "drop", this.recipe.textArgDrop, this.recipe);
|
this.addDynamicListener("textarea.arg", "drop", this.recipe.textArgDrop, this.recipe);
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
document.getElementById("reset-layout").addEventListener("click", this.app.resetLayout.bind(this.app));
|
document.getElementById("reset-layout").addEventListener("click", this.app.setDesktopUI.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-file").addEventListener("click", this.input.inputOpenClick.bind(this.input));
|
||||||
|
|
|
@ -5,3 +5,4 @@ manual testing issues
|
||||||
|
|
||||||
mobile:
|
mobile:
|
||||||
- all ops with bootstrap checkboxes in recipe break ( due to the bootstrap checkbox func not being applied ). Need to replace / remove this
|
- all ops with bootstrap checkboxes in recipe break ( due to the bootstrap checkbox func not being applied ). Need to replace / remove this
|
||||||
|
- on ingredient input change ( for instance 'to charcode' 'base' or whatever ) on backspace / removing the value, there is a popup at teh bottem [object Object]. Also happens on actual CC but still. Only happens when value = null
|
||||||
|
|
|
@ -164,7 +164,7 @@ class RecipeWaiter {
|
||||||
/**
|
/**
|
||||||
* Generates a configuration object to represent the current recipe.
|
* Generates a configuration object to represent the current recipe.
|
||||||
*
|
*
|
||||||
* @returns {recipeConfig}
|
* @returns {Object[]} recipeConfig - The recipe configuration
|
||||||
*/
|
*/
|
||||||
getConfig() {
|
getConfig() {
|
||||||
const config = [];
|
const config = [];
|
||||||
|
|
|
@ -25,9 +25,6 @@ class WindowWaiter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for window resize events.
|
* Handler for window resize events.
|
||||||
*
|
|
||||||
* Resets adjustable component sizes after 200ms (so that continuous resizing doesn't cause
|
|
||||||
* continuous resetting).
|
|
||||||
*/
|
*/
|
||||||
windowResize() {
|
windowResize() {
|
||||||
if (!this.app.isMobileView()) {
|
if (!this.app.isMobileView()) {
|
||||||
|
@ -41,8 +38,6 @@ class WindowWaiter {
|
||||||
if (document.getElementById("output").classList.contains("maximised-pane")) {
|
if (document.getElementById("output").classList.contains("maximised-pane")) {
|
||||||
this.manager.controls.setPaneMaximised("output", true);
|
this.manager.controls.setPaneMaximised("output", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
debounce(this.app.adjustComponentSizes, 200, "windowResize", this.app, [])();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,9 +46,9 @@ class WindowWaiter {
|
||||||
* Correct the height of #recipe
|
* Correct the height of #recipe
|
||||||
*/
|
*/
|
||||||
onResizeToDesktop() {
|
onResizeToDesktop() {
|
||||||
this.app.setDesktopUI(false);
|
this.app.setDesktopUI();
|
||||||
|
|
||||||
// disable app popovers on li.operation elements
|
// enable popovers on li.operation elements
|
||||||
$(document.querySelectorAll("li.operation")).popover("enable");
|
$(document.querySelectorAll("li.operation")).popover("enable");
|
||||||
|
|
||||||
// if a window is resized past breakpoint while #recipe or #input is maximised, close these maxed panes
|
// if a window is resized past breakpoint while #recipe or #input is maximised, close these maxed panes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue