WordPress/wp-admin/js/press-this.min.js

1 line
7.9 KiB
JavaScript
Raw Normal View History

!function(a,b){var c=function(){function c(a){return a&&b.pressThisL10n?b.pressThisL10n[a]||a:a||""}function d(a){return a=a||"",a.replace(/<!--[\s\S]*?(-->|$)/g,"").replace(/<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/gi,"").replace(/<\/?[a-z][\s\S]*?(>|$)/gi,"")}function e(a){var b=d(a);try{A.innerHTML=b,b=d(A.value)}catch(c){}return b}function f(b){return b=a.trim(b||""),/^(?:https?:)?\/\//.test(b)?(b=d(b),b.replace(/["\\]+/g,"")):""}function g(){a("#spinner").addClass("show"),a(".post-actions button").each(function(){a(this).attr("disabled","disabled")})}function h(){a("#spinner").removeClass("show"),a(".post-actions button").each(function(){a(this).removeAttr("disabled")})}function i(){y&&y.save(),a("#post_title").val(e(a("#title-container").text())),b.tagBox&&a("div.tagsdiv").each(function(){b.tagBox.flushTags(this,!1,1)})}function j(c){var d;z=!1,g(),"publish"===c&&a("#post_status").val("publish"),i(),d=a("#pressthis-form").serialize(),a.ajax({type:"post",url:b.ajaxurl,data:d,success:function(a){if(a.success){if(a.data.redirect)if(b.opener&&C.redirInParent){try{b.opener.location.href=a.data.redirect}catch(c){}b.self.close()}else b.location.href=a.data.redirect}else o(a.data.errorMessage),h()}})}function k(a,b,c){var d="";y&&(b=f(b),c=f(c),"img"===a?(c||(c=b),d='<a href="'+c+'"><img class="alignnone size-full" src="'+b+'" /></a>\n'):d="[embed]"+b+"[/embed]\n",F||y.focus(),y.execCommand("mceInsertContent",!1,d),F=!0)}function l(){var c,d=a("#new-category").val();d&&(c={action:"press-this-add-category",post_id:a("#post_ID").val()||0,name:d,new_cat_nonce:a("#_ajax_nonce-add-category").val()||"",parent:a("#new-category-parent").val()||0},a.post(b.ajaxurl,c,function(b){if(b.success){var c,d,e=a("ul.categories-select");a.each(b.data,function(b,f){var g=a("<li>").attr("id","category-"+f.term_id).append(a('<label class="selectit">').text(f.name).append(a('<input type="checkbox" name="post_category[]" checked>').attr("value",f.term_id)));f.parent?(d&&d.length||(c=e.find("#category-"+f.parent),d=c.find("ul.children:first"),d.length||(d=a('<ul class="children">').appendTo(c))),d.append(g)):e.prepend(g)}),x()}else o(b.data.errorMessage)}))}function m(){D.hasData&&a("#scanbar").hide()}function n(b,c){var d=a(".editor-wrapper div.alerts"),e=c?"is-error":"is-notice";d.append(a('<p class="alert '+e+'">').text(b))}function o(a){n(a,!0)}function p(){D.errors&&a.each(D.errors,function(a,b){o(b)}),D.v&&C.version&&D.v+""!=C.version+""&&a(".should-upgrade-bookmarklet").removeClass("is-hidden")}function q(){var b=a("#featured-media-container"),d=a("#all-media-container"),e=0;return d.empty(),(D._embeds||D._images)&&d.append('<h2 class="screen-reader-text">'+c("allMediaHeading")+'</h2><ul class="wppt-all-media-list" />'),D._embeds&&a.each(D._embeds,function(b,g){g=f(g);var h="",i="suggested-media-thumbnail suggested-media-embed";g.indexOf("youtube.com/")>-1?(h="https://i.ytimg.com/vi/"+g.replace(/.+v=([^&]+).*/,"$1")+"/hqdefault.jpg",i+=" is-video"):g.indexOf("youtu.be/")>-1?(h="https://i.ytimg.com/vi/"+g.replace(/\/([^\/])$/,"$1")+"/hqdefault.jpg",i+=" is-video"):g.indexOf("dailymotion.com")>-1?(h=g.replace("/video/","/thumbnail/video/"),i+=" is-video"):i+=g.indexOf("soundcloud.com")>-1?" is-audio":g.indexOf("twitter.com")>-1?" is-tweet":" is-video",a("<li></li>",{id:"embed-"+b+"-container","class":i,tabindex:"0"}).css({"background-image":h?"url("+h+")":null}).html('<span class="screen-reader-text">'+c("suggestedEmbedAlt").replace("%d",b+1)+"</span>").on("click keypress",function(a){("click"===a.type||13===a.which)&&k("embed",g)}).appendTo(".wppt-all-media-list",d),e++}),D._images&&a.each(D._images,function(b,g){g=f(g);var h=g.replace(/^(http[^\?]+)(\?.*)?$/,"$1");h=g.indexOf("files.wordpress.com/")>-1?h.replace(/\?.*$/,"")+"?w="+E:g.indexOf("gravatar.com/")>-1?h.replace(/\?.*$/,"")+"?s="+E:g,a("<li></li>",{id:"img-"+b+"-container","class":"suggested-media-thumbnail is-image",tabindex:"0"}).css({"background-image":"url("+h+")"}).html('<span class="screen-reader-text">'+c("suggestedImgAlt").replace("%d",b+1)+"</span>").on("click keypress",fu