diff --git a/themes/bootstrap3/js/cart.js b/themes/bootstrap3/js/cart.js index 4a351c132e6bb4358a8c11c1bf25d68dab6d477b..a2c447a7296d2112d6801e507be6888c2e10fdf8 100644 --- a/themes/bootstrap3/js/cart.js +++ b/themes/bootstrap3/js/cart.js @@ -171,8 +171,11 @@ function cartSubmit($form) { } else { Lightbox.displayError(vufindString['bulk_noitems_advice']); } - } else { + } else if ((submit != 'empty' || confirm(vufindString['confirmEmpty'])) + && (submit != 'delete' || confirm(vufindString['confirmDelete']))) { Lightbox.submit($form, Lightbox.changeContent); + } else { + $('#modal').find('.fa.fa-spinner').remove(); } } @@ -247,7 +250,7 @@ $(document).ready(function() { }); return false; }); - Lightbox.addCloseAction(function() { + Lightbox.addPermenantCloseAction(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 384afb29689f84ac0a75f0b7a092ba09662ab496..35ca402c109e12341002519ae98f09d5e694cec5 100644 --- a/themes/bootstrap3/js/lightbox.js +++ b/themes/bootstrap3/js/lightbox.js @@ -12,7 +12,8 @@ var Lightbox = { shown: false, // Is the lightbox deployed? 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 after the lightbox event 'hidden' + 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 @@ -44,6 +45,12 @@ var Lightbox = { addCloseAction: function(func) { this.closeStack.push(func); }, + /** + * Register custom close event handlers + */ + addPermenantCloseAction: function(func) { + this.closeStackPerm.push(func); + }, /** * For when you want to handle that form all by yourself * @@ -127,6 +134,10 @@ var Lightbox = { closeActions: function() { Lightbox.shown = false; Lightbox.openingURL = false; + // Permenant 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(); diff --git a/themes/bootstrap3/templates/layout/layout.phtml b/themes/bootstrap3/templates/layout/layout.phtml index d8e7e5adcebd63ed128825fca5f5ef35814d7e30..08cfe146a2b2ac95ae6096b7eb1f3b251a47cfd6 100644 --- a/themes/bootstrap3/templates/layout/layout.phtml +++ b/themes/bootstrap3/templates/layout/layout.phtml @@ -42,6 +42,7 @@ $this->jsTranslations()->addStrings( array( 'bulk_noitems_advice' => 'bulk_noitems_advice', + 'confirmDelete' => 'confirm_delete', 'confirmEmpty' => 'bookbag_confirm_empty', 'viewBookBag' => 'View Book Bag', 'addBookBag' => 'Add to Book Bag',