[ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 /* global $gp_mass_create_sets_options, $gp */ 2 /* eslint camelcase: "off" */ 3 jQuery( function( $ ) { 4 $gp.notices.init(); 5 $( '#project_id' ).change( function() { 6 var select = $( this ); 7 var project_id = $( 'option:selected', select ).attr( 'value' ); 8 if ( ! project_id ) { 9 $( '#submit' ).prop( 'disabled', true ); 10 $( '#preview' ).hide(); 11 return; 12 } 13 $gp.notices.notice( $gp_mass_create_sets_options.loading ); 14 select.prop( 'disabled', true ); 15 $.ajax( { type: 'POST', url: $gp_mass_create_sets_options.url, data: { project_id: project_id }, dataType: 'json', 16 success: function( data ) { 17 var preview = $( '#preview' ); 18 var preview_html = ''; 19 preview.html( '<h3>Preview changes:</h3>' ); 20 preview_html += '<ul>'; 21 select.prop( 'disabled', false ); 22 $gp.notices.clear(); 23 if ( data.added.length || data.removed.length ) { 24 $( '#submit' ).prop( 'disabled', false ); 25 } 26 function preview_html_for( kind, text ) { 27 var sets = data[ kind ]; 28 var html = ''; 29 html += '<li><span class="' + kind + '">' + text.replace( '{count}', sets.length ) + '</span>'; 30 if ( sets.length ) { 31 html += '<ul>'; 32 $.each( sets, function() { 33 html += '<li>' + $gp.esc_html( this.name ) + ' (' + this.locale + '/' + this.slug + ')</li>'; 34 } ); 35 html += '</ul>'; 36 } 37 html += '</li>'; 38 return html; 39 } 40 preview_html += preview_html_for( 'added', '{count} set(s) will be added' ); 41 preview_html += preview_html_for( 'removed', '{count} set(s) will be removed' ); 42 preview_html += '</ul>'; 43 preview.append( preview_html ); 44 preview.fadeIn(); 45 }, 46 error: function( xhr, msg ) { 47 select.prop( 'disabled', false ); 48 msg = xhr.responsehtml ? 'Error: ' + xhr.responsehtml : 'Error saving the translation!'; 49 $gp.notices.error( msg ); 50 }, 51 } ); 52 } ); 53 $( '#submit' ).prop( 'disabled', true ); 54 $( '#preview' ).hide(); 55 } );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:01:04 2024 | Cross-referenced by PHPXref 0.7.1 |