forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
21 lines
601 B
JavaScript
21 lines
601 B
JavaScript
/**
|
|
* @file
|
|
* Defines Javascript behaviors for the flag module.
|
|
*/
|
|
|
|
(function ($, Drupal) {
|
|
Drupal.behaviors.flagsSummary = {
|
|
attach: (context) => {
|
|
const $context = $(context);
|
|
$context.find('details[data-drupal-selector="edit-flag"]').drupalSetSummary((context) => {
|
|
const checkedBoxes = $(context).find('input:checkbox:checked');
|
|
if (checkedBoxes.length === 0) {
|
|
return Drupal.t('No flags');
|
|
}
|
|
const getTitle = () => this.title;
|
|
return checkedBoxes.map(getTitle).toArray().join(', ');
|
|
});
|
|
},
|
|
};
|
|
}(jQuery, Drupal));
|