Backup of db before drupal security update
[yaffs-website] / web / core / misc / entity-form.js
1 /**
2  * @file
3  * Defines Javascript behaviors for the block_content module.
4  */
5
6 (function ($, Drupal) {
7
8   'use strict';
9
10   /**
11    * Sets summaries about revision and translation of entities.
12    *
13    * @type {Drupal~behavior}
14    *
15    * @prop {Drupal~behaviorAttach} attach
16    *   Attaches summary behaviour entity form tabs.
17    *
18    *   Specifically, it updates summaries to the revision information and the
19    *   translation options.
20    */
21   Drupal.behaviors.entityContentDetailsSummaries = {
22     attach: function (context) {
23       var $context = $(context);
24       $context.find('.entity-content-form-revision-information').drupalSetSummary(function (context) {
25         var $revisionContext = $(context);
26         var revisionCheckbox = $revisionContext.find('.js-form-item-revision input');
27
28         // Return 'New revision' if the 'Create new revision' checkbox is checked,
29         // or if the checkbox doesn't exist, but the revision log does. For users
30         // without the "Administer content" permission the checkbox won't appear,
31         // but the revision log will if the content type is set to auto-revision.
32         if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $revisionContext.find('.js-form-item-revision-log textarea').length)) {
33           return Drupal.t('New revision');
34         }
35
36         return Drupal.t('No revision');
37       });
38
39       $context.find('details.entity-translation-options').drupalSetSummary(function (context) {
40         var $translationContext = $(context);
41         var translate;
42         var $checkbox = $translationContext.find('.js-form-item-translation-translate input');
43
44         if ($checkbox.length) {
45           translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated');
46         }
47         else {
48           $checkbox = $translationContext.find('.js-form-item-translation-retranslate input');
49           translate = $checkbox.is(':checked') ? Drupal.t('Flag other translations as outdated') : Drupal.t('Do not flag other translations as outdated');
50         }
51
52         return translate;
53       });
54     }
55   };
56
57 })(jQuery, Drupal);