From b9d4ac098d515a284e9c478f1db5896e3450229d Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Thu, 20 Feb 2014 10:32:02 -0500
Subject: [PATCH] Bootstrap js checkstyles.

---
 themes/bootstrap/js/cart.js     |  6 ++--
 themes/bootstrap/js/common.js   |  2 +-
 themes/bootstrap/js/lightbox.js | 60 +++++++++++++++++----------------
 themes/bootstrap/js/record.js   | 10 ++----
 4 files changed, 38 insertions(+), 40 deletions(-)

diff --git a/themes/bootstrap/js/cart.js b/themes/bootstrap/js/cart.js
index 946c58f67e3..3be5e1b806b 100644
--- a/themes/bootstrap/js/cart.js
+++ b/themes/bootstrap/js/cart.js
@@ -1,4 +1,4 @@
-/*global Cookies, path, vufindString, addLightboxFormHandler, addLightboxOnClose, ajaxSubmit, changeModalContent, getDataFromForm, lastLightboxPOST, modalXHR */
+/*global Cookies, path, vufindString, addLightboxFormHandler, addLightboxOnClose, ajaxSubmit, changeModalContent, getDataFromForm, lastLightboxPOST, lightboxConfirm */
 
 var _CART_COOKIE = 'vufind_cart';
 var _CART_COOKIE_SOURCES = 'vufind_cart_src';
@@ -173,7 +173,7 @@ $(document).ready(function() {
     return false;
   });
   addLightboxFormHandler('bulkSave', function(evt){
-    ajaxSubmit($(evt.target), function(){lightboxConfirm(vufindString['bulk_save_success'])});
+    ajaxSubmit($(evt.target), function(){lightboxConfirm(vufindString['bulk_save_success']);});
     // After we close the lightbox, redirect to list view
     addLightboxOnClose(function() {
       document.location.href = path+'/MyResearch/MyList/'+lastLightboxPOST['list'];
@@ -181,7 +181,7 @@ $(document).ready(function() {
     return false;
   });
   addLightboxFormHandler('exportForm', function(evt){
-    modalXHR = $.ajax({
+    $.ajax({
       url: path + '/AJAX/JSON?' + $.param({method:'exportFavorites'}),
       type:'POST',
       dataType:'json',
diff --git a/themes/bootstrap/js/common.js b/themes/bootstrap/js/common.js
index a1480429e3f..54edbeaa2df 100644
--- a/themes/bootstrap/js/common.js
+++ b/themes/bootstrap/js/common.js
@@ -124,7 +124,7 @@ $(document).ready(function() {
   $('.checkbox-select-all').change(function() {
     $(this).closest('form').find('.checkbox-select-item').attr('checked', this.checked);
   });
-  $(modal).find('.checkbox-select-item').change(function() {
+  $('#modal').find('.checkbox-select-item').change(function() {
     if(!this.checked) {
       $(this).closest('form').find('.checkbox-select-all').attr('checked', false);
     }
diff --git a/themes/bootstrap/js/lightbox.js b/themes/bootstrap/js/lightbox.js
index 825607f2063..57a1f3ba83f 100644
--- a/themes/bootstrap/js/lightbox.js
+++ b/themes/bootstrap/js/lightbox.js
@@ -10,6 +10,29 @@ var lightboxShown = false; // Is the lightbox deployed?
 var modalXHR; // Used for current in-progress XHR lightbox request
 var modalOpenStack = [];
 var modalCloseStack = [];
+var modalFormHandlers = {};
+
+/**********************************/
+/* ======    INTERFACE     ====== */
+/**********************************/
+/**
+ * Register custom open event handlers
+ */
+function addLightboxOnOpen(func) {
+  modalOpenStack.push(func);
+}
+/**
+ * Register custom close event handlers
+ */
+function addLightboxOnClose(func) {
+  modalCloseStack.push(func);
+}
+/**
+ * Register custom form handlers
+ */
+function addLightboxFormHandler(formName, func) {
+  modalFormHandlers[formName] = func;
+}
 
 /**********************************/
 /* ====== LIGHTBOX ACTIONS ====== */
@@ -48,7 +71,7 @@ function closeLightboxActions() {
     f();
   }
   // Abort requests triggered by the lightbox
-  if(modalXHR) { modalXHR.abort() }
+  if(modalXHR) { modalXHR.abort(); }
   // Reset content so we start fresh when we open a lightbox
   $('#modal').removeData('modal');
   $('#modal').find('.modal-header h3').html('');
@@ -214,8 +237,8 @@ function getDataFromForm($form) {
     // Checkboxes
     } else if($(inputs[i]).attr('type') != 'checkbox' || inputs[i].checked) {
       if(array) {
-        var n = currentName.substring(0,currentName.length-2);
-        data[n].push(inputs[i].value);
+        var f = currentName.substring(0,currentName.length-2);
+        data[f].push(inputs[i].value);
       } else {
         data[currentName] = inputs[i].value;
       }
@@ -385,20 +408,12 @@ function registerModalEvents(modal) {
     $(this).after(' <i class="icon-spinner icon-spin"></i> ');
   });
 }
-
 /**
  * Prevents default submission, reroutes through ajaxSubmit
  * or a specified action based on form name. Please return false.
  *
  * Called everytime the lightbox is loaded.
  */
-var modalFormHandlers = {
-  loginForm:
-    function() {
-      ajaxLogin(this);
-      return false;
-    },
-};
 function registerModalForms(modal) {
   var $form = $(modal).find('form');
   // Assign form handler based on name
@@ -412,24 +427,6 @@ function registerModalForms(modal) {
     });
   }
 }
-/**
- * Register custom open event handlers
- */
-function addLightboxOnOpen(func) {
-  modalOpenStack.push(func);
-}
-/**
- * Register custom close event handlers
- */
-function addLightboxOnClose(func) {
-  modalCloseStack.push(func);
-}
-/**
- * Register custom form handlers
- */
-function addLightboxFormHandler(formName, func) {
-  modalFormHandlers[formName] = func;
-}
 /**
  * This is where you add click events to open the lightbox.
  * We do it here so that non-JS users still have a good time.
@@ -439,6 +436,11 @@ $(document).ready(function() {
   // First things first
   addLightboxOnOpen(registerModalEvents);
   addLightboxOnOpen(registerModalForms);
+  addLightboxFormHandler('loginForm', function() {
+    ajaxLogin(this);
+    return false;
+  });
+
   // Hijack modal forms
   $('#modal').on('show', function() {
     for(var i=0;i<modalOpenStack.length;i++) {
diff --git a/themes/bootstrap/js/record.js b/themes/bootstrap/js/record.js
index 3e348ba6bf8..e61ecb0c512 100644
--- a/themes/bootstrap/js/record.js
+++ b/themes/bootstrap/js/record.js
@@ -1,4 +1,4 @@
-/*global addLightboxFormHandler, addLightboxOnClose, closeLightbox, extractClassParams, getLightbox, path */
+/*global addLightboxFormHandler, addLightboxOnClose, ajaxSubmit, closeLightbox, extractClassParams, getLightbox, lightboxConfirm, path, vufindString */
 
 /**
  * Functions and event handlers specific to record pages.
@@ -117,7 +117,7 @@ function registerAjaxCommentRecord() {
               type: 'POST',
               url:  url,
               data: data,
-              dataType: 'json',
+              dataType: 'json'
             });
           });
           return getLightbox('Record', 'AddComment', data, data);
@@ -158,12 +158,8 @@ $(document).ready(function(){
     return getLightbox(params['controller'], 'Save', {id:id});
   });
   // Form handlers
-  addLightboxFormHandler('placeHold', function(evt) {
-    ajaxSubmit($(evt.target), closeLightbox);
-    return false;
-  });
   addLightboxFormHandler('emailRecord', function(evt) {
-    ajaxSubmit($(evt.target), function(){lightboxConfirm(vufindString['bulk_email_success'])});
+    ajaxSubmit($(evt.target), function(){lightboxConfirm(vufindString['bulk_email_success']);});
     return false;
   });
   
-- 
GitLab