]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Fix to the modal stack implementation so that you can safely close a modal that isn... 6691/head
authorBrian Lenz <brian@socialstrata.com>
Thu, 9 Jul 2015 22:21:22 +0000 (15:21 -0700)
committerBrian Lenz <brian@socialstrata.com>
Thu, 9 Jul 2015 22:21:22 +0000 (15:21 -0700)
js/foundation/foundation.reveal.js

index 458ab1f0aa0647f987c661383894fa1a66a47bbb..561a57b036b3f4b5d69e196e33afd0c5f24cdf48 100644 (file)
         }
 
         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]);
           }