- else {
- sourceRow = nextRow;
- }
- }
- }
- // Parents, look up the tree until we find a field not in this group.
- // Go up as many parents as indentations in the changed row.
- else if (rowSettings.relationship === 'parent') {
- $previousRow = $changedRow.prev('tr');
- previousRow = $previousRow;
- while ($previousRow.length && $previousRow.find('.js-indentation').length >= this.rowObject.indents) {
- $previousRow = $previousRow.prev('tr');
- previousRow = $previousRow;
- }
- // If we found a row.
- if ($previousRow.length) {
- sourceRow = $previousRow.get(0);
- }
- // Otherwise we went all the way to the left of the table without finding
- // a parent, meaning this item has been placed at the root level.
- else {
- // Use the first row in the table as source, because it's guaranteed to
- // be at the root level. Find the first item, then compare this row
- // against it as a sibling.
- sourceRow = $(this.table).find('tr.draggable:first-of-type').get(0);
- if (sourceRow === this.rowObject.element) {
- sourceRow = $(this.rowObject.group[this.rowObject.group.length - 1]).next('tr.draggable').get(0);
+ } else if (rowSettings.relationship === 'parent') {
+ $previousRow = $changedRow.prev('tr');
+ previousRow = $previousRow;
+ while ($previousRow.length && $previousRow.find('.js-indentation').length >= this.rowObject.indents) {
+ $previousRow = $previousRow.prev('tr');
+ previousRow = $previousRow;
+ }
+
+ if ($previousRow.length) {
+ sourceRow = $previousRow.get(0);
+ } else {
+ sourceRow = $(this.table).find('tr.draggable:first-of-type').get(0);
+ if (sourceRow === this.rowObject.element) {
+ sourceRow = $(this.rowObject.group[this.rowObject.group.length - 1]).next('tr.draggable').get(0);
+ }
+ useSibling = true;
+ }