From 1c92432b009db415e7dd63523c4e6dac9664172f Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Tue, 28 Oct 2014 14:00:11 -0400
Subject: [PATCH] Switched from and removed Lightbox permanent close actions in
 favor of BS events.

---
 themes/bootstrap/js/cart.js      |  2 +-
 themes/bootstrap/js/lightbox.js  |  7 -------
 themes/bootstrap3/js/cart.js     |  2 +-
 themes/bootstrap3/js/lightbox.js | 11 -----------
 4 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/themes/bootstrap/js/cart.js b/themes/bootstrap/js/cart.js
index fd456bc761b..f5149c11b1d 100644
--- a/themes/bootstrap/js/cart.js
+++ b/themes/bootstrap/js/cart.js
@@ -249,7 +249,7 @@ $(document).ready(function() {
     });
     return false;
   });
-  Lightbox.addCloseAction(function() {
+  $('#modal').on('hidden', function(e) {
     // Update cart items (add to cart, remove from cart, cart lightbox interface)
     var cartCount = $('#cartItems strong');
     if(cartCount.length > 0) {
diff --git a/themes/bootstrap/js/lightbox.js b/themes/bootstrap/js/lightbox.js
index 1df725df4fe..5e4ba92fe63 100644
--- a/themes/bootstrap/js/lightbox.js
+++ b/themes/bootstrap/js/lightbox.js
@@ -13,7 +13,6 @@ var Lightbox = {
   XHR: false,        // Used for current in-progress XHR lightbox request
   openStack: [],     // Array of functions to be called after changeContent or the lightbox event 'shown'
   closeStack: [],    // Array of functions to be called and cleared after the lightbox event 'hidden'
-  closeStackPerm: [],// Array of functions to be called after the lightbox event 'hidden'
   formHandlers: [],  // Full custom handlers for forms; by name
   formCallbacks: [], // Custom functions for forms, called after .submit(); by name
 
@@ -45,12 +44,6 @@ var Lightbox = {
   addCloseAction: function(func) {
     this.closeStack.push(func);
   },
-  /**
-   * Register permanent close event handlers
-   */
-  addPermanentCloseAction: function(func) {
-    this.closeStackPerm.push(func);
-  },
   /**
    * For when you want to handle that form all by yourself
    *
diff --git a/themes/bootstrap3/js/cart.js b/themes/bootstrap3/js/cart.js
index c0942d86744..0b53236b774 100644
--- a/themes/bootstrap3/js/cart.js
+++ b/themes/bootstrap3/js/cart.js
@@ -249,7 +249,7 @@ $(document).ready(function() {
     });
     return false;
   });
-  Lightbox.addPermanentCloseAction(function() {
+  $('#modal').on('hidden.bs.modal', function() {
     // Update cart items (add to cart, remove from cart, cart lightbox interface)
     var cartCount = $('#cartItems strong');
     if(cartCount.length > 0) {
diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js
index f50be405d2d..4037500959f 100644
--- a/themes/bootstrap3/js/lightbox.js
+++ b/themes/bootstrap3/js/lightbox.js
@@ -13,7 +13,6 @@ var Lightbox = {
   XHR: false,        // Used for current in-progress XHR lightbox request
   openStack: [],     // Array of functions to be called after changeContent or the lightbox event 'shown'
   closeStack: [],    // Array of functions to be called and cleared after the lightbox event 'hidden'
-  closeStackPerm: [],// Array of functions to be called after the lightbox event 'hidden'
   formHandlers: [],  // Full custom handlers for forms; by name
   formCallbacks: [], // Custom functions for forms, called after .submit(); by name
 
@@ -45,12 +44,6 @@ var Lightbox = {
   addCloseAction: function(func) {
     this.closeStack.push(func);
   },
-  /**
-   * Register permanent close event handlers
-   */
-  addPermanentCloseAction: function(func) {
-    this.closeStackPerm.push(func);
-  },
   /**
    * For when you want to handle that form all by yourself
    *
@@ -134,10 +127,6 @@ var Lightbox = {
   closeActions: function() {
     Lightbox.shown = false;
     Lightbox.openingURL = false;
-    // permanent close actions
-    for(var i=Lightbox.closeStackPerm.length;i--;) {
-      Lightbox.closeStackPerm[i]();
-    }
     // Clean out stack
     while(Lightbox.closeStack.length > 0) {
       var f = Lightbox.closeStack.pop();
-- 
GitLab