mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 07:21:02 -04:00
A few annotations and event listener removals on disconnectedCallback
This commit is contained in:
parent
6b0b368564
commit
5f32df891b
3 changed files with 25 additions and 5 deletions
|
@ -31,16 +31,21 @@ export class CCategoryLi extends HTMLElement {
|
||||||
this.addEventListener("click", this.handleClick.bind(this));
|
this.addEventListener("click", this.handleClick.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove listeners on disconnectedCallback
|
||||||
|
*/
|
||||||
|
disconnectedCallback() {
|
||||||
|
this.removeEventListener("click", this.handleClick.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle click
|
* Handle click
|
||||||
*
|
*
|
||||||
* @param {Event} e
|
* @param {Event} e
|
||||||
*/
|
*/
|
||||||
handleClick(e) {
|
handleClick(e) {
|
||||||
// todo some event (target ) bs here
|
if (e.target === this.querySelector("button") || e.target === this.querySelector("button > i")) {
|
||||||
if (e.target === this.querySelector("button")) {
|
e.stopPropagation(); // stop the event from propagating to the collapsable panel
|
||||||
// todo back to this "hitbox" issue w the icon inside the button
|
|
||||||
console.log(e.target);
|
|
||||||
this.app.manager.ops.editFavouritesClick(e);
|
this.app.manager.ops.editFavouritesClick(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,13 @@ export class COperationLi extends HTMLElement {
|
||||||
this.addEventListener('dblclick', this.handleDoubleClick.bind(this));
|
this.addEventListener('dblclick', this.handleDoubleClick.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: dont think I need config separately, just use this.app.operations[name].xx?
|
/**
|
||||||
|
* Remove listeners on disconnectedCallback
|
||||||
|
*/
|
||||||
|
disconnectedCallback() {
|
||||||
|
this.removeEventListener("click", this.handleClick.bind(this));
|
||||||
|
this.removeEventListener("dblclick", this.handleDoubleClick.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fires OperationsWaiter#operationDblclick on double click
|
* @fires OperationsWaiter#operationDblclick on double click
|
||||||
|
@ -52,6 +58,9 @@ export class COperationLi extends HTMLElement {
|
||||||
this.app.addFavourite(this.name);
|
this.app.addFavourite(this.name);
|
||||||
this.updateFavourite(true);
|
this.updateFavourite(true);
|
||||||
}
|
}
|
||||||
|
if (e.target === this.querySelector("i.remove-icon")) {
|
||||||
|
this.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,6 +177,9 @@ export class COperationLi extends HTMLElement {
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update favourite icon for this list item and add 'favourite' class
|
||||||
|
*/
|
||||||
updateFavourite(isFavourite) {
|
updateFavourite(isFavourite) {
|
||||||
if (isFavourite) {
|
if (isFavourite) {
|
||||||
this.querySelector("li").classList.add("favourite");
|
this.querySelector("li").classList.add("favourite");
|
||||||
|
|
|
@ -18,6 +18,9 @@ export class COperationList extends HTMLElement {
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build c-operation-list
|
||||||
|
*/
|
||||||
build() {
|
build() {
|
||||||
const ul = document.createElement("ul");
|
const ul = document.createElement("ul");
|
||||||
ul.classList.add("op-list");
|
ul.classList.add("op-list");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue