Projet

Général

Profil

0001-misc-more-items-accessibility-40883-40884.patch

Lauréline Guérin, 26 mars 2020 15:07

Télécharger (4,41 ko)

Voir les différences:

Subject: [PATCH] misc: more items & accessibility (#40883, #40884)

 combo/apps/wcs/templates/combo/wcs/forms_of_category.html | 6 ++++--
 combo/public/static/js/combo.public.js                    | 5 +++++
 combo/public/templates/combo/link-list-cell.html          | 7 +++++--
 tests/test_cells.py                                       | 4 ++--
 4 files changed, 16 insertions(+), 6 deletions(-)
combo/apps/wcs/templates/combo/wcs/forms_of_category.html
25 25
  {% if form.description %}<div class="description">{{ form.description|safe }}</div>{% endif %}
26 26
  </li>
27 27
{% endfor %}
28
</ul>
28 29

  
29 30
{% if more_forms %}
30
<li class="more-items"><a>+</a></li>
31
<button aria-expanded="false" aria-controls="wcs-more-forms-of-category-{{ cell.get_reference }}" aria-label="{% trans 'More forms' %}" id="btn-wcs-more-forms-of-category-{{ cell.get_reference }}" class="more-items">+</button>
32
<ul style="display: none" class="additional-list" id="wcs-more-forms-of-category-{{ cell.get_reference }}" aria-labelledby="btn-wcs-more-forms-of-category-{{ cell.get_reference }}">
31 33
{% for form in more_forms %}
32
<li style="display: none" class="additional-form {% if form.authentication_required %}required-authentication{% endif %}
34
<li class="additional-list {% if form.authentication_required %}required-authentication{% endif %}
33 35
           {% for context in form.required_authentication_contexts %}required-{{context}}-authentication {% endfor %}
34 36
           {% for keyword in form.keywords %}keyword-{{keyword|slugify}} {% endfor %}
35 37
           {% if form.redirection %}is-redirection{% endif %}"
combo/public/static/js/combo.public.js
99 99
    $(this).parent().hide();
100 100
    $(this).parent().nextAll().show();
101 101
  });
102
  $(document).on('click', 'button.more-items', function() {
103
    $(this).attr('aria-expanded', 'true');
104
    $(this).hide();
105
    $('#' + $(this).attr('aria-controls')).show().focus();
106
  });
102 107

  
103 108
  var menu_page_ids = $.makeArray($('[data-menu-page-id]').map(function() { return $(this).data('menu-page-id'); }));
104 109
  if (menu_page_ids.length && $('body').data('check-badges') === true) {
combo/public/templates/combo/link-list-cell.html
1
{% load i18n %}
1 2
{% block cell-content %}
2 3
{% spaceless %}
3 4
{% if title %}<h2>{{ title }}</h2>{% endif %}
......
7 8
  {% for link in links %}
8 9
    <li><a href="{{ link.url }}">{{ link.title }}</a></li>
9 10
  {% endfor %}
11
  </ul>
10 12

  
11 13
  {% if more_links %}
12
    <li class="more-items"><a>+</a></li>
14
  <button aria-expanded="false" aria-controls="more-links-{{ cell.get_reference }}" aria-label="{% trans 'More links' %}" id="btn-more-links-{{ cell.get_reference }}" class="more-items">+</button>
15
  <ul style="display: none" class="additional-list" id="more-links-{{ cell.get_reference }}" aria-labelledby="btn-more-links-{{ cell.get_reference }}">
13 16
  {% for link in more_links %}
14
    <li style="display: none" class="additional-links"><a href="{{ link.url }}">{{ link.title }}</a></li>
17
    <li class="additional-list"><a href="{{ link.url }}">{{ link.title }}</a></li>
15 18
  {% endfor %}
16 19
  {% endif %}
17 20
  </ul>
tests/test_cells.py
243 243
        order=1,
244 244
    )
245 245
    ctx = {'page_cells': [item, item2]}
246
    assert '<li class="more-items"><a>+</a></li>' not in cell.render(ctx)
246
    assert 'class="more-items">+</button>' not in cell.render(ctx)
247 247
    cell.limit = 1
248
    assert '<li class="more-items"><a>+</a></li>' in cell.render(ctx)
248
    assert 'class="more-items">+</button>' in cell.render(ctx)
249 249

  
250 250

  
251 251
def test_link_list_cell_validity():
252
-