1 $(document).ready(function() {
2 $("table.preferences").tablesorter({
4 headers: { 1: { sorter:false}}
8 // We can assume 'KOHA' exists, as we depend on KOHA.AJAX
11 Save: function ( form ) {
12 modified_prefs = $( form ).find( '.modified' );
13 data = modified_prefs.serialize();
15 humanMsg.displayAlert( MSG_NOTHING_TO_SAVE );
18 KOHA.AJAX.MarkRunning( $( form ).find( '.save-all' ), _( MSG_SAVING ) );
21 url: '/cgi-bin/koha/svc/config/systempreferences/',
22 success: function ( data ) { KOHA.Preferences.Success( form ) },
23 complete: function () { KOHA.AJAX.MarkDone( $( form ).find( '.save-all' ) ) }
26 Success: function ( form ) {
28 modified_prefs.each(function(){
29 var modified_pref = $(this).attr("id");
30 modified_pref = modified_pref.replace("pref_","");
31 msg += '<strong>Saved preference '+modified_pref+'</strong>\n';
33 humanMsg.displayAlert(msg);
36 .find( '.modified-warning' ).remove().end()
37 .find( '.modified' ).removeClass('modified');
38 KOHA.Preferences.Modified = false;
42 $( document ).ready( function () {
43 function mark_modified() {
44 $( this.form ).find( '.save-all' ).removeAttr( 'disabled' );
45 $( this ).addClass( 'modified' );
46 var name_cell = $( this ).parents( '.name-row' ).find( '.name-cell' );
47 if ( !name_cell.find( '.modified-warning' ).length )
48 name_cell.append( '<em class="modified-warning">('+MSG_MODIFIED+')</em>' );
49 KOHA.Preferences.Modified = true;
53 .find( 'input.preference, textarea.preference' ).keyup( function () {
54 if ( this.defaultValue === undefined || this.value != this.defaultValue ) mark_modified.call( this );
56 .find( 'select.preference' ).change( mark_modified );
57 $('.preference-checkbox').change( function () {
58 $('.preference-checkbox').addClass('modified');
59 mark_modified.call(this);
62 window.onbeforeunload = function () {
63 if ( KOHA.Preferences.Modified ) {
64 return MSG_MADE_CHANGES;
68 $( '.prefs-tab .action .cancel' ).click( function () { KOHA.Preferences.Modified = false } );
70 $( '.prefs-tab .save-all' ).attr( 'disabled', true ).click( function () {
71 KOHA.Preferences.Save( this.form );
75 $( '.prefs-tab .expand-textarea' ).show().click( function () {
76 $( this ).hide().nextAll( 'textarea, input[type=submit]' )
77 .animate( { height: 'show', queue: false } )
78 .animate( { opacity: 1 } );
81 } ).nextAll( 'textarea, input[type=submit]' ).hide().css( { opacity: 0 } );
83 $("h3").attr("class","expanded").attr("title",MSG_CLICK_TO_EXPAND);
84 var collapsible = $(".collapsed,.expanded");
86 $(collapsible).toggle(
88 $(this).addClass("collapsed").removeClass("expanded").attr("title",MSG_CLICK_TO_EXPAND);
89 $(this).next("table").hide();
92 $(this).addClass("expanded").removeClass("collapsed").attr("title",MSG_CLICK_TO_COLLAPSE);
93 $(this).next("table").show();
98 var words = to_highlight.split( ' ' );
99 $( '.prefs-tab table' ).find( 'td, th' ).not( '.name-cell' ).each( function ( i, td ) {
100 $.each( words, function ( i, word ) { $( td ).highlight( word ) } );
101 } ).find( 'option' ).removeHighlight();
104 if ( search_jumped ) {
105 document.location.hash = "jumped";