Add files via upload

This commit is contained in:
sienori 2017-09-26 21:41:29 +09:00 committed by GitHub
parent 0b15e9694a
commit 2f5866ca06
7 changed files with 39 additions and 45 deletions

View file

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"version": "1.1.1",
"version": "1.1.3",
"name": "__MSG_extName__",
"description": "__MSG_extDescription__",

View file

@ -40,12 +40,6 @@ textarea {
color: #4268da;
}
#distination {
color: #aaa;
max-height: 250px;
overflow-y: auto;
}
#target {
max-height: 250px;
overflow-y: auto;

View file

@ -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;

View file

@ -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,7 +68,7 @@
}
}
@keyframes fadein {
@keyframes simple-translate-fadein {
from {
opacity: 0;
}
@ -72,7 +76,3 @@
opacity: 1;
}
}
#simple-translate-panel p::-moz-selection {
background: #ebebeb;
}

View file

@ -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文字を抽出
if(ifCheckLang){ //設定がオンなら
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); //真偽値を返す
});
}else { //設定がオフならtrueを返す
resolve(true);
}
})
}
//ボタンを表示
function popupButton(e) {
if (ifShowButton) {
button.style.left = e.clientX + 10 + 'px';
button.style.top = e.clientY + 5 + 'px';
if (ifShowButton) {
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);
}