Added new languages and moved extension files to folder src
diff --git a/src/LICENSE b/src/LICENSE
new file mode 100644
index 0000000..23b8b3e
--- /dev/null
+++ b/src/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Adrià Vilanova Martínez
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/src/_locales/ca/messages.json b/src/_locales/ca/messages.json
new file mode 100644
index 0000000..a2f36c2
--- /dev/null
+++ b/src/_locales/ca/messages.json
@@ -0,0 +1,102 @@
+{
+ "appName": {
+ "message": "Traduïr Text Seleccionat",
+ "description": "The app name"
+ },
+ "appBetaName": {
+ "message": "Traduïr Text Seleccionat (Beta)",
+ "description": "The beta app name"
+ },
+ "appDescription" : {
+ "message": "Tradueix el text que seleccionis amb el Traductor de Google",
+ "description": "The app description"
+ },
+ "contextmenu_title" : {
+ "message": "Tradueix la selecció al...",
+ "description": "Title of the context menu that appears when a right click is done. Inside this prent menu there are the menus"
+ },
+ "contextmenu_title2" : {
+ "message": "Tradueix la selecció a '$language$'",
+ "description": "Title of the context menu that appears when a right click is done and there's only one language available.",
+ "placeholders": {
+ "language": {
+ "content": "$1",
+ "example": "Language to translate into."
+ }
+ }
+ },
+ "contextmenu_edit" : {
+ "message": "Edita idiomes...",
+ "description": "Title of the option inside the 'Translate section into...' context menu."
+ },
+ "options_welcome" : {
+ "message": "Benvingut!",
+ "description": "Title of the options page"
+ },
+ "options_introduction" : {
+ "message": "Si us plau, selecciona els idiomes que vols que surtin al menú \"traduïr\".",
+ "description": "Introduction paragraph to the options pages"
+ },
+ "options_languageselectheader" : {
+ "message": "Idiomes:",
+ "description": "Header of the language select option."
+ },
+ "options_otheroptionsheader" : {
+ "message": "Altres opcions:",
+ "description": "Header of the options page."
+ },
+ "options_tabsoption_1" : {
+ "message": "Obre Google Traductor en una nova pestanya per a cada traducció.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_2" : {
+ "message": "Obre Google Traductor en una única pestanya i reemplaça l'última traducció en comptes d'obrir varies pestanyes.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_3" : {
+ "message": "Obre Google Traductor en un panel i reemplaça l'última traducció (fa falta activar la bandera <a href='chrome://flags/#enable-panels' id='panelsflag'>--enable-panels</a>). <sup style='color:red; font-weight: bold;'>EXPERIMENTAL</sup>",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_savebutton" : {
+ "message": "Desar",
+ "description": "Save button in the settings app"
+ },
+ "options_addlanguage": {
+ "message": "Afegir idioma",
+ "description": "Title for the 'Add language' dialog"
+ },
+ "options_addlanguage_addbutton": {
+ "message": "Afegeix",
+ "description": "Add button in the footer of the languages list"
+ },
+ "options_language_label": {
+ "message": "Idioma:",
+ "description": "Label for the language selector in the 'Add language' dialog"
+ },
+ "options_credits" : {
+ "message": "Crèdits",
+ "description": "Title for the credits link and dialog"
+ },
+ "options_credits_homepage": {
+ "message": "pàgina web",
+ "description": "Homepage link for an item in the credits. NOTE: put in in lowercase letters"
+ },
+ "options_credits_by": {
+ "message": "",
+ "description": "Fragment of the author statement in an item of the credits. NOTE: put in in lowercase letters. EXAMPLE: '{{options_credits_by}} Adrià Vilanova Martínez'"
+ },
+ "options_ok": {
+ "message": "OK",
+ "description": "OK button in the dialogs"
+ },
+ "options_cancel": {
+ "message": "Cancel·lar",
+ "description": "Cancel button in the dialogs"
+ },
+ "notification_install_title": { "message": "Gràcies per instal·lar 'Traduïr Text Seleccionat'" },
+ "notification_install_message": { "message": "Fes clic en aquesta notificació per a configurar l'extensión." },
+ "notification_upgradedtostorage_title": { "message": "'Traduïr Text Seleccionat' s'ha actualizat a v0.6!" },
+ "notification_upgradedtostorage_message": { "message": "Ara la configuració es sincronitzarà en tots els teus dispositius! La part dolenta és que has de configurar l'extensión una altra vegada :-( Fes clic en aquesta notificación per a configurar-la." },
+ "notification_reorder_title": { "message": "'Traduïr Text Seleccionat' s'ha actualizat a v0.7!" },
+ "notification_reorder_message": { "message": "Ara pots configurar en quin ordre vols que apareixin els idiomes en el menú contextual." }
+}
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
new file mode 100644
index 0000000..a7c7422
--- /dev/null
+++ b/src/_locales/en/messages.json
@@ -0,0 +1,102 @@
+{
+ "appName": {
+ "message": "Translate Selected Text",
+ "description": "The app name"
+ },
+ "appBetaName": {
+ "message": "Translate Selected Text (Beta)",
+ "description": "The beta app name"
+ },
+ "appDescription": {
+ "message": "Translate selected text with Google Translator",
+ "description": "The app description"
+ },
+ "contextmenu_title": {
+ "message": "Translate selection into...",
+ "description": "Title of the context menu that appears when a right click is done. Inside this parent menu there are the menus"
+ },
+ "contextmenu_title2": {
+ "message": "Translate selection into '$language$'",
+ "description": "Title of the context menu that appears when a right click is done and there's only one language available.",
+ "placeholders": {
+ "language": {
+ "content": "$1",
+ "example": "Language to translate into."
+ }
+ }
+ },
+ "contextmenu_edit": {
+ "message": "Edit languages...",
+ "description": "Title of the option inside the 'Translate section into...' context menu."
+ },
+ "options_welcome": {
+ "message": "Welcome!",
+ "description": "Title of the options page"
+ },
+ "options_introduction": {
+ "message": "Please, select the languages you want to show up in the \"translate\" menu.",
+ "description": "Introduction paragraph to the options pages"
+ },
+ "options_languageselectheader": {
+ "message": "Languages:",
+ "description": "Header of the language select option."
+ },
+ "options_otheroptionsheader": {
+ "message": "Other options:",
+ "description": "Header of the options page."
+ },
+ "options_tabsoption_1": {
+ "message": "Open Google Translator in a new tab for each translation.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_2": {
+ "message": "Open Google Translator in a unique tab and override the last translation instead of opening several tabs.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_3": {
+ "message": "Open Google Translator in a panel and override the last translation (need to activate <a href='chrome://flags/#enable-panels' id='panelsflag'>--enable-panels</a> flag). <sup style='color:red; font-weight: bold;'>EXPERIMENTAL</sup>",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_savebutton": {
+ "message": "Save",
+ "description": "Save button in the settings page"
+ },
+ "options_addlanguage": {
+ "message": "Add language",
+ "description": "Title for the 'Add language' dialog"
+ },
+ "options_addlanguage_addbutton": {
+ "message": "Add",
+ "description": "Add button in the footer of the languages list"
+ },
+ "options_language_label": {
+ "message": "Language:",
+ "description": "Label for the language selector in the 'Add language' dialog"
+ },
+ "options_credits": {
+ "message": "Credits",
+ "description": "Title for the credits link and dialog"
+ },
+ "options_credits_homepage": {
+ "message": "homepage",
+ "description": "Homepage link for an item in the credits. NOTE: put in in lowercase letters"
+ },
+ "options_credits_by": {
+ "message": "by",
+ "description": "Fragment of the author statement in an item of the credits. NOTE: put in in lowercase letters. EXAMPLE: '{{options_credits_by}} Adrià Vilanova Martínez'"
+ },
+ "options_ok": {
+ "message": "OK",
+ "description": "OK button in the dialogs"
+ },
+ "options_cancel": {
+ "message": "Cancel",
+ "description": "Cancel button in the dialogs"
+ },
+ "notification_install_title": { "message": "Thanks for installing 'Translate Selected Text'" },
+ "notification_install_message": { "message": "Click this notification to set it up." },
+ "notification_upgradedtostorage_title": { "message": "'Translate Selected Text' was updated to v0.6!" },
+ "notification_upgradedtostorage_message": { "message": "Now your options will be synced across all your devices! The bad side is that you have to set up the extension again :-( Click this notification to set it up." },
+ "notification_reorder_title": { "message": "'Translate Selected Text' was updated to v0.7!" },
+ "notification_reorder_message": { "message": "Now you can configure in which order you want the languages to appear in the context menu. " }
+}
diff --git a/src/_locales/es/messages.json b/src/_locales/es/messages.json
new file mode 100644
index 0000000..723ab13
--- /dev/null
+++ b/src/_locales/es/messages.json
@@ -0,0 +1,102 @@
+{
+ "appName": {
+ "message": "Traducir Texto Seleccionado",
+ "description": "The app name"
+ },
+ "appBetaName": {
+ "message": "Traducir Texto Seleccionado (Beta)",
+ "description": "The beta app name"
+ },
+ "appDescription" : {
+ "message": "Traduce el texto que selecciones con el Traductor de Google.",
+ "description": "The app description"
+ },
+ "contextmenu_title" : {
+ "message": "Traducir selección al...",
+ "description": "Title of the context menu that appears when a right click is done. Inside this prent menu there are the menus"
+ },
+ "contextmenu_title2" : {
+ "message": "Traducir selección al '$language$'",
+ "description": "Title of the context menu that appears when a right click is done and there's only one language available.",
+ "placeholders": {
+ "language": {
+ "content": "$1",
+ "example": "Language to translate into."
+ }
+ }
+ },
+ "contextmenu_edit" : {
+ "message": "Modifica idiomas...",
+ "description": "Title of the option inside the 'Translate section into...' context menu."
+ },
+ "options_welcome" : {
+ "message": "¡Bienvenido!",
+ "description": "Title of the options page"
+ },
+ "options_introduction" : {
+ "message": "Por favor, selecciona los idiomas que quieres que se muestren en el menú \"traducir\".",
+ "description": "Introduction paragraph to the options pages"
+ },
+ "options_languageselectheader" : {
+ "message": "Idiomas:",
+ "description": "Header of the language select option."
+ },
+ "options_otheroptionsheader" : {
+ "message": "Otras opciones:",
+ "description": "Header of the options page."
+ },
+ "options_tabsoption_1" : {
+ "message": "Abre Google Traductor en una nueva pestaña para cada traducción.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_2" : {
+ "message": "Abre Google Traductor en una única pestaña y reemplaza la última traducción en vez de abrir varias pestañas.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_3" : {
+ "message": "Abre Google Traductor en un panel y remplaza la última traducción (hace falta activar la bandera <a href='chrome://flags/#enable-panels' id='panelsflag'>--enable-panels</a>). <sup style='color:red; font-weight: bold;'>EXPERIMENTAL</sup>",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_savebutton" : {
+ "message": "Guardar",
+ "description": "Save button in the settings app"
+ },
+ "options_addlanguage": {
+ "message": "Añadir idioma",
+ "description": "Title for the 'Add language' dialog"
+ },
+ "options_addlanguage_addbutton": {
+ "message": "Añade",
+ "description": "Add button in the footer of the languages list"
+ },
+ "options_language_label": {
+ "message": "Idioma:",
+ "description": "Label for the language selector in the 'Add language' dialog"
+ },
+ "options_credits": {
+ "message": "Créditos",
+ "description": "Title for the credits link and dialog"
+ },
+ "options_credits_homepage": {
+ "message": "página web",
+ "description": "Homepage link for an item in the credits. NOTE: put in in lowercase letters"
+ },
+ "options_credits_by": {
+ "message": "",
+ "description": "Fragment of the author statement in an item of the credits. NOTE: put in in lowercase letters. EXAMPLE: '{{options_credits_by}} Adrià Vilanova Martínez'"
+ },
+ "options_ok": {
+ "message": "OK",
+ "description": "OK button in the dialogs"
+ },
+ "options_cancel": {
+ "message": "Cancelar",
+ "description": "Cancel button in the dialogs"
+ },
+ "notification_install_title": { "message": "Gracias por instalar 'Traducir Texto Seleccionado'" },
+ "notification_install_message": { "message": "Haz clic en esta notificación para configurar la extensión." },
+ "notification_upgradedtostorage_title": { "message": "'Traducir Texto Seleccionado' se ha actualizado a v0.6!" },
+ "notification_upgradedtostorage_message": { "message": "¡Ahora la configuración se sincronizará en todos tus dispositivos! La parte mala es que tienes que configurar la extensión otra vez :-( Haz clic en esta notificación para configurarla." },
+ "notification_reorder_title": { "message": "'Traducir Texto Seleccionado' se ha actualizado a v0.7!" },
+ "notification_reorder_message": { "message": "Ahora puedes configurar en qué orden quieres que aparezcan los idiomas en el menú contextual." }
+}
diff --git a/src/_locales/ru/messages.json b/src/_locales/ru/messages.json
new file mode 100644
index 0000000..b370213
--- /dev/null
+++ b/src/_locales/ru/messages.json
@@ -0,0 +1,68 @@
+{
+ "appName": {
+ "message": "Перевести выбранный текст",
+ "description": "The app name"
+ },
+ "appBetaName": {
+ "message": "Перевести выбранный текст (Beta)",
+ "description": "The beta app name"
+ },
+ "appDescription": {
+ "message": "Перевод выбранного текста с помощью Google Переводчика",
+ "description": "The app description"
+ },
+ "contextmenu_title": {
+ "message": "Перевести на...",
+ "description": "Title of the context menu that appears when a right click is done. Inside this parent menu there are the menus"
+ },
+ "contextmenu_title2" : {
+ "message": "Перевести на '$language$'",
+ "description": "Title of the context menu that appears when a right click is done and there's only one language available.",
+ "placeholders": {
+ "language": {
+ "content": "$1",
+ "example": "Language to translate into."
+ }
+ }
+ },
+ "contextmenu_edit": {
+ "message": "Настройки...",
+ "description": "Title of the option inside the 'Translate section into...' context menu."
+ },
+ "options_welcome": {
+ "message": "Добро пожаловать!",
+ "description": "Title of the options page"
+ },
+ "options_introduction": {
+ "message": "Выберите языки, которые вы хотите видеть в контекстном меню.",
+ "description": "Introduction paragraph to the options pages"
+ },
+ "options_languageselectheader": {
+ "message": "Языки:",
+ "description": "Header of the language select option."
+ },
+ "options_otheroptionsheader": {
+ "message": "Другие опции:",
+ "description": "Header of the options page."
+ },
+ "options_tabsoption_1": {
+ "message": "Открывать вкладку Google Переводчика в новой вкладке для каждого перевода.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_2": {
+ "message": "Открывать Google Переводчик в одной вкладке, и перезаписывать предыдущие результаты, вместо открытия нескольких вкладок.",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_tabsoption_3": {
+ "message": "Открыть Google Переводчик в новой панели и перезаписать последний результат перевода (нужно активировать флаг <a href='chrome://flags/#enable-panels' id='panelsflag'>--enable-panels</a>). <sup style='color:red; font-weight: bold;'>ЭКСПЕРИМЕНТАЛЬНАЯ ФУНКЦИЯ</sup>",
+ "description": "Option which defines how should the app behave in relation to tabs."
+ },
+ "options_savebutton": {
+ "message": "Сохранить",
+ "description": "Save button in the settings page"
+ },
+ "notification_install_title": { "message": "Спасибо за установку \"Перевести выбранный текст\"" },
+ "notification_install_message": { "message": "Нажмите сюда, чтобы настроить расширение." },
+ "notification_upgradedtostorage_title": { "message": "\"Перевести выбранный текст\" было обновлено до 0.6!" },
+ "notification_upgradedtostorage_message": { "message": "Теперь настройки расширения будут синхронизироваться со всеми вашими устройствами, но придётся настроить расширение снова :-( Нажмите сюда, чтобы настроить расширение." }
+}
\ No newline at end of file
diff --git a/src/background.js b/src/background.js
new file mode 100644
index 0000000..3c34a89
--- /dev/null
+++ b/src/background.js
@@ -0,0 +1,212 @@
+// To generate isoLangs, edit code at isolangs.json and use Closure to minimize it
+var isoLangs={af:{name:"Afrikaans",nativeName:"Afrikaans"},sq:{name:"Albanian",nativeName:"Shqip"},am:{name:"Amharic",nativeName:"\u12a0\u121b\u122d\u129b"},ar:{name:"Arabic",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629"},hy:{name:"Armenian",nativeName:"\u0540\u0561\u0575\u0565\u0580\u0565\u0576"},az:{name:"Azerbaijani",nativeName:"az\u0259rbaycan dili"},eu:{name:"Basque",nativeName:"euskara"},be:{name:"Belarusian",nativeName:"\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f"},
+bn:{name:"Bengali",nativeName:"\u09ac\u09be\u0982\u09b2\u09be"},bs:{name:"Bosnian",nativeName:"bosanski jezik"},bg:{name:"Bulgarian",nativeName:"\u0431\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438 \u0435\u0437\u0438\u043a"},ca:{name:"Catalan",nativeName:"Catal\u00e0"},ceb:{name:"Cebuano",nativeName:"Bisaya"},ny:{name:"Chichewa",nativeName:"chiChe\u0175a"},zh:{name:"Chinese",nativeName:"\u4e2d\u6587 (Zh\u014dngw\u00e9n)"},co:{name:"Corsican",nativeName:"corsu"},hr:{name:"Croatian",nativeName:"hrvatski"},
+cs:{name:"Czech",nativeName:"\u010desky"},da:{name:"Danish",nativeName:"dansk"},nl:{name:"Dutch",nativeName:"Nederlands"},en:{name:"English",nativeName:"English"},eo:{name:"Esperanto",nativeName:"Esperanto"},et:{name:"Estonian",nativeName:"eesti"},tl:{name:"Filipino",nativeName:"Pilipino"},fi:{name:"Finnish",nativeName:"suomi"},fr:{name:"French",nativeName:"fran\u00e7ais"},fy:{name:"Frisian",nativeName:"Frysk"},gl:{name:"Galician",nativeName:"Galego"},ka:{name:"Georgian",nativeName:"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8"},
+de:{name:"German",nativeName:"Deutsch"},el:{name:"Greek",nativeName:"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"},gu:{name:"Gujarati",nativeName:"\u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0"},ht:{name:"Haitian Creole",nativeName:"Krey\u00f2l ayisyen"},ha:{name:"Hausa",nativeName:"Hausa"},haw:{name:"Hawaiian",nativeName:"Hausa"},iw:{name:"Hebrew",nativeName:"\u05e2\u05d1\u05e8\u05d9\u05ea"},hi:{name:"Hindi",nativeName:"\u0939\u093f\u0928\u094d\u0926\u0940, \u0939\u093f\u0902\u0926\u0940"},hmn:{name:"Hmong",
+nativeName:"lus Hmoob"},hu:{name:"Hungarian",nativeName:"Magyar"},is:{name:"Icelandic",nativeName:"\u00cdslenska"},ig:{name:"Igbo",nativeName:"As\u1ee5s\u1ee5 Igbo"},id:{name:"Indonesian",nativeName:"Bahasa Indonesia"},ga:{name:"Irish",nativeName:"Gaeilge"},it:{name:"Italian",nativeName:"Italiano"},ja:{name:"Japanese",nativeName:"\u65e5\u672c\u8a9e (\u306b\u307b\u3093\u3054\uff0f\u306b\u3063\u307d\u3093\u3054)"},jv:{name:"Javanese",nativeName:"basa Jawa"},kn:{name:"Kannada",nativeName:"\u0c95\u0ca8\u0ccd\u0ca8\u0ca1"},
+kk:{name:"Kazakh",nativeName:"\u049a\u0430\u0437\u0430\u049b \u0442\u0456\u043b\u0456"},km:{name:"Khmer",nativeName:"\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a"},ko:{name:"Korean",nativeName:"\ud55c\uad6d\uc5b4 (\u97d3\u570b\u8a9e)"},ku:{name:"Kurdish (Kurmanji)",nativeName:"Kurd\u00ee"},ky:{name:"Kyrgyz",nativeName:"\u043a\u044b\u0440\u0433\u044b\u0437 \u0442\u0438\u043b\u0438"},lo:{name:"Lao",nativeName:"\u0e9e\u0eb2\u0eaa\u0eb2\u0ea5\u0eb2\u0ea7"},la:{name:"Latin",nativeName:"latine"},
+lv:{name:"Latvian",nativeName:"latvie\u0161u valoda"},lt:{name:"Lithuanian",nativeName:"lietuvi\u0173 kalba"},lb:{name:"Luxembourgish",nativeName:"L\u00ebtzebuergesch"},mk:{name:"Macedonian",nativeName:"\u043c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438 \u0458\u0430\u0437\u0438\u043a"},mg:{name:"Malagasy",nativeName:"Malagasy fiteny"},ms:{name:"Malay",nativeName:"bahasa Melayu"},ml:{name:"Malayalam",nativeName:"\u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02"},mt:{name:"Maltese",nativeName:"Malti"},
+mi:{name:"M\u0101ori",nativeName:"te reo M\u0101ori"},mr:{name:"Marathi",nativeName:"\u092e\u0930\u093e\u0920\u0940"},mn:{name:"Mongolian",nativeName:"\u043c\u043e\u043d\u0433\u043e\u043b"},my:{name:"Myanmar",nativeName:"\u1017\u1019\u102c\u1005\u102c"},ne:{name:"Nepali",nativeName:"\u0928\u0947\u092a\u093e\u0932\u0940"},no:{name:"Norwegian",nativeName:"Norsk"},ps:{name:"Pashto",nativeName:"\u067e\u069a\u062a\u0648"},fa:{name:"Persian",nativeName:"\u0641\u0627\u0631\u0633\u06cc"},pl:{name:"Polish",
+nativeName:"polski"},pt:{name:"Portuguese",nativeName:"Portugu\u00eas"},pa:{name:"Punjabi",nativeName:"\u0a2a\u0a70\u0a1c\u0a3e\u0a2c"},ro:{name:"Romanian",nativeName:"rom\u00e2n\u0103"},ru:{name:"Russian",nativeName:"\u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a"},sm:{name:"Samoan",nativeName:"gagana faa Samoa"},gd:{name:"Scots Gaelic",nativeName:"G\u00e0idhlig"},sr:{name:"Serbian",nativeName:"\u0441\u0440\u043f\u0441\u043a\u0438 \u0458\u0435\u0437\u0438\u043a"},st:{name:"Sesotho",
+nativeName:"Sesotho"},sn:{name:"Shona",nativeName:"chiShona"},sd:{name:"Sindhi",nativeName:"\u0938\u093f\u0928\u094d\u0927\u0940"},si:{name:"Sinhala",nativeName:"\u0dc3\u0dd2\u0d82\u0dc4\u0dbd"},sk:{name:"Slovak",nativeName:"sloven\u010dina"},sl:{name:"Slovenian",nativeName:"sloven\u0161\u010dina"},so:{name:"Somali",nativeName:"Soomaaliga"},es:{name:"Spanish",nativeName:"espa\u00f1ol"},su:{name:"Sundanese",nativeName:"Basa Sunda"},sw:{name:"Swahili",nativeName:"Kiswahili"},sv:{name:"Swedish",nativeName:"svenska"},
+tg:{name:"Tajik",nativeName:"\u0442\u043e\u04b7\u0438\u043a\u04e3"},ta:{name:"Tamil",nativeName:"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd"},te:{name:"Telugu",nativeName:"\u0c24\u0c46\u0c32\u0c41\u0c17\u0c41"},th:{name:"Thai",nativeName:"\u0e44\u0e17\u0e22"},tr:{name:"Turkish",nativeName:"T\u00fcrk\u00e7e"},uk:{name:"Ukrainian",nativeName:"\u0443\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430"},ur:{name:"Urdu",nativeName:"\u0627\u0631\u062f\u0648"},uz:{name:"Uzbek",nativeName:"zbek"},vi:{name:"Vietnamese",
+nativeName:"Ti\u1ebfng Vi\u1ec7t"},cy:{name:"Welsh",nativeName:"Cymraeg"},xh:{name:"Xhosa",nativeName:"isiXhosa"},yi:{name:"Yiddish",nativeName:"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9"},yo:{name:"Yoruba",nativeName:"Yor\u00f9b\u00e1"},za:{name:"Zhuang, Chuang",nativeName:"Sa\u026f cue\u014b\u0185"},zu:{name:"Zulu",nativeName:"isiZulu"}};
+
+var array_elements = new Array(), translator_tab = false, translator_window = false;
+
+function isEmpty(obj) {
+ return Object.keys(obj).length === 0;
+}
+
+function click(info, tab) {
+ chrome.storage.sync.get("uniquetab", function(items) {
+ var settings_tab = {'url': 'https://translate.google.com/#auto/'+array_elements[info.menuItemId]['langCode']+'/'+encodeURIComponent(info.selectionText)};
+ if (translator_tab && items.uniquetab == "yep") {
+ chrome.tabs.update(translator_tab, settings_tab, function(tab){
+ chrome.tabs.highlight({'windowId': tab.windowId, 'tabs': tab.index}, function() {
+ chrome.windows.update(tab.windowId, {focused: true}, function() {});
+ });
+ });
+ } else if (items.uniquetab == "panel") {
+ chrome.windows.create({
+ type: 'panel', url: 'https://translate.google.com/#auto/'+array_elements[info.menuItemId]['langCode']+'/'+encodeURIComponent(info.selectionText), width: 1000, height: 382}, function(tab) {
+ translator_window = tab.windowId;
+ translator_tab = tab.id;
+ chrome.windows.onRemoved.addListener(function (windowId) {
+ if (windowId == translator_window) {
+ translator_window = false;
+ translator_tab = false;
+ }
+ });
+ }
+ );
+ } else {
+ chrome.tabs.create(settings_tab, function(tab) {
+ translator_window = tab.windowId;
+ translator_tab = tab.id;
+ chrome.tabs.onRemoved.addListener(function (tabId, removeInfo) {
+ if (tabId == translator_tab) {
+ translator_window = false;
+ translator_tab = false;
+ }
+ });
+ });
+ }
+ });
+}
+
+function click2(info, tab) {
+ if (chrome.runtime.openOptionsPage) {
+ // New way to open options pages, if supported (Chrome 42+).
+ chrome.runtime.openOptionsPage();
+ } else {
+ chrome.tabs.create({'url': 'chrome-extension://'+chrome.i18n.getMessage("@@extension_id")+'/options.html', 'active': true}, function(tab) {
+ chrome.windows.update(tab.windowId, {'focused': true}, function() {});
+ });
+ }
+
+}
+
+function createmenus() {
+ chrome.storage.sync.get("translateinto", function(items) {
+ chrome.contextMenus.removeAll();
+
+ var count = 0, singleone = true;
+
+ for (var language in items.translateinto) {
+ if (count == 0) {
+ count++;
+ } else {
+ singleone = false;
+ break;
+ }
+ }
+
+ if (singleone) {
+ for (var language_id in items.translateinto) {
+ var language = items.translateinto[language_id];
+ var languagem = isoLangs[language];
+ var title = languagem.name + " ("+languagem.nativeName+")";
+ var parent = chrome.contextMenus.create({"id": "tr_single_parent", "title": chrome.i18n.getMessage("contextmenu_title2", languagem.name), "contexts": ["selection"]});
+ array_elements[parent] = new Array();
+ array_elements[parent]["langCode"] = language;
+ array_elements[parent]["langName"] = languagem.name;
+ array_elements[parent]["langNativeName"] = language.nativeName;
+ }
+ } else {
+ var parent = chrome.contextMenus.create({"id": "parent", "title": chrome.i18n.getMessage("contextmenu_title"), "contexts": ["selection"]});
+ for (var language_id in items.translateinto) {
+ var language = items.translateinto[language_id];
+ var languagem = isoLangs[language];
+ var title = languagem.name + " ("+languagem.nativeName+")";
+ var id = chrome.contextMenus.create({"id": "tr_language_"+language, "title": title, "parentId": parent, "contexts":["selection"]});
+ array_elements[id] = new Array();
+ array_elements[id]["langCode"] = language;
+ array_elements[id]["langName"] = languagem.name;
+ array_elements[id]["langNativeName"] = language.nativeName;
+ }
+ var id = chrome.contextMenus.create({"id": "tr_separator", "type": "separator","parentId": parent, "contexts":["selection"]});
+ var id = chrome.contextMenus.create({"id": "tr_options", "title": chrome.i18n.getMessage("contextmenu_edit"), "parentId": parent, "contexts":["selection"]});
+ }
+ });
+}
+
+chrome.runtime.onInstalled.addListener(function(details) {
+ chrome.storage.sync.get(null, function(items) {
+ if (details.reason == "install") {
+ if (isEmpty(items)) {
+ var settings = {'translateinto': {}, 'uniquetab': ''}, default_language = chrome.i18n.getMessage("@@ui_locale").split("_")[0];
+ if (isoLangs[default_language] != "undefined") {
+ settings.translateinto[default_language] = default_language;
+ }
+ chrome.storage.sync.set(settings, function() {
+ chrome.notifications.create("install", {
+ type: "basic",
+ iconUrl: "icons/translate-128.png",
+ title: chrome.i18n.getMessage("notification_install_title"),
+ message: chrome.i18n.getMessage("notification_install_message"),
+ isClickable: true
+ }, function(id) {});
+ });
+ }
+ }
+ if (details.reason == "update") {
+ var version = details.previousVersion.split(".");
+ if (version[0] == "0" && version[1] < "6") {
+ var settings = {'languages': {}, 'uniquetab': ''}, default_language = chrome.i18n.getMessage("@@ui_locale").split("_")[0];
+ if (isoLangs[default_language] != "undefined") {
+ settings.languages[default_language] = default_language;
+ }
+ chrome.storage.sync.set(settings, function() {
+ chrome.notifications.create("upgradedtostorage", {
+ type: "basic",
+ iconUrl: "icons/translate-128.png",
+ title: chrome.i18n.getMessage("notification_upgradedtostorage_title"),
+ message: chrome.i18n.getMessage("notification_upgradedtostorage_message"),
+ isClickable: true
+ }, function(id) {});
+ });
+ }
+ if (version[0] == "0" && version[1] < "7") {
+ items.translateinto = {};
+ var i = 0;
+ for (var language in items.languages) {
+ items.translateinto[i] = items.languages[language];
+ i++;
+ }
+ delete(items.languages);
+ chrome.storage.sync.set(items, function() {
+ chrome.notifications.create("reorder", {
+ type: "basic",
+ iconUrl: "icons/translate-128.png",
+ title: chrome.i18n.getMessage("notification_reorder_title"),
+ message: chrome.i18n.getMessage("notification_reorder_message"),
+ isClickable: true
+ }, function(id) {});
+ });
+ }
+ }
+ });
+});
+
+chrome.storage.onChanged.addListener(function(changes, areaName) {
+ if (areaName == "sync")
+ createmenus();
+});
+
+chrome.storage.sync.get(null, function(items) {
+ if (items.translateinto) {
+ createmenus();
+ } else {
+ chrome.contextMenus.removeAll();
+ var parent = chrome.contextMenus.create({"id": "tr_parent", "title": chrome.i18n.getMessage("contextmenu_title"), "contexts":["selection"]});
+ var id = chrome.contextMenus.create({"id": "tr_options", "title": chrome.i18n.getMessage("contextmenu_edit"), "parentId": parent, "contexts":["selection"]});
+ }
+});
+
+chrome.notifications.onClicked.addListener(function(notification_id) {
+ switch(notification_id) {
+ case "install":
+ click2();
+ break;
+
+ case "upgradedtostorage":
+ click2();
+ break;
+
+ case "reorder":
+ click2();
+ break;
+ }
+ chrome.notifications.clear(notification_id, function() {
+
+ });
+});
+
+chrome.contextMenus.onClicked.addListener(function(info, tab) {
+ if (info.menuItemId == "tr_options") {
+ click2(info, tab);
+ } else {
+ click(info, tab);
+ }
+});
diff --git a/src/css/options.css b/src/css/options.css
new file mode 100644
index 0000000..72b5904
--- /dev/null
+++ b/src/css/options.css
@@ -0,0 +1,157 @@
+/*@import url("widgets.css");*/
+
+body {
+ padding: 10px;
+ font-family: "Roboto", "Arial", sans-serif!important;
+ background-color: #BBDEFB;
+ background-repeat: repeat;
+ background-position: left top;
+ font-size: 90%;
+ cursor: default;
+ min-width: 400px;
+}
+h1 {
+ text-align: center;
+ font-size: 30px;
+}
+h2 {
+ font-size: 20px;
+}
+#languages_container {
+ width: 300px;
+ height: 365px;
+ border: 1px solid #ccc;
+ background-color: #E3F2FD;
+ overflow: auto;
+}
+#languages {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
+#languages li {
+ padding: 15px;
+ border-bottom: 1px dashed #ddd;
+ background-color: #EEF7FD;
+ cursor: move;
+ -webkit-user-select: none;
+}
+#languages li.sortable-ghost {
+ background-color: #E3F2FD;
+}
+#languages li .delete {
+ font-size: 14px;
+ float: right;
+ cursor: pointer;
+ color: red;
+}
+#languages_footer {
+ width: 300px;
+ height: 35px;
+ background-color: #fff;
+ border: 1px solid #ccc;
+ border-top: 0;
+}
+button, input, select, option {
+ font-size: 13px!important;
+}
+#languages_add {
+ margin-left: 4px;
+ margin-top: 4px;
+}
+#save {
+ display: block;
+ margin: 18px auto;
+}
+
+/* Dialog */
+dialog#languages_add_dialog {
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ margin-left: -216px;
+ margin-top: -91px;
+ height: 150px;
+ width: 400px;
+ border: 1px solid rgba(0, 0, 0, 0.3);
+ border-radius: 6px;
+ box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+}
+
+dialog h3 {
+ margin-bottom: 10px;
+}
+
+dialog #language_label {
+ font-size: 12px;
+}
+
+dialog select {
+ width: 100%;
+}
+
+dialog .action_buttons {
+ margin-top: 10px;
+ float: right;
+}
+
+dialog::backdrop {
+ position: fixed;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ background-color: rgba(0, 0, 0, 0.5);
+}
+
+/* Credits */
+#credits_container {
+ position: absolute;
+ top: 0px;
+ right: 50px;
+ background: rgb(195, 235, 204);
+ border: solid 1px rgb(139, 139, 139);
+ border-top: 0;
+ border-radius: 0px 0px 5px 5px;
+}
+
+#credits_container a {
+ color: green!important;
+ margin: 0 5px;
+}
+
+dialog#credits_dialog {
+ position: fixed;
+ top: 50%;
+ left: 50%;
+ margin-left: -216px;
+ margin-top: -231px;
+ height: 430px;
+ width: 400px;
+ border: 1px solid rgba(0, 0, 0, 0.3);
+ border-radius: 6px;
+ box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
+}
+
+dialog#credits_dialog .content_area h4 {
+ margin-bottom: 0px;
+}
+
+dialog#credits_dialog .content_area a.homepage {
+ position: absolute;
+ right: 16px;
+ font-size: 14px;
+}
+
+dialog#credits_dialog .content_area p, dialog#credits_dialog .content_area span {
+ font-size: 14px;
+}
+
+dialog#credits_dialog .content_area p.author {
+ margin-top: 7px;
+}
+
+#otheroptions p {
+ margin-top: 0;
+ margin-bottom: 0;
+}
diff --git a/src/css/widgets.css b/src/css/widgets.css
new file mode 100644
index 0000000..c988a27
--- /dev/null
+++ b/src/css/widgets.css
@@ -0,0 +1,304 @@
+/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in https://chromium.googlesource.com/chromium/src/+/master/LICENSE */
+
+/* This file defines styles for form controls. The order of rule blocks is
+ * important as there are some rules with equal specificity that rely on order
+ * as a tiebreaker. These are marked with OVERRIDE. */
+
+/* Default state **************************************************************/
+
+:-webkit-any(button,
+ input[type='button'],
+ input[type='submit']):not(.custom-appearance):not(.link-button),
+select,
+input[type='checkbox'],
+input[type='radio'] {
+ -webkit-appearance: none;
+ -webkit-user-select: none;
+ background-image: -webkit-linear-gradient(#ededed, #ededed 38%, #dedede);
+ border: 1px solid rgba(0, 0, 0, 0.25);
+ border-radius: 2px;
+ box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08),
+ inset 0 1px 2px rgba(255, 255, 255, 0.75);
+ color: #444;
+ font: inherit;
+ margin: 0 1px 0 0;
+ outline: none;
+ text-shadow: 0 1px 0 rgb(240, 240, 240);
+}
+
+:-webkit-any(button,
+ input[type='button'],
+ input[type='submit']):not(.custom-appearance):not(.link-button),
+select {
+ min-height: 2em;
+ min-width: 4em;
+
+}
+
+:-webkit-any(button,
+ input[type='button'],
+ input[type='submit']):not(.custom-appearance):not(.link-button) {
+ -webkit-padding-end: 10px;
+ -webkit-padding-start: 10px;
+}
+
+select {
+ -webkit-appearance: none;
+ -webkit-padding-end: 20px;
+ -webkit-padding-start: 6px;
+ /* OVERRIDE */
+ background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAICAQAAACxSAwfAAAAUklEQVQY02P4z0AMRGZGMaShwCisyhITmb8huMzfEhOxKvuvsGAh208Ik+3ngoX/FbBbClcIUcSAw21QhXxfIIrwKAMpfNsEUYRXGVCEFc6CQwBqq4CCCtU4VgAAAABJRU5ErkJggg==') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAQCAQAAAA/1a6rAAAAQUlEQVR4Xu3MsQnAMBAEMI1+myf9gw0+3ASCenmu+mQn2yGn3S4Mp906DEW3CEPfzTD03QxD380w3OmIUHe9v+u9QwAt93yns5cAAAAASUVORK5CYII=') 2x),
+ -webkit-linear-gradient(#ededed, #ededed 38%, #dedede);
+ background-position: right center;
+ background-repeat: no-repeat;
+}
+
+html[dir='rtl'] select {
+ background-position: center left;
+}
+
+input[type='checkbox'] {
+
+bottom: 2px;
+ height: 13px;
+ position: relative;
+ vertical-align: middle;
+ width: 13px;
+}
+
+input[type='radio'] {
+ /* OVERRIDE */
+ border-radius: 100%;
+ bottom: 1px;
+ height: 15px;
+ position: relative;
+ vertical-align: middle;
+ width: 15px;
+}
+
+/* TODO(estade): add more types here? */
+input[type='number'],
+input[type='password'],
+input[type='search'],
+input[type='text'],
+input[type='url'],
+input:not([type]),
+textarea {
+ border: 1px solid #bfbfbf;
+ border-radius: 2px;
+ box-sizing: border-box;
+ color: #444;
+ font: inherit;
+ margin: 0;
+ /* Use min-height to accommodate addditional padding for touch as needed. */
+ min-height: 2em;
+ padding: 3px;
+ outline: none;
+/* For better alignment between adjacent buttons and inputs. */
+ padding-bottom: 4px;
+}
+
+input[type='search'] {
+ -webkit-appearance: textfield;
+ /* NOTE: Keep a relatively high min-width for this so we don't obscure the end
+ * of the default text in relatively spacious languages (i.e. German). */
+ min-width: 160px;
+}
+
+/* Remove when https://bugs.webkit.org/show_bug.cgi?id=51499 is fixed.
+ * TODO(dbeam): are there more types that would benefit from this? */
+input[type='search']::-webkit-textfield-decoration-container {
+ direction: inherit;
+}
+
+/* Checked ********************************************************************/
+
+input[type='checkbox']:checked::before {
+ -webkit-user-select: none;
+ background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAQAAAADpb+tAAAAaElEQVR4Xl3PIQoCQQCF4Y8JW42D1bDZ4iVEjDbxFpstYhC7eIVBZHkXFGw734sv/TqDQQ8Xb1udja/I8igeIm7Aygj2IpoKTGZnVRNxAHYi4iPiDlA9xX+aNQDFySziqDN6uSp6y7ofEMwZ05uUZRkAAAAASUVORK5CYII=') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAQAAABuvaSwAAAAvElEQVR4XrXPMUrDYBzG4UeRZnAQnFxq3XT3AsVABm8QPIHQIeAJuoqb2s1BcHAIin4HVLqEvx9NQgb5rc/wvn4mNBUbqlKDcezCp6Qexxx7lbapx/CBe6mrHsYrKXQ7hKtIre1nOD/W9eiQiK80inis680JEc+1kien+TEfzom4sJG2aZXxmG9LIqaRerohx6V2J72zl2NY2OTUgxm7MEU25sURfZg4590Zw5iFZ8mXS0ZwN+eaPjyh/8O/H7bzPJ5NOo0AAAAASUVORK5CYII=') 2x);
+ background-size: 100% 100%;
+ content: '';
+ display: block;
+ height: 100%;
+ width: 100%;
+}
+
+input[type='radio']:checked::before {
+ background-color: #666;
+ border-radius: 100%;
+ bottom: 3px;
+ content: '';
+ display: block;
+ left: 3px;
+ position: absolute;
+ right: 3px;
+ top: 3px;
+}
+
+/* Hover **********************************************************************/
+
+:enabled:hover:-webkit-any(
+ select,
+ input[type='checkbox'],
+ input[type='radio'],
+ :-webkit-any(
+ button,
+ input[type='button'],
+ input[type='submit']):not(.custom-appearance):not(.link-button)) {
+ background-image: -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0);
+ border-color: rgba(0, 0, 0, 0.3);
+ box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12),
+ inset 0 1px 2px rgba(255, 255, 255, 0.95);
+ color: black;
+}
+
+:enabled:hover:-webkit-any(select) {
+ /* OVERRIDE */
+ background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAICAQAAACxSAwfAAAAUklEQVQY02P4z0AMRGZGMaShwCisyhITmb8huMzfEhOxKvuvsGAh208Ik+3ngoX/FbBbClcIUcSAw21QhXxfIIrwKAMpfNsEUYRXGVCEFc6CQwBqq4CCCtU4VgAAAABJRU5ErkJggg==') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAQCAQAAAA/1a6rAAAAQUlEQVR4Xu3MsQnAMBAEMI1+myf9gw0+3ASCenmu+mQn2yGn3S4Mp906DEW3CEPfzTD03QxD380w3OmIUHe9v+u9QwAt93yns5cAAAAASUVORK5CYII=') 2x),
+ -webkit-linear-gradient(#f0f0f0, #f0f0f0 38%, #e0e0e0);
+}
+
+/* Active *********************************************************************/
+
+:enabled:active:-webkit-any(
+ select,
+ input[type='checkbox'],
+ input[type='radio'],
+ :-webkit-any(
+ button,
+ input[type='button'],
+ input[type='submit']):not(.custom-appearance):not(.link-button)) {
+ background-image: -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7);
+ box-shadow: none;
+ text-shadow: none;
+}
+
+:enabled:active:-webkit-any(select) {
+ /* OVERRIDE */
+ background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAICAQAAACxSAwfAAAAUklEQVQY02P4z0AMRGZGMaShwCisyhITmb8huMzfEhOxKvuvsGAh208Ik+3ngoX/FbBbClcIUcSAw21QhXxfIIrwKAMpfNsEUYRXGVCEFc6CQwBqq4CCCtU4VgAAAABJRU5ErkJggg==') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACcAAAAQCAQAAAA/1a6rAAAAQUlEQVR4Xu3MsQnAMBAEMI1+myf9gw0+3ASCenmu+mQn2yGn3S4Mp906DEW3CEPfzTD03QxD380w3OmIUHe9v+u9QwAt93yns5cAAAAASUVORK5CYII=') 2x),
+ -webkit-linear-gradient(#e7e7e7, #e7e7e7 38%, #d7d7d7);
+}
+
+/* Disabled *******************************************************************/
+
+:disabled:-webkit-any(
+ button,
+ input[type='button'],
+ input[type='submit']):not(.custom-appearance):not(.link-button),
+select:disabled {
+ background-image: -webkit-linear-gradient(#f1f1f1, #f1f1f1 38%, #e6e6e6);
+ border-color: rgba(80, 80, 80, 0.2);
+ box-shadow: 0 1px 0 rgba(80, 80, 80, 0.08),
+ inset 0 1px 2px rgba(255, 255, 255, 0.75);
+ color: #aaa;
+}
+
+select:disabled {
+ /* OVERRIDE */
+ background-image: -webkit-image-set(url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAICAQAAACxSAwfAAAASklEQVQY02P4z0AMRGZGMaShwCisyhITG/4jw8RErMr+KyxYiFC0YOF/BeyWIikEKWLA4Ta4QogiPMpACt82QRThVQYUYYWz4BAAGr6Ii6kEPacAAAAASUVORK5CYII=') 1x, url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAQCAQAAADQF8WVAAAARElEQVR4Xu3MsQ0AIAwEsYx+m4fySsgLOuTe1Re9z4De4DzbdVDnmZ0ENcrsZJVkdoIKMzurMLOzSjNhlWfCapBlfpZbeMFeGdxKIEQAAAAASUVORK5CYII=') 2x),
+ -webkit-linear-gradient(#f1f1f1, #f1f1f1 38%, #e6e6e6);
+}
+
+input:disabled:-webkit-any([type='checkbox'],
+ [type='radio']) {
+ opacity: .75;
+}
+
+input:disabled:-webkit-any([type='password'],
+ [type='search'],
+ [type='text'],
+ [type='url'],
+ :not([type])) {
+ color: #999;
+}
+
+/* Focus **********************************************************************/
+
+:enabled:focus:-webkit-any(
+ select,
+ input[type='checkbox'],
+ input[type='number'],
+ input[type='password'],
+ input[type='radio'],
+ input[type='search'],
+ input[type='text'],
+ input[type='url'],
+ input:not([type]),
+ :-webkit-any(
+ button,
+ input[type='button'],
+ input[type='submit']):not(.custom-appearance):not(.link-button)) {
+ /* OVERRIDE */
+ -webkit-transition: border-color 200ms;
+ /* We use border color because it follows the border radius (unlike outline).
+ * This is particularly noticeable on mac. */
+ border-color: rgb(77, 144, 254);
+ outline: none;
+}
+
+/* Link buttons ***************************************************************/
+
+.link-button {
+ -webkit-box-shadow: none;
+ background: transparent none;
+ border: none;
+ color: rgb(17, 85, 204);
+ cursor: pointer;
+ /* Input elements have -webkit-small-control which can override the body font.
+ * Resolve this by using 'inherit'. */
+ font: inherit;
+ margin: 0;
+ padding: 0;
+}
+
+.link-button:hover {
+ text-decoration: underline;
+}
+
+.link-button:active {
+ color: rgb(5, 37, 119);
+ text-decoration: underline;
+}
+
+.link-button[disabled] {
+ color: #999;
+ cursor: default;
+ text-decoration: none;
+}
+
+/* Checkbox/radio helpers ******************************************************
+ *
+ * .checkbox and .radio classes wrap labels. Checkboxes and radios should use
+ * these classes with the markup structure:
+ *
+ * <div class="checkbox">
+ * <label>
+ * <input type="checkbox"></input>
+ * <span>
+ * </label>
+ * </div>
+ */
+
+:-webkit-any(.checkbox, .radio) label {
+ /* Don't expand horizontally: <http://crbug.com/112091>. */
+ display: -webkit-inline-box;
+ padding-bottom: 7px;
+ padding-top: 7px;
+}
+
+:-webkit-any(.checkbox, .radio) label input ~ span {
+ -webkit-margin-start: 0.6em;
+ -webkit-user-select: none;
+ /* Make sure long spans wrap at the same horizontal position they start. */
+ display: block;
+}
+
+:-webkit-any(.checkbox, .radio) label:hover {
+ color: black;
+}
+
+label > input:disabled:-webkit-any([type='checkbox'], [type='radio']) ~ span {
+ color: #999;
+}
\ No newline at end of file
diff --git a/src/icons/translate-128.png b/src/icons/translate-128.png
new file mode 100644
index 0000000..1a33921
--- /dev/null
+++ b/src/icons/translate-128.png
Binary files differ
diff --git a/src/icons/translate-16.png b/src/icons/translate-16.png
new file mode 100644
index 0000000..6629ac6
--- /dev/null
+++ b/src/icons/translate-16.png
Binary files differ
diff --git a/src/icons/translate-256.png b/src/icons/translate-256.png
new file mode 100644
index 0000000..0b2ead1
--- /dev/null
+++ b/src/icons/translate-256.png
Binary files differ
diff --git a/src/icons/translate-32.png b/src/icons/translate-32.png
new file mode 100644
index 0000000..ee6fcfe
--- /dev/null
+++ b/src/icons/translate-32.png
Binary files differ
diff --git a/src/icons/translate-512.png b/src/icons/translate-512.png
new file mode 100644
index 0000000..8fc23a3
--- /dev/null
+++ b/src/icons/translate-512.png
Binary files differ
diff --git a/src/icons/translate-64.png b/src/icons/translate-64.png
new file mode 100644
index 0000000..6de6bb7
--- /dev/null
+++ b/src/icons/translate-64.png
Binary files differ
diff --git a/src/js/options.js b/src/js/options.js
new file mode 100644
index 0000000..147b02e
--- /dev/null
+++ b/src/js/options.js
@@ -0,0 +1,219 @@
+var isoLangs={af:{name:"Afrikaans",nativeName:"Afrikaans"},sq:{name:"Albanian",nativeName:"Shqip"},am:{name:"Amharic",nativeName:"\u12a0\u121b\u122d\u129b"},ar:{name:"Arabic",nativeName:"\u0627\u0644\u0639\u0631\u0628\u064a\u0629"},hy:{name:"Armenian",nativeName:"\u0540\u0561\u0575\u0565\u0580\u0565\u0576"},az:{name:"Azerbaijani",nativeName:"az\u0259rbaycan dili"},eu:{name:"Basque",nativeName:"euskara"},be:{name:"Belarusian",nativeName:"\u0411\u0435\u043b\u0430\u0440\u0443\u0441\u043a\u0430\u044f"},
+bn:{name:"Bengali",nativeName:"\u09ac\u09be\u0982\u09b2\u09be"},bs:{name:"Bosnian",nativeName:"bosanski jezik"},bg:{name:"Bulgarian",nativeName:"\u0431\u044a\u043b\u0433\u0430\u0440\u0441\u043a\u0438 \u0435\u0437\u0438\u043a"},ca:{name:"Catalan",nativeName:"Catal\u00e0"},ceb:{name:"Cebuano",nativeName:"Bisaya"},ny:{name:"Chichewa",nativeName:"chiChe\u0175a"},zh:{name:"Chinese",nativeName:"\u4e2d\u6587 (Zh\u014dngw\u00e9n)"},co:{name:"Corsican",nativeName:"corsu"},hr:{name:"Croatian",nativeName:"hrvatski"},
+cs:{name:"Czech",nativeName:"\u010desky"},da:{name:"Danish",nativeName:"dansk"},nl:{name:"Dutch",nativeName:"Nederlands"},en:{name:"English",nativeName:"English"},eo:{name:"Esperanto",nativeName:"Esperanto"},et:{name:"Estonian",nativeName:"eesti"},tl:{name:"Filipino",nativeName:"Pilipino"},fi:{name:"Finnish",nativeName:"suomi"},fr:{name:"French",nativeName:"fran\u00e7ais"},fy:{name:"Frisian",nativeName:"Frysk"},gl:{name:"Galician",nativeName:"Galego"},ka:{name:"Georgian",nativeName:"\u10e5\u10d0\u10e0\u10d7\u10e3\u10da\u10d8"},
+de:{name:"German",nativeName:"Deutsch"},el:{name:"Greek",nativeName:"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac"},gu:{name:"Gujarati",nativeName:"\u0a97\u0ac1\u0a9c\u0ab0\u0abe\u0aa4\u0ac0"},ht:{name:"Haitian Creole",nativeName:"Krey\u00f2l ayisyen"},ha:{name:"Hausa",nativeName:"Hausa"},haw:{name:"Hawaiian",nativeName:"Hausa"},iw:{name:"Hebrew",nativeName:"\u05e2\u05d1\u05e8\u05d9\u05ea"},hi:{name:"Hindi",nativeName:"\u0939\u093f\u0928\u094d\u0926\u0940, \u0939\u093f\u0902\u0926\u0940"},hmn:{name:"Hmong",
+nativeName:"lus Hmoob"},hu:{name:"Hungarian",nativeName:"Magyar"},is:{name:"Icelandic",nativeName:"\u00cdslenska"},ig:{name:"Igbo",nativeName:"As\u1ee5s\u1ee5 Igbo"},id:{name:"Indonesian",nativeName:"Bahasa Indonesia"},ga:{name:"Irish",nativeName:"Gaeilge"},it:{name:"Italian",nativeName:"Italiano"},ja:{name:"Japanese",nativeName:"\u65e5\u672c\u8a9e (\u306b\u307b\u3093\u3054\uff0f\u306b\u3063\u307d\u3093\u3054)"},jv:{name:"Javanese",nativeName:"basa Jawa"},kn:{name:"Kannada",nativeName:"\u0c95\u0ca8\u0ccd\u0ca8\u0ca1"},
+kk:{name:"Kazakh",nativeName:"\u049a\u0430\u0437\u0430\u049b \u0442\u0456\u043b\u0456"},km:{name:"Khmer",nativeName:"\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a"},ko:{name:"Korean",nativeName:"\ud55c\uad6d\uc5b4 (\u97d3\u570b\u8a9e)"},ku:{name:"Kurdish (Kurmanji)",nativeName:"Kurd\u00ee"},ky:{name:"Kyrgyz",nativeName:"\u043a\u044b\u0440\u0433\u044b\u0437 \u0442\u0438\u043b\u0438"},lo:{name:"Lao",nativeName:"\u0e9e\u0eb2\u0eaa\u0eb2\u0ea5\u0eb2\u0ea7"},la:{name:"Latin",nativeName:"latine"},
+lv:{name:"Latvian",nativeName:"latvie\u0161u valoda"},lt:{name:"Lithuanian",nativeName:"lietuvi\u0173 kalba"},lb:{name:"Luxembourgish",nativeName:"L\u00ebtzebuergesch"},mk:{name:"Macedonian",nativeName:"\u043c\u0430\u043a\u0435\u0434\u043e\u043d\u0441\u043a\u0438 \u0458\u0430\u0437\u0438\u043a"},mg:{name:"Malagasy",nativeName:"Malagasy fiteny"},ms:{name:"Malay",nativeName:"bahasa Melayu"},ml:{name:"Malayalam",nativeName:"\u0d2e\u0d32\u0d2f\u0d3e\u0d33\u0d02"},mt:{name:"Maltese",nativeName:"Malti"},
+mi:{name:"M\u0101ori",nativeName:"te reo M\u0101ori"},mr:{name:"Marathi",nativeName:"\u092e\u0930\u093e\u0920\u0940"},mn:{name:"Mongolian",nativeName:"\u043c\u043e\u043d\u0433\u043e\u043b"},my:{name:"Myanmar",nativeName:"\u1017\u1019\u102c\u1005\u102c"},ne:{name:"Nepali",nativeName:"\u0928\u0947\u092a\u093e\u0932\u0940"},no:{name:"Norwegian",nativeName:"Norsk"},ps:{name:"Pashto",nativeName:"\u067e\u069a\u062a\u0648"},fa:{name:"Persian",nativeName:"\u0641\u0627\u0631\u0633\u06cc"},pl:{name:"Polish",
+nativeName:"polski"},pt:{name:"Portuguese",nativeName:"Portugu\u00eas"},pa:{name:"Punjabi",nativeName:"\u0a2a\u0a70\u0a1c\u0a3e\u0a2c"},ro:{name:"Romanian",nativeName:"rom\u00e2n\u0103"},ru:{name:"Russian",nativeName:"\u0440\u0443\u0441\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a"},sm:{name:"Samoan",nativeName:"gagana faa Samoa"},gd:{name:"Scots Gaelic",nativeName:"G\u00e0idhlig"},sr:{name:"Serbian",nativeName:"\u0441\u0440\u043f\u0441\u043a\u0438 \u0458\u0435\u0437\u0438\u043a"},st:{name:"Sesotho",
+nativeName:"Sesotho"},sn:{name:"Shona",nativeName:"chiShona"},sd:{name:"Sindhi",nativeName:"\u0938\u093f\u0928\u094d\u0927\u0940"},si:{name:"Sinhala",nativeName:"\u0dc3\u0dd2\u0d82\u0dc4\u0dbd"},sk:{name:"Slovak",nativeName:"sloven\u010dina"},sl:{name:"Slovenian",nativeName:"sloven\u0161\u010dina"},so:{name:"Somali",nativeName:"Soomaaliga"},es:{name:"Spanish",nativeName:"espa\u00f1ol"},su:{name:"Sundanese",nativeName:"Basa Sunda"},sw:{name:"Swahili",nativeName:"Kiswahili"},sv:{name:"Swedish",nativeName:"svenska"},
+tg:{name:"Tajik",nativeName:"\u0442\u043e\u04b7\u0438\u043a\u04e3"},ta:{name:"Tamil",nativeName:"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd"},te:{name:"Telugu",nativeName:"\u0c24\u0c46\u0c32\u0c41\u0c17\u0c41"},th:{name:"Thai",nativeName:"\u0e44\u0e17\u0e22"},tr:{name:"Turkish",nativeName:"T\u00fcrk\u00e7e"},uk:{name:"Ukrainian",nativeName:"\u0443\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430"},ur:{name:"Urdu",nativeName:"\u0627\u0631\u062f\u0648"},uz:{name:"Uzbek",nativeName:"zbek"},vi:{name:"Vietnamese",
+nativeName:"Ti\u1ebfng Vi\u1ec7t"},cy:{name:"Welsh",nativeName:"Cymraeg"},xh:{name:"Xhosa",nativeName:"isiXhosa"},yi:{name:"Yiddish",nativeName:"\u05d9\u05d9\u05b4\u05d3\u05d9\u05e9"},yo:{name:"Yoruba",nativeName:"Yor\u00f9b\u00e1"},za:{name:"Zhuang, Chuang",nativeName:"Sa\u026f cue\u014b\u0185"},zu:{name:"Zulu",nativeName:"isiZulu"}};
+
+function $(selector) {
+ return document.querySelector(selector);
+}
+
+function $all(selector) {
+ return document.querySelectorAll(selector);
+}
+
+function isEmpty(obj) {
+ return Object.keys(obj).length === 0;
+}
+
+function i18n() {
+ $("#welcome").innerHTML = chrome.i18n.getMessage("options_welcome");
+ $("#introduction").innerHTML = chrome.i18n.getMessage("options_introduction");
+ //$("#languageselectheader").innerHTML = chrome.i18n.getMessage("options_languageselectheader");
+ $("#otheroptionsheader").innerHTML = chrome.i18n.getMessage("options_otheroptionsheader");
+ $("#varioustabs_label").innerHTML = chrome.i18n.getMessage("options_tabsoption_1");
+ $("#uniquetab_label").innerHTML = chrome.i18n.getMessage("options_tabsoption_2");
+ $("#panel_label").innerHTML = chrome.i18n.getMessage("options_tabsoption_3");
+ $("#languages_add").innerHTML = chrome.i18n.getMessage("options_addlanguage_addbutton");
+ $("#save").innerHTML = chrome.i18n.getMessage("options_savebutton");
+ $("#credits").innerHTML = chrome.i18n.getMessage("options_credits");
+ $("#credits_dialog h3").innerHTML = chrome.i18n.getMessage("options_credits");
+ $("#languages_add_ok").innerHTML = chrome.i18n.getMessage("options_ok");
+ $("#languages_add_cancel").innerHTML = chrome.i18n.getMessage("options_cancel");
+ $("#credits_ok").innerHTML = chrome.i18n.getMessage("options_ok");
+ $("#languages_add_dialog h3").innerHTML = chrome.i18n.getMessage("options_addlanguage");
+ $("#language_label").innerHTML = chrome.i18n.getMessage("options_language_label");
+}
+
+function print_list_modal() {
+ $("#select_language").innerHTML = "";
+ var heysortable = sortable.toArray();
+ for (var language in isoLangs) {
+ if (!inArray(language, heysortable)) {
+ var el = document.createElement('option');
+ el.setAttribute('value', language);
+ el.innerText = isoLangs[language]["name"]+" ("+isoLangs[language]["nativeName"]+")";
+ $("#select_language").appendChild(el);
+ }
+ }
+}
+
+function init() {
+ i18n();
+ chrome.storage.sync.get(null, function(items) {
+ // If no settings are set
+ if (isEmpty(items)) {
+ items = {'translateinto': {}, 'uniquetab': ''};
+ chrome.storage.sync.set({'translateinto': {}, 'uniquetab': ''});
+ }
+
+ // Check the checkbox of the window opening
+ if (items.uniquetab === "yep")
+ $("#uniquetab").checked = true;
+ if (items.uniquetab === "")
+ $("#varioustabs").checked = true;
+ if (items.uniquetab === "panel")
+ $("#panel").checked = true;
+
+ // Add event listeners for certain buttons and links
+ $("#panelsflag").addEventListener('click', function() { event.preventDefault(); chrome.tabs.create({url: 'chrome://flags/#enable-panels'}); });
+ $("#save").addEventListener('click', function() {
+ save_options();
+ });
+
+ // Print selected language list
+ var languages = items.translateinto;
+
+ if (languages) {
+ for (var language_id in languages) {
+ var language = languages[language_id];
+ var el = document.createElement('li');
+ el.setAttribute('data-language', language);
+ el.setAttribute('data-id', language);
+ el.innerHTML = isoLangs[language]["name"]+" ("+isoLangs[language]["nativeName"]+")"+"<span data-language='"+language+"' class='delete'>x</span>";
+ $("#languages").appendChild(el);
+ $("#languages li[data-language="+language+"] .delete").addEventListener('click', function() {
+ $("#languages").removeChild($("li[data-language="+this.getAttribute("data-language")+"]"));
+ print_list_modal();
+ });
+ }
+ }
+
+ // Initiate Sortable
+ sortable = new Sortable($("#languages"), {
+ animation: 150
+ });
+
+ // Handling The Dialog
+ $("#languages_add").addEventListener('click', function() { $("dialog#languages_add_dialog").showModal(); $("#select_language").focus(); });
+ $("#languages_add_cancel").addEventListener('click', function() { $("dialog#languages_add_dialog").close(); });
+ $("#languages_add_ok").addEventListener('click', function() {
+ var el = document.createElement('li');
+ var language = $("#select_language").value;
+ if (inArray(language, sortable.toArray())) {
+ return;
+ }
+ el.setAttribute('data-language', language);
+ el.setAttribute('data-id', language);
+ el.innerHTML = isoLangs[language]["name"]+" ("+isoLangs[language]["nativeName"]+")"+"<span data-language='"+language+"' class='delete'>x</span>";
+ $("#languages").appendChild(el);
+ var selection = $("#select_language option[value="+language+"]");
+ selection.parentNode.removeChild(selection);
+ $("#languages li[data-id="+language+"] .delete").addEventListener('click', function() {
+ $("#languages").removeChild($("li[data-language="+this.getAttribute("data-language")+"]"));
+ print_list_modal();
+ });
+ $("dialog").close();
+ });
+
+ // About credits...
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4 && xhr.status == 200) {
+ var json = JSON.parse(xhr.responseText), printhtml = "";
+ for (var item in json) {
+ printhtml += "<div>";
+ if (json[item].url) {
+ printhtml += "<a href='"+json[item].url+"' class='homepage' target='_blank'>"+chrome.i18n.getMessage("options_credits_homepage")+"</a>";
+ }
+ printhtml += "<h4>"+json[item].name+"</h4>";
+ if (json[item].author) {
+ printhtml += "<p class='author'>"+chrome.i18n.getMessage("options_credits_by")+" "+json[item].author;
+ }
+ if (json[item].license) {
+ printhtml += " – "+json[item].license+"</p>";
+ } else {
+ printhtml += "</p>";
+ }
+ printhtml += "</div>";
+ }
+ $("dialog#credits_dialog .content_area").innerHTML = printhtml;
+ window.onhashchange = function() {
+ if (location.hash == "#credits") {
+ $("dialog#credits_dialog").showModal();
+ $("#credits_ok").focus();
+ }
+ }
+ if (location.hash == "#credits") {
+ $("dialog#credits_dialog").showModal();
+ $("#credits_ok").focus();
+ }
+ $("#credits_ok").addEventListener('click', function() { $("dialog#credits_dialog").close(); });
+ $("dialog#credits_dialog").addEventListener('close', function() { history.pushState("", document.title, window.location.pathname + window.location.search); });
+ }
+ }
+ xhr.open("GET", "json/credits.json", true);
+ xhr.send();
+
+ // Print language list in the modal dialog
+ print_list_modal();
+ });
+}
+
+function save_options() {
+ var languages = document.getElementById("languages");
+ var options = {"uniquetab": "", "translateinto": {}};
+
+ options.uniquetab = radio_selected("uniquetab");
+
+ var selected_languages = sortable.toArray();
+
+ var i = 0;
+ for (var language_id in selected_languages) {
+ var language = selected_languages[language_id];
+ options.translateinto[i] = language;
+ i++;
+ }
+
+ chrome.storage.sync.set(options, function() {
+ var background = chrome.extension.getBackgroundPage();
+
+ background.translator_tab = false;
+ background.translator_window = false;
+ window.close();
+ });
+
+ // We don't need the following code because the background.js is already listening to changes in chrome.sync ;-) Yeeey!
+ //chrome.extension.getBackgroundPage().createmenus(JSON.stringify(options));
+}
+
+function toObject(arr) {
+ var rv = {};
+ for (var i = 0; i < arr.length; ++i)
+ if (arr[i] !== undefined) rv[i] = arr[i];
+ return rv;
+}
+
+function radio_selected(a) {
+ var elements = document.getElementsByName(a);
+
+ for (var i=0; i<elements.length; i++)
+ if (elements[i].checked) return elements[i].value;
+}
+
+function inArray(needle, haystack) {
+ var length = haystack.length;
+ for(var i = 0; i < length; i++) {
+ if(haystack[i] == needle) return true;
+ }
+ return false;
+}
+
+window.addEventListener('load', init);
diff --git a/src/js/sortable.js b/src/js/sortable.js
new file mode 100644
index 0000000..524e118
--- /dev/null
+++ b/src/js/sortable.js
@@ -0,0 +1,783 @@
+/**!
+ * Sortable
+ * @author RubaXa <trash@rubaxa.org>
+ * @license MIT
+ */
+
+
+(function (factory){
+ "use strict";
+
+ if( typeof define === "function" && define.amd ){
+ define(factory);
+ }
+ else if( typeof module != "undefined" && typeof module.exports != "undefined" ){
+ module.exports = factory();
+ }
+ else {
+ window["Sortable"] = factory();
+ }
+})(function (){
+ "use strict";
+
+ var
+ dragEl
+ , ghostEl
+ , cloneEl
+ , rootEl
+ , nextEl
+
+ , lastEl
+ , lastCSS
+
+ , activeGroup
+
+ , tapEvt
+ , touchEvt
+
+ , expando = 'Sortable' + (new Date).getTime()
+
+ , win = window
+ , document = win.document
+ , parseInt = win.parseInt
+ , supportIEdnd = !!document.createElement('div').dragDrop
+
+ , _silent = false
+
+ , _dispatchEvent = function (rootEl, name, targetEl, fromEl) {
+ var evt = document.createEvent('Event');
+
+ evt.initEvent(name, true, true);
+ evt.item = targetEl || rootEl;
+ evt.from = fromEl || rootEl;
+
+ rootEl.dispatchEvent(evt);
+ }
+
+ , _customEvents = 'onAdd onUpdate onRemove onStart onEnd onFilter onSort'.split(' ')
+
+ , noop = function (){}
+ , slice = [].slice
+
+ , touchDragOverListeners = []
+ ;
+
+
+
+ /**
+ * @class Sortable
+ * @param {HTMLElement} el
+ * @param {Object} [options]
+ */
+ function Sortable(el, options){
+ this.el = el; // root element
+ this.options = options = (options || {});
+
+
+ // Default options
+ var defaults = {
+ group: Math.random(),
+ sort: true,
+ store: null,
+ handle: null,
+ draggable: el.children[0] && el.children[0].nodeName || (/[uo]l/i.test(el.nodeName) ? 'li' : '*'),
+ ghostClass: 'sortable-ghost',
+ ignore: 'a, img',
+ filter: null,
+ animation: 0
+ };
+
+
+ // Set default options
+ for (var name in defaults) {
+ !(name in options) && (options[name] = defaults[name]);
+ }
+
+
+ if (!options.group.name) {
+ options.group = { name: options.group };
+ }
+
+
+ ['pull', 'put'].forEach(function (key) {
+ if (!(key in options.group)) {
+ options.group[key] = true;
+ }
+ });
+
+
+ // Define events
+ _customEvents.forEach(function (name) {
+ options[name] = _bind(this, options[name] || noop);
+ _on(el, name.substr(2).toLowerCase(), options[name]);
+ }, this);
+
+
+ // Export group name
+ el[expando] = options.group.name;
+
+
+ // Bind all private methods
+ for( var fn in this ){
+ if( fn.charAt(0) === '_' ){
+ this[fn] = _bind(this, this[fn]);
+ }
+ }
+
+
+ // Bind events
+ _on(el, 'mousedown', this._onTapStart);
+ _on(el, 'touchstart', this._onTapStart);
+ supportIEdnd && _on(el, 'selectstart', this._onTapStart);
+
+ _on(el, 'dragover', this._onDragOver);
+ _on(el, 'dragenter', this._onDragOver);
+
+ touchDragOverListeners.push(this._onDragOver);
+
+ // Restore sorting
+ options.store && this.sort(options.store.get(this));
+ }
+
+
+ Sortable.prototype = /** @lends Sortable.prototype */ {
+ constructor: Sortable,
+
+
+ _applyEffects: function (){
+ _toggleClass(dragEl, this.options.ghostClass, true);
+ },
+
+
+ _onTapStart: function (evt/**Event|TouchEvent*/){
+ var
+ touch = evt.touches && evt.touches[0]
+ , target = (touch || evt).target
+ , options = this.options
+ , el = this.el
+ , filter = options.filter
+ ;
+
+ if( evt.type === 'mousedown' && evt.button !== 0 ) {
+ return; // only left button
+ }
+
+ // Check filter
+ if( typeof filter === 'function' ){
+ if( filter.call(this, target, this) ){
+ _dispatchEvent(el, 'filter', target);
+ return; // cancel dnd
+ }
+ }
+ else if( filter ){
+ filter = filter.split(',').filter(function (criteria) {
+ return _closest(target, criteria.trim(), el);
+ });
+
+ if (filter.length) {
+ _dispatchEvent(el, 'filter', target);
+ return; // cancel dnd
+ }
+ }
+
+ if( options.handle ){
+ target = _closest(target, options.handle, el);
+ }
+
+ target = _closest(target, options.draggable, el);
+
+ // IE 9 Support
+ if( target && evt.type == 'selectstart' ){
+ if( target.tagName != 'A' && target.tagName != 'IMG'){
+ target.dragDrop();
+ }
+ }
+
+ if( target && !dragEl && (target.parentNode === el) ){
+ tapEvt = evt;
+
+ rootEl = this.el;
+ dragEl = target;
+ nextEl = dragEl.nextSibling;
+ activeGroup = this.options.group;
+
+ dragEl.draggable = true;
+
+ // Disable "draggable"
+ options.ignore.split(',').forEach(function (criteria) {
+ _find(target, criteria.trim(), _disableDraggable);
+ });
+
+ if( touch ){
+ // Touch device support
+ tapEvt = {
+ target: target
+ , clientX: touch.clientX
+ , clientY: touch.clientY
+ };
+
+ this._onDragStart(tapEvt, true);
+ evt.preventDefault();
+ }
+
+ _on(document, 'mouseup', this._onDrop);
+ _on(document, 'touchend', this._onDrop);
+ _on(document, 'touchcancel', this._onDrop);
+
+ _on(this.el, 'dragstart', this._onDragStart);
+ _on(this.el, 'dragend', this._onDrop);
+ _on(document, 'dragover', _globalDragOver);
+
+
+ try {
+ if( document.selection ){
+ document.selection.empty();
+ } else {
+ window.getSelection().removeAllRanges()
+ }
+ } catch (err){ }
+
+
+ _dispatchEvent(dragEl, 'start');
+
+
+ cloneEl = dragEl.cloneNode(true);
+ _css(cloneEl, 'display', 'none');
+ rootEl.insertBefore(cloneEl, dragEl);
+ }
+ },
+
+ _emulateDragOver: function (){
+ if( touchEvt ){
+ _css(ghostEl, 'display', 'none');
+
+ var
+ target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY)
+ , parent = target
+ , groupName = this.options.group.name
+ , i = touchDragOverListeners.length
+ ;
+
+ if( parent ){
+ do {
+ if( parent[expando] === groupName ){
+ while( i-- ){
+ touchDragOverListeners[i]({
+ clientX: touchEvt.clientX,
+ clientY: touchEvt.clientY,
+ target: target,
+ rootEl: parent
+ });
+ }
+ break;
+ }
+
+ target = parent; // store last element
+ }
+ while( parent = parent.parentNode );
+ }
+
+ _css(ghostEl, 'display', '');
+ }
+ },
+
+
+ _onTouchMove: function (evt/**TouchEvent*/){
+ if( tapEvt ){
+ var
+ touch = evt.touches[0]
+ , dx = touch.clientX - tapEvt.clientX
+ , dy = touch.clientY - tapEvt.clientY
+ , translate3d = 'translate3d(' + dx + 'px,' + dy + 'px,0)'
+ ;
+
+ touchEvt = touch;
+
+ _css(ghostEl, 'webkitTransform', translate3d);
+ _css(ghostEl, 'mozTransform', translate3d);
+ _css(ghostEl, 'msTransform', translate3d);
+ _css(ghostEl, 'transform', translate3d);
+
+ evt.preventDefault();
+ }
+ },
+
+
+ _onDragStart: function (evt/**Event*/, isTouch/**Boolean*/){
+ var dataTransfer = evt.dataTransfer;
+
+ this._offUpEvents();
+
+ if( isTouch ){
+ var
+ rect = dragEl.getBoundingClientRect()
+ , css = _css(dragEl)
+ , ghostRect
+ ;
+
+ ghostEl = dragEl.cloneNode(true);
+
+ _css(ghostEl, 'top', rect.top - parseInt(css.marginTop, 10));
+ _css(ghostEl, 'left', rect.left - parseInt(css.marginLeft, 10));
+ _css(ghostEl, 'width', rect.width);
+ _css(ghostEl, 'height', rect.height);
+ _css(ghostEl, 'opacity', '0.8');
+ _css(ghostEl, 'position', 'fixed');
+ _css(ghostEl, 'zIndex', '100000');
+
+ rootEl.appendChild(ghostEl);
+
+ // Fixing dimensions.
+ ghostRect = ghostEl.getBoundingClientRect();
+ _css(ghostEl, 'width', rect.width*2 - ghostRect.width);
+ _css(ghostEl, 'height', rect.height*2 - ghostRect.height);
+
+ // Bind touch events
+ _on(document, 'touchmove', this._onTouchMove);
+ _on(document, 'touchend', this._onDrop);
+ _on(document, 'touchcancel', this._onDrop);
+
+ this._loopId = setInterval(this._emulateDragOver, 150);
+ }
+ else {
+ dataTransfer.effectAllowed = 'move';
+ dataTransfer.setData('Text', dragEl.textContent);
+
+ _on(document, 'drop', this._onDrop);
+ }
+
+ setTimeout(this._applyEffects);
+ },
+
+
+ _onDragOver: function (evt/**Event*/){
+ var el = this.el,
+ target,
+ dragRect,
+ revert,
+ options = this.options,
+ group = options.group,
+ groupPut = group.put,
+ isOwner = (activeGroup === group);
+
+ if( !_silent &&
+ (activeGroup.name === group.name || groupPut && groupPut.indexOf && groupPut.indexOf(activeGroup.name) > -1) &&
+ (isOwner && (options.sort || (revert = !rootEl.contains(dragEl))) || groupPut && activeGroup.pull) &&
+ (evt.rootEl === void 0 || evt.rootEl === this.el)
+ ){
+ target = _closest(evt.target, this.options.draggable, el);
+ dragRect = dragEl.getBoundingClientRect();
+
+ if ((activeGroup.pull == 'clone') && (cloneEl.state !== isOwner)) {
+ _css(cloneEl, 'display', isOwner ? 'none' : '');
+ !isOwner && cloneEl.state && rootEl.insertBefore(cloneEl, dragEl);
+ cloneEl.state = isOwner;
+ }
+
+ if (revert) {
+ rootEl.insertBefore(dragEl, cloneEl);
+ return;
+ }
+
+ if( (el.children.length === 0) || (el.children[0] === ghostEl) ||
+ (el === evt.target) && _ghostInBottom(el, evt)
+ ){
+ target && (targetRect = target.getBoundingClientRect());
+
+ el.appendChild(dragEl);
+ this._animate(dragRect, dragEl);
+ target && this._animate(targetRect, target);
+ }
+ else if( target && !target.animated && target !== dragEl && (target.parentNode[expando] !== void 0) ){
+ if( lastEl !== target ){
+ lastEl = target;
+ lastCSS = _css(target);
+ }
+
+
+ var targetRect = target.getBoundingClientRect()
+ , width = targetRect.right - targetRect.left
+ , height = targetRect.bottom - targetRect.top
+ , floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display)
+ , isWide = (target.offsetWidth > dragEl.offsetWidth)
+ , isLong = (target.offsetHeight > dragEl.offsetHeight)
+ , halfway = (floating ? (evt.clientX - targetRect.left)/width : (evt.clientY - targetRect.top)/height) > .5
+ , nextSibling = target.nextElementSibling
+ , after
+ ;
+
+ _silent = true;
+ setTimeout(_unsilent, 30);
+
+ if( floating ){
+ after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide
+ } else {
+ after = (nextSibling !== dragEl) && !isLong || halfway && isLong;
+ }
+
+ if( after && !nextSibling ){
+ el.appendChild(dragEl);
+ } else {
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
+ }
+
+ this._animate(dragRect, dragEl);
+ this._animate(targetRect, target);
+ }
+ }
+ },
+
+ _animate: function (prevRect, target) {
+ var ms = this.options.animation;
+
+ if (ms) {
+ var currentRect = target.getBoundingClientRect();
+
+ _css(target, 'transition', 'none');
+ _css(target, 'transform', 'translate3d('
+ + (prevRect.left - currentRect.left) + 'px,'
+ + (prevRect.top - currentRect.top) + 'px,0)'
+ );
+
+ target.offsetWidth; // repaint
+
+ _css(target, 'transition', 'all ' + ms + 'ms');
+ _css(target, 'transform', 'translate3d(0,0,0)');
+
+ clearTimeout(target.animated);
+ target.animated = setTimeout(function () {
+ _css(target, 'transition', '');
+ target.animated = false;
+ }, ms);
+ }
+ },
+
+ _offUpEvents: function () {
+ _off(document, 'mouseup', this._onDrop);
+ _off(document, 'touchmove', this._onTouchMove);
+ _off(document, 'touchend', this._onDrop);
+ _off(document, 'touchcancel', this._onDrop);
+ },
+
+ _onDrop: function (evt/**Event*/){
+ clearInterval(this._loopId);
+
+ // Unbind events
+ _off(document, 'drop', this._onDrop);
+ _off(document, 'dragover', _globalDragOver);
+
+ _off(this.el, 'dragend', this._onDrop);
+ _off(this.el, 'dragstart', this._onDragStart);
+ _off(this.el, 'selectstart', this._onTapStart);
+
+ this._offUpEvents();
+
+ if( evt ){
+ evt.preventDefault();
+ evt.stopPropagation();
+
+ cloneEl.parentNode.removeChild(cloneEl);
+ ghostEl && ghostEl.parentNode.removeChild(ghostEl);
+
+ if( dragEl ){
+ _disableDraggable(dragEl);
+ _toggleClass(dragEl, this.options.ghostClass, false);
+
+ if( !rootEl.contains(dragEl) ){
+ _dispatchEvent(dragEl, 'sort');
+ _dispatchEvent(rootEl, 'sort');
+
+ // Add event
+ _dispatchEvent(dragEl, 'add', dragEl, rootEl);
+
+ // Remove event
+ _dispatchEvent(rootEl, 'remove', dragEl);
+ }
+ else if( dragEl.nextSibling !== nextEl ){
+ // Update event
+ _dispatchEvent(dragEl, 'update');
+ _dispatchEvent(dragEl, 'sort');
+ }
+
+ _dispatchEvent(rootEl, 'end');
+ }
+
+ // Set NULL
+ rootEl =
+ dragEl =
+ ghostEl =
+ nextEl =
+ cloneEl =
+
+ tapEvt =
+ touchEvt =
+
+ lastEl =
+ lastCSS =
+
+ activeGroup = null;
+
+ // Save sorting
+ this.options.store && this.options.store.set(this);
+ }
+ },
+
+
+ /**
+ * Serializes the item into an array of string.
+ * @returns {String[]}
+ */
+ toArray: function () {
+ var order = [],
+ el,
+ children = this.el.children,
+ i = 0,
+ n = children.length
+ ;
+
+ for (; i < n; i++) {
+ el = children[i];
+ if (_closest(el, this.options.draggable, this.el)) {
+ order.push(el.getAttribute('data-id') || _generateId(el));
+ }
+ }
+
+ return order;
+ },
+
+
+ /**
+ * Sorts the elements according to the array.
+ * @param {String[]} order order of the items
+ */
+ sort: function (order) {
+ var items = {}, rootEl = this.el;
+
+ this.toArray().forEach(function (id, i) {
+ var el = rootEl.children[i];
+
+ if (_closest(el, this.options.draggable, rootEl)) {
+ items[id] = el;
+ }
+ }, this);
+
+
+ order.forEach(function (id) {
+ if (items[id]) {
+ rootEl.removeChild(items[id]);
+ rootEl.appendChild(items[id]);
+ }
+ });
+ },
+
+
+ /**
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
+ * @param {HTMLElement} el
+ * @param {String} [selector] default: `options.draggable`
+ * @returns {HTMLElement|null}
+ */
+ closest: function (el, selector) {
+ return _closest(el, selector || this.options.draggable, this.el);
+ },
+
+
+ /**
+ * Destroy
+ */
+ destroy: function () {
+ var el = this.el, options = this.options;
+
+ _customEvents.forEach(function (name) {
+ _off(el, name.substr(2).toLowerCase(), options[name]);
+ });
+
+ _off(el, 'mousedown', this._onTapStart);
+ _off(el, 'touchstart', this._onTapStart);
+ _off(el, 'selectstart', this._onTapStart);
+
+ _off(el, 'dragover', this._onDragOver);
+ _off(el, 'dragenter', this._onDragOver);
+
+ //remove draggable attributes
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function(el) {
+ el.removeAttribute('draggable');
+ });
+
+ touchDragOverListeners.splice(touchDragOverListeners.indexOf(this._onDragOver), 1);
+
+ this._onDrop();
+
+ this.el = null;
+ }
+ };
+
+
+ function _bind(ctx, fn){
+ var args = slice.call(arguments, 2);
+ return fn.bind ? fn.bind.apply(fn, [ctx].concat(args)) : function (){
+ return fn.apply(ctx, args.concat(slice.call(arguments)));
+ };
+ }
+
+
+ function _closest(el, selector, ctx){
+ if( selector === '*' ){
+ return el;
+ }
+ else if( el ){
+ ctx = ctx || document;
+ selector = selector.split('.');
+
+ var
+ tag = selector.shift().toUpperCase()
+ , re = new RegExp('\\s('+selector.join('|')+')\\s', 'g')
+ ;
+
+ do {
+ if(
+ (tag === '' || el.nodeName == tag)
+ && (!selector.length || ((' '+el.className+' ').match(re) || []).length == selector.length)
+ ){
+ return el;
+ }
+ }
+ while( el !== ctx && (el = el.parentNode) );
+ }
+
+ return null;
+ }
+
+
+ function _globalDragOver(evt){
+ evt.dataTransfer.dropEffect = 'move';
+ evt.preventDefault();
+ }
+
+
+ function _on(el, event, fn){
+ el.addEventListener(event, fn, false);
+ }
+
+
+ function _off(el, event, fn){
+ el.removeEventListener(event, fn, false);
+ }
+
+
+ function _toggleClass(el, name, state){
+ if( el ){
+ if( el.classList ){
+ el.classList[state ? 'add' : 'remove'](name);
+ }
+ else {
+ var className = (' '+el.className+' ').replace(/\s+/g, ' ').replace(' '+name+' ', '');
+ el.className = className + (state ? ' '+name : '')
+ }
+ }
+ }
+
+
+ function _css(el, prop, val){
+ var style = el && el.style;
+
+ if( style ){
+ if( val === void 0 ){
+ if( document.defaultView && document.defaultView.getComputedStyle ){
+ val = document.defaultView.getComputedStyle(el, '');
+ }
+ else if( el.currentStyle ){
+ val = el.currentStyle;
+ }
+
+ return prop === void 0 ? val : val[prop];
+ }
+ else {
+ if (!(prop in style)) {
+ prop = '-webkit-' + prop;
+ }
+
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
+ }
+ }
+ }
+
+
+ function _find(ctx, tagName, iterator){
+ if( ctx ){
+ var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
+ if( iterator ){
+ for( ; i < n; i++ ){
+ iterator(list[i], i);
+ }
+ }
+ return list;
+ }
+ return [];
+ }
+
+
+ function _disableDraggable(el){
+ return el.draggable = false;
+ }
+
+
+ function _unsilent(){
+ _silent = false;
+ }
+
+
+ function _ghostInBottom(el, evt){
+ var last = el.lastElementChild.getBoundingClientRect();
+ return evt.clientY - (last.top + last.height) > 5; // min delta
+ }
+
+
+ /**
+ * Generate id
+ * @param {HTMLElement} el
+ * @returns {String}
+ * @private
+ */
+ function _generateId(el) {
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
+ i = str.length,
+ sum = 0
+ ;
+
+ while (i--) {
+ sum += str.charCodeAt(i);
+ }
+
+ return sum.toString(36);
+ }
+
+
+ // Export utils
+ Sortable.utils = {
+ on: _on,
+ off: _off,
+ css: _css,
+ find: _find,
+ bind: _bind,
+ closest: _closest,
+ toggleClass: _toggleClass,
+ dispatchEvent: _dispatchEvent
+ };
+
+
+ Sortable.version = '0.6.0';
+
+
+ /**
+ * Create sortable instance
+ * @param {HTMLElement} el
+ * @param {Object} [options]
+ */
+ Sortable.create = function (el, options) {
+ return new Sortable(el, options)
+ };
+
+ // Export
+ return Sortable;
+});
diff --git a/src/json/credits.json b/src/json/credits.json
new file mode 100644
index 0000000..c0c34e4
--- /dev/null
+++ b/src/json/credits.json
@@ -0,0 +1,30 @@
+{
+ "icon": {
+ "name": "Metro Uinvert Dock Icon Set",
+ "url": "http://dakirby309.deviantart.com/art/Metro-Uinvert-Dock-Icon-Set-725-Icons-294529071",
+ "author": "dAKirby309"
+ },
+ "translation": {
+ "name": "Russian Translation",
+ "url": "https://code.google.com/r/sashasimkin-translateselectedtext/source/detail?r=fc4e58ee0d69929d610a84a7600338e99b9d3d83",
+ "author": "Alexander Simkin"
+ },
+ "sortable": {
+ "name": "Sortable",
+ "url": "https://github.com/RubaXa/Sortable",
+ "author": "Lebedev Konstantin",
+ "license": "MIT License"
+ },
+ "widgets": {
+ "name": "Chromium",
+ "url": "https://code.google.com/p/chromium/",
+ "author": "The Chromium Authors",
+ "license": "BSD-like License"
+ },
+ "languages": {
+ "name": "What-2-Nite",
+ "url": "https://github.com/enricolucia/what-2-nite/blob/master/isoLangs.json",
+ "author": "Google, Inc.",
+ "license": "MIT License"
+ }
+}
diff --git a/src/manifest.json b/src/manifest.json
new file mode 100644
index 0000000..f8a9b58
--- /dev/null
+++ b/src/manifest.json
@@ -0,0 +1,28 @@
+{
+ "manifest_version": 2,
+ "name": "__MSG_appBetaName__",
+ "description": "__MSG_appDescription__",
+ "version": "0.7.2.3",
+ "permissions": [
+ "contextMenus",
+ "storage",
+ "notifications"
+ ],
+ "icons": {
+ "16": "icons/translate-16.png",
+ "32": "icons/translate-32.png",
+ "64": "icons/translate-64.png",
+ "128": "icons/translate-128.png",
+ "256": "icons/translate-256.png"
+ },
+ "background": {
+ "scripts": ["background.js"],
+ "persistent": false
+ },
+ "options_page": "options.html",
+ "options_ui": {
+ "page": "options.html",
+ "chrome_style": true
+ },
+ "default_locale": "en"
+}
diff --git a/src/options.html b/src/options.html
new file mode 100644
index 0000000..8cb7196
--- /dev/null
+++ b/src/options.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <title>Options</title>
+ <link rel="stylesheet" type="text/css" href="css/options.css">
+ <script src="js/options.js"></script>
+ <script src="js/sortable.js"></script>
+ <link href='http://fonts.googleapis.com/css?family=Roboto:400,700,700italic,400italic' rel='stylesheet' type='text/css'>
+
+ </head>
+ <body>
+ <div id="credits_container">
+ <a href="#credits" id="credits"></a>
+ </div>
+
+ <h1 id="welcome"></h1>
+
+ <p id="introduction"></p>
+
+ <div id="languages_container">
+ <ul id="languages"></ul>
+ </div>
+ <div id="languages_footer">
+ <button id="languages_add"></button>
+ </div>
+
+ <h2 id="otheroptionsheader"></h2>
+
+ <div id="otheroptions">
+ <p><input type="radio" name="uniquetab" id="varioustabs" value=""> <label id="varioustabs_label" for="varioustabs"></label></p>
+ <p><input type="radio" name="uniquetab" id="uniquetab" value="yep"> <label id="uniquetab_label" for="uniquetab"></label></p>
+ <p><input type="radio" name="uniquetab" id="panel" value="panel"> <label id="panel_label" for="panel"></label></p>
+ </div>
+
+ <button id="save"></button>
+
+ <dialog id="languages_add_dialog">
+ <h3></h3>
+ <div class="content_area">
+ <label id="language_label" for="select_language"></label>
+ <select id="select_language"></select>
+ </div>
+ <div class="action_buttons">
+ <button id="languages_add_cancel"></button>
+ <button id="languages_add_ok"></button>
+ </div>
+ </dialog>
+ <dialog id="credits_dialog">
+ <h3></h3>
+ <div class="content_area">
+ </div>
+ <div class="action_buttons">
+ <button id="credits_ok"></button>
+ </div>
+ </dialog>
+ </body>
+</html>