Auto-focus on place hold or checkout action buttons
authorSteven Chan <steven3416@gmail.com>
Sun, 31 Aug 2014 18:53:16 +0000 (11:53 -0700)
committerSteven Chan <steven3416@gmail.com>
Sun, 31 Aug 2014 18:53:16 +0000 (11:53 -0700)
Signed-off-by: Steven Chan <steven3416@gmail.com>
src/od_action.coffee
src/overdrive.coffee

index 2617fcb..5f09245 100644 (file)
@@ -293,7 +293,7 @@ define [
 
                        tpl = _.template """
                        <div>
-                               <a href="<%= href %>" class="opac-button" style="margin-top: 0px; margin-bottom: 0px"><%= label %></a>
+                               <a href="<%= href %>" class="opac-button <%= action_name %>" style="margin-top: 0px; margin-bottom: 0px"><%= label %></a>
                        </div>
                        """
 
@@ -306,7 +306,7 @@ define [
                                $.extend action, _of: $tr, _name: n
 
                                # Create a button for this action
-                               $ tpl href: action.href, label: Labels?[n] or n
+                               $ tpl href: action.href, action_name: n, label: Labels?[n] or n
 
                                # On clicking the button, build a new dialog using the extended action object
                                .on 'click', action, (ev) ->
index d84a21a..273ae9b 100644 (file)
@@ -277,7 +277,7 @@ require [
                                ._holdings_row id # Add an empty row
                                .appendTo $('#myopac_holds_div, #myopac_checked_div')
 
-                       # Fill in metadata values when they become available
+                       # Fill in empty row when data becomes available
                        od.$.on
 
                                'od.interests': (ev, x) ->
@@ -287,6 +287,7 @@ require [
                                        interested = x.byID
 
                                'od.metadata': (ev, x) ->
+                                       # Fill in metadata columns
                                        $("##{x.id}")._row_meta x, 'thumbnail', 'title', 'author', 'formats'
 
                                'od.availability': (ev, x) ->
@@ -299,8 +300,15 @@ require [
                                        # a hold.
                                        if interested[x.id]?.type
                                                window.history.go -2
+
                                        else
-                                               $("##{x.id}")._holdings_row_avail x
+                                               $("##{x.id}")
+                                               # Fill in availability column
+                                               ._holdings_row_avail x
+                                               # Auto-focus on place hold or checkout button
+                                               .find '.opac-button.hold, .opac-button.checkout'
+                                                       .focus()
+                                                       .end()
 
                'myopac\/holds': ->