| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @output wp-admin/js/language-chooser.js | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | jQuery( function($) { | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Set the correct translation to the continue button and show a spinner | 
					
						
							|  |  |  |  * when downloading a language. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | var select = $( '#language' ), | 
					
						
							|  |  |  | 	submit = $( '#language-continue' ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ( ! $( 'body' ).hasClass( 'language-chooser' ) ) { | 
					
						
							|  |  |  | 	return; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | select.focus().on( 'change', function() { | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 	/* | 
					
						
							|  |  |  | 	 * When a language is selected, set matching translation to continue button | 
					
						
							|  |  |  | 	 * and attach the language attribute. | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 	var option = select.children( 'option:selected' ); | 
					
						
							|  |  |  | 	submit.attr({ | 
					
						
							|  |  |  | 		value: option.data( 'continue' ), | 
					
						
							|  |  |  | 		lang: option.attr( 'lang' ) | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $( 'form' ).submit( function() { | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 	// Show spinner for languages that need to be downloaded.
 | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 	if ( ! select.children( 'option:selected' ).data( 'installed' ) ) { | 
					
						
							|  |  |  | 		$( this ).find( '.step .spinner' ).css( 'visibility', 'visible' ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }); |