Add Video Games as an item type
authorJeff Godin <jgodin@tadl.org>
Tue, 21 May 2013 16:21:33 +0000 (12:21 -0400)
committerJeff Godin <jgodin@tadl.org>
Tue, 21 May 2013 16:23:57 +0000 (12:23 -0400)
This makes use of a genre facet / search index on "game".

We're abusing the fi:format of mVG- to distinguish between
video games and other m- selections.

Our approach may change in the future. This is a little bit of a
hack.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
templates_tadlskin/opac/parts/item_format_selector.tt2
templates_tadlskin/opac/parts/js.tt2

index a1e67c3..af7ff8a 100644 (file)
@@ -9,6 +9,7 @@ item_formats = [
     { 'code' => 'g', 'value' => 'Video Recordings' },
     { 'code' => 'j', 'value' => 'Music' },
     { 'code' => 'm', 'value' => 'Streaming Video and Online Books' },
+    { 'code' => 'mVG-', 'value' => 'Video Games' },
 ];
 %]
 
index df50a03..880a4c8 100644 (file)
 </script>
 [% END; # use_autosuggest %]
 
+[%- # Add an event handler to append a facet for subject|genre[game] if Video Games is chosen %]
+
+<script type="text/javascript">
+// handle the instance where Video Games is selected on page load
+dojo.addOnLoad(function() {
+       var item_format_selector = dojo.byId('item_format_selector');
+       var search_form = document.forms[0];
+       if (item_format_selector.value == 'mVG-') {
+               dojo.create('input', {id:"search_facet_field", name:"facet", type:"hidden", value: 'subject|genre[game]'}, search_form);
+       } else {
+               if (dojo.byId('search_facet_field')) {
+                       dojo.destroy(dojo.byId('search_facet_field'));
+               }
+       }
+});
+
+// add an event handler for when Video Games is selected/de-selected
+dojo.addOnLoad(function() {
+       var item_format_selector = dojo.byId('item_format_selector');
+       item_format_selector.onchange=function () {
+               var search_form = document.forms[0];
+               if (this.value == 'mVG-') {
+                       dojo.create('input', {id:"search_facet_field", name:"facet", type:"hidden", value: 'subject|genre[game]'}, search_form);
+               } else {
+                       if (dojo.byId('search_facet_field')) {
+                               dojo.destroy(dojo.byId('search_facet_field'));
+                       }
+               }
+       }
+});
+</script>
+
 [%- END; # want_dojo -%]