PageSourceSearch

https://social.tn/core/misc/dialog/dialog.ajax.js?v=9.1.4

js social.tn collected 2026-10-02 14:51:41 UTC 4,017 bytes, 134 lines download raw bytes

1/**
2* DO NOT EDIT THIS FILE.
3* See the following change record for more information,
4* https://www.drupal.org/node/2815083
5* @preserve
6**/
7
8(function ($, Drupal) {
9  Drupal.behaviors.dialog = {
10    attach: function attach(context, settings) {
11      var $context = $(context);
12
13      if (!$('#drupal-modal').length) {
14        $('<div id="drupal-modal" class="ui-front"></div>').hide().appendTo('body');
15      }
16
17      var $dialog = $context.closest('.ui-dialog-content');
18
19      if ($dialog.length) {
20        if ($dialog.dialog('option', 'drupalAutoButtons')) {
21          $dialog.trigger('dialogButtonsChange');
22        }
23
24        $dialog.dialog('widget').trigger('focus');
25      }
26
27      var originalClose = settings.dialog.close;
28
29      settings.dialog.close = function (event) {
30        for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
31          args[_key - 1] = arguments[_key];
32        }
33
34        originalClose.apply(settings.dialog, [event].concat(args));
35        $(event.target).remove();
36      };
37    },
38    prepareDialogButtons: function prepareDialogButtons($dialog) {
39      var buttons = [];
40      var $buttons = $dialog.find('.form-actions input[type=submit], .form-actions a.button');
41      $buttons.each(function () {
42        var $originalButton = $(this).css({
43          display: 'none'
44        });
45        buttons.push({
46          text: $originalButton.html() || $originalButton.attr('value'),
47          class: $originalButton.attr('class'),
48          click: function click(e) {
49            if ($originalButton.is('a')) {
50              $originalButton[0].click();
51            } else {
52              $originalButton.trigger('mousedown').trigger('mouseup').trigger('click');
53              e.preventDefault();
54            }
55          }
56        });
57      });
58      return buttons;
59    }
60  };
61
62  Drupal.AjaxCommands.prototype.openDialog = function (ajax, response, status) {
63    if (!response.selector) {
64      return false;
65    }
66
67    var $dialog = $(response.selector);
68
69    if (!$dialog.length) {
70      $dialog = $("<div id=\"".concat(response.selector.replace(/^#/, ''), "\" class=\"ui-front\"></div>")).appendTo('body');
71    }
72
73    if (!ajax.wrapper) {
74      ajax.wrapper = $dialog.attr('id');
75    }
76
77    response.command = 'insert';
78    response.method = 'html';
79    ajax.commands.insert(ajax, response, status);
80
81    if (!response.dialogOptions.buttons) {
82      response.dialogOptions.drupalAutoButtons = true;
83      response.dialogOptions.buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
84    }
85
86    $dialog.on('dialogButtonsChange', function () {
87      var buttons = Drupal.behaviors.dialog.prepareDialogButtons($dialog);
88      $dialog.dialog('option', 'buttons', buttons);
89    });
90    response.dialogOptions = response.dialogOptions || {};
91    var dialog = Drupal.dialog($dialog.get(0), response.dialogOptions);
92
93    if (response.dialogOptions.modal) {
94      dialog.showModal();
95    } else {
96      dialog.show();
97    }
98
99    $dialog.parent().find('.ui-dialog-buttonset').addClass('form-actions');
100  };
101
102  Drupal.AjaxCommands.prototype.closeDialog = function (ajax, response, status) {
103    var $dialog = $(response.selector);
104
105    if ($dialog.length) {
106      Drupal.dialog($dialog.get(0)).close();
107
108      if (!response.persist) {
109        $dialog.remove();
110      }
111    }
112
113    $dialog.off('dialogButtonsChange');
114  };
115
116  Drupal.AjaxCommands.prototype.setDialogOption = function (ajax, response, status) {
117    var $dialog = $(response.selector);
118
119    if ($dialog.length) {
120      $dialog.dialog('option', response.optionName, response.optionValue);
121    }
122  };
123
124  $(window).on('dialog:aftercreate', function (e, dialog, $element, settings) {
125    $element.on('click.dialog', '.dialog-cancel', function (e) {
126      dialog.close('cancel');
127      e.preventDefault();
128      e.stopPropagation();
129    });
130  });
131  $(window).on('dialog:beforeclose', function (e, dialog, $element) {
132    $element.off('.dialog');
133  });
134})(jQuery, Drupal);

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.