Commit 421a1c829686e6367d897332eb4d05465b693394

Authored by David Guilherme
1 parent b1424e32
Exists in master

Fixes the passing of the selected text

Showing 3 changed files with 19 additions and 5 deletions   Show diff stats
app/main.js
... ... @@ -30,3 +30,5 @@ chrome.runtime.onMessage.addListener(
30 30  
31 31 req.send();
32 32 });
  33 +
  34 +chrome.runtime.sendMessage({ready: true});
... ...
app/window.html
... ... @@ -21,11 +21,14 @@
21 21 position: absolute;
22 22 top: 5px;
23 23 right: 40px;
24   - padding: 15px 5px;
  24 + padding: 15px 10px;
25 25 background: #000;
26 26 color: #FFF;
27 27  
28   - font-size: 23px;
  28 + font-size: 1.2em;
  29 + -webkit-border-radius: 20px;
  30 + -moz-border-radius: 20px;
  31 + border-radius: 20px;
29 32 }
30 33  
31 34 #loading-screen {
... ...
background.js
1 1 var popup = undefined;
2   -var port = undefined;
  2 +var selectedText = undefined;
3 3  
4 4 // Creates the context menu to translate texts
5 5 chrome.contextMenus.create({
... ... @@ -24,7 +24,7 @@ chrome.contextMenus.onClicked.addListener( function (info) {
24 24 }, function (w) {
25 25 popup = w;
26 26  
27   - chrome.runtime.sendMessage({selectedText: info.selectionText});
  27 + selectedText = info.selectionText;
28 28 });
29 29 } else {
30 30 chrome.windows.update(popup.id, {focused: true}, function () {
... ... @@ -38,4 +38,13 @@ chrome.windows.onRemoved.addListener( function (windowId) {
38 38 if (windowId == popup.id) {
39 39 popup = undefined;
40 40 }
41   -});
42 41 \ No newline at end of file
  42 +});
  43 +
  44 +// Listening the ready event of the popup
  45 +chrome.runtime.onMessage.addListener(
  46 + function(request, sender, sendResponse) {
  47 + if (request.ready === true && selectedText !== undefined) {
  48 + selectedText = undefined;
  49 + chrome.runtime.sendMessage({selectedText: info.selectionText});
  50 + }
  51 + });
... ...