9bd8b554e4e1e590fcf46623779be18f03fd0207
[yaffs-website] / web / core / misc / dialog / dialog.js
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, drupalSettings) {
9   drupalSettings.dialog = {
10     autoOpen: true,
11     dialogClass: '',
12
13     buttonClass: 'button',
14     buttonPrimaryClass: 'button--primary',
15     close: function close(event) {
16       Drupal.dialog(event.target).close();
17       Drupal.detachBehaviors(event.target, null, 'unload');
18     }
19   };
20
21   Drupal.dialog = function (element, options) {
22     var undef = void 0;
23     var $element = $(element);
24     var dialog = {
25       open: false,
26       returnValue: undef
27     };
28
29     function openDialog(settings) {
30       settings = $.extend({}, drupalSettings.dialog, options, settings);
31
32       $(window).trigger('dialog:beforecreate', [dialog, $element, settings]);
33       $element.dialog(settings);
34       dialog.open = true;
35       $(window).trigger('dialog:aftercreate', [dialog, $element, settings]);
36     }
37
38     function closeDialog(value) {
39       $(window).trigger('dialog:beforeclose', [dialog, $element]);
40       $element.dialog('close');
41       dialog.returnValue = value;
42       dialog.open = false;
43       $(window).trigger('dialog:afterclose', [dialog, $element]);
44     }
45
46     dialog.show = function () {
47       openDialog({ modal: false });
48     };
49     dialog.showModal = function () {
50       openDialog({ modal: true });
51     };
52     dialog.close = closeDialog;
53
54     return dialog;
55   };
56 })(jQuery, Drupal, drupalSettings);