Prevent DOM pollution when having many confirmation dialogs.
Append confirmation dialog on show and detach it on hide.
HFJ-1969
(cherry picked from commit 0a63d12
)
h5p-prerequisites-validator
parent
c2f5feaae5
commit
eba774c863
|
@ -141,14 +141,12 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
||||||
var wrapperElement;
|
var wrapperElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append confirmation dialog
|
* Set parent of confirmation dialog
|
||||||
* @param {HTMLElement} wrapper
|
* @param {HTMLElement} wrapper
|
||||||
* @returns {H5P.ConfirmationDialog}
|
* @returns {H5P.ConfirmationDialog}
|
||||||
*/
|
*/
|
||||||
this.appendTo = function (wrapper) {
|
this.appendTo = function (wrapper) {
|
||||||
wrapper.appendChild(popupBackground);
|
|
||||||
wrapperElement = wrapper;
|
wrapperElement = wrapper;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -182,6 +180,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
||||||
* @returns {H5P.ConfirmationDialog}
|
* @returns {H5P.ConfirmationDialog}
|
||||||
*/
|
*/
|
||||||
this.show = function (offsetTop) {
|
this.show = function (offsetTop) {
|
||||||
|
wrapperElement.appendChild(popupBackground);
|
||||||
popupBackground.classList.remove('hidden');
|
popupBackground.classList.remove('hidden');
|
||||||
fitToContainer(offsetTop);
|
fitToContainer(offsetTop);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
@ -215,6 +214,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
||||||
popup.classList.add('hidden');
|
popup.classList.add('hidden');
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
popupBackground.classList.add('hidden');
|
popupBackground.classList.add('hidden');
|
||||||
|
wrapperElement.removeChild(popupBackground);
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in New Issue