Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Structure changes

  • Loading branch information...
commit d2e5a14d88bef4e4a8cab7ee3d5a20986b123496 1 parent 18a726f
@oskarkrawczyk authored
View
2  background.html
@@ -1 +1 @@
-<script src="zuckbook.background.js" type="text/javascript" charset="utf-8"></script>
+<script src="js/fb.translate.background.js" type="text/javascript" charset="utf-8"></script>
View
0  zuckbook.css → css/fb.translate.css
File renamed without changes
View
0  zuckbook.background.js → js/fb.translate.background.js
File renamed without changes
View
26 zuckbook.js → js/fb.translate.js
@@ -32,41 +32,41 @@
if (!actionLink.get('data-translate-button')){
this.buttons = Elements.from(this.Template.button).inject(actionLink);
this.translateButton = this.buttons.getLast();
- this.showOriginal = false;
+ //this.showOriginal = false;
this.translateButton.addEvents({
click: function(event){
- self.attachTranslate.call(self, event, this);
+ event.stop();
+ self.attachTranslate.call(self, this);
}
});
actionLink.set('data-translate-button', true);
}
},
- attachTranslate: function(event, element){
- event.stop();
+ attachTranslate: function(element){
var messageBody = element.getParent('.storyInnerContent').getElement('.messageBody');
-
- if (this.showOriginal){
+ var showOriginal;
+ if (showOriginal){
messageBody.set('html', messageBody.get('data-translate-original'));
- element.set('text', 'Translate');
- this.showOriginal = false;
+ showOriginal = false;
+ element.set('html', '<span>Translate</span>');
} else {
if (messageBody.get('data-translate-cache')){
- messageBody.set('html', messageBody.get('data-translate-cache'));
+ messageBody.set('html', this.messageBody.get('data-translate-cache'));
} else {
messageBody.setOpacity(0.5);
this.translate(messageBody.get('html'), function(response){
- var translation = this.googleapis.data.translations[0].translatedText;
+ var translation = response.googleapis.data.translations[0].translatedText;
messageBody.set({
'data-translate-original': messageBody.get('html'),
'data-translate-cache': translation,
'html': translation
});
messageBody.setOpacity(1);
- });
+ }.bind(this));
}
+ showOriginal = true;
element.set('html', '<span>Show original</span>');
- this.showOriginal = true;
}
},
@@ -86,7 +86,7 @@
},
function(response){
if (response.type === 'translate'){
- callback.call(response);
+ callback.call(this, response);
}
});
}
View
0  mootools-core-1.3.2.js → js/mootools-core-1.3.2.js
File renamed without changes
View
0  mootools-more-1.3.2.1.js → js/mootools-more-1.3.2.1.js
File renamed without changes
View
8 manifest.json
@@ -15,12 +15,12 @@
"*://*.facebook.com/*"
],
"js": [
- "mootools-core-1.3.2.js",
- "mootools-more-1.3.2.1.js",
- "zuckbook.js"
+ "js/mootools-core-1.3.2.js",
+ "js/mootools-more-1.3.2.1.js",
+ "js/fb.translate.js"
],
"css": [
- "zuckbook.css"
+ "css/fb.translate.css"
],
"run_at": "document_end",
"all_frames": false
Please sign in to comment.
Something went wrong with that request. Please try again.