/* global $gp_mass_create_sets_options, $gp */ /* eslint camelcase: "off" */ jQuery( function( $ ) { $gp.notices.init(); $( '#project_id' ).change( function() { var select = $( this ); var project_id = $( 'option:selected', select ).attr( 'value' ); if ( ! project_id ) { $( '#submit' ).prop( 'disabled', true ); $( '#preview' ).hide(); return; } $gp.notices.notice( $gp_mass_create_sets_options.loading ); select.prop( 'disabled', true ); $.ajax( { type: 'POST', url: $gp_mass_create_sets_options.url, data: { project_id: project_id }, dataType: 'json', success: function( data ) { var preview = $( '#preview' ); var preview_html = ''; preview.html( '

Preview changes:

' ); preview_html += ''; preview.append( preview_html ); preview.fadeIn(); }, error: function( xhr, msg ) { select.prop( 'disabled', false ); msg = xhr.responsehtml ? 'Error: ' + xhr.responsehtml : 'Error saving the translation!'; $gp.notices.error( msg ); }, } ); } ); $( '#submit' ).prop( 'disabled', true ); $( '#preview' ).hide(); } );