2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
7 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
9 (function ($, Drupal, drupalSettings) {
10 var showWeight = JSON.parse(localStorage.getItem('Drupal.tableDrag.showWeight'));
12 Drupal.behaviors.tableDrag = {
13 attach: function attach(context, settings) {
14 function initTableDrag(table, base) {
16 Drupal.tableDrag[base] = new Drupal.tableDrag(table[0], settings.tableDrag[base]);
20 Object.keys(settings.tableDrag || {}).forEach(function (base) {
21 initTableDrag($(context).find('#' + base).once('tabledrag'), base);
26 Drupal.tableDrag = function (table, tableSettings) {
30 var $table = $(table);
32 this.$table = $(table);
36 this.tableSettings = tableSettings;
38 this.dragObject = null;
40 this.rowObject = null;
42 this.oldRowElement = null;
50 this.rtl = $(this.table).css('direction') === 'rtl' ? -1 : 1;
52 this.striping = $(this.table).data('striping') === 1;
54 this.scrollSettings = { amount: 4, interval: 50, trigger: 70 };
56 this.scrollInterval = null;
60 this.windowHeight = 0;
62 this.indentEnabled = false;
63 Object.keys(tableSettings || {}).forEach(function (group) {
64 Object.keys(tableSettings[group] || {}).forEach(function (n) {
65 if (tableSettings[group][n].relationship === 'parent') {
66 _this.indentEnabled = true;
68 if (tableSettings[group][n].limit > 0) {
69 _this.maxDepth = tableSettings[group][n].limit;
73 if (this.indentEnabled) {
76 var indent = Drupal.theme('tableDragIndentation');
77 var testRow = $('<tr/>').addClass('draggable').appendTo(table);
78 var testCell = $('<td/>').appendTo(testRow).prepend(indent).prepend(indent);
79 var $indentation = testCell.find('.js-indentation');
81 this.indentAmount = $indentation.get(1).offsetLeft - $indentation.get(0).offsetLeft;
85 $table.find('> tr.draggable, > tbody > tr.draggable').each(function () {
86 self.makeDraggable(this);
89 $table.before($('<button type="button" class="link tabledrag-toggle-weight"></button>').attr('title', Drupal.t('Re-order rows by numerical weight instead of dragging.')).on('click', $.proxy(function (e) {
92 }, this)).wrap('<div class="tabledrag-toggle-weight-wrapper"></div>').parent());
96 $(document).on('touchmove', function (event) {
97 return self.dragRow(event.originalEvent.touches[0], self);
99 $(document).on('touchend', function (event) {
100 return self.dropRow(event.originalEvent.touches[0], self);
102 $(document).on('mousemove pointermove', function (event) {
103 return self.dragRow(event, self);
105 $(document).on('mouseup pointerup', function (event) {
106 return self.dropRow(event, self);
109 $(window).on('storage', $.proxy(function (e) {
110 if (e.originalEvent.key === 'Drupal.tableDrag.showWeight') {
111 showWeight = JSON.parse(e.originalEvent.newValue);
112 this.displayColumns(showWeight);
117 Drupal.tableDrag.prototype.initColumns = function () {
120 var $table = this.$table;
123 var columnIndex = void 0;
124 Object.keys(this.tableSettings || {}).forEach(function (group) {
125 Object.keys(_this2.tableSettings[group]).some(function (tableSetting) {
126 var field = $table.find('.' + _this2.tableSettings[group][tableSetting].target).eq(0);
127 if (field.length && _this2.tableSettings[group][tableSetting].hidden) {
128 hidden = _this2.tableSettings[group][tableSetting].hidden;
129 cell = field.closest('td');
135 if (hidden && cell[0]) {
136 columnIndex = cell.parent().find('> td').index(cell.get(0)) + 1;
137 $table.find('> thead > tr, > tbody > tr, > tr').each(_this2.addColspanClass(columnIndex));
140 this.displayColumns(showWeight);
143 Drupal.tableDrag.prototype.addColspanClass = function (columnIndex) {
146 var index = columnIndex;
147 var cells = $row.children();
149 cells.each(function (n) {
150 if (n < index && this.colSpan && this.colSpan > 1) {
151 index -= this.colSpan - 1;
155 cell = cells.filter(':nth-child(' + index + ')');
156 if (cell[0].colSpan && cell[0].colSpan > 1) {
157 cell.addClass('tabledrag-has-colspan');
159 cell.addClass('tabledrag-hide');
165 Drupal.tableDrag.prototype.displayColumns = function (displayWeight) {
172 $('table').findOnce('tabledrag').trigger('columnschange', !!displayWeight);
175 Drupal.tableDrag.prototype.toggleColumns = function () {
176 showWeight = !showWeight;
177 this.displayColumns(showWeight);
179 localStorage.setItem('Drupal.tableDrag.showWeight', showWeight);
181 localStorage.removeItem('Drupal.tableDrag.showWeight');
185 Drupal.tableDrag.prototype.hideColumns = function () {
186 var $tables = $('table').findOnce('tabledrag');
188 $tables.find('.tabledrag-hide').css('display', 'none');
190 $tables.find('.tabledrag-handle').css('display', '');
192 $tables.find('.tabledrag-has-colspan').each(function () {
193 this.colSpan = this.colSpan - 1;
196 $('.tabledrag-toggle-weight').text(Drupal.t('Show row weights'));
199 Drupal.tableDrag.prototype.showColumns = function () {
200 var $tables = $('table').findOnce('tabledrag');
202 $tables.find('.tabledrag-hide').css('display', '');
204 $tables.find('.tabledrag-handle').css('display', 'none');
206 $tables.find('.tabledrag-has-colspan').each(function () {
207 this.colSpan = this.colSpan + 1;
210 $('.tabledrag-toggle-weight').text(Drupal.t('Hide row weights'));
213 Drupal.tableDrag.prototype.rowSettings = function (group, row) {
214 var field = $(row).find('.' + group);
215 var tableSettingsGroup = this.tableSettings[group];
216 return Object.keys(tableSettingsGroup).map(function (delta) {
217 var targetClass = tableSettingsGroup[delta].target;
218 var rowSettings = void 0;
219 if (field.is('.' + targetClass)) {
221 Object.keys(tableSettingsGroup[delta]).forEach(function (n) {
222 rowSettings[n] = tableSettingsGroup[delta][n];
226 }).filter(function (rowSetting) {
231 Drupal.tableDrag.prototype.makeDraggable = function (item) {
235 $item.find('td:first-of-type').find('a').addClass('menu-item__link');
237 var handle = $('<a href="#" class="tabledrag-handle"><div class="handle"> </div></a>').attr('title', Drupal.t('Drag to re-order'));
239 var $indentationLast = $item.find('td:first-of-type').find('.js-indentation').eq(-1);
240 if ($indentationLast.length) {
241 $indentationLast.after(handle);
243 self.indentCount = Math.max($item.find('.js-indentation').length, self.indentCount);
245 $item.find('td').eq(0).prepend(handle);
248 handle.on('mousedown touchstart pointerdown', function (event) {
249 event.preventDefault();
250 if (event.originalEvent.type === 'touchstart') {
251 event = event.originalEvent.touches[0];
253 self.dragStart(event, self, item);
256 handle.on('click', function (e) {
260 handle.on('focus', function () {
261 self.safeBlur = true;
264 handle.on('blur', function (event) {
265 if (self.rowObject && self.safeBlur) {
266 self.dropRow(event, self);
270 handle.on('keydown', function (event) {
271 if (event.keyCode !== 9 && !self.rowObject) {
272 self.rowObject = new self.row(item, 'keyboard', self.indentEnabled, self.maxDepth, true);
275 var keyChange = false;
276 var groupHeight = void 0;
278 switch (event.keyCode) {
282 self.rowObject.indent(-1 * self.rtl);
288 var $previousRow = $(self.rowObject.element).prev('tr:first-of-type');
289 var previousRow = $previousRow.get(0);
290 while (previousRow && $previousRow.is(':hidden')) {
291 $previousRow = $(previousRow).prev('tr:first-of-type');
292 previousRow = $previousRow.get(0);
295 self.safeBlur = false;
296 self.rowObject.direction = 'up';
299 if ($(item).is('.tabledrag-root')) {
301 while (previousRow && $previousRow.find('.js-indentation').length) {
302 $previousRow = $(previousRow).prev('tr:first-of-type');
303 previousRow = $previousRow.get(0);
304 groupHeight += $previousRow.is(':hidden') ? 0 : previousRow.offsetHeight;
307 self.rowObject.swap('before', previousRow);
309 window.scrollBy(0, -groupHeight);
311 } else if (self.table.tBodies[0].rows[0] !== previousRow || $previousRow.is('.draggable')) {
312 self.rowObject.swap('before', previousRow);
313 self.rowObject.interval = null;
314 self.rowObject.indent(0);
315 window.scrollBy(0, -parseInt(item.offsetHeight, 10));
318 handle.trigger('focus');
326 self.rowObject.indent(self.rtl);
332 var $nextRow = $(self.rowObject.group).eq(-1).next('tr:first-of-type');
333 var nextRow = $nextRow.get(0);
334 while (nextRow && $nextRow.is(':hidden')) {
335 $nextRow = $(nextRow).next('tr:first-of-type');
336 nextRow = $nextRow.get(0);
339 self.safeBlur = false;
340 self.rowObject.direction = 'down';
343 if ($(item).is('.tabledrag-root')) {
345 var nextGroup = new self.row(nextRow, 'keyboard', self.indentEnabled, self.maxDepth, false);
347 $(nextGroup.group).each(function () {
348 groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight;
350 var nextGroupRow = $(nextGroup.group).eq(-1).get(0);
351 self.rowObject.swap('after', nextGroupRow);
353 window.scrollBy(0, parseInt(groupHeight, 10));
356 self.rowObject.swap('after', nextRow);
357 self.rowObject.interval = null;
358 self.rowObject.indent(0);
359 window.scrollBy(0, parseInt(item.offsetHeight, 10));
362 handle.trigger('focus');
368 if (self.rowObject && self.rowObject.changed === true) {
369 $(item).addClass('drag');
370 if (self.oldRowElement) {
371 $(self.oldRowElement).removeClass('drag-previous');
373 self.oldRowElement = item;
374 if (self.striping === true) {
375 self.restripeTable();
385 handle.on('keypress', function (event) {
387 switch (event.keyCode) {
397 Drupal.tableDrag.prototype.dragStart = function (event, self, item) {
398 self.dragObject = {};
399 self.dragObject.initOffset = self.getPointerOffset(item, event);
400 self.dragObject.initPointerCoords = self.pointerCoords(event);
401 if (self.indentEnabled) {
402 self.dragObject.indentPointerPos = self.dragObject.initPointerCoords;
405 if (self.rowObject) {
406 $(self.rowObject.element).find('a.tabledrag-handle').trigger('blur');
409 self.rowObject = new self.row(item, 'pointer', self.indentEnabled, self.maxDepth, true);
411 self.table.topY = $(self.table).offset().top;
412 self.table.bottomY = self.table.topY + self.table.offsetHeight;
414 $(item).addClass('drag');
416 $('body').addClass('drag');
417 if (self.oldRowElement) {
418 $(self.oldRowElement).removeClass('drag-previous');
422 Drupal.tableDrag.prototype.dragRow = function (event, self) {
423 if (self.dragObject) {
424 self.currentPointerCoords = self.pointerCoords(event);
425 var y = self.currentPointerCoords.y - self.dragObject.initOffset.y;
426 var x = self.currentPointerCoords.x - self.dragObject.initOffset.x;
428 if (y !== self.oldY) {
429 self.rowObject.direction = y > self.oldY ? 'down' : 'up';
433 var scrollAmount = self.checkScroll(self.currentPointerCoords.y);
435 clearInterval(self.scrollInterval);
437 if (scrollAmount > 0 && self.rowObject.direction === 'down' || scrollAmount < 0 && self.rowObject.direction === 'up') {
438 self.setScroll(scrollAmount);
441 var currentRow = self.findDropTargetRow(x, y);
443 if (self.rowObject.direction === 'down') {
444 self.rowObject.swap('after', currentRow, self);
446 self.rowObject.swap('before', currentRow, self);
448 if (self.striping === true) {
449 self.restripeTable();
454 if (self.indentEnabled) {
455 var xDiff = self.currentPointerCoords.x - self.dragObject.indentPointerPos.x;
457 var indentDiff = Math.round(xDiff / self.indentAmount);
459 var indentChange = self.rowObject.indent(indentDiff);
461 self.dragObject.indentPointerPos.x += self.indentAmount * indentChange * self.rtl;
462 self.indentCount = Math.max(self.indentCount, self.rowObject.indents);
469 Drupal.tableDrag.prototype.dropRow = function (event, self) {
470 var droppedRow = void 0;
471 var $droppedRow = void 0;
473 if (self.rowObject !== null) {
474 droppedRow = self.rowObject.element;
475 $droppedRow = $(droppedRow);
477 if (self.rowObject.changed === true) {
478 self.updateFields(droppedRow);
480 Object.keys(self.tableSettings || {}).forEach(function (group) {
481 var rowSettings = self.rowSettings(group, droppedRow);
482 if (rowSettings.relationship === 'group') {
483 Object.keys(self.rowObject.children || {}).forEach(function (n) {
484 self.updateField(self.rowObject.children[n], group);
489 self.rowObject.markChanged();
490 if (self.changed === false) {
491 $(Drupal.theme('tableDragChangedWarning')).insertBefore(self.table).hide().fadeIn('slow');
496 if (self.indentEnabled) {
497 self.rowObject.removeIndentClasses();
499 if (self.oldRowElement) {
500 $(self.oldRowElement).removeClass('drag-previous');
502 $droppedRow.removeClass('drag').addClass('drag-previous');
503 self.oldRowElement = droppedRow;
505 self.rowObject = null;
508 if (self.dragObject !== null) {
509 self.dragObject = null;
510 $('body').removeClass('drag');
511 clearInterval(self.scrollInterval);
515 Drupal.tableDrag.prototype.pointerCoords = function (event) {
516 if (event.pageX || event.pageY) {
517 return { x: event.pageX, y: event.pageY };
520 x: event.clientX + document.body.scrollLeft - document.body.clientLeft,
521 y: event.clientY + document.body.scrollTop - document.body.clientTop
525 Drupal.tableDrag.prototype.getPointerOffset = function (target, event) {
526 var docPos = $(target).offset();
527 var pointerPos = this.pointerCoords(event);
528 return { x: pointerPos.x - docPos.left, y: pointerPos.y - docPos.top };
531 Drupal.tableDrag.prototype.findDropTargetRow = function (x, y) {
534 var rows = $(this.table.tBodies[0].rows).not(':hidden');
536 var _loop = function _loop(n) {
539 var rowY = $row.offset().top;
540 var rowHeight = void 0;
542 if (row.offsetHeight === 0) {
543 rowHeight = parseInt(row.firstChild.offsetHeight, 10) / 2;
545 rowHeight = parseInt(row.offsetHeight, 10) / 2;
548 if (y > rowY - rowHeight && y < rowY + rowHeight) {
549 if (_this3.indentEnabled) {
550 if (Object.keys(_this3.rowObject.group).some(function (o) {
551 return _this3.rowObject.group[o] === row;
557 } else if (row === _this3.rowObject.element) {
563 if (!_this3.rowObject.isValidSwap(row)) {
569 while ($row.is(':hidden') && $row.prev('tr').is(':hidden')) {
570 $row = $row.prev('tr:first-of-type');
579 for (var n = 0; n < rows.length; n++) {
582 if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
587 Drupal.tableDrag.prototype.updateFields = function (changedRow) {
590 Object.keys(this.tableSettings || {}).forEach(function (group) {
591 _this4.updateField(changedRow, group);
595 Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
596 var rowSettings = this.rowSettings(group, changedRow);
597 var $changedRow = $(changedRow);
598 var sourceRow = void 0;
599 var $previousRow = void 0;
600 var previousRow = void 0;
601 var useSibling = void 0;
603 if (rowSettings.relationship === 'self' || rowSettings.relationship === 'group') {
604 sourceRow = changedRow;
605 } else if (rowSettings.relationship === 'sibling') {
606 $previousRow = $changedRow.prev('tr:first-of-type');
607 previousRow = $previousRow.get(0);
608 var $nextRow = $changedRow.next('tr:first-of-type');
609 var nextRow = $nextRow.get(0);
610 sourceRow = changedRow;
611 if ($previousRow.is('.draggable') && $previousRow.find('.' + group).length) {
612 if (this.indentEnabled) {
613 if ($previousRow.find('.js-indentations').length === $changedRow.find('.js-indentations').length) {
614 sourceRow = previousRow;
617 sourceRow = previousRow;
619 } else if ($nextRow.is('.draggable') && $nextRow.find('.' + group).length) {
620 if (this.indentEnabled) {
621 if ($nextRow.find('.js-indentations').length === $changedRow.find('.js-indentations').length) {
628 } else if (rowSettings.relationship === 'parent') {
629 $previousRow = $changedRow.prev('tr');
630 previousRow = $previousRow;
631 while ($previousRow.length && $previousRow.find('.js-indentation').length >= this.rowObject.indents) {
632 $previousRow = $previousRow.prev('tr');
633 previousRow = $previousRow;
636 if ($previousRow.length) {
637 sourceRow = $previousRow.get(0);
639 sourceRow = $(this.table).find('tr.draggable:first-of-type').get(0);
640 if (sourceRow === this.rowObject.element) {
641 sourceRow = $(this.rowObject.group[this.rowObject.group.length - 1]).next('tr.draggable').get(0);
647 this.copyDragClasses(sourceRow, changedRow, group);
648 rowSettings = this.rowSettings(group, changedRow);
651 rowSettings.relationship = 'sibling';
652 rowSettings.source = rowSettings.target;
655 var targetClass = '.' + rowSettings.target;
656 var targetElement = $changedRow.find(targetClass).get(0);
659 var sourceClass = '.' + rowSettings.source;
660 var sourceElement = $(sourceClass, sourceRow).get(0);
661 switch (rowSettings.action) {
663 targetElement.value = $(sourceElement).closest('tr').find('.js-indentation').length;
667 targetElement.value = sourceElement.value;
672 var siblings = this.rowObject.findSiblings(rowSettings);
673 if ($(targetElement).is('select')) {
675 $(targetElement).find('option').each(function () {
676 values.push(this.value);
678 var maxVal = values[values.length - 1];
680 $(siblings).find(targetClass).each(function () {
681 if (values.length > 0) {
682 this.value = values.shift();
688 var weight = parseInt($(siblings[0]).find(targetClass).val(), 10) || 0;
689 $(siblings).find(targetClass).each(function () {
700 Drupal.tableDrag.prototype.copyDragClasses = function (sourceRow, targetRow, group) {
701 var sourceElement = $(sourceRow).find('.' + group);
702 var targetElement = $(targetRow).find('.' + group);
703 if (sourceElement.length && targetElement.length) {
704 targetElement[0].className = sourceElement[0].className;
708 Drupal.tableDrag.prototype.checkScroll = function (cursorY) {
709 var de = document.documentElement;
710 var b = document.body;
712 var windowHeight = window.innerHeight || (de.clientHeight && de.clientWidth !== 0 ? de.clientHeight : b.offsetHeight);
713 this.windowHeight = windowHeight;
714 var scrollY = void 0;
716 scrollY = !de.scrollTop ? b.scrollTop : de.scrollTop;
718 scrollY = window.pageYOffset ? window.pageYOffset : window.scrollY;
720 this.scrollY = scrollY;
721 var trigger = this.scrollSettings.trigger;
724 if (cursorY - scrollY > windowHeight - trigger) {
725 delta = trigger / (windowHeight + scrollY - cursorY);
726 delta = delta > 0 && delta < trigger ? delta : trigger;
727 return delta * this.scrollSettings.amount;
729 if (cursorY - scrollY < trigger) {
730 delta = trigger / (cursorY - scrollY);
731 delta = delta > 0 && delta < trigger ? delta : trigger;
732 return -delta * this.scrollSettings.amount;
736 Drupal.tableDrag.prototype.setScroll = function (scrollAmount) {
739 this.scrollInterval = setInterval(function () {
740 self.checkScroll(self.currentPointerCoords.y);
741 var aboveTable = self.scrollY > self.table.topY;
742 var belowTable = self.scrollY + self.windowHeight < self.table.bottomY;
743 if (scrollAmount > 0 && belowTable || scrollAmount < 0 && aboveTable) {
744 window.scrollBy(0, scrollAmount);
746 }, this.scrollSettings.interval);
749 Drupal.tableDrag.prototype.restripeTable = function () {
750 $(this.table).find('> tbody > tr.draggable, > tr.draggable').filter(':visible').filter(':odd').removeClass('odd').addClass('even').end().filter(':even').removeClass('even').addClass('odd');
753 Drupal.tableDrag.prototype.onDrag = function () {
757 Drupal.tableDrag.prototype.onDrop = function () {
761 Drupal.tableDrag.prototype.row = function (tableRow, method, indentEnabled, maxDepth, addClasses) {
762 var $tableRow = $(tableRow);
764 this.element = tableRow;
765 this.method = method;
766 this.group = [tableRow];
767 this.groupDepth = $tableRow.find('.js-indentation').length;
768 this.changed = false;
769 this.table = $tableRow.closest('table')[0];
770 this.indentEnabled = indentEnabled;
771 this.maxDepth = maxDepth;
774 if (this.indentEnabled) {
775 this.indents = $tableRow.find('.js-indentation').length;
776 this.children = this.findChildren(addClasses);
777 this.group = $.merge(this.group, this.children);
779 for (var n = 0; n < this.group.length; n++) {
780 this.groupDepth = Math.max($(this.group[n]).find('.js-indentation').length, this.groupDepth);
785 Drupal.tableDrag.prototype.row.prototype.findChildren = function (addClasses) {
786 var parentIndentation = this.indents;
787 var currentRow = $(this.element, this.table).next('tr.draggable');
791 function rowIndentation(indentNum, el) {
793 if (child === 1 && indentNum === parentIndentation) {
794 self.addClass('tree-child-first');
796 if (indentNum === parentIndentation) {
797 self.addClass('tree-child');
798 } else if (indentNum > parentIndentation) {
799 self.addClass('tree-child-horizontal');
803 while (currentRow.length) {
804 if (currentRow.find('.js-indentation').length > parentIndentation) {
806 rows.push(currentRow[0]);
808 currentRow.find('.js-indentation').each(rowIndentation);
813 currentRow = currentRow.next('tr.draggable');
815 if (addClasses && rows.length) {
816 $(rows[rows.length - 1]).find('.js-indentation:nth-child(' + (parentIndentation + 1) + ')').addClass('tree-child-last');
821 Drupal.tableDrag.prototype.row.prototype.isValidSwap = function (row) {
823 if (this.indentEnabled) {
824 var prevRow = void 0;
825 var nextRow = void 0;
826 if (this.direction === 'down') {
828 nextRow = $row.next('tr').get(0);
830 prevRow = $row.prev('tr').get(0);
833 this.interval = this.validIndentInterval(prevRow, nextRow);
835 if (this.interval.min > this.interval.max) {
840 if (this.table.tBodies[0].rows[0] === row && $row.is(':not(.draggable)')) {
847 Drupal.tableDrag.prototype.row.prototype.swap = function (position, row) {
848 this.group.forEach(function (row) {
849 Drupal.detachBehaviors(row, drupalSettings, 'move');
851 $(row)[position](this.group);
853 this.group.forEach(function (row) {
854 Drupal.attachBehaviors(row, drupalSettings);
860 Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) {
861 var $prevRow = $(prevRow);
862 var maxIndent = void 0;
864 var minIndent = nextRow ? $(nextRow).find('.js-indentation').length : 0;
866 if (!prevRow || $prevRow.is(':not(.draggable)') || $(this.element).is('.tabledrag-root')) {
869 maxIndent = $prevRow.find('.js-indentation').length + ($prevRow.is('.tabledrag-leaf') ? 0 : 1);
872 maxIndent = Math.min(maxIndent, this.maxDepth - (this.groupDepth - this.indents));
876 return { min: minIndent, max: maxIndent };
879 Drupal.tableDrag.prototype.row.prototype.indent = function (indentDiff) {
880 var $group = $(this.group);
882 if (!this.interval) {
883 var prevRow = $(this.element).prev('tr').get(0);
884 var nextRow = $group.eq(-1).next('tr').get(0);
885 this.interval = this.validIndentInterval(prevRow, nextRow);
888 var indent = this.indents + indentDiff;
889 indent = Math.max(indent, this.interval.min);
890 indent = Math.min(indent, this.interval.max);
891 indentDiff = indent - this.indents;
893 for (var n = 1; n <= Math.abs(indentDiff); n++) {
894 if (indentDiff < 0) {
895 $group.find('.js-indentation:first-of-type').remove();
898 $group.find('td:first-of-type').prepend(Drupal.theme('tableDragIndentation'));
904 this.groupDepth += indentDiff;
911 Drupal.tableDrag.prototype.row.prototype.findSiblings = function (rowSettings) {
913 var directions = ['prev', 'next'];
914 var rowIndentation = this.indents;
915 var checkRowIndentation = void 0;
916 for (var d = 0; d < directions.length; d++) {
917 var checkRow = $(this.element)[directions[d]]();
918 while (checkRow.length) {
919 if (checkRow.find('.' + rowSettings.target)) {
920 if (this.indentEnabled) {
921 checkRowIndentation = checkRow.find('.js-indentation').length;
924 if (!this.indentEnabled || checkRowIndentation === rowIndentation) {
925 siblings.push(checkRow[0]);
926 } else if (checkRowIndentation < rowIndentation) {
932 checkRow = checkRow[directions[d]]();
935 if (directions[d] === 'prev') {
937 siblings.push(this.element);
943 Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () {
946 Object.keys(this.children || {}).forEach(function (n) {
947 $(_this5.children[n]).find('.js-indentation').removeClass('tree-child').removeClass('tree-child-first').removeClass('tree-child-last').removeClass('tree-child-horizontal');
951 Drupal.tableDrag.prototype.row.prototype.markChanged = function () {
952 var marker = Drupal.theme('tableDragChangedMarker');
953 var cell = $(this.element).find('td:first-of-type');
954 if (cell.find('abbr.tabledrag-changed').length === 0) {
959 Drupal.tableDrag.prototype.row.prototype.onIndent = function () {
963 Drupal.tableDrag.prototype.row.prototype.onSwap = function (swappedRow) {
967 $.extend(Drupal.theme, {
968 tableDragChangedMarker: function tableDragChangedMarker() {
969 return '<abbr class="warning tabledrag-changed" title="' + Drupal.t('Changed') + '">*</abbr>';
971 tableDragIndentation: function tableDragIndentation() {
972 return '<div class="js-indentation indentation"> </div>';
974 tableDragChangedWarning: function tableDragChangedWarning() {
975 return '<div class="tabledrag-changed-warning messages messages--warning" role="alert">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t('You have unsaved changes.') + '</div>';
978 })(jQuery, Drupal, drupalSettings);