This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/web/core/misc/dialog/dialog.js

56 lines
1.5 KiB
JavaScript
Raw Normal View History

/**
2018-11-23 12:29:20 +00:00
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal, drupalSettings) {
drupalSettings.dialog = {
autoOpen: true,
dialogClass: '',
2018-11-23 12:29:20 +00:00
buttonClass: 'button',
buttonPrimaryClass: 'button--primary',
2018-11-23 12:29:20 +00:00
close: function close(event) {
Drupal.dialog(event.target).close();
Drupal.detachBehaviors(event.target, null, 'unload');
}
};
Drupal.dialog = function (element, options) {
2018-11-23 12:29:20 +00:00
var undef = void 0;
var $element = $(element);
var dialog = {
open: false,
2018-11-23 12:29:20 +00:00
returnValue: undef
};
function openDialog(settings) {
settings = $.extend({}, drupalSettings.dialog, options, settings);
2018-11-23 12:29:20 +00:00
$(window).trigger('dialog:beforecreate', [dialog, $element, settings]);
$element.dialog(settings);
dialog.open = true;
$(window).trigger('dialog:aftercreate', [dialog, $element, settings]);
}
function closeDialog(value) {
$(window).trigger('dialog:beforeclose', [dialog, $element]);
$element.dialog('close');
dialog.returnValue = value;
dialog.open = false;
$(window).trigger('dialog:afterclose', [dialog, $element]);
}
2018-11-23 12:29:20 +00:00
dialog.show = function () {
openDialog({ modal: false });
};
dialog.showModal = function () {
openDialog({ modal: true });
};
dialog.close = closeDialog;
return dialog;
};
2018-11-23 12:29:20 +00:00
})(jQuery, Drupal, drupalSettings);