Commit 336d30dc authored by alexpott's avatar alexpott

Issue #2914719 by nod_, droplet: JS codestyle: newline-per-chained-call

parent fa985778
......@@ -13,7 +13,6 @@
"no-lonely-if": "off",
"no-empty": "off",
"no-continue": "off",
"newline-per-chained-call": "off",
"new-cap": "off",
"max-len": "off",
"default-case": "off",
......
......@@ -1283,10 +1283,14 @@
// :even and :odd are reversed because jQuery counts from 0 and
// we count from 1, so we're out of sync.
// Match immediate children of the parent element to allow nesting.
$(response.selector).find('> tbody > tr:visible, > tr:visible')
$(response.selector)
.find('> tbody > tr:visible, > tr:visible')
.removeClass('odd even')
.filter(':even').addClass('odd').end()
.filter(':odd').addClass('even');
.filter(':even')
.addClass('odd')
.end()
.filter(':odd')
.addClass('even');
},
/**
......
......@@ -603,8 +603,10 @@
if (e.trigger) {
$(e.target)
.prop('disabled', e.value)
.closest('.js-form-item, .js-form-submit, .js-form-wrapper').toggleClass('form-disabled', e.value)
.find('select, input, textarea').prop('disabled', e.value);
.closest('.js-form-item, .js-form-submit, .js-form-wrapper')
.toggleClass('form-disabled', e.value)
.find('select, input, textarea')
.prop('disabled', e.value);
// Note: WebKit nightlies don't reflect that change correctly.
// See https://bugs.webkit.org/show_bug.cgi?id=23789
......@@ -622,7 +624,11 @@
}
}
else {
$(e.target).removeAttr('required aria-required').closest('.js-form-item, .js-form-wrapper').find('label.js-form-required').removeClass('js-form-required form-required');
$(e.target)
.removeAttr('required aria-required')
.closest('.js-form-item, .js-form-wrapper')
.find('label.js-form-required')
.removeClass('js-form-required form-required');
}
}
});
......
......@@ -1157,10 +1157,16 @@
// :even and :odd are reversed because jQuery counts from 0 and
// we count from 1, so we're out of sync.
// Match immediate children of the parent element to allow nesting.
$(this.table).find('> tbody > tr.draggable, > tr.draggable')
$(this.table)
.find('> tbody > tr.draggable, > tr.draggable')
.filter(':visible')
.filter(':odd').removeClass('odd').addClass('even').end()
.filter(':even').removeClass('even').addClass('odd');
.filter(':odd')
.removeClass('odd')
.addClass('even')
.end()
.filter(':even')
.removeClass('even')
.addClass('odd');
};
/**
......
......@@ -15,7 +15,11 @@
Drupal.behaviors.tableSelect = {
attach(context, settings) {
// Select the inner-most table in case of nested tables.
$(context).find('th.select-all').closest('table').once('table-select').each(Drupal.tableSelect);
$(context)
.find('th.select-all')
.closest('table')
.once('table-select')
.each(Drupal.tableSelect);
},
};
......
......@@ -204,8 +204,13 @@
// Update .first marker for items. We need recurse from parent to retain
// the actual DOM element order as jQuery implements sortOrder, but not
// as public method.
this.item.parent().children('.vertical-tabs__menu-item').removeClass('first')
.filter(':visible').eq(0).addClass('first');
this.item
.parent()
.children('.vertical-tabs__menu-item')
.removeClass('first')
.filter(':visible')
.eq(0)
.addClass('first');
// Display the details element.
this.details.removeClass('vertical-tab--hidden').show();
// Focus this tab.
......@@ -225,8 +230,13 @@
// Update .first marker for items. We need recurse from parent to retain
// the actual DOM element order as jQuery implements sortOrder, but not
// as public method.
this.item.parent().children('.vertical-tabs__menu-item').removeClass('first')
.filter(':visible').eq(0).addClass('first');
this.item
.parent()
.children('.vertical-tabs__menu-item')
.removeClass('first')
.filter(':visible')
.eq(0)
.addClass('first');
// Hide the details element.
this.details.addClass('vertical-tab--hidden').hide();
// Focus the first visible tab (if there is one).
......
......@@ -98,7 +98,14 @@
}
// Wrap between rows.
else {
$container.closest('.ckeditor-row').prev().find('.ckeditor-toolbar-group').not('.placeholder').find('.ckeditor-toolbar-group-buttons').eq(-1).append($button);
$container
.closest('.ckeditor-row')
.prev()
.find('.ckeditor-toolbar-group')
.not('.placeholder')
.find('.ckeditor-toolbar-group-buttons')
.eq(-1)
.append($button);
}
}
}
......@@ -127,7 +134,13 @@
.off()
.remove();
// Focus on the first button in the active toolbar.
$activeButtons.find('.ckeditor-toolbar-group-buttons').eq(0).children().eq(0).children().trigger('focus');
$activeButtons
.find('.ckeditor-toolbar-group-buttons')
.eq(0)
.children()
.eq(0)
.children()
.trigger('focus');
}
// Otherwise, move it.
else {
......@@ -229,7 +242,13 @@
// Wrap between rows. Insert the group before the placeholder group
// at the end of the previous row.
else {
$group.insertBefore($container.closest('.ckeditor-row').prev().find('.ckeditor-toolbar-groups').children().eq(-1));
const $rowChildElement = $container
.closest('.ckeditor-row')
.prev()
.find('.ckeditor-toolbar-groups')
.children()
.eq(-1);
$group.insertBefore($rowChildElement);
}
}
// Move right between sibling groups.
......@@ -247,7 +266,11 @@
// Move groups between rows.
else if (_.indexOf(upDownKeys, event.keyCode) > -1) {
dir = (_.indexOf([38, 63232], event.keyCode) > -1) ? 'prev' : 'next';
$group.closest('.ckeditor-row')[dir]().find('.ckeditor-toolbar-groups').eq(0).prepend($group);
$group
.closest('.ckeditor-row')[dir]()
.find('.ckeditor-toolbar-groups')
.eq(0)
.prepend($group);
}
Drupal.ckeditor.registerGroupMove(this, $group);
......
......@@ -128,7 +128,8 @@
if (index > 0) {
$group.insertBefore($siblings.eq(index - 1));
} else {
$group.insertBefore($container.closest('.ckeditor-row').prev().find('.ckeditor-toolbar-groups').children().eq(-1));
var $rowChildElement = $container.closest('.ckeditor-row').prev().find('.ckeditor-toolbar-groups').children().eq(-1);
$group.insertBefore($rowChildElement);
}
} else if (_.indexOf([39, 63235], event.keyCode) > -1) {
if (!$siblings.eq(index + 1).hasClass('placeholder')) {
......
......@@ -218,9 +218,12 @@
const input = e.target;
// Remove old bindings.
if (focused) {
$(focused).off('keyup', farb.updateValue)
.off('keyup', preview).off('keyup', resetScheme)
.parent().removeClass('item-selected');
$(focused)
.off('keyup', farb.updateValue)
.off('keyup', preview)
.off('keyup', resetScheme)
.parent()
.removeClass('item-selected');
}
// Add new bindings.
......@@ -229,8 +232,12 @@
callback(input, color, true, false);
});
farb.setColor(input.value);
$(focused).on('keyup', farb.updateValue).on('keyup', preview).on('keyup', resetScheme)
.parent().addClass('item-selected');
$(focused)
.on('keyup', farb.updateValue)
.on('keyup', preview)
.on('keyup', resetScheme)
.parent()
.addClass('item-selected');
}
// Initialize color fields.
......
......@@ -66,9 +66,11 @@
// Find the parent <li>.
.closest('.comment-new-comments')
// Find the preceding <li>, if any, and give it the 'last' class.
.prev().addClass('last')
.prev()
.addClass('last')
// Go back to the parent <li> and hide it.
.end().hide();
.end()
.hide();
}
/**
......@@ -95,9 +97,11 @@
// Find the parent <li>.
.closest('.comment-new-comments')
// Find the preceding <li>, if any, and remove its 'last' class, if any.
.prev().removeClass('last')
.prev()
.removeClass('last')
// Go back to the parent <li> and show it.
.end().show();
.end()
.show();
}
/**
......
......@@ -89,7 +89,12 @@
$bundleSettings.nextUntil('.bundle-settings').hide();
}
else {
$bundleSettings.nextUntil('.bundle-settings', '.field-settings').find('.translatable :input:not(:checked)').closest('.field-settings').nextUntil(':not(.column-settings)').hide();
$bundleSettings
.nextUntil('.bundle-settings', '.field-settings')
.find('.translatable :input:not(:checked)')
.closest('.field-settings')
.nextUntil(':not(.column-settings)')
.hide();
}
});
......
......@@ -17,14 +17,21 @@
function updateFilterGuidelines(event) {
const $this = $(event.target);
const value = $this.val();
$this.closest('.filter-wrapper')
.find('.filter-guidelines-item').hide()
.filter(`.filter-guidelines-${value}`).show();
$this
.closest('.filter-wrapper')
.find('.filter-guidelines-item')
.hide()
.filter(`.filter-guidelines-${value}`)
.show();
}
$(context).find('.filter-guidelines').once('filter-guidelines')
.find(':header').hide()
.closest('.filter-wrapper').find('select.filter-list')
$(context)
.find('.filter-guidelines')
.once('filter-guidelines')
.find(':header')
.hide()
.closest('.filter-wrapper')
.find('select.filter-list')
.on('change.filterGuidelines', updateFilterGuidelines)
// Need to trigger the namespaced event to avoid triggering formUpdated
// when initializing the select.
......
......@@ -346,8 +346,15 @@
const $addDisplayDropdown = $(`<li class="add"><a href="#"><span class="icon add"></span>${Drupal.t('Add')}</a><ul class="action-list" style="display:none;"></ul></li>`);
const $displayButtons = $menu.nextAll('input.add-display').detach();
$displayButtons.appendTo($addDisplayDropdown.find('.action-list')).wrap('<li>')
.parent().eq(0).addClass('first').end().eq(-1).addClass('last');
$displayButtons
.appendTo($addDisplayDropdown.find('.action-list'))
.wrap('<li>')
.parent()
.eq(0)
.addClass('first')
.end()
.eq(-1)
.addClass('last');
// Remove the 'Add ' prefix from the button labels since they're being
// placed in an 'Add' dropdown. @todo This assumes English, but so does
// $addDisplayDropdown above. Add support for translation.
......@@ -1021,7 +1028,11 @@
*/
Drupal.behaviors.viewsRemoveIconClass = {
attach(context) {
$(context).find('.dropbutton').once('dropbutton-icon').find('.icon').removeClass('icon');
$(context)
.find('.dropbutton')
.once('dropbutton-icon')
.find('.icon')
.removeClass('icon');
},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment