2018-06-27 22:30:15 -04:00
|
|
|
/**
|
|
|
|
* @output wp-admin/js/language-chooser.js
|
|
|
|
*/
|
|
|
|
|
2014-08-04 16:47:16 -04:00
|
|
|
jQuery( function($) {
|
2018-06-27 22:24:43 -04:00
|
|
|
/*
|
|
|
|
* Set the correct translation to the continue button and show a spinner
|
|
|
|
* when downloading a language.
|
|
|
|
*/
|
2014-08-04 16:47:16 -04:00
|
|
|
var select = $( '#language' ),
|
|
|
|
submit = $( '#language-continue' );
|
2014-07-07 20:30:14 -04:00
|
|
|
|
2014-08-04 16:47:16 -04:00
|
|
|
if ( ! $( 'body' ).hasClass( 'language-chooser' ) ) {
|
|
|
|
return;
|
|
|
|
}
|
2014-07-07 20:30:14 -04:00
|
|
|
|
2021-02-23 14:45:04 -05:00
|
|
|
select.trigger( 'focus' ).on( 'change', function() {
|
2018-06-27 22:24:43 -04:00
|
|
|
/*
|
|
|
|
* When a language is selected, set matching translation to continue button
|
|
|
|
* and attach the language attribute.
|
|
|
|
*/
|
2014-08-04 16:47:16 -04:00
|
|
|
var option = select.children( 'option:selected' );
|
|
|
|
submit.attr({
|
|
|
|
value: option.data( 'continue' ),
|
|
|
|
lang: option.attr( 'lang' )
|
2014-07-07 20:30:14 -04:00
|
|
|
});
|
2014-08-04 16:47:16 -04:00
|
|
|
});
|
2014-07-07 20:30:14 -04:00
|
|
|
|
2021-02-23 14:45:04 -05:00
|
|
|
$( 'form' ).on( 'submit', function() {
|
2018-06-27 22:24:43 -04:00
|
|
|
// Show spinner for languages that need to be downloaded.
|
2014-08-04 16:47:16 -04:00
|
|
|
if ( ! select.children( 'option:selected' ).data( 'installed' ) ) {
|
|
|
|
$( this ).find( '.step .spinner' ).css( 'visibility', 'visible' );
|
|
|
|
}
|
|
|
|
});
|
2014-07-07 20:33:15 -04:00
|
|
|
|
2014-08-04 16:47:16 -04:00
|
|
|
});
|