Projet

Général

Profil

Paste
Télécharger (1,9 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / diff / js / diff.js @ a84ddea4

1 85ad3d82 Assos Assos
(function ($) {
2
3
Drupal.behaviors.diffRevisions = {
4
  attach: function (context, settings) {
5
    var $rows = $('table.diff-revisions tbody tr');
6
    function updateDiffRadios() {
7
      var newTd = false;
8
      var oldTd = false;
9
      if (!$rows.length) {
10
        return true;
11
      }
12
      $rows.removeClass('selected').each(function() {
13
        var $row = $(this);
14
        $row.removeClass('selected');
15
        var $inputs = $row.find('input[type="radio"]');
16
        var $oldRadio = $inputs.filter('[name="old"]').eq(0);
17
        var $newRadio = $inputs.filter('[name="new"]').eq(0);
18
        if (!$oldRadio.length || !$newRadio.length) {
19
          return true;
20
        }
21
        if ($oldRadio.attr('checked')) {
22
          oldTd = true;
23
          $row.addClass('selected');
24
          $oldRadio.css('visibility', 'visible');
25
          $newRadio.css('visibility', 'hidden');
26
        } else if ($newRadio.attr('checked')) {
27
          newTd = true;
28
          $row.addClass('selected');
29
          $oldRadio.css('visibility', 'hidden');
30
          $newRadio.css('visibility', 'visible');
31
        } else {
32
          if (Drupal.settings.diffRevisionRadios == 'linear') {
33
            if (newTd && oldTd) {
34
              $oldRadio.css('visibility', 'visible');
35
              $newRadio.css('visibility', 'hidden');
36
            } else if (newTd) {
37
              $newRadio.css('visibility', 'visible');
38
              $oldRadio.css('visibility', 'visible');
39
            } else {
40
              $newRadio.css('visibility', 'visible');
41
              $oldRadio.css('visibility', 'hidden');
42
            }
43
          } else {
44
            $newRadio.css('visibility', 'visible');
45
            $oldRadio.css('visibility', 'visible');
46
          }
47
        }
48
      });
49
      return true;
50
    }
51
    if (Drupal.settings.diffRevisionRadios) {
52
      $rows.find('input[name="new"], input[name="old"]').click(updateDiffRadios);
53
      updateDiffRadios();
54
    }
55
  }
56
};
57
58
})(jQuery);