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