taxonomy.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function ($) {
  2. /**
  3. * Move a block in the blocks table from one region to another via select list.
  4. *
  5. * This behavior is dependent on the tableDrag behavior, since it uses the
  6. * objects initialized in that behavior to update the row.
  7. */
  8. Drupal.behaviors.termDrag = {
  9. attach: function (context, settings) {
  10. var table = $('#taxonomy', context);
  11. var tableDrag = Drupal.tableDrag.taxonomy; // Get the blocks tableDrag object.
  12. var rows = $('tr', table).length;
  13. // When a row is swapped, keep previous and next page classes set.
  14. tableDrag.row.prototype.onSwap = function (swappedRow) {
  15. $('tr.taxonomy-term-preview', table).removeClass('taxonomy-term-preview');
  16. $('tr.taxonomy-term-divider-top', table).removeClass('taxonomy-term-divider-top');
  17. $('tr.taxonomy-term-divider-bottom', table).removeClass('taxonomy-term-divider-bottom');
  18. if (settings.taxonomy.backStep) {
  19. for (var n = 0; n < settings.taxonomy.backStep; n++) {
  20. $(table[0].tBodies[0].rows[n]).addClass('taxonomy-term-preview');
  21. }
  22. $(table[0].tBodies[0].rows[settings.taxonomy.backStep - 1]).addClass('taxonomy-term-divider-top');
  23. $(table[0].tBodies[0].rows[settings.taxonomy.backStep]).addClass('taxonomy-term-divider-bottom');
  24. }
  25. if (settings.taxonomy.forwardStep) {
  26. for (var n = rows - settings.taxonomy.forwardStep - 1; n < rows - 1; n++) {
  27. $(table[0].tBodies[0].rows[n]).addClass('taxonomy-term-preview');
  28. }
  29. $(table[0].tBodies[0].rows[rows - settings.taxonomy.forwardStep - 2]).addClass('taxonomy-term-divider-top');
  30. $(table[0].tBodies[0].rows[rows - settings.taxonomy.forwardStep - 1]).addClass('taxonomy-term-divider-bottom');
  31. }
  32. };
  33. }
  34. };
  35. })(jQuery);