From edd458aa704675710269109153bef4688435c249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= <frederick.capovilla@libeo.com> Date: Wed, 20 Mar 2013 17:23:39 -0400 Subject: [PATCH] Bug 8600 - Remove search terms in advanced search Rewrote parts of previous patch by Marc Veron to remove remove href and onclick of links and instead use jQuery --- .../opac-tmpl/prog/en/modules/opac-advsearch.tt | 26 ++++++++++++++----- 1 files changed, 19 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt index 825e8be..3ef7048 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt @@ -124,7 +124,10 @@ <input type="text" size="30" name="q" title="Enter search terms" value="" /> [% IF ( expanded_options ) %] <!-- [% IF ( search_box.scan_index ) %]<input type="checkbox" name="scan" id="scan" value="1" /> Scan Indexes[% END %] --> - [% IF ( search_box.add_field ) %]<a href="JavaScript:add_field();" id="ButtonPlus" title="Add another field">[+]</a>[% END %] + [% IF ( !loop.first ) %] + <a class="ButtonPlus" name="ButtonPlus" title="Add another field">[+]</a> + <a class="ButtonLess" title="Remove field">[-]</a> + [% END %] [% END %] </p> [% END %] @@ -335,12 +338,21 @@ <script type="text/javascript" language="javascript"> /* This function allows to display a new field to search. */ - function add_field() { - var ButtonPlus = document.getElementById('ButtonPlus'); - var line = ButtonPlus.parentNode; - line.parentNode.appendChild(line.cloneNode(true)); - line.removeChild(ButtonPlus); - } + $(document).on("click", '.ButtonPlus', function() { + $('.ButtonLess').show(); + var thisLine = $(this).parent(); + var newLine = thisLine.clone(); + console.log(newLine); + newLine.find('input').val(''); + thisLine.after(newLine); + }); + + $(document).on("click", '.ButtonLess', function() { + if($(this).parent().siblings().length <= 3 ) { + $('.ButtonLess').hide(); + } + $(this).parent().remove(); + }); </script> </div> -- 1.7.2.5