From 65845c6c6ebad89222064e0eac410a546adffbc8 Mon Sep 17 00:00:00 2001 From: Jeremy Schomery Date: Mon, 13 Mar 2017 16:28:35 +0330 Subject: [PATCH] replacing window.confirm --- _locales/ar/messages.json | 6 ++++++ _locales/cs/messages.json | 6 ++++++ _locales/de/messages.json | 6 ++++++ _locales/el/messages.json | 6 ++++++ _locales/en/messages.json | 6 ++++++ _locales/es/messages.json | 8 +++++++- _locales/fi/messages.json | 6 ++++++ _locales/fr/messages.json | 6 ++++++ _locales/it/messages.json | 6 ++++++ _locales/ja/messages.json | 6 ++++++ _locales/nl/messages.json | 6 ++++++ _locales/pt_BR/messages.json | 6 ++++++ _locales/ru/messages.json | 6 ++++++ _locales/sr/messages.json | 6 ++++++ _locales/sv/messages.json | 6 ++++++ _locales/sv_SE/messages.json | 6 ++++++ _locales/te/messages.json | 6 ++++++ _locales/tr/messages.json | 6 ++++++ _locales/zh/messages.json | 6 ++++++ _locales/zh_CN/messages.json | 6 ++++++ _locales/zh_TW/messages.json | 6 ++++++ manifest.json | 2 +- popup.css | 38 ++++++++++++++++++++++++++++++++++++ popup.html | 10 ++++++++++ popup.js | 23 ++++++++++++++-------- 25 files changed, 191 insertions(+), 10 deletions(-) diff --git a/_locales/ar/messages.json b/_locales/ar/messages.json index 8b44cbbd..6f09732a 100644 --- a/_locales/ar/messages.json +++ b/_locales/ar/messages.json @@ -168,6 +168,12 @@ "message": "هل تريد بالتأكيد حذف هذا النمط؟", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp is invalid.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/cs/messages.json b/_locales/cs/messages.json index f436db00..e48a8e46 100644 --- a/_locales/cs/messages.json +++ b/_locales/cs/messages.json @@ -168,6 +168,12 @@ "message": "Opravdu chcete tento styl smazat?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Tento regulérní výraz je neplatný.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/de/messages.json b/_locales/de/messages.json index f656393a..1f0952a6 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -168,6 +168,12 @@ "message": "Möchten Sie diesen Style wirklich löschen?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regulärer Ausdruck ist ungültig.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/el/messages.json b/_locales/el/messages.json index 5efd10e5..1ba27c22 100644 --- a/_locales/el/messages.json +++ b/_locales/el/messages.json @@ -168,6 +168,12 @@ "message": "Είστε σίγουροι ότι θέλετε να διαγράψετε αυτό το στυλ;", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Το Regexp δεν είναι έγκυρο.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 325e615a..0e20ea4e 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -136,6 +136,12 @@ "message": "Are you sure you want to delete this style?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "description": { "message": "Restyle the web with Stylus, a user styles manager. Stylus lets you easily install themes and skins for many popular sites.", "description": "Extension description" diff --git a/_locales/es/messages.json b/_locales/es/messages.json index 90e2d01c..ceddc43e 100644 --- a/_locales/es/messages.json +++ b/_locales/es/messages.json @@ -212,6 +212,12 @@ "message": "¿Está seguro de que quiere eliminar este estilo?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "La expresión regular (regexp) introducida no es válida", "description": "Validation message for a bad regexp in a style" @@ -504,4 +510,4 @@ "message": "Modifique el estilo de la Web con Stylus, un administrador de estilos de usuario. Stylus le permite instalar fácilmente temas y coberturas para muchos sitios populares.", "description": "Extension description" } -} \ No newline at end of file +} diff --git a/_locales/fi/messages.json b/_locales/fi/messages.json index 2fd9e969..9598a2d7 100644 --- a/_locales/fi/messages.json +++ b/_locales/fi/messages.json @@ -168,6 +168,12 @@ "message": "Oletko varma että haluat poistaa tämän tyylin?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp ei kelpaa.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 87f1811d..1a4e8080 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -168,6 +168,12 @@ "message": "Voulez-vous vraiment supprimer ce style ?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Le Regexp est éronné", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/it/messages.json b/_locales/it/messages.json index 50d2c835..cba5cb0a 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -168,6 +168,12 @@ "message": "Vuoi eliminare questo stile?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp is invalid.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/ja/messages.json b/_locales/ja/messages.json index 981b4df8..39ca5c87 100644 --- a/_locales/ja/messages.json +++ b/_locales/ja/messages.json @@ -168,6 +168,12 @@ "message": "このスタイルを削除してもよろしいですか?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "正規表現は無効です。", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/nl/messages.json b/_locales/nl/messages.json index 0905ceb2..d4fe0d85 100644 --- a/_locales/nl/messages.json +++ b/_locales/nl/messages.json @@ -168,6 +168,12 @@ "message": "Weet u zeker dat u deze stijl wilt verwijderen?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp is ongeldig.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/pt_BR/messages.json b/_locales/pt_BR/messages.json index 53452a15..01776a49 100644 --- a/_locales/pt_BR/messages.json +++ b/_locales/pt_BR/messages.json @@ -168,6 +168,12 @@ "message": "Tem certeza de que deseja excluir este estilo?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp is invalid.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index d5067a42..cde4ac07 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -168,6 +168,12 @@ "message": "Удалить этот стиль?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Ошибка в регулярном выражении.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/sr/messages.json b/_locales/sr/messages.json index c9b3913e..8b13f395 100644 --- a/_locales/sr/messages.json +++ b/_locales/sr/messages.json @@ -168,6 +168,12 @@ "message": "Да ли сте сигурни да желите да избришете овај стил?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Регуларни израз је неисправан.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/sv/messages.json b/_locales/sv/messages.json index 97fbe9c6..230af782 100644 --- a/_locales/sv/messages.json +++ b/_locales/sv/messages.json @@ -168,6 +168,12 @@ "message": "Är du säker på att du vill ta bort denna stil?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp:en är ogiltig", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/sv_SE/messages.json b/_locales/sv_SE/messages.json index c0f95116..6b78292a 100644 --- a/_locales/sv_SE/messages.json +++ b/_locales/sv_SE/messages.json @@ -168,6 +168,12 @@ "message": "Är du säker på att du vill ta bort denna stil?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp:en är ogiltig.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/te/messages.json b/_locales/te/messages.json index 16ed6424..c41b2eac 100644 --- a/_locales/te/messages.json +++ b/_locales/te/messages.json @@ -168,6 +168,12 @@ "message": "మీరు నజంగానే ఈ శైలిని తొలగించాలనుకుంటున్నారా?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp is invalid.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/tr/messages.json b/_locales/tr/messages.json index 83453eee..a1377bec 100644 --- a/_locales/tr/messages.json +++ b/_locales/tr/messages.json @@ -168,6 +168,12 @@ "message": "Bu stili silmek istediğinizden emin misiniz?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp is invalid.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/zh/messages.json b/_locales/zh/messages.json index 82a6a84c..a1c4d1fb 100644 --- a/_locales/zh/messages.json +++ b/_locales/zh/messages.json @@ -168,6 +168,12 @@ "message": "确定要删除这个样式吗?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "Regexp is invalid.", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index 8b772618..22227c36 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -168,6 +168,12 @@ "message": "确定要删除此样式吗?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "正则表达式无效。", "description": "Validation message for a bad regexp in a style" diff --git a/_locales/zh_TW/messages.json b/_locales/zh_TW/messages.json index 18e2c92e..88c47e52 100644 --- a/_locales/zh_TW/messages.json +++ b/_locales/zh_TW/messages.json @@ -168,6 +168,12 @@ "message": "確定要刪除這個樣式嗎?", "description": "Confirmation before deleting a style" }, + "confirmOK": { + "message": "OK" + }, + "confirmCancel": { + "message": "Cancel" + }, "styleBadRegexp": { "message": "正規表示式無效。", "description": "Validation message for a bad regexp in a style" diff --git a/manifest.json b/manifest.json index a77d8f74..61d0053d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Stylus", - "version": "1.0.3", + "version": "1.0.4", "description": "__MSG_description__", "homepage_url": "http://add0n.com/stylus.html", "manifest_version": 2, diff --git a/popup.css b/popup.css index 9028e9b3..165c48c8 100644 --- a/popup.css +++ b/popup.css @@ -219,4 +219,42 @@ body>div:not(#installed) { text-overflow: ellipsis; white-space: nowrap; padding-right: 5px; +} + /* confirm */ +#confirm, +#confirm>div>span { + align-items: center; + justify-content: center; +} +#confirm { + display: none; /* flex */ + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 100%; + margin: 0!important; + box-sizing: border-box; + background-color: rgba(0, 0, 0, 0.4); +} +#confirm[data-display=true] { + display: flex; +} +#confirm>div { + width: 80%; + height: 100px; + max-height: 80%; + background-color: #fff; + display: flex; + flex-direction: column; + border: solid 2px rgba(0, 0, 0, 0.5); +} +#confirm>div>span { + display: flex; + flex: 1; + padding: 0 10px; +} +#confirm>div>div { + padding: 10px; + direction: rtl; } diff --git a/popup.html b/popup.html index f6dcabb4..22237289 100644 --- a/popup.html +++ b/popup.html @@ -67,6 +67,16 @@ + +
+
+ +
+ + +
+
+
diff --git a/popup.js b/popup.js index 9a3a9c17..8eaa77d0 100644 --- a/popup.js +++ b/popup.js @@ -116,15 +116,22 @@ function enable(event, enabled) { } function doDelete() { - // Opera can't do confirms in popups - if (getBrowser() != "Opera") { - if (!confirm(t('deleteStyleConfirm'))) { - return; - } - } - var id = getId(event); - deleteStyle(id); + document.getElementById('confirm').dataset.display = true; + let id = getId(event); + document.getElementById('confirm').dataset.id = id; + } +document.getElementById('confirm').addEventListener('click', e => { + let cmd = e.target.dataset.cmd; + if (cmd === 'ok') { + deleteStyle(document.getElementById('confirm').dataset.id); + window.close(); + } + // + if (cmd) { + document.getElementById('confirm').dataset.display = false; + } +}); function getBrowser() { if (navigator.userAgent.indexOf("OPR") > -1) {