2008-08-27 15:41:51 -04:00
|
|
|
jQuery(document).ready( function($) {
|
2008-08-20 17:42:31 -04:00
|
|
|
postboxes.add_postbox_toggles('page');
|
2008-02-08 14:57:50 -05:00
|
|
|
make_slugedit_clickable();
|
2008-02-18 17:07:57 -05:00
|
|
|
|
2008-03-26 16:06:18 -04:00
|
|
|
// close postboxes that should be closed
|
|
|
|
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
|
|
|
|
2008-03-19 01:38:58 -04:00
|
|
|
jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } );
|
|
|
|
|
2008-02-21 15:19:34 -05:00
|
|
|
// hide advanced slug field
|
|
|
|
jQuery('#pageslugdiv').hide();
|
|
|
|
|
2008-09-14 08:58:00 -04:00
|
|
|
var stamp = $('#timestamp').html();
|
|
|
|
|
|
|
|
$('.edit-timestamp').click(function () {
|
|
|
|
if ($('#timestampdiv').is(":hidden")) {
|
|
|
|
$('#timestampdiv').slideDown("normal");
|
|
|
|
$('.edit-timestamp').hide();
|
2008-02-18 17:07:57 -05:00
|
|
|
}
|
2008-09-14 08:58:00 -04:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.cancel-timestamp').click(function() {
|
|
|
|
$('#timestampdiv').slideUp("normal");
|
|
|
|
$('#mm').val($('#hidden_mm').val());
|
|
|
|
$('#jj').val($('#hidden_jj').val());
|
|
|
|
$('#aa').val($('#hidden_aa').val());
|
|
|
|
$('#hh').val($('#hidden_hh').val());
|
|
|
|
$('#mn').val($('#hidden_mn').val());
|
|
|
|
$('#timestamp').html(stamp);
|
|
|
|
$('.edit-timestamp').show();
|
|
|
|
|
2008-10-31 01:38:31 -04:00
|
|
|
var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val() );
|
|
|
|
var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
|
|
|
|
if ( attemptedDate > currentDate ) {
|
|
|
|
$('#publish').val( postL10n.schedule );
|
|
|
|
} else if ( $('#original_post_status').val() != 'publish' ) {
|
|
|
|
$('#publish').val( postL10n.publish );
|
|
|
|
} else {
|
|
|
|
$('#publish').val( postL10n.update );
|
|
|
|
}
|
|
|
|
|
2008-02-22 01:12:10 -05:00
|
|
|
return false;
|
2008-08-20 17:42:31 -04:00
|
|
|
});
|
|
|
|
|
2008-09-14 08:58:00 -04:00
|
|
|
$('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
|
|
|
|
$('#timestampdiv').slideUp("normal");
|
|
|
|
$('.edit-timestamp').show();
|
2008-10-31 01:38:31 -04:00
|
|
|
var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val() );
|
|
|
|
var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() );
|
|
|
|
if ( attemptedDate > currentDate ) {
|
|
|
|
var publishOn = postL10n.publishOnFuture;
|
|
|
|
$('#publish').val( postL10n.schedule );
|
|
|
|
} else if ( $('#original_post_status').val() != 'publish' ) {
|
|
|
|
var publishOn = postL10n.publishOn;
|
|
|
|
$('#publish').val( postL10n.publish );
|
|
|
|
} else {
|
|
|
|
var publishOn = postL10n.publishOnPast;
|
|
|
|
$('#publish').val( postL10n.update );
|
|
|
|
}
|
2008-09-14 08:58:00 -04:00
|
|
|
$('#timestamp').html(
|
2008-11-03 02:06:36 -05:00
|
|
|
publishOn + ' <b>' +
|
2008-09-14 08:58:00 -04:00
|
|
|
$( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
|
|
|
|
$('#jj').val() + ', ' +
|
|
|
|
$('#aa').val() + ' @ ' +
|
|
|
|
$('#hh').val() + ':' +
|
2008-11-03 02:06:36 -05:00
|
|
|
$('#mn').val() + '</b> '
|
2008-09-14 08:58:00 -04:00
|
|
|
);
|
|
|
|
|
2008-08-20 17:42:31 -04:00
|
|
|
return false;
|
|
|
|
});
|
2008-08-27 15:41:51 -04:00
|
|
|
|
2008-09-14 08:58:00 -04:00
|
|
|
$('.edit-post-status').click(function() {
|
|
|
|
if ($('#post-status-select').is(":hidden")) {
|
|
|
|
$('#post-status-select').slideDown("normal");
|
|
|
|
$(this).hide();
|
2008-09-13 15:12:55 -04:00
|
|
|
}
|
2008-09-14 08:58:00 -04:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.save-post-status').click(function() {
|
|
|
|
$('#post-status-select').slideUp("normal");
|
|
|
|
$('#post-status-display').html($('#post_status :selected').text());
|
|
|
|
$('.edit-post-status').show();
|
2008-10-31 01:38:31 -04:00
|
|
|
if ( $('#post_status :selected').val() == 'pending' ) {
|
|
|
|
$('#save-post').val( postL10n.savePending );
|
|
|
|
} else {
|
|
|
|
$('#save-post').val( postL10n.saveDraft );
|
|
|
|
}
|
2008-09-14 08:58:00 -04:00
|
|
|
return false;
|
|
|
|
});
|
2008-10-31 01:38:31 -04:00
|
|
|
|
2008-09-14 08:58:00 -04:00
|
|
|
$('.cancel-post-status').click(function() {
|
|
|
|
$('#post-status-select').slideUp("normal");
|
|
|
|
$('#post_status').val($('#hidden_post_status').val());
|
|
|
|
$('#post-status-display').html($('#post_status :selected').text());
|
|
|
|
$('.edit-post-status').show();
|
2008-10-31 01:38:31 -04:00
|
|
|
if ( $('#post_status :selected').val() == 'pending' ) {
|
|
|
|
$('#save-post').val( postL10n.savePending );
|
|
|
|
} else {
|
|
|
|
$('#save-post').val( postL10n.saveDraft );
|
|
|
|
}
|
|
|
|
|
2008-09-13 15:12:55 -04:00
|
|
|
return false;
|
|
|
|
});
|
2008-11-07 21:15:53 -05:00
|
|
|
|
|
|
|
// Custom Fields
|
|
|
|
jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
|
|
|
|
$('table#list-table').show();
|
|
|
|
if ( jQuery.isFunction( autosave_update_post_ID ) ) {
|
|
|
|
autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
|
|
|
|
}
|
|
|
|
}, addBefore: function( s ) {
|
|
|
|
s.data += '&post_id=' + jQuery('#post_ID').val();
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2008-10-31 18:47:07 -04:00
|
|
|
// preview
|
|
|
|
$('#post-preview').click(function(e){
|
2008-11-02 08:56:32 -05:00
|
|
|
if ( 1 > $('#post_ID').val() && autosaveFirst ) {
|
|
|
|
autosaveDelayPreview = true;
|
|
|
|
autosave();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-10-31 18:47:07 -04:00
|
|
|
$('input#wp-preview').val('dopreview');
|
|
|
|
$('form#post').attr('target', 'wp-preview').submit().attr('target', '');
|
|
|
|
$('input#wp-preview').val('');
|
2008-11-02 08:56:32 -05:00
|
|
|
return false;
|
2008-10-31 18:47:07 -04:00
|
|
|
});
|
2008-09-14 08:58:00 -04:00
|
|
|
});
|