1 // We can assume 'KOHA' exists, as we depend on KOHA.AJAX
4 Save: function ( form ) {
5 modified_prefs = $( form ).find( '.modified' );
6 data = modified_prefs.serialize();
8 humanMsg.displayAlert( MSG_NOTHING_TO_SAVE );
11 KOHA.AJAX.MarkRunning( $( form ).find( '.save-all' ), _( MSG_SAVING ) );
14 url: '/cgi-bin/koha/svc/config/systempreferences/',
15 success: function ( data ) { KOHA.Preferences.Success( form ) },
16 complete: function () { KOHA.AJAX.MarkDone( $( form ).find( '.save-all' ) ) }
19 Success: function ( form ) {
21 modified_prefs.each(function(){
22 var modified_pref = $(this).attr("id");
23 modified_pref = modified_pref.replace("pref_","");
24 msg += '<strong>Saved preference '+modified_pref+'</strong>\n';
26 humanMsg.displayAlert(msg);
29 .find( '.modified-warning' ).remove().end()
30 .find( '.modified' ).removeClass('modified');
31 KOHA.Preferences.Modified = false;
35 $( document ).ready( function () {
37 $("table.preferences").dataTable($.extend(true, {}, dataTablesDefaults, {
40 { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }
45 function mark_modified() {
46 $( this.form ).find( '.save-all' ).removeAttr( 'disabled' );
47 $( this ).addClass( 'modified' );
48 var name_cell = $( this ).parents( '.name-row' ).find( '.name-cell' );
49 if ( !name_cell.find( '.modified-warning' ).length )
50 name_cell.append( '<em class="modified-warning">('+MSG_MODIFIED+')</em>' );
51 KOHA.Preferences.Modified = true;
55 .find( 'input.preference, textarea.preference' ).keyup( function () {
56 if ( this.defaultValue === undefined || this.value != this.defaultValue ) mark_modified.call( this );
58 .find( 'select.preference' ).change( mark_modified );
59 $('.preference-checkbox').change( function () {
60 $('.preference-checkbox').addClass('modified');
61 mark_modified.call(this);
64 $(".set_syspref").click(function() {
65 var s = $(this).attr('data-syspref');
66 var v = $(this).attr('data-value');
67 // populate the input with the value in data-value
69 // pass the DOM element to trigger "modified" to enable submit button
70 mark_modified.call($("#pref_"+s)[0]);
74 window.onbeforeunload = function () {
75 if ( KOHA.Preferences.Modified ) {
76 return MSG_MADE_CHANGES;
80 $( '.prefs-tab .action .cancel' ).click( function () { KOHA.Preferences.Modified = false } );
82 $( '.prefs-tab .save-all' ).attr( 'disabled', true ).click( function () {
83 KOHA.Preferences.Save( this.form );
87 $( '.prefs-tab .expand-textarea' ).show().click( function () {
88 $( this ).hide().nextAll( 'textarea, input[type=submit]' )
89 .animate( { height: 'show', queue: false } )
90 .animate( { opacity: 1 } );
93 } ).nextAll( 'textarea, input[type=submit]' ).hide().css( { opacity: 0 } );
95 $("h3").attr("class","expanded").attr("title",MSG_CLICK_TO_EXPAND);
96 var collapsible = $(".collapsed,.expanded");
98 $(collapsible).toggle(
100 $(this).addClass("collapsed").removeClass("expanded").attr("title",MSG_CLICK_TO_EXPAND);
101 $(this).next("div").hide();
104 $(this).addClass("expanded").removeClass("collapsed").attr("title",MSG_CLICK_TO_COLLAPSE);
105 $(this).next("div").show();
109 if ( to_highlight ) {
110 var words = to_highlight.split( ' ' );
111 $( '.prefs-tab table' ).find( 'td, th' ).not( '.name-cell' ).each( function ( i, td ) {
112 $.each( words, function ( i, word ) { $( td ).highlight( word ) } );
113 } ).find( 'option, textarea' ).removeHighlight();
116 if ( search_jumped ) {
117 document.location.hash = "jumped";