Skip to content

Commit

Permalink
Fixes issue with backdrop click closing
Browse files Browse the repository at this point in the history
  • Loading branch information
jensljungblad committed Jan 7, 2015
1 parent 34d3dd3 commit 936afa4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
12 changes: 5 additions & 7 deletions micro-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
};

initialize = function(options) {
var $modal, $modalDialog;
var $modal;
options = $.extend({
backdrop: true,
keyboard: true,
Expand All @@ -32,12 +32,10 @@
if (options.vertical) {
$modal.addClass('modal-vertical');
}
$modal.on('click', function(e) {
return close.apply(this);
});
$modalDialog = $modal.children('.modal-dialog');
return $modalDialog.on('click', function(e) {
return e.stopPropagation();
return $modal.on('click', function(e) {
if (e.target === e.currentTarget) {
return close.apply(this);
}
});
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "micro-modal",
"version": "1.0.0",
"version": "1.0.1",
"author": "Jens Ljungblad",
"devDependencies": {
"gulp": "~3.8.8",
Expand Down
11 changes: 6 additions & 5 deletions source/micro-modal.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ initialize = (options) ->
$modal.addClass 'modal-vertical' if options.vertical

# Close modal when clicking the backdrop
$modal.on 'click', (e) -> close.apply this
$modal.on 'click', (e) ->
close.apply this if e.target is e.currentTarget

$modalDialog = $modal.children '.modal-dialog'

# Prevent closing modal when clicking the dialog
$modalDialog.on 'click', (e) -> e.stopPropagation()
# $modalDialog = $modal.children '.modal-dialog'
#
# # Prevent closing modal when clicking the dialog
# $modalDialog.on 'click', (e) -> e.stopPropagation()

open = ->
$(this).addClass 'modal-open'
Expand Down

0 comments on commit 936afa4

Please sign in to comment.