1 jQuery(document).ready( function($) {
2 postboxes.add_postbox_toggles('page');
3 make_slugedit_clickable();
5 // close postboxes that should be closed
6 jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
8 jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } );
10 var stamp = $('#timestamp').html();
12 var visibility = $('#post-visibility-display').html();
14 function updateVisibility() {
15 if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
16 $('#sticky').attr('checked', false);
17 $('#sticky-span').hide();
19 $('#sticky-span').show();
21 if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) {
22 $('#password-span').hide();
24 $('#password-span').show();
28 function updateText() {
29 var attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val());
30 var originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val());
31 var currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val());
32 if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
33 var publishOn = postL10n.publishOnFuture;
34 $('#publish').val( postL10n.schedule );
35 } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
36 var publishOn = postL10n.publishOn;
37 $('#publish').val( postL10n.publish );
39 var publishOn = postL10n.publishOnPast;
40 $('#publish').val( postL10n.update );
42 if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
43 $('#timestamp').html(stamp);
47 $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' +
48 $('#jj').val() + ', ' +
49 $('#aa').val() + ' @ ' +
50 $('#hh').val() + ':' +
51 $('#mn').val() + '</b> '
55 if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) {
56 $('#publish').val( postL10n.update );
57 if ( $('#post_status option[value=publish]').length == 0 ) {
58 $('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>');
60 $('#post_status option[value=publish]').html( postL10n.privatelyPublished );
61 $('#post_status option[value=publish]').attr('selected', true);
62 $('.edit-post-status').hide();
64 if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) {
65 if ( $('#post_status option[value=publish]').length != 0 ) {
66 $('#post_status option[value=publish]').remove();
67 $('#post_status').val($('#hidden_post_status').val());
70 $('#post_status option[value=publish]').html( postL10n.published );
72 $('.edit-post-status').show();
74 $('#post-status-display').html($('#post_status :selected').text());
75 if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) {
76 $('#save-post').hide();
78 $('#save-post').show();
79 if ( $('#post_status :selected').val() == 'pending' ) {
80 $('#save-post').show().val( postL10n.savePending );
82 $('#save-post').show().val( postL10n.saveDraft );
87 $('.edit-visibility').click(function () {
88 if ($('#post-visibility-select').is(":hidden")) {
90 $('#post-visibility-select').slideDown("normal");
91 $('.edit-visibility').hide();
96 $('.cancel-post-visibility').click(function () {
97 $('#post-visibility-select').slideUp("normal");
98 $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true);
99 $('#post_password').val($('#hidden_post_password').val());
100 $('#post-visibility-display').html(visibility);
101 $('.edit-visibility').show();
106 $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels
107 $('#post-visibility-select').slideUp("normal");
108 $('.edit-visibility').show();
111 $('#post-visibility-display').html(
112 postL10n[$('#post-visibility-select input:radio:checked').val()]
118 $('#post-visibility-select input:radio').change(function() {
122 $('.edit-timestamp').click(function () {
123 if ($('#timestampdiv').is(":hidden")) {
124 $('#timestampdiv').slideDown("normal");
125 $('.edit-timestamp').hide();
131 $('.cancel-timestamp').click(function() {
132 $('#timestampdiv').slideUp("normal");
133 $('#mm').val($('#hidden_mm').val());
134 $('#jj').val($('#hidden_jj').val());
135 $('#aa').val($('#hidden_aa').val());
136 $('#hh').val($('#hidden_hh').val());
137 $('#mn').val($('#hidden_mn').val());
138 $('.edit-timestamp').show();
144 $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels
145 $('#timestampdiv').slideUp("normal");
146 $('.edit-timestamp').show();
152 $('.edit-post-status').click(function() {
153 if ($('#post-status-select').is(":hidden")) {
154 $('#post-status-select').slideDown("normal");
161 $('.save-post-status').click(function() {
162 $('#post-status-select').slideUp("normal");
163 $('.edit-post-status').show();
168 $('.cancel-post-status').click(function() {
169 $('#post-status-select').slideUp("normal");
170 $('#post_status').val($('#hidden_post_status').val());
171 $('.edit-post-status').show();
178 jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
179 $('table#list-table').show();
180 if ( jQuery.isFunction( autosave_update_post_ID ) ) {
181 autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
183 }, addBefore: function( s ) {
184 s.data += '&post_id=' + jQuery('#post_ID').val();
190 $('#post-preview').click(function(e){
191 if ( 1 > $('#post_ID').val() && autosaveFirst ) {
192 autosaveDelayPreview = true;
197 $('input#wp-preview').val('dopreview');
198 $('form#post').attr('target', 'wp-preview').submit().attr('target', '');
199 $('input#wp-preview').val('');