WordPress/wp-admin/js/page.js

1 line
5.2 KiB
JavaScript

jQuery(document).ready(function(f){postboxes.add_postbox_toggles("page");make_slugedit_clickable();f("#title").blur(function(){if((f("#post_ID").val()>0)||(f("#title").val().length==0)){return}autosave()});var c=f("#timestamp").html(),a=f("#post-visibility-display").html(),b=true;function e(){if(f("#post-visibility-select input:radio:checked").val()!="public"){f("#sticky").attr("checked",false);f("#sticky-span").hide()}else{f("#sticky-span").show()}if(f("#post-visibility-select input:radio:checked").val()!="password"){f("#password-span").hide()}else{f("#password-span").show()}}function d(){var g,i,h,j;g=new Date(f("#aa").val(),f("#mm").val()-1,f("#jj").val(),f("#hh").val(),f("#mn").val());i=new Date(f("#hidden_aa").val(),f("#hidden_mm").val()-1,f("#hidden_jj").val(),f("#hidden_hh").val(),f("#hidden_mn").val());h=new Date(f("#cur_aa").val(),f("#cur_mm").val()-1,f("#cur_jj").val(),f("#cur_hh").val(),f("#cur_mn").val());if(g>h&&f("#original_post_status").val()!="future"){j=postL10n.publishOnFuture;f("#publish").val(postL10n.schedule)}else{if(g<=h&&f("#original_post_status").val()!="publish"){j=postL10n.publishOn;f("#publish").val(postL10n.publish)}else{j=postL10n.publishOnPast;f("#publish").val(postL10n.update)}}if(i.toUTCString()==g.toUTCString()){f("#timestamp").html(c)}else{f("#timestamp").html(j+" <b>"+f("#mm option[value="+f("#mm").val()+"]").text()+" "+f("#jj").val()+", "+f("#aa").val()+" @ "+f("#hh").val()+":"+f("#mn").val()+"</b> ")}if(f("#post-visibility-select input:radio:checked").val()=="private"){f("#publish").val(postL10n.update);if(f("#post_status option[value=publish]").length==0){f("#post_status").append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}f("#post_status option[value=publish]").html(postL10n.privatelyPublished);f("#post_status option[value=publish]").attr("selected",true);f(".edit-post-status").hide()}else{if(f("#original_post_status").val()=="future"||f("#original_post_status").val()=="draft"){if(f("#post_status option[value=publish]").length!=0){f("#post_status option[value=publish]").remove();f("#post_status").val(f("#hidden_post_status").val())}}else{f("#post_status option[value=publish]").html(postL10n.published)}f(".edit-post-status").show()}f("#post-status-display").html(f("#post_status :selected").text());if(f("#post_status :selected").val()=="private"||f("#post_status :selected").val()=="publish"){f("#save-post").hide()}else{f("#save-post").show();if(f("#post_status :selected").val()=="pending"){f("#save-post").show().val(postL10n.savePending)}else{f("#save-post").show().val(postL10n.saveDraft)}}}f(".edit-visibility").click(function(){if(f("#post-visibility-select").is(":hidden")){e();f("#post-visibility-select").slideDown("normal");f(".edit-visibility").hide()}return false});f(".cancel-post-visibility").click(function(){f("#post-visibility-select").slideUp("normal");f("#visibility-radio-"+f("#hidden-post-visibility").val()).attr("checked",true);f("#post_password").val(f("#hidden_post_password").val());f("#post-visibility-display").html(a);f(".edit-visibility").show();d();return false});f(".save-post-visibility").click(function(){f("#post-visibility-select").slideUp("normal");f(".edit-visibility").show();d();f("#post-visibility-display").html(postL10n[f("#post-visibility-select input:radio:checked").val()]);return false});f("#post-visibility-select input:radio").change(function(){e()});f(".edit-timestamp").click(function(){if(f("#timestampdiv").is(":hidden")){f("#timestampdiv").slideDown("normal");f(".edit-timestamp").hide()}return false});f(".cancel-timestamp").click(function(){f("#timestampdiv").slideUp("normal");f("#mm").val(f("#hidden_mm").val());f("#jj").val(f("#hidden_jj").val());f("#aa").val(f("#hidden_aa").val());f("#hh").val(f("#hidden_hh").val());f("#mn").val(f("#hidden_mn").val());f(".edit-timestamp").show();d();return false});f(".save-timestamp").click(function(){f("#timestampdiv").slideUp("normal");f(".edit-timestamp").show();d();return false});f(".edit-post-status").click(function(){if(f("#post-status-select").is(":hidden")){f("#post-status-select").slideDown("normal");f(this).hide()}return false});f(".save-post-status").click(function(){f("#post-status-select").slideUp("normal");f(".edit-post-status").show();d();return false});f(".cancel-post-status").click(function(){f("#post-status-select").slideUp("normal");f("#post_status").val(f("#hidden_post_status").val());f(".edit-post-status").show();d();return false});f("#the-list").wpList({addAfter:function(g,h){f("table#list-table").show();if(f.isFunction(autosave_update_post_ID)){autosave_update_post_ID(h.parsed.responses[0].supplemental.postid)}},addBefore:function(g){g.data+="&post_id="+f("#post_ID").val();return g}});f("#post-preview").click(function(g){if(1>f("#post_ID").val()&&autosaveFirst){autosaveDelayPreview=true;autosave();return false}f("input#wp-preview").val("dopreview");f("form#post").attr("target","wp-preview").submit().attr("target","");f("input#wp-preview").val("");return false});if(typeof tinyMCE!="undefined"){f("#title")[f.browser.opera?"keypress":"keydown"](function(g){if(g.which==9&&!g.shiftKey&&!g.controlKey&&!g.altKey){if((f("#post_ID").val()<1)&&(f("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&b){g.preventDefault();b=false;tinyMCE.activeEditor.focus();return false}}})}});