Skip to content

Commit

Permalink
New: Add method to destroy all popups ($.fn.popup.destroyall)
Browse files Browse the repository at this point in the history
Initial version, not stable.
  • Loading branch information
vladimirsiljkovic committed Dec 10, 2018
1 parent ffe6521 commit 2f442eb
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion jquery.popupoverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
} else {

// Handler: Show popup when clicked on `open` element
$(document).on('click', openelement, function (event) {
$(document).on('click.jqp', openelement, function (event) {
event.preventDefault();

var ord = $(this).data('popup-ordinal');
Expand Down Expand Up @@ -831,6 +831,19 @@
});
};

// destroy all popups
$.fn.popup.destroyall = function () {
// TODO: create tests to check if we can use `hide` method (perhaps we'll need to remove transitions)
// or we need another way of removing the data when destroying.
for(var i=0; i < visiblePopupsArray.length; i++) {
$('#' + visiblePopupsArray[i]).popup('hide');
}
$('.popup_wrapper').remove();
$('.popup_background').remove();
// visiblePopupsArray = []; // TODO: check if we need this for SPA and popups with fadeOut animation and scrolllock
$(document).off('click.jqp');
};

$.fn.popup.defaults = {
type: 'overlay',
absolute: false,
Expand Down

0 comments on commit 2f442eb

Please sign in to comment.