Skip to content

Commit

Permalink
Javascipt reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Aug 16, 2024
1 parent cf298e4 commit 0599523
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
8 changes: 4 additions & 4 deletions cypress/e2e/crkeng/search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/crkeng/search/result-header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
48 changes: 24 additions & 24 deletions frontend/js/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down

0 comments on commit 0599523

Please sign in to comment.