Koha/koha-tmpl/intranet-tmpl/prog/en/js/ajax.js
Owen Leonard 538ab5631e Bug 2774 - Path to theme is hard-coded in many places
This patch corrects more places in Koha where the path to the "prog"
theme is hard-coded in templates, CSS, and scripts.

Staff client home page:

Paths to the Koha logo background image and the module image sprite have
been corrected. Inactive and hover states of the module links
(circulation, patrons, etc) should look correct.

addbiblio.pl:

An <img> tag is replaced with a text link and an
additional CSS class. CSS uses an image-replacement technique to display
the image as before.

To test, open a blank or existing bibliographic record for editing.
Confirm that the "tag editor" icon displays correctly in two cases: 1)
tags linked to plugin editors and 2) tags linked to authorities. Both
should look correct and work correctly.

System preferences:

The system preferences editor appends a "loading" image to system
preference submit buttons when they are clicked. This patch changes
ajax.js to insert a <span> styled with a background-image instead.

To test, open system preferences and modify any preference. Submit the
change and confirm that the "loading" image appears correctly.

Background jobs:

Any place in Koha where a background job is used displays a progress
bar. This patch corrects the path in CSS to the progress bar image. To
test, perform an action which triggers the display of a progress bar.
For instance, batch modification of items. Confirm that the progress bar
image displays correctly.

blue.css:

I don't know if this is still used by anyone, but a couple of image
paths in this CSS file have been corrected.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests, QA script and test plan.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2013-07-18 16:49:18 +00:00

88 lines
3.3 KiB
JavaScript

if ( KOHA === undefined ) var KOHA = {};
KOHA.AJAX = {
Submit: function ( options ) {
var error_callback = options.error;
$.extend( options, {
cache: false,
dataType: 'json',
type: 'POST',
error: function ( xhr, stat, error ) { KOHA.AJAX.BaseError( error_callback, xhr, stat, error ); }
} );
$.ajax( options );
},
BaseError: function ( callback, xhr, stat, e ) {
KOHA.xhr = xhr;
if ( !xhr.getResponseHeader( 'content-type' ).match( 'application/json' ) ) {
// Something really failed
humanMsg.displayAlert( MSG_INTERNAL_SERVER_ERROR );
return;
}
var error = eval( '(' + xhr.responseText + ')' );
if ( error.type == 'auth' ) {
humanMsg.displayMsg( MSG_SESSION_TIMED_OUT );
}
if ( callback ) {
callback( error );
} else {
humanMsg.displayAlert( MSG_DATA_NOT_SAVED );
}
},
MarkRunning: function ( selector, text ) {
text = text || _("Loading...");
$( selector )
.attr( 'disabled', 'disabled' )
.each( function () {
var $spinner = $( '<span class="loading"></span>' );
var selector_type = this.localName;
if (selector_type === undefined) selector_type = this.nodeName; // IE only
switch ( selector_type.toLowerCase() ) {
case 'input':
$( this ).data( 'original-text', this.value );
this.value = text;
break;
case 'a':
$( this )
.data( 'original-text', $( this ).text )
.text( text )
.before( $spinner )
.bind( 'click.disabled', function () { return false; } );
break;
case 'button':
$( this )
.data( 'original-text', $( this ).text() )
.text( text )
.prepend( $spinner );
break;
}
} );
},
MarkDone: function ( selector ) {
$( selector )
.removeAttr( 'disabled' )
.each( function () {
var selector_type = this.localName;
if (selector_type === undefined) selector_type = this.nodeName; // IE only
switch ( selector_type.toLowerCase() ) {
case 'input':
this.value = $( this ).data( 'original-text' );
break;
case 'a':
$( this )
.text( $( this ).data( 'original-text' ) )
.unbind( 'click.disabled' )
.prevAll( 'span.loading' ).remove();
break;
case 'button':
$( this )
.text( $( this ).data( 'original-text' ) )
.find( 'span.loading' ).remove();
break;
}
} )
.removeData( 'original-text' );
}
};