taxonomy.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/2815083
  5. * @preserve
  6. **/
  7. (function ($, Drupal) {
  8. Drupal.behaviors.termDrag = {
  9. attach: function attach(context, settings) {
  10. var backStep = settings.taxonomy.backStep;
  11. var forwardStep = settings.taxonomy.forwardStep;
  12. var tableDrag = Drupal.tableDrag.taxonomy;
  13. var $table = $('#taxonomy');
  14. var rows = $table.find('tr').length;
  15. tableDrag.row.prototype.onSwap = function (swappedRow) {
  16. $table.find('tr.taxonomy-term-preview').removeClass('taxonomy-term-preview');
  17. $table.find('tr.taxonomy-term-divider-top').removeClass('taxonomy-term-divider-top');
  18. $table.find('tr.taxonomy-term-divider-bottom').removeClass('taxonomy-term-divider-bottom');
  19. var tableBody = $table[0].tBodies[0];
  20. if (backStep) {
  21. for (var n = 0; n < backStep; n++) {
  22. $(tableBody.rows[n]).addClass('taxonomy-term-preview');
  23. }
  24. $(tableBody.rows[backStep - 1]).addClass('taxonomy-term-divider-top');
  25. $(tableBody.rows[backStep]).addClass('taxonomy-term-divider-bottom');
  26. }
  27. if (forwardStep) {
  28. for (var k = rows - forwardStep - 1; k < rows - 1; k++) {
  29. $(tableBody.rows[k]).addClass('taxonomy-term-preview');
  30. }
  31. $(tableBody.rows[rows - forwardStep - 2]).addClass('taxonomy-term-divider-top');
  32. $(tableBody.rows[rows - forwardStep - 1]).addClass('taxonomy-term-divider-bottom');
  33. }
  34. };
  35. }
  36. };
  37. })(jQuery, Drupal);