Use jQuery.noConflict to avoid conflict with other libraries
[sitka/overdrive-evergreen-opac.git] / src / od_pages_opac.coffee
index 2c58250..9a45122 100644 (file)
@@ -2,7 +2,7 @@
 # None of the extensions directly use the API, but they depend on od_action which does.
 
 define [
-       'jquery'
+       'jquery-noconflict'
        'lodash'
        'od_api'
        'od_config'
@@ -68,18 +68,21 @@ define [
                        ids = []
                        for row in @ when id = $(row)._productID()
 
-                               # Cache the ID so that we don't need to traverse the DOM again
-                               ids.push id
+                               # skip this row if it is a grouped record (metarecord)
+                               unless $(row).find("abbr.unapi-id[title*='metabib-metarecord']").length > 0
 
-                               # Adorn each row with a product ID
-                               $(row).prop 'id', id
-                               # Add an empty container of format and availability values
-                               .find '.results_info_table > tbody'
-                                       .append result
-                                       .end()
-                               # Set up progress bars
-                               ._results_meta()
-                               ._results_avail()
+                                       # Cache the ID so that we don't need to traverse the DOM again
+                                       ids.push id
+
+                                       # Adorn each row with a product ID
+                                       $(row).prop 'id', id
+                                       # Add an empty container of format and availability values
+                                       .find '.results_info_table > tbody'
+                                               .append result
+                                               .end()
+                                       # Set up progress bars
+                                       ._results_meta()
+                                       ._results_avail()
 
                        return ids
 
@@ -98,19 +101,13 @@ define [
 
                        return @ unless avail
 
-                       $x =
-                               if avail.available is undefined
-                                       $('<span>')
-                                               .css 'color', 'red'
-                                               .text 'No longer available'
-                               else
-                                       tpl = _.template """
-                                       <span><%= n_avail %> of <%= n_owned %> available, <%= n_holds %> holds</span>
-                                       """
-                                       $ tpl
-                                               n_avail: avail.copiesAvailable
-                                               n_owned: avail.copiesOwned
-                                               n_holds:  avail.numberOfHolds
+                       tpl = _.template """
+                       <span><%= n_avail %> of <%= n_owned %> available, <%= n_holds %> holds</span>
+                       """
+                       $x = $ tpl
+                               n_avail: avail.copiesAvailable
+                               n_owned: avail.copiesOwned
+                               n_holds:  avail.numberOfHolds
 
                        @find('.result_holdings_table .status')
                                .append $x
@@ -159,19 +156,13 @@ define [
 
                        return @ unless avail
 
-                       $x =
-                               if avail.available is undefined
-                                       $('<span>')
-                                               .css 'color', 'red'
-                                               .text 'No longer available'
-                               else
-                                       tpl = _.template """
-                                       <span><%= n_avail %> of <%= n_owned %> available, <%= n_holds %> holds</span>
-                                       """
-                                       $ tpl
-                                               n_avail: avail.copiesAvailable
-                                               n_owned: avail.copiesOwned
-                                               n_holds: avail.numberOfHolds
+                       tpl = _.template """
+                       <span><%= n_avail %> of <%= n_owned %> available, <%= n_holds %> holds</span>
+                       """
+                       $x = $ tpl
+                               n_avail: avail.copiesAvailable
+                               n_owned: avail.copiesOwned
+                               n_holds:  avail.numberOfHolds
 
                        @find '.status'
                                .append $x
@@ -182,11 +173,6 @@ define [
                _replace_place_hold_link: (avail, type_of_interest) ->
                        return @ unless avail
                        
-                       if avail.available is undefined
-                               @find '.place_hold'
-                                       .remove()
-                                       .end()
-
                        # Find the place hold link that we want to replace
                        $a = @find '.place_hold > a'