From 5c72b7344bb51ecb9e99fe0bec0a792ab2dbca66 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Wed, 7 Nov 2012 21:31:08 +0000 Subject: [PATCH] Post UI: Provide visual feedback to the user if they try to set an invalid date for a post. Fixes #17180 props jkudish. git-svn-id: http://core.svn.wordpress.org/trunk@22442 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/post.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 307c8c214d..2afd7ec4d2 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -387,6 +387,10 @@ jQuery(document).ready( function($) { } function updateText() { + + if ( ! $('#timestampdiv').length ) + return true; + var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'), optPublish = $('option[value="publish"]', postStatus), aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(); @@ -534,6 +538,16 @@ jQuery(document).ready( function($) { return false; }); + $('#post').on( 'submit', function(e){ + if ( ! updateText() ) { + e.preventDefault(); + $('#timestampdiv').show(); + $('#publishing-action .spinner').hide(); + $('#publish').prop('disabled', false).removeClass('button-primary-disabled'); + return false; + } + }); + $('#post-status-select').siblings('a.edit-post-status').click(function() { if ($('#post-status-select').is(":hidden")) { $('#post-status-select').slideDown('fast');