summaryrefslogtreecommitdiff
path: root/sites/all/modules/l10n_update/js/l10n_update.admin.js
blob: a785f07801f402fc9bc6ee99aa7eb77bb2038bdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(function ($) {

/**
 * Show/hide the description details on Available translation updates page.
 */
Drupal.behaviors.hideUpdateInformation = {
  attach: function (context, settings) {
    var $table = $('#l10n-update-status-form').once('expand-updates');
    if ($table.length) {
      var $tbodies = $table.find('tbody');

      // Open/close the description details by toggling a tr class.
      $tbodies.find('.description').bind('click keydown', function (e) {
        if (e.keyCode && (e.keyCode !== 13 && e.keyCode !== 32)) {
          return;
        }
        e.preventDefault();
        var $tr = $(this).closest('tr');

        $tr.toggleClass('expanded');

        // Change screen reader text.
        $tr.find('.update-description-prefix').text(function () {
          if ($tr.hasClass('expanded')) {
            return Drupal.t('Hide description');
          }
          else {
            return Drupal.t('Show description');
          }
        });
      });
      $table.find('.requirements, .links').hide();
    }
  }
};

})(jQuery);