From: Brian Lenz Date: Thu, 9 Jul 2015 22:21:22 +0000 (-0700) Subject: Fix to the modal stack implementation so that you can safely close a modal that isn... X-Git-Tag: v5.5.3~33^2~2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6691%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Fix to the modal stack implementation so that you can safely close a modal that isn't at the top of the stack. --- diff --git a/js/foundation/foundation.reveal.js b/js/foundation/foundation.reveal.js index 458ab1f0a..561a57b03 100644 --- a/js/foundation/foundation.reveal.js +++ b/js/foundation/foundation.reveal.js @@ -267,8 +267,24 @@ } if (settings.multiple_opened) { + var isCurrent = modal.is(':not(.toback)'); self.hide(modal, settings.css.close, settings); - openModals.pop(); + if(isCurrent) { + // remove the last modal since it is now closed + openModals.pop(); + } else { + // if this isn't the current modal, then find it in the array and remove it + openModals = $.grep(openModals, function(elt) { + var isThis = elt[0]===modal[0]; + if(isThis) { + // since it's not currently in the front, put it in the front now that it is hidden + // so that if it's re-opened, it won't be .toback + self.to_front(modal); + } + return !isThis; + }); + } + // finally, show the next modal in the stack, if there is one if(openModals.length>0) { self.to_front(openModals[openModals.length - 1]); }