Skip to content

Commit

Permalink
Modify kbox to not call open() when already open.
Browse files Browse the repository at this point in the history
This was causing a bug in which if you click the button that opens the
kbox when the kbox was open, and closeOnOutClick is True, the kbox would
be permanently closed, and would not open again.
  • Loading branch information
mythmon committed Dec 28, 2012
1 parent 445395c commit 0e7b4cc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions media/js/kbox.js
Expand Up @@ -115,6 +115,7 @@ KBox.prototype = {
self.rendered = false; // did we render out yet?
self.$ph = false; // placeholder used if we need to move self.$el in the DOM.
self.$kbox = $();
self.isOpen = false;

// Make the instance accessible from the DOM element.
self.$el.data('kbox', self);
Expand Down Expand Up @@ -176,6 +177,10 @@ KBox.prototype = {
// we don't open anything.
return;
}
if (self.isOpen) {
return;
}
self.isOpen = true;
self.rendered || self.render();
self.$kbox.addClass('kbox-open');
self.setPosition();
Expand Down Expand Up @@ -249,6 +254,10 @@ KBox.prototype = {
// we don't open anything.
return;
}
if (!self.isOpen) {
return;
}
self.isOpen = false;
self.$kbox.removeClass('kbox-open');
self.options.modal && self.destroyOverlay();
self.options.destroy && self.destroy();
Expand Down

0 comments on commit 0e7b4cc

Please sign in to comment.