1 // We can assume 'KOHA' exists, as we depend on KOHA.AJAX
4 Save: function ( form ) {
5 data = $( form ).find( '.modified' ).serialize();
7 humanMsg.displayAlert( 'Nothing to save' );
10 KOHA.AJAX.MarkRunning( $( form ).find( '.save-all' ), _( 'Saving...' ) );
13 url: '/cgi-bin/koha/svc/config/systempreferences/',
14 success: function ( data ) { KOHA.Preferences.Success( form ) },
15 complete: function () { KOHA.AJAX.MarkDone( $( form ).find( '.save-all' ) ) }
18 Success: function ( form ) {
19 humanMsg.displayAlert( 'Saved' );
22 .find( '.modified-warning' ).remove().end()
23 .find( '.modified' ).removeClass('modified');
24 KOHA.Preferences.Modified = false;
28 $( document ).ready( function () {
29 function mark_modified() {
30 $( this.form ).find( '.save-all' ).removeAttr( 'disabled' );
31 $( this ).addClass( 'modified' );
32 var name_cell = $( this ).parent().parent().find( '.name-cell' );
34 if ( !name_cell.find( '.modified-warning' ).length ) name_cell.append( '<em class="modified-warning">(modified)</em>' );
35 KOHA.Preferences.Modified = true;
39 .find( 'input.preference, textarea.preference' ).keyup( function () {
40 if ( this.defaultValue === undefined || this.value != this.defaultValue ) mark_modified.call( this );
42 .find( 'select.preference' ).change( mark_modified );
44 window.onbeforeunload = function () {
45 if ( KOHA.Preferences.Modified ) {
46 return _( "You have made changes to system preferences." );
50 $( '.prefs-tab .action .cancel' ).click( function () { KOHA.Preferences.Modified = false } );
52 $( '.prefs-tab .save-all' ).attr( 'disabled', true ).click( function () {
53 KOHA.Preferences.Save( this.form );
57 $( '.prefs-tab .expand-textarea' ).show().click( function () {
58 $( this ).hide().nextAll( 'textarea, input[type=submit]' )
59 .animate( { height: 'show', queue: false } )
60 .animate( { opacity: 1 } );
63 } ).nextAll( 'textarea, input[type=submit]' ).hide().css( { opacity: 0 } );
65 $("h3").attr("class","expanded").attr("title",_("Click to expand this section"));
66 var collapsible = $(".collapsed,.expanded");
68 $(collapsible).toggle(
70 $(this).addClass("collapsed").removeClass("expanded").attr("title",_("Click to expand this section"));
71 $(this).next("table").hide();
74 $(this).addClass("expanded").removeClass("collapsed").attr("title",_("Click to collapse this section"));
75 $(this).next("table").show();
80 var words = to_highlight.split( ' ' );
81 $( '.prefs-tab table' ).find( 'td, th' ).not( '.name-cell' ).each( function ( i, td ) {
82 $.each( words, function ( i, word ) { $( td ).highlight( word ) } );
83 } ).find( 'option' ).removeHighlight();
86 if ( search_jumped ) {
87 document.location.hash = "jumped";