1/**
2 * @output wp-admin/js/language-chooser.js
3 */
4
5jQuery( function($) {
6/*
7 * Set the correct translation to the continue button and show a spinner
8 * when downloading a language.
9 */
10var select = $( '#language' ),
11 submit = $( '#language-continue' );
12
13if ( ! $( 'body' ).hasClass( 'language-chooser' ) ) {
14 return;
15}
16
17select.trigger( 'focus' ).on( 'change', function() {
18 /*
19 * When a language is selected, set matching translation to continue button
20 * and attach the language attribute.
21 */
22 var option = select.children( 'option:selected' );
23 submit.attr({
24 value: option.data( 'continue' ),
25 lang: option.attr( 'lang' )
26 });
27});
28
29$( 'form' ).on( 'submit', function() {
30 // Show spinner for languages that need to be downloaded.
31 if ( ! select.children( 'option:selected' ).data( 'installed' ) ) {
32 $( this ).find( '.step .spinner' ).css( 'visibility', 'visible' );
33 }
34});
35
36});
37