1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- (function ($) {
- "use strict";
-
- Drupal.behaviors.diffRevisions = {
- attach: function (context, settings) {
- var $rows = $('table.diff-revisions tbody tr');
- function updateDiffRadios() {
- var newTd = false;
- var oldTd = false;
- if (!$rows.length) {
- return true;
- }
- $rows.removeClass('selected').each(function() {
- var $row = $(this);
- $row.removeClass('selected');
- var $inputs = $row.find('input[type="radio"]');
- var $oldRadio = $inputs.filter('[name="old"]').eq(0);
- var $newRadio = $inputs.filter('[name="new"]').eq(0);
- if (!$oldRadio.length || !$newRadio.length) {
- return true;
- }
- if ($oldRadio.attr('checked')) {
- oldTd = true;
- $row.addClass('selected');
- $oldRadio.css('visibility', 'visible');
- $newRadio.css('visibility', 'hidden');
- }
- else if ($newRadio.attr('checked')) {
- newTd = true;
- $row.addClass('selected');
- $oldRadio.css('visibility', 'hidden');
- $newRadio.css('visibility', 'visible');
- }
- else {
- if (Drupal.settings.diffRevisionRadios == 'linear') {
- if (newTd && oldTd) {
- $oldRadio.css('visibility', 'visible');
- $newRadio.css('visibility', 'hidden');
- }
- else if (newTd) {
- $newRadio.css('visibility', 'visible');
- $oldRadio.css('visibility', 'visible');
- }
- else {
- $newRadio.css('visibility', 'visible');
- $oldRadio.css('visibility', 'hidden');
- }
- }
- else {
- $newRadio.css('visibility', 'visible');
- $oldRadio.css('visibility', 'visible');
- }
- }
- });
- return true;
- }
- if (Drupal.settings.diffRevisionRadios) {
- $rows.find('input[name="new"], input[name="old"]').click(updateDiffRadios);
- updateDiffRadios();
- }
- }
- };
- })(jQuery);
|