From dd63369cefc9463a68a8a6e306645c95e979aa1b Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 7 Mar 2014 10:46:39 -0500
Subject: [PATCH] ILL lightbox support. Bootstrap.

---
 themes/bootstrap/js/record.js                 |  5 +++-
 .../templates/record/illrequest.phtml         | 26 ++++++++++++-------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/themes/bootstrap/js/record.js b/themes/bootstrap/js/record.js
index d1364c748e2..1e358ed3bd8 100644
--- a/themes/bootstrap/js/record.js
+++ b/themes/bootstrap/js/record.js
@@ -161,7 +161,7 @@ $(document).ready(function(){
   });
   // Place a Hold
   // Place a Storage Hold
-  $('.placehold,.placeStorageRetrievalRequest').click(function() {
+  $('.placehold,.placeStorageRetrievalRequest,.placeILLRequest').click(function() {
     var parts = $(this).attr('href').split('?');
     parts = parts[0].split('/');
     var params = deparam($(this).attr('href'));
@@ -225,4 +225,7 @@ $(document).ready(function(){
   Lightbox.addFormCallback('placeStorageRetrievalRequest', function() {
     document.location.href = path+'/MyResearch/StorageRetrievalRequests';
   });
+  Lightbox.addFormCallback('placeILLRequest', function() {
+    document.location.href = path+'/MyResearch/ILLRequests';
+  });
 });
diff --git a/themes/bootstrap/templates/record/illrequest.phtml b/themes/bootstrap/templates/record/illrequest.phtml
index e10a3a052f0..0a3695bc755 100644
--- a/themes/bootstrap/templates/record/illrequest.phtml
+++ b/themes/bootstrap/templates/record/illrequest.phtml
@@ -1,7 +1,4 @@
 <?
-    // Set up ill script:
-    $this->headScript()->appendFile("ill.js");
-
     // Set page title.
     $this->headTitle($this->translate('ill_request_place_text') . ': ' . $this->driver->getBreadcrumb());
 
@@ -13,7 +10,7 @@
 <p class="lead"><?=$this->transEsc('ill_request_place_text')?></p>
 <?=$this->flashmessages()?>
 <div id="ILLRequestForm" class="storage-retrieval-request-form">
-  <form action="" class="form-horizontal" method="post">
+  <form action="" name="placeILLRequest" class="form-horizontal" method="post">
 
     <? if (in_array("itemId", $this->extraFields)): ?>
       <div class="control-group">
@@ -119,8 +116,19 @@
   </form>
 </div>
 
-<script type="text/javascript">
-$(document).ready(function(){
-    setUpILLRequestForm('<?=$this->escapeHtml($this->driver->getUniqueId()) ?>');
-});
-</script>
+<?
+    // Set up ill script; we do this inline instead of in the header for lightbox compatibility:
+    $this->inlineScript()->appendFile('ill.js');
+
+    $js = <<<JS
+        if ($.isReady) {
+            setUpILLRequestForm("{$this->escapeHtml($this->driver->getUniqueId())}");
+        } else {
+            $(document).ready(function(){
+                setUpILLRequestForm("{$this->escapeHtml($this->driver->getUniqueId())}");
+            });
+        }
+JS;
+
+    echo $this->inlineScript()->appendScript($js);
+?>
-- 
GitLab