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
|
|
|
|
2014-08-04 16:47:16 -04:00
|
|
|
select.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
|
|
|
|
2014-08-04 16:47:16 -04:00
|
|
|
$( 'form' ).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
|
|
|
});
|