[Koha-patches] [PATCH] Setting focus on form fields

Owen Leonard oleonard at myacpl.org
Sat Apr 18 23:45:22 CEST 2009


This patch includes an addition to the OPAC's default js (identical to one in the staff client) which lets you add a "focus" class to an element on the page and have javascript move the focus to that element (input or link).
---
 koha-tmpl/opac-tmpl/prog/en/js/script.js           |    1 +
 .../prog/en/modules/opac-sendbasketform.tmpl       |    4 ++--
 .../prog/en/modules/opac-sendshelfform.tmpl        |    4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/prog/en/js/script.js b/koha-tmpl/opac-tmpl/prog/en/js/script.js
index b3e3a16..76a6c91 100644
--- a/koha-tmpl/opac-tmpl/prog/en/js/script.js
+++ b/koha-tmpl/opac-tmpl/prog/en/js/script.js
@@ -11,6 +11,7 @@ $(document).ready(function(){
 	$(".close").click(function(){
 		window.close();
 	});
+	$(".focus").focus();
 	// clear the basket when user logs out
 	$("#logout").click(function(){
 		var nameCookie = "bib_list";
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendbasketform.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendbasketform.tmpl
index c162a9d..9caef3c 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendbasketform.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendbasketform.tmpl
@@ -7,7 +7,7 @@
 	<!-- TMPL_IF NAME="SENT" -->
 		<h3>Message Sent</h3>
 	    <p>The cart was sent to: <!-- TMPL_VAR NAME="email_add" --></p>
-		<p><a class="close" href="#">Close window</a></p>
+		<p><a class="focus close" href="#">Close window</a></p>
 	<!-- /TMPL_IF  -->
 	<!-- TMPL_IF NAME="error" -->
 	<p>Problem sending the cart...</p>
@@ -21,7 +21,7 @@
 <legend>Sending your cart</legend>
 <ol>   <li>
         <label for="email_add">Email Address:</label>
-        <input type="text" id="email_add" name="email_add" size="43" />
+        <input type="text" id="email_add" name="email_add" size="43" class="focus" />
     </li>
     <li>
             <label for="comment">Comment:</label>
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelfform.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelfform.tmpl
index c4c33f9..41f7d32 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelfform.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelfform.tmpl
@@ -7,7 +7,7 @@
     <!-- TMPL_IF NAME="SENT" -->
         <h3>Message Sent</h3>
         <p>The list was sent to: <!-- TMPL_VAR NAME="email" --></p>
-        <p><a class="close" href="#">Close window</a></p>
+        <p><a class="close focus" href="#">Close window</a></p>
     <!-- /TMPL_IF  -->
     <!-- TMPL_IF NAME="error" -->
     <p>Problem sending the list...</p>
@@ -21,7 +21,7 @@
 <legend>Sending your list</legend>
 <ol>   <li>
         <label for="email">Email Address:</label>
-        <input type="text" id="email" name="email" size="43" />
+        <input type="text" id="email" name="email" size="43" class="focus" />
     </li>
     <li>
             <label for="comment">Comment:</label>
-- 
1.5.6.5




More information about the Koha-patches mailing list