Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / system / tests / modules / ajax_test / js / insert-ajax.es6.js
1 /**
2  * @file
3  * Drupal behavior to attach click event handlers to ajax-insert and
4  * ajax-insert-inline links for testing ajax requests.
5  */
6
7 (function($, window, Drupal) {
8   Drupal.behaviors.insertTest = {
9     attach(context) {
10       $('.ajax-insert')
11         .once('ajax-insert')
12         .on('click', event => {
13           event.preventDefault();
14           const ajaxSettings = {
15             url: event.currentTarget.getAttribute('href'),
16             wrapper: 'ajax-target',
17             base: false,
18             element: false,
19             method: event.currentTarget.getAttribute('data-method'),
20             effect: event.currentTarget.getAttribute('data-effect'),
21           };
22           const myAjaxObject = Drupal.ajax(ajaxSettings);
23           myAjaxObject.execute();
24         });
25
26       $('.ajax-insert-inline')
27         .once('ajax-insert')
28         .on('click', event => {
29           event.preventDefault();
30           const ajaxSettings = {
31             url: event.currentTarget.getAttribute('href'),
32             wrapper: 'ajax-target-inline',
33             base: false,
34             element: false,
35             method: event.currentTarget.getAttribute('data-method'),
36             effect: event.currentTarget.getAttribute('data-effect'),
37           };
38           const myAjaxObject = Drupal.ajax(ajaxSettings);
39           myAjaxObject.execute();
40         });
41
42       $(context).addClass('processed');
43     },
44   };
45 })(jQuery, window, Drupal);