@@ -, +, @@ --- koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js | 10 ++- .../intranet-tmpl/prog/en/modules/circ/returns.tt | 21 +++-- .../prog/en/modules/tools/delay-load.tt | 36 +++++++++ tools/delay-load.pl | 83 ++++++++++++++++++++ 4 files changed, 140 insertions(+), 10 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/delay-load.tt create mode 100755 tools/delay-load.pl --- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js +++ a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js @@ -101,4 +101,12 @@ jQuery.fn.preventDoubleFormSubmit = function() { else this.beenSubmitted = true; }); -}; +}; + +function delayPopup( link, title, delay ) { + link = "/cgi-bin/koha/tools/delay-load.pl?url=" + escape( link ) + "&message=" + encodeURI( title ) + "&delay=" + delay; + alert( link ); + var childWindow = window.open(link,'popup','width=600,height=400,resizable=1,toolbar=0,scrollbars=1,top'); + return childWindow; +} + --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -4,9 +4,12 @@ [% INCLUDE 'doc-head-close.inc' %] + + +
+

[% message %]

+ +

Loading, Please Wait

+ +
+
+[% INCLUDE 'intranet-bottom.inc' %] --- a/tools/delay-load.pl +++ a/tools/delay-load.pl @@ -0,0 +1,83 @@ +#!/usr/bin/perl + +# Copyright 2012 Bywater Solutions +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +=pod + +The purpose of this script is simply to +delay the loading of another page. This is +useful to ensure race conditions are avoided +for items such as pop-up windows for printing +slips. + +This script accepts the following cgi parameters: +url - The url to forward to +message - An optional message to display during the delay +delay - The amount of time in seconds the delay should last + +A javascript function has been added to the staff functions js +file to facility easy use of this script. Use the function as follows: + +delayPopup( url, message, delay ); + +where url is the url of the +page to load ( supports GET variables ), message is an optional +message to display, and delay is the amount of time in seconds +to delay the loading of this new url. This function will automatically +urlencode the passed url and message. If you use this script directly, +you will need to urlencode your data manually. + +=cut + +use strict; +use warnings; + +use C4::Auth; +use C4::Context; +use C4::Output; +use CGI; + +use vars qw($debug); + +BEGIN { + $debug = $ENV{DEBUG} || 0; +} + +my $input = new CGI; + +my $url = $input->param('url'); +my $message = $input->param('message'); +my $delay = $input->param('delay'); + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "tools/delay-load.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + debug => $debug, + } +); + +$template->param( + url => $url, + message => $message, + delay => $delay, +); + +output_html_with_http_headers $input, $cookie, $template->output; --