e7c01dd88a3299d0f5271deda108f094c89dcbe0
[yaffs-website] / web / core / modules / node / content_types.es6.js
1 /**
2  * @file
3  * Javascript for the node content editing form.
4  */
5
6 (function ($, Drupal) {
7   /**
8    * Behaviors for setting summaries on content type form.
9    *
10    * @type {Drupal~behavior}
11    *
12    * @prop {Drupal~behaviorAttach} attach
13    *   Attaches summary behaviors on content type edit forms.
14    */
15   Drupal.behaviors.contentTypes = {
16     attach(context) {
17       const $context = $(context);
18       // Provide the vertical tab summaries.
19       $context.find('#edit-submission').drupalSetSummary((context) => {
20         const vals = [];
21         vals.push(Drupal.checkPlain($(context).find('#edit-title-label').val()) || Drupal.t('Requires a title'));
22         return vals.join(', ');
23       });
24       $context.find('#edit-workflow').drupalSetSummary((context) => {
25         const vals = [];
26         $(context).find('input[name^="options"]:checked').next('label').each(function () {
27           vals.push(Drupal.checkPlain($(this).text()));
28         });
29         if (!$(context).find('#edit-options-status').is(':checked')) {
30           vals.unshift(Drupal.t('Not published'));
31         }
32         return vals.join(', ');
33       });
34       $('#edit-language', context).drupalSetSummary((context) => {
35         const vals = [];
36
37         vals.push($('.js-form-item-language-configuration-langcode select option:selected', context).text());
38
39         $('input:checked', context).next('label').each(function () {
40           vals.push(Drupal.checkPlain($(this).text()));
41         });
42
43         return vals.join(', ');
44       });
45       $context.find('#edit-display').drupalSetSummary((context) => {
46         const vals = [];
47         const $editContext = $(context);
48         $editContext.find('input:checked').next('label').each(function () {
49           vals.push(Drupal.checkPlain($(this).text()));
50         });
51         if (!$editContext.find('#edit-display-submitted').is(':checked')) {
52           vals.unshift(Drupal.t("Don't display post information"));
53         }
54         return vals.join(', ');
55       });
56     },
57   };
58 }(jQuery, Drupal));