Initial Drupal 11 with DDEV setup

This commit is contained in:
gluebox
2025-10-08 11:39:17 -04:00
commit 89ef74b305
25344 changed files with 2599172 additions and 0 deletions

View File

@ -0,0 +1,69 @@
/**
* @file
* Provides date format preview feature.
*/
(function ($, Drupal, drupalSettings) {
const dateFormats = drupalSettings.dateFormats;
/**
* Display the preview for date format entered.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attach behavior for previewing date formats on input elements.
*/
Drupal.behaviors.dateFormat = {
attach(context) {
const source = once(
'dateFormat',
'[data-drupal-date-formatter="source"]',
context,
);
const target = once(
'dateFormat',
'[data-drupal-date-formatter="preview"]',
context,
);
// All elements have to exist.
if (!source.length || !target.length) {
return;
}
/**
* Event handler that replaces date characters with value.
*
* @param {jQuery.Event} e
* The jQuery event triggered.
*/
function dateFormatHandler(e) {
const baseValue = e.target.value || '';
const dateString = baseValue.replace(/\\?(.?)/gi, (key, value) =>
dateFormats[key] ? dateFormats[key] : value,
);
// Set date preview.
target.forEach((item) => {
item.querySelectorAll('em').forEach((em) => {
em.textContent = dateString;
});
});
$(target).toggleClass('js-hide', !dateString.length);
}
/**
* On given event triggers the date character replacement.
*/
$(source)
.on(
'keyup.dateFormat change.dateFormat input.dateFormat',
dateFormatHandler,
)
// Initialize preview.
.trigger('keyup');
},
};
})(jQuery, Drupal, drupalSettings);

View File

@ -0,0 +1,82 @@
/**
* @file
* System behaviors.
*/
(function ($, Drupal, drupalSettings) {
// Cache IDs in an array for ease of use.
const ids = [];
/**
* Attaches field copy behavior from input fields to other input fields.
*
* When a field is filled out, apply its value to other fields that will
* likely use the same value. In the installer this is used to populate the
* administrator email address with the same value as the site email address.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches the field copy behavior to an input field.
*/
Drupal.behaviors.copyFieldValue = {
attach(context) {
// List of fields IDs on which to bind the event listener.
// Create an array of IDs to use with jQuery.
Object.keys(drupalSettings.copyFieldValue || {}).forEach((element) => {
ids.push(element);
});
if (ids.length) {
// Listen to value:copy events on all dependent fields.
// We have to use body and not document because of the way jQuery events
// bubble up the DOM tree.
$(once('copy-field-values', 'body')).on(
'value:copy',
this.valueTargetCopyHandler,
);
// Listen on all source elements.
$(once('copy-field-values', `#${ids.join(', #')}`)).on(
'blur',
this.valueSourceBlurHandler,
);
}
},
detach(context, settings, trigger) {
if (trigger === 'unload' && ids.length) {
$(once.remove('copy-field-values', 'body')).off('value:copy');
$(once.remove('copy-field-values', `#${ids.join(', #')}`)).off('blur');
}
},
/**
* Event handler that fill the target element with the specified value.
*
* @param {jQuery.Event} e
* Event object.
* @param {string} value
* Custom value from jQuery trigger.
*/
valueTargetCopyHandler(e, value) {
const { target } = e;
if (target.value === '') {
target.value = value;
}
},
/**
* Handler for a Blur event on a source field.
*
* This event handler will trigger a 'value:copy' event on all dependent
* fields.
*
* @param {jQuery.Event} e
* The event triggered.
*/
valueSourceBlurHandler(e) {
const { value } = e.target;
const targetIds = drupalSettings.copyFieldValue[e.target.id];
$(`#${targetIds.join(', #')}`).trigger('value:copy', value);
},
};
})(jQuery, Drupal, drupalSettings);

View File

@ -0,0 +1,112 @@
/**
* @file
* Module page behaviors.
*/
(function ($, Drupal, debounce) {
/**
* Filters the module list table by a text input search string.
*
* Additionally accounts for multiple tables being wrapped in "package" details
* elements.
*
* Text search input: input.table-filter-text
* Target table: input.table-filter-text[data-table]
* Source text: .table-filter-text-source, .module-name, .module-description
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.tableFilterByText = {
attach(context, settings) {
const [input] = once('table-filter-text', 'input.table-filter-text');
if (!input) {
return;
}
const $table = $(input.getAttribute('data-table'));
let $rowsAndDetails;
let $rows;
let $details;
let searching = false;
function hidePackageDetails(index, element) {
const $packDetails = $(element);
const $visibleRows = $packDetails.find('tbody tr:visible');
$packDetails.toggle($visibleRows.length > 0);
}
function filterModuleList(e) {
const query = e.target.value;
// Case insensitive expression to find query at the beginning of a word.
const re = new RegExp(`\\b${query}`, 'i');
function showModuleRow(index, row) {
const sources = row.querySelectorAll(
'.table-filter-text-source, .module-name, .module-description',
);
let sourcesConcat = '';
// Concatenate the textContent of the elements in the row, with a
// space in between.
sources.forEach((item) => {
sourcesConcat += ` ${item.textContent}`;
});
const textMatch = sourcesConcat.search(re) !== -1;
$(row).closest('tr').toggle(textMatch);
}
// Search over all rows and packages.
$rowsAndDetails.show();
// Filter if the length of the query is at least 2 characters.
if (query.length >= 2) {
searching = true;
$rows.each(showModuleRow);
// Note that we first open all <details> to be able to use ':visible'.
// Mark the <details> elements that were closed before filtering, so
// they can be closed again when filtering is removed.
$details
.not('[open]')
.attr('data-drupal-system-state', 'forced-open');
// Hide the package <details> if they don't have any visible rows.
// Note that we first show() all <details> to be able to use ':visible'.
$details.attr('open', true).each(hidePackageDetails);
Drupal.announce(
Drupal.formatPlural(
$rowsAndDetails.filter('tbody tr:visible').length,
'1 module is available in the modified list.',
'@count modules are available in the modified list.',
),
);
} else if (searching) {
searching = false;
$rowsAndDetails.show();
// Return <details> elements that had been closed before filtering
// to a closed state.
$details
.filter('[data-drupal-system-state="forced-open"]')
.removeAttr('data-drupal-system-state')
.attr('open', false);
}
}
function preventEnterKey(event) {
if (event.which === 13) {
event.preventDefault();
event.stopPropagation();
}
}
if ($table.length) {
$rowsAndDetails = $table.find('tr, details');
$rows = $table.find('tbody tr');
$details = $rowsAndDetails.filter('.package-listing');
$(input).on({
input: debounce(filterModuleList, 200),
keydown: preventEnterKey,
});
}
},
};
})(jQuery, Drupal, Drupal.debounce);