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