Validate date/time fields for posts and comments, fixes #10309
git-svn-id: http://svn.automattic.com/wordpress/trunk@12318 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ae20d06e94
commit
dd81243d16
File diff suppressed because one or more lines are too long
|
@ -211,7 +211,8 @@ strong .post-com-count span {
|
|||
background-color: #ffebe8 !important;
|
||||
}
|
||||
|
||||
.form-invalid input {
|
||||
.form-invalid input,
|
||||
.form-invalid select {
|
||||
border-color: #c00 !important;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -211,7 +211,8 @@ strong .post-com-count span {
|
|||
background-color: #ffebe8 !important;
|
||||
}
|
||||
|
||||
.form-invalid input {
|
||||
.form-invalid input,
|
||||
.form-invalid select {
|
||||
border-color: #c00 !important;
|
||||
}
|
||||
|
||||
|
|
|
@ -2629,10 +2629,12 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
|||
$year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';
|
||||
$hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
|
||||
$minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
|
||||
|
||||
echo '<div class="timestamp-wrap">';
|
||||
/* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
|
||||
printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
|
||||
|
||||
echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
|
||||
echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />';
|
||||
|
||||
if ( $multi ) return;
|
||||
|
||||
|
|
|
@ -22,15 +22,25 @@ jQuery(document).ready( function($) {
|
|||
});
|
||||
|
||||
$('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
|
||||
var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(),
|
||||
newD = new Date( aa, mm - 1, jj, hh, mn );
|
||||
|
||||
if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn ) {
|
||||
$('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');
|
||||
return false;
|
||||
} else {
|
||||
$('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
|
||||
}
|
||||
|
||||
$('#timestampdiv').slideUp("normal");
|
||||
$('.edit-timestamp').show();
|
||||
$('#timestamp').html(
|
||||
commentL10n.submittedOn + ' <b>' +
|
||||
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
|
||||
$('#jj').val() + ', ' +
|
||||
$('#aa').val() + ' @ ' +
|
||||
$('#hh').val() + ':' +
|
||||
$('#mn').val() + '</b> '
|
||||
$( '#mm option[value=' + mm + ']' ).text() + ' ' +
|
||||
jj + ', ' +
|
||||
aa + ' @ ' +
|
||||
hh + ':' +
|
||||
mn + '</b> '
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(document).ready(function(b){var a=b("#timestamp").html();b(".edit-timestamp").click(function(){if(b("#timestampdiv").is(":hidden")){b("#timestampdiv").slideDown("normal");b(".edit-timestamp").hide()}return false});b(".cancel-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b("#mm").val(b("#hidden_mm").val());b("#jj").val(b("#hidden_jj").val());b("#aa").val(b("#hidden_aa").val());b("#hh").val(b("#hidden_hh").val());b("#mn").val(b("#hidden_mn").val());b("#timestamp").html(a);b(".edit-timestamp").show();return false});b(".save-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b(".edit-timestamp").show();b("#timestamp").html(commentL10n.submittedOn+" <b>"+b("#mm option[value="+b("#mm").val()+"]").text()+" "+b("#jj").val()+", "+b("#aa").val()+" @ "+b("#hh").val()+":"+b("#mn").val()+"</b> ");return false})});
|
||||
jQuery(document).ready(function(b){var a=b("#timestamp").html();b(".edit-timestamp").click(function(){if(b("#timestampdiv").is(":hidden")){b("#timestampdiv").slideDown("normal");b(".edit-timestamp").hide()}return false});b(".cancel-timestamp").click(function(){b("#timestampdiv").slideUp("normal");b("#mm").val(b("#hidden_mm").val());b("#jj").val(b("#hidden_jj").val());b("#aa").val(b("#hidden_aa").val());b("#hh").val(b("#hidden_hh").val());b("#mn").val(b("#hidden_mn").val());b("#timestamp").html(a);b(".edit-timestamp").show();return false});b(".save-timestamp").click(function(){var g=b("#aa").val(),h=b("#mm").val(),d=b("#jj").val(),c=b("#hh").val(),f=b("#mn").val(),e=new Date(g,h-1,d,c,f);if(e.getFullYear()!=g||(1+e.getMonth())!=h||e.getDate()!=d||e.getMinutes()!=f){b(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{b(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}b("#timestampdiv").slideUp("normal");b(".edit-timestamp").show();b("#timestamp").html(commentL10n.submittedOn+" <b>"+b("#mm option[value="+h+"]").text()+" "+d+", "+g+" @ "+c+":"+f+"</b> ");return false})});
|
|
@ -340,11 +340,21 @@ jQuery(document).ready( function($) {
|
|||
}
|
||||
|
||||
function updateText() {
|
||||
var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'), optPublish = $('option[value=publish]', postStatus);
|
||||
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();
|
||||
|
||||
attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val() );
|
||||
attemptedDate = new Date( aa, mm - 1, jj, hh, mn );
|
||||
originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val() );
|
||||
currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
|
||||
|
||||
if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) {
|
||||
$('.timestamp-wrap', '#timestampdiv').addClass('form-invalid');
|
||||
return false;
|
||||
} else {
|
||||
$('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
|
||||
}
|
||||
|
||||
if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
|
||||
publishOn = postL10n.publishOnFuture;
|
||||
$('#publish').val( postL10n.schedule );
|
||||
|
@ -364,10 +374,10 @@ jQuery(document).ready( function($) {
|
|||
$('#timestamp').html(
|
||||
publishOn + ' <b>' +
|
||||
$('option[value=' + $('#mm').val() + ']', '#mm').text() + ' ' +
|
||||
$('#jj').val() + ', ' +
|
||||
$('#aa').val() + ' @ ' +
|
||||
$('#hh').val() + ':' +
|
||||
$('#mn').val() + '</b> '
|
||||
jj + ', ' +
|
||||
aa + ' @ ' +
|
||||
hh + ':' +
|
||||
mn + '</b> '
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -392,7 +402,8 @@ jQuery(document).ready( function($) {
|
|||
} else {
|
||||
optPublish.html( postL10n.published );
|
||||
}
|
||||
$('.edit-post-status', '#misc-publishing-actions').show();
|
||||
if ( postStatus.is(':hidden') )
|
||||
$('.edit-post-status', '#misc-publishing-actions').show();
|
||||
}
|
||||
$('#post-status-display').html($('option:selected', postStatus).text());
|
||||
if ( $('option:selected', postStatus).val() == 'private' || $('option:selected', postStatus).val() == 'publish' ) {
|
||||
|
@ -405,6 +416,7 @@ jQuery(document).ready( function($) {
|
|||
$('#save-post').show().val( postL10n.saveDraft );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$('.edit-visibility', '#visibility').click(function () {
|
||||
|
@ -473,9 +485,10 @@ jQuery(document).ready( function($) {
|
|||
});
|
||||
|
||||
$('.save-timestamp', '#timestampdiv').click(function () { // crazyhorse - multiple ok cancels
|
||||
$('#timestampdiv').slideUp("normal");
|
||||
$('#timestampdiv').siblings('a.edit-timestamp').show();
|
||||
updateText();
|
||||
if ( updateText() ) {
|
||||
$('#timestampdiv').slideUp("normal");
|
||||
$('#timestampdiv').siblings('a.edit-timestamp').show();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -2276,8 +2276,9 @@ fieldset {
|
|||
|
||||
#timestampdiv select {
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
line-height: 14px;
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#jj, #hh, #mn {
|
||||
|
|
|
@ -275,7 +275,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), '20091012' );
|
||||
$scripts->add_data( 'postbox', 'group', 1 );
|
||||
|
||||
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20091109' );
|
||||
$scripts->add( 'post', "/wp-admin/js/post$suffix.js", array('suggest', 'wp-lists', 'postbox'), '20091202' );
|
||||
$scripts->add_data( 'post', 'group', 1 );
|
||||
$scripts->localize( 'post', 'postL10n', array(
|
||||
'tagsUsed' => __('Tags used on this post:'),
|
||||
|
@ -308,7 +308,7 @@ function wp_default_scripts( &$scripts ) {
|
|||
$scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20090506' );
|
||||
$scripts->add_data( 'link', 'group', 1 );
|
||||
|
||||
$scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20090102' );
|
||||
$scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array('jquery'), '20091202' );
|
||||
$scripts->add_data( 'comment', 'group', 1 );
|
||||
$scripts->localize( 'comment', 'commentL10n', array(
|
||||
'cancel' => __('Cancel'),
|
||||
|
@ -425,9 +425,9 @@ function wp_default_styles( &$styles ) {
|
|||
$rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' );
|
||||
|
||||
// all colors stylesheets need to have the same query strings (cache manifest compat)
|
||||
$colors_version = '20091128';
|
||||
$colors_version = '20091202';
|
||||
|
||||
$styles->add( 'wp-admin', "/wp-admin/wp-admin$suffix.css", array(), '20091126' );
|
||||
$styles->add( 'wp-admin', "/wp-admin/wp-admin$suffix.css", array(), '20091202' );
|
||||
$styles->add_data( 'wp-admin', 'rtl', "/wp-admin/rtl$suffix.css" );
|
||||
|
||||
$styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20091128' );
|
||||
|
|
Loading…
Reference in New Issue