summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/system/js/system.js
diff options
context:
space:
mode:
authorAlex Pott <alex.a.pott@googlemail.com>2017-05-19 23:12:53 +0100
committerAlex Pott <alex.a.pott@googlemail.com>2017-05-19 23:12:53 +0100
commit8287017e034bc323dec1d86b3f37a804aa082d2d (patch)
treeebd8ff908859b0e1cc4319392da94e8f68033321 /core/modules/system/js/system.js
parent9a0e9a649ac8078ce6e5f6089749a1115bdda06b (diff)
downloaddrupal-8287017e034bc323dec1d86b3f37a804aa082d2d.tar.gz
drupal-8287017e034bc323dec1d86b3f37a804aa082d2d.zip
Issue #2818825 by drpal, nod_, droplet, cilefen: Rename all JS files to *.es6.js and compile them
Diffstat (limited to 'core/modules/system/js/system.js')
-rw-r--r--core/modules/system/js/system.js57
1 files changed, 12 insertions, 45 deletions
diff --git a/core/modules/system/js/system.js b/core/modules/system/js/system.js
index 82f0de66871..56c29f433d7 100644
--- a/core/modules/system/js/system.js
+++ b/core/modules/system/js/system.js
@@ -1,81 +1,48 @@
/**
- * @file
- * System behaviors.
- */
+* DO NOT EDIT THIS FILE.
+* All changes should be applied to ./modules/system/js/system.es6.js
+* See the following change record for more information,
+* https://www.drupal.org/node/2873849
+* @preserve
+**/
(function ($, Drupal, drupalSettings) {
'use strict';
- // Cache IDs in an array for ease of use.
var ids = [];
- /**
- * Attaches field copy behavior from input fields to other input fields.
- *
- * When a field is filled out, apply its value to other fields that will
- * likely use the same value. In the installer this is used to populate the
- * administrator email address with the same value as the site email address.
- *
- * @type {Drupal~behavior}
- *
- * @prop {Drupal~behaviorAttach} attach
- * Attaches the field copy behavior to an input field.
- */
Drupal.behaviors.copyFieldValue = {
- attach: function (context) {
- // List of fields IDs on which to bind the event listener.
- // Create an array of IDs to use with jQuery.
+ attach: function attach(context) {
for (var sourceId in drupalSettings.copyFieldValue) {
if (drupalSettings.copyFieldValue.hasOwnProperty(sourceId)) {
ids.push(sourceId);
}
}
if (ids.length) {
- // Listen to value:copy events on all dependent fields.
- // We have to use body and not document because of the way jQuery events
- // bubble up the DOM tree.
$('body').once('copy-field-values').on('value:copy', this.valueTargetCopyHandler);
- // Listen on all source elements.
+
$('#' + ids.join(', #')).once('copy-field-values').on('blur', this.valueSourceBlurHandler);
}
},
- detach: function (context, settings, trigger) {
+ detach: function detach(context, settings, trigger) {
if (trigger === 'unload' && ids.length) {
$('body').removeOnce('copy-field-values').off('value:copy');
$('#' + ids.join(', #')).removeOnce('copy-field-values').off('blur');
}
},
- /**
- * Event handler that fill the target element with the specified value.
- *
- * @param {jQuery.Event} e
- * Event object.
- * @param {string} value
- * Custom value from jQuery trigger.
- */
- valueTargetCopyHandler: function (e, value) {
+ valueTargetCopyHandler: function valueTargetCopyHandler(e, value) {
var $target = $(e.target);
if ($target.val() === '') {
$target.val(value);
}
},
- /**
- * Handler for a Blur event on a source field.
- *
- * This event handler will trigger a 'value:copy' event on all dependent
- * fields.
- *
- * @param {jQuery.Event} e
- * The event triggered.
- */
- valueSourceBlurHandler: function (e) {
+ valueSourceBlurHandler: function valueSourceBlurHandler(e) {
var value = $(e.target).val();
var targetIds = drupalSettings.copyFieldValue[e.target.id];
$('#' + targetIds.join(', #')).trigger('value:copy', value);
}
};
-
-})(jQuery, Drupal, drupalSettings);
+})(jQuery, Drupal, drupalSettings); \ No newline at end of file