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

1 line
8.2 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{F.innerHTML=b,b=d(F.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(){var c=a("#pressthis-form"),d=a('<input type="hidden" name="post_category[]" value="">');B&&B.save(),a("#post_title").val(e(a("#title-container").text())),b.tagBox&&a("div.tagsdiv").each(function(){b.tagBox.flushTags(this,!1,1)}),a(".categories-select .category").each(function(b,e){var f=a(e);f.hasClass("selected")&&c.append(d.clone().val(f.attr("data-term-id")||""))})}function j(c){var d;E=!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&&H.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){var b,c,d="";B&&(b=f(a.attr("data-wp-src")||""),c=f(I.u),a.hasClass("is-image")?(c||(c=b),d='<a href="'+c+'"><img class="alignnone size-full" src="'+b+'" /></a>'):d="[embed]"+b+"[/embed]",K?B.execCommand("mceInsertContent",!1,d):B.setContent("<p>"+d+"</p>"+B.getContent()))}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>").append(a('<div class="category selected" tabindex="0" role="checkbox" aria-checked="true">').attr("data-term-id",f.term_id).text(f.name));f.parent?(d&&d.length||(c=e.find('div[data-term-id="'+f.parent+'"]').parent(),d=c.find("ul.children:first"),d.length||(d=a('<ul class="children">').appendTo(c))),d.prepend(g)):e.prepend(g),g.focus()}),A()}else o(b.data.errorMessage)}))}function m(){I.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(){I.errors&&a.each(I.errors,function(a,b){o(b)}),I.v&&H.version&&I.v+""!=H.version+""&&a(".should-upgrade-bookmarklet").removeClass("is-hidden")}function q(a,b,d){var e=D.clone().addClass("is-image");e.attr("data-wp-src",a).css("background-image","url("+b+")").find("span").text(c("suggestedImgAlt").replace("%d",d+1)),C.append(e)}function r(){var b=0;C=a("ul.media-list"),D=a('<li class="suggested-media-thumbnail" tabindex="0"><span class="screen-reader-text"></span></li>'),I._embeds&&a.each(I._embeds,function(a,d){var e="",g="",h=D.clone().addClass("is-embed");d=f(d),d.indexOf("youtube.com/")>-1?(e="https://i.ytimg.com/vi/"+d.replace(/.+v=([^&]+).*/,"$1")+"/hqdefault.jpg",g+=" is-video"):d.indexOf("youtu.be/")>-1?(e="https://i.ytimg.com/vi/"+d.replace(/\/([^\/])$/,"$1")+"/hqdefault.jpg",g+=" is-video"):d.indexOf("dailymotion.com")>-1?(e=d.replace("/video/","/thumbnail/video/"),g+=" is-video"):g+=d.indexOf("soundcloud.com")>-1?" is-audio":d.indexOf("twitter.com")>-1?" is-tweet":" is-video",h.attr("data-wp-src",d).find("span").text(c("suggestedEmbedAlt").replace("%d",a+1)),e&&h.css("background-image","url("+e+")"),C.append(h),b++}),I._images&&a.each(I._images,function(a,c){var d,e=new Image;c=f(c),d=c.replace(/^(http[^\?]+)(\?.*)?$/,"$1"),d=c.indexOf("files.wordpress.com/")>-1?d.replace(/\?.*$/,"")+"?w="+J:c.indexOf("gravatar.com/")>-1?d.replace(/\?.*$/,"")+"?s="+J:c,e.onload=function(){e.width&&e.width<256||e.he