|
1 jQuery(document).ready( function($) { |
|
2 postboxes.add_postbox_toggles('page'); |
|
3 make_slugedit_clickable(); |
|
4 |
|
5 $('#title').blur( function() { if ( ($("#post_ID").val() > 0) || ($("#title").val().length == 0) ) return; autosave(); } ); |
|
6 |
|
7 var stamp = $('#timestamp').html(), visibility = $('#post-visibility-display').html(); |
|
8 |
|
9 function updateVisibility() { |
|
10 if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) { |
|
11 $('#sticky').attr('checked', false); |
|
12 $('#sticky-span').hide(); |
|
13 } else { |
|
14 $('#sticky-span').show(); |
|
15 } |
|
16 if ( $('#post-visibility-select input:radio:checked').val() != 'password' ) { |
|
17 $('#password-span').hide(); |
|
18 } else { |
|
19 $('#password-span').show(); |
|
20 } |
|
21 } |
|
22 |
|
23 function updateText() { |
|
24 var attemptedDate, originalDate, currentDate, publishOn; |
|
25 |
|
26 attemptedDate = new Date( $('#aa').val(), $('#mm').val() -1, $('#jj').val(), $('#hh').val(), $('#mn').val()); |
|
27 originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val()); |
|
28 currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val()); |
|
29 if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) { |
|
30 publishOn = postL10n.publishOnFuture; |
|
31 $('#publish').val( postL10n.schedule ); |
|
32 } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) { |
|
33 publishOn = postL10n.publishOn; |
|
34 $('#publish').val( postL10n.publish ); |
|
35 } else { |
|
36 publishOn = postL10n.publishOnPast; |
|
37 $('#publish').val( postL10n.update ); |
|
38 } |
|
39 if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack |
|
40 $('#timestamp').html(stamp); |
|
41 } else { |
|
42 $('#timestamp').html( |
|
43 publishOn + ' <b>' + |
|
44 $( '#mm option[value=' + $('#mm').val() + ']' ).text() + ' ' + |
|
45 $('#jj').val() + ', ' + |
|
46 $('#aa').val() + ' @ ' + |
|
47 $('#hh').val() + ':' + |
|
48 $('#mn').val() + '</b> ' |
|
49 ); |
|
50 } |
|
51 |
|
52 if ( $('#post-visibility-select input:radio:checked').val() == 'private' ) { |
|
53 $('#publish').val( postL10n.update ); |
|
54 if ( $('#post_status option[value=publish]').length == 0 ) { |
|
55 $('#post_status').append('<option value="publish">' + postL10n.privatelyPublished + '</option>'); |
|
56 } |
|
57 $('#post_status option[value=publish]').html( postL10n.privatelyPublished ); |
|
58 $('#post_status option[value=publish]').attr('selected', true); |
|
59 $('.edit-post-status').hide(); |
|
60 } else { |
|
61 if ( $('#original_post_status').val() == 'future' || $('#original_post_status').val() == 'draft' ) { |
|
62 if ( $('#post_status option[value=publish]').length != 0 ) { |
|
63 $('#post_status option[value=publish]').remove(); |
|
64 $('#post_status').val($('#hidden_post_status').val()); |
|
65 } |
|
66 } else { |
|
67 $('#post_status option[value=publish]').html( postL10n.published ); |
|
68 } |
|
69 $('.edit-post-status').show(); |
|
70 } |
|
71 $('#post-status-display').html($('#post_status :selected').text()); |
|
72 if ( $('#post_status :selected').val() == 'private' || $('#post_status :selected').val() == 'publish' ) { |
|
73 $('#save-post').hide(); |
|
74 } else { |
|
75 $('#save-post').show(); |
|
76 if ( $('#post_status :selected').val() == 'pending' ) { |
|
77 $('#save-post').show().val( postL10n.savePending ); |
|
78 } else { |
|
79 $('#save-post').show().val( postL10n.saveDraft ); |
|
80 } |
|
81 } |
|
82 } |
|
83 |
|
84 $('.edit-visibility').click(function () { |
|
85 if ($('#post-visibility-select').is(":hidden")) { |
|
86 updateVisibility(); |
|
87 $('#post-visibility-select').slideDown("normal"); |
|
88 $('.edit-visibility').hide(); |
|
89 } |
|
90 return false; |
|
91 }); |
|
92 |
|
93 $('.cancel-post-visibility').click(function () { |
|
94 $('#post-visibility-select').slideUp("normal"); |
|
95 $('#visibility-radio-' + $('#hidden-post-visibility').val()).attr('checked', true); |
|
96 $('#post_password').val($('#hidden_post_password').val()); |
|
97 $('#post-visibility-display').html(visibility); |
|
98 $('.edit-visibility').show(); |
|
99 updateText(); |
|
100 return false; |
|
101 }); |
|
102 |
|
103 $('.save-post-visibility').click(function () { // crazyhorse - multiple ok cancels |
|
104 $('#post-visibility-select').slideUp("normal"); |
|
105 $('.edit-visibility').show(); |
|
106 updateText(); |
|
107 |
|
108 $('#post-visibility-display').html( |
|
109 postL10n[$('#post-visibility-select input:radio:checked').val()] |
|
110 ); |
|
111 |
|
112 return false; |
|
113 }); |
|
114 |
|
115 $('#post-visibility-select input:radio').change(function() { |
|
116 updateVisibility(); |
|
117 }); |
|
118 |
|
119 $('.edit-timestamp').click(function () { |
|
120 if ($('#timestampdiv').is(":hidden")) { |
|
121 $('#timestampdiv').slideDown("normal"); |
|
122 $('.edit-timestamp').hide(); |
|
123 } |
|
124 |
|
125 return false; |
|
126 }); |
|
127 |
|
128 $('.cancel-timestamp').click(function() { |
|
129 $('#timestampdiv').slideUp("normal"); |
|
130 $('#mm').val($('#hidden_mm').val()); |
|
131 $('#jj').val($('#hidden_jj').val()); |
|
132 $('#aa').val($('#hidden_aa').val()); |
|
133 $('#hh').val($('#hidden_hh').val()); |
|
134 $('#mn').val($('#hidden_mn').val()); |
|
135 $('.edit-timestamp').show(); |
|
136 |
|
137 updateText(); |
|
138 return false; |
|
139 }); |
|
140 |
|
141 $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels |
|
142 $('#timestampdiv').slideUp("normal"); |
|
143 $('.edit-timestamp').show(); |
|
144 updateText(); |
|
145 |
|
146 return false; |
|
147 }); |
|
148 |
|
149 $('.edit-post-status').click(function() { |
|
150 if ($('#post-status-select').is(":hidden")) { |
|
151 $('#post-status-select').slideDown("normal"); |
|
152 $(this).hide(); |
|
153 } |
|
154 |
|
155 return false; |
|
156 }); |
|
157 |
|
158 $('.save-post-status').click(function() { |
|
159 $('#post-status-select').slideUp("normal"); |
|
160 $('.edit-post-status').show(); |
|
161 updateText(); |
|
162 return false; |
|
163 }); |
|
164 |
|
165 $('.cancel-post-status').click(function() { |
|
166 $('#post-status-select').slideUp("normal"); |
|
167 $('#post_status').val($('#hidden_post_status').val()); |
|
168 $('.edit-post-status').show(); |
|
169 |
|
170 updateText(); |
|
171 return false; |
|
172 }); |
|
173 |
|
174 // Custom Fields |
|
175 $('#the-list').wpList( { addAfter: function( xml, s ) { |
|
176 $('table#list-table').show(); |
|
177 if ( $.isFunction( autosave_update_post_ID ) ) { |
|
178 autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); |
|
179 } |
|
180 }, addBefore: function( s ) { |
|
181 s.data += '&post_id=' + $('#post_ID').val(); |
|
182 return s; |
|
183 } |
|
184 }); |
|
185 }); |