diff --git a/themes/bootstrap/js/cart.js b/themes/bootstrap/js/cart.js index df788886ebb09706c3ae9475b35255884fa71033..fd456bc761bc1c63ff43dd31daf6cc19dc2f22c9 100644 --- a/themes/bootstrap/js/cart.js +++ b/themes/bootstrap/js/cart.js @@ -159,20 +159,22 @@ var lastCartSubmit = false; function cartSubmit($form) { lastCartSubmit = $form; var submit = $form.find('input[type="submit"][clicked=true]').attr('name'); + var checks = $form.find('input.checkbox-select-item:checked'); + if(checks.length == 0 && submit != 'empty') { + return Lightbox.displayError(vufindString['bulk_noitems_advice']); + } if (submit == 'print') { //redirect page - var checks = $form.find('input.checkbox-select-item:checked'); - if(checks.length > 0) { - var url = path+'/Records/Home?print=true'; - for(var i=0;i<checks.length;i++) { - url += '&id[]='+checks[i].value; - } - document.location.href = url; - } else { - Lightbox.displayError(vufindString['bulk_noitems_advice']); + var url = path+'/Records/Home?print=true'; + for(var i=0;i<checks.length;i++) { + url += '&id[]='+checks[i].value; } - } else { + document.location.href = url; + } else if ((submit != 'empty' || confirm(vufindString['confirmEmpty'])) + && (submit != 'delete' || confirm(vufindString['confirmDelete']))) { Lightbox.submit($form, Lightbox.changeContent); + } else { + $('#modal').find('.icon-spinner').remove(); } } diff --git a/themes/bootstrap/js/common.js b/themes/bootstrap/js/common.js index 21490c20509965201426a9f40517036a4ece139a..ac8c1ea646b347b475bbe5fb68c782e7671650e6 100644 --- a/themes/bootstrap/js/common.js +++ b/themes/bootstrap/js/common.js @@ -115,12 +115,10 @@ function registerLightboxEvents() { }); // Select all checkboxes $(modal).find('.checkbox-select-all').change(function() { - $(this).closest('.modal-body').find('.checkbox-select-item').attr('checked', this.checked); + $(this).closest('.modal-body').find('.checkbox-select-item').prop('checked', this.checked); }); $(modal).find('.checkbox-select-item').change(function() { - if(!this.checked) { // Uncheck all selected if one is unselected - $(this).closest('.modal-body').find('.checkbox-select-all').attr('checked', false); - } + $(this).closest('.modal-body').find('.checkbox-select-all').prop('checked', false); }); // Highlight which submit button clicked $(modal).find("form input[type=submit]").click(function() { @@ -361,7 +359,10 @@ $(document).ready(function() { // Checkbox select all $('.checkbox-select-all').change(function() { - $(this).closest('form').find('.checkbox-select-item').attr('checked', this.checked); + $(this).closest('form').find('.checkbox-select-item').prop('checked', this.checked); + }); + $('.checkbox-select-item').change(function() { + $(this).closest('form').find('.checkbox-select-all').prop('checked', false); }); // handle QR code links diff --git a/themes/bootstrap/js/lightbox.js b/themes/bootstrap/js/lightbox.js index fcf57bce40152359292cc03385895d8b75a2aefa..1df725df4fedd61fd41040a4755c6d37290a415f 100644 --- a/themes/bootstrap/js/lightbox.js +++ b/themes/bootstrap/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 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/bootstrap/templates/layout/layout.phtml b/themes/bootstrap/templates/layout/layout.phtml index 1e98cb170374ec0b45cd95f5487bd7ee63dd038f..12b41dc037aaf4fcfc831920edff2ea374849ce8 100644 --- a/themes/bootstrap/templates/layout/layout.phtml +++ b/themes/bootstrap/templates/layout/layout.phtml @@ -40,6 +40,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', diff --git a/themes/bootstrap3/js/cart.js b/themes/bootstrap3/js/cart.js index 0a7ca901a3dcf97acd3249afb0e570c50bf7e8ae..c0942d8674470a591f51f6bcb9bf99ed0688c67c 100644 --- a/themes/bootstrap3/js/cart.js +++ b/themes/bootstrap3/js/cart.js @@ -159,18 +159,17 @@ var lastCartSubmit = false; function cartSubmit($form) { lastCartSubmit = $form; var submit = $form.find('input[type="submit"][clicked=true]').attr('name'); + var checks = $form.find('input.checkbox-select-item:checked'); + if(checks.length == 0 && submit != 'empty') { + return Lightbox.displayError(vufindString['bulk_noitems_advice']); + } if (submit == 'print') { //redirect page - var checks = $form.find('input.checkbox-select-item:checked'); - if(checks.length > 0) { var url = path+'/Records/Home?print=true'; - for(var i=0;i<checks.length;i++) { - url += '&id[]='+checks[i].value; - } - document.location.href = url; - } else { - Lightbox.displayError(vufindString['bulk_noitems_advice']); + for(var i=0;i<checks.length;i++) { + url += '&id[]='+checks[i].value; } + document.location.href = url; } else if ((submit != 'empty' || confirm(vufindString['confirmEmpty'])) && (submit != 'delete' || confirm(vufindString['confirmDelete']))) { Lightbox.submit($form, Lightbox.changeContent); @@ -250,7 +249,7 @@ $(document).ready(function() { }); return false; }); - Lightbox.addPermenantCloseAction(function() { + Lightbox.addPermanentCloseAction(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/common.js b/themes/bootstrap3/js/common.js index 9168a53da1f125eac471c97dcb45f841430e50a5..56273cf3d41e8ce85d58b125e75c399203e0a8f4 100644 --- a/themes/bootstrap3/js/common.js +++ b/themes/bootstrap3/js/common.js @@ -1,4 +1,4 @@ -/*global ajaxLoadTab, btoa, checkSaveStatuses, console, extractSource, hexEncode, Lightbox, path, rc4Encrypt, refreshCommentList, unescape, vufindString */ +/*global ajaxLoadTab, checkSaveStatuses, console, extractSource, hexEncode, Lightbox, path, rc4Encrypt, refreshCommentList, vufindString */ /* --- GLOBAL FUNCTIONS --- */ function htmlEncode(value){ @@ -117,12 +117,10 @@ function registerLightboxEvents() { }); // Select all checkboxes $(modal).find('.checkbox-select-all').change(function() { - $(this).closest('.modal-body').find('.checkbox-select-item').attr('checked', this.checked); + $(this).closest('.modal-body').find('.checkbox-select-item').prop('checked', this.checked); }); $(modal).find('.checkbox-select-item').change(function() { - if(!this.checked) { // Uncheck all selected if one is unselected - $(this).closest('.modal-body').find('.checkbox-select-all').attr('checked', false); - } + $(this).closest('.modal-body').find('.checkbox-select-all').prop('checked', false); }); // Highlight which submit button clicked $(modal).find("form input[type=submit]").click(function() { @@ -205,9 +203,8 @@ function ajaxLogin(form) { // get the user entered password var password = form.password.value; - // base-64 encode the password (to allow support for Unicode) - // and then encrypt the password with the salt - password = rc4Encrypt(salt, btoa(unescape(encodeURIComponent(password)))); + // encrypt the password with the salt + password = rc4Encrypt(salt, password); // hex encode the encrypted password password = hexEncode(password); @@ -304,7 +301,7 @@ $(document).ready(function() { q:query, method:'getACSuggestions', searcher:searcher['searcher'], - type:$('#searchForm_type').val() + type:$('#searchForm_type').val(), }, dataType:'json', success: function(json) { @@ -318,22 +315,17 @@ $(document).ready(function() { cb([]); } } - }); + }) } } ); // Checkbox select all - $('.checkbox-select-all').click(function(event) { - if(this.checked) { - $(this).closest('form').find('.checkbox-select-item').each(function() { - this.checked = true; - }); - } else { - $(this).closest('form').find('.checkbox-select-item').each(function() { - this.checked = false; - }); - } + $('.checkbox-select-all').change(function() { + $(this).closest('form').find('.checkbox-select-item').prop('checked', this.checked); + }); + $('.checkbox-select-item').change(function() { + $(this).closest('form').find('.checkbox-select-all').prop('checked', false); }); // handle QR code links @@ -382,23 +374,6 @@ $(document).ready(function() { Lightbox.close(); checkSaveStatuses(); }); - - $('[name=bulkActionForm]').submit(function() { - if($(this).find('[clicked=true]').attr('name') == 'print') { - Lightbox.submit($(this), Lightbox.close); - Lightbox.close(); - } else { - Lightbox.submit($(this), function(html) { - Lightbox.checkForError(html, Lightbox.changeContent); - }); - return false; - } - }); - $('[name=bulkActionForm]').find('[type=submit]').click(function() { - $("[clicked=true]").attr("clicked", "false"); - $(this).attr("clicked", "true"); - }); - Lightbox.addFormHandler('feedback', function(evt) { var $form = $(evt.target); // Grabs hidden inputs @@ -447,4 +422,4 @@ $(document).ready(function() { var parts = this.href.split('/'); return Lightbox.get(parts[parts.length-3],'Save',{id:$(this).attr('id')}); }); -}); +}); \ No newline at end of file diff --git a/themes/bootstrap3/js/lightbox.js b/themes/bootstrap3/js/lightbox.js index 35ca402c109e12341002519ae98f09d5e694cec5..f50be405d2dd9fe614a502ef19dc6bd780a25406 100644 --- a/themes/bootstrap3/js/lightbox.js +++ b/themes/bootstrap3/js/lightbox.js @@ -46,9 +46,9 @@ var Lightbox = { this.closeStack.push(func); }, /** - * Register custom close event handlers + * Register permanent close event handlers */ - addPermenantCloseAction: function(func) { + addPermanentCloseAction: function(func) { this.closeStackPerm.push(func); }, /** @@ -134,7 +134,7 @@ var Lightbox = { closeActions: function() { Lightbox.shown = false; Lightbox.openingURL = false; - // Permenant close actions + // permanent close actions for(var i=Lightbox.closeStackPerm.length;i--;) { Lightbox.closeStackPerm[i](); }