PageSourceSearch

https://www.ucg.org/core/misc/dialog/dialog-deprecation.js?v=11.3.16

js ucg.org collected 2026-09-24 09:20:59 UTC 2,070 bytes, 58 lines download raw bytes

1/**
2 * @file
3 * Maintains and deprecates Dialog jQuery events.
4 */
5
6(function ($, Drupal, once) {
7  if (once('drupal-dialog-deprecation-listener', 'html').length) {
8    const eventSpecial = {
9      handle($event) {
10        const $element = $($event.target);
11        const event = $event.originalEvent;
12        const dialog = event.dialog;
13        const dialogArguments = [$event, dialog, $element, event?.settings];
14        $event.handleObj.handler.apply(this, dialogArguments);
15      },
16    };
17
18    $.event.special['dialog:beforecreate'] = eventSpecial;
19    $.event.special['dialog:aftercreate'] = eventSpecial;
20    $.event.special['dialog:beforeclose'] = eventSpecial;
21    $.event.special['dialog:afterclose'] = eventSpecial;
22
23    const listenDialogEvent = (event) => {
24      const windowEvents = $._data(window, 'events');
25      const isWindowHasDialogListener = windowEvents[event.type];
26      if (isWindowHasDialogListener) {
27        Drupal.deprecationError({
28          message: `jQuery event ${event.type} is deprecated in 10.3.0 and is removed from Drupal:12.0.0. See https://www.drupal.org/node/3422670`,
29        });
30      }
31    };
32
33    [
34      'dialog:beforecreate',
35      'dialog:aftercreate',
36      'dialog:beforeclose',
37      'dialog:afterclose',
38    ].forEach((e) => window.addEventListener(e, listenDialogEvent));
39
40    window.addEventListener('dialog:beforecreate', (event) => {
41      const dialog = event.target;
42      $(dialog).on('dialogButtonsChange.dialogDeprecation', (e) => {
43        // If triggered by jQuery.
44        if (!e?.originalEvent) {
45          Drupal.deprecationError({
46            message: `jQuery event dialogButtonsChange is deprecated in 11.2.0 and is removed from Drupal:12.0.0. See https://www.drupal.org/node/3464202`,
47          });
48          dialog.dispatchEvent(new CustomEvent('dialogButtonsChange'));
49        }
50      });
51    });
52
53    window.addEventListener('dialog:beforeclose', (event) => {
54      const dialog = event.target;
55      $(dialog).off(`dialogButtonsChange.dialogDeprecation`);
56    });
57  }
58})(jQuery, Drupal, once);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.