6 (function ($, Drupal) {
11 * Move a block in the blocks table from one region to another.
13 * This behavior is dependent on the tableDrag behavior, since it uses the
14 * objects initialized in that behavior to update the row.
16 * @type {Drupal~behavior}
18 * @prop {Drupal~behaviorAttach} attach
19 * Attaches the drag behavior to a applicable table element.
21 Drupal.behaviors.termDrag = {
22 attach: function (context, settings) {
23 var backStep = settings.taxonomy.backStep;
24 var forwardStep = settings.taxonomy.forwardStep;
25 // Get the blocks tableDrag object.
26 var tableDrag = Drupal.tableDrag.taxonomy;
27 var $table = $('#taxonomy');
28 var rows = $table.find('tr').length;
30 // When a row is swapped, keep previous and next page classes set.
31 tableDrag.row.prototype.onSwap = function (swappedRow) {
32 $table.find('tr.taxonomy-term-preview').removeClass('taxonomy-term-preview');
33 $table.find('tr.taxonomy-term-divider-top').removeClass('taxonomy-term-divider-top');
34 $table.find('tr.taxonomy-term-divider-bottom').removeClass('taxonomy-term-divider-bottom');
36 var tableBody = $table[0].tBodies[0];
38 for (var n = 0; n < backStep; n++) {
39 $(tableBody.rows[n]).addClass('taxonomy-term-preview');
41 $(tableBody.rows[backStep - 1]).addClass('taxonomy-term-divider-top');
42 $(tableBody.rows[backStep]).addClass('taxonomy-term-divider-bottom');
46 for (var k = rows - forwardStep - 1; k < rows - 1; k++) {
47 $(tableBody.rows[k]).addClass('taxonomy-term-preview');
49 $(tableBody.rows[rows - forwardStep - 2]).addClass('taxonomy-term-divider-top');
50 $(tableBody.rows[rows - forwardStep - 1]).addClass('taxonomy-term-divider-bottom');