From ac5a3fc7a890b1159b7cd78af9a58652debef247 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 9 Nov 2017 03:54:13 +0000 Subject: [PATCH] Settings: Fix date/time format previewing. Props afercia. Amends [41857]. Fixes #41603. git-svn-id: https://develop.svn.wordpress.org/trunk@42134 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/forms.css | 2 +- src/wp-admin/includes/options.php | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/css/forms.css b/src/wp-admin/css/forms.css index dac5fddf65..0e499cfc4a 100644 --- a/src/wp-admin/css/forms.css +++ b/src/wp-admin/css/forms.css @@ -897,7 +897,7 @@ table.form-table td .updated p { .options-general-php .spinner { float: none; - margin: 0 3px; + margin: -3px 3px 0; } .settings-php .language-install-spinner, diff --git a/src/wp-admin/includes/options.php b/src/wp-admin/includes/options.php index 053d5eec64..f011efd312 100644 --- a/src/wp-admin/includes/options.php +++ b/src/wp-admin/includes/options.php @@ -51,7 +51,7 @@ function options_general_add_js() { $("input[name='date_format']").click(function(){ if ( "date_format_custom_radio" != $(this).attr("id") ) - $( "input[name='date_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() ); + $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() ); }); $( 'input[name="date_format_custom"]' ).on( 'click input', function() { $( '#date_format_custom_radio' ).prop( 'checked', true ); @@ -59,18 +59,23 @@ function options_general_add_js() { $("input[name='time_format']").click(function(){ if ( "time_format_custom_radio" != $(this).attr("id") ) - $( "input[name='time_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() ); + $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() ); }); $( 'input[name="time_format_custom"]' ).on( 'click input', function() { $( '#time_format_custom_radio' ).prop( 'checked', true ); }); $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() { - var format = $(this); - format.siblings( '.spinner' ).addClass( 'is-active' ); - $.post(ajaxurl, { - action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format', + var format = $( this ), + fieldset = format.closest( 'fieldset' ), + example = fieldset.find( '.example' ), + spinner = fieldset.find( '.spinner' ); + + spinner.addClass( 'is-active' ); + + $.post( ajaxurl, { + action: 'date_format_custom' == format.attr( 'name' ) ? 'date_format' : 'time_format', date : format.val() - }, function(d) { format.siblings( '.spinner' ).removeClass( 'is-active' ); format.siblings('.example').text(d); } ); + }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } ); }); var languageSelect = $( '#WPLANG' );