2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
8 (function ($, Drupal, drupalSettings) {
11 Drupal.behaviors.copyFieldValue = {
12 attach: function attach(context) {
13 Object.keys(drupalSettings.copyFieldValue || {}).forEach(function (element) {
18 $('body').once('copy-field-values').on('value:copy', this.valueTargetCopyHandler);
20 $('#' + ids.join(', #')).once('copy-field-values').on('blur', this.valueSourceBlurHandler);
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');
29 valueTargetCopyHandler: function valueTargetCopyHandler(e, value) {
30 var $target = $(e.target);
31 if ($target.val() === '') {
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);
41 })(jQuery, Drupal, drupalSettings);