Skip to content

Commit

Permalink
Add popup
Browse files Browse the repository at this point in the history
  • Loading branch information
julijonas committed Jan 20, 2018
1 parent 5c6c2e0 commit f82b496
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion emojifier.js
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
document.body.style.border = "5px solid red";

let imgNode;

const popupNode = document.createElement('a');
popupNode.textContent = 'Emojify';
popupNode.style.position = 'absolute';
popupNode.style.background = '#eee';
popupNode.style.padding = '2px';
popupNode.style.cursor = 'pointer';
popupNode.style.textDecoration = 'underline';
document.body.appendChild(popupNode);

function convertImage(event) {
alert('hahaha');
}

popupNode.addEventListener('click', convertImage);

function showPopup(event) {
imgNode = event.target;
let left = imgNode.offsetLeft + imgNode.offsetWidth - popupNode.offsetWidth;
let top = imgNode.offsetTop + imgNode.offsetHeight - popupNode.offsetHeight;
popupNode.style.left = `${left}px`;
popupNode.style.top = `${top}px`;
popupNode.hidden = false;
console.log(event);
}

function hidePopup(event) {
imgNode = event.target;
popupNode.hidden = true;
console.log(event);
}

for (const node of document.images) {
node.addEventListener('mouseover', showPopup);
//node.addEventListener('mouseout', hidePopup);
}

0 comments on commit f82b496

Please sign in to comment.