diff --git a/themes/bootstrap3/templates/cart/cart.phtml b/themes/bootstrap3/templates/cart/cart.phtml index 5b9c31cb403bee64171835b06826bdbcc6ac4c05..9e1c02cf44b6378665c2a51c70e78f3cb50a2542 100644 --- a/themes/bootstrap3/templates/cart/cart.phtml +++ b/themes/bootstrap3/templates/cart/cart.phtml @@ -24,16 +24,16 @@ <? endif; ?> <input class="btn btn-default" type="submit" name="print" value="<?=$this->transEsc('bookbag_print_selected')?>" title="<?=$this->transEsc('print_selected')?>"/> <div class="btn-group" id="cartDelete"> - <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="cart-delete-label"><?=$this->transEsc('bookbag_delete_selected')?></a> + <button type="submit" name="delete" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="cart-delete-label"><?=$this->transEsc('bookbag_delete_selected')?></button> <ul class="dropdown-menu" role="menu" aria-labelledby="cart-delete-label"> - <li><a onClick="submitFormWithIds(this, path+'/AJAX/JSON?method=getLightbox&submodule=Cart&subaction=Home', {'delete':'delete'}, Lightbox.changeContent)" title="<?=$this->transEsc('confirm_delete')?>"><?=$this->transEsc('confirm_delete')?></a></li> + <li><a onClick="submitFormWithIds(this, {'delete':'delete'})" title="<?=$this->transEsc('confirm_delete')?>"><?=$this->transEsc('confirm_dialog_yes')?></a></li> <li><a><?=$this->transEsc('confirm_dialog_no')?></a></li> </ul> </div> <div class="btn-group"> - <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="cart-empty-label"><?=$this->transEsc('Empty Book Bag')?></a> + <input type="submit" name="empty" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="cart-empty-label" value="<?=$this->transEsc('Empty Book Bag')?>"/> <ul class="dropdown-menu" role="menu" aria-labelledby="cart-empty-label"> - <li><a onClick="$.post(path+'/AJAX/JSON?method=getLightbox&submodule=Cart&subaction=Home', {'empty':'empty'}, Lightbox.changeContent)" title="<?=$this->transEsc('bookbag_confirm_empty')?>"><?=$this->transEsc('bookbag_confirm_empty')?></a></li> + <li><a onClick="submitCartForm(this, {'empty':'empty'})" title="<?=$this->transEsc('bookbag_confirm_empty')?>"><?=$this->transEsc('confirm_dialog_yes')?></a></li> <li><a><?=$this->transEsc('confirm_dialog_no')?></a></li> </ul> </div> @@ -42,21 +42,32 @@ </form> <? $script = <<<JS - function submitFormWithIds(elem, url, data, callback) { + function determineCallback(elem) { + var modal = $(elem).parents('.modal'); + if(modal.length > 0) { + return Lightbox.changeContent; + } else { + return function() {location.reload()} + } + } + function submitCartForm(elem, data) { + var url = path+'/AJAX/JSON?method=getLightbox&submodule=Cart&subaction=Home'; + $.post(url, data, determineCallback(elem)); + } + function submitFormWithIds(elem, data) { data['ids[]'] = []; var form = $(elem).closest('form')[0]; var checkboxes = form.querySelectorAll('[name="ids[]"]:checked'); for(var i=0;i<checkboxes.length;i++) { data['ids[]'].push(checkboxes[i].value); } - $.post(url, data, callback); + submitCartForm(elem, data); } $('#cartDelete').on('show.bs.dropdown', function () { var form = $(this).closest('form')[0]; var checkboxes = form.querySelectorAll('[name="ids[]"]:checked'); if(checkboxes.length == 0) { Lightbox.displayError(vufindString['bulk_noitems_advice']); - return false; } }) JS;