add language switcher drop-down to Marketplace (bug 740717)
This commit is contained in:
Родитель
e38475f88c
Коммит
527c5464c7
|
@ -53,3 +53,9 @@ $('html').ajaxSend(function(event, xhr, ajaxSettings) {
|
|||
}).ajaxSuccess(function(event, xhr, ajaxSettings) {
|
||||
$(window).trigger('resize'); // Redraw what needs to be redrawn.
|
||||
});
|
||||
|
||||
|
||||
// If any field changes, submit the form.
|
||||
$('form.go').change(function() {
|
||||
this.submit();
|
||||
});
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<form class="go" id="lang-form" method="get">
|
||||
<label for="language">{{ _('Other languages') }}:</label>
|
||||
<select id="language" name="lang" dir="ltr">
|
||||
{% for code, name in LANGUAGES|dictsort -%}
|
||||
<option value="{{ code }}"{% if code == LANG|lower %} selected{% endif %}>
|
||||
{{ name }}</option>
|
||||
{%- endfor %}
|
||||
</select>
|
||||
{% for key, value in request.GET.items() %}
|
||||
<input type="hidden" name="{{ key }}" value="{{ value }}">
|
||||
{% endfor %}
|
||||
<noscript><button type="submit">{{ _('Go') }}</button></noscript>
|
||||
</form>
|
|
@ -4,6 +4,8 @@ from django.conf import settings
|
|||
|
||||
import mock
|
||||
from nose.tools import eq_
|
||||
from pyquery import PyQuery as pq
|
||||
import waffle
|
||||
|
||||
import amo
|
||||
import amo.tests
|
||||
|
@ -42,3 +44,22 @@ class TestRobots(amo.tests.TestCase):
|
|||
def test_do_not_engage_robots(self):
|
||||
rs = self.client.get('/robots.txt')
|
||||
self.assertContains(rs, 'Disallow: /')
|
||||
|
||||
|
||||
class TestFooter(amo.tests.TestCase):
|
||||
|
||||
def test_language_selector(self):
|
||||
waffle.models.Switch.objects.create(name='unleash-consumer',
|
||||
active=True)
|
||||
r = self.client.get(reverse('home'))
|
||||
eq_(r.status_code, 200)
|
||||
eq_(pq(r.content)('#lang-form option[selected]').attr('value'),
|
||||
'en-us')
|
||||
|
||||
def test_language_selector_variables(self):
|
||||
waffle.models.Switch.objects.create(name='unleash-consumer',
|
||||
active=True)
|
||||
r = self.client.get(reverse('home'), {'x': 'xxx', 'y': 'yyy'})
|
||||
doc = pq(r.content)('#lang-form')
|
||||
eq_(doc('input[type=hidden][name=x]').attr('value'), 'xxx')
|
||||
eq_(doc('input[type=hidden][name=y]').attr('value'), 'yyy')
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
{% else %}
|
||||
<a class="button browserid" href="#">{{ _('Log in / Register') }}</a>
|
||||
{% endif %}
|
||||
{% include 'site/includes/languages.html' %}
|
||||
</footer>
|
||||
{% endblock %}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче