Mercurial > hg > cmmr2012-drupal-site
comparison core/misc/dialog/dialog.es6.js @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
3 * Dialog API inspired by HTML5 dialog element. | 3 * Dialog API inspired by HTML5 dialog element. |
4 * | 4 * |
5 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#the-dialog-element | 5 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#the-dialog-element |
6 */ | 6 */ |
7 | 7 |
8 (function ($, Drupal, drupalSettings) { | 8 (function($, Drupal, drupalSettings) { |
9 /** | 9 /** |
10 * Default dialog options. | 10 * Default dialog options. |
11 * | 11 * |
12 * @type {object} | 12 * @type {object} |
13 * | 13 * |
57 * jQuery UI options to be passed to the dialog. | 57 * jQuery UI options to be passed to the dialog. |
58 * | 58 * |
59 * @return {Drupal.dialog~dialogDefinition} | 59 * @return {Drupal.dialog~dialogDefinition} |
60 * The dialog instance. | 60 * The dialog instance. |
61 */ | 61 */ |
62 Drupal.dialog = function (element, options) { | 62 Drupal.dialog = function(element, options) { |
63 let undef; | 63 let undef; |
64 const $element = $(element); | 64 const $element = $(element); |
65 const dialog = { | 65 const dialog = { |
66 open: false, | 66 open: false, |
67 returnValue: undef, | 67 returnValue: undef, |
68 show() { | |
69 openDialog({ modal: false }); | |
70 }, | |
71 showModal() { | |
72 openDialog({ modal: true }); | |
73 }, | |
74 close: closeDialog, | |
75 }; | 68 }; |
76 | 69 |
77 function openDialog(settings) { | 70 function openDialog(settings) { |
78 settings = $.extend({}, drupalSettings.dialog, options, settings); | 71 settings = $.extend({}, drupalSettings.dialog, options, settings); |
79 // Trigger a global event to allow scripts to bind events to the dialog. | 72 // Trigger a global event to allow scripts to bind events to the dialog. |
89 dialog.returnValue = value; | 82 dialog.returnValue = value; |
90 dialog.open = false; | 83 dialog.open = false; |
91 $(window).trigger('dialog:afterclose', [dialog, $element]); | 84 $(window).trigger('dialog:afterclose', [dialog, $element]); |
92 } | 85 } |
93 | 86 |
87 dialog.show = () => { | |
88 openDialog({ modal: false }); | |
89 }; | |
90 dialog.showModal = () => { | |
91 openDialog({ modal: true }); | |
92 }; | |
93 dialog.close = closeDialog; | |
94 | |
94 return dialog; | 95 return dialog; |
95 }; | 96 }; |
96 }(jQuery, Drupal, drupalSettings)); | 97 })(jQuery, Drupal, drupalSettings); |