WordPress/wp-admin/js/post.min.js
Bot (Assets) e30777bc0a Compress scripts/styles: 3.6-beta3-24306.
git-svn-id: http://core.svn.wordpress.org/trunk@24306 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-20 20:58:55 +00:00

1 line
17 KiB
JavaScript

var tagBox,commentsBox,editPermalink,makeSlugeditClickable,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail,wptitlehint;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(c){var b=postL10n.comma;if(","!==b){c=c.replace(new RegExp(b,"g"),",")}c=c.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,"");if(","!==b){c=c.replace(/,/g,b)}return c},parseTags:function(f){var i=f.id,c=i.split("-check-num-")[1],e=a(f).closest(".tagsdiv"),h=e.find(".the-tags"),b=postL10n.comma,d=h.val().split(b),g=[];delete d[c];a.each(d,function(j,k){k=a.trim(k);if(k){g.push(k)}});h.val(this.clean(g.join(b)));this.quickClicks(e);return false},quickClicks:function(d){var g=a(".the-tags",d),e=a(".tagchecklist",d),f=a(d).attr("id"),b,c;if(!g.length){return}c=g.prop("disabled");b=g.val().split(postL10n.comma);e.empty();a.each(b,function(i,k){var j,h;k=a.trim(k);if(!k){return}j=a("<span />").text(k);if(!c){h=a('<a id="'+f+"-check-num-"+i+'" class="ntdelbutton">X</a>');h.click(function(){tagBox.parseTags(this)});j.prepend("&nbsp;").prepend(h)}e.append(j)})},flushTags:function(g,c,h){c=c||false;var d=a(".the-tags",g),j=a("input.newtag",g),b=postL10n.comma,e,i;i=c?a(c).text():j.val();tagsval=d.val();e=tagsval?tagsval+b+i:i;e=this.clean(e);e=array_unique_noempty(e.split(b)).join(b);d.val(e);this.quickClicks(g);if(!c){j.val("")}if("undefined"==typeof(h)){j.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('<p id="tagcloud-'+b+'" class="the-tagcloud">'+e+"</p>");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:postL10n.comma+" "})});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 .spinner").show();e={action:"get-comments",mode:"single",_ajax_nonce:a("#add_comment_nonce").val(),p:a("#post_ID").val(),start:b,number:c};a.post(ajaxurl,e,function(f){f=wpAjax.parseAjaxResponse(f);a("#commentsdiv .widefat").show();a("#commentsdiv .spinner").hide();if("object"==typeof f&&f.responses[0]){a("#the-comment-list").append(f.responses[0].data);theList=theExtraList=null;a("a[className*=':']").unbind();if(commentsBox.st>commentsBox.total){a("#show-comments").hide()}else{a("#show-comments").show().children("a").html(postL10n.showcomm)}return}else{if(1==f){a("#show-comments").html(postL10n.endcomm);return}}a("#the-comment-list").append('<tr><td colspan="2">'+wpAjax.broken+"</td></tr>")});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(b){a.post(ajaxurl,{action:"set-post-thumbnail",post_id:a("#post_ID").val(),thumbnail_id:-1,_ajax_nonce:b,cookie:encodeURIComponent(document.cookie)},function(c){if(c=="0"){alert(setPostThumbnailL10n.error)}else{WPSetThumbnailHTML(c)}})};a(document).on("heartbeat-send.refresh-lock",function(g,d){var c=a("#active_post_lock").val(),b=a("#post_ID").val(),f={};if(!b||!a("#post-lock-dialog").length){return}f.post_id=b;if(c){f.lock=c}d["wp-refresh-post-lock"]=f});a(document).on("heartbeat-tick.refresh-lock",function(f,d){var g,c,b;if(d["wp-refresh-post-lock"]){g=d["wp-refresh-post-lock"];if(g.lock_error){c=a("#post-lock-dialog");if(c.length&&!c.is(":visible")){if(typeof autosave=="function"){a(document).on("autosave-disable-buttons.post-lock",function(){c.addClass("saving")}).on("autosave-enable-buttons.post-lock",function(){c.removeClass("saving").addClass("saved");window.onbeforeunload=null});if(!autosave()){window.onbeforeunload=null}autosave=function(){}}if(g.lock_error.avatar_src){b=a('<img class="avatar avatar-64 photo" width="64" height="64" />').attr("src",g.lock_error.avatar_src.replace(/&amp;/g,"&"));c.find("div.post-locked-avatar").empty().append(b)}c.show().find(".currently-editing").text(g.lock_error.text);c.find(".wp-tab-first").focus()}}else{if(g.new_lock){a("#active_post_lock").val(g.new_lock)}}}})}(jQuery));(function(c){var a,b;function d(){a=false;window.clearTimeout(b);b=window.setTimeout(function(){a=1},3600000)}c(document).on("heartbeat-send.wp-refresh-nonces",function(i,h){var g,f;if(a){if((f=c("#post_ID").val())&&(g=c("#_wpnonce").val())){h["wp-refresh-post-nonces"]={post_id:f,post_nonce:g}}a=2}}).on("heartbeat-tick.wp-refresh-nonces",function(g,f){if(a===2){d()}if(f["wp-refresh-post-nonces"]){c.each(f["wp-refresh-post-nonces"],function(e,h){if(e.match(/^replace-/)){c("#"+e.replace("replace-","")).val(h)}})}}).ready(function(){d()})}(jQuery));jQuery(document).ready(function(f){var b,a,g="",e=0,h=f("#content");postboxes.add_postbox_toggles(pagenow);f("#post-lock-dialog .notification-dialog").on("keydown",function(j){if(j.which!=9){return}var i=f(j.target);if(i.hasClass("wp-tab-first")&&j.shiftKey){f(this).find(".wp-tab-last").focus();j.preventDefault()}else{if(i.hasClass("wp-tab-last")&&!j.shiftKey){f(this).find(".wp-tab-first").focus();j.preventDefault()}}}).filter(":visible").find(".wp-tab-first").focus();if(f("#tagsdiv-post_tag").length){tagBox.init()}else{f("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(this.id.indexOf("tagsdiv-")===0){tagBox.init();return false}})}f(".categorydiv").each(function(){var m=f(this).attr("id"),l,n,k,i,j;k=m.split("-");k.shift();i=k.join("-");j=i+"_tab";if(i=="category"){j="cats"}f("a","#"+i+"-tabs").click(function(){var o=f(this).attr("href");f(this).parent().addClass("tabs").siblings("li").removeClass("tabs");f("#"+i+"-tabs").siblings(".tabs-panel").hide();f(o).show();if("#"+i+"-all"==o){deleteUserSetting(j)}else{setUserSetting(j,"pop")}return false});if(getUserSetting(j)){f('a[href="#'+i+'-pop"]',"#"+i+"-tabs").click()}f("#new"+i).one("focus",function(){f(this).val("").removeClass("form-input-tip")});f("#new"+i).keypress(function(o){if(13===o.keyCode){o.preventDefault();f("#"+i+"-add-submit").click()}});f("#"+i+"-add-submit").click(function(){f("#new"+i).focus()});l=function(o){if(!f("#new"+i).val()){return false}o.data+="&"+f(":checked","#"+i+"checklist").serialize();f("#"+i+"-add-submit").prop("disabled",true);return o};n=function(t,q){var p,o=f("#new"+i+"_parent");f("#"+i+"-add-submit").prop("disabled",false);if("undefined"!=q.parsed.responses[0]&&(p=q.parsed.responses[0].supplemental.newcat_parent)){o.before(p);o.remove()}};f("#"+i+"checklist").wpList({alt:"",response:i+"-ajax-response",addBefore:l,addAfter:n});f("#"+i+"-add-toggle").click(function(){f("#"+i+"-adder").toggleClass("wp-hidden-children");f('a[href="#'+i+'-all"]',"#"+i+"-tabs").click();f("#new"+i).focus();return false});f("#"+i+"checklist, #"+i+"checklist-pop").on("click",'li.popular-category > label input[type="checkbox"]',function(){var o=f(this),q=o.is(":checked"),p=o.val();if(p&&o.parents("#taxonomy-"+i).length){f("#in-"+i+"-"+p+", #in-popular-"+i+"-"+p).prop("checked",q)}})});if(f("#postcustom").length){f("#the-list").wpList({addAfter:function(i,j){f("table#list-table").show()},addBefore:function(i){i.data+="&post_id="+f("#post_ID").val();return i}})}if(f("#submitdiv").length){b=f("#timestamp").html();a=f("#post-visibility-display").html();function d(){var i=f("#post-visibility-select");if(f("input:radio:checked",i).val()!="public"){f("#sticky").prop("checked",false);f("#sticky-span").hide()}else{f("#sticky-span").show()}if(f("input:radio:checked",i).val()!="password"){f("#password-span").hide()}else{f("#password-span").show()}}function c(){if(!f("#timestampdiv").length){return true}var p,q,j,s,r=f("#post_status"),k=f('option[value="publish"]',r),i=f("#aa").val(),n=f("#mm").val(),o=f("#jj").val(),m=f("#hh").val(),l=f("#mn").val();p=new Date(i,n-1,o,m,l);q=new Date(f("#hidden_aa").val(),f("#hidden_mm").val()-1,f("#hidden_jj").val(),f("#hidden_hh").val(),f("#hidden_mn").val());j=new Date(f("#cur_aa").val(),f("#cur_mm").val()-1,f("#cur_jj").val(),f("#cur_hh").val(),f("#cur_mn").val());if(p.getFullYear()!=i||(1+p.getMonth())!=n||p.getDate()!=o||p.getMinutes()!=l){f(".timestamp-wrap","#timestampdiv").addClass("form-invalid");return false}else{f(".timestamp-wrap","#timestampdiv").removeClass("form-invalid")}if(p>j&&f("#original_post_status").val()!="future"){s=postL10n.publishOnFuture;f("#publish").val(postL10n.schedule)}else{if(p<=j&&f("#original_post_status").val()!="publish"){s=postL10n.publishOn;f("#publish").val(postL10n.publish)}else{s=postL10n.publishOnPast;f("#publish").val(postL10n.update)}}if(q.toUTCString()==p.toUTCString()){f("#timestamp").html(b)}else{f("#timestamp").html(s+" <b>"+postL10n.dateFormat.replace("%1$s",f('option[value="'+f("#mm").val()+'"]',"#mm").text()).replace("%2$s",o).replace("%3$s",i).replace("%4$s",m).replace("%5$s",l)+"</b> ")}if(f("input:radio:checked","#post-visibility-select").val()=="private"){f("#publish").val(postL10n.update);if(k.length==0){r.append('<option value="publish">'+postL10n.privatelyPublished+"</option>")}else{k.html(postL10n.privatelyPublished)}f('option[value="publish"]',r).prop("selected",true);f(".edit-post-status","#misc-publishing-actions").hide()}else{if(f("#original_post_status").val()=="future"||f("#original_post_status").val()=="draft"){if(k.length){k.remove();r.val(f("#hidden_post_status").val())}}else{k.html(postL10n.published)}if(r.is(":hidden")){f(".edit-post-status","#misc-publishing-actions").show()}}f("#post-status-display").html(f("option:selected",r).text());if(f("option:selected",r).val()=="private"||f("option:selected",r).val()=="publish"){f("#save-post").hide()}else{f("#save-post").show();if(f("option:selected",r).val()=="pending"){f("#save-post").show().val(postL10n.savePending)}else{f("#save-post").show().val(postL10n.saveDraft)}}return true}f(".edit-visibility","#visibility").click(function(){if(f("#post-visibility-select").is(":hidden")){d();f("#post-visibility-select").slideDown("fast");f(this).hide()}return false});f(".cancel-post-visibility","#post-visibility-select").click(function(){f("#post-visibility-select").slideUp("fast");f("#visibility-radio-"+f("#hidden-post-visibility").val()).prop("checked",true);f("#post_password").val(f("#hidden-post-password").val());f("#sticky").prop("checked",f("#hidden-post-sticky").prop("checked"));f("#post-visibility-display").html(a);f(".edit-visibility","#visibility").show();c();return false});f(".save-post-visibility","#post-visibility-select").click(function(){var i=f("#post-visibility-select");i.slideUp("fast");f(".edit-visibility","#visibility").show();c();if(f("input:radio:checked",i).val()!="public"){f("#sticky").prop("checked",false)}if(true==f("#sticky").prop("checked")){g="Sticky"}else{g=""}f("#post-visibility-display").html(postL10n[f("input:radio:checked",i).val()+g]);return false});f("input:radio","#post-visibility-select").change(function(){d()});f("#timestampdiv").siblings("a.edit-timestamp").click(function(){if(f("#timestampdiv").is(":hidden")){f("#timestampdiv").slideDown("fast");f("#mm").focus();f(this).hide()}return false});f(".cancel-timestamp","#timestampdiv").click(function(){f("#timestampdiv").slideUp("fast");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("#timestampdiv").siblings("a.edit-timestamp").show();c();return false});f(".save-timestamp","#timestampdiv").click(function(){if(c()){f("#timestampdiv").slideUp("fast");f("#timestampdiv").siblings("a.edit-timestamp").show()}return false});f("#post").on("submit",function(i){if(!c()){i.preventDefault();f("#timestampdiv").show();f("#publishing-action .spinner").hide();f("#publish").prop("disabled",false).removeClass("button-primary-disabled");return false}});f("#post-status-select").siblings("a.edit-post-status").click(function(){if(f("#post-status-select").is(":hidden")){f("#post-status-select").slideDown("fast");f(this).hide()}return false});f(".save-post-status","#post-status-select").click(function(){f("#post-status-select").slideUp("fast");f("#post-status-select").siblings("a.edit-post-status").show();c();return false});f(".cancel-post-status","#post-status-select").click(function(){f("#post-status-select").slideUp("fast");f("#post_status").val(f("#hidden_post_status").val());f("#post-status-select").siblings("a.edit-post-status").show();c();return false})}if(f("#edit-slug-box").length){editPermalink=function(j){var k,n=0,m=f("#editable-post-name"),o=m.html(),r=f("#post_name"),s=r.val(),p=f("#edit-slug-buttons"),q=p.html(),l=f("#editable-post-name-full").html();f("#view-post-btn").hide();p.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+"</a>");p.children(".save").click(function(){var i=m.children("input").val();if(i==f("#editable-post-name-full").text()){return f(".cancel","#edit-slug-buttons").click()}f.post(ajaxurl,{action:"sample-permalink",post_id:j,new_slug:i,new_title:f("#title").val(),samplepermalinknonce:f("#samplepermalinknonce").val()},function(u){var t=f("#edit-slug-box");t.html(u);if(t.hasClass("hidden")){t.fadeIn("fast",function(){t.removeClass("hidden")})}p.html(q);r.val(i);makeSlugeditClickable();f("#view-post-btn").show()});return false});f(".cancel","#edit-slug-buttons").click(function(){f("#view-post-btn").show();m.html(o);p.html(q);r.val(s);return false});for(k=0;k<l.length;++k){if("%"==l.charAt(k)){n++}}slug_value=(n>l.length/4)?"":l;m.html('<input type="text" id="new-post-slug" value="'+slug_value+'" />').children("input").keypress(function(t){var i=t.keyCode||0;if(13==i){p.children(".save").click();return false}if(27==i){p.children(".cancel").click();return false}}).keyup(function(i){r.val(this.value)}).focus()};makeSlugeditClickable=function(){f("#editable-post-name").click(function(){f("#edit-slug-buttons").children(".edit-slug").click()})};makeSlugeditClickable()}if(typeof(wpWordCount)!="undefined"){f(document).triggerHandler("wpcountwords",[h.val()]);h.keyup(function(j){var i=j.keyCode||j.charCode;if(i==e){return true}if(13==i||8==e||46==e){f(document).triggerHandler("wpcountwords",[h.val()])}e=i;return true})}wptitlehint=function(k){k=k||"title";var i=f("#"+k),j=f("#"+k+"-prompt-text");if(i.val()==""){j.removeClass("screen-reader-text")}j.click(function(){f(this).addClass("screen-reader-text");i.focus()});i.blur(function(){if(this.value==""){j.removeClass("screen-reader-text")}}).focus(function(){j.addClass("screen-reader-text")}).keydown(function(l){j.addClass("screen-reader-text");f(this).unbind(l)})};wptitlehint();(function(){var i=f("textarea#content"),l=null,j;if(!i.length||"ontouchstart" in window){return}function k(n){i.height(Math.max(50,l+n.pageY)+"px");return false}function m(o){var n;i.focus();f(document).unbind("mousemove",k).unbind("mouseup",m);n=parseInt(i.css("height"),10);if(n&&n>50&&n<5000){setUserSetting("ed_size",n)}}i.css("resize","none");j=f('<div id="content-resize-handle"><br></div>');f("#wp-content-wrap").append(j);j.on("mousedown",function(n){l=i.height()-n.pageY;i.blur();f(document).mousemove(k).mouseup(m);return false})})();if(typeof(tinymce)!="undefined"){tinymce.onAddEditor.add(function(i,j){if(j.id!="content"||tinymce.isIOS5){return}function k(){var l,m=document.getElementById("content_ifr"),o=m?parseInt(m.style.height,10):0,n=f("#content_tbl tr.mceFirst").height();if(!o||!n){return false}l=o+n+21;l-=33;return l}j.onLoadContent.add(function(m,q){var r,n=document.getElementById("content"),l=n?parseInt(n.style.height,10):0,p=f("#content_tbl tr.mceFirst").height()||33;if(!l||l<50||l>5000){l=360}if(getUserSetting("ed_size")>5000){setUserSetting("ed_size",360)}r=(l-p)+12;if(r>50&&r<5000){f("#content_tbl").css("height","");f("#content_ifr").css("height",r+"px")}});j.onSaveContent.add(function(m,n){var l=k();if(!l||l<50||l>5000){return}f("textarea#content").css("height",l+"px")});j.onPostRender.add(function(){f("#content_resize").on("mousedown.wp-mce-resize",function(l){f(document).on("mouseup.wp-mce-resize",function(n){var m;f(document).off("mouseup.wp-mce-resize");m=k();if(m&&m>50&&m<5000){setUserSetting("ed_size",m)}})})})})}});