From 059952375f417590e7dc9069b573510a298be275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Ba=C3=B1ados=20Schwerter?= Date: Fri, 16 Aug 2024 00:38:49 +0000 Subject: [PATCH] Javascipt reformat --- cypress/e2e/crkeng/search.spec.js | 8 ++-- .../e2e/crkeng/search/result-header.spec.js | 5 +- frontend/js/tooltip.js | 48 +++++++++---------- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/cypress/e2e/crkeng/search.spec.js b/cypress/e2e/crkeng/search.spec.js index 6fa2da637..de9788805 100644 --- a/cypress/e2e/crkeng/search.spec.js +++ b/cypress/e2e/crkeng/search.spec.js @@ -112,11 +112,11 @@ context("Searching", () => { it("should not display None", () => { cy.visitSearch("nipawâkan"); - cy.get("[data-cy=elaboration]") + cy.get("[data-cy=elaboration]"); - cy.contains("None").should('not.exist'); - }) - }) + cy.contains("None").should("not.exist"); + }); + }); describe("A tooltip should show up when the user click/focus on the i icon beside the matched wordform", () => { it("should show tooltip when the user focuses on the i icon beside ê-wâpamat", () => { diff --git a/cypress/e2e/crkeng/search/result-header.spec.js b/cypress/e2e/crkeng/search/result-header.spec.js index 3efc3b8d8..bc31e4903 100644 --- a/cypress/e2e/crkeng/search/result-header.spec.js +++ b/cypress/e2e/crkeng/search/result-header.spec.js @@ -206,7 +206,10 @@ context("Searching", () => { .and("contain", plainEnglishInflectionalCategory); // Inflectional category tool tip - cy.get("@elaboration").get('[data-cy="elaboration"]').first().trigger("mouseenter",{force: true}); + cy.get("@elaboration") + .get('[data-cy="elaboration"]') + .first() + .trigger("mouseenter", { force: true }); cy.get("@elaboration").get('[role="tooltip"]').should("be.visible"); cy.get("@elaboration").contains('[role="tooltip"]', inflectionalCategory); }); diff --git a/frontend/js/tooltip.js b/frontend/js/tooltip.js index d045952a6..d43be85fe 100644 --- a/frontend/js/tooltip.js +++ b/frontend/js/tooltip.js @@ -16,37 +16,37 @@ export function createTooltip(icon, popup) { let permanent = false; let popperInstance = null; -/** - * @param {Element} icon - * @param {Element} popup - */ -function create(icon, popup) { - popperInstance = createPopper(icon, popup, { - modifiers: [ - { - name: "offset", - options: { - offset: [0, 8], + /** + * @param {Element} icon + * @param {Element} popup + */ + function create(icon, popup) { + popperInstance = createPopper(icon, popup, { + modifiers: [ + { + name: "offset", + options: { + offset: [0, 8], + }, }, - }, - ], - }); -} + ], + }); + } -function destroy() { - if (popperInstance) { - popperInstance.destroy(); - popperInstance = null; + function destroy() { + if (popperInstance) { + popperInstance.destroy(); + popperInstance = null; + } } -} - function show () { - if(!popperInstance){ + function show() { + if (!popperInstance) { popup.setAttribute("data-show", ""); create(icon, popup); } } - function hide () { + function hide() { if (!permanent && popperInstance) { popup.removeAttribute("data-show"); destroy(); @@ -73,7 +73,7 @@ function destroy() { for (let event of outsidePopupCloseEvents) { document.addEventListener(event, (event) => { - if (!popup.contains(event.target) && !icon.contains(event.target)){ + if (!popup.contains(event.target) && !icon.contains(event.target)) { permanent = false; hide(); }