Skip to content

Commit

Permalink
Explicitly test that bootstrap and bootstrap.Modal are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed Apr 27, 2022
1 parent 6955a36 commit eab5a9c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/blacklight/blacklight.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,15 @@ Blacklight.modal.checkCloseModal = function (event) {
};

Blacklight.modal.hide = function (el) {
if (bootstrap.Modal.VERSION >= "5") {
if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).hide();
} else {
$(el || Blacklight.modal.modalSelector).modal('hide');
}
};

Blacklight.modal.show = function (el) {
if (bootstrap.Modal.VERSION >= "5") {
if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).show();
} else {
$(el || Blacklight.modal.modalSelector).modal('show');
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/blacklight/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ Blacklight.modal.checkCloseModal = function(event) {
}

Blacklight.modal.hide = function(el) {
if (bootstrap && bootstrap.Modal && bootstrap.Modal.VERSION >= "5") {
if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).hide();
} else {
$(el || Blacklight.modal.modalSelector).modal('hide');
}
}

Blacklight.modal.show = function(el) {
if (bootstrap && bootstrap.Modal && bootstrap.Modal.VERSION >= "5") {
if (typeof bootstrap !== 'undefined' && typeof bootstrap.Modal !== 'undefined' && bootstrap.Modal.VERSION >= "5") {
bootstrap.Modal.getOrCreateInstance(el || document.querySelector(Blacklight.modal.modalSelector)).show();
} else {
$(el || Blacklight.modal.modalSelector).modal('show');
Expand Down

0 comments on commit eab5a9c

Please sign in to comment.