dialog.js 1.5 KB

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