Bug 13271 - Subject search links broken if XSLT and OPACPopupAuthorsSearch are both off
authorOwen Leonard <oleonard@myacpl.org>
Tue, 18 Nov 2014 14:16:53 +0000 (09:16 -0500)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Sat, 22 Nov 2014 14:14:58 +0000 (11:14 -0300)
This patch corrects some faults in the OPAC's bootstrap template which
prevent additional author and subject searches from working correctly
with OPACPopupAuthorsSearch both on and off.

Some JavaScript has been removed because it was used only by the prog
theme and is obsolete.

Locate a title with multiple subjects and additional authors. Test the
following conditions:

OPACXSLTDetailsDisplay is blank and OPACPopupAuthorsSearch is off:

 - Clicking an additional author or subject link should directly trigger
   the correct search without an JavaScript error.

OPACXSLTDetailsDisplay is blank and OPACPopupAuthorsSearch is on:

 - Clicking an additional author or subject link should trigger a modal
   window where you can select options for searching. Checking boxes and
   submitting the form should perform the correct search.

OPACXSLTDetailsDisplay is set to "default" and OPACPopupAuthorsSearch is
on OR off:

 - Clicking an additional author or subject link should directly trigger
   the correct search without an JavaScript error.
   (OPACPopupAuthorsSearch only works with the non-XSL view).

For extra credit: Test with JavaScript disabled and confirm that link
still work correctly.

Signed-off-by: Frederic Demians <f.demians@tamil.fr>
I confirm the bug and the solution. Before various JS errors: "ReferenceError:
e is not defined" and "ReferenceError: showSubjects is not defined". After:
Comforting silence, and functionnality.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt

index 52089b1..28a3686 100644 (file)
                                             </ul>
                                         </div>
                                         <div class="modal-footer">
-                                            <a href="#" class="btn btn-primary">Search</a>
+                                            <a id="validAuthorSearch" href="#" class="btn btn-primary">Search</a>
                                             <a href="#" class="cancel" data-dismiss="modal" aria-hidden="true">Cancel</a>
                                         </div>
                                     </div>
                                     [% authorsloop = loop %]
                                     [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %]
                                         [% MARCAUTHOR_SUBFIELDS_LOO.separator %]
-                                        <a role="button" data-toggle="modal" title="‡[% MARCAUTHOR_SUBFIELDS_LOO.code %] [% MARCAUTHOR_SUBFIELDS_LOO.value %]"
+                                        [% IF Koha.Preference( 'OPACPopupAuthorsSearch' ) == 1 %]
+                                            <a role="button" data-toggle="modal" title="‡[% MARCAUTHOR_SUBFIELDS_LOO.code %] [% MARCAUTHOR_SUBFIELDS_LOO.value %]"
                                             class="showauthors" data-count="[% authorsloop.count %]"
                                             href="/cgi-bin/koha/opac-search.pl?q=[% FOREACH link_loo IN MARCAUTHOR_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit |url %]:[% link_loo.link |url %][% END %]#authorSearch">[% MARCAUTHOR_SUBFIELDS_LOO.value %]</a>
+                                        [% ELSE %]
+                                            <a title="‡[% MARCAUTHOR_SUBFIELDS_LOO.code %] [% MARCAUTHOR_SUBFIELDS_LOO.value %]"
+                                            class="showauthors" href="/cgi-bin/koha/opac-search.pl?q=[% FOREACH link_loo IN MARCAUTHOR_SUBFIELDS_LOO.link_loop %][% link_loo.operator |url %][% link_loo.limit |url %]:[% link_loo.link |url %][% END %]">[% MARCAUTHOR_SUBFIELDS_LOO.value %]</a>
+                                        [% END %]
                                     [% END %]
                                     [% IF (MARCAUTHOR.authoritylink) %]
                                         <a class='authlink' href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% MARCAUTHOR.authoritylink %]"><img style="vertical-align:middle" height="15" width="15" src="[% interface %]/[% theme %]/images/filefind.png"></a>
                                     [% subjectsloop = loop %]
                                     [% FOREACH SUBFIELD IN MARCSUBJCT.MARCSUBJECT_SUBFIELDS_LOOP %]
                                         [% SUBFIELD.separator %]
-                                        <a role="button" data-toggle="modal" title="$[% SUBFIELD.code %] [% SUBFIELD.value %]" href="/cgi-bin/koha/opac-search.pl?q=[% FOREACH link_loo IN SUBFIELD.link_loop %][% link_loo.operator |url %][% link_loo.limit |url %]:[% link_loo.link |url %][% END %]#subjectSearch" onclick="showSubjects(this, [% subjectsloop.count %], [% loop.count %]); return false;">[% SUBFIELD.value %]</a>
+                                        [% IF Koha.Preference( 'OPACPopupAuthorsSearch' ) == 1 %]
+                                            <a role="button" data-toggle="modal" title="$[% SUBFIELD.code %] [% SUBFIELD.value %]" href="/cgi-bin/koha/opac-search.pl?q=[% FOREACH link_loo IN SUBFIELD.link_loop %][% link_loo.operator |url %][% link_loo.limit |url %]:[% link_loo.link |url %][% END %]#subjectSearch" onclick="showSubjects(this, [% subjectsloop.count %], [% loop.count %]); return false;">[% SUBFIELD.value %]</a>
+                                        [% ELSE %]
+                                            <a title="$[% SUBFIELD.code %] [% SUBFIELD.value %]" href="/cgi-bin/koha/opac-search.pl?q=[% FOREACH link_loo IN SUBFIELD.link_loop %][% link_loo.operator |url %][% link_loo.limit |url %]:[% link_loo.link |url %][% END %]">[% SUBFIELD.value %]</a>
+                                        [% END %]
                                     [% END %]
                                     [% IF (MARCSUBJCT.authoritylink) %]
                                         <a class="authlink" href="/cgi-bin/koha/opac-authoritiesdetail.pl?authid=[% MARCSUBJCT.authoritylink %]"><img style="vertical-align:middle" height="15" width="15" src="[% interface %]/[% theme %]/images/filefind.png" /></a>
     //<![CDATA[
         function showAuthors(element){
             var authornumber = $(element).attr("data-count");
-            // Hide subjects menu if displayed
-            hideMenu(".subjectSearch");
 
             // Check checkbox related to the clicked link
             $("#authorsList input[type='checkbox']").attr('checked', false);
             $("#author_"+authornumber).attr('checked', true);
 
             makeAuthorRequest();
-
-            // Display menu
-            var left = element.offsetLeft || 0;
-            var top = element.offsetTop || 0;
-            $('.authorSearch').css('display', 'block');
-            $('.authorSearch').css('left', left);
-            $('.authorSearch').css('top', top + 15);
-        }
-
-        function hideMenu(elem) {
-            $(elem).css('display', 'none');
         }
 
         function checkAll(checkbox, elem) {
             }
         }
         $(document).ready(function() {
-            $("a.showauthors").click(function(){
+            $("a.showauthors").click(function(e){
                 e.preventDefault();
                 showAuthors(this);
             });