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 for (var sourceId in drupalSettings.copyFieldValue) {
14 if (drupalSettings.copyFieldValue.hasOwnProperty(sourceId)) {
19 $('body').once('copy-field-values').on('value:copy', this.valueTargetCopyHandler);
21 $('#' + ids.join(', #')).once('copy-field-values').on('blur', this.valueSourceBlurHandler);
24 detach: function detach(context, settings, trigger) {
25 if (trigger === 'unload' && ids.length) {
26 $('body').removeOnce('copy-field-values').off('value:copy');
27 $('#' + ids.join(', #')).removeOnce('copy-field-values').off('blur');
30 valueTargetCopyHandler: function valueTargetCopyHandler(e, value) {
31 var $target = $(e.target);
32 if ($target.val() === '') {
36 valueSourceBlurHandler: function valueSourceBlurHandler(e) {
37 var value = $(e.target).val();
38 var targetIds = drupalSettings.copyFieldValue[e.target.id];
39 $('#' + targetIds.join(', #')).trigger('value:copy', value);
42 })(jQuery, Drupal, drupalSettings);