diff --git a/wp-admin/js/post.dev.js b/wp-admin/js/post.dev.js index febf750f6a..e15bcbbb5f 100644 --- a/wp-admin/js/post.dev.js +++ b/wp-admin/js/post.dev.js @@ -331,9 +331,6 @@ jQuery(document).ready( function($) { if ( $('#postcustom').length ) { $('#the-list').wpList( { addAfter: function( xml, s ) { $('table#list-table').show(); - if ( typeof( autosave_update_post_ID ) != 'undefined' ) { - autosave_update_post_ID(s.parsed.responses[0].supplemental.postid); - } }, addBefore: function( s ) { s.data += '&post_id=' + $('#post_ID').val(); return s; diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index 59fccccd4e..3c0a25833f 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -1 +1 @@ -var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail;function array_unique_noempty(a){var out=[];jQuery.each(a,function(key,val){val=jQuery.trim(val);if(val&&jQuery.inArray(val,out)==-1){out.push(val)}});return out}(function($){tagBox={clean:function(tags){return tags.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"")},parseTags:function(el){var id=el.id,num=id.split("-check-num-")[1],taxbox=$(el).closest(".tagsdiv"),thetags=taxbox.find(".the-tags"),current_tags=thetags.val().split(","),new_tags=[];delete current_tags[num];$.each(current_tags,function(key,val){val=$.trim(val);if(val){new_tags.push(val)}});thetags.val(this.clean(new_tags.join(",")));this.quickClicks(taxbox);return false},quickClicks:function(el){var thetags=$(".the-tags",el),tagchecklist=$(".tagchecklist",el),current_tags;if(!thetags.length){return}var disabled=thetags.attr("disabled");current_tags=thetags.val().split(",");tagchecklist.empty();$.each(current_tags,function(key,val){var txt,button_id,id=$(el).attr("id");val=$.trim(val);if(!val.match(/^\s+$/)&&""!=val){button_id=id+"-check-num-"+key;if(disabled){txt=""+val+" "}else{txt='X '+val+" "}tagchecklist.append(txt);if(!disabled){$("#"+button_id).click(function(){tagBox.parseTags(this)})}}})},flushTags:function(el,a,f){a=a||false;var text,tags=$(".the-tags",el),newtag=$("input.newtag",el),newtags;text=a?$(a).text():newtag.val();tagsval=tags.val();newtags=tagsval?tagsval+","+text:text;newtags=this.clean(newtags);newtags=array_unique_noempty(newtags.split(",")).join(",");tags.val(newtags);this.quickClicks(el);if(!a){newtag.val("")}if("undefined"==typeof(f)){newtag.focus()}return false},get:function(id){var tax=id.substr(id.indexOf("-")+1);$.post(ajaxurl,{action:"get-tagcloud",tax:tax},function(r,stat){if(0==r||"success"!=stat){r=wpAjax.broken}r=$('

'+r+"

");$("a",r).click(function(){tagBox.flushTags($(this).closest(".inside").children(".tagsdiv"),this);return false});$("#"+id).after(r)})},init:function(){var t=this,ajaxtag=$("div.ajaxtag");$(".tagsdiv").each(function(){tagBox.quickClicks(this)});$("input.tagadd",ajaxtag).click(function(){t.flushTags($(this).closest(".tagsdiv"))});$("div.taghint",ajaxtag).click(function(){$(this).css("visibility","hidden").parent().siblings(".newtag").focus()});$("input.newtag",ajaxtag).blur(function(){if(this.value==""){$(this).parent().siblings(".taghint").css("visibility","")}}).focus(function(){$(this).parent().siblings(".taghint").css("visibility","hidden")}).keyup(function(e){if(13==e.which){tagBox.flushTags($(this).closest(".tagsdiv"));return false}}).keypress(function(e){if(13==e.which){e.preventDefault();return false}}).each(function(){var tax=$(this).closest("div.tagsdiv").attr("id");$(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+tax,{delay:500,minchars:2,multiple:true,multipleSep:","})});$("#post").submit(function(){$("div.tagsdiv").each(function(){tagBox.flushTags(this,false,1)})});$("a.tagcloud-link").click(function(){tagBox.get($(this).attr("id"));$(this).unbind().click(function(){$(this).siblings(".the-tagcloud").toggle();return false});return false})}};commentsBox={st:0,get:function(total,num){var st=this.st,data;if(!num){num=20}this.st+=num;this.total=total;$("#commentsdiv img.waiting").show();data={action:"get-comments",mode:"single",_ajax_nonce:$("#add_comment_nonce").val(),post_ID:$("#post_ID").val(),start:st,num:num};$.post(ajaxurl,data,function(r){r=wpAjax.parseAjaxResponse(r);$("#commentsdiv .widefat").show();$("#commentsdiv img.waiting").hide();if("object"==typeof r&&r.responses[0]){$("#the-comment-list").append(r.responses[0].data);theList=theExtraList=null;$("a[className*=':']").unbind();setCommentsList();if(commentsBox.st>commentsBox.total){$("#show-comments").hide()}else{$("#show-comments").html(postL10n.showcomm)}return}else{if(1==r){$("#show-comments").parent().html(postL10n.endcomm);return}}$("#the-comment-list").append(''+wpAjax.broken+"")});return false}};WPSetThumbnailHTML=function(html){$(".inside","#postimagediv").html(html)};WPSetThumbnailID=function(id){var field=$("input[value=_thumbnail_id]","#list-table");if(field.size()>0){$("#meta\\["+field.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(id)}};WPRemoveThumbnail=function(){$.post(ajaxurl,{action:"set-post-thumbnail",post_id:$("#post_ID").val(),thumbnail_id:-1,cookie:encodeURIComponent(document.cookie)},function(str){if(str=="0"){alert(setPostThumbnailL10n.error)}else{WPSetThumbnailHTML(str)}})}})(jQuery);jQuery(document).ready(function($){var stamp,visibility,sticky="";postboxes.add_postbox_toggles(pagenow);if($("#tagsdiv-post_tag").length){tagBox.init()}else{$("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(this.id.indexOf("tagsdiv-")===0){tagBox.init();return false}})}$(".categorydiv").each(function(){var this_id=$(this).attr("id"),noSyncChecks=false,syncChecks,catAddAfter,taxonomyParts,taxonomy,settingName;taxonomyParts=this_id.split("-");taxonomyParts.shift();taxonomy=taxonomyParts.join("-");settingName=taxonomy+"_tab";if(taxonomy=="category"){settingName="cats"}$("a","#"+taxonomy+"-tabs").click(function(){var t=$(this).attr("href");$(this).parent().addClass("tabs").siblings("li").removeClass("tabs");$("#"+taxonomy+"-tabs").siblings(".tabs-panel").hide();$(t).show();if("#"+taxonomy+"-all"==t){deleteUserSetting(settingName)}else{setUserSetting(settingName,"pop")}return false});if(getUserSetting(settingName)){$('a[href="#'+taxonomy+'-pop"]',"#"+taxonomy+"-tabs").click()}$("#new"+taxonomy).one("focus",function(){$(this).val("").removeClass("form-input-tip")});$("#"+taxonomy+"-add-submit").click(function(){$("#new"+taxonomy).focus()});syncChecks=function(){if(noSyncChecks){return}noSyncChecks=true;var th=jQuery(this),c=th.is(":checked"),id=th.val().toString();$("#in-"+taxonomy+"-"+id+", #in-"+taxonomy+"-category-"+id).attr("checked",c);noSyncChecks=false};catAddBefore=function(s){if(!$("#new"+taxonomy).val()){return false}s.data+="&"+$(":checked","#"+taxonomy+"checklist").serialize();return s};catAddAfter=function(r,s){var sup,drop=$("#new"+taxonomy+"_parent");if("undefined"!=s.parsed.responses[0]&&(sup=s.parsed.responses[0].supplemental.newcat_parent)){drop.before(sup);drop.remove()}};$("#"+taxonomy+"checklist").wpList({alt:"",response:taxonomy+"-ajax-response",addBefore:catAddBefore,addAfter:catAddAfter});$("#"+taxonomy+"-add-toggle").click(function(){$("#"+taxonomy+"-adder").toggleClass("wp-hidden-children");$('a[href="#'+taxonomy+'-all"]',"#"+taxonomy+"-tabs").click();return false});$("#"+taxonomy+"checklist li.popular-category :checkbox, #"+taxonomy+"checklist-pop :checkbox").live("click",function(){var t=$(this),c=t.is(":checked"),id=t.val();if(id&&t.parents("#taxonomy-"+taxonomy).length){$("#in-"+taxonomy+"-"+id+", #in-popular-"+taxonomy+"-"+id).attr("checked",c)}})});if($("#postcustom").length){$("#the-list").wpList({addAfter:function(xml,s){$("table#list-table").show();if(typeof(autosave_update_post_ID)!="undefined"){autosave_update_post_ID(s.parsed.responses[0].supplemental.postid)}},addBefore:function(s){s.data+="&post_id="+$("#post_ID").val();return s}})}if($("#submitdiv").length){stamp=$("#timestamp").html();visibility=$("#post-visibility-display").html();function updateVisibility(){var pvSelect=$("#post-visibility-select");if($("input:radio:checked",pvSelect).val()!="public"){$("#sticky").attr("checked",false);$("#sticky-span").hide()}else{$("#sticky-span").show()}if($("input:radio:checked",pvSelect).val()!="password"){$("#password-span").hide()}else{$("#password-span").show()}}function updateText(){var attemptedDate,originalDate,currentDate,publishOn,page="page"==pagenow||"page-new"==pagenow,postStatus=$("#post_status"),optPublish=$("option[value=publish]",postStatus),aa=$("#aa").val(),mm=$("#mm").val(),jj=$("#jj").val(),hh=$("#hh").val(),mn=$("#mn").val();attemptedDate=new Date(aa,mm-1,jj,hh,mn);originalDate=new Date($("#hidden_aa").val(),$("#hidden_mm").val()-1,$("#hidden_jj").val(),$("#hidden_hh").val(),$("#hidden_mn").val());currentDate=new Date($("#cur_aa").val(),$("#cur_mm").val()-1,$("#cur_jj").val(),$("#cur_hh").val(),$("#cur_mn").val());if(attemptedDate.getFullYear()!=aa||(1+attemptedDate.getMonth())!=mm||attemptedDate.getDate()!=jj||attemptedDate.getMinutes()!=mn){$(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{$(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}if(attemptedDate>currentDate&&$("#original_post_status").val()!="future"){publishOn=postL10n.publishOnFuture;$("#publish").val(postL10n.schedule)}else{if(attemptedDate<=currentDate&&$("#original_post_status").val()!="publish"){publishOn=postL10n.publishOn;$("#publish").val(postL10n.publish)}else{publishOn=postL10n.publishOnPast;if(page){$("#publish").val(postL10n.updatePage)}else{$("#publish").val(postL10n.updatePost)}}}if(originalDate.toUTCString()==attemptedDate.toUTCString()){$("#timestamp").html(stamp)}else{$("#timestamp").html(publishOn+" "+$("option[value="+$("#mm").val()+"]","#mm").text()+" "+jj+", "+aa+" @ "+hh+":"+mn+" ")}if($("input:radio:checked","#post-visibility-select").val()=="private"){if(page){$("#publish").val(postL10n.updatePage)}else{$("#publish").val(postL10n.updatePost)}if(optPublish.length==0){postStatus.append('")}else{optPublish.html(postL10n.privatelyPublished)}$("option[value=publish]",postStatus).attr("selected",true);$(".edit-post-status","#misc-publishing-actions").hide()}else{if($("#original_post_status").val()=="future"||$("#original_post_status").val()=="draft"){if(optPublish.length){optPublish.remove();postStatus.val($("#hidden_post_status").val())}}else{optPublish.html(postL10n.published)}if(postStatus.is(":hidden")){$(".edit-post-status","#misc-publishing-actions").show()}}$("#post-status-display").html($("option:selected",postStatus).text());if($("option:selected",postStatus).val()=="private"||$("option:selected",postStatus).val()=="publish"){$("#save-post").hide()}else{$("#save-post").show();if($("option:selected",postStatus).val()=="pending"){$("#save-post").show().val(postL10n.savePending)}else{$("#save-post").show().val(postL10n.saveDraft)}}return true}$(".edit-visibility","#visibility").click(function(){if($("#post-visibility-select").is(":hidden")){updateVisibility();$("#post-visibility-select").slideDown("normal");$(this).hide()}return false});$(".cancel-post-visibility","#post-visibility-select").click(function(){$("#post-visibility-select").slideUp("normal");$("#visibility-radio-"+$("#hidden-post-visibility").val()).attr("checked",true);$("#post_password").val($("#hidden_post_password").val());$("#sticky").attr("checked",$("#hidden-post-sticky").attr("checked"));$("#post-visibility-display").html(visibility);$(".edit-visibility","#visibility").show();updateText();return false});$(".save-post-visibility","#post-visibility-select").click(function(){var pvSelect=$("#post-visibility-select");pvSelect.slideUp("normal");$(".edit-visibility","#visibility").show();updateText();if($("input:radio:checked",pvSelect).val()!="public"){$("#sticky").attr("checked",false)}if(true==$("#sticky").attr("checked")){sticky="Sticky"}else{sticky=""}$("#post-visibility-display").html(postL10n[$("input:radio:checked",pvSelect).val()+sticky]);return false});$("input:radio","#post-visibility-select").change(function(){updateVisibility()});$("#timestampdiv").siblings("a.edit-timestamp").click(function(){if($("#timestampdiv").is(":hidden")){$("#timestampdiv").slideDown("normal");$(this).hide()}return false});$(".cancel-timestamp","#timestampdiv").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());$("#timestampdiv").siblings("a.edit-timestamp").show();updateText();return false});$(".save-timestamp","#timestampdiv").click(function(){if(updateText()){$("#timestampdiv").slideUp("normal");$("#timestampdiv").siblings("a.edit-timestamp").show()}return false});$("#post-status-select").siblings("a.edit-post-status").click(function(){if($("#post-status-select").is(":hidden")){$("#post-status-select").slideDown("normal");$(this).hide()}return false});$(".save-post-status","#post-status-select").click(function(){$("#post-status-select").slideUp("normal");$("#post-status-select").siblings("a.edit-post-status").show();updateText();return false});$(".cancel-post-status","#post-status-select").click(function(){$("#post-status-select").slideUp("normal");$("#post_status").val($("#hidden_post_status").val());$("#post-status-select").siblings("a.edit-post-status").show();updateText();return false})}if($("#edit-slug-box").length){editPermalink=function(post_id){var i,c=0,e=$("#editable-post-name"),revert_e=e.html(),real_slug=$("#post_name"),revert_slug=real_slug.val(),b=$("#edit-slug-buttons"),revert_b=b.html(),full=$("#editable-post-name-full").html();$("#view-post-btn").hide();b.html(''+postL10n.ok+' '+postL10n.cancel+"");b.children(".save").click(function(){var new_slug=e.children("input").val();$.post(ajaxurl,{action:"sample-permalink",post_id:post_id,new_slug:new_slug,new_title:$("#title").val(),samplepermalinknonce:$("#samplepermalinknonce").val()},function(data){$("#edit-slug-box").html(data);b.html(revert_b);real_slug.attr("value",new_slug);makeSlugeditClickable();$("#view-post-btn").show()});return false});$(".cancel","#edit-slug-buttons").click(function(){$("#view-post-btn").show();e.html(revert_e);b.html(revert_b);real_slug.attr("value",revert_slug);return false});for(i=0;ifull.length/4)?"":full;e.html('').children("input").keypress(function(e){var key=e.keyCode||0;if(13==key){b.children(".save").click();return false}if(27==key){b.children(".cancel").click();return false}real_slug.attr("value",this.value)}).focus()};makeSlugeditClickable=function(){$("#editable-post-name").click(function(){$("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()}if($("#title").val()==""){$("#title").siblings("#title-prompt-text").css("visibility","")}$("#title-prompt-text").click(function(){$(this).css("visibility","hidden").siblings("#title").focus()});$("#title").blur(function(){if(this.value==""){$(this).siblings("#title-prompt-text").css("visibility","")}}).focus(function(){$(this).siblings("#title-prompt-text").css("visibility","hidden")}).keydown(function(e){$(this).siblings("#title-prompt-text").css("visibility","hidden");$(this).unbind(e)})}); \ No newline at end of file +var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail;function array_unique_noempty(b){var c=[];jQuery.each(b,function(a,d){d=jQuery.trim(d);if(d&&jQuery.inArray(d,c)==-1){c.push(d)}});return c}(function(a){tagBox={clean:function(b){return b.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"")},parseTags:function(e){var h=e.id,b=h.split("-check-num-")[1],d=a(e).closest(".tagsdiv"),g=d.find(".the-tags"),c=g.val().split(","),f=[];delete c[b];a.each(c,function(i,j){j=a.trim(j);if(j){f.push(j)}});g.val(this.clean(f.join(",")));this.quickClicks(d);return false},quickClicks:function(d){var f=a(".the-tags",d),e=a(".tagchecklist",d),b;if(!f.length){return}var c=f.attr("disabled");b=f.val().split(",");e.empty();a.each(b,function(i,j){var g,h,k=a(d).attr("id");j=a.trim(j);if(!j.match(/^\s+$/)&&""!=j){h=k+"-check-num-"+i;if(c){g=""+j+" "}else{g='X '+j+" "}e.append(g);if(!c){a("#"+h).click(function(){tagBox.parseTags(this)})}}})},flushTags:function(e,b,g){b=b||false;var i,c=a(".the-tags",e),h=a("input.newtag",e),d;i=b?a(b).text():h.val();tagsval=c.val();d=tagsval?tagsval+","+i:i;d=this.clean(d);d=array_unique_noempty(d.split(",")).join(",");c.val(d);this.quickClicks(e);if(!b){h.val("")}if("undefined"==typeof(g)){h.focus()}return false},get:function(c){var b=c.substr(c.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:b},function(e,d){if(0==e||"success"!=d){e=wpAjax.broken}e=a('

'+e+"

");a("a",e).click(function(){tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this);return false});a("#"+c).after(e)})},init:function(){var b=this,c=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)});a("input.tagadd",c).click(function(){b.flushTags(a(this).closest(".tagsdiv"))});a("div.taghint",c).click(function(){a(this).css("visibility","hidden").parent().siblings(".newtag").focus()});a("input.newtag",c).blur(function(){if(this.value==""){a(this).parent().siblings(".taghint").css("visibility","")}}).focus(function(){a(this).parent().siblings(".taghint").css("visibility","hidden")}).keyup(function(d){if(13==d.which){tagBox.flushTags(a(this).closest(".tagsdiv"));return false}}).keypress(function(d){if(13==d.which){d.preventDefault();return false}}).each(function(){var d=a(this).closest("div.tagsdiv").attr("id");a(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+d,{delay:500,minchars:2,multiple:true,multipleSep:","})});a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,false,1)})});a("a.tagcloud-link").click(function(){tagBox.get(a(this).attr("id"));a(this).unbind().click(function(){a(this).siblings(".the-tagcloud").toggle();return false});return false})}};commentsBox={st:0,get:function(d,c){var b=this.st,e;if(!c){c=20}this.st+=c;this.total=d;a("#commentsdiv img.waiting").show();e={action:"get-comments",mode:"single",_ajax_nonce:a("#add_comment_nonce").val(),post_ID:a("#post_ID").val(),start:b,num:c};a.post(ajaxurl,e,function(f){f=wpAjax.parseAjaxResponse(f);a("#commentsdiv .widefat").show();a("#commentsdiv img.waiting").hide();if("object"==typeof f&&f.responses[0]){a("#the-comment-list").append(f.responses[0].data);theList=theExtraList=null;a("a[className*=':']").unbind();setCommentsList();if(commentsBox.st>commentsBox.total){a("#show-comments").hide()}else{a("#show-comments").html(postL10n.showcomm)}return}else{if(1==f){a("#show-comments").parent().html(postL10n.endcomm);return}}a("#the-comment-list").append(''+wpAjax.broken+"")});return false}};WPSetThumbnailHTML=function(b){a(".inside","#postimagediv").html(b)};WPSetThumbnailID=function(c){var b=a("input[value=_thumbnail_id]","#list-table");if(b.size()>0){a("#meta\\["+b.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(c)}};WPRemoveThumbnail=function(){a.post(ajaxurl,{action:"set-post-thumbnail",post_id:a("#post_ID").val(),thumbnail_id:-1,cookie:encodeURIComponent(document.cookie)},function(b){if(b=="0"){alert(setPostThumbnailL10n.error)}else{WPSetThumbnailHTML(b)}})}})(jQuery);jQuery(document).ready(function(e){var b,a,f="";postboxes.add_postbox_toggles(pagenow);if(e("#tagsdiv-post_tag").length){tagBox.init()}else{e("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(this.id.indexOf("tagsdiv-")===0){tagBox.init();return false}})}e(".categorydiv").each(function(){var l=e(this).attr("id"),h=false,k,m,j,g,i;j=l.split("-");j.shift();g=j.join("-");i=g+"_tab";if(g=="category"){i="cats"}e("a","#"+g+"-tabs").click(function(){var n=e(this).attr("href");e(this).parent().addClass("tabs").siblings("li").removeClass("tabs");e("#"+g+"-tabs").siblings(".tabs-panel").hide();e(n).show();if("#"+g+"-all"==n){deleteUserSetting(i)}else{setUserSetting(i,"pop")}return false});if(getUserSetting(i)){e('a[href="#'+g+'-pop"]',"#"+g+"-tabs").click()}e("#new"+g).one("focus",function(){e(this).val("").removeClass("form-input-tip")});e("#"+g+"-add-submit").click(function(){e("#new"+g).focus()});k=function(){if(h){return}h=true;var n=jQuery(this),p=n.is(":checked"),o=n.val().toString();e("#in-"+g+"-"+o+", #in-"+g+"-category-"+o).attr("checked",p);h=false};catAddBefore=function(n){if(!e("#new"+g).val()){return false}n.data+="&"+e(":checked","#"+g+"checklist").serialize();return n};m=function(q,p){var o,n=e("#new"+g+"_parent");if("undefined"!=p.parsed.responses[0]&&(o=p.parsed.responses[0].supplemental.newcat_parent)){n.before(o);n.remove()}};e("#"+g+"checklist").wpList({alt:"",response:g+"-ajax-response",addBefore:catAddBefore,addAfter:m});e("#"+g+"-add-toggle").click(function(){e("#"+g+"-adder").toggleClass("wp-hidden-children");e('a[href="#'+g+'-all"]',"#"+g+"-tabs").click();return false});e("#"+g+"checklist li.popular-category :checkbox, #"+g+"checklist-pop :checkbox").live("click",function(){var n=e(this),p=n.is(":checked"),o=n.val();if(o&&n.parents("#taxonomy-"+g).length){e("#in-"+g+"-"+o+", #in-popular-"+g+"-"+o).attr("checked",p)}})});if(e("#postcustom").length){e("#the-list").wpList({addAfter:function(g,h){e("table#list-table").show()},addBefore:function(g){g.data+="&post_id="+e("#post_ID").val();return g}})}if(e("#submitdiv").length){b=e("#timestamp").html();a=e("#post-visibility-display").html();function d(){var g=e("#post-visibility-select");if(e("input:radio:checked",g).val()!="public"){e("#sticky").attr("checked",false);e("#sticky-span").hide()}else{e("#sticky-span").show()}if(e("input:radio:checked",g).val()!="password"){e("#password-span").hide()}else{e("#password-span").show()}}function c(){var n,p,h,r,o="page"==pagenow||"page-new"==pagenow,q=e("#post_status"),i=e("option[value=publish]",q),g=e("#aa").val(),l=e("#mm").val(),m=e("#jj").val(),k=e("#hh").val(),j=e("#mn").val();n=new Date(g,l-1,m,k,j);p=new Date(e("#hidden_aa").val(),e("#hidden_mm").val()-1,e("#hidden_jj").val(),e("#hidden_hh").val(),e("#hidden_mn").val());h=new Date(e("#cur_aa").val(),e("#cur_mm").val()-1,e("#cur_jj").val(),e("#cur_hh").val(),e("#cur_mn").val());if(n.getFullYear()!=g||(1+n.getMonth())!=l||n.getDate()!=m||n.getMinutes()!=j){e(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{e(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}if(n>h&&e("#original_post_status").val()!="future"){r=postL10n.publishOnFuture;e("#publish").val(postL10n.schedule)}else{if(n<=h&&e("#original_post_status").val()!="publish"){r=postL10n.publishOn;e("#publish").val(postL10n.publish)}else{r=postL10n.publishOnPast;if(o){e("#publish").val(postL10n.updatePage)}else{e("#publish").val(postL10n.updatePost)}}}if(p.toUTCString()==n.toUTCString()){e("#timestamp").html(b)}else{e("#timestamp").html(r+" "+e("option[value="+e("#mm").val()+"]","#mm").text()+" "+m+", "+g+" @ "+k+":"+j+" ")}if(e("input:radio:checked","#post-visibility-select").val()=="private"){if(o){e("#publish").val(postL10n.updatePage)}else{e("#publish").val(postL10n.updatePost)}if(i.length==0){q.append('")}else{i.html(postL10n.privatelyPublished)}e("option[value=publish]",q).attr("selected",true);e(".edit-post-status","#misc-publishing-actions").hide()}else{if(e("#original_post_status").val()=="future"||e("#original_post_status").val()=="draft"){if(i.length){i.remove();q.val(e("#hidden_post_status").val())}}else{i.html(postL10n.published)}if(q.is(":hidden")){e(".edit-post-status","#misc-publishing-actions").show()}}e("#post-status-display").html(e("option:selected",q).text());if(e("option:selected",q).val()=="private"||e("option:selected",q).val()=="publish"){e("#save-post").hide()}else{e("#save-post").show();if(e("option:selected",q).val()=="pending"){e("#save-post").show().val(postL10n.savePending)}else{e("#save-post").show().val(postL10n.saveDraft)}}return true}e(".edit-visibility","#visibility").click(function(){if(e("#post-visibility-select").is(":hidden")){d();e("#post-visibility-select").slideDown("normal");e(this).hide()}return false});e(".cancel-post-visibility","#post-visibility-select").click(function(){e("#post-visibility-select").slideUp("normal");e("#visibility-radio-"+e("#hidden-post-visibility").val()).attr("checked",true);e("#post_password").val(e("#hidden_post_password").val());e("#sticky").attr("checked",e("#hidden-post-sticky").attr("checked"));e("#post-visibility-display").html(a);e(".edit-visibility","#visibility").show();c();return false});e(".save-post-visibility","#post-visibility-select").click(function(){var g=e("#post-visibility-select");g.slideUp("normal");e(".edit-visibility","#visibility").show();c();if(e("input:radio:checked",g).val()!="public"){e("#sticky").attr("checked",false)}if(true==e("#sticky").attr("checked")){f="Sticky"}else{f=""}e("#post-visibility-display").html(postL10n[e("input:radio:checked",g).val()+f]);return false});e("input:radio","#post-visibility-select").change(function(){d()});e("#timestampdiv").siblings("a.edit-timestamp").click(function(){if(e("#timestampdiv").is(":hidden")){e("#timestampdiv").slideDown("normal");e(this).hide()}return false});e(".cancel-timestamp","#timestampdiv").click(function(){e("#timestampdiv").slideUp("normal");e("#mm").val(e("#hidden_mm").val());e("#jj").val(e("#hidden_jj").val());e("#aa").val(e("#hidden_aa").val());e("#hh").val(e("#hidden_hh").val());e("#mn").val(e("#hidden_mn").val());e("#timestampdiv").siblings("a.edit-timestamp").show();c();return false});e(".save-timestamp","#timestampdiv").click(function(){if(c()){e("#timestampdiv").slideUp("normal");e("#timestampdiv").siblings("a.edit-timestamp").show()}return false});e("#post-status-select").siblings("a.edit-post-status").click(function(){if(e("#post-status-select").is(":hidden")){e("#post-status-select").slideDown("normal");e(this).hide()}return false});e(".save-post-status","#post-status-select").click(function(){e("#post-status-select").slideUp("normal");e("#post-status-select").siblings("a.edit-post-status").show();c();return false});e(".cancel-post-status","#post-status-select").click(function(){e("#post-status-select").slideUp("normal");e("#post_status").val(e("#hidden_post_status").val());e("#post-status-select").siblings("a.edit-post-status").show();c();return false})}if(e("#edit-slug-box").length){editPermalink=function(g){var h,l=0,k=e("#editable-post-name"),m=k.html(),p=e("#post_name"),q=p.val(),n=e("#edit-slug-buttons"),o=n.html(),j=e("#editable-post-name-full").html();e("#view-post-btn").hide();n.html(''+postL10n.ok+' '+postL10n.cancel+"");n.children(".save").click(function(){var i=k.children("input").val();e.post(ajaxurl,{action:"sample-permalink",post_id:g,new_slug:i,new_title:e("#title").val(),samplepermalinknonce:e("#samplepermalinknonce").val()},function(r){e("#edit-slug-box").html(r);n.html(o);p.attr("value",i);makeSlugeditClickable();e("#view-post-btn").show()});return false});e(".cancel","#edit-slug-buttons").click(function(){e("#view-post-btn").show();k.html(m);n.html(o);p.attr("value",q);return false});for(h=0;hj.length/4)?"":j;k.html('').children("input").keypress(function(r){var i=r.keyCode||0;if(13==i){n.children(".save").click();return false}if(27==i){n.children(".cancel").click();return false}p.attr("value",this.value)}).focus()};makeSlugeditClickable=function(){e("#editable-post-name").click(function(){e("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()}if(e("#title").val()==""){e("#title").siblings("#title-prompt-text").css("visibility","")}e("#title-prompt-text").click(function(){e(this).css("visibility","hidden").siblings("#title").focus()});e("#title").blur(function(){if(this.value==""){e(this).siblings("#title-prompt-text").css("visibility","")}}).focus(function(){e(this).siblings("#title-prompt-text").css("visibility","hidden")}).keydown(function(g){e(this).siblings("#title-prompt-text").css("visibility","hidden");e(this).unbind(g)})}); \ No newline at end of file diff --git a/wp-includes/js/autosave.dev.js b/wp-includes/js/autosave.dev.js index b235b78051..ee5c4e4b85 100644 --- a/wp-includes/js/autosave.dev.js +++ b/wp-includes/js/autosave.dev.js @@ -132,7 +132,11 @@ function autosave_saved_new(response) { if ( res && res.responses.length && !res.errors ) { // An ID is sent only for real auto-saves, not for autosave=0 "keepalive" saves postID = parseInt( res.responses[0].id, 10 ); - autosave_update_post_ID( postID ); // disabled form buttons are re-enabled here + if ( !isNaN(postID) && postID > 0 ) { + notSaved = false; + jQuery('#auto_draft').val('0'); // No longer an auto-draft + } + autosave_enable_buttons(); if ( autosaveDelayPreview ) { autosaveDelayPreview = false; doPreview(); @@ -142,17 +146,6 @@ function autosave_saved_new(response) { } } -function autosave_update_post_ID( postID ) { - if ( !isNaN(postID) && postID > 0 ) { - if ( postID == parseInt(jQuery('#post_ID').val(), 10) ) { return; } // no need to do this more than once - notSaved = false; - autosave_enable_buttons(); - jQuery('#delete-action a.submitdelete').fadeIn(); - jQuery('#hiddenaction').val('editpost'); - jQuery('#auto_draft').val('0'); // No longer an auto-draft - } -} - function autosave_update_slug(post_id) { // create slug area only if not already there if ( 'undefined' != makeSlugeditClickable && jQuery.isFunction(makeSlugeditClickable) && !jQuery('#edit-slug-box > *').size() ) { diff --git a/wp-includes/js/autosave.js b/wp-includes/js/autosave.js index ac83ba832a..581fc6f909 100644 --- a/wp-includes/js/autosave.js +++ b/wp-includes/js/autosave.js @@ -1 +1 @@ -var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function($){var dotabkey=true;autosaveLast=$("#post #title").val()+$("#post #content").val();autosavePeriodical=$.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});$("#post").submit(function(){$.cancel(autosavePeriodical)});$('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;$(":button, :submit","#submitpost").each(function(){var t=$(this);if(t.hasClass("button-primary")){t.addClass("button-primary-disabled")}else{t.addClass("button-disabled")}});$("#ajax-loading").css("visibility","visible")});window.onbeforeunload=function(){var mce=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,title,content;if(mce&&!mce.isHidden()){if(mce.isDirty()){return autosaveL10n.saveAlert}}else{title=$("#post #title").val(),content=$("#post #content").val();if((title||content)&&title+content!=autosaveLast){return autosaveL10n.saveAlert}}};$("#post-preview").click(function(){if($("#auto_draft").val()=="1"&¬Saved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){$("input#wp-preview").val("dopreview");$("form#post").attr("target","wp-preview").submit().attr("target","");$("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){$("#title")[$.browser.opera?"keypress":"keydown"](function(e){if(e.which==9&&!e.shiftKey&&!e.controlKey&&!e.altKey){if(($("#auto_draft").val()=="1")&&($("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&dotabkey){e.preventDefault();dotabkey=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==$("#auto_draft").val()){$("#title").blur(function(){if(!this.value||$("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(response){var res=wpAjax.parseAjaxResponse(response,"autosave"),message="",postID,sup,url;if(res&&res.responses&&res.responses.length){message=res.responses[0].data;if(res.responses[0].supplemental){sup=res.responses[0].supplemental;if("disable"==sup.disable_autosave){autosave=function(){};res={errors:true}}if(sup.session_expired&&(url=sup.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(url,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete sup.session_expired}jQuery.each(sup,function(selector,value){if(selector.match(/^replace-/)){jQuery("#"+selector.replace("replace-","")).val(value)}})}if(!res.errors){postID=parseInt(res.responses[0].id,10);if(!isNaN(postID)&&postID>0){autosave_update_slug(postID)}}}if(message){jQuery("#autosave").html(message)}else{if(autosaveOldMessage&&res){jQuery("#autosave").html(autosaveOldMessage)}}return res}function autosave_saved(response){blockSave=false;autosave_parse_response(response);autosave_enable_buttons()}function autosave_saved_new(response){blockSave=false;var res=autosave_parse_response(response),tempID,postID;if(res&&res.responses.length&&!res.errors){postID=parseInt(res.responses[0].id,10);autosave_update_post_ID(postID);if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_post_ID(postID){if(!isNaN(postID)&&postID>0){if(postID==parseInt(jQuery("#post_ID").val(),10)){return}notSaved=false;autosave_enable_buttons();jQuery("#delete-action a.submitdelete").fadeIn();jQuery("#hiddenaction").val("editpost");jQuery("#auto_draft").val("0")}}function autosave_update_slug(post_id){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:post_id,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(data){jQuery("#edit-slug-box").html(data);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery("#ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var rich=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),post_data,doAutoSave,ed,origStatus,successCallback;autosave_disable_buttons();post_data={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){post_data[this.name]=this.value});doAutoSave=true;if(jQuery("#TB_window").css("display")=="block"){doAutoSave=false}if(rich&&doAutoSave){ed=tinyMCE.activeEditor;if(ed.plugins.spellchecker&&ed.plugins.spellchecker.active){doAutoSave=false}else{if("mce_fullscreen"==ed.id){tinyMCE.get("content").setContent(ed.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}post_data.content=jQuery("#content").val();if(jQuery("#post_name").val()){post_data.post_name=jQuery("#post_name").val()}if((post_data.post_title.length==0&&post_data.content.length==0)||post_data.post_title+post_data.content==autosaveLast){doAutoSave=false}origStatus=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(i){goodcats.push(this.value)});post_data.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){post_data.comment_status="open"}if(jQuery("#ping_status").attr("checked")){post_data.ping_status="open"}if(jQuery("#excerpt").size()){post_data.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){post_data.post_author=jQuery("#post_author").val()}if(jQuery("#parent_id").val()){post_data.parent_id=jQuery("#parent_id").val()}post_data.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){post_data.auto_draft="1"}if(doAutoSave){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{post_data.autosave=0}if(post_data.auto_draft=="1"){successCallback=autosave_saved_new}else{successCallback=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:post_data,beforeSend:doAutoSave?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:successCallback})}; \ No newline at end of file +var autosave,autosaveLast="",autosavePeriodical,autosaveOldMessage="",autosaveDelayPreview=false,notSaved=true,blockSave=false,interimLogin=false;jQuery(document).ready(function(b){var a=true;autosaveLast=b("#post #title").val()+b("#post #content").val();autosavePeriodical=b.schedule({time:autosaveL10n.autosaveInterval*1000,func:function(){autosave()},repeat:true,protect:true});b("#post").submit(function(){b.cancel(autosavePeriodical)});b('input[type="submit"], a.submitdelete',"#submitpost").click(function(){blockSave=true;window.onbeforeunload=null;b(":button, :submit","#submitpost").each(function(){var c=b(this);if(c.hasClass("button-primary")){c.addClass("button-primary-disabled")}else{c.addClass("button-disabled")}});b("#ajax-loading").css("visibility","visible")});window.onbeforeunload=function(){var c=typeof(tinyMCE)!="undefined"?tinyMCE.activeEditor:false,e,d;if(c&&!c.isHidden()){if(c.isDirty()){return autosaveL10n.saveAlert}}else{e=b("#post #title").val(),d=b("#post #content").val();if((e||d)&&e+d!=autosaveLast){return autosaveL10n.saveAlert}}};b("#post-preview").click(function(){if(b("#auto_draft").val()=="1"&¬Saved){autosaveDelayPreview=true;autosave();return false}doPreview();return false});doPreview=function(){b("input#wp-preview").val("dopreview");b("form#post").attr("target","wp-preview").submit().attr("target","");b("input#wp-preview").val("")};if(typeof tinyMCE!="undefined"){b("#title")[b.browser.opera?"keypress":"keydown"](function(c){if(c.which==9&&!c.shiftKey&&!c.controlKey&&!c.altKey){if((b("#auto_draft").val()=="1")&&(b("#title").val().length>0)){autosave()}if(tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&a){c.preventDefault();a=false;tinyMCE.activeEditor.focus();return false}}})}if("1"==b("#auto_draft").val()){b("#title").blur(function(){if(!this.value||b("#auto_draft").val()!="1"){return}delayed_autosave()})}});function autosave_parse_response(c){var e=wpAjax.parseAjaxResponse(c,"autosave"),f="",a,b,d;if(e&&e.responses&&e.responses.length){f=e.responses[0].data;if(e.responses[0].supplemental){b=e.responses[0].supplemental;if("disable"==b.disable_autosave){autosave=function(){};e={errors:true}}if(b.session_expired&&(d=b.session_expired)){if(!interimLogin||interimLogin.closed){interimLogin=window.open(d,"login","width=600,height=450,resizable=yes,scrollbars=yes,status=yes");interimLogin.focus()}delete b.session_expired}jQuery.each(b,function(g,h){if(g.match(/^replace-/)){jQuery("#"+g.replace("replace-","")).val(h)}})}if(!e.errors){a=parseInt(e.responses[0].id,10);if(!isNaN(a)&&a>0){autosave_update_slug(a)}}}if(f){jQuery("#autosave").html(f)}else{if(autosaveOldMessage&&e){jQuery("#autosave").html(autosaveOldMessage)}}return e}function autosave_saved(a){blockSave=false;autosave_parse_response(a);autosave_enable_buttons()}function autosave_saved_new(b){blockSave=false;var d=autosave_parse_response(b),c,a;if(d&&d.responses.length&&!d.errors){a=parseInt(d.responses[0].id,10);if(!isNaN(a)&&a>0){notSaved=false;jQuery("#auto_draft").val("0")}autosave_enable_buttons();if(autosaveDelayPreview){autosaveDelayPreview=false;doPreview()}}else{autosave_enable_buttons()}}function autosave_update_slug(a){if("undefined"!=makeSlugeditClickable&&jQuery.isFunction(makeSlugeditClickable)&&!jQuery("#edit-slug-box > *").size()){jQuery.post(ajaxurl,{action:"sample-permalink",post_id:a,new_title:jQuery("#title").val(),samplepermalinknonce:jQuery("#samplepermalinknonce").val()},function(b){jQuery("#edit-slug-box").html(b);makeSlugeditClickable()})}}function autosave_loading(){jQuery("#autosave").html(autosaveL10n.savingText)}function autosave_enable_buttons(){setTimeout(function(){jQuery(":button, :submit","#submitpost").removeAttr("disabled");jQuery("#ajax-loading").css("visibility","hidden")},500)}function autosave_disable_buttons(){jQuery(":button, :submit","#submitpost").attr("disabled","disabled");setTimeout(autosave_enable_buttons,5000)}function delayed_autosave(){setTimeout(function(){if(blockSave){return}autosave()},200)}autosave=function(){blockSave=true;var c=(typeof tinyMCE!="undefined")&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden(),d,f,b,e,a;autosave_disable_buttons();d={action:"autosave",post_ID:jQuery("#post_ID").val()||0,post_title:jQuery("#title").val()||"",autosavenonce:jQuery("#autosavenonce").val(),post_type:jQuery("#post_type").val()||"",autosave:1};jQuery(".tags-input").each(function(){d[this.name]=this.value});f=true;if(jQuery("#TB_window").css("display")=="block"){f=false}if(c&&f){b=tinyMCE.activeEditor;if(b.plugins.spellchecker&&b.plugins.spellchecker.active){f=false}else{if("mce_fullscreen"==b.id){tinyMCE.get("content").setContent(b.getContent({format:"raw"}),{format:"raw"})}tinyMCE.get("content").save()}}d.content=jQuery("#content").val();if(jQuery("#post_name").val()){d.post_name=jQuery("#post_name").val()}if((d.post_title.length==0&&d.content.length==0)||d.post_title+d.content==autosaveLast){f=false}e=jQuery("#original_post_status").val();goodcats=([]);jQuery("[name='post_category[]']:checked").each(function(g){goodcats.push(this.value)});d.catslist=goodcats.join(",");if(jQuery("#comment_status").attr("checked")){d.comment_status="open"}if(jQuery("#ping_status").attr("checked")){d.ping_status="open"}if(jQuery("#excerpt").size()){d.excerpt=jQuery("#excerpt").val()}if(jQuery("#post_author").size()){d.post_author=jQuery("#post_author").val()}if(jQuery("#parent_id").val()){d.parent_id=jQuery("#parent_id").val()}d.user_ID=jQuery("#user-id").val();if(jQuery("#auto_draft").val()=="1"){d.auto_draft="1"}if(f){autosaveLast=jQuery("#title").val()+jQuery("#content").val()}else{d.autosave=0}if(d.auto_draft=="1"){a=autosave_saved_new}else{a=autosave_saved}autosaveOldMessage=jQuery("#autosave").html();jQuery.ajax({data:d,beforeSend:f?autosave_loading:null,type:"POST",url:autosaveL10n.requestFile,success:a})}; \ No newline at end of file