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

1 line
9.6 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){return a=d(a),G.innerHTML=a,d(G.value)}function f(b){return b=a.trim(b||""),/^(?:https?:)?\/\//.test(b)?(b=d(b),b.replace(/["\\]+/g,"")):""}function g(){var a="";return I._links&&I._links.canonical&&I._links.canonical.length&&(a=I._links.canonical),!a.length&&I.u&&(a=I.u),!a.length&&I._meta&&(I._meta["twitter:url"]&&I._meta["twitter:url"].length?a=I._meta["twitter:url"]:I._meta["og:url"]&&I._meta["og:url"].length&&(a=I._meta["og:url"])),f(decodeURI(a))}function h(){var a="";return I._meta&&(I._meta["og:site_name"]&&I._meta["og:site_name"].length?a=I._meta["og:site_name"]:I._meta["application-name"]&&I._meta["application-name"].length&&(a=I._meta["application-name"])),e(a)}function i(){var a="";return I.t&&(a=I.t),!a&&I._meta&&(I._meta["twitter:title"]&&I._meta["twitter:title"].length?a=I._meta["twitter:title"]:I._meta["og:title"]&&I._meta["og:title"].length?a=I._meta["og:title"]:I._meta.title&&I._meta.title.length&&(a=I._meta.title)),a||(a=c("newPost"),M=!0),e(a)}function j(){var a="",b="",d=i(),f=g(),j=h();return I.s&&I.s.length?b=I.s:I._meta&&(I._meta["twitter:description"]&&I._meta["twitter:description"].length?b=I._meta["twitter:description"]:I._meta["og:description"]&&I._meta["og:description"].length?b=I._meta["og:description"]:I._meta.description&&I._meta.description.length&&(b=I._meta.description)),b&&H.html.quote&&(a=H.html.quote.replace(/%1\$s/g,e(b))),f&&H.html.link&&(d&&c("newPost")!==d||j)&&(a+=H.html.link.replace(/%1\$s/g,encodeURI(f)).replace(/%2\$s/g,d||j)),a||""}function k(){var b=I._embed||[],c=[],d=[];return b.length&&a.each(b,function(b,e){if(e&&e.length){var f=e.replace(/^https?:/,"");a.inArray(f,d)>-1||(c.push(e),d.push(f))}}),c}function l(b){var c=b._img||[],d=[],e=[];return c.length&&a.each(c,function(a,b){if(b=b.replace(/http:\/\/[\d]+\.gravatar\.com\//,"https://secure.gravatar.com/"),b=f(b),b&&b.length){var c=b.replace(/^https?:/,"");Array.prototype.indexOf&&e.indexOf(c)>-1||b.indexOf("avatar")>-1&&d.length>=15||(d.push(b),e.push(c))}}),d}function m(){a("#spinner").addClass("show"),a(".post-actions button").each(function(){a(this).attr("disabled","disabled")})}function n(){a("#spinner").removeClass("show"),a(".post-actions button").each(function(){a(this).removeAttr("disabled")})}function o(c){F=!1,m();var d=a("#pressthis-form");"publish"===c&&a("#post_status").val("publish"),E&&E.save(),a("#title-field").val(e(a("#title-container").text())),b.tagBox&&a("div.tagsdiv").each(function(){b.tagBox.flushTags(this,!1,1)});var f=d.serialize();a.ajax({type:"post",url:b.ajaxurl,data:f,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 t(a.data.errorMessage),n()}})}function p(a,b,c){var d="";E&&(b=f(b),c=f(c),"img"===a?(c&&c.length||(c=b),d='<a href="'+c+'"><img class="alignnone size-full" src="'+b+'" /></a>\n'):d="[embed]"+b+"[/embed]\n",P||E.focus(),E.execCommand("mceInsertContent",!1,d),P=!0)}function q(){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)}),D()}else t(b.data.errorMessage)}))}function r(){I.u&&I.u.match(/^https?:/)&&a("#scanbar").hide()}function s(b,c){var d=a(".edi