Skip to content

Commit

Permalink
added option for preventing modal close from outside click
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetty committed Feb 13, 2019
1 parent 444d6f1 commit 4fdf38f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Modal v1.17.1
# Modal v1.17.2

Library for opening content in a modal window. Built to be used with web applications and ajax.

- Requires jQuery 1.7+

### new in 1.17.2

Added option for preventing modal close when clicking outside of the modal

### new in 1.17.1

Added support for nested modals. Modal windows will get appended after the last. when nested modals are closed, the previous modal will be displayed until the last one is closed which will destroy the modal elements.
Expand Down Expand Up @@ -55,6 +59,7 @@ ajax : false,
width : false,
centered : false,
allowClose : true,
allowCloseOverlay : true,
afterInit : $.noop,
afterOpen : $.noop,
afterClose : $.noop,
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.modal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 17 additions & 14 deletions src/jquery.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
$(this.settings.closeModalName).on('click.' + this.namespace, $.proxy(this.close, this));
$(document).on('keydown.' + this.namespace, $.proxy(this.close, this));

this.$modal.on('click.' + this.namespace, function (e) {
if (!$(e.target).closest('.' + self.settings.modalContentName).length) {
self.close();
}
});
if (this.settings.allowCloseOverlay) {
this.$modal.on('click.' + this.namespace, function (e) {
if (!$(e.target).closest('.' + self.settings.modalContentName).length) {
self.close();
}
});
}
};

Modal.prototype.removeEvents = function () {
Expand Down Expand Up @@ -341,21 +343,22 @@
// Set options obj
$.fn.modal2.defaults = {
closeModalName: '[data-dismiss="modal2"]',
backdropName: 'modal-backdrop',
modalDialogName: 'modal-dialog',
modalContentName: 'modal-content',
modalDialogName: 'modal-dialog',
backdropName: 'modal-backdrop',
allowCloseOverlay: true,
onBeforeClose: $.noop,
modalSkin: 'default',
modalName: 'modal',
afterClose: $.noop,
container: 'body',
html: false,
ajax: false,
width: false,
centered: false,
allowClose: true,
afterInit: $.noop,
afterOpen: $.noop,
afterClose: $.noop,
onBeforeClose: $.noop
allowClose: true,
centered: false,
width: false,
html: false,
ajax: false,
};

// return for module loader
Expand Down

0 comments on commit 4fdf38f

Please sign in to comment.