diff --git a/app/main.js b/app/main.js index b910bd3..b6d48a8 100644 --- a/app/main.js +++ b/app/main.js @@ -30,3 +30,5 @@ chrome.runtime.onMessage.addListener( req.send(); }); + +chrome.runtime.sendMessage({ready: true}); diff --git a/app/window.html b/app/window.html index a6249c5..777889b 100644 --- a/app/window.html +++ b/app/window.html @@ -21,11 +21,14 @@ position: absolute; top: 5px; right: 40px; - padding: 15px 5px; + padding: 15px 10px; background: #000; color: #FFF; - font-size: 23px; + font-size: 1.2em; + -webkit-border-radius: 20px; + -moz-border-radius: 20px; + border-radius: 20px; } #loading-screen { diff --git a/background.js b/background.js index 0fae671..c3accaf 100644 --- a/background.js +++ b/background.js @@ -1,5 +1,5 @@ var popup = undefined; -var port = undefined; +var selectedText = undefined; // Creates the context menu to translate texts chrome.contextMenus.create({ @@ -24,7 +24,7 @@ chrome.contextMenus.onClicked.addListener( function (info) { }, function (w) { popup = w; - chrome.runtime.sendMessage({selectedText: info.selectionText}); + selectedText = info.selectionText; }); } else { chrome.windows.update(popup.id, {focused: true}, function () { @@ -38,4 +38,13 @@ chrome.windows.onRemoved.addListener( function (windowId) { if (windowId == popup.id) { popup = undefined; } -}); \ No newline at end of file +}); + +// Listening the ready event of the popup +chrome.runtime.onMessage.addListener( + function(request, sender, sendResponse) { + if (request.ready === true && selectedText !== undefined) { + selectedText = undefined; + chrome.runtime.sendMessage({selectedText: info.selectionText}); + } + }); -- libgit2 0.21.2