Fix sale date field

This commit is contained in:
Mike Jolley 2017-02-22 10:31:20 +00:00
parent af39a16434
commit 2ac125417f
3 changed files with 14 additions and 16 deletions

View File

@ -118,22 +118,20 @@ jQuery( function( $ ) {
});
// Datepicker fields
$( '.sale_price_dates_fields', wrapper ).each( function() {
var dates = $( this ).find( 'input' ).datepicker({
$( '.sale_price_dates_fields', wrapper ).find( 'input' ).datepicker({
defaultDate: '',
dateFormat: 'yy-mm-dd',
numberOfMonths: 1,
showButtonPanel: true,
onSelect: function( selectedDate ) {
onSelect: function( selectedDate, instance ) {
var option = $( this ).is( '.sale_price_dates_from' ) ? 'minDate' : 'maxDate',
instance = $( this ).data( 'datepicker' ),
dates = $( this ).closest( '.sale_price_dates_fields' ).find( 'input' ),
date = $.datepicker.parseDate( instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings );
dates.not( this ).datepicker( 'option', option, date );
$( this ).change();
}
});
});
// Allow sorting
$( '.woocommerce_variations', wrapper ).sortable({

File diff suppressed because one or more lines are too long

View File

@ -135,7 +135,7 @@ if ( ! defined( 'ABSPATH' ) ) {
</p>
<p class="form-row form-row-last">
<label>' . __( 'Sale end date', 'woocommerce' ) . '</label>
<input type="text" class="sale_price_dates_to" name="variable_sale_price_dates_to[' . $loop . ']" id="_sale_price_dates_to" value="' . esc_attr( $sale_price_dates_to ) . '" placeholder="' . _x( 'To&hellip;', 'placeholder', 'woocommerce' ) . ' YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
<input type="text" class="sale_price_dates_to" name="variable_sale_price_dates_to[' . $loop . ']" value="' . esc_attr( $sale_price_dates_to ) . '" placeholder="' . _x( 'To&hellip;', 'placeholder', 'woocommerce' ) . ' YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
</p>
</div>';