1 if ( KOHA === undefined ) var KOHA = {};
4 Submit: function ( options ) {
5 var error_callback = options.error;
10 error: function ( xhr, stat, error ) { KOHA.AJAX.BaseError( error_callback, xhr, stat, error ); }
14 BaseError: function ( callback, xhr, stat, e ) {
16 if ( !xhr.getResponseHeader( 'content-type' ).match( 'application/json' ) ) {
17 // Something really failed
18 humanMsg.displayAlert( MSG_INTERNAL_SERVER_ERROR );
22 var error = eval( '(' + xhr.responseText + ')' );
24 if ( error.type == 'auth' ) {
25 humanMsg.displayMsg( MSG_SESSION_TIMED_OUT );
31 humanMsg.displayAlert( MSG_DATA_NOT_SAVED );
34 MarkRunning: function ( selector, text ) {
35 text = text || _("Loading...");
37 .prop('disabled', true)
39 var $spinner = $( '<span class="loading"></span>' );
40 var selector_type = this.localName;
41 if (selector_type === undefined) selector_type = this.nodeName; // IE only
42 switch ( selector_type.toLowerCase() ) {
44 $( this ).data( 'original-text', this.value );
49 .data( 'original-text', $( this ).text )
52 .bind( 'click.disabled', function () { return false; } );
56 .data( 'original-text', $( this ).text() )
63 MarkDone: function ( selector ) {
65 .prop('disabled', false)
67 var selector_type = this.localName;
68 if (selector_type === undefined) selector_type = this.nodeName; // IE only
69 switch ( selector_type.toLowerCase() ) {
71 this.value = $( this ).data( 'original-text' );
75 .text( $( this ).data( 'original-text' ) )
76 .unbind( 'click.disabled' )
77 .prevAll( 'span.loading' ).remove();
81 .text( $( this ).data( 'original-text' ) )
82 .find( 'span.loading' ).remove();
86 .removeData( 'original-text' );