1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
var commentsBox,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail,wptitlehint,editPermalink,makeSlugeditClickable=editPermalink=function(){};window.wp=window.wp||{},function(n){var t=!1;commentsBox={st:0,get:function(t,e){var s=this.st;return e=e||20,this.st+=e,this.total=t,n("#commentsdiv .spinner").addClass("is-active"),e={action:"get-comments",mode:"single",_ajax_nonce:n("#add_comment_nonce").val(),p:n("#post_ID").val(),start:s,number:e},n.post(ajaxurl,e,function(t){return t=wpAjax.parseAjaxResponse(t),n("#commentsdiv .widefat").show(),n("#commentsdiv .spinner").removeClass("is-active"),"object"==typeof t&&t.responses[0]?(n("#the-comment-list").append(t.responses[0].data),theList=theExtraList=null,n("a[className*=':']").unbind(),void(commentsBox.st>commentsBox.total?n("#show-comments").hide():n("#show-comments").show().children("a").html(postL10n.showcomm))):void(1!=t?n("#the-comment-list").append('<tr><td colspan="2">'+wpAjax.broken+"</td></tr>"):n("#show-comments").html(postL10n.endcomm))}),!1}},WPSetThumbnailHTML=function(t){n(".inside","#postimagediv").html(t)},WPSetThumbnailID=function(t){var e=n('input[value="_thumbnail_id"]',"#list-table");0<e.size()&&n("#meta\\["+e.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(t)},WPRemoveThumbnail=function(t){n.post(ajaxurl,{action:"set-post-thumbnail",post_id:n("#post_ID").val(),thumbnail_id:-1,_ajax_nonce:t,cookie:encodeURIComponent(document.cookie)},function(t){"0"==t?alert(setPostThumbnailL10n.error):WPSetThumbnailHTML(t)})},n(document).on("heartbeat-send.refresh-lock",function(t,e){var s=n("#active_post_lock").val(),i=n("#post_ID").val(),a={};i&&n("#post-lock-dialog").length&&(a.post_id=i,s&&(a.lock=s),e["wp-refresh-post-lock"]=a)}).on("heartbeat-tick.refresh-lock",function(t,e){var s,i;e["wp-refresh-post-lock"]&&((s=e["wp-refresh-post-lock"]).lock_error?(i=n("#post-lock-dialog")).length&&!i.is(":visible")&&(wp.autosave&&(n(document).one("heartbeat-tick",function(){wp.autosave.server.suspend(),i.removeClass("saving").addClass("saved"),n(window).off("beforeunload.edit-post")}),i.addClass("saving"),wp.autosave.server.triggerSave()),s.lock_error.avatar_src&&(e=n('<img class="avatar avatar-64 photo" width="64" height="64" />').attr("src",s.lock_error.avatar_src.replace(/&/g,"&")),i.find("div.post-locked-avatar").empty().append(e)),i.show().find(".currently-editing").text(s.lock_error.text),i.find(".wp-tab-first").focus()):s.new_lock&&n("#active_post_lock").val(s.new_lock))}).on("before-autosave.update-post-slug",function(){t=document.activeElement&&"title"===document.activeElement.id}).on("after-autosave.update-post-slug",function(){n("#edit-slug-box > *").length||t||n.post(ajaxurl,{action:"sample-permalink",post_id:n("#post_ID").val(),new_title:n("#title").val(),samplepermalinknonce:n("#samplepermalinknonce").val()},function(t){"-1"!=t&&n("#edit-slug-box").html(t)})})}(jQuery),function(a){var n,t;function s(){n=!1,window.clearTimeout(t),t=window.setTimeout(function(){n=!0},3e5)}a(document).on("heartbeat-send.wp-refresh-nonces",function(t,e){var s,i;n&&(i=a("#post_ID").val())&&(s=a("#_wpnonce").val())&&(e["wp-refresh-post-nonces"]={post_id:i,post_nonce:s})}).on("heartbeat-tick.wp-refresh-nonces",function(t,e){e=e["wp-refresh-post-nonces"];e&&(s(),e.replace&&a.each(e.replace,function(t,e){a("#"+t).val(e)}),e.heartbeatNonce&&(window.heartbeatSettings.nonce=e.heartbeatNonce))}).ready(function(){s()})}(jQuery),jQuery(document).ready(function(d){var u,e,s,t,i,a,n,o,l,r,p="",c=0,h=d("#content"),v=d(document),f=d("#edit-slug-box"),m=d("#post_ID").val()||0,w=d("#submitpost"),b=!0,g=d("#post-visibility-select"),k=d("#timestampdiv"),_=d("#post-status-select");function y(t){r.hasClass("wp-editor-expand")||(o?a.theme.resizeTo(null,n+t.pageY):l.height(Math.max(50,n+t.pageY)),t.preventDefault())}function x(){var t;r.hasClass("wp-editor-expand")||(t=o?(a.focus(),((t=parseInt(d("#wp-content-editor-container .mce-toolbar-grp").height(),10))<10||200<t)&&(t=30),parseInt(d("#content_ifr").css("height"),10)+t-28):(l.focus(),parseInt(l.css("height"),10)),v.off(".wp-editor-resize"),t&&50<t&&t<5e3&&setUserSetting("ed_size",t))}postboxes.add_postbox_toggles(pagenow),window.name="",d("#post-lock-dialog .notification-dialog").on("keydown",function(t){var e;9==t.which&&((e=d(t.target)).hasClass("wp-tab-first")&&t.shiftKey?(d(this).find(".wp-tab-last").focus(),t.preventDefault()):e.hasClass("wp-tab-last")&&!t.shiftKey&&(d(this).find(".wp-tab-first").focus(),t.preventDefault()))}).filter(":visible").find(".wp-tab-first").focus(),wp.heartbeat&&d("#post-lock-dialog").length&&wp.heartbeat.interval(15),s=w.find(":submit, a.submitdelete, #post-preview").on("click.edit-post",function(t){var e=d(this);e.hasClass("disabled")?t.preventDefault():e.hasClass("submitdelete")||e.is("#post-preview")||d("form#post").off("submit.edit-post").on("submit.edit-post",function(t){t.isDefaultPrevented()||(wp.autosave&&wp.autosave.server.suspend(),b=!1,d(window).off("beforeunload.edit-post"),s.addClass("disabled"),("publish"===e.attr("id")?w.find("#major-publishing-actions .spinner"):w.find("#minor-publishing .spinner")).addClass("is-active"))})}),d("#post-preview").on("click.post-preview",function(t){var e=d(this),s=d("form#post"),i=d("input#wp-preview"),a=e.attr("target")||"wp-preview",n=navigator.userAgent.toLowerCase();t.preventDefault(),e.hasClass("disabled")||(wp.autosave&&wp.autosave.server.tempBlockSave(),i.val("dopreview"),s.attr("target",a).submit().attr("target",""),-1!==n.indexOf("safari")&&-1===n.indexOf("chrome")&&s.attr("action",function(t,e){return e+"?t="+(new Date).getTime()}),i.val(""))}),d("#title").on("keydown.editor-focus",function(t){var e,s;if(9===t.keyCode&&!t.ctrlKey&&!t.altKey&&!t.shiftKey){if(e="undefined"!=typeof tinymce&&tinymce.get("content"),s=d("#content"),e&&!e.isHidden())e.focus();else{if(!s.length)return;s.focus()}t.preventDefault()}}),d("#auto_draft").val()&&d("#title").blur(function(){var t;this.value&&!d("#edit-slug-box > *").length&&(d("form#post").one("submit",function(){t=!0}),window.setTimeout(function(){!t&&wp.autosave&&wp.autosave.server.triggerSave()},200))}),v.on("autosave-disable-buttons.edit-post",function(){s.addClass("disabled")}).on("autosave-enable-buttons.edit-post",function(){wp.heartbeat&&wp.heartbeat.hasConnectionError()||s.removeClass("disabled")}).on("before-autosave.edit-post",function(){d(".autosave-message").text(postL10n.savingText)}).on("after-autosave.edit-post",function(t,e){d(".autosave-message").text(e.message)}),d(window).on("beforeunload.edit-post",function(){var t="undefined"!=typeof tinymce&&tinymce.get("content");if(t&&!t.isHidden()&&t.isDirty()||wp.autosave&&wp.autosave.server.postChanged())return postL10n.saveAlert}).on("unload.edit-post",function(t){b&&(t.target&&"#document"!=t.target.nodeName||d.ajax({type:"POST",url:ajaxurl,async:!1,data:{action:"wp-remove-post-lock",_wpnonce:d("#_wpnonce").val(),post_ID:d("#post_ID").val(),active_post_lock:d("#active_post_lock").val()}}))}),d("#tagsdiv-post_tag").length?window.tagBox&&window.tagBox.init():d("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(0===this.id.indexOf("tagsdiv-"))return window.tagBox&&window.tagBox.init(),!1}),d(".categorydiv").each(function(){var t,a,e,s=d(this).attr("id").split("-");s.shift(),a=s.join("-"),e="category"==a?"cats":a+"_tab",d("a","#"+a+"-tabs").click(function(){var t=d(this).attr("href");return d(this).parent().addClass("tabs").siblings("li").removeClass("tabs"),d("#"+a+"-tabs").siblings(".tabs-panel").hide(),d(t).show(),"#"+a+"-all"==t?deleteUserSetting(e):setUserSetting(e,"pop"),!1}),getUserSetting(e)&&d('a[href="#'+a+'-pop"]',"#"+a+"-tabs").click(),d("#new"+a).one("focus",function(){d(this).val("").removeClass("form-input-tip")}),d("#new"+a).keypress(function(t){13===t.keyCode&&(t.preventDefault(),d("#"+a+"-add-submit").click())}),d("#"+a+"-add-submit").click(function(){d("#new"+a).focus()}),t=function(t){return!!d("#new"+a).val()&&(t.data+="&"+d(":checked","#"+a+"checklist").serialize(),d("#"+a+"-add-submit").prop("disabled",!0),t)},s=function(t,e){var s,i=d("#new"+a+"_parent");d("#"+a+"-add-submit").prop("disabled",!1),"undefined"!=e.parsed.responses[0]&&(s=e.parsed.responses[0].supplemental.newcat_parent)&&(i.before(s),i.remove())},d("#"+a+"checklist").wpList({alt:"",response:a+"-ajax-response",addBefore:t,addAfter:s}),d("#"+a+"-add-toggle").click(function(){return d("#"+a+"-adder").toggleClass("wp-hidden-children"),d('a[href="#'+a+'-all"]',"#"+a+"-tabs").click(),d("#new"+a).focus(),!1}),d("#"+a+"checklist, #"+a+"checklist-pop").on("click",'li.popular-category > label input[type="checkbox"]',function(){var t=d(this),e=t.is(":checked"),s=t.val();s&&t.parents("#taxonomy-"+a).length&&d("#in-"+a+"-"+s+", #in-popular-"+a+"-"+s).prop("checked",e)})}),d("#postcustom").length&&d("#the-list").wpList({addAfter:function(){d("table#list-table").show()},addBefore:function(t){return t.data+="&post_id="+d("#post_ID").val(),t}}),d("#submitdiv").length&&(u=d("#timestamp").html(),e=d("#post-visibility-display").html(),t=function(){"public"!=g.find("input:radio:checked").val()?(d("#sticky").prop("checked",!1),d("#sticky-span").hide()):d("#sticky-span").show(),"password"!=g.find("input:radio:checked").val()?d("#password-span").hide():d("#password-span").show()},i=function(){if(!k.length)return!0;var t,e=d("#post_status"),s=d('option[value="publish"]',e),i=d("#aa").val(),a=d("#mm").val(),n=d("#jj").val(),o=d("#hh").val(),l=d("#mn").val(),r=new Date(i,a-1,n,o,l),p=new Date(d("#hidden_aa").val(),d("#hidden_mm").val()-1,d("#hidden_jj").val(),d("#hidden_hh").val(),d("#hidden_mn").val()),c=new Date(d("#cur_aa").val(),d("#cur_mm").val()-1,d("#cur_jj").val(),d("#cur_hh").val(),d("#cur_mn").val());return r.getFullYear()!=i||1+r.getMonth()!=a||r.getDate()!=n||r.getMinutes()!=l?(k.find(".timestamp-wrap").addClass("form-invalid"),!1):(k.find(".timestamp-wrap").removeClass("form-invalid"),c<r&&"future"!=d("#original_post_status").val()?(t=postL10n.publishOnFuture,d("#publish").val(postL10n.schedule)):r<=c&&"publish"!=d("#original_post_status").val()?(t=postL10n.publishOn,d("#publish").val(postL10n.publish)):(t=postL10n.publishOnPast,d("#publish").val(postL10n.update)),p.toUTCString()==r.toUTCString()?d("#timestamp").html(u):d("#timestamp").html(t+" <b>"+postL10n.dateFormat.replace("%1$s",d('option[value="'+d("#mm").val()+'"]',"#mm").text()).replace("%2$s",n).replace("%3$s",i).replace("%4$s",o).replace("%5$s",l)+"</b> "),"private"==g.find("input:radio:checked").val()?(d("#publish").val(postL10n.update),0===s.length?e.append('<option value="publish">'+postL10n.privatelyPublished+"</option>"):s.html(postL10n.privatelyPublished),d('option[value="publish"]',e).prop("selected",!0),d("#misc-publishing-actions .edit-post-status").hide()):("future"==d("#original_post_status").val()||"draft"==d("#original_post_status").val()?s.length&&(s.remove(),e.val(d("#hidden_post_status").val())):s.html(postL10n.published),e.is(":hidden")&&d("#misc-publishing-actions .edit-post-status").show()),d("#post-status-display").html(d("option:selected",e).text()),"private"==d("option:selected",e).val()||"publish"==d("option:selected",e).val()?d("#save-post").hide():(d("#save-post").show(),"pending"==d("option:selected",e).val()?d("#save-post").show().val(postL10n.savePending):d("#save-post").show().val(postL10n.saveDraft)),!0)},d("#visibility .edit-visibility").click(function(){return g.is(":hidden")&&(t(),g.slideDown("fast").find('input[type="radio"]').first().focus(),d(this).hide()),!1}),g.find(".cancel-post-visibility").click(function(t){g.slideUp("fast"),d("#visibility-radio-"+d("#hidden-post-visibility").val()).prop("checked",!0),d("#post_password").val(d("#hidden-post-password").val()),d("#sticky").prop("checked",d("#hidden-post-sticky").prop("checked")),d("#post-visibility-display").html(e),d("#visibility .edit-visibility").show().focus(),i(),t.preventDefault()}),g.find(".save-post-visibility").click(function(t){g.slideUp("fast"),d("#visibility .edit-visibility").show(),i(),"public"!=g.find("input:radio:checked").val()&&d("#sticky").prop("checked",!1),p=d("#sticky").prop("checked")?"Sticky":"",d("#post-visibility-display").html(postL10n[g.find("input:radio:checked").val()+p]),t.preventDefault()}),g.find("input:radio").change(function(){t()}),k.siblings("a.edit-timestamp").click(function(t){k.is(":hidden")&&(k.slideDown("fast"),d("#mm").focus(),d(this).hide()),t.preventDefault()}),k.find(".cancel-timestamp").click(function(t){k.slideUp("fast").siblings("a.edit-timestamp").show().focus(),d("#mm").val(d("#hidden_mm").val()),d("#jj").val(d("#hidden_jj").val()),d("#aa").val(d("#hidden_aa").val()),d("#hh").val(d("#hidden_hh").val()),d("#mn").val(d("#hidden_mn").val()),i(),t.preventDefault()}),k.find(".save-timestamp").click(function(t){i()&&(k.slideUp("fast"),k.siblings("a.edit-timestamp").show()),t.preventDefault()}),d("#post").on("submit",function(t){i()||(t.preventDefault(),k.show(),wp.autosave&&wp.autosave.enableButtons(),d("#publishing-action .spinner").removeClass("is-active"))}),_.siblings("a.edit-post-status").click(function(t){_.is(":hidden")&&(_.slideDown("fast").find("select").focus(),d(this).hide()),t.preventDefault()}),_.find(".save-post-status").click(function(t){_.slideUp("fast").siblings("a.edit-post-status").show(),i(),t.preventDefault()}),_.find(".cancel-post-status").click(function(t){d("#post-status-select").slideUp("fast").siblings("a.edit-post-status").show().focus(),d("#post_status").val(d("#hidden_post_status").val()),i(),t.preventDefault()})),f.length&&f.on("click",function(t){t=d(t.target);(t.is("#editable-post-name")||t.hasClass("edit-slug"))&&function(){var t,e,s=0,i=d("#editable-post-name"),a=i.html(),n=d("#post_name"),o=n.val(),l=d("#edit-slug-buttons"),r=l.html(),p=d("#editable-post-name-full");for(p.find("img").replaceWith(function(){return this.alt}),p=p.html(),d("#view-post-btn").hide(),l.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+"</a>"),l.children(".save").click(function(){var s=i.children("input").val();return s==d("#editable-post-name-full").text()?l.children(".cancel").click():d.post(ajaxurl,{action:"sample-permalink",post_id:m,new_slug:s,new_title:d("#title").val(),samplepermalinknonce:d("#samplepermalinknonce").val()},function(t){var e=d("#edit-slug-box");e.html(t),e.hasClass("hidden")&&e.fadeIn("fast",function(){e.removeClass("hidden")}),l.html(r),n.val(s),d("#view-post-btn").show()}),!1}),l.children(".cancel").click(function(){return d("#view-post-btn").show(),i.html(a),l.html(r),n.val(o),!1}),t=0;t<p.length;++t)"%"==p.charAt(t)&&s++;e=s>p.length/4?"":p,i.html('<input type="text" id="new-post-slug" value="'+e+'" />').children("input").keypress(function(t){t=t.keyCode||0;return 13==t?(l.children(".save").click(),!1):27==t?(l.children(".cancel").click(),!1):void 0}).keyup(function(){n.val(this.value)}).focus()}()}),"undefined"!=typeof wpWordCount&&(v.triggerHandler("wpcountwords",[h.val()]),h.keyup(function(t){t=t.keyCode||t.charCode;return t==c||(13!=t&&8!=c&&46!=c||v.triggerHandler("wpcountwords",[h.val()]),c=t),!0})),(wptitlehint=function(t){var e=d("#"+(t=t||"title")),s=d("#"+t+"-prompt-text");""===e.val()&&s.removeClass("screen-reader-text"),s.click(function(){d(this).addClass("screen-reader-text"),e.focus()}),e.blur(function(){""===this.value&&s.removeClass("screen-reader-text")}).focus(function(){s.addClass("screen-reader-text")}).keydown(function(t){s.addClass("screen-reader-text"),d(this).unbind(t)})})(),l=d("textarea#content"),f=d("#post-status-info"),r=d("#postdivrich"),!l.length||"ontouchstart"in window?d("#content-resize-handle").hide():f.on("mousedown.wp-editor-resize",function(t){(a="undefined"!=typeof tinymce?tinymce.get("content"):a)&&!a.isHidden()?(o=!0,n=d("#content_ifr").height()-t.pageY):(o=!1,n=l.height()-t.pageY,l.blur()),v.on("mousemove.wp-editor-resize",y).on("mouseup.wp-editor-resize mouseleave.wp-editor-resize",x),t.preventDefault()}).on("mouseup.wp-editor-resize",x),"undefined"!=typeof tinymce&&d("#post-formats-select input.post-format").on("change.set-editor-class",function(){var t,e,s=this.id;s&&d(this).prop("checked")&&(t=tinymce.get("content"))&&((e=t.getBody()).className=e.className.replace(/\bpost-format-[^ ]+/,""),t.dom.addClass(e,"post-format-0"==s?"post-format-standard":s),d(document).trigger("editor-classchange"))})}); |