Improvements

This commit is contained in:
Alex Yatskov 2016-05-07 13:43:32 -07:00
parent 8c1ebe6bcb
commit 9b9985bd4b
6 changed files with 14 additions and 12 deletions

View File

@ -23,13 +23,13 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia
},"2":function(container,depth0,helpers,partials,data,blockParams,depths) {
var helper, alias1=container.lambda, alias2=container.escapeExpression;
return " <a href=\"#\" title=\"Add Kanji\" class=\"action-link disabled\" data-sequence=\""
return " <div class=\"action-bar\">\n <a href=\"#\" title=\"Add Kanji\" class=\"action-link disabled\" data-sequence=\""
+ alias2(alias1((depths[1] != null ? depths[1].sequence : depths[1]), depth0))
+ "\" data-mode=\"kanji\" data-index=\""
+ alias2(((helper = (helper = helpers.index || (data && data.index)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(depth0 != null ? depth0 : {},{"name":"index","hash":{},"data":data}) : helper)))
+ "\"><img src=\""
+ alias2(alias1((depths[1] != null ? depths[1].root : depths[1]), depth0))
+ "/add_kanji.png\"></a>\n";
+ "/img/add_kanji.png\"></a>\n </div>\n";
},"4":function(container,depth0,helpers,partials,data) {
var stack1;
@ -97,13 +97,13 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial
},"2":function(container,depth0,helpers,partials,data,blockParams,depths) {
var helper, alias1=container.lambda, alias2=container.escapeExpression, alias3=depth0 != null ? depth0 : {}, alias4=helpers.helperMissing, alias5="function";
return " <div class=\"action-bar\">\n <a href=\"#\" title=\"Add as expression\" class=\"action-link disabled\" data-sequence=\""
return " <div class=\"action-bar\">\n <a href=\"#\" title=\"Add term as expression\" class=\"action-link disabled\" data-sequence=\""
+ alias2(alias1((depths[1] != null ? depths[1].sequence : depths[1]), depth0))
+ "\" data-mode=\"vocabExp\" data-index=\""
+ alias2(((helper = (helper = helpers.index || (data && data.index)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"index","hash":{},"data":data}) : helper)))
+ "\"><img src=\""
+ alias2(alias1((depths[1] != null ? depths[1].root : depths[1]), depth0))
+ "/img/add_expression.png\"></a>\n <a href=\"#\" title=\"Add as reading\" class=\"action-link disabled\" data-sequence=\""
+ "/img/add_expression.png\"></a>\n <a href=\"#\" title=\"Add term as reading\" class=\"action-link disabled\" data-sequence=\""
+ alias2(alias1((depths[1] != null ? depths[1].sequence : depths[1]), depth0))
+ "\" data-mode=\"vocabReading\" data-index=\""
+ alias2(((helper = (helper = helpers.index || (data && data.index)) != null ? helper : alias4),(typeof helper === alias5 ? helper.call(alias3,{"name":"index","hash":{},"data":data}) : helper)))

View File

@ -51,7 +51,7 @@ class Yomichan {
onMessage(request, sender, callback) {
const {action, params} = request, handlers = {
canAddNotes: (definitions) => this.ankiInvoke('canAddNotes', definitions, 'notes', callback),
canAddNotes: ({definitions, modes}) => this.ankiInvoke('canAddNotes', {definitions: definitions, modes: modes}, 'notes', callback),
findKanji: (text) => callback(this.translator.findKanji(text)),
findTerm: (text) => callback(this.translator.findTerm(text)),
getOptions: () => callback(this.options),

View File

@ -45,6 +45,6 @@ function bgGetState(callback) {
bgSendMessage('getState', null, callback);
}
function bgCanAddNotes(definitions, callback) {
bgSendMessage('canAddNotes', definitions, callback);
function bgCanAddNotes(definitions, modes, callback) {
bgSendMessage('canAddNotes', {definitions, modes}, callback);
}

View File

@ -115,7 +115,7 @@ class Client {
this.definitions = definitions;
this.showPopup(range, content);
bgCanAddNotes(definitions, (states) => {
bgCanAddNotes(definitions, ['vocabExp', 'vocabReading'], (states) => {
if (states !== null) {
states.forEach((state, index) => this.popup.sendMessage(
'setActionState',
@ -149,7 +149,7 @@ class Client {
this.definitions = definitions;
this.popup.setContent(content, definitions);
bgCanAddNotes(definitions, (states) => {
bgCanAddNotes(definitions, ['kanji'], (states) => {
if (states !== null) {
states.forEach((state, index) => this.popup.sendMessage(
'setActionState',

View File

@ -1,7 +1,9 @@
<div class="kanji-definition">
{{#with options}}
{{#if enableAnkiConnect}}
<a href="#" title="Add Kanji" class="action-link disabled" data-sequence="{{../sequence}}" data-mode="kanji" data-index="{{@index}}"><img src="{{../root}}/add_kanji.png"></a>
<div class="action-bar">
<a href="#" title="Add Kanji" class="action-link disabled" data-sequence="{{../sequence}}" data-mode="kanji" data-index="{{@index}}"><img src="{{../root}}/img/add_kanji.png"></a>
</div>
{{/if}}
{{/with}}

View File

@ -2,8 +2,8 @@
{{#with options}}
{{#if enableAnkiConnect}}
<div class="action-bar">
<a href="#" title="Add as expression" class="action-link disabled" data-sequence="{{../sequence}}" data-mode="vocabExp" data-index="{{@index}}"><img src="{{../root}}/img/add_expression.png"></a>
<a href="#" title="Add as reading" class="action-link disabled" data-sequence="{{../sequence}}" data-mode="vocabReading" data-index="{{@index}}"><img src="{{../root}}/img/add_reading.png"></a>
<a href="#" title="Add term as expression" class="action-link disabled" data-sequence="{{../sequence}}" data-mode="vocabExp" data-index="{{@index}}"><img src="{{../root}}/img/add_expression.png"></a>
<a href="#" title="Add term as reading" class="action-link disabled" data-sequence="{{../sequence}}" data-mode="vocabReading" data-index="{{@index}}"><img src="{{../root}}/img/add_reading.png"></a>
</div>
{{/if}}
{{/with}}