From 48bbb235ef8483e3672be0ff013e49fb4d511b7c Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 24 Apr 2012 10:49:15 -0400 Subject: [PATCH] [PASSED QA] Bug 7747 - Replace YUI autocomplete with jQueryUI In order to facilitate a more painless process for converting to jQueryUI I will submit separate patches for various "widgets," starting with Autocomplete. This patch replaces all instances of YUI autocomplete with a jQueryUI version. The patch includes an up-to-date version of jQuery and jQueryUI libraries. The patch also moves some markup in instances where it should have been removed in favor of a different include. To test, find the various autocomplete instances and confirm that they are working: - Circulation search header autocomplete - Overdues patron attribute authorized value filter (must have patron attributes enabled, and a patron attribute defined which uses authorized values. - Authorities search plugin. Edit a MARC record and use an authorities plugin link to do a search for authority records. Incomplete: There is a YUI autocomplete instance in a UNIMARC plugin (unimarc_field_210c_bis.tt) which I couldn't figure out how to test, even on a sandbox set up with UNIMARC. I could use help with a follow-up. http://bugs.koha-community.org/show_bug.cgi?id=7447 Signed-off-by: Liz Rea Passes all tests outlined, is quite pretty. Passes t xt Signed-off-by: Ian Walls --- authorities/ysearch.pl | 20 +- circ/ypattrodue-attr-search-authvalue.pl | 13 +- circ/ysearch.pl | 37 ++- .../intranet-tmpl/prog/en/css/staff-global.css | 22 ++- .../prog/en/includes/auth-finder-search.inc | 134 +++++--- .../prog/en/includes/budgets-admin-search.inc | 90 +----- .../intranet-tmpl/prog/en/includes/cat-search.inc | 71 +---- .../prog/en/includes/cities-admin-search.inc | 69 +---- .../prog/en/includes/contracts-admin-search.inc | 68 +---- .../prog/en/includes/doc-head-close.inc | 2 + .../prog/en/includes/patron-search-box.inc | 65 ++--- .../prog/en/includes/patron-search.inc | 69 +---- .../prog/en/includes/roadtype-admin-search.inc | 70 +---- .../prog/en/includes/suggestions-add-search.inc | 70 +---- .../prog/en/includes/z3950-admin-search.inc | 71 +---- .../jquery/images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 0 -> 180 bytes .../jquery/images/ui-bg_flat_75_ffffff_40x100.png | Bin 0 -> 178 bytes .../jquery/images/ui-bg_glass_55_fbf9ee_1x400.png | Bin 0 -> 120 bytes .../jquery/images/ui-bg_glass_65_ffffff_1x400.png | Bin 0 -> 105 bytes .../jquery/images/ui-bg_glass_75_dadada_1x400.png | Bin 0 -> 111 bytes .../jquery/images/ui-bg_glass_75_e6e6e6_1x400.png | Bin 0 -> 110 bytes .../jquery/images/ui-bg_glass_95_fef1ec_1x400.png | Bin 0 -> 119 bytes .../ui-bg_highlight-soft_75_cccccc_1x100.png | Bin 0 -> 101 bytes .../lib/jquery/images/ui-icons_222222_256x240.png | Bin 0 -> 4369 bytes .../lib/jquery/images/ui-icons_2e83ff_256x240.png | Bin 0 -> 4369 bytes .../lib/jquery/images/ui-icons_454545_256x240.png | Bin 0 -> 4369 bytes .../lib/jquery/images/ui-icons_888888_256x240.png | Bin 0 -> 4369 bytes .../lib/jquery/images/ui-icons_cd0a0a_256x240.png | Bin 0 -> 4369 bytes .../intranet-tmpl/prog/en/lib/jquery/jquery-ui.css | 339 ++++++++++++++++++++ .../intranet-tmpl/prog/en/lib/jquery/jquery-ui.js | 49 +++ .../intranet-tmpl/prog/en/modules/circ/overdue.tt | 102 +++---- koha-tmpl/intranet-tmpl/prog/img/loading-small.gif | Bin 0 -> 1849 bytes 32 files changed, 643 insertions(+), 718 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-bg_flat_75_ffffff_40x100.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-bg_glass_65_ffffff_1x400.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-bg_glass_75_dadada_1x400.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-bg_glass_95_fef1ec_1x400.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-icons_222222_256x240.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-icons_2e83ff_256x240.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-icons_454545_256x240.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-icons_888888_256x240.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/images/ui-icons_cd0a0a_256x240.png create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/jquery-ui.css create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/jquery-ui.js create mode 100644 koha-tmpl/intranet-tmpl/prog/img/loading-small.gif diff --git a/authorities/ysearch.pl b/authorities/ysearch.pl index 56ef8e2..1f7e5ef 100755 --- a/authorities/ysearch.pl +++ b/authorities/ysearch.pl @@ -3,6 +3,7 @@ # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) # Copyright 2011 BibLibre +# Parts copyright 2012 Athens County Public Libraries # # This file is part of Koha. # @@ -43,7 +44,7 @@ if ( $auth_status ne "ok" ) { exit 0; } - my $searchstr = $query->param('query'); + my $searchstr = $query->param('term'); my $searchtype = $query->param('querytype'); my @value; given ($searchtype) { @@ -62,10 +63,17 @@ if ( $auth_status ne "ok" ) { my $startfrom = 0; my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby ); + +print "["; +my $i = 0; foreach (@$results) { - my ($value) = $_->{'summary'}; - # Removes new lines - $value =~ s/
/ /g; - $value =~ s/\n//g; - print nsb_clean($value) . "\n"; + if($i > 0){ print ","; } + my ($value) = $_->{'summary'}; + # Removes new lines + $value =~ s/
/ /g; + $value =~ s/\n//g; + $value = "{\"summary\":\"" . $value . "\"" . "}"; + print nsb_clean($value) . "\n"; + $i++; } +print "]"; \ No newline at end of file diff --git a/circ/ypattrodue-attr-search-authvalue.pl b/circ/ypattrodue-attr-search-authvalue.pl index f8d77c5..517c8c0 100755 --- a/circ/ypattrodue-attr-search-authvalue.pl +++ b/circ/ypattrodue-attr-search-authvalue.pl @@ -2,6 +2,7 @@ # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) +# Parts copyright 2012 Athens County Public Libraries # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the @@ -25,7 +26,7 @@ use C4::Auth qw/check_cookie_auth/; use C4::Debug; my $input = new CGI; -my $query = $input->param('query'); +my $query = $input->param('term'); my $attrcode = $input->path_info || ''; $attrcode =~ s|^/||; @@ -45,8 +46,14 @@ my $sql = qq(SELECT authorised_value, lib description AND v.lib like ?); my $sth = $dbh->prepare($sql); $sth->execute( $attrcode, "$query%" ); + +print "["; +my $i = 0; while ( my $rec = $sth->fetchrow_hashref ) { print STDERR ">> attrcode=$attrcode match '$query' ==> $rec->{description} ($rec->{authorised_value})\n" if $debug; - print "$rec->{description}\t$rec->{authorised_value}\n"; + print "{\"description\":\"" . $rec->{description} . "\",\"" . + "authorised_value\":\"" . $rec->{authorised_value} . "\"" . + "}"; + $i++; } - +print "]"; \ No newline at end of file diff --git a/circ/ysearch.pl b/circ/ysearch.pl index beab6a1..8a48c51 100755 --- a/circ/ysearch.pl +++ b/circ/ysearch.pl @@ -3,6 +3,7 @@ # This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html) # Copyright 2007 Tamil s.a.r.l. +# Parts copyright 2010-2012 Athens County Public Libraries # # This file is part of Koha. # @@ -32,7 +33,7 @@ use C4::Members; use C4::Auth qw/check_cookie_auth/; my $input = new CGI; -my $query = $input->param('query'); +my $query = $input->param('term'); binmode STDOUT, ":encoding(UTF-8)"; print $input->header(-type => 'text/plain', -charset => 'UTF-8'); @@ -42,11 +43,29 @@ if ($auth_status ne "ok") { exit 0; } -print map $_->{surname} . ", " . $_->{firstname} . "\t" . - $_->{cardnumber} . "\t" . - $_->{address} . "\t" . - $_->{city} . "\t" . - $_->{zipcode} . "\t" . - $_->{country} . - "\n", - @{ Search($query, [qw(surname firstname cardnumber)], [10], [qw(surname firstname cardnumber address city zipcode country)]) }; +my $dbh = C4::Context->dbh; +my $sql = qq(SELECT surname, firstname, cardnumber, address, city, zipcode, country + FROM borrowers + WHERE surname LIKE ? + OR firstname LIKE ? + OR cardnumber LIKE ? + ORDER BY surname, firstname + LIMIT 10); +my $sth = $dbh->prepare( $sql ); +$sth->execute("$query%", "$query%", "$query%"); + +print "["; +my $i = 0; +while ( my $rec = $sth->fetchrow_hashref ) { + if($i > 0){ print ","; } + print "{\"surname\":\"" . $rec->{surname} . "\",\"" . + "firstname\":\"".$rec->{firstname} . "\",\"" . + "cardnumber\":\"".$rec->{cardnumber} . "\",\"" . + "address\":\"".$rec->{address} . "\",\"" . + "city\":\"".$rec->{city} . "\",\"" . + "zipcode\":\"".$rec->{zipcode} . "\",\"" . + "country\":\"".$rec->{country} . "\"" . + "}"; + $i++; +} +print "]"; \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index a05b6e5..044d3a1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -2193,7 +2193,11 @@ div.pager { padding : .3em .5em .3em .5em; margin : .4em 0; } -div.pager img { +div.pager img {+/* jQuery UI Autocomplete */ ++ul.ui-autocomplete li { list-style-type: none; font-size : inherit; } ++ul.ui-autocomplete { -webkit-box-shadow: 2px 2px 2px rgba(0,0,0,.3); -moz-box-shadow: 2px 2px 2px rgba(0,0,0,.3); box-shadow: 2px 2px 2px rgba(0,0,0,.3); } ++input.ui-autocomplete-input.active { background: transparent url("../../img/loading-small.gif") right center no-repeat; } + vertical-align : middle; } div.pager img.last { @@ -2233,3 +2237,19 @@ div#acqui_order_supplierlist > div.supplier > span.action { div#acqui_order_supplierlist > div.supplier > div.baskets { margin-top: 0.5em; } + +/* jQuery UI Autocomplete */ +ul.ui-autocomplete li { + list-style-type: none; + font-size : inherit; +} + +ul.ui-autocomplete { + -webkit-box-shadow: 2px 2px 2px rgba(0,0,0,.3); + -moz-box-shadow: 2px 2px 2px rgba(0,0,0,.3); + box-shadow: 2px 2px 2px rgba(0,0,0,.3); +} + +.ui-autocomplete-loading { + background: #FFF url("../../img/loading-small.gif") right center no-repeat; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc index f3752b8..81e410a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc @@ -1,64 +1,90 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc index 6f79e71..5cb753a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/budgets-admin-search.inc @@ -1,49 +1,5 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc index 13a24fe..d813d17 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc @@ -1,74 +1,9 @@

[% LibraryName %]

-[% IF ( CAN_user_circulate ) %][% IF ( CircAutocompl ) %][% END %][% END %]