2012-11-10 15:25:19 +00:00
|
|
|
/**
|
2022-09-09 06:26:42 +00:00
|
|
|
* @file
|
|
|
|
* Defines JavaScript behaviors for the node module.
|
|
|
|
*/
|
2012-11-10 15:25:19 +00:00
|
|
|
|
2013-09-21 23:39:42 +00:00
|
|
|
(function ($, Drupal, drupalSettings) {
|
2022-09-09 06:26:42 +00:00
|
|
|
/**
|
|
|
|
* Behaviors for tabs in the node edit form.
|
|
|
|
*
|
|
|
|
* @type {Drupal~behavior}
|
|
|
|
*
|
|
|
|
* @prop {Drupal~behaviorAttach} attach
|
|
|
|
* Attaches summary behavior for tabs in the node edit form.
|
|
|
|
*/
|
2014-01-27 21:41:32 +00:00
|
|
|
Drupal.behaviors.nodeDetailsSummaries = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context) {
|
|
|
|
const $context = $(context);
|
2022-09-09 06:26:42 +00:00
|
|
|
|
|
|
|
$context.find('.node-form-author').drupalSetSummary((context) => {
|
2022-01-17 16:08:33 +00:00
|
|
|
const nameElement = context.querySelector('.field--name-uid input');
|
|
|
|
const name = nameElement && nameElement.value;
|
|
|
|
const dateElement = context.querySelector('.field--name-created input');
|
|
|
|
const date = dateElement && dateElement.value;
|
2015-12-10 14:56:01 +00:00
|
|
|
|
|
|
|
if (name && date) {
|
2018-08-09 15:49:18 +00:00
|
|
|
return Drupal.t('By @name on @date', {
|
|
|
|
'@name': name,
|
2022-09-09 06:26:42 +00:00
|
|
|
'@date': date,
|
2018-08-09 15:49:18 +00:00
|
|
|
});
|
2018-07-05 15:50:52 +00:00
|
|
|
}
|
|
|
|
if (name) {
|
2022-09-09 06:26:42 +00:00
|
|
|
return Drupal.t('By @name', { '@name': name });
|
2018-07-05 15:50:52 +00:00
|
|
|
}
|
|
|
|
if (date) {
|
2022-09-09 06:26:42 +00:00
|
|
|
return Drupal.t('Authored on @date', { '@date': date });
|
2015-12-10 14:56:01 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
2022-09-09 06:26:42 +00:00
|
|
|
|
|
|
|
$context.find('.node-form-options').drupalSetSummary((context) => {
|
2021-12-18 06:12:16 +00:00
|
|
|
const $optionsContext = $(context);
|
2023-01-16 16:36:05 +00:00
|
|
|
const values = [];
|
2009-04-11 22:19:46 +00:00
|
|
|
|
2023-06-26 07:01:04 +00:00
|
|
|
if ($optionsContext.find('input:checked').length) {
|
2022-09-09 06:26:42 +00:00
|
|
|
$optionsContext
|
|
|
|
.find('input:checked')
|
|
|
|
.next('label')
|
|
|
|
.each(function () {
|
2023-01-16 16:36:05 +00:00
|
|
|
values.push(Drupal.checkPlain(this.textContent.trim()));
|
2022-09-09 06:26:42 +00:00
|
|
|
});
|
2023-01-16 16:36:05 +00:00
|
|
|
return values.join(', ');
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2017-07-06 06:21:40 +00:00
|
|
|
|
|
|
|
return Drupal.t('Not promoted');
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
2022-09-09 06:26:42 +00:00
|
|
|
},
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2022-09-09 06:26:42 +00:00
|
|
|
})(jQuery, Drupal, drupalSettings);
|