HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/ERijn/knijft.eu/wwwroot/wp-content/plugins/multisite-language-switcher/js/msls.js
jQuery( document ).ready( function( $ ) {
	$( 'input.msls_title' ).focus( function() {
		var blog_id   = $( this ).attr( 'name' ).slice( 11 );
		var hid_field = $( '#msls_id_' + blog_id );
		var mslsinput = {
			id: hid_field.val(),
			title: $( this ).val()
		};
		$( this ).select().autocomplete( {
			minLength: 0,
			source: function( request, response ) {
				$.ajax( {
					url: ajaxurl,
					data: {
						post_type: $( '#msls_post_type' ).val(),
						blog_id: blog_id,
						s: request.term,
						action: $( '#msls_action' ).val()
					},
					dataType: 'JSON',
					type: 'POST',
					success: function( data ) {
						response( data ); 
					}
				} );
			},
			focus: function( event, ui ) {
				$( event.target ).val( ui.item.label );
				return false;
			},
			select: function( event, ui ) {
				$( event.target ).val( ui.item.label );
				hid_field.val( ui.item.value );
				return false;
			},
			change: function( event, ui ) {
				if ( !$( event.target ).val() ) {
					hid_field.val( '' );
				}
				else if (
					mslsinput.id === hid_field.val() &&
					mslsinput.title !== $( event.target ).val()
				) {
					$( event.target ).val( mslsinput.title );
				}
				return false;
			}
		} );
	} );
} );