tr8n 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.project +18 -0
- data/Gemfile +34 -0
- data/Gemfile.lock +79 -0
- data/LICENSE +18 -0
- data/README.rdoc +116 -0
- data/Rakefile +29 -0
- data/VERSION +1 -0
- data/app/controllers/application_controller.rb +28 -0
- data/app/controllers/tr8n/admin/base_controller.rb +65 -0
- data/app/controllers/tr8n/admin/clientsdk_controller.rb +34 -0
- data/app/controllers/tr8n/admin/domain_controller.rb +77 -0
- data/app/controllers/tr8n/admin/forum_controller.rb +58 -0
- data/app/controllers/tr8n/admin/glossary_controller.rb +56 -0
- data/app/controllers/tr8n/admin/language_controller.rb +129 -0
- data/app/controllers/tr8n/admin/translation_controller.rb +64 -0
- data/app/controllers/tr8n/admin/translation_key_controller.rb +157 -0
- data/app/controllers/tr8n/admin/translator_controller.rb +119 -0
- data/app/controllers/tr8n/api/v1/base_controller.rb +81 -0
- data/app/controllers/tr8n/api/v1/language_controller.rb +107 -0
- data/app/controllers/tr8n/api/v1/translation_controller.rb +75 -0
- data/app/controllers/tr8n/api/v1/translator_controller.rb +34 -0
- data/app/controllers/tr8n/awards_controller.rb +43 -0
- data/app/controllers/tr8n/base_controller.rb +206 -0
- data/app/controllers/tr8n/dashboard_controller.rb +32 -0
- data/app/controllers/tr8n/forum_controller.rb +100 -0
- data/app/controllers/tr8n/glossary_controller.rb +40 -0
- data/app/controllers/tr8n/help_controller.rb +40 -0
- data/app/controllers/tr8n/home_controller.rb +51 -0
- data/app/controllers/tr8n/language_cases_controller.rb +82 -0
- data/app/controllers/tr8n/language_controller.rb +372 -0
- data/app/controllers/tr8n/login_controller.rb +86 -0
- data/app/controllers/tr8n/phrases_controller.rb +293 -0
- data/app/controllers/tr8n/translations_controller.rb +194 -0
- data/app/controllers/tr8n/translator_controller.rb +83 -0
- data/app/helpers/application_helper.rb +27 -0
- data/app/helpers/tr8n/admin/base_helper.rb +84 -0
- data/app/helpers/tr8n/base_helper.rb +44 -0
- data/app/helpers/tr8n/dashboard_helper.rb +43 -0
- data/app/models/tr8n/base_filter.rb +68 -0
- data/app/models/tr8n/daily_language_metric.rb +42 -0
- data/app/models/tr8n/date_rule.rb +123 -0
- data/app/models/tr8n/gender_list_rule.rb +247 -0
- data/app/models/tr8n/gender_rule.rb +140 -0
- data/app/models/tr8n/glossary.rb +27 -0
- data/app/models/tr8n/glossary_filter.rb +33 -0
- data/app/models/tr8n/integration/ru/russian_gender_list_rule.rb +60 -0
- data/app/models/tr8n/integration/ru/russian_numeric_rule.rb +64 -0
- data/app/models/tr8n/ip_location.rb +74 -0
- data/app/models/tr8n/ip_location_filter.rb +34 -0
- data/app/models/tr8n/language.rb +318 -0
- data/app/models/tr8n/language_case.rb +141 -0
- data/app/models/tr8n/language_case_filter.rb +30 -0
- data/app/models/tr8n/language_case_rule.rb +187 -0
- data/app/models/tr8n/language_case_rule_filter.rb +30 -0
- data/app/models/tr8n/language_case_value_map.rb +100 -0
- data/app/models/tr8n/language_case_value_map_filter.rb +41 -0
- data/app/models/tr8n/language_filter.rb +75 -0
- data/app/models/tr8n/language_forum_abuse_report.rb +33 -0
- data/app/models/tr8n/language_forum_abuse_report_filter.rb +30 -0
- data/app/models/tr8n/language_forum_message.rb +46 -0
- data/app/models/tr8n/language_forum_message_filter.rb +34 -0
- data/app/models/tr8n/language_forum_topic.rb +41 -0
- data/app/models/tr8n/language_forum_topic_filter.rb +34 -0
- data/app/models/tr8n/language_metric.rb +91 -0
- data/app/models/tr8n/language_metric_filter.rb +63 -0
- data/app/models/tr8n/language_rule.rb +117 -0
- data/app/models/tr8n/language_rule_filter.rb +45 -0
- data/app/models/tr8n/language_user.rb +61 -0
- data/app/models/tr8n/language_user_filter.rb +34 -0
- data/app/models/tr8n/list_rule.rb +118 -0
- data/app/models/tr8n/monthly_language_metric.rb +34 -0
- data/app/models/tr8n/numeric_rule.rb +175 -0
- data/app/models/tr8n/total_language_metric.rb +59 -0
- data/app/models/tr8n/translation.rb +299 -0
- data/app/models/tr8n/translation_domain.rb +48 -0
- data/app/models/tr8n/translation_domain_filter.rb +26 -0
- data/app/models/tr8n/translation_filter.rb +34 -0
- data/app/models/tr8n/translation_key.rb +625 -0
- data/app/models/tr8n/translation_key_comment.rb +37 -0
- data/app/models/tr8n/translation_key_comment_filter.rb +30 -0
- data/app/models/tr8n/translation_key_filter.rb +45 -0
- data/app/models/tr8n/translation_key_lock.rb +59 -0
- data/app/models/tr8n/translation_key_lock_filter.rb +30 -0
- data/app/models/tr8n/translation_key_source.rb +58 -0
- data/app/models/tr8n/translation_key_source_filter.rb +30 -0
- data/app/models/tr8n/translation_source.rb +52 -0
- data/app/models/tr8n/translation_source_filter.rb +30 -0
- data/app/models/tr8n/translation_vote.rb +36 -0
- data/app/models/tr8n/translation_vote_filter.rb +34 -0
- data/app/models/tr8n/translator.rb +301 -0
- data/app/models/tr8n/translator_filter.rb +46 -0
- data/app/models/tr8n/translator_following.rb +38 -0
- data/app/models/tr8n/translator_following_filter.rb +34 -0
- data/app/models/tr8n/translator_log.rb +120 -0
- data/app/models/tr8n/translator_log_filter.rb +49 -0
- data/app/models/tr8n/translator_metric.rb +83 -0
- data/app/models/tr8n/translator_metric_filter.rb +38 -0
- data/app/models/tr8n/translator_report.rb +82 -0
- data/app/models/tr8n/translator_report_filter.rb +30 -0
- data/app/models/tr8n/value_rule.rb +117 -0
- data/app/views/layouts/_footer.html.erb +15 -0
- data/app/views/layouts/_header.html.erb +12 -0
- data/app/views/layouts/_html_head.html.erb +5 -0
- data/app/views/layouts/tr8n.html.erb +21 -0
- data/app/views/layouts/tr8n_admin.html.erb +33 -0
- data/app/views/tr8n/admin/clientsdk/index.html.erb +133 -0
- data/app/views/tr8n/admin/clientsdk/lb_samples.html.erb +54 -0
- data/app/views/tr8n/admin/common/_footer.html.erb +1 -0
- data/app/views/tr8n/admin/common/_header.html.erb +30 -0
- data/app/views/tr8n/admin/common/_lightbox_buttons.html.erb +5 -0
- data/app/views/tr8n/admin/common/_paginator.html.erb +20 -0
- data/app/views/tr8n/admin/domain/_tabs.html.erb +23 -0
- data/app/views/tr8n/admin/domain/index.html.erb +33 -0
- data/app/views/tr8n/admin/domain/key_sources.rhtml +53 -0
- data/app/views/tr8n/admin/domain/lb_caller.html.erb +35 -0
- data/app/views/tr8n/admin/domain/sources.html.erb +35 -0
- data/app/views/tr8n/admin/forum/_tabs.html.erb +22 -0
- data/app/views/tr8n/admin/forum/index.html.erb +34 -0
- data/app/views/tr8n/admin/forum/messages.html.erb +33 -0
- data/app/views/tr8n/admin/forum/reports.html.erb +50 -0
- data/app/views/tr8n/admin/glossary/index.html.erb +22 -0
- data/app/views/tr8n/admin/glossary/lb_update.html.erb +26 -0
- data/app/views/tr8n/admin/language/_rules.html.erb +22 -0
- data/app/views/tr8n/admin/language/_tabs.html.erb +27 -0
- data/app/views/tr8n/admin/language/_users.html.erb +40 -0
- data/app/views/tr8n/admin/language/case_rules.html.erb +24 -0
- data/app/views/tr8n/admin/language/case_values.html.erb +25 -0
- data/app/views/tr8n/admin/language/cases.html.erb +24 -0
- data/app/views/tr8n/admin/language/charts.html.erb +35 -0
- data/app/views/tr8n/admin/language/index.html.erb +99 -0
- data/app/views/tr8n/admin/language/lb_update.html.erb +76 -0
- data/app/views/tr8n/admin/language/lb_value_map.html.erb +42 -0
- data/app/views/tr8n/admin/language/metrics.rhtml +16 -0
- data/app/views/tr8n/admin/language/rules.html.erb +24 -0
- data/app/views/tr8n/admin/language/users.rhtml +31 -0
- data/app/views/tr8n/admin/language/view.html.erb +106 -0
- data/app/views/tr8n/admin/translation/_tabs.html.erb +21 -0
- data/app/views/tr8n/admin/translation/index.html.erb +75 -0
- data/app/views/tr8n/admin/translation/view.html.erb +142 -0
- data/app/views/tr8n/admin/translation/votes.rhtml +81 -0
- data/app/views/tr8n/admin/translation_key/_tabs.html.erb +22 -0
- data/app/views/tr8n/admin/translation_key/comments.html.erb +49 -0
- data/app/views/tr8n/admin/translation_key/index.html.erb +79 -0
- data/app/views/tr8n/admin/translation_key/lb_merge.html.erb +43 -0
- data/app/views/tr8n/admin/translation_key/lb_update.html.erb +44 -0
- data/app/views/tr8n/admin/translation_key/locks.html.erb +51 -0
- data/app/views/tr8n/admin/translation_key/view.html.erb +192 -0
- data/app/views/tr8n/admin/translator/_list.html.erb +51 -0
- data/app/views/tr8n/admin/translator/_tabs.html.erb +26 -0
- data/app/views/tr8n/admin/translator/following.html.erb +20 -0
- data/app/views/tr8n/admin/translator/index.html.erb +77 -0
- data/app/views/tr8n/admin/translator/ip_locations.html.erb +9 -0
- data/app/views/tr8n/admin/translator/lb_register.html.erb +18 -0
- data/app/views/tr8n/admin/translator/log.html.erb +27 -0
- data/app/views/tr8n/admin/translator/metrics.html.erb +25 -0
- data/app/views/tr8n/admin/translator/reports.html.erb +22 -0
- data/app/views/tr8n/admin/translator/view.html.erb +228 -0
- data/app/views/tr8n/awards/_list.html.erb +46 -0
- data/app/views/tr8n/awards/index.html.erb +42 -0
- data/app/views/tr8n/common/_flashes.html.erb +39 -0
- data/app/views/tr8n/common/_footer.html.erb +1 -0
- data/app/views/tr8n/common/_header.html.erb +5 -0
- data/app/views/tr8n/common/_language_selector.html.erb +8 -0
- data/app/views/tr8n/common/_language_strip.html.erb +29 -0
- data/app/views/tr8n/common/_language_table.html.erb +13 -0
- data/app/views/tr8n/common/_paginator.html.erb +8 -0
- data/app/views/tr8n/common/_permutations.html.erb +37 -0
- data/app/views/tr8n/common/_scripts.html.erb +49 -0
- data/app/views/tr8n/common/_splash_screen.html.erb +9 -0
- data/app/views/tr8n/common/_splash_screen_legacy.html.erb +4 -0
- data/app/views/tr8n/common/_tabs.html.erb +39 -0
- data/app/views/tr8n/common/_translation_votes.html.erb +41 -0
- data/app/views/tr8n/common/_translator_login.html.erb +11 -0
- data/app/views/tr8n/dashboard/_forum.html.erb +25 -0
- data/app/views/tr8n/dashboard/_language_metric.html.erb +49 -0
- data/app/views/tr8n/dashboard/_statistics.html.erb +35 -0
- data/app/views/tr8n/dashboard/_translations.html.erb +24 -0
- data/app/views/tr8n/dashboard/_translator_metric.html.erb +68 -0
- data/app/views/tr8n/dashboard/_votes.html.erb +76 -0
- data/app/views/tr8n/dashboard/index.rhtml +115 -0
- data/app/views/tr8n/forum/_message.html.erb +17 -0
- data/app/views/tr8n/forum/_messages.html.erb +21 -0
- data/app/views/tr8n/forum/_new_message.html.erb +28 -0
- data/app/views/tr8n/forum/_new_topic.html.erb +49 -0
- data/app/views/tr8n/forum/index.html.erb +84 -0
- data/app/views/tr8n/forum/topic.html.erb +36 -0
- data/app/views/tr8n/glossary/index.html.erb +42 -0
- data/app/views/tr8n/help/_navigation.html.erb +127 -0
- data/app/views/tr8n/help/awards.html.erb +13 -0
- data/app/views/tr8n/help/basic_information.html.erb +13 -0
- data/app/views/tr8n/help/context_rules.html.erb +13 -0
- data/app/views/tr8n/help/creating_translations.html.erb +16 -0
- data/app/views/tr8n/help/dashboard.html.erb +13 -0
- data/app/views/tr8n/help/direction.html.erb +13 -0
- data/app/views/tr8n/help/discussions.html.erb +13 -0
- data/app/views/tr8n/help/enter_translation.html.erb +13 -0
- data/app/views/tr8n/help/fallback_language.html.erb +13 -0
- data/app/views/tr8n/help/generate_context_rules.html.erb +17 -0
- data/app/views/tr8n/help/index.html.erb +18 -0
- data/app/views/tr8n/help/inline_translations.html.erb +28 -0
- data/app/views/tr8n/help/language_dashboard.html.erb +21 -0
- data/app/views/tr8n/help/language_phrases.html.erb +17 -0
- data/app/views/tr8n/help/language_selector.html.erb +13 -0
- data/app/views/tr8n/help/language_statistics.html.erb +13 -0
- data/app/views/tr8n/help/lb_credits.html.erb +9 -0
- data/app/views/tr8n/help/lb_shortcuts.html.erb +26 -0
- data/app/views/tr8n/help/manage.html.erb +13 -0
- data/app/views/tr8n/help/manage_language.html.erb +13 -0
- data/app/views/tr8n/help/native_name.html.erb +13 -0
- data/app/views/tr8n/help/original_phrase.html.erb +13 -0
- data/app/views/tr8n/help/other_languages.html.erb +15 -0
- data/app/views/tr8n/help/other_translatable_resources.html.erb +13 -0
- data/app/views/tr8n/help/phrases.html.erb +19 -0
- data/app/views/tr8n/help/phrases_with_translations.html.erb +21 -0
- data/app/views/tr8n/help/phrases_without_translations.html.erb +15 -0
- data/app/views/tr8n/help/prohibited_words.html.erb +13 -0
- data/app/views/tr8n/help/rank.html.erb +13 -0
- data/app/views/tr8n/help/recent_discussions.html.erb +13 -0
- data/app/views/tr8n/help/recent_translation_votes.html.erb +13 -0
- data/app/views/tr8n/help/recent_translations.html.erb +13 -0
- data/app/views/tr8n/help/site_map.html.erb +17 -0
- data/app/views/tr8n/help/site_sections.html.erb +13 -0
- data/app/views/tr8n/help/suggested_translation.html.erb +13 -0
- data/app/views/tr8n/help/translating_inline.html.erb +30 -0
- data/app/views/tr8n/help/translation_context_rules.html.erb +16 -0
- data/app/views/tr8n/help/translation_rank.html.erb +17 -0
- data/app/views/tr8n/help/translation_tokens.html.erb +13 -0
- data/app/views/tr8n/help/translation_tools.html.erb +13 -0
- data/app/views/tr8n/help/translations.html.erb +13 -0
- data/app/views/tr8n/help/user_rank.html.erb +13 -0
- data/app/views/tr8n/help/using_translation_tools.html.erb +13 -0
- data/app/views/tr8n/help/voting_on_translations.html.erb +13 -0
- data/app/views/tr8n/help/your_dashboard.html.erb +17 -0
- data/app/views/tr8n/help/your_languages.html.erb +19 -0
- data/app/views/tr8n/help/your_translations.html.erb +17 -0
- data/app/views/tr8n/home/credits.html.erb +102 -0
- data/app/views/tr8n/home/docs.html.erb +3 -0
- data/app/views/tr8n/home/index.html.erb +37 -0
- data/app/views/tr8n/home/integration.html.erb +564 -0
- data/app/views/tr8n/home/languages.html.erb +7 -0
- data/app/views/tr8n/home/license.html.erb +586 -0
- data/app/views/tr8n/home/rules.html.erb +668 -0
- data/app/views/tr8n/home/tokens.html.erb +324 -0
- data/app/views/tr8n/language/_basic_info.html.erb +53 -0
- data/app/views/tr8n/language/_edit_language_case_rules.html.erb +51 -0
- data/app/views/tr8n/language/_edit_language_cases.html.erb +68 -0
- data/app/views/tr8n/language/_edit_rules.html.erb +46 -0
- data/app/views/tr8n/language/_grammar.html.erb +84 -0
- data/app/views/tr8n/language/_header.html.erb +14 -0
- data/app/views/tr8n/language/_language_cases.html.erb +196 -0
- data/app/views/tr8n/language/_lists.html.erb +56 -0
- data/app/views/tr8n/language/_prohibited_words.html.erb +16 -0
- data/app/views/tr8n/language/_translator_dependencies.html.erb +27 -0
- data/app/views/tr8n/language/_translator_header.html.erb +19 -0
- data/app/views/tr8n/language/_translator_submit.html.erb +141 -0
- data/app/views/tr8n/language/_translator_votes.html.erb +27 -0
- data/app/views/tr8n/language/index.html.erb +54 -0
- data/app/views/tr8n/language/lb_language_case_rule.html.erb +94 -0
- data/app/views/tr8n/language/rules/_date_rule.html.erb +3 -0
- data/app/views/tr8n/language/rules/_gender_list_rule.html.erb +23 -0
- data/app/views/tr8n/language/rules/_gender_rule.html.erb +3 -0
- data/app/views/tr8n/language/rules/_list_rule.html.erb +3 -0
- data/app/views/tr8n/language/rules/_number_rule.html.erb +24 -0
- data/app/views/tr8n/language/rules/_value_rule.html.erb +3 -0
- data/app/views/tr8n/language/select.html.erb +72 -0
- data/app/views/tr8n/language/table.html.erb +32 -0
- data/app/views/tr8n/language/translator.html.erb +18 -0
- data/app/views/tr8n/language_cases/_gender_based.html.erb +32 -0
- data/app/views/tr8n/language_cases/_gender_neutral.html.erb +25 -0
- data/app/views/tr8n/language_cases/_manager_header.html.erb +18 -0
- data/app/views/tr8n/language_cases/index.html.erb +54 -0
- data/app/views/tr8n/language_cases/manager.html.erb +60 -0
- data/app/views/tr8n/login/index.html.erb +33 -0
- data/app/views/tr8n/login/register.html.erb +57 -0
- data/app/views/tr8n/phrases/_breadcrumb.html.erb +11 -0
- data/app/views/tr8n/phrases/_comment.html.erb +17 -0
- data/app/views/tr8n/phrases/_comments_module.html.erb +37 -0
- data/app/views/tr8n/phrases/_dictionary.rhtml +29 -0
- data/app/views/tr8n/phrases/_header.html.erb +24 -0
- data/app/views/tr8n/phrases/_new_comment.html.erb +31 -0
- data/app/views/tr8n/phrases/_permutations_module.html.erb +30 -0
- data/app/views/tr8n/phrases/_tokens.html.erb +122 -0
- data/app/views/tr8n/phrases/_toolbar.html.erb +33 -0
- data/app/views/tr8n/phrases/_translation_module.html.erb +127 -0
- data/app/views/tr8n/phrases/_translations_module.html.erb +70 -0
- data/app/views/tr8n/phrases/index.html.erb +90 -0
- data/app/views/tr8n/phrases/lb_sources.html.erb +51 -0
- data/app/views/tr8n/phrases/map.html.erb +42 -0
- data/app/views/tr8n/phrases/view.html.erb +77 -0
- data/app/views/tr8n/translations/_list.html.erb +71 -0
- data/app/views/tr8n/translations/_original_phrase.html.erb +11 -0
- data/app/views/tr8n/translations/_translation.html.erb +80 -0
- data/app/views/tr8n/translations/index.html.erb +30 -0
- data/app/views/tr8n/translator/_basic_info.html.erb +95 -0
- data/app/views/tr8n/translator/_header.html.erb +12 -0
- data/app/views/tr8n/translator/_header_key_report.html.erb +12 -0
- data/app/views/tr8n/translator/index.html.erb +25 -0
- data/app/views/tr8n/translator/lb_report.html.erb +113 -0
- data/config.ru +4 -0
- data/config/application.rb +65 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +13 -0
- data/config/environment.rb +46 -0
- data/config/environments/development.rb +25 -0
- data/config/environments/test.rb +35 -0
- data/config/routes.rb +47 -0
- data/config/tr8n/config.yml +247 -0
- data/config/tr8n/data/ip_locations.csv +93460 -0
- data/config/tr8n/rules/default_cases.yml +141 -0
- data/config/tr8n/rules/default_date_rules.yml +20 -0
- data/config/tr8n/rules/default_gender_list_rules.yml +82 -0
- data/config/tr8n/rules/default_gender_rules.yml +20 -0
- data/config/tr8n/rules/default_list_rules.yml +19 -0
- data/config/tr8n/rules/default_numeric_rules.yml +42 -0
- data/config/tr8n/rules/default_value_rules.yml +18 -0
- data/config/tr8n/site/default_glossary.yml +18 -0
- data/config/tr8n/site/default_languages.yml +1591 -0
- data/config/tr8n/site/features.yml +111 -0
- data/config/tr8n/site/shortcuts.yml +55 -0
- data/config/tr8n/site/sitemap.json +42 -0
- data/config/tr8n/tokens/data.yml +19 -0
- data/config/tr8n/tokens/decorations.yml +16 -0
- data/config/will_filter/config.yml +97 -0
- data/db/extras/20100511185330_create_test_users.rb +43 -0
- data/db/migrate/20090730070119_create_will_filter_tables.rb +19 -0
- data/db/migrate/20100405201417_create_tr8n_tables.rb +350 -0
- data/db/seeds.rb +7 -0
- data/doc/README_FOR_APP +2 -0
- data/doc/cheat sheet.docx +0 -0
- data/doc/cheat sheet.pdf +0 -0
- data/doc/classes.graffle +12555 -0
- data/doc/classes.pdf +0 -0
- data/doc/client sdk sequence.graffle +2768 -0
- data/doc/integration.doc +0 -0
- data/doc/integration.docx +0 -0
- data/doc/pixel client sdk.graffle +1454 -0
- data/lib/application_controller.rb +38 -0
- data/lib/application_helper.rb +336 -0
- data/lib/core_ext/array.rb +61 -0
- data/lib/core_ext/date.rb +76 -0
- data/lib/core_ext/fixnum.rb +35 -0
- data/lib/core_ext/hash.rb +60 -0
- data/lib/core_ext/string.rb +49 -0
- data/lib/core_ext/time.rb +83 -0
- data/lib/generators/tr8n/templates/create_tr8n_tables.rb +350 -0
- data/lib/generators/tr8n/tr8n_generator.rb +49 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/tr8n_tasks.rake +99 -0
- data/lib/tr8n.rb +3 -0
- data/lib/tr8n/active_dumper.rb +49 -0
- data/lib/tr8n/cache.rb +57 -0
- data/lib/tr8n/common_methods.rb +61 -0
- data/lib/tr8n/config.rb +719 -0
- data/lib/tr8n/controller_methods.rb +112 -0
- data/lib/tr8n/dictionary.rb +53 -0
- data/lib/tr8n/engine.rb +29 -0
- data/lib/tr8n/exception.rb +26 -0
- data/lib/tr8n/extender.rb +34 -0
- data/lib/tr8n/helper_methods.rb +304 -0
- data/lib/tr8n/ip_address.rb +52 -0
- data/lib/tr8n/key_registration_exception.rb +26 -0
- data/lib/tr8n/keyboard_mapping.rb +174 -0
- data/lib/tr8n/logger.rb +60 -0
- data/lib/tr8n/site_map.rb +85 -0
- data/lib/tr8n/site_map_section.rb +108 -0
- data/lib/tr8n/token.rb +438 -0
- data/lib/tr8n/token_exception.rb +26 -0
- data/lib/tr8n/tokenized_label.rb +141 -0
- data/lib/tr8n/tokens/data_token.rb +52 -0
- data/lib/tr8n/tokens/decoration_token.rb +124 -0
- data/lib/tr8n/tokens/hidden_token.rb +87 -0
- data/lib/tr8n/tokens/method_token.rb +60 -0
- data/lib/tr8n/tokens/transform_token.rb +131 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +26 -0
- data/public/favicon.ico +0 -0
- data/public/robots.txt +5 -0
- data/public/tr8n/images/accept.png +0 -0
- data/public/tr8n/images/action_tab_bkgd.gif +0 -0
- data/public/tr8n/images/action_tab_white_bkgd.gif +0 -0
- data/public/tr8n/images/add.png +0 -0
- data/public/tr8n/images/arrow_down.gif +0 -0
- data/public/tr8n/images/arrow_down.png +0 -0
- data/public/tr8n/images/arrow_down_grey.png +0 -0
- data/public/tr8n/images/arrow_right.gif +0 -0
- data/public/tr8n/images/arrow_up.png +0 -0
- data/public/tr8n/images/arrow_up_grey.png +0 -0
- data/public/tr8n/images/bullet_go.png +0 -0
- data/public/tr8n/images/buttons.png +0 -0
- data/public/tr8n/images/cancel.png +0 -0
- data/public/tr8n/images/close.gif +0 -0
- data/public/tr8n/images/cross.png +0 -0
- data/public/tr8n/images/delete.png +0 -0
- data/public/tr8n/images/disk.png +0 -0
- data/public/tr8n/images/examples/context_rules_1.png +0 -0
- data/public/tr8n/images/examples/context_rules_2.png +0 -0
- data/public/tr8n/images/examples/date_rules_1.png +0 -0
- data/public/tr8n/images/examples/date_rules_2.png +0 -0
- data/public/tr8n/images/examples/date_rules_3.png +0 -0
- data/public/tr8n/images/examples/gender_rules_1.png +0 -0
- data/public/tr8n/images/examples/gender_rules_2.png +0 -0
- data/public/tr8n/images/examples/gender_rules_3.png +0 -0
- data/public/tr8n/images/examples/language_manager_1.png +0 -0
- data/public/tr8n/images/examples/list_rules_1.png +0 -0
- data/public/tr8n/images/examples/list_rules_2.png +0 -0
- data/public/tr8n/images/examples/list_rules_3.png +0 -0
- data/public/tr8n/images/examples/numeric_rules_1.png +0 -0
- data/public/tr8n/images/examples/numeric_rules_2.png +0 -0
- data/public/tr8n/images/examples/numeric_rules_3.png +0 -0
- data/public/tr8n/images/examples/numeric_rules_4.png +0 -0
- data/public/tr8n/images/exclamation.png +0 -0
- data/public/tr8n/images/eye.png +0 -0
- data/public/tr8n/images/eye_not.png +0 -0
- data/public/tr8n/images/facebook/connect_light_medium_long.gif +0 -0
- data/public/tr8n/images/field_sprite.gif +0 -0
- data/public/tr8n/images/find.png +0 -0
- data/public/tr8n/images/flags/.DS_Store +0 -0
- data/public/tr8n/images/flags/ab.png +0 -0
- data/public/tr8n/images/flags/ach.png +0 -0
- data/public/tr8n/images/flags/af.png +0 -0
- data/public/tr8n/images/flags/ak.png +0 -0
- data/public/tr8n/images/flags/am.png +0 -0
- data/public/tr8n/images/flags/an.png +0 -0
- data/public/tr8n/images/flags/ar-AE.png +0 -0
- data/public/tr8n/images/flags/ar-BH.png +0 -0
- data/public/tr8n/images/flags/ar-DZ.png +0 -0
- data/public/tr8n/images/flags/ar-EG.png +0 -0
- data/public/tr8n/images/flags/ar-IQ.png +0 -0
- data/public/tr8n/images/flags/ar-JO.png +0 -0
- data/public/tr8n/images/flags/ar-KW.png +0 -0
- data/public/tr8n/images/flags/ar-LB.png +0 -0
- data/public/tr8n/images/flags/ar-LY.png +0 -0
- data/public/tr8n/images/flags/ar-MA.png +0 -0
- data/public/tr8n/images/flags/ar-OM.png +0 -0
- data/public/tr8n/images/flags/ar-QA.png +0 -0
- data/public/tr8n/images/flags/ar-SA.png +0 -0
- data/public/tr8n/images/flags/ar-SY.png +0 -0
- data/public/tr8n/images/flags/ar-TN.png +0 -0
- data/public/tr8n/images/flags/ar-YE.png +0 -0
- data/public/tr8n/images/flags/ar.png +0 -0
- data/public/tr8n/images/flags/as.png +0 -0
- data/public/tr8n/images/flags/ast.png +0 -0
- data/public/tr8n/images/flags/ay.png +0 -0
- data/public/tr8n/images/flags/az.png +0 -0
- data/public/tr8n/images/flags/ba.png +0 -0
- data/public/tr8n/images/flags/be.png +0 -0
- data/public/tr8n/images/flags/bg.png +0 -0
- data/public/tr8n/images/flags/bh.png +0 -0
- data/public/tr8n/images/flags/bn.png +0 -0
- data/public/tr8n/images/flags/bo.png +0 -0
- data/public/tr8n/images/flags/br.png +0 -0
- data/public/tr8n/images/flags/bs.png +0 -0
- data/public/tr8n/images/flags/ca.png +0 -0
- data/public/tr8n/images/flags/cb.png +0 -0
- data/public/tr8n/images/flags/ce.png +0 -0
- data/public/tr8n/images/flags/ch.png +0 -0
- data/public/tr8n/images/flags/ck-US.png +0 -0
- data/public/tr8n/images/flags/co.png +0 -0
- data/public/tr8n/images/flags/cr.png +0 -0
- data/public/tr8n/images/flags/cs.png +0 -0
- data/public/tr8n/images/flags/cv.png +0 -0
- data/public/tr8n/images/flags/cy.png +0 -0
- data/public/tr8n/images/flags/da.png +0 -0
- data/public/tr8n/images/flags/de-AT.png +0 -0
- data/public/tr8n/images/flags/de-CH.png +0 -0
- data/public/tr8n/images/flags/de-DE.png +0 -0
- data/public/tr8n/images/flags/de-LI.png +0 -0
- data/public/tr8n/images/flags/de-LU.png +0 -0
- data/public/tr8n/images/flags/de.png +0 -0
- data/public/tr8n/images/flags/el.png +0 -0
- data/public/tr8n/images/flags/en-AU.png +0 -0
- data/public/tr8n/images/flags/en-BZ.png +0 -0
- data/public/tr8n/images/flags/en-CA.png +0 -0
- data/public/tr8n/images/flags/en-IE.png +0 -0
- data/public/tr8n/images/flags/en-JM.png +0 -0
- data/public/tr8n/images/flags/en-NZ.png +0 -0
- data/public/tr8n/images/flags/en-PH.png +0 -0
- data/public/tr8n/images/flags/en-PI.png +0 -0
- data/public/tr8n/images/flags/en-SC.png +0 -0
- data/public/tr8n/images/flags/en-UK.png +0 -0
- data/public/tr8n/images/flags/en-US.png +0 -0
- data/public/tr8n/images/flags/en-ZA.png +0 -0
- data/public/tr8n/images/flags/en-ZW.png +0 -0
- data/public/tr8n/images/flags/en.png +0 -0
- data/public/tr8n/images/flags/eo.png +0 -0
- data/public/tr8n/images/flags/es-AR.png +0 -0
- data/public/tr8n/images/flags/es-BO.png +0 -0
- data/public/tr8n/images/flags/es-CL.png +0 -0
- data/public/tr8n/images/flags/es-CO.png +0 -0
- data/public/tr8n/images/flags/es-CR.png +0 -0
- data/public/tr8n/images/flags/es-DO.png +0 -0
- data/public/tr8n/images/flags/es-EC.png +0 -0
- data/public/tr8n/images/flags/es-ES.png +0 -0
- data/public/tr8n/images/flags/es-GT.png +0 -0
- data/public/tr8n/images/flags/es-HN.png +0 -0
- data/public/tr8n/images/flags/es-MX.png +0 -0
- data/public/tr8n/images/flags/es-NI.png +0 -0
- data/public/tr8n/images/flags/es-PA.png +0 -0
- data/public/tr8n/images/flags/es-PE.png +0 -0
- data/public/tr8n/images/flags/es-PR.png +0 -0
- data/public/tr8n/images/flags/es-PY.png +0 -0
- data/public/tr8n/images/flags/es-SV.png +0 -0
- data/public/tr8n/images/flags/es-UY.png +0 -0
- data/public/tr8n/images/flags/es-VE.png +0 -0
- data/public/tr8n/images/flags/es.png +0 -0
- data/public/tr8n/images/flags/et.png +0 -0
- data/public/tr8n/images/flags/eu.png +0 -0
- data/public/tr8n/images/flags/fa-IR.png +0 -0
- data/public/tr8n/images/flags/fa.png +0 -0
- data/public/tr8n/images/flags/fb-LT.png +0 -0
- data/public/tr8n/images/flags/fi.png +0 -0
- data/public/tr8n/images/flags/fj.png +0 -0
- data/public/tr8n/images/flags/fo.png +0 -0
- data/public/tr8n/images/flags/fr-BE.png +0 -0
- data/public/tr8n/images/flags/fr-CA.png +0 -0
- data/public/tr8n/images/flags/fr-CH.png +0 -0
- data/public/tr8n/images/flags/fr-FR.png +0 -0
- data/public/tr8n/images/flags/fr-LU.png +0 -0
- data/public/tr8n/images/flags/fr-MC.png +0 -0
- data/public/tr8n/images/flags/fr.png +0 -0
- data/public/tr8n/images/flags/fur.png +0 -0
- data/public/tr8n/images/flags/fy.png +0 -0
- data/public/tr8n/images/flags/ga.png +0 -0
- data/public/tr8n/images/flags/gd.png +0 -0
- data/public/tr8n/images/flags/gl.png +0 -0
- data/public/tr8n/images/flags/gn.png +0 -0
- data/public/tr8n/images/flags/gu.png +0 -0
- data/public/tr8n/images/flags/gv.png +0 -0
- data/public/tr8n/images/flags/ha.png +0 -0
- data/public/tr8n/images/flags/haw.png +0 -0
- data/public/tr8n/images/flags/he.png +0 -0
- data/public/tr8n/images/flags/hi.png +0 -0
- data/public/tr8n/images/flags/hr.png +0 -0
- data/public/tr8n/images/flags/hsb.png +0 -0
- data/public/tr8n/images/flags/ht.png +0 -0
- data/public/tr8n/images/flags/hu.png +0 -0
- data/public/tr8n/images/flags/hy.png +0 -0
- data/public/tr8n/images/flags/ia.png +0 -0
- data/public/tr8n/images/flags/id.png +0 -0
- data/public/tr8n/images/flags/ie.png +0 -0
- data/public/tr8n/images/flags/ig.png +0 -0
- data/public/tr8n/images/flags/is.png +0 -0
- data/public/tr8n/images/flags/it-CH.png +0 -0
- data/public/tr8n/images/flags/it.png +0 -0
- data/public/tr8n/images/flags/iu.png +0 -0
- data/public/tr8n/images/flags/ja.png +0 -0
- data/public/tr8n/images/flags/jw.png +0 -0
- data/public/tr8n/images/flags/ka.png +0 -0
- data/public/tr8n/images/flags/kk.png +0 -0
- data/public/tr8n/images/flags/kl.png +0 -0
- data/public/tr8n/images/flags/km.png +0 -0
- data/public/tr8n/images/flags/kn.png +0 -0
- data/public/tr8n/images/flags/ko-KP.png +0 -0
- data/public/tr8n/images/flags/ko-KR.png +0 -0
- data/public/tr8n/images/flags/ko.png +0 -0
- data/public/tr8n/images/flags/kok.png +0 -0
- data/public/tr8n/images/flags/ks.png +0 -0
- data/public/tr8n/images/flags/ku.png +0 -0
- data/public/tr8n/images/flags/ky.png +0 -0
- data/public/tr8n/images/flags/la.png +0 -0
- data/public/tr8n/images/flags/lb.png +0 -0
- data/public/tr8n/images/flags/lg.png +0 -0
- data/public/tr8n/images/flags/li-NL.png +0 -0
- data/public/tr8n/images/flags/ln.png +0 -0
- data/public/tr8n/images/flags/lo.png +0 -0
- data/public/tr8n/images/flags/lt.png +0 -0
- data/public/tr8n/images/flags/lv.png +0 -0
- data/public/tr8n/images/flags/md.png +0 -0
- data/public/tr8n/images/flags/mfe.png +0 -0
- data/public/tr8n/images/flags/mg.png +0 -0
- data/public/tr8n/images/flags/mh.png +0 -0
- data/public/tr8n/images/flags/mi.png +0 -0
- data/public/tr8n/images/flags/mk.png +0 -0
- data/public/tr8n/images/flags/ml.png +0 -0
- data/public/tr8n/images/flags/mn.png +0 -0
- data/public/tr8n/images/flags/mo.png +0 -0
- data/public/tr8n/images/flags/mr.png +0 -0
- data/public/tr8n/images/flags/ms.png +0 -0
- data/public/tr8n/images/flags/mt.png +0 -0
- data/public/tr8n/images/flags/my.png +0 -0
- data/public/tr8n/images/flags/na.png +0 -0
- data/public/tr8n/images/flags/nb.png +0 -0
- data/public/tr8n/images/flags/nd.png +0 -0
- data/public/tr8n/images/flags/ne.png +0 -0
- data/public/tr8n/images/flags/ng.png +0 -0
- data/public/tr8n/images/flags/nl-NE.png +0 -0
- data/public/tr8n/images/flags/nl.png +0 -0
- data/public/tr8n/images/flags/nn.png +0 -0
- data/public/tr8n/images/flags/no.png +0 -0
- data/public/tr8n/images/flags/nr.png +0 -0
- data/public/tr8n/images/flags/nso.png +0 -0
- data/public/tr8n/images/flags/nv.png +0 -0
- data/public/tr8n/images/flags/ny.png +0 -0
- data/public/tr8n/images/flags/nyn.png +0 -0
- data/public/tr8n/images/flags/oc.png +0 -0
- data/public/tr8n/images/flags/om.png +0 -0
- data/public/tr8n/images/flags/or.png +0 -0
- data/public/tr8n/images/flags/pa-IN.png +0 -0
- data/public/tr8n/images/flags/pa-PK.png +0 -0
- data/public/tr8n/images/flags/pa.png +0 -0
- data/public/tr8n/images/flags/pf.png +0 -0
- data/public/tr8n/images/flags/pl.png +0 -0
- data/public/tr8n/images/flags/pp.png +0 -0
- data/public/tr8n/images/flags/ps.png +0 -0
- data/public/tr8n/images/flags/pt-BZ.png +0 -0
- data/public/tr8n/images/flags/pt.png +0 -0
- data/public/tr8n/images/flags/qu-PE.png +0 -0
- data/public/tr8n/images/flags/qu.png +0 -0
- data/public/tr8n/images/flags/rj.png +0 -0
- data/public/tr8n/images/flags/rm.png +0 -0
- data/public/tr8n/images/flags/rn.png +0 -0
- data/public/tr8n/images/flags/ro-MD.png +0 -0
- data/public/tr8n/images/flags/ro-RO.png +0 -0
- data/public/tr8n/images/flags/ro.png +0 -0
- data/public/tr8n/images/flags/ru.png +0 -0
- data/public/tr8n/images/flags/rw.png +0 -0
- data/public/tr8n/images/flags/sa.png +0 -0
- data/public/tr8n/images/flags/sc.png +0 -0
- data/public/tr8n/images/flags/sd.png +0 -0
- data/public/tr8n/images/flags/se-NO.png +0 -0
- data/public/tr8n/images/flags/sg.png +0 -0
- data/public/tr8n/images/flags/sh.png +0 -0
- data/public/tr8n/images/flags/si.png +0 -0
- data/public/tr8n/images/flags/sk.png +0 -0
- data/public/tr8n/images/flags/sl.png +0 -0
- data/public/tr8n/images/flags/sm.png +0 -0
- data/public/tr8n/images/flags/sn.png +0 -0
- data/public/tr8n/images/flags/so.png +0 -0
- data/public/tr8n/images/flags/sq.png +0 -0
- data/public/tr8n/images/flags/sr-me.png +0 -0
- data/public/tr8n/images/flags/sr.png +0 -0
- data/public/tr8n/images/flags/ss.png +0 -0
- data/public/tr8n/images/flags/st.png +0 -0
- data/public/tr8n/images/flags/su.png +0 -0
- data/public/tr8n/images/flags/sv-FI.png +0 -0
- data/public/tr8n/images/flags/sv-SE.png +0 -0
- data/public/tr8n/images/flags/sv.png +0 -0
- data/public/tr8n/images/flags/sw.png +0 -0
- data/public/tr8n/images/flags/ta.png +0 -0
- data/public/tr8n/images/flags/te.png +0 -0
- data/public/tr8n/images/flags/tg.png +0 -0
- data/public/tr8n/images/flags/th.png +0 -0
- data/public/tr8n/images/flags/ti.png +0 -0
- data/public/tr8n/images/flags/tig.png +0 -0
- data/public/tr8n/images/flags/tk.png +0 -0
- data/public/tr8n/images/flags/tl.png +0 -0
- data/public/tr8n/images/flags/tlh.png +0 -0
- data/public/tr8n/images/flags/tn.png +0 -0
- data/public/tr8n/images/flags/to.png +0 -0
- data/public/tr8n/images/flags/tr.png +0 -0
- data/public/tr8n/images/flags/ts.png +0 -0
- data/public/tr8n/images/flags/tt.png +0 -0
- data/public/tr8n/images/flags/tw.png +0 -0
- data/public/tr8n/images/flags/ug.png +0 -0
- data/public/tr8n/images/flags/uk.png +0 -0
- data/public/tr8n/images/flags/ur.png +0 -0
- data/public/tr8n/images/flags/uz.png +0 -0
- data/public/tr8n/images/flags/ve.png +0 -0
- data/public/tr8n/images/flags/vi.png +0 -0
- data/public/tr8n/images/flags/vo.png +0 -0
- data/public/tr8n/images/flags/wa.png +0 -0
- data/public/tr8n/images/flags/wo.png +0 -0
- data/public/tr8n/images/flags/xh.png +0 -0
- data/public/tr8n/images/flags/yi.png +0 -0
- data/public/tr8n/images/flags/yo.png +0 -0
- data/public/tr8n/images/flags/zh-CN.png +0 -0
- data/public/tr8n/images/flags/zh-HK.png +0 -0
- data/public/tr8n/images/flags/zh-SG.png +0 -0
- data/public/tr8n/images/flags/zh-TW.png +0 -0
- data/public/tr8n/images/flags/zh.png +0 -0
- data/public/tr8n/images/flags/zu.png +0 -0
- data/public/tr8n/images/globe.gif +0 -0
- data/public/tr8n/images/help.png +0 -0
- data/public/tr8n/images/help/color_coding.png +0 -0
- data/public/tr8n/images/help/language_selector.png +0 -0
- data/public/tr8n/images/help/language_selector_default.png +0 -0
- data/public/tr8n/images/help/languages_disabled.png +0 -0
- data/public/tr8n/images/help/translator.png +0 -0
- data/public/tr8n/images/help2.png +0 -0
- data/public/tr8n/images/information.png +0 -0
- data/public/tr8n/images/keyboard.png +0 -0
- data/public/tr8n/images/language_selector_arrow.gif +0 -0
- data/public/tr8n/images/left_quote.png +0 -0
- data/public/tr8n/images/lightning.png +0 -0
- data/public/tr8n/images/loading.gif +0 -0
- data/public/tr8n/images/loading2.gif +0 -0
- data/public/tr8n/images/loading3.gif +0 -0
- data/public/tr8n/images/loading_large.gif +0 -0
- data/public/tr8n/images/lock.png +0 -0
- data/public/tr8n/images/lock_add.png +0 -0
- data/public/tr8n/images/lock_delete.png +0 -0
- data/public/tr8n/images/lock_open.png +0 -0
- data/public/tr8n/images/medals/bronze.png +0 -0
- data/public/tr8n/images/medals/gold.png +0 -0
- data/public/tr8n/images/medals/runner.png +0 -0
- data/public/tr8n/images/medals/silver.png +0 -0
- data/public/tr8n/images/pencil.png +0 -0
- data/public/tr8n/images/photo_silhouette.gif +0 -0
- data/public/tr8n/images/plus.png +0 -0
- data/public/tr8n/images/random.png +0 -0
- data/public/tr8n/images/random2.png +0 -0
- data/public/tr8n/images/rating_star0.png +0 -0
- data/public/tr8n/images/rating_star05.png +0 -0
- data/public/tr8n/images/rating_star1.png +0 -0
- data/public/tr8n/images/rating_stars.gif +0 -0
- data/public/tr8n/images/rating_stars.psd +0 -0
- data/public/tr8n/images/reply.png +0 -0
- data/public/tr8n/images/right_quote.png +0 -0
- data/public/tr8n/images/rotating_world.gif +0 -0
- data/public/tr8n/images/script.png +0 -0
- data/public/tr8n/images/script_edit.png +0 -0
- data/public/tr8n/images/script_gear.png +0 -0
- data/public/tr8n/images/site_sprite.gif +0 -0
- data/public/tr8n/images/spinner.gif +0 -0
- data/public/tr8n/images/star.png +0 -0
- data/public/tr8n/images/table_edit.png +0 -0
- data/public/tr8n/images/table_gear.png +0 -0
- data/public/tr8n/images/table_multiple.png +0 -0
- data/public/tr8n/images/thumb_down.png +0 -0
- data/public/tr8n/images/thumb_up.png +0 -0
- data/public/tr8n/images/toolbar_bg.gif +0 -0
- data/public/tr8n/images/top_left_stem.png +0 -0
- data/public/tr8n/images/top_right_stem.png +0 -0
- data/public/tr8n/images/tr8n_loading.gif +0 -0
- data/public/tr8n/images/tr8n_logo.jpg +0 -0
- data/public/tr8n/images/tr8n_logo.png +0 -0
- data/public/tr8n/images/tr8n_logo2.gif +0 -0
- data/public/tr8n/images/tr8n_logo2.png +0 -0
- data/public/tr8n/images/tr8n_logo_wiki.png +0 -0
- data/public/tr8n/images/tr8n_logo_wiki2.png +0 -0
- data/public/tr8n/images/translate_icn.gif +0 -0
- data/public/tr8n/images/wizard.png +0 -0
- data/public/tr8n/javascripts/jsDraw2D.js +24 -0
- data/public/tr8n/javascripts/keyboard_1_36.js +1214 -0
- data/public/tr8n/javascripts/keyboard_1_44.js +1735 -0
- data/public/tr8n/javascripts/shortcut.js +223 -0
- data/public/tr8n/javascripts/tr8n.js +904 -0
- data/public/tr8n/javascripts/tr8n_client_sdk.js +1182 -0
- data/public/tr8n/javascripts/tr8n_prototype_effects.js +65 -0
- data/public/tr8n/stylesheets/components.css +208 -0
- data/public/tr8n/stylesheets/keyboard_1_36.css +185 -0
- data/public/tr8n/stylesheets/keyboard_1_44.css +268 -0
- data/public/tr8n/stylesheets/layout.css +119 -0
- data/public/tr8n/stylesheets/tr8n.css +201 -0
- data/rails/init.rb +53 -0
- data/script/rails +6 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +13 -0
- data/tr8n.gemspec +40 -0
- metadata +865 -0
@@ -0,0 +1,223 @@
|
|
1
|
+
/**
|
2
|
+
* http://www.openjs.com/scripts/events/keyboard_shortcuts/
|
3
|
+
* Version : 2.01.B
|
4
|
+
* By Binny V A
|
5
|
+
* License : BSD
|
6
|
+
*/
|
7
|
+
shortcut = {
|
8
|
+
'all_shortcuts':{},//All the shortcuts are stored in this array
|
9
|
+
'add': function(shortcut_combination,callback,opt) {
|
10
|
+
//Provide a set of default options
|
11
|
+
var default_options = {
|
12
|
+
'type':'keydown',
|
13
|
+
'propagate':false,
|
14
|
+
'disable_in_input':false,
|
15
|
+
'target':document,
|
16
|
+
'keycode':false
|
17
|
+
}
|
18
|
+
if(!opt) opt = default_options;
|
19
|
+
else {
|
20
|
+
for(var dfo in default_options) {
|
21
|
+
if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
var ele = opt.target;
|
26
|
+
if(typeof opt.target == 'string') ele = document.getElementById(opt.target);
|
27
|
+
var ths = this;
|
28
|
+
shortcut_combination = shortcut_combination.toLowerCase();
|
29
|
+
|
30
|
+
//The function to be called at keypress
|
31
|
+
var func = function(e) {
|
32
|
+
e = e || window.event;
|
33
|
+
|
34
|
+
if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields
|
35
|
+
var element;
|
36
|
+
if(e.target) element=e.target;
|
37
|
+
else if(e.srcElement) element=e.srcElement;
|
38
|
+
if(element.nodeType==3) element=element.parentNode;
|
39
|
+
|
40
|
+
if(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return;
|
41
|
+
}
|
42
|
+
|
43
|
+
//Find Which key is pressed
|
44
|
+
if (e.keyCode) code = e.keyCode;
|
45
|
+
else if (e.which) code = e.which;
|
46
|
+
var character = String.fromCharCode(code).toLowerCase();
|
47
|
+
|
48
|
+
if(code == 188) character=","; //If the user presses , when the type is onkeydown
|
49
|
+
if(code == 190) character="."; //If the user presses , when the type is onkeydown
|
50
|
+
|
51
|
+
var keys = shortcut_combination.split("+");
|
52
|
+
//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked
|
53
|
+
var kp = 0;
|
54
|
+
|
55
|
+
//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken
|
56
|
+
var shift_nums = {
|
57
|
+
"`":"~",
|
58
|
+
"1":"!",
|
59
|
+
"2":"@",
|
60
|
+
"3":"#",
|
61
|
+
"4":"$",
|
62
|
+
"5":"%",
|
63
|
+
"6":"^",
|
64
|
+
"7":"&",
|
65
|
+
"8":"*",
|
66
|
+
"9":"(",
|
67
|
+
"0":")",
|
68
|
+
"-":"_",
|
69
|
+
"=":"+",
|
70
|
+
";":":",
|
71
|
+
"'":"\"",
|
72
|
+
",":"<",
|
73
|
+
".":">",
|
74
|
+
"/":"?",
|
75
|
+
"\\":"|"
|
76
|
+
}
|
77
|
+
//Special Keys - and their codes
|
78
|
+
var special_keys = {
|
79
|
+
'esc':27,
|
80
|
+
'escape':27,
|
81
|
+
'tab':9,
|
82
|
+
'space':32,
|
83
|
+
'return':13,
|
84
|
+
'enter':13,
|
85
|
+
'backspace':8,
|
86
|
+
|
87
|
+
'scrolllock':145,
|
88
|
+
'scroll_lock':145,
|
89
|
+
'scroll':145,
|
90
|
+
'capslock':20,
|
91
|
+
'caps_lock':20,
|
92
|
+
'caps':20,
|
93
|
+
'numlock':144,
|
94
|
+
'num_lock':144,
|
95
|
+
'num':144,
|
96
|
+
|
97
|
+
'pause':19,
|
98
|
+
'break':19,
|
99
|
+
|
100
|
+
'insert':45,
|
101
|
+
'home':36,
|
102
|
+
'delete':46,
|
103
|
+
'end':35,
|
104
|
+
|
105
|
+
'pageup':33,
|
106
|
+
'page_up':33,
|
107
|
+
'pu':33,
|
108
|
+
|
109
|
+
'pagedown':34,
|
110
|
+
'page_down':34,
|
111
|
+
'pd':34,
|
112
|
+
|
113
|
+
'left':37,
|
114
|
+
'up':38,
|
115
|
+
'right':39,
|
116
|
+
'down':40,
|
117
|
+
|
118
|
+
'f1':112,
|
119
|
+
'f2':113,
|
120
|
+
'f3':114,
|
121
|
+
'f4':115,
|
122
|
+
'f5':116,
|
123
|
+
'f6':117,
|
124
|
+
'f7':118,
|
125
|
+
'f8':119,
|
126
|
+
'f9':120,
|
127
|
+
'f10':121,
|
128
|
+
'f11':122,
|
129
|
+
'f12':123
|
130
|
+
}
|
131
|
+
|
132
|
+
var modifiers = {
|
133
|
+
shift: { wanted:false, pressed:false},
|
134
|
+
ctrl : { wanted:false, pressed:false},
|
135
|
+
alt : { wanted:false, pressed:false},
|
136
|
+
meta : { wanted:false, pressed:false} //Meta is Mac specific
|
137
|
+
};
|
138
|
+
|
139
|
+
if(e.ctrlKey) modifiers.ctrl.pressed = true;
|
140
|
+
if(e.shiftKey) modifiers.shift.pressed = true;
|
141
|
+
if(e.altKey) modifiers.alt.pressed = true;
|
142
|
+
if(e.metaKey) modifiers.meta.pressed = true;
|
143
|
+
|
144
|
+
for(var i=0; k=keys[i],i<keys.length; i++) {
|
145
|
+
//Modifiers
|
146
|
+
if(k == 'ctrl' || k == 'control') {
|
147
|
+
kp++;
|
148
|
+
modifiers.ctrl.wanted = true;
|
149
|
+
|
150
|
+
} else if(k == 'shift') {
|
151
|
+
kp++;
|
152
|
+
modifiers.shift.wanted = true;
|
153
|
+
|
154
|
+
} else if(k == 'alt') {
|
155
|
+
kp++;
|
156
|
+
modifiers.alt.wanted = true;
|
157
|
+
} else if(k == 'meta') {
|
158
|
+
kp++;
|
159
|
+
modifiers.meta.wanted = true;
|
160
|
+
} else if(k.length > 1) { //If it is a special key
|
161
|
+
if(special_keys[k] == code) kp++;
|
162
|
+
|
163
|
+
} else if(opt['keycode']) {
|
164
|
+
if(opt['keycode'] == code) kp++;
|
165
|
+
|
166
|
+
} else { //The special keys did not match
|
167
|
+
if(character == k) kp++;
|
168
|
+
else {
|
169
|
+
if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase
|
170
|
+
character = shift_nums[character];
|
171
|
+
if(character == k) kp++;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
if(kp == keys.length &&
|
178
|
+
modifiers.ctrl.pressed == modifiers.ctrl.wanted &&
|
179
|
+
modifiers.shift.pressed == modifiers.shift.wanted &&
|
180
|
+
modifiers.alt.pressed == modifiers.alt.wanted &&
|
181
|
+
modifiers.meta.pressed == modifiers.meta.wanted) {
|
182
|
+
callback(e);
|
183
|
+
|
184
|
+
if(!opt['propagate']) { //Stop the event
|
185
|
+
//e.cancelBubble is supported by IE - this will kill the bubbling process.
|
186
|
+
e.cancelBubble = true;
|
187
|
+
e.returnValue = false;
|
188
|
+
|
189
|
+
//e.stopPropagation works in Firefox.
|
190
|
+
if (e.stopPropagation) {
|
191
|
+
e.stopPropagation();
|
192
|
+
e.preventDefault();
|
193
|
+
}
|
194
|
+
return false;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
this.all_shortcuts[shortcut_combination] = {
|
199
|
+
'callback':func,
|
200
|
+
'target':ele,
|
201
|
+
'event': opt['type']
|
202
|
+
};
|
203
|
+
//Attach the function with the event
|
204
|
+
if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
|
205
|
+
else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
|
206
|
+
else ele['on'+opt['type']] = func;
|
207
|
+
},
|
208
|
+
|
209
|
+
//Remove the shortcut - just specify the shortcut and I will remove the binding
|
210
|
+
'remove':function(shortcut_combination) {
|
211
|
+
shortcut_combination = shortcut_combination.toLowerCase();
|
212
|
+
var binding = this.all_shortcuts[shortcut_combination];
|
213
|
+
delete(this.all_shortcuts[shortcut_combination])
|
214
|
+
if(!binding) return;
|
215
|
+
var type = binding['event'];
|
216
|
+
var ele = binding['target'];
|
217
|
+
var callback = binding['callback'];
|
218
|
+
|
219
|
+
if(ele.detachEvent) ele.detachEvent('on'+type, callback);
|
220
|
+
else if(ele.removeEventListener) ele.removeEventListener(type, callback, false);
|
221
|
+
else ele['on'+type] = false;
|
222
|
+
}
|
223
|
+
}
|
@@ -0,0 +1,904 @@
|
|
1
|
+
/****************************************************************************
|
2
|
+
Copyright (c) 2010 Michael Berkovich, Ian McDaniel, Geni Inc
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
****************************************************************************/
|
23
|
+
|
24
|
+
/****************************************************************************
|
25
|
+
**** Tr8n Generic Helper Functions
|
26
|
+
****************************************************************************/
|
27
|
+
|
28
|
+
document.createElement('tr8n');
|
29
|
+
|
30
|
+
var Tr8n = Tr8n || {
|
31
|
+
element:function(element_id) {
|
32
|
+
if (typeof element_id == 'string') return document.getElementById(element_id);
|
33
|
+
return element_id;
|
34
|
+
},
|
35
|
+
value:function(element_id) {
|
36
|
+
return Tr8n.element(element_id).value;
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
/****************************************************************************
|
41
|
+
**** Tr8n Effects Helper Functions - Can be overloaded by JS frameworks
|
42
|
+
****************************************************************************/
|
43
|
+
|
44
|
+
Tr8n.Effects = {
|
45
|
+
toggle: function(element_id) {
|
46
|
+
if (Tr8n.element(element_id).style.display == "none")
|
47
|
+
Tr8n.element(element_id).show();
|
48
|
+
else
|
49
|
+
Tr8n.element(element_id).hide();
|
50
|
+
},
|
51
|
+
hide: function(element_id) {
|
52
|
+
Tr8n.element(element_id).style.display = "none";
|
53
|
+
},
|
54
|
+
show: function(element_id) {
|
55
|
+
var style = (Tr8n.element(element_id).tagName == "SPAN") ? "inline" : "block";
|
56
|
+
Tr8n.element(element_id).style.display = style;
|
57
|
+
},
|
58
|
+
blindUp: function(element_id) {
|
59
|
+
Tr8n.Effects.hide(element_id);
|
60
|
+
},
|
61
|
+
blindDown: function(element_id) {
|
62
|
+
Tr8n.Effects.show(element_id);
|
63
|
+
},
|
64
|
+
appear: function(element_id) {
|
65
|
+
Tr8n.Effects.show(element_id);
|
66
|
+
},
|
67
|
+
fade: function(element_id) {
|
68
|
+
Tr8n.Effects.hide(element_id);
|
69
|
+
},
|
70
|
+
submit: function(element_id) {
|
71
|
+
Tr8n.element(element_id).submit();
|
72
|
+
},
|
73
|
+
focus: function(element_id) {
|
74
|
+
Tr8n.element(element_id).focus();
|
75
|
+
},
|
76
|
+
scrollTo: function(element_id) {
|
77
|
+
var theElement = Tr8n.element(element_id);
|
78
|
+
var selectedPosX = 0;
|
79
|
+
var selectedPosY = 0;
|
80
|
+
while(theElement != null){
|
81
|
+
selectedPosX += theElement.offsetLeft;
|
82
|
+
selectedPosY += theElement.offsetTop;
|
83
|
+
theElement = theElement.offsetParent;
|
84
|
+
}
|
85
|
+
window.scrollTo(selectedPosX,selectedPosY);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
/****************************************************************************
|
90
|
+
**** Tr8n Translator
|
91
|
+
****************************************************************************/
|
92
|
+
|
93
|
+
Tr8n.Translator = function(options) {
|
94
|
+
var self = this;
|
95
|
+
this.options = options;
|
96
|
+
this.translation_key_id = null;
|
97
|
+
|
98
|
+
this.container = document.createElement('div');
|
99
|
+
this.container.className = 'tr8n_translator';
|
100
|
+
this.container.id = 'tr8n_translator';
|
101
|
+
this.container.style.display = "none";
|
102
|
+
|
103
|
+
document.body.appendChild(this.container);
|
104
|
+
|
105
|
+
|
106
|
+
var event_type = Tr8n.Utils.isOpera() ? 'click' : 'contextmenu';
|
107
|
+
|
108
|
+
Tr8n.Utils.addEvent(document, event_type, function(e) {
|
109
|
+
if (Tr8n.Utils.isOpera() && !e.ctrlKey) return;
|
110
|
+
|
111
|
+
var translatable_node = Tr8n.Utils.findElement(e, ".tr8n_translatable");
|
112
|
+
var link_node = Tr8n.Utils.findElement(e, "a");
|
113
|
+
|
114
|
+
if (translatable_node == null) return;
|
115
|
+
|
116
|
+
if (link_node) {
|
117
|
+
var temp_href = link_node.href;
|
118
|
+
link_node.href='javascript:void(0);';
|
119
|
+
setTimeout(function() {link_node.href = temp_href;}, 500);
|
120
|
+
}
|
121
|
+
|
122
|
+
if (e.stop) e.stop();
|
123
|
+
if (e.preventDefault) e.preventDefault();
|
124
|
+
if (e.stopPropagation) e.stopPropagation();
|
125
|
+
|
126
|
+
self.show(translatable_node);
|
127
|
+
return false;
|
128
|
+
});
|
129
|
+
}
|
130
|
+
|
131
|
+
Tr8n.Translator.prototype = {
|
132
|
+
hide: function() {
|
133
|
+
this.container.style.display = "none";
|
134
|
+
Tr8n.Utils.showFlash();
|
135
|
+
},
|
136
|
+
|
137
|
+
show: function(translatable_node) {
|
138
|
+
var self = this;
|
139
|
+
if (tr8nLanguageSelector) tr8nLanguageSelector.hide();
|
140
|
+
if (tr8nLightbox) tr8nLightbox.hide();
|
141
|
+
if (tr8nLanguageCaseManager) tr8nLanguageCaseManager.hide();
|
142
|
+
Tr8n.Utils.hideFlash();
|
143
|
+
|
144
|
+
var html = "";
|
145
|
+
var splash_screen = Tr8n.element('tr8n_splash_screen');
|
146
|
+
|
147
|
+
if (splash_screen) {
|
148
|
+
html += splash_screen.innerHTML;
|
149
|
+
} else {
|
150
|
+
html += "<div style='font-size:18px;text-align:center; margin:5px; padding:10px; background-color:black;'>";
|
151
|
+
html += " <img src='/tr8n/images/tr8n_logo.jpg' style='width:280px; vertical-align:middle;'>";
|
152
|
+
html += " <img src='/tr8n/images/loading3.gif' style='width:200px; height:20px; vertical-align:middle;'>";
|
153
|
+
html += "</div>"
|
154
|
+
}
|
155
|
+
this.container.innerHTML = html;
|
156
|
+
this.container.style.display = "block";
|
157
|
+
|
158
|
+
var stem = {v:"top", h:"left",width:10, height:12};
|
159
|
+
var stem_type = "top_left";
|
160
|
+
var target_dimensions = {width:translatable_node.offsetWidth, height:translatable_node.offsetHeight};
|
161
|
+
var target_position = Tr8n.Utils.cumulativeOffset(translatable_node);
|
162
|
+
var container_position = {
|
163
|
+
left: (target_position[0] + 'px'),
|
164
|
+
top : (target_position[1] + target_dimensions.height + stem.height + 'px')
|
165
|
+
}
|
166
|
+
|
167
|
+
var stem_offset = target_dimensions.width/2;
|
168
|
+
var scroll_buffer = 100;
|
169
|
+
var scroll_height = target_position[1] - scroll_buffer;
|
170
|
+
|
171
|
+
if (window.innerWidth < target_position[0] + target_dimensions.width + window.innerWidth/2) {
|
172
|
+
container_position.left = target_position[0] + target_dimensions.width - this.container.offsetWidth + "px";
|
173
|
+
stem_offset = target_dimensions.width/2;
|
174
|
+
stem.h = "right";
|
175
|
+
}
|
176
|
+
|
177
|
+
window.scrollTo(target_position[0], scroll_height);
|
178
|
+
this.container.style.left = container_position.left;
|
179
|
+
this.container.style.top = container_position.top;
|
180
|
+
this.translation_key_id = translatable_node.getAttribute('translation_key_id');
|
181
|
+
|
182
|
+
window.setTimeout(function() {
|
183
|
+
Tr8n.Utils.update('tr8n_translator', '/tr8n/language/translator', {
|
184
|
+
evalScripts: true,
|
185
|
+
parameters: {
|
186
|
+
translation_key_id: self.translation_key_id,
|
187
|
+
stem_type: stem.v + "_" + stem.h,
|
188
|
+
stem_offset: stem_offset
|
189
|
+
}
|
190
|
+
});
|
191
|
+
}, 500);
|
192
|
+
},
|
193
|
+
|
194
|
+
reportTranslation: function(key, translation_id) {
|
195
|
+
var msg = "Reporting this translation will remove it from this list and the translator will be put on a watch list. \n\nAre you sure you want to report this translation?";
|
196
|
+
if (!confirm(msg)) return;
|
197
|
+
this.voteOnTranslation(key, translation_id, -1000);
|
198
|
+
},
|
199
|
+
|
200
|
+
voteOnTranslation: function(key, translation_id, vote) {
|
201
|
+
Tr8n.Effects.hide('tr8n_votes_for_' + translation_id);
|
202
|
+
Tr8n.Effects.show('tr8n_spinner_for_' + translation_id);
|
203
|
+
|
204
|
+
// the long version updates and reorders translations - used in translator and phrase list
|
205
|
+
// the short version only updates the total results - used everywhere else
|
206
|
+
if (Tr8n.element('tr8n_translator_votes_for_' + key)) {
|
207
|
+
Tr8n.Utils.update('tr8n_translator_votes_for_' + key, '/tr8n/translations/vote', {
|
208
|
+
parameters: {
|
209
|
+
translation_id: translation_id,
|
210
|
+
vote: vote
|
211
|
+
},
|
212
|
+
method: 'post'
|
213
|
+
});
|
214
|
+
} else {
|
215
|
+
Tr8n.Utils.update('tr8n_votes_for_' + translation_id, '/tr8n/translations/vote', {
|
216
|
+
parameters: {
|
217
|
+
translation_id: translation_id,
|
218
|
+
vote: vote,
|
219
|
+
short_version: true
|
220
|
+
},
|
221
|
+
method: 'post',
|
222
|
+
onComplete: function() {
|
223
|
+
Tr8n.Effects.hide('tr8n_spinner_for_' + translation_id);
|
224
|
+
Tr8n.Effects.show('tr8n_votes_for_' + translation_id);
|
225
|
+
}
|
226
|
+
});
|
227
|
+
}
|
228
|
+
},
|
229
|
+
|
230
|
+
insertDecorationToken: function (token, txtarea_id) {
|
231
|
+
txtarea_id = txtarea_id || 'tr8n_translator_translation_label';
|
232
|
+
Tr8n.Utils.wrapText(txtarea_id, "[" + token + ": ", "]");
|
233
|
+
},
|
234
|
+
|
235
|
+
insertToken: function (token, txtarea_id) {
|
236
|
+
txtarea_id = txtarea_id || 'tr8n_translator_translation_label';
|
237
|
+
Tr8n.Utils.insertAtCaret(txtarea_id, "{" + token + "}");
|
238
|
+
},
|
239
|
+
|
240
|
+
switchTranslatorMode: function(translation_key_id, mode, source_url) {
|
241
|
+
Tr8n.Utils.update('tr8n_translator_container', '/tr8n/language/translator', {
|
242
|
+
parameters: {translation_key_id: translation_key_id, mode: mode, source_url: source_url},
|
243
|
+
evalScripts: true
|
244
|
+
});
|
245
|
+
},
|
246
|
+
|
247
|
+
submitTranslation: function() {
|
248
|
+
Tr8n.Effects.hide('tr8n_translator_translation_container');
|
249
|
+
Tr8n.Effects.hide('tr8n_translator_buttons_container');
|
250
|
+
Tr8n.Effects.show('tr8n_translator_spinner');
|
251
|
+
Tr8n.Effects.submit('tr8n_translator_form');
|
252
|
+
},
|
253
|
+
|
254
|
+
submitViewingUserDependency: function() {
|
255
|
+
Tr8n.element('tr8n_translator_translation_has_dependencies').value = "true";
|
256
|
+
this.submitTranslation();
|
257
|
+
},
|
258
|
+
|
259
|
+
submitDependencies: function() {
|
260
|
+
Tr8n.Effects.hide('tr8n_translator_buttons_container');
|
261
|
+
Tr8n.Effects.hide('tr8n_translator_dependencies_container');
|
262
|
+
Tr8n.Effects.show('tr8n_translator_spinner');
|
263
|
+
Tr8n.element('tr8n_translator_form').action = '/tr8n/translations/permutate';
|
264
|
+
Tr8n.Effects.submit('tr8n_translator_form');
|
265
|
+
},
|
266
|
+
|
267
|
+
translate: function(label, callback, opts) {
|
268
|
+
opts = opts || {}
|
269
|
+
Tr8n.Utils.ajax('/tr8n/language/translate', {
|
270
|
+
method: 'post',
|
271
|
+
parameters: {
|
272
|
+
label: label,
|
273
|
+
description: opts.description,
|
274
|
+
tokens: opts.tokens,
|
275
|
+
options: opts.options,
|
276
|
+
language: opts.language
|
277
|
+
},
|
278
|
+
onSuccess: function(r) {
|
279
|
+
if(callback) callback(r.responseText);
|
280
|
+
}
|
281
|
+
});
|
282
|
+
},
|
283
|
+
|
284
|
+
translateBatch: function(phrases, callback) {
|
285
|
+
Tr8n.Utils.ajax('/tr8n/language/translate', {
|
286
|
+
method: 'post',
|
287
|
+
parameters: {phrases: phrases},
|
288
|
+
onSuccess: function(r) {
|
289
|
+
if (callback) callback(r.responseText);
|
290
|
+
}
|
291
|
+
});
|
292
|
+
},
|
293
|
+
|
294
|
+
suggestTranslation: function(translation_key_id, original, tokens, from_lang, to_lang) {
|
295
|
+
google.language.translate(original, from_lang, to_lang, function(result) {
|
296
|
+
if (!result.error) {
|
297
|
+
var suggestion = result.translation;
|
298
|
+
tokens = tokens.split(",");
|
299
|
+
for (var i=0; i<tokens.length; i++) {
|
300
|
+
suggestion = Tr8n.Utils.replaceAll(suggestion, "(" + i + ")", tokens[i]);
|
301
|
+
}
|
302
|
+
Tr8n.element("tr8n_translation_suggestion_" + translation_key_id).innerHTML = suggestion;
|
303
|
+
Tr8n.element("tr8n_google_suggestion_container_" + translation_key_id).style.display = "block";
|
304
|
+
var suggestion_section = Tr8n.element('tr8n_google_suggestion_section');
|
305
|
+
if (suggestion_section) suggestion_section.style.display = "block";
|
306
|
+
}
|
307
|
+
});
|
308
|
+
}
|
309
|
+
|
310
|
+
}
|
311
|
+
|
312
|
+
/****************************************************************************
|
313
|
+
**** Tr8n Language Case Manager
|
314
|
+
****************************************************************************/
|
315
|
+
|
316
|
+
Tr8n.LanguageCaseManager = function(options) {
|
317
|
+
var self = this;
|
318
|
+
this.options = options;
|
319
|
+
this.case_key = null;
|
320
|
+
|
321
|
+
this.container = document.createElement('div');
|
322
|
+
this.container.className = 'tr8n_language_case_manager';
|
323
|
+
this.container.id = 'tr8n_language_case_manager';
|
324
|
+
this.container.style.display = "none";
|
325
|
+
|
326
|
+
document.body.appendChild(this.container)
|
327
|
+
|
328
|
+
var event_type = Tr8n.Utils.isOpera() ? 'click' : 'contextmenu';
|
329
|
+
|
330
|
+
Tr8n.Utils.addEvent(document, event_type, function(e) {
|
331
|
+
if (Tr8n.Utils.isOpera() && !e.ctrlKey) return;
|
332
|
+
|
333
|
+
var case_node = Tr8n.Utils.findElement(e, ".tr8n_language_case");
|
334
|
+
var link_node = Tr8n.Utils.findElement(e, "a");
|
335
|
+
|
336
|
+
if (case_node == null) return;
|
337
|
+
|
338
|
+
if (link_node) {
|
339
|
+
var temp_href = link_node.href;
|
340
|
+
link_node.href='javascript:void(0);';
|
341
|
+
setTimeout(function() {link_node.href = temp_href;}, 500);
|
342
|
+
}
|
343
|
+
|
344
|
+
if (e.stop) e.stop();
|
345
|
+
if (e.preventDefault) e.preventDefault();
|
346
|
+
if (e.stopPropagation) e.stopPropagation();
|
347
|
+
|
348
|
+
self.show(case_node);
|
349
|
+
});
|
350
|
+
}
|
351
|
+
|
352
|
+
Tr8n.LanguageCaseManager.prototype = {
|
353
|
+
hide: function() {
|
354
|
+
this.container.style.display = "none";
|
355
|
+
Tr8n.Utils.showFlash();
|
356
|
+
},
|
357
|
+
|
358
|
+
show: function(case_node) {
|
359
|
+
var self = this;
|
360
|
+
if (tr8nLanguageSelector) tr8nLanguageSelector.hide();
|
361
|
+
if (tr8nLightbox) tr8nLightbox.hide();
|
362
|
+
if (tr8nTranslator) tr8nTranslator.hide();
|
363
|
+
Tr8n.Utils.hideFlash();
|
364
|
+
|
365
|
+
var html = "";
|
366
|
+
var splash_screen = Tr8n.element('tr8n_splash_screen');
|
367
|
+
|
368
|
+
if (splash_screen) {
|
369
|
+
html += splash_screen.innerHTML;
|
370
|
+
} else {
|
371
|
+
html += "<div style='font-size:18px;text-align:center; margin:5px; padding:10px; background-color:black;'>";
|
372
|
+
html += " <img src='/tr8n/images/tr8n_logo.jpg' style='width:280px; vertical-align:middle;'>";
|
373
|
+
html += " <img src='/tr8n/images/loading3.gif' style='width:200px; height:20px; vertical-align:middle;'>";
|
374
|
+
html += "</div>"
|
375
|
+
}
|
376
|
+
this.container.innerHTML = html;
|
377
|
+
this.container.style.display = "block";
|
378
|
+
|
379
|
+
var stem = {v:"top", h:"left",width:10, height:12};
|
380
|
+
var stem_type = "top_left";
|
381
|
+
var target_dimensions = {width:case_node.offsetWidth, height:case_node.offsetHeight};
|
382
|
+
var target_position = Tr8n.Utils.cumulativeOffset(case_node);
|
383
|
+
var container_position = {
|
384
|
+
left: (target_position[0] + 'px'),
|
385
|
+
top : (target_position[1] + target_dimensions.height + stem.height + 'px')
|
386
|
+
}
|
387
|
+
|
388
|
+
var stem_offset = target_dimensions.width/2;
|
389
|
+
var scroll_buffer = 100;
|
390
|
+
var scroll_height = target_position[1] - scroll_buffer;
|
391
|
+
|
392
|
+
if (window.innerWidth < target_position[0] + target_dimensions.width + window.innerWidth/2) {
|
393
|
+
container_position.left = target_position[0] + target_dimensions.width - this.container.offsetWidth + "px";
|
394
|
+
stem_offset = target_dimensions.width/2;
|
395
|
+
stem.h = "right";
|
396
|
+
}
|
397
|
+
|
398
|
+
window.scrollTo(target_position[0], scroll_height);
|
399
|
+
this.container.style.left = container_position.left;
|
400
|
+
this.container.style.top = container_position.top;
|
401
|
+
this.case_id = case_node.getAttribute('case_id');
|
402
|
+
this.rule_id = case_node.getAttribute('rule_id');
|
403
|
+
this.case_key = case_node.getAttribute('case_key');
|
404
|
+
|
405
|
+
window.setTimeout(function() {
|
406
|
+
Tr8n.Utils.update('tr8n_language_case_manager', '/tr8n/language_cases/manager', {
|
407
|
+
evalScripts: true,
|
408
|
+
parameters: {
|
409
|
+
case_id: self.case_id,
|
410
|
+
rule_id: self.rule_id,
|
411
|
+
case_key: self.case_key,
|
412
|
+
stem_type: stem.v + "_" + stem.h,
|
413
|
+
stem_offset: stem_offset
|
414
|
+
}
|
415
|
+
});
|
416
|
+
}, 500);
|
417
|
+
},
|
418
|
+
|
419
|
+
switchToCaseMapMode: function() {
|
420
|
+
Tr8n.Effects.hide('tr8n_language_case_container');
|
421
|
+
Tr8n.Effects.show('tr8n_language_case_exception_container');
|
422
|
+
},
|
423
|
+
|
424
|
+
switchCaseMapMode: function(mode) {
|
425
|
+
var self = this;
|
426
|
+
Tr8n.Utils.update('tr8n_language_cases_form', '/tr8n/language_cases/switch_manager_mode', {
|
427
|
+
evalScripts: true,
|
428
|
+
parameters: {mode: mode, case_key: self.case_key}
|
429
|
+
});
|
430
|
+
},
|
431
|
+
|
432
|
+
reportCaseMap: function(map_id) {
|
433
|
+
var msg = "Reporting these values will remove them from the system and the translator will be put on a watch list. \n\nAre you sure you want to report these values?";
|
434
|
+
if (!confirm(msg)) return;
|
435
|
+
|
436
|
+
Tr8n.element("tr8n_language_case_form").action = "/tr8n/language_cases/report_value_map";
|
437
|
+
Tr8n.Effects.hide('tr8n_language_case_exception_container');
|
438
|
+
Tr8n.Effects.show('tr8n_language_case_report_spinner');
|
439
|
+
Tr8n.Effects.submit('tr8n_language_case_form');
|
440
|
+
},
|
441
|
+
|
442
|
+
submitCaseMap: function() {
|
443
|
+
Tr8n.Effects.hide('tr8n_language_case_exception_container');
|
444
|
+
Tr8n.Effects.show('tr8n_language_case_submit_spinner');
|
445
|
+
Tr8n.Effects.submit('tr8n_language_case_form');
|
446
|
+
}
|
447
|
+
}
|
448
|
+
|
449
|
+
|
450
|
+
/****************************************************************************
|
451
|
+
**** Tr8n Language Selector
|
452
|
+
****************************************************************************/
|
453
|
+
|
454
|
+
Tr8n.LanguageSelector = function(options) {
|
455
|
+
this.options = options || {};
|
456
|
+
this.keyboardMode = false;
|
457
|
+
this.loaded = false;
|
458
|
+
|
459
|
+
this.container = document.createElement('div');
|
460
|
+
this.container.className = 'tr8n_language_selector';
|
461
|
+
this.container.id = 'tr8n_language_selector';
|
462
|
+
this.container.style.display = "none";
|
463
|
+
|
464
|
+
document.body.appendChild(this.container);
|
465
|
+
}
|
466
|
+
|
467
|
+
Tr8n.LanguageSelector.prototype = {
|
468
|
+
|
469
|
+
toggle: function() {
|
470
|
+
if (this.container.style.display == "none") {
|
471
|
+
this.show();
|
472
|
+
} else {
|
473
|
+
this.hide();
|
474
|
+
}
|
475
|
+
},
|
476
|
+
|
477
|
+
hide: function() {
|
478
|
+
this.container.style.display = "none";
|
479
|
+
Tr8n.Utils.showFlash();
|
480
|
+
},
|
481
|
+
|
482
|
+
show: function() {
|
483
|
+
var self = this;
|
484
|
+
if (tr8nTranslator) tr8nTranslator.hide();
|
485
|
+
if (tr8nLightbox) tr8nLightbox.hide();
|
486
|
+
if (tr8nLanguageCaseManager) tr8nLanguageCaseManager.hide();
|
487
|
+
Tr8n.Utils.hideFlash();
|
488
|
+
|
489
|
+
var splash_screen = Tr8n.element('tr8n_splash_screen');
|
490
|
+
|
491
|
+
if (!this.loaded) {
|
492
|
+
var html = "";
|
493
|
+
if (splash_screen) {
|
494
|
+
html += splash_screen.innerHTML;
|
495
|
+
} else {
|
496
|
+
html += "<div style='font-size:18px;text-align:center; margin:5px; padding:10px; background-color:black;'>";
|
497
|
+
html += " <img src='/tr8n/images/tr8n_logo.jpg' style='width:280px; vertical-align:middle;'>";
|
498
|
+
html += " <img src='/tr8n/images/loading3.gif' style='width:200px; height:20px; vertical-align:middle;'>";
|
499
|
+
html += "</div>";
|
500
|
+
}
|
501
|
+
this.container.innerHTML = html;
|
502
|
+
}
|
503
|
+
this.container.style.display = "block";
|
504
|
+
|
505
|
+
var trigger = Tr8n.element('tr8n_language_selector_trigger');
|
506
|
+
var trigger_position = Tr8n.Utils.cumulativeOffset(trigger);
|
507
|
+
var container_position = {
|
508
|
+
left: trigger_position[0] + trigger.offsetWidth - this.container.offsetWidth + 'px',
|
509
|
+
top: trigger_position[1] + trigger.offsetHeight + 4 + 'px'
|
510
|
+
}
|
511
|
+
|
512
|
+
// if (trigger_position[0] < window.innerWidth/2 ) {
|
513
|
+
// this.container.offsetLeft = trigger_position[0] + 'px';
|
514
|
+
// }
|
515
|
+
|
516
|
+
this.container.style.left = container_position.left;
|
517
|
+
this.container.style.top = container_position.top;
|
518
|
+
|
519
|
+
if (!this.loaded) {
|
520
|
+
window.setTimeout(function() {
|
521
|
+
Tr8n.Utils.update('tr8n_language_selector', '/tr8n/language/select', {
|
522
|
+
evalScripts: true
|
523
|
+
})
|
524
|
+
}, 100);
|
525
|
+
}
|
526
|
+
|
527
|
+
this.loaded = true;
|
528
|
+
},
|
529
|
+
|
530
|
+
removeLanguage: function(language_id) {
|
531
|
+
Tr8n.Utils.update('tr8n_language_lists', '/tr8n/language/lists', {
|
532
|
+
parameters: {language_action: "remove", language_id: language_id},
|
533
|
+
method: 'post'
|
534
|
+
});
|
535
|
+
},
|
536
|
+
|
537
|
+
enableInlineTranslations: function() {
|
538
|
+
window.location = "/tr8n/language/switch?language_action=enable_inline_mode&source_url=" + location;
|
539
|
+
},
|
540
|
+
|
541
|
+
disableInlineTranslations: function() {
|
542
|
+
window.location = "/tr8n/language/switch?language_action=disable_inline_mode&source_url=" + location;
|
543
|
+
},
|
544
|
+
|
545
|
+
showDashboard: function() {
|
546
|
+
window.location = "/tr8n/dashboard";
|
547
|
+
},
|
548
|
+
|
549
|
+
manageLanguage: function() {
|
550
|
+
window.location = "/tr8n/language";
|
551
|
+
},
|
552
|
+
|
553
|
+
toggleInlineTranslations: function() {
|
554
|
+
window.location = "/tr8n/language/switch?language_action=toggle_inline_mode&source_url=" + location;
|
555
|
+
}
|
556
|
+
}
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
/****************************************************************************
|
561
|
+
**** Tr8n Lightbox
|
562
|
+
****************************************************************************/
|
563
|
+
|
564
|
+
Tr8n.Lightbox = function() {
|
565
|
+
this.container = document.createElement('div');
|
566
|
+
this.container.className = 'tr8n_lightbox';
|
567
|
+
this.container.id = 'tr8n_lightbox';
|
568
|
+
this.container.style.display = "none";
|
569
|
+
|
570
|
+
this.overlay = document.createElement('div');
|
571
|
+
this.overlay.className = 'tr8n_lightbox_overlay';
|
572
|
+
this.overlay.id = 'tr8n_lightbox_overlay';
|
573
|
+
this.overlay.style.display = "none";
|
574
|
+
|
575
|
+
document.body.appendChild(this.container);
|
576
|
+
document.body.appendChild(this.overlay);
|
577
|
+
}
|
578
|
+
|
579
|
+
|
580
|
+
Tr8n.Lightbox.prototype = {
|
581
|
+
|
582
|
+
hide: function() {
|
583
|
+
this.container.style.display = "none";
|
584
|
+
this.overlay.style.display = "none";
|
585
|
+
Tr8n.Utils.showFlash();
|
586
|
+
},
|
587
|
+
|
588
|
+
show: function(url, opts) {
|
589
|
+
var self = this;
|
590
|
+
if(tr8nTranslator) tr8nTranslator.hide();
|
591
|
+
if(tr8nLanguageSelector) tr8nLanguageSelector.hide();
|
592
|
+
if(tr8nLanguageCaseManager) tr8nLanguageCaseManager.hide();
|
593
|
+
Tr8n.Utils.hideFlash();
|
594
|
+
|
595
|
+
this.container.innerHTML = "<div style='font-size:18px;text-align:left;padding:10px;'><img src='/tr8n/images/spinner.gif' style='vertical-align:middle'> Loading...</div>";
|
596
|
+
|
597
|
+
var overlay_height = window.innerHeight < screen.availHeight ? screen.availHeight : window.innerHeight;
|
598
|
+
var overlay_width = window.innerWidth < screen.availWidth ? screen.availWidth : window.innerWidth;
|
599
|
+
|
600
|
+
this.overlay.style.position = "fixed";
|
601
|
+
this.overlay.style.top = "0px";
|
602
|
+
this.overlay.style.left = "0px";
|
603
|
+
this.overlay.style.dispaly = "inline";
|
604
|
+
this.overlay.style.width = overlay_width + 'px';
|
605
|
+
this.overlay.style.height = overlay_height + 'px';
|
606
|
+
this.overlay.style.display = "block";
|
607
|
+
|
608
|
+
opts = opts || {}
|
609
|
+
opts["width"] = opts["width"] || (overlay_width / 2);
|
610
|
+
opts["height"] = opts["height"] || (overlay_height / 2);
|
611
|
+
opts["left"] = (overlay_width - opts["width"])/2;
|
612
|
+
opts["top"] = (overlay_height - opts["height"])/2 - 100;
|
613
|
+
|
614
|
+
this.container.style.position = "fixed";
|
615
|
+
this.container.style.top = opts["top"] + 'px';
|
616
|
+
this.container.style.left = opts["left"] + 'px';
|
617
|
+
this.container.style.width = opts["width"] + 'px';
|
618
|
+
this.container.style.height = opts["height"] + 'px';
|
619
|
+
this.container.style.display = "block";
|
620
|
+
|
621
|
+
Tr8n.Utils.update('tr8n_lightbox', url, {
|
622
|
+
evalScripts: true
|
623
|
+
});
|
624
|
+
}
|
625
|
+
}
|
626
|
+
|
627
|
+
/****************************************************************************
|
628
|
+
**** Tr8n Utils
|
629
|
+
****************************************************************************/
|
630
|
+
|
631
|
+
Tr8n.Utils = {
|
632
|
+
|
633
|
+
hideFlash: function() {
|
634
|
+
// alert("Hiding");
|
635
|
+
var embeds = document.getElementsByTagName('embed');
|
636
|
+
for(i = 0; i < embeds.length; i++) {
|
637
|
+
embeds[i].style.visibility = 'hidden';
|
638
|
+
}
|
639
|
+
},
|
640
|
+
|
641
|
+
showFlash: function() {
|
642
|
+
// alert("Showing");
|
643
|
+
var embeds = document.getElementsByTagName('embed');
|
644
|
+
for(i = 0; i < embeds.length; i++) {
|
645
|
+
embeds[i].style.visibility = 'visible';
|
646
|
+
}
|
647
|
+
},
|
648
|
+
|
649
|
+
isOpera: function() {
|
650
|
+
return /Opera/.test(navigator.userAgent);
|
651
|
+
},
|
652
|
+
|
653
|
+
addEvent: function(elm, evType, fn, useCapture) {
|
654
|
+
useCapture = useCapture || false;
|
655
|
+
if (elm.addEventListener) {
|
656
|
+
elm.addEventListener(evType, fn, useCapture);
|
657
|
+
return true;
|
658
|
+
} else if (elm.attachEvent) {
|
659
|
+
var r = elm.attachEvent('on' + evType, fn);
|
660
|
+
return r;
|
661
|
+
} else {
|
662
|
+
elm['on' + evType] = fn;
|
663
|
+
}
|
664
|
+
},
|
665
|
+
|
666
|
+
toQueryParams: function (obj) {
|
667
|
+
if (typeof obj == 'undefined' || obj == null) return "";
|
668
|
+
if (typeof obj == 'string') return obj;
|
669
|
+
|
670
|
+
var qs = [];
|
671
|
+
for(p in obj) {
|
672
|
+
qs.push(p + "=" + encodeURIComponent(obj[p]))
|
673
|
+
}
|
674
|
+
return qs.join("&")
|
675
|
+
},
|
676
|
+
|
677
|
+
serializeForm: function(form) {
|
678
|
+
var els = Tr8n.element(form).elements;
|
679
|
+
var form_obj = {}
|
680
|
+
for(i=0; i < els.length; i++) {
|
681
|
+
if (els[i].type == 'checkbox' && !els[i].checked) continue;
|
682
|
+
form_obj[els[i].name] = els[i].value;
|
683
|
+
}
|
684
|
+
return form_obj;
|
685
|
+
},
|
686
|
+
|
687
|
+
replaceAll: function(label, key, value) {
|
688
|
+
while (label.indexOf(key) != -1) {
|
689
|
+
label = label.replace(key, value);
|
690
|
+
}
|
691
|
+
return label;
|
692
|
+
},
|
693
|
+
|
694
|
+
getRequest: function() {
|
695
|
+
var factories = [
|
696
|
+
function() { return new ActiveXObject("Msxml2.XMLHTTP"); },
|
697
|
+
function() { return new XMLHttpRequest(); },
|
698
|
+
function() { return new ActiveXObject("Microsoft.XMLHTTP"); }
|
699
|
+
];
|
700
|
+
for(var i = 0; i < factories.length; i++) {
|
701
|
+
try {
|
702
|
+
var request = factories[i]();
|
703
|
+
if (request != null) return request;
|
704
|
+
} catch(e) {continue;}
|
705
|
+
}
|
706
|
+
},
|
707
|
+
|
708
|
+
ajax: function(url, options) {
|
709
|
+
options = options || {};
|
710
|
+
options.parameters = Tr8n.Utils.toQueryParams(options.parameters);
|
711
|
+
options.method = options.method || 'get';
|
712
|
+
|
713
|
+
var self=this;
|
714
|
+
if (options.method == 'get' && options.parameters != '') {
|
715
|
+
url = url + (url.indexOf('?') == -1 ? '?' : '&') + options.parameters;
|
716
|
+
}
|
717
|
+
|
718
|
+
var request = this.getRequest();
|
719
|
+
|
720
|
+
request.onreadystatechange = function() {
|
721
|
+
if(request.readyState == 4) {
|
722
|
+
if (request.status == 200) {
|
723
|
+
if(options.onSuccess) options.onSuccess(request);
|
724
|
+
if(options.onComplete) options.onComplete(request);
|
725
|
+
if(options.evalScripts) self.evalScripts(request.responseText);
|
726
|
+
} else {
|
727
|
+
if(options.onFailure) options.onFailure(request)
|
728
|
+
if(options.onComplete) options.onComplete(request)
|
729
|
+
}
|
730
|
+
}
|
731
|
+
}
|
732
|
+
|
733
|
+
request.open(options.method, url, true);
|
734
|
+
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
735
|
+
request.setRequestHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*');
|
736
|
+
request.send(options.parameters);
|
737
|
+
},
|
738
|
+
|
739
|
+
update: function(element_id, url, options) {
|
740
|
+
options.onSuccess = function(response) {
|
741
|
+
Tr8n.element(element_id).innerHTML = response.responseText;
|
742
|
+
};
|
743
|
+
Tr8n.Utils.ajax(url, options);
|
744
|
+
},
|
745
|
+
|
746
|
+
evalScripts: function(html){
|
747
|
+
var script_re = '<script[^>]*>([\\S\\s]*?)<\/script>';
|
748
|
+
var matchAll = new RegExp(script_re, 'img');
|
749
|
+
var matchOne = new RegExp(script_re, 'im');
|
750
|
+
var matches = html.match(matchAll) || [];
|
751
|
+
for(var i=0,l=matches.length;i<l;i++){
|
752
|
+
var script = (matches[i].match(matchOne) || ['', ''])[1];
|
753
|
+
// console.info(script)
|
754
|
+
// alert(script);
|
755
|
+
eval(script);
|
756
|
+
}
|
757
|
+
},
|
758
|
+
|
759
|
+
hasClassName:function(el, cls){
|
760
|
+
var exp = new RegExp("(^|\\s)"+cls+"($|\\s)");
|
761
|
+
return (el.className && exp.test(el.className))?true:false;
|
762
|
+
},
|
763
|
+
|
764
|
+
findElement: function (e,selector,el) {
|
765
|
+
var event = e || window.event;
|
766
|
+
var target = el || event.target || event.srcElement;
|
767
|
+
if(target == document.body) return null;
|
768
|
+
var condition = (selector.match(/^\./)) ? this.hasClassName(target,selector.replace(/^\./,'')) : (target.tagName.toLowerCase() == selector.toLowerCase());
|
769
|
+
if(condition) {
|
770
|
+
return target;
|
771
|
+
} else {
|
772
|
+
return this.findElement(e,selector,target.parentNode);
|
773
|
+
}
|
774
|
+
},
|
775
|
+
|
776
|
+
cumulativeOffset: function(element) {
|
777
|
+
var valueT = 0, valueL = 0;
|
778
|
+
do {
|
779
|
+
valueT += element.offsetTop || 0;
|
780
|
+
valueL += element.offsetLeft || 0;
|
781
|
+
element = element.offsetParent;
|
782
|
+
} while (element);
|
783
|
+
return [valueL, valueT];
|
784
|
+
},
|
785
|
+
|
786
|
+
wrapText: function (obj_id, beginTag, endTag) {
|
787
|
+
var obj = document.getElementById(obj_id);
|
788
|
+
|
789
|
+
if (typeof obj.selectionStart == 'number') {
|
790
|
+
// Mozilla, Opera, and other browsers
|
791
|
+
var start = obj.selectionStart;
|
792
|
+
var end = obj.selectionEnd;
|
793
|
+
obj.value = obj.value.substring(0, start) + beginTag + obj.value.substring(start, end) + endTag + obj.value.substring(end, obj.value.length);
|
794
|
+
|
795
|
+
} else if(document.selection) {
|
796
|
+
// Internet Explorer
|
797
|
+
obj.focus();
|
798
|
+
var range = document.selection.createRange();
|
799
|
+
if(range.parentElement() != obj)
|
800
|
+
return false;
|
801
|
+
|
802
|
+
if(typeof range.text == 'string')
|
803
|
+
document.selection.createRange().text = beginTag + range.text + endTag;
|
804
|
+
} else
|
805
|
+
obj.value += beginTag + " " + endTag;
|
806
|
+
|
807
|
+
return true;
|
808
|
+
},
|
809
|
+
|
810
|
+
insertAtCaret: function (areaId, text) {
|
811
|
+
var txtarea = document.getElementById(areaId);
|
812
|
+
var scrollPos = txtarea.scrollTop;
|
813
|
+
var strPos = 0;
|
814
|
+
var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ) );
|
815
|
+
|
816
|
+
if (br == "ie") {
|
817
|
+
txtarea.focus();
|
818
|
+
var range = document.selection.createRange();
|
819
|
+
range.moveStart ('character', -txtarea.value.length);
|
820
|
+
strPos = range.text.length;
|
821
|
+
} else if (br == "ff")
|
822
|
+
strPos = txtarea.selectionStart;
|
823
|
+
|
824
|
+
var front = (txtarea.value).substring(0, strPos);
|
825
|
+
var back = (txtarea.value).substring(strPos, txtarea.value.length);
|
826
|
+
txtarea.value=front+text+back;
|
827
|
+
|
828
|
+
strPos = strPos + text.length;
|
829
|
+
if (br == "ie") {
|
830
|
+
txtarea.focus();
|
831
|
+
var range = document.selection.createRange();
|
832
|
+
range.moveStart ('character', -txtarea.value.length);
|
833
|
+
range.moveStart ('character', strPos);
|
834
|
+
range.moveEnd ('character', 0); range.select();
|
835
|
+
} else if (br == "ff") {
|
836
|
+
txtarea.selectionStart = strPos;
|
837
|
+
txtarea.selectionEnd = strPos;
|
838
|
+
txtarea.focus();
|
839
|
+
}
|
840
|
+
txtarea.scrollTop = scrollPos;
|
841
|
+
},
|
842
|
+
|
843
|
+
toggleKeyboards: function() {
|
844
|
+
if(!VKI_attach) return;
|
845
|
+
if (!this.keyboardMode) {
|
846
|
+
this.keyboardMode = true;
|
847
|
+
|
848
|
+
var elements = document.getElementsByTagName("input");
|
849
|
+
for(i=0; i<elements.length; i++) {
|
850
|
+
if (elements[i].type == "text") VKI_attach(elements[i]);
|
851
|
+
}
|
852
|
+
elements = document.getElementsByTagName("textarea");
|
853
|
+
for(i=0; i<elements.length; i++) {
|
854
|
+
VKI_attach(elements[i]);
|
855
|
+
}
|
856
|
+
} else {
|
857
|
+
window.location.reload();
|
858
|
+
}
|
859
|
+
},
|
860
|
+
|
861
|
+
displayShortcuts: function() {
|
862
|
+
if (tr8nLightbox)
|
863
|
+
tr8nLightbox.show('/tr8n/help/lb_shortcuts', {width:400, height:480});
|
864
|
+
},
|
865
|
+
|
866
|
+
displayCredits: function() {
|
867
|
+
if (tr8nLightbox)
|
868
|
+
tr8nLightbox.show('/tr8n/help/lb_credits', {width:420, height:250});
|
869
|
+
}
|
870
|
+
|
871
|
+
}
|
872
|
+
|
873
|
+
/****************************************************************************
|
874
|
+
**** Tr8n Initialization
|
875
|
+
****************************************************************************/
|
876
|
+
|
877
|
+
var tr8nTranslator = null;
|
878
|
+
var tr8nLanguageSelector = null;
|
879
|
+
var tr8nLightbox = null;
|
880
|
+
var tr8nLanguageCaseManager = null;
|
881
|
+
|
882
|
+
function initializeTr8n() {
|
883
|
+
var setup = function() {
|
884
|
+
tr8nTranslator = new Tr8n.Translator();
|
885
|
+
tr8nLanguageSelector = new Tr8n.LanguageSelector();
|
886
|
+
tr8nLightbox = new Tr8n.Lightbox();
|
887
|
+
tr8nLanguageCaseManager = new Tr8n.LanguageCaseManager();
|
888
|
+
|
889
|
+
Tr8n.Utils.addEvent(document, "keyup", function(event) {
|
890
|
+
if (event.keyCode == 27) { // Capture Esc key
|
891
|
+
tr8nTranslator.hide();
|
892
|
+
tr8nLanguageSelector.hide();
|
893
|
+
tr8nLightbox.hide();
|
894
|
+
tr8nLanguageCaseManager.hide();
|
895
|
+
}
|
896
|
+
});
|
897
|
+
}
|
898
|
+
|
899
|
+
Tr8n.Utils.addEvent(window, 'load', setup);
|
900
|
+
}
|
901
|
+
|
902
|
+
function initializeTr8nGoogleSuggestions() {
|
903
|
+
google.load("language", "1");
|
904
|
+
}
|