From af2c813745657e5c367bad776beb6c956e6e16db Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 30 May 2018 14:15:19 +0000 Subject: [PATCH] Bug 16575: Irregular behaviour using window.print() followed by window.location.href This patch updates the OPAC and staff client carts to use CSS to control print output, removing a print parameter which was passed to the script. Currently, when you click "Print" on the OPAC basket, it navigates to a new page and initiates window.print() followed by a window.location.href change again. Unfortunately, due to differences in IE, Chrome, and FF, it will either show the print options, navigate away without showing them, or refuse to navigate away after printing. By changing to using print CSS, we don't navigate away from the basket in the first place, so we prevent this irregular behavior. TEST PLAN 1) Apply the patch 2) Create an OPAC basket by clicking "Add to cart" on multiple items 3) Using Chrome, IE, and Firefox (of any version), click the "Print" button 4) You should see the relevant print menu without the OPAC basket re-loading in any way. 5) After printing is complete, you should still be on the OPAC basket pop-up 6) Perform the same tests in the staff client Signed-off-by: Katrin Fischer Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens (cherry picked from commit a9836864dcbe4c11d370c245511ee4b9d6bd33f3) Signed-off-by: Martin Renvoize --- basket/basket.pl | 2 - koha-tmpl/intranet-tmpl/prog/css/print.css | 30 +++++++++- .../intranet-tmpl/prog/css/staff-global.css | 5 ++ .../prog/en/modules/basket/basket.tt | 55 ++++++------------- koha-tmpl/intranet-tmpl/prog/js/basket.js | 3 +- .../bootstrap/en/modules/opac-basket.tt | 4 +- koha-tmpl/opac-tmpl/bootstrap/less/print.less | 17 +++++- 7 files changed, 70 insertions(+), 46 deletions(-) diff --git a/basket/basket.pl b/basket/basket.pl index 76edc34449..4318a9560f 100755 --- a/basket/basket.pl +++ b/basket/basket.pl @@ -39,11 +39,9 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( ); my $bib_list = $query->param('bib_list'); -my $print_basket = $query->param('print'); my $verbose = $query->param('verbose'); if ($verbose) { $template->param( verbose => 1 ); } -if ($print_basket) { $template->param( print_basket => 1 ); } my @bibs = split( /\//, $bib_list ); my @results; diff --git a/koha-tmpl/intranet-tmpl/prog/css/print.css b/koha-tmpl/intranet-tmpl/prog/css/print.css index c71c62ba71..53617b007a 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/print.css +++ b/koha-tmpl/intranet-tmpl/prog/css/print.css @@ -302,7 +302,8 @@ form#sortbyform, fieldset.action, .list-actions, .print, -.ui-tabs-nav { +.ui-tabs-nav, +.cart-controls { display: none; } @@ -329,3 +330,30 @@ p#upload_image { display: none; } + +th { + text-align: left; +} + +#cart_basket .container, +#cart_basket table, +#cart_basket tr, +#cart_basket th, +#cart_basket td, +#cart_basket .sorting_asc, +#cart_basket .sorting, +#cart_basket .sorting_desc, +#cart_basket .sorting_disabled, +#cart_basket tbody tr:nth-child(2n+1) td { + background: transparent none; + border: 0; +} + +#cart_basket tr { + border-collapse: collapse; + border-bottom: 1px solid #DDD; +} + +.container { + width:100%; +} diff --git a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css index 38cbf5cec5..200f6e239b 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -3324,3 +3324,8 @@ span.name { margin: auto; margin-bottom: 2px; } + +.cart-controls { + border-top: 1px solid #E8E8E8; + padding: 7px 0; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt index 6b1d28f904..c798725f1f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt @@ -1,7 +1,7 @@ [% USE Asset %] [% SET footerjs = 1 %] [% BLOCK controls %] -

+

Select all Clear all | Selected items : Remove @@ -24,26 +24,18 @@

[% END %] [% INCLUDE 'doc-head-open.inc' %] -[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] Catalog › Your cart - [% IF ( print_basket ) %] - - - - - [% ELSE %][% INCLUDE 'doc-head-close.inc' %] -[% Asset.css("css/datatables.css") %] - [% END %] +Koha › Catalog › Your cart +[% INCLUDE 'doc-head-close.inc' %] -[% IF ( print_basket ) %][% ELSE %][% END %] + +
-[% UNLESS ( print_basket ) %] +

Your cart

@@ -69,25 +61,17 @@ Empty and close Hide window
- [% END %] + [% IF ( verbose ) %] - [% UNLESS ( print_basket ) %] [% PROCESS controls %] - [% END %]
[% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %]

- [% IF ( print_basket ) %] - [% BIBLIO_RESULT.title |html %] - [% FOREACH subtitl IN BIBLIO_RESULT.subtitle %] [% subtitl.subfield | html %][% END %] - [% IF ( BIBLIO_RESULT.author ) %] [% BIBLIO_RESULT.author %][% END %] - [% ELSE %] - - [% BIBLIO_RESULT.title |html %] - [% FOREACH subtitl IN BIBLIO_RESULT.subtitle %] [% subtitl.subfield | html %][% END %] - [% IF ( BIBLIO_RESULT.author ) %] [% BIBLIO_RESULT.author %][% END %] - [% END %] + + [% BIBLIO_RESULT.title |html %] + [% FOREACH subtitl IN BIBLIO_RESULT.subtitle %] [% subtitl.subfield | html %][% END %] + [% IF ( BIBLIO_RESULT.author ) %] [% BIBLIO_RESULT.author %][% END %]

@@ -235,14 +219,13 @@
[% ELSE %] -[% UNLESS ( print_basket ) %] +
[% PROCESS controls %] -[% END %] - [% UNLESS ( print_basket ) %][% END %] + @@ -250,10 +233,10 @@ [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %] - [% UNLESS ( print_basket ) %] [% END %] +
   Title Item type Items
+ - [% BIBLIO_RESULT.title |html %] [% FOREACH subtitl IN BIBLIO_RESULT.subtitle %] [% subtitl.subfield | html %][% END %] @@ -294,10 +277,8 @@ [% INCLUDE js_includes.inc %] - [% UNLESS ( print_basket ) %] - [% INCLUDE 'datatables.inc' %] - [% Asset.js("js/cart.js") %] - [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %] - [% END %] + [% INCLUDE 'datatables.inc' %] + [% Asset.js("js/cart.js") %] + [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/basket.js b/koha-tmpl/intranet-tmpl/prog/js/basket.js index e477cce961..d6ca7becce 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/basket.js +++ b/koha-tmpl/intranet-tmpl/prog/js/basket.js @@ -381,8 +381,7 @@ function downloadBasket() { } function printBasket() { - var loc = document.location + "&print=1"; - document.location = loc; + window.print(); } function showMore() { diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt index 44a88b99c3..77b5b194bb 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt @@ -15,7 +15,7 @@

Your cart

-
+
[% IF ( verbose ) %] Brief display [% ELSE %] @@ -30,7 +30,7 @@ Hide window
-
+
Select all Clear all | diff --git a/koha-tmpl/opac-tmpl/bootstrap/less/print.less b/koha-tmpl/opac-tmpl/bootstrap/less/print.less index 92153cc04c..8f837ac4ca 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/less/print.less +++ b/koha-tmpl/opac-tmpl/bootstrap/less/print.less @@ -153,32 +153,40 @@ body#basket a { } body#basket table { - border-top : 1px solid #EEE; - border-left : 1px solid #EEE; + border-collapse: collapse; } + body#basket td, body#basket th { background-color : transparent; + border: 0; padding : 2px; } body#basket th { background-color : #EEE; + border: 0; } body#basket th, body#basket th[scope=col] { + border: 0; text-align : center; vertical-align : middle; } body#basket th[scope=row] { + border: 0; font-size : 89%; text-align : right; vertical-align : top; width : 10%; } +#basket tr { + border-bottom: 1px solid #DDD; +} + body#basket p { font-size : 85%; margin : .2em 0; @@ -243,3 +251,8 @@ div#userupdate input,div#userupdate textarea { #ulactioncontainer { display: none; } + +.main, +.table-bordered { + border: 0; +} \ No newline at end of file -- 2.39.5