54
* An optional function (must return a string) that will be run to
55
* populate the form_content of the confirmation overlay when it's
58
* @attribute form_content_fn
68
* An optional function (must return a string) that will be run to
69
* populate the header_content of the confirmation overlay when it's
72
* @attribute header_content_fn
82
* An optional function (must return a boolean) that will be run to
83
* before the confirmation overlay is shown to decide whether it
84
* should really be displayed.
86
* @attribute display_confirmation_fn
91
display_confirmation_fn: {
56
96
Y.extend(ConfirmationOverlay, Y.lazr.FormOverlay, {
65
105
this.set('form_submit_button', submit_button);
66
106
this.set('form_cancel_button', cancel_button);
108
this.set('form', this.get('button').ancestor('form'));
110
// When ok is clicked, submit the form.
69
112
var submit_form = function() {
70
self.createHiddenDispatcher();
113
self._createHiddenDispatcher();
71
114
self.get('form').submit();
73
116
this.set('form_submit_callback', submit_form);
75
this._set('destroy_on_hide', true);
118
// Enable the button if it's disabled.
119
this.get('button').set('disabled', false);
121
// Wire this._handleButtonClicked to the button.
123
'button').on('click', Y.bind(this._handleButtonClicked, this));
129
_handleButtonClicked: function(e) {
130
var display_confirmation_fn = this.get('display_confirmation_fn');
131
if (display_confirmation_fn === null || display_confirmation_fn()) {
132
// Stop the event to prevent the form submission.
134
// Update the overlay's content.
136
this._positionOverlay();
137
// Render and display the overlay.
139
this._setFormContent();
144
_fillContent: function() {
145
var form_content_fn = this.get('form_content_fn');
146
if (form_content_fn !== null) {
147
this.set('form_content', form_content_fn());
149
var header_content_fn = this.get('header_content_fn');
150
if (header_content_fn !== null) {
151
this.set('form_header', header_content_fn());
155
_positionOverlay: function() {
77
156
// Center the overlay in the viewport.
81
160
Y.WidgetPositionAlign.CC,
82
161
Y.WidgetPositionAlign.CC]
87
createHiddenDispatcher: function() {
165
_createHiddenDispatcher: function() {
166
// Create a hidden input to simulate the click on the right
88
168
var dispatcher = Y.Node.create('<input>')
89
169
.set('type', 'hidden')
90
170
.set('name', this.get('button').get('name'))