mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 07:21:02 -04:00
[#181] fix some event issues ( dragging and dropping, mobile taps ), fix popover issues ( popovers properly disappear ), eslint cleanup fixes
This commit is contained in:
parent
8afcfa0b45
commit
5e6327a400
5 changed files with 34 additions and 45 deletions
|
@ -437,6 +437,7 @@ class App {
|
||||||
// update all op-lists to reflect the current recipe list ( selected ops ) and favourite category list ( favourite ops )
|
// update all op-lists to reflect the current recipe list ( selected ops ) and favourite category list ( favourite ops )
|
||||||
this.manager.ops.updateListItemsClasses("#rec-list", "selected");
|
this.manager.ops.updateListItemsClasses("#rec-list", "selected");
|
||||||
this.manager.ops.updateListItemsClasses("#catFavourites > c-operation-list > ul.op-list", "favourite");
|
this.manager.ops.updateListItemsClasses("#catFavourites > c-operation-list > ul.op-list", "favourite");
|
||||||
|
this.manager.recipe.initDragAndDrop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,25 +1,3 @@
|
||||||
recipe:
|
|
||||||
- ignore dropped item outside of rec-list
|
|
||||||
- bit smoother sort experience would be nice
|
|
||||||
|
|
||||||
operations:
|
operations:
|
||||||
- can only drag an op to favourites 1 time
|
|
||||||
- popovers should also show on key up and down per operation
|
|
||||||
- after dragging op to rec, popover no longer works on original op ( see opSortEnd )
|
|
||||||
|
|
||||||
- stupid popovers on deleting favs for instance ( dont always close nicely )
|
|
||||||
- UI tests etc.
|
- UI tests etc.
|
||||||
|
- input in search > click X > dropdown doesn't close
|
||||||
--------
|
|
||||||
|
|
||||||
x highlight strings
|
|
||||||
x esc on focused-op search results will add that op to recipe
|
|
||||||
x be able to tab from panel to panel, open and close them, use up and down arrows
|
|
||||||
x little line on click ( for all input fields, also ingredient focus )
|
|
||||||
x native focus thingy is a bit ugly
|
|
||||||
x RecipeWaiter opSortEnd()
|
|
||||||
|
|
||||||
wont do
|
|
||||||
x initial search is kinda slow
|
|
||||||
|
|
||||||
Tim
|
|
||||||
|
|
|
@ -34,7 +34,8 @@ export class COperationLi extends HTMLElement {
|
||||||
|
|
||||||
this.build();
|
this.build();
|
||||||
|
|
||||||
this.addEventListener("click", this.handleClick.bind(this));
|
// Use mousedown event instead of click to prevent accidentally firing the handler twice on mobile
|
||||||
|
this.addEventListener("mousedown", this.handleMousedown.bind(this));
|
||||||
this.addEventListener("dblclick", this.handleDoubleClick.bind(this));
|
this.addEventListener("dblclick", this.handleDoubleClick.bind(this));
|
||||||
|
|
||||||
if (this.includeStarIcon) {
|
if (this.includeStarIcon) {
|
||||||
|
@ -47,12 +48,14 @@ export class COperationLi extends HTMLElement {
|
||||||
* Remove listeners on disconnectedCallback
|
* Remove listeners on disconnectedCallback
|
||||||
*/
|
*/
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
this.removeEventListener("click", this.handleClick.bind(this));
|
this.removeEventListener("mousedown", this.handleMousedown.bind(this));
|
||||||
this.removeEventListener("dblclick", this.handleDoubleClick.bind(this));
|
this.removeEventListener("dblclick", this.handleDoubleClick.bind(this));
|
||||||
|
|
||||||
if (this.includeStarIcon) {
|
if (this.includeStarIcon) {
|
||||||
this.observer.disconnect();
|
this.observer.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(this).find("[data-toggle=popover]").popover("dispose").popover("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,11 +71,11 @@ export class COperationLi extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle click
|
* Handle mousedown
|
||||||
*
|
*
|
||||||
* @param {Event} e
|
* @param {Event} e
|
||||||
*/
|
*/
|
||||||
handleClick(e) {
|
handleMousedown(e) {
|
||||||
if (e.target === this.querySelector("i.star-icon")) {
|
if (e.target === this.querySelector("i.star-icon")) {
|
||||||
this.app.addFavourite(this.name);
|
this.app.addFavourite(this.name);
|
||||||
}
|
}
|
||||||
|
@ -124,24 +127,22 @@ export class COperationLi extends HTMLElement {
|
||||||
* @param {HTMLElement} el - The element to start selecting from
|
* @param {HTMLElement} el - The element to start selecting from
|
||||||
*/
|
*/
|
||||||
setPopover(el) {
|
setPopover(el) {
|
||||||
$(el)
|
$(this)
|
||||||
.find("[data-toggle=popover]")
|
.find("[data-toggle=popover]")
|
||||||
.addBack("[data-toggle=popover]")
|
.addBack("[data-toggle=popover]")
|
||||||
.popover({trigger: "manual"})
|
.popover({trigger: "manual"})
|
||||||
.on("mouseenter", function(e) {
|
.on("mouseenter", function(e) {
|
||||||
if (e.buttons > 0) return; // Mouse button held down - likely dragging an operation
|
if (e.buttons > 0) return; // Mouse button held down - likely dragging an operation
|
||||||
const _this = this;
|
$(el).popover("show");
|
||||||
$(this).popover("show");
|
|
||||||
$(".popover").on("mouseleave", function () {
|
$(".popover").on("mouseleave", function () {
|
||||||
$(_this).popover("hide");
|
$(el).popover("hide");
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.on("mouseleave", function () {
|
.on("mouseleave", function () {
|
||||||
const _this = this;
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// Determine if the popover associated with this element is being hovered over
|
// Determine if the popover associated with this element is being hovered over
|
||||||
if ($(_this).data("bs.popover") && ($(_this).data("bs.popover").tip && !$($(_this).data("bs.popover").tip).is(":hover"))) {
|
if ($(el).data("bs.popover") && ($(el).data("bs.popover").tip && !$($(el).data("bs.popover").tip).is(":hover"))) {
|
||||||
$(_this).popover("hide");
|
$(el).popover("hide");
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
});
|
});
|
||||||
|
@ -190,7 +191,6 @@ export class COperationLi extends HTMLElement {
|
||||||
li.classList.add("favourite");
|
li.classList.add("favourite");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.config.description) {
|
if (this.config.description) {
|
||||||
let dataContent = this.config.description;
|
let dataContent = this.config.description;
|
||||||
|
|
||||||
|
@ -200,9 +200,7 @@ export class COperationLi extends HTMLElement {
|
||||||
|
|
||||||
li.setAttribute("data-container", "body");
|
li.setAttribute("data-container", "body");
|
||||||
li.setAttribute("data-toggle", "popover");
|
li.setAttribute("data-toggle", "popover");
|
||||||
li.setAttribute("data-placement", "left");
|
|
||||||
li.setAttribute("data-html", "true");
|
li.setAttribute("data-html", "true");
|
||||||
li.setAttribute("data-trigger", "hover");
|
|
||||||
li.setAttribute("data-boundary", "viewport");
|
li.setAttribute("data-boundary", "viewport");
|
||||||
li.setAttribute("data-content", dataContent);
|
li.setAttribute("data-content", dataContent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ export class COperationList extends HTMLElement {
|
||||||
group: "sorting",
|
group: "sorting",
|
||||||
sort: true,
|
sort: true,
|
||||||
draggable: "c-operation-li",
|
draggable: "c-operation-li",
|
||||||
|
filter: "i.material-icons",
|
||||||
onFilter: function (e) {
|
onFilter: function (e) {
|
||||||
const el = sortableList.closest(e.item);
|
const el = sortableList.closest(e.item);
|
||||||
if (el && el.parentNode) {
|
if (el && el.parentNode) {
|
||||||
|
@ -97,6 +98,17 @@ export class COperationList extends HTMLElement {
|
||||||
* @param { string } targetListId
|
* @param { string } targetListId
|
||||||
* */
|
* */
|
||||||
createCloneableList(ul, targetListName, targetListId) {
|
createCloneableList(ul, targetListName, targetListId) {
|
||||||
|
let dragOverRecList = false;
|
||||||
|
const recList = document.querySelector(`#${targetListId}`);
|
||||||
|
|
||||||
|
Sortable.utils.on(recList, "dragover", function () {
|
||||||
|
dragOverRecList = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
Sortable.utils.on(recList, "dragleave", function () {
|
||||||
|
dragOverRecList = false;
|
||||||
|
});
|
||||||
|
|
||||||
Sortable.create(ul, {
|
Sortable.create(ul, {
|
||||||
group: {
|
group: {
|
||||||
name: targetListName,
|
name: targetListName,
|
||||||
|
@ -113,19 +125,19 @@ export class COperationList extends HTMLElement {
|
||||||
// event bindings from the one left in the operations list. Without manually removing
|
// event bindings from the one left in the operations list. Without manually removing
|
||||||
// these bindings, we cannot re-initialise the popover on the stub operation.
|
// these bindings, we cannot re-initialise the popover on the stub operation.
|
||||||
$(e.item)
|
$(e.item)
|
||||||
.popover("dispose")
|
.find("[data-toggle=popover]")
|
||||||
.removeData("bs.popover")
|
.popover("dispose");
|
||||||
.off("mouseenter")
|
|
||||||
.off("mouseleave")
|
|
||||||
.attr("data-toggle", "popover-disabled");
|
|
||||||
$(e.clone)
|
$(e.clone)
|
||||||
|
.find("[data-toggle=popover]")
|
||||||
.off(".popover")
|
.off(".popover")
|
||||||
.removeData("bs.popover");
|
.removeData("bs.popover");
|
||||||
},
|
},
|
||||||
onEnd: ({item}) => {
|
onEnd: ({item, to}) => {
|
||||||
if (item.parentNode.id === targetListId) {
|
if (item.parentNode.id === targetListId && dragOverRecList) {
|
||||||
this.app.manager.recipe.addOperation(item.name);
|
this.app.manager.recipe.addOperation(item.name);
|
||||||
item.remove();
|
item.remove();
|
||||||
|
} else if (!dragOverRecList && !to.classList.contains("op-list")) {
|
||||||
|
item.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,7 @@ class RecipeWaiter {
|
||||||
if (this.app.isMobileView()) {
|
if (this.app.isMobileView()) {
|
||||||
swapThreshold = 0.60;
|
swapThreshold = 0.60;
|
||||||
animation = 400;
|
animation = 400;
|
||||||
delay = 200;
|
delay = 50;
|
||||||
} else {
|
} else {
|
||||||
swapThreshold = 0.10;
|
swapThreshold = 0.10;
|
||||||
animation = 200;
|
animation = 200;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue