Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / js / system.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, Drupal, drupalSettings) {
9   var ids = [];
10
11   Drupal.behaviors.copyFieldValue = {
12     attach: function attach(context) {
13       Object.keys(drupalSettings.copyFieldValue || {}).forEach(function (element) {
14         ids.push(element);
15       });
16
17       if (ids.length) {
18         $('body').once('copy-field-values').on('value:copy', this.valueTargetCopyHandler);
19
20         $('#' + ids.join(', #')).once('copy-field-values').on('blur', this.valueSourceBlurHandler);
21       }
22     },
23     detach: function detach(context, settings, trigger) {
24       if (trigger === 'unload' && ids.length) {
25         $('body').removeOnce('copy-field-values').off('value:copy');
26         $('#' + ids.join(', #')).removeOnce('copy-field-values').off('blur');
27       }
28     },
29     valueTargetCopyHandler: function valueTargetCopyHandler(e, value) {
30       var $target = $(e.target);
31       if ($target.val() === '') {
32         $target.val(value);
33       }
34     },
35     valueSourceBlurHandler: function valueSourceBlurHandler(e) {
36       var value = $(e.target).val();
37       var targetIds = drupalSettings.copyFieldValue[e.target.id];
38       $('#' + targetIds.join(', #')).trigger('value:copy', value);
39     }
40   };
41 })(jQuery, Drupal, drupalSettings);