Koha/koha-tmpl/intranet-tmpl/prog/js/ajax.js
Owen Leonard 5e1bcc4aa7 Bug 16242 - Move staff client JavaScript out of language directory
This patch moves the JavaScript files in prog/en/js to prog/js.
JavaScript files do not need to be in the directory which is processed
by the translator.

To test, apply the patch and visit various pages in the staff client to
confirm that JavaScript files are still loading correctly.

Revised: I intended for this to be built on top of Bug 15883 as well as
Bug 16242. Now it is.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
On top of 15883 and 16241
All seems to work, js files pulled from new dir.
No errors

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-04-29 14:32:42 +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 )
.prop('disabled', true)
.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 )
.prop('disabled', false)
.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' );
}
};