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 $(".set_syspref").click(function() {
63 var s = $(this).attr('data-syspref');
64 var v = $(this).attr('data-value');
65 // populate the input with the value in data-value
67 // pass the DOM element to trigger "modified" to enable submit button
68 mark_modified.call($("#pref_"+s)[0]);
72 window.onbeforeunload = function () {
73 if ( KOHA.Preferences.Modified ) {
74 return MSG_MADE_CHANGES;
78 $( '.prefs-tab .action .cancel' ).click( function () { KOHA.Preferences.Modified = false } );
80 $( '.prefs-tab .save-all' ).attr( 'disabled', true ).click( function () {
81 KOHA.Preferences.Save( this.form );
85 $( '.prefs-tab .expand-textarea' ).show().click( function () {
86 $( this ).hide().nextAll( 'textarea, input[type=submit]' )
87 .animate( { height: 'show', queue: false } )
88 .animate( { opacity: 1 } );
91 } ).nextAll( 'textarea, input[type=submit]' ).hide().css( { opacity: 0 } );
93 $("h3").attr("class","expanded").attr("title",MSG_CLICK_TO_EXPAND);
94 var collapsible = $(".collapsed,.expanded");
96 $(collapsible).toggle(
98 $(this).addClass("collapsed").removeClass("expanded").attr("title",MSG_CLICK_TO_EXPAND);
99 $(this).next("table").hide();
102 $(this).addClass("expanded").removeClass("collapsed").attr("title",MSG_CLICK_TO_COLLAPSE);
103 $(this).next("table").show();
107 if ( to_highlight ) {
108 var words = to_highlight.split( ' ' );
109 $( '.prefs-tab table' ).find( 'td, th' ).not( '.name-cell' ).each( function ( i, td ) {
110 $.each( words, function ( i, word ) { $( td ).highlight( word ) } );
111 } ).find( 'option' ).removeHighlight();
114 if ( search_jumped ) {
115 document.location.hash = "jumped";