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( _( 'Internal Server Error, please reload the page' ) );
22 var error = eval( '(' + xhr.responseText + ')' );
24 if ( error.type == 'auth' ) {
25 humanMsg.displayMsg( _( 'You need to log in again, your session has timed out' ) );
31 humanMsg.displayAlert( _( 'Error; your data might not have been saved' ) );
34 MarkRunning: function ( selector, text ) {
35 text = text || _( 'Loading...' );
37 .attr( 'disabled', 'disabled' )
39 var $image = $( '<img src="/intranet-tmpl/prog/img/spinner-small.gif" alt="" class="spinner" />' );
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 .removeAttr( 'disabled' )
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( 'img.spinner' ).remove();
81 .text( $( this ).data( 'original-text' ) )
82 .find( 'img.spinner' ).remove();
86 .removeData( 'original-text' );