updated core to 8.6.1 via composer
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Block admin behaviors.
|
||||
*/
|
||||
|
||||
(function ($, Drupal, debounce) {
|
||||
(function($, Drupal, debounce) {
|
||||
/**
|
||||
* Filters the block list by a text input search string.
|
||||
*
|
||||
@@ -33,7 +33,9 @@
|
||||
* The jQuery event for the keyup event that triggered the filter.
|
||||
*/
|
||||
function filterBlockList(e) {
|
||||
const query = $(e.target).val().toLowerCase();
|
||||
const query = $(e.target)
|
||||
.val()
|
||||
.toLowerCase();
|
||||
|
||||
/**
|
||||
* Shows or hides the block entry based on the query.
|
||||
@@ -46,7 +48,11 @@
|
||||
function toggleBlockEntry(index, label) {
|
||||
const $label = $(label);
|
||||
const $row = $label.parent().parent();
|
||||
const textMatch = $label.text().toLowerCase().indexOf(query) !== -1;
|
||||
const textMatch =
|
||||
$label
|
||||
.text()
|
||||
.toLowerCase()
|
||||
.indexOf(query) !== -1;
|
||||
$row.toggle(textMatch);
|
||||
}
|
||||
|
||||
@@ -60,10 +66,12 @@
|
||||
'@count blocks are available in the modified list.',
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$filterRows.each(function (index) {
|
||||
$(this).parent().parent().show();
|
||||
} else {
|
||||
$filterRows.each(function(index) {
|
||||
$(this)
|
||||
.parent()
|
||||
.parent()
|
||||
.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -86,15 +94,24 @@
|
||||
Drupal.behaviors.blockHighlightPlacement = {
|
||||
attach(context, settings) {
|
||||
if (settings.blockPlacement) {
|
||||
$(context).find('[data-drupal-selector="edit-blocks"]').once('block-highlight').each(function () {
|
||||
const $container = $(this);
|
||||
// Just scrolling the document.body will not work in Firefox. The html
|
||||
// element is needed as well.
|
||||
$('html, body').animate({
|
||||
scrollTop: ($('.js-block-placed').offset().top - $container.offset().top) + $container.scrollTop(),
|
||||
}, 500);
|
||||
});
|
||||
$(context)
|
||||
.find('[data-drupal-selector="edit-blocks"]')
|
||||
.once('block-highlight')
|
||||
.each(function() {
|
||||
const $container = $(this);
|
||||
// Just scrolling the document.body will not work in Firefox. The html
|
||||
// element is needed as well.
|
||||
$('html, body').animate(
|
||||
{
|
||||
scrollTop:
|
||||
$('.js-block-placed').offset().top -
|
||||
$container.offset().top +
|
||||
$container.scrollTop(),
|
||||
},
|
||||
500,
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
}(jQuery, Drupal, Drupal.debounce));
|
||||
})(jQuery, Drupal, Drupal.debounce);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Block behaviors.
|
||||
*/
|
||||
|
||||
(function ($, window, Drupal) {
|
||||
(function($, window, Drupal) {
|
||||
/**
|
||||
* Provide the summary information for the block settings vertical tabs.
|
||||
*
|
||||
@@ -32,7 +32,9 @@
|
||||
*/
|
||||
function checkboxesSummary(context) {
|
||||
const vals = [];
|
||||
const $checkboxes = $(context).find('input[type="checkbox"]:checked + label');
|
||||
const $checkboxes = $(context).find(
|
||||
'input[type="checkbox"]:checked + label',
|
||||
);
|
||||
const il = $checkboxes.length;
|
||||
for (let i = 0; i < il; i++) {
|
||||
vals.push($($checkboxes[i]).html());
|
||||
@@ -43,10 +45,16 @@
|
||||
return vals.join(', ');
|
||||
}
|
||||
|
||||
$('[data-drupal-selector="edit-visibility-node-type"], [data-drupal-selector="edit-visibility-language"], [data-drupal-selector="edit-visibility-user-role"]').drupalSetSummary(checkboxesSummary);
|
||||
$(
|
||||
'[data-drupal-selector="edit-visibility-node-type"], [data-drupal-selector="edit-visibility-language"], [data-drupal-selector="edit-visibility-user-role"]',
|
||||
).drupalSetSummary(checkboxesSummary);
|
||||
|
||||
$('[data-drupal-selector="edit-visibility-request-path"]').drupalSetSummary((context) => {
|
||||
const $pages = $(context).find('textarea[name="visibility[request_path][pages]"]');
|
||||
$(
|
||||
'[data-drupal-selector="edit-visibility-request-path"]',
|
||||
).drupalSetSummary(context => {
|
||||
const $pages = $(context).find(
|
||||
'textarea[name="visibility[request_path][pages]"]',
|
||||
);
|
||||
if (!$pages.val()) {
|
||||
return Drupal.t('Not restricted');
|
||||
}
|
||||
@@ -70,7 +78,10 @@
|
||||
Drupal.behaviors.blockDrag = {
|
||||
attach(context, settings) {
|
||||
// tableDrag is required and we should be on the blocks admin page.
|
||||
if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag.blocks === 'undefined') {
|
||||
if (
|
||||
typeof Drupal.tableDrag === 'undefined' ||
|
||||
typeof Drupal.tableDrag.blocks === 'undefined'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,19 +94,25 @@
|
||||
* The jQuery object representing the table row.
|
||||
*/
|
||||
function checkEmptyRegions(table, rowObject) {
|
||||
table.find('tr.region-message').each(function () {
|
||||
table.find('tr.region-message').each(function() {
|
||||
const $this = $(this);
|
||||
// If the dragged row is in this region, but above the message row,
|
||||
// swap it down one space.
|
||||
if ($this.prev('tr').get(0) === rowObject.element) {
|
||||
// Prevent a recursion problem when using the keyboard to move rows
|
||||
// up.
|
||||
if ((rowObject.method !== 'keyboard' || rowObject.direction === 'down')) {
|
||||
if (
|
||||
rowObject.method !== 'keyboard' ||
|
||||
rowObject.direction === 'down'
|
||||
) {
|
||||
rowObject.swap('after', this);
|
||||
}
|
||||
}
|
||||
// This region has become empty.
|
||||
if ($this.next('tr').is(':not(.draggable)') || $this.next('tr').length === 0) {
|
||||
if (
|
||||
$this.next('tr').is(':not(.draggable)') ||
|
||||
$this.next('tr').length === 0
|
||||
) {
|
||||
$this.removeClass('region-populated').addClass('region-empty');
|
||||
}
|
||||
// This region has become populated.
|
||||
@@ -136,33 +153,40 @@
|
||||
// Calculate minimum weight.
|
||||
let weight = -Math.round(table.find('.draggable').length / 2);
|
||||
// Update the block weights.
|
||||
table.find(`.region-${region}-message`).nextUntil('.region-title')
|
||||
.find('select.block-weight').val(() =>
|
||||
table
|
||||
.find(`.region-${region}-message`)
|
||||
.nextUntil('.region-title')
|
||||
.find('select.block-weight')
|
||||
.val(
|
||||
// Increment the weight before assigning it to prevent using the
|
||||
// absolute minimum available weight. This way we always have an
|
||||
// unused upper and lower bound, which makes manually setting the
|
||||
// weights easier for users who prefer to do it that way.
|
||||
++weight);
|
||||
() => ++weight,
|
||||
);
|
||||
}
|
||||
|
||||
const table = $('#blocks');
|
||||
// Get the blocks tableDrag object.
|
||||
const tableDrag = Drupal.tableDrag.blocks;
|
||||
// Add a handler for when a row is swapped, update empty regions.
|
||||
tableDrag.row.prototype.onSwap = function (swappedRow) {
|
||||
tableDrag.row.prototype.onSwap = function(swappedRow) {
|
||||
checkEmptyRegions(table, this);
|
||||
updateLastPlaced(table, this);
|
||||
};
|
||||
|
||||
// Add a handler so when a row is dropped, update fields dropped into
|
||||
// new regions.
|
||||
tableDrag.onDrop = function () {
|
||||
tableDrag.onDrop = function() {
|
||||
const dragObject = this;
|
||||
const $rowElement = $(dragObject.rowObject.element);
|
||||
// Use "region-message" row instead of "region" row because
|
||||
// "region-{region_name}-message" is less prone to regexp match errors.
|
||||
const regionRow = $rowElement.prevAll('tr.region-message').get(0);
|
||||
const regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
||||
const regionName = regionRow.className.replace(
|
||||
/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/,
|
||||
'$2',
|
||||
);
|
||||
const regionField = $rowElement.find('select.block-region-select');
|
||||
// Check whether the newly picked region is available for this block.
|
||||
if (regionField.find(`option[value=${regionName}]`).length === 0) {
|
||||
@@ -177,9 +201,16 @@
|
||||
// Update region and weight fields if the region has been changed.
|
||||
if (!regionField.is(`.block-region-${regionName}`)) {
|
||||
const weightField = $rowElement.find('select.block-weight');
|
||||
const oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
|
||||
regionField.removeClass(`block-region-${oldRegionName}`).addClass(`block-region-${regionName}`);
|
||||
weightField.removeClass(`block-weight-${oldRegionName}`).addClass(`block-weight-${regionName}`);
|
||||
const oldRegionName = weightField[0].className.replace(
|
||||
/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/,
|
||||
'$2',
|
||||
);
|
||||
regionField
|
||||
.removeClass(`block-region-${oldRegionName}`)
|
||||
.addClass(`block-region-${regionName}`);
|
||||
weightField
|
||||
.removeClass(`block-weight-${oldRegionName}`)
|
||||
.addClass(`block-weight-${regionName}`);
|
||||
regionField.val(regionName);
|
||||
}
|
||||
|
||||
@@ -187,16 +218,22 @@
|
||||
};
|
||||
|
||||
// Add the behavior to each region select list.
|
||||
$(context).find('select.block-region-select').once('block-region-select')
|
||||
.on('change', function (event) {
|
||||
$(context)
|
||||
.find('select.block-region-select')
|
||||
.once('block-region-select')
|
||||
.on('change', function(event) {
|
||||
// Make our new row and select field.
|
||||
const row = $(this).closest('tr');
|
||||
const select = $(this);
|
||||
// Find the correct region and insert the row as the last in the
|
||||
// region.
|
||||
tableDrag.rowObject = new tableDrag.row(row[0]);
|
||||
const regionMessage = table.find(`.region-${select[0].value}-message`);
|
||||
const regionItems = regionMessage.nextUntil('.region-message, .region-title');
|
||||
const regionMessage = table.find(
|
||||
`.region-${select[0].value}-message`,
|
||||
);
|
||||
const regionItems = regionMessage.nextUntil(
|
||||
'.region-message, .region-title',
|
||||
);
|
||||
if (regionItems.length) {
|
||||
regionItems.last().after(row);
|
||||
}
|
||||
@@ -211,7 +248,10 @@
|
||||
updateLastPlaced(table, row);
|
||||
// Show unsaved changes warning.
|
||||
if (!tableDrag.changed) {
|
||||
$(Drupal.theme('tableDragChangedWarning')).insertBefore(tableDrag.table).hide().fadeIn('slow');
|
||||
$(Drupal.theme('tableDragChangedWarning'))
|
||||
.insertBefore(tableDrag.table)
|
||||
.hide()
|
||||
.fadeIn('slow');
|
||||
tableDrag.changed = true;
|
||||
}
|
||||
// Remove focus from selectbox.
|
||||
@@ -219,4 +259,4 @@
|
||||
});
|
||||
},
|
||||
};
|
||||
}(jQuery, window, Drupal));
|
||||
})(jQuery, window, Drupal);
|
||||
|
||||
Reference in New Issue
Block a user