Skip to content

Commit

Permalink
Merge pull request #6 from elidupuis/master
Browse files Browse the repository at this point in the history
  • Loading branch information
kylefox committed Oct 26, 2011
2 parents 31c14a2 + 77fbf5f commit 0e1cadc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions jquery.modal.js
Expand Up @@ -28,7 +28,7 @@
opacity: options.opacity
});
if(options.escapeClose) {
$(document).keydown(function(event) {
$(document).bind('keydown.modal', function(event) {
if(event.which == 27) {$.fn.modal.close();}
});
}
Expand All @@ -45,7 +45,7 @@
current_modal.closeButton = $('<a href="#close-modal" rel="modal:close" class="close-modal">' + options.closeText + '</a>');
current_modal.elm.append(current_modal.closeButton);
}
$elm.addClass(options.modalClass).addClass('current').show();
$elm.addClass(options.modalClass + ' current').show();
$elm.trigger($.fn.modal.OPEN, [current_modal]);
}

Expand Down Expand Up @@ -88,9 +88,11 @@
current_modal.closeButton.remove();
}
current_modal.blocker.remove();
current_modal.elm.hide();
current_modal.elm.removeClass('current').hide();
current_modal.elm.trigger($.fn.modal.CLOSE, [current_modal]);
current_modal = null;

$(document).unbind('keydown.modal');
};

$.fn.modal.resize = function() {
Expand All @@ -104,7 +106,8 @@
$(target).modal();
} else { // AJAX
$.get(target, {}, function(html) {
$(html)
$('<div/>')
.html(html)
.appendTo('body')
.bind('modal:close', function(event, modal) { modal.elm.remove(); })
.modal();
Expand Down

0 comments on commit 0e1cadc

Please sign in to comment.