@@ -, +, @@ * Extends login screen to pass along #hash * Adds JSONP support to C4::Service * Extends humanmsg to allow per-message classes * Adds proper charset to results of svc/bib --- C4/Auth.pm | 2 ++ C4/Service.pm | 16 +++++++++--- .../intranet-tmpl/lib/jquery/plugins/humanmsg.js | 29 +++++++++++----------- koha-tmpl/intranet-tmpl/prog/en/css/humanmsg.css | 15 ++++++----- .../intranet-tmpl/prog/en/css/staff-global.css | 11 +++++--- koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt | 8 ++++++ svc/bib | 2 +- 7 files changed, 56 insertions(+), 27 deletions(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -302,6 +302,8 @@ sub get_template_and_user { $template->param(dateformat => C4::Context->preference('dateformat')) } + $template->param(auth_forwarded_hash => $in->{'query'}->param('auth_forwarded_hash')); + # these template parameters are set the same regardless of $in->{'type'} $template->param( "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, --- a/C4/Service.pm +++ a/C4/Service.pm @@ -55,6 +55,16 @@ BEGIN { our ( $query, $cookie ); +sub _output { + my ( $response, $status ) = @_; + + if ( $query->param( 'callback' ) ) { + output_with_http_headers $query, $cookie, $query->param( 'callback' ) . '(' . $response->output . ');', 'js'; + } else { + output_with_http_headers $query, $cookie, $response->output, 'json', $status; + } +} + =head1 METHODS =head2 init @@ -113,7 +123,7 @@ sub return_error { $response->param( message => $error ) if ( $error ); $response->param( type => $type, %flags ); - output_with_http_headers $query, $cookie, $response->output, 'json', '400 Bad Request'; + _output( $response, '400 Bad Request' ); exit; } @@ -159,7 +169,7 @@ sub return_multi { } $response->param( 'multi' => JSON::true, responses => \@responses_formatted, @flags ); - output_with_http_headers $query, $cookie, $response->output, 'json', '207 Multi-Status'; + _output( $response, '207 Multi-Status' ); } exit; @@ -177,7 +187,7 @@ exit with HTTP status 200. sub return_success { my ( $class, $response ) = @_; - output_with_http_headers $query, $cookie, $response->output, 'json'; + _output( $response ); } =head2 require_params --- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/humanmsg.js +++ a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/humanmsg.js @@ -21,7 +21,7 @@ var humanMsg = { if (msgOpacity != undefined) humanMsg.msgOpacity = parseFloat(msgOpacity); // Inject the message structure - jQuery(appendTo).append('
'+logName+'
'+logName+'
' + msg + '
', $.extend({log: false}, options), true); }, - displayMsg: function(msg, options, is_alert) { + displayMsg: function(msg, options) { if (msg == '') return; - if (options != undefined) { - delay = 'delay' in options ? parseInt(options.delay) * 1000 : 1000 - life = 'life' in options ? parseInt(options.life) * 1000 : Infinity - } else { - delay = 1000 - life = Infinity - } + options = $.extend({ + delay: 1000, + life: Infinity, + log: true, + className: '', + }, options); + clearTimeout(humanMsg.t1); clearTimeout(humanMsg.t2); // Inject message - jQuery('#'+humanMsg.msgID+'-contents').html(is_alert ? ('' + msg + '
') : msg) + jQuery('#'+humanMsg.msgID+'-contents').html(msg); // Show message - jQuery('#'+humanMsg.msgID).show().animate({ opacity: humanMsg.msgOpacity}, 200, function() { + jQuery('#'+humanMsg.msgID).attr('class', 'humanMsg ' + options.className).show().animate({ opacity: humanMsg.msgOpacity}, 200, function() { + if ( !options.log ) return true; jQuery('#'+humanMsg.logID) .show().children('ul').prepend('