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