Projet

Général

Profil

0001-a11y-add-support-for-foldable-folding-cells-38192.patch

Frédéric Péters, 06 décembre 2019 09:28

Télécharger (2,16 ko)

Voir les différences:

Subject: [PATCH] a11y: add support for foldable/folding cells (#38192)

 combo/public/static/js/combo.public.js | 34 +++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 4 deletions(-)
combo/public/static/js/combo.public.js
213 213
    $(checkboxes[checkboxes.length-1]).parents('tr').next().find('td:nth-child(' + (column_index+1) + ')').addClass('clickable');
214 214
  }
215 215

  
216
  $('body').on('click', 'div.cell.foldable > div > h2:first-child, div.cell.foldable > div > picture', function() {
217
      $(this).parents('div.foldable').toggleClass('folded');
218
      return false;
219
  });
216
  /* foldable/folded support */
217
  function prepare_foldable(cell) {
218
    var $cell = $(cell);
219
    var $cell_title = $cell.find('> div > h2:first-child');
220
    if ($cell.is('.foldable')) {
221
      $cell_title.attr('tabindex', '0');
222
      if ($cell.is('.folded')) {
223
        $cell_title.attr('aria-expanded', 'false');
224
      } else {
225
        $cell_title.attr('aria-expanded', 'true');
226
      }
227
      $cell.find('> div > h2:first-child, > div > picture').on('keydown', function(ev) {
228
        if (ev.keyCode == 13) {  // enter
229
          $(this).trigger('click');
230
        }
231
      });
232
      $cell.find('> div > h2:first-child, > div > picture').on('click', function() {
233
        $cell.toggleClass('folded');
234
        if ($cell.is('.folded')) {
235
          $cell_title.attr('aria-expanded', 'false');
236
        } else {
237
          $cell_title.attr('aria-expanded', 'true');
238
        }
239
        return false;
240
      });
241
    }
242
  }
243

  
244
  $('div.cell.foldable').each(function(i, cell) { prepare_foldable(cell); });
245
  $(document).on('combo:cell-loaded', function(ev, cell) { prepare_foldable(cell); });
220 246

  
221 247
  /* add a scrolled class to body once the user scrolled the page a bit */
222 248
  $(window).on('scroll', function() {
223
-