Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Fixed modalpreventDefault()
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Apr 25, 2011
1 parent 8be249b commit c189bf1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/modal.js
Expand Up @@ -38,12 +38,12 @@ function Modal(api)

// Apply our show/hide/focus modal events
.bind('tooltipshow'+globalNamespace+' tooltiphide'+globalNamespace, function(event, api, duration) {
self[ event.type.replace('tooltip', '') ](duration);
self[ event.type.replace('tooltip', '') ](event, duration);
})

// Adjust modal z-index on tooltip focus
.bind('tooltipfocus'+globalNamespace, function(event, api, zIndex) {
overlay.css('z-index', zIndex - 1);
overlay[0].style.zIndex = zIndex - 1;
})

// Focus any other visible modals when this one blurs
Expand Down Expand Up @@ -102,8 +102,11 @@ function Modal(api)
return overlay;
},

toggle: function(state)
toggle: function(event, state, duration)
{
// Make sure default event hasn't been prevented
if(event && event.isDefaultPrevented()) { return self; }

var effect = options.effect,
type = state ? 'show': 'hide',
modals = $('[' + attr + ']:visible').not(tooltip),
Expand All @@ -112,14 +115,11 @@ function Modal(api)
// Create our overlay if it isn't present already
if(!overlay) { overlay = self.create(); }

// Prevent modal from conflicting with show.solo
if(overlay.is(':animated') && !state) { return self; }

// Make sure not to hide the backdrop if other modals are visible
if(!state && modals.length) { return self; }
// Prevent modal from conflicting with show.solo, and don't hide backdrop is other modals are visible
if((overlay.is(':animated') && !state) || (!state && modals.length)) { return self; }

// Toggle backdrop cursor style on show
else if(state) {
if(state) {
elems.overlay.css('cursor', options.blur ? 'pointer' : '');
}

Expand All @@ -138,16 +138,16 @@ function Modal(api)

// Use basic fade function
else {
overlay.fadeTo(90, state ? 0.7 : 0, function() {
overlay.fadeTo( parseInt(duration, 10) || 90, state ? 0.7 : 0, function() {
if(!state) { $(this).hide(); }
});
}

return self;
},

show: function() { return self.toggle(TRUE); },
hide: function() { return self.toggle(FALSE); },
show: function(event, duration) { return self.toggle(event, TRUE, duration); },
hide: function(event, duration) { return self.toggle(event, FALSE, duration); },

destroy: function()
{
Expand Down

0 comments on commit c189bf1

Please sign in to comment.