mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 07:21:02 -04:00
add function to check for window width and use that throughout the app for more convenient future use
This commit is contained in:
parent
6a1514db30
commit
df781bec00
6 changed files with 11 additions and 8 deletions
|
@ -50,6 +50,9 @@ class App {
|
||||||
this.breakpoint = 768;
|
this.breakpoint = 768;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isMobileView() {
|
||||||
|
return window.innerWidth < this.breakpoint;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function sets up the stage and creates listeners for all events.
|
* This function sets up the stage and creates listeners for all events.
|
||||||
|
@ -297,7 +300,7 @@ class App {
|
||||||
* @param {boolean} [minimise=false] - Set this flag if attempting to minimise frames to 0 width
|
* @param {boolean} [minimise=false] - Set this flag if attempting to minimise frames to 0 width
|
||||||
*/
|
*/
|
||||||
initialiseUI() {
|
initialiseUI() {
|
||||||
if (window.innerWidth < this.breakpoint) {
|
if (this.isMobileView()) {
|
||||||
this.setMobileUI();
|
this.setMobileUI();
|
||||||
} else {
|
} else {
|
||||||
this.setDesktopUI(false);
|
this.setDesktopUI(false);
|
||||||
|
|
|
@ -64,14 +64,14 @@ class HTMLOperation {
|
||||||
|
|
||||||
if (removeIcon) {
|
if (removeIcon) {
|
||||||
html += "<i class='material-icons remove-icon op-icon'>delete</i>";
|
html += "<i class='material-icons remove-icon op-icon'>delete</i>";
|
||||||
} else if (!removeIcon && window.innerWidth < this.app.breakpoint) {
|
} else if (!removeIcon && this.app.isMobileView()) {
|
||||||
html += "<i class='material-icons check-icon op-icon'>check</i>";
|
html += "<i class='material-icons check-icon op-icon'>check</i>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if local storage is available *and* has favourites at all ( otherwise we use the default favs )
|
// check if local storage is available *and* has favourites at all ( otherwise we use the default favs )
|
||||||
const isFavourite = this.app.isLocalStorageAvailable() && localStorage.favourites?.includes(this.name);
|
const isFavourite = this.app.isLocalStorageAvailable() && localStorage.favourites?.includes(this.name);
|
||||||
|
|
||||||
if (window.innerWidth < this.app.breakpoint) {
|
if (this.app.isMobileView()) {
|
||||||
html += `<i title="${this.name}" class='material-icons icon-add-favourite star-icon op-icon ${isFavourite ? "fav-op" : ""}'>
|
html += `<i title="${this.name}" class='material-icons icon-add-favourite star-icon op-icon ${isFavourite ? "fav-op" : ""}'>
|
||||||
${isFavourite ? "star" : "star_outline"}
|
${isFavourite ? "star" : "star_outline"}
|
||||||
</i>`;
|
</i>`;
|
||||||
|
|
|
@ -450,7 +450,7 @@ ${navigator.userAgent}
|
||||||
if (maximise) {
|
if (maximise) {
|
||||||
pane.style.height = `${window.innerHeight - 40}px`;
|
pane.style.height = `${window.innerHeight - 40}px`;
|
||||||
} else {
|
} else {
|
||||||
if (window.innerWidth < this.app.breakpoint) {
|
if (this.app.isMobileView()) {
|
||||||
this.app.assignAvailableHeight();
|
this.app.assignAvailableHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ class OperationsWaiter {
|
||||||
* @param {event} e
|
* @param {event} e
|
||||||
*/
|
*/
|
||||||
opListCreate(e) {
|
opListCreate(e) {
|
||||||
if (window.innerWidth < this.app.breakpoint) {
|
if (this.app.isMobileView()) {
|
||||||
this.createMobileOpList(e);
|
this.createMobileOpList(e);
|
||||||
} else {
|
} else {
|
||||||
this.createDesktopOpList(e);
|
this.createDesktopOpList(e);
|
||||||
|
@ -313,7 +313,7 @@ class OperationsWaiter {
|
||||||
this.removeIntent = false;
|
this.removeIntent = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
if (window.innerWidth >= this.app.breakpoint) {
|
if (!this.app.isMobileView()) {
|
||||||
$("#edit-favourites-list [data-toggle=popover]").popover();
|
$("#edit-favourites-list [data-toggle=popover]").popover();
|
||||||
}
|
}
|
||||||
$("#favourites-modal").modal();
|
$("#favourites-modal").modal();
|
||||||
|
|
|
@ -33,7 +33,7 @@ class RecipeWaiter {
|
||||||
*/
|
*/
|
||||||
initialiseOperationDragNDrop() {
|
initialiseOperationDragNDrop() {
|
||||||
const recList = document.getElementById("rec-list");
|
const recList = document.getElementById("rec-list");
|
||||||
const isMobileView = window.innerWidth < this.app.breakpoint;
|
const isMobileView = this.app.isMobileView();
|
||||||
|
|
||||||
// Recipe list
|
// Recipe list
|
||||||
Sortable.create(recList, {
|
Sortable.create(recList, {
|
||||||
|
|
|
@ -30,7 +30,7 @@ class WindowWaiter {
|
||||||
* continuous resetting).
|
* continuous resetting).
|
||||||
*/
|
*/
|
||||||
windowResize() {
|
windowResize() {
|
||||||
if (window.innerWidth >= this.app.breakpoint) {
|
if (!this.app.isMobileView()) {
|
||||||
this.onResizeToDesktop();
|
this.onResizeToDesktop();
|
||||||
} else {
|
} else {
|
||||||
this.onResizeToMobile();
|
this.onResizeToMobile();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue