From 368fa49ef8bec417ca11a8feb523aa6293185eac Mon Sep 17 00:00:00 2001 From: "K. Sasa" Date: Tue, 6 Feb 2018 18:15:00 +0900 Subject: [PATCH] Added the function to automatically display the translation panel. (#53) --- simple-translate/_locales/en/messages.json | 6 ++++++ simple-translate/_locales/ja_JP/messages.json | 6 ++++++ simple-translate/options/options.html | 12 ++++++++++++ simple-translate/simple-translate.js | 9 +++++++-- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/simple-translate/_locales/en/messages.json b/simple-translate/_locales/en/messages.json index 7d69960..c2e8652 100644 --- a/simple-translate/_locales/en/messages.json +++ b/simple-translate/_locales/en/messages.json @@ -35,6 +35,12 @@ "ifShowCandidateCaptionLabel": { "message": "Show multiple translation candidates when a single word is translated." }, + "ifAutoTranslate": { + "message": "Automatically display translation panel" + }, + "ifAutoTranslateLabel": { + "message": "Directly display the translation panel without displaying the button." + }, "ifShowButtonLabel": { "message": "Display the button when text is selected" }, diff --git a/simple-translate/_locales/ja_JP/messages.json b/simple-translate/_locales/ja_JP/messages.json index a38d160..5568c2d 100644 --- a/simple-translate/_locales/ja_JP/messages.json +++ b/simple-translate/_locales/ja_JP/messages.json @@ -47,6 +47,12 @@ "ifCheckLangCaptionLabel": { "message": "選択したテキストの言語を検出し,翻訳先言語と同じ場合はボタンを表示しません。" }, + "ifAutoTranslate": { + "message": "自動的に翻訳パネルを表示する" + }, + "ifAutoTranslateLabel": { + "message": "ボタンを表示せずに直接翻訳パネルを表示します。" + }, "ifShowMenuLabel": { "message": "コンテキストメニューを表示する" }, diff --git a/simple-translate/options/options.html b/simple-translate/options/options.html index 785a62c..380c13b 100644 --- a/simple-translate/options/options.html +++ b/simple-translate/options/options.html @@ -102,6 +102,18 @@ +
  • +
    +

    自動的に翻訳パネルを表示する

    +

    ボタンを表示せずに直接翻訳パネルを表示します。

    +
    +
    + +
    +

  • diff --git a/simple-translate/simple-translate.js b/simple-translate/simple-translate.js index d373e73..24c1790 100644 --- a/simple-translate/simple-translate.js +++ b/simple-translate/simple-translate.js @@ -24,9 +24,14 @@ function Select(e) { if ((selectionWord.length !== 0) && (e.button == 0) && (e.target.id !== "simple-translate-panel") && (e.target.parentElement.id !== "simple-translate-panel")) { //選択範囲が存在かつ左クリックかつパネル以外のとき clickPosition = e; - if (S.get().ifShowButton) { //ボタンを表示 + if (S.get().ifShowButton) { checkLang().then(function (results) { - if (results) popupButton(e); + if (results && S.get().ifAutoTranslate) { // 自動翻訳パネル表示がOnならshowPanel() + translate(); + showPanel(e); + } else if (results) { // Offならボタンを表示 + popupButton(e); + } }); } }