diff --git a/simple-translate/manifest.json b/simple-translate/manifest.json index 7e739c4..1234933 100644 --- a/simple-translate/manifest.json +++ b/simple-translate/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, - "version": "1.1.1", + "version": "1.1.3", "name": "__MSG_extName__", "description": "__MSG_extDescription__", diff --git a/simple-translate/popup/popup.css b/simple-translate/popup/popup.css index f73028a..bf0043a 100644 --- a/simple-translate/popup/popup.css +++ b/simple-translate/popup/popup.css @@ -40,12 +40,6 @@ textarea { color: #4268da; } -#distination { - color: #aaa; - max-height: 250px; - overflow-y: auto; -} - #target { max-height: 250px; overflow-y: auto; diff --git a/simple-translate/popup/popup.js b/simple-translate/popup/popup.js index 119df22..6e02a53 100644 --- a/simple-translate/popup/popup.js +++ b/simple-translate/popup/popup.js @@ -76,11 +76,10 @@ function resize() { }, 0); } -//テキストエリアクリック時の処理 textarea.addEventListener("click", textAreaClick, { once: true }); - +//テキストエリアクリック時の処理 function textAreaClick() { if (textarea.value == initialText) { textarea.value = ""; @@ -89,7 +88,10 @@ function textAreaClick() { } } -textarea.addEventListener("keyup", inputText); +textarea.addEventListener("keyup", function(event){ + if(event.keyCode==13) resize(); + inputText(); +}); //文字入力時の処理 function inputText() { sourceWord = textarea.value; diff --git a/simple-translate/simple-translate.css b/simple-translate/simple-translate.css index 3eb4528..59865ef 100644 --- a/simple-translate/simple-translate.css +++ b/simple-translate/simple-translate.css @@ -1,4 +1,5 @@ #simple-translate-button { + all: initial; background-color: #fff; box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08); border-radius: 3px; @@ -14,14 +15,12 @@ display: none; cursor: pointer; animation-duration: 200ms; - animation-name: showButton; + animation-name: simple-translate-showButton; } #simple-translate-panel { + all: initial; background-color: #fff; - font-family: 'Hiragino Kaku Gothic Pro', 'ヒラギノ角ゴ Pro W3', Meiryo, メイリオ, Osaka, 'MS PGothic', arial, helvetica, sans-serif; - text-align: left; - font-size: 13px; /*opacity: 0;*/ box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08); border-radius: 3px; @@ -39,20 +38,25 @@ top: 0px; display: none; overflow-y: auto; - /* - transition-property: height, width, opacity; - transition-timing-function: ease-out; - transition-duration: 400ms;*/ } #simple-translate-panel p { + all: initial; + font-size: 13px; + font-family: 'Hiragino Kaku Gothic Pro', 'ヒラギノ角ゴ Pro W3', Meiryo, メイリオ, Osaka, 'MS PGothic', arial, helvetica, sans-serif; + text-align: left; display: inline-block; margin: 0; + word-wrap: break-word; transition-duration: 200ms; - animation-name: fadein; + animation-name: simple-translate-fadein; } -@keyframes showButton { +#simple-translate-panel p::-moz-selection { + background: #ebebeb; +} + +@keyframes simple-translate-showButton { 0% { transform: scale3d(1, 1, 1); } @@ -64,15 +68,11 @@ } } -@keyframes fadein { +@keyframes simple-translate-fadein { from { opacity: 0; } to { opacity: 1; } -} - -#simple-translate-panel p::-moz-selection { - background: #ebebeb; } \ No newline at end of file diff --git a/simple-translate/simple-translate.js b/simple-translate/simple-translate.js index 30fb59f..ae0897d 100644 --- a/simple-translate/simple-translate.js +++ b/simple-translate/simple-translate.js @@ -9,10 +9,10 @@ var targetLang; var ifShowButton; var ifCheckLang; -//設定を読み出し + getSetting(); browser.storage.onChanged.addListener(getSetting); - +//設定を読み出し function getSetting() { browser.storage.sync.get(["targetLang", "ifShowButton", "ifCheckLang"], function (value) { targetLang = value.targetLang; @@ -22,18 +22,17 @@ function getSetting() { } window.addEventListener("mouseup", Select, false); -//テキスト選択時の処理 +//テキスト選択時の処理 ダブルクリックした時2回処理が走るのを何とかしたい function Select(e) { hidePanel(e); setTimeout(function () { //誤動作防止の為ディレイを設ける selectionWord = String(window.getSelection()); if ((selectionWord.length !== 0) && (e.button == 0) && (e.target.id !== "simple-translate-panel") && (e.target.parentElement.id !== "simple-translate-panel")) { //選択範囲が存在かつ左クリックかつパネル以外のとき - if (ifCheckLang) { + clickPosition=e; + if (ifShowButton) {//ボタンを表示 checkLang().then(function (results) { if (results) popupButton(e); }); - } else { - popupButton(e); } } }, 200); @@ -42,25 +41,27 @@ function Select(e) { //選択テキストの言語をチェックして返す function checkLang() { return new Promise(function (resolve, reject) { - getRequest(selectionWord.substr(0, 100)) //先頭100文字を抽出 - .then(function (results) { - let lang = results.response[2]; - let percentage = results.response[6]; - //console.log(lang, percentage, lang!=targetLang && percentage>0); - resolve(lang != targetLang && percentage > 0); //真偽値を返す - }); + if(ifCheckLang){ //設定がオンなら + getRequest(selectionWord.substr(0, 100)) //先頭100文字を抽出して言語を取得 + .then(function (results) { + let lang = results.response[2]; + let percentage = results.response[6]; + resolve(lang != targetLang && percentage > 0); //真偽値を返す + }); + }else { //設定がオフならtrueを返す + resolve(true); + } }) } //ボタンを表示 function popupButton(e) { - button.style.left = e.clientX + 10 + 'px'; - button.style.top = e.clientY + 5 + 'px'; if (ifShowButton) { + button.style.left = e.clientX + 10 + 'px'; + button.style.top = e.clientY + 5 + 'px'; button.style.display = 'block'; } } - button.addEventListener("click", function (e) { translate(); showPanel(e); @@ -173,8 +174,5 @@ function sendToPopup() { function showPanelFromMenu() { button.style.display = "none"; translate(); - let event = new Object(); - event.clientX = parseInt(button.style.left); - event.clientY = parseInt(button.style.top); - showPanel(event); + showPanel(clickPosition); } diff --git a/simple-translate/web-ext-artifacts/simple_translate-1.1.2.zip b/simple-translate/web-ext-artifacts/simple_translate-1.1.2.zip new file mode 100644 index 0000000..939c2ef Binary files /dev/null and b/simple-translate/web-ext-artifacts/simple_translate-1.1.2.zip differ diff --git a/simple-translate/web-ext-artifacts/simple_translate-1.1.3.zip b/simple-translate/web-ext-artifacts/simple_translate-1.1.3.zip new file mode 100644 index 0000000..19981e2 Binary files /dev/null and b/simple-translate/web-ext-artifacts/simple_translate-1.1.3.zip differ