2015-06-05 20:17:55 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-05 20:17:55 +00:00
|
|
|
|
2021-08-10 10:05:02 +00:00
|
|
|
(function ($, window, Drupal, once) {
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.blockSettingsSummary = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach() {
|
2016-02-29 03:25:57 +00:00
|
|
|
if (typeof $.fn.drupalSetSummary === 'undefined') {
|
2014-01-27 21:41:32 +00:00
|
|
|
return;
|
2009-12-07 21:16:31 +00:00
|
|
|
}
|
2012-04-19 17:45:46 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
function checkboxesSummary(context) {
|
2021-12-18 06:12:16 +00:00
|
|
|
const vals = [];
|
|
|
|
const $checkboxes = $(context).find('input[type="checkbox"]:checked + label');
|
|
|
|
const il = $checkboxes.length;
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
for (let i = 0; i < il; i++) {
|
2015-07-05 19:30:01 +00:00
|
|
|
vals.push($($checkboxes[i]).html());
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
if (!vals.length) {
|
|
|
|
vals.push(Drupal.t('Not restricted'));
|
|
|
|
}
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
return vals.join(', ');
|
2009-12-07 21:16:31 +00:00
|
|
|
}
|
|
|
|
|
Issue #1932810 by Berdir, jibran, joegraduate, joelpittet, JeroenT, RenatoG, tim.plunkett, tedbow, andypost, paulocs, hugronaphor, ankithashetty, Meenakshi_j, chr.fritsch, Beanjammin, nikitagupta, EclipseGc, dawehner, xjm, alexpott, fago, tstoeckler, catch, seanB, larowlan: Add entity bundles condition plugin for entities with bundles
2021-07-08 09:22:26 +00:00
|
|
|
$('[data-drupal-selector="edit-visibility-node-type"], [data-drupal-selector="edit-visibility-entity-bundlenode"], [data-drupal-selector="edit-visibility-language"], [data-drupal-selector="edit-visibility-user-role"]').drupalSetSummary(checkboxesSummary);
|
2021-12-18 06:12:16 +00:00
|
|
|
$('[data-drupal-selector="edit-visibility-request-path"]').drupalSetSummary(context => {
|
|
|
|
const $pages = $(context).find('textarea[name="visibility[request_path][pages]"]');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2022-01-17 16:08:33 +00:00
|
|
|
if (!$pages.length || !$pages[0].value) {
|
2014-01-27 21:41:32 +00:00
|
|
|
return Drupal.t('Not restricted');
|
|
|
|
}
|
2017-07-06 06:21:40 +00:00
|
|
|
|
|
|
|
return Drupal.t('Restricted to certain pages');
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
2009-12-07 21:16:31 +00:00
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
|
|
|
Drupal.behaviors.blockDrag = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context, settings) {
|
2014-01-27 21:41:32 +00:00
|
|
|
if (typeof Drupal.tableDrag === 'undefined' || typeof Drupal.tableDrag.blocks === 'undefined') {
|
|
|
|
return;
|
|
|
|
}
|
2007-11-14 09:50:00 +00:00
|
|
|
|
2015-11-26 10:29:45 +00:00
|
|
|
function checkEmptyRegions(table, rowObject) {
|
|
|
|
table.find('tr.region-message').each(function () {
|
2021-12-18 06:12:16 +00:00
|
|
|
const $this = $(this);
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2015-11-26 10:29:45 +00:00
|
|
|
if ($this.prev('tr').get(0) === rowObject.element) {
|
2017-05-19 22:12:53 +00:00
|
|
|
if (rowObject.method !== 'keyboard' || rowObject.direction === 'down') {
|
2015-11-26 10:29:45 +00:00
|
|
|
rowObject.swap('after', this);
|
|
|
|
}
|
|
|
|
}
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2015-11-26 10:29:45 +00:00
|
|
|
if ($this.next('tr').is(':not(.draggable)') || $this.next('tr').length === 0) {
|
|
|
|
$this.removeClass('region-populated').addClass('region-empty');
|
2017-05-19 22:12:53 +00:00
|
|
|
} else if ($this.is('.region-empty')) {
|
2021-10-27 20:02:41 +00:00
|
|
|
$this.removeClass('region-empty').addClass('region-populated');
|
|
|
|
}
|
2015-11-26 10:29:45 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateLastPlaced(table, rowObject) {
|
|
|
|
table.find('.color-success').removeClass('color-success');
|
2021-12-18 06:12:16 +00:00
|
|
|
const $rowObject = $(rowObject);
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2015-11-26 10:29:45 +00:00
|
|
|
if (!$rowObject.is('.drag-previous')) {
|
|
|
|
table.find('.drag-previous').removeClass('drag-previous');
|
|
|
|
$rowObject.addClass('drag-previous');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateBlockWeights(table, region) {
|
2021-12-18 06:12:16 +00:00
|
|
|
let weight = -Math.round(table.find('.draggable').length / 2);
|
2022-01-17 16:08:33 +00:00
|
|
|
table.find(`.region-${region}-message`).nextUntil('.region-title').find('select.block-weight').each(function () {
|
|
|
|
this.value = ++weight;
|
|
|
|
});
|
2015-11-26 10:29:45 +00:00
|
|
|
}
|
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
const table = $('#blocks');
|
|
|
|
const tableDrag = Drupal.tableDrag.blocks;
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
tableDrag.row.prototype.onSwap = function (swappedRow) {
|
|
|
|
checkEmptyRegions(table, this);
|
2015-09-09 13:16:36 +00:00
|
|
|
updateLastPlaced(table, this);
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2007-11-14 09:50:00 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
tableDrag.onDrop = function () {
|
2021-12-18 06:12:16 +00:00
|
|
|
const dragObject = this;
|
|
|
|
const $rowElement = $(dragObject.rowObject.element);
|
|
|
|
const regionRow = $rowElement.prevAll('tr.region-message').get(0);
|
|
|
|
const regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
|
|
|
const regionField = $rowElement.find('select.block-region-select');
|
2017-05-19 22:12:53 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
if (regionField.find(`option[value=${regionName}]`).length === 0) {
|
2014-01-27 21:41:32 +00:00
|
|
|
window.alert(Drupal.t('The block cannot be placed in this region.'));
|
|
|
|
regionField.trigger('change');
|
2008-10-29 10:01:28 +00:00
|
|
|
}
|
2015-08-17 16:49:10 +00:00
|
|
|
|
2021-12-18 06:12:16 +00:00
|
|
|
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}`);
|
2022-01-17 16:08:33 +00:00
|
|
|
regionField[0].value = regionName;
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2015-08-17 16:49:10 +00:00
|
|
|
|
|
|
|
updateBlockWeights(table, regionName);
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2007-11-14 09:50:00 +00:00
|
|
|
|
2021-08-10 10:05:02 +00:00
|
|
|
$(once('block-region-select', 'select.block-region-select', context)).on('change', function (event) {
|
2021-12-18 06:12:16 +00:00
|
|
|
const row = $(this).closest('tr');
|
|
|
|
const select = $(this);
|
2017-05-19 22:12:53 +00:00
|
|
|
tableDrag.rowObject = new tableDrag.row(row[0]);
|
2021-12-18 06:12:16 +00:00
|
|
|
const regionMessage = table.find(`.region-${select[0].value}-message`);
|
|
|
|
const regionItems = regionMessage.nextUntil('.region-message, .region-title');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2017-12-03 16:02:05 +00:00
|
|
|
if (regionItems.length) {
|
|
|
|
regionItems.last().after(row);
|
2017-05-19 22:12:53 +00:00
|
|
|
} else {
|
2021-10-27 20:02:41 +00:00
|
|
|
regionMessage.after(row);
|
|
|
|
}
|
2020-01-28 13:12:54 +00:00
|
|
|
|
2020-01-30 09:08:38 +00:00
|
|
|
updateBlockWeights(table, select[0].value);
|
2017-05-19 22:12:53 +00:00
|
|
|
checkEmptyRegions(table, tableDrag.rowObject);
|
|
|
|
updateLastPlaced(table, row);
|
|
|
|
|
|
|
|
if (!tableDrag.changed) {
|
|
|
|
$(Drupal.theme('tableDragChangedWarning')).insertBefore(tableDrag.table).hide().fadeIn('slow');
|
|
|
|
tableDrag.changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
select.trigger('blur');
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2021-08-10 10:05:02 +00:00
|
|
|
})(jQuery, window, Drupal, once);
|