From 04d1074e6f289d684b39fc8ca6a47a328a903abb Mon Sep 17 00:00:00 2001 From: Brian Burkard Date: Wed, 2 Oct 2019 21:32:24 -0400 Subject: [PATCH] Added title attributes to tooltips --- selection.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/selection.js b/selection.js index b919f3f..5e22a47 100644 --- a/selection.js +++ b/selection.js @@ -68,25 +68,30 @@ const Selection = (function() { const twitterConfig = { url: 'https://twitter.com/intent/tweet?text=', icon: - '' + '', + alt: 'Twitter' }; const facebookConfig = { url: 'https://www.facebook.com/sharer/sharer.php?quote=', icon: - '' + '', + alt: 'Facebook' }; const searchConfig = { url: 'https://www.google.co.in/search?q=', icon: - '' + '', + alt: 'Search' }; const copyConfig = { icon: - '' + '', + alt: 'Copy' }; const speakConfig = { icon: - '' + '', + alt: 'Speak' }; const translateConfig = { url:'https://translate.google.com/#auto/', @@ -100,7 +105,8 @@ const Selection = (function() { ''+ ''+ ''+ - '' + '', + alt: 'Translate' }; let selection = ''; @@ -124,16 +130,16 @@ const Selection = (function() { } finalurl += text + '&u=' + sharelink; popupwindow(finalurl, 'Share', 600, 500); - }); + }, facebookConfig.alt); return fbbtn; } function twitterButton() { const url = window.location.href; - const twbtn = new Button(twitterConfig.icon, function() { + const twbtn = new Button(twitterConfig.icon,function() { popupwindow(twitterConfig.url + encodeURIComponent(text) + ' ' + url, 'Share', 550, 295); return false; - }); + }, twitterConfig.alt); return twbtn; } @@ -142,7 +148,7 @@ const Selection = (function() { const searchbtn = new Button(searchConfig.icon, function() { popupwindow(searchConfig.url + encodeURIComponent(text), 'Search', 900, 540); return false; - }); + }, searchConfig.alt); return searchbtn; } @@ -150,7 +156,7 @@ const Selection = (function() { function copyButton() { const cbtn = new Button(copyConfig.icon, function() { copyTextToClipboard(text); - }); + }, copyConfig.alt); return cbtn; } @@ -158,7 +164,7 @@ const Selection = (function() { const spbtn = new Button(speakConfig.icon, function() { let speech = new SpeechSynthesisUtterance(text); window.speechSynthesis.speak(speech); - }); + }, speakConfig.alt); return spbtn; } @@ -166,7 +172,7 @@ const Selection = (function() { const tsbtn = new Button(translateConfig.icon, function() { popupwindow(translateConfig.url + getBrowserLanguage() + '/' + text, 'Translate', 900, 540); return false; - }); + }, translateConfig.alt); return tsbtn; } @@ -323,10 +329,11 @@ const Selection = (function() { }; } - function Button(icon, clickFn) { + function Button(icon, clickFn, alt = "") { const btn = document.createElement('div'); btn.style = 'display:inline-block;' + 'margin:7px;' + 'cursor:pointer;' + 'transition:all .2s ease-in-out;'; btn.innerHTML = icon; + btn.title = alt; btn.onclick = clickFn; btn.onmouseover = function() { this.style.transform = 'scale(1.2)';