From 8cbd7ffef43ec8f36d0673298ec6474d17dfac0e Mon Sep 17 00:00:00 2001 From: Matt Claypotch Date: Thu, 9 Dec 2010 02:53:30 -0800 Subject: [PATCH] Bug 615414, added 'delete locale' functionality to l10n UI --- media/css/zamboni/zamboni.css | 15 +++++++++---- media/js/zamboni/l10n.js | 42 ++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/media/css/zamboni/zamboni.css b/media/css/zamboni/zamboni.css index 6e7ff77bb4..b33dd95e1f 100644 --- a/media/css/zamboni/zamboni.css +++ b/media/css/zamboni/zamboni.css @@ -3186,10 +3186,7 @@ input.ui-autocomplete-loading { #locale-popup section a { display: block; } -#locale-popup section a.remove { - display: inline-block; - float: right; -} + #locale-popup section > div, #locale-popup section > ul { border-top: 1px dotted #a4cfde; @@ -3200,6 +3197,16 @@ input.ui-autocomplete-loading { border-top: none; } +#existing_locales a.remove { + float: right; + display: block; + margin: 4px; +} + +#existing_locales a.remove:hover { + background-color: #2A4364; +} + .trans .cloned { color: #ccc; font-style: italic; diff --git a/media/js/zamboni/l10n.js b/media/js/zamboni/l10n.js index 28e7c278bb..f45e490da5 100644 --- a/media/js/zamboni/l10n.js +++ b/media/js/zamboni/l10n.js @@ -21,6 +21,22 @@ $(document).ready(function () { }); } + function showExistingLocales() { + discoverLocales(); + $el = $("#existing_locales").empty(); + $("#all_locales li").show(); + $.each(_.without(locales, dl), function() { + var locale_row = $(format("#all_locales a[href$={0}]",[this])).parent(); + if (locale_row.length) { + $el.append(format("
  • x{row}
  • ", + { msg: gettext('Remove this localization'), + row: locale_row.html() + })); + locale_row.hide(); + } + }); + } + function checkTranslation(e, t) { var $input = e.originalEvent ? $(this) : $(format("[lang={0}]", [e]), t), $trans = $input.closest(".trans"), @@ -59,18 +75,22 @@ $(document).ready(function () { pointTo: "#change-locale", width: 200, callback: function() { - discoverLocales(); - $el = $("#existing_locales").empty(); - $("#all_locales li").show(); - $.each(_.without(locales, dl), function() { - var locale_row = $(format("#all_locales a[href$={0}]",[this])).parent(); - if (locale_row.length) { - $el.append("
  • " + locale_row.html() + "
  • "); - locale_row.hide(); - } - }); + showExistingLocales(); - $("#locale-popup").delegate('a', 'click', function (e) { + $("#locale-popup").delegate('a.remove', 'click', function (e) { + e.preventDefault(); + e.stopPropagation(); + var toRemove = $(this).closest("li").find("a:not(.remove)").attr("href").substring(1); + $(format(".trans [lang={0}]", [toRemove])).each(function () { + var n = $(this).attr('name'); + $(this).attr('name', n + '_delete').attr('lang', toRemove + '_delete'); + }); + if (currentLocale == toRemove) { + updateLocale(dl); + } + showExistingLocales(); + }); + $("#locale-popup").delegate('a:not(.remove)', 'click', function (e) { e.preventDefault(); $tgt = $(this); var new_locale = $tgt.attr("href").substring(1);