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

1 line
12 KiB
JavaScript

!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][^>]*>/gi,"")}function e(a){return a=d(a),a.replace(/\\/,"").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function f(b){return b=a.trim(b||""),/^(?:https?:)?\/\//.test(b)?(b=d(b),b.replace(/["\\]+/g,"")):""}function g(a){if(!a||a.length)return"";var b="";return a._links&&a._links.canonical&&a._links.canonical.length&&(b=a._links.canonical),!b.length&&a.u&&(b=a.u),!b.length&&a._meta&&(a._meta["twitter:url"]&&a._meta["twitter:url"].length?b=a._meta["twitter:url"]:a._meta["og:url"]&&a._meta["og:url"].length&&(b=a._meta["og:url"])),decodeURI(b)}function h(a){if(!a||a.length)return"";var b="";return a._meta&&(a._meta["og:site_name"]&&a._meta["og:site_name"].length?b=a._meta["og:site_name"]:a._meta["application-name"]&&a._meta["application-name"].length&&(b=a._meta["application-name"])),b.replace(/\\/g,"")}function i(a){if(!a||a.length)return c("newPost");var b="";return a.t&&(b=a.t),!b.length&&a._meta&&(a._meta["twitter:title"]&&a._meta["twitter:title"].length?b=a._meta["twitter:title"]:a._meta["og:title"]&&a._meta["og:title"].length?b=a._meta["og:title"]:a._meta.title&&a._meta.title.length&&(b=a._meta.title)),b.length||(b=c("newPost"),P=!0),b.replace(/\\/g,"")}function j(a){if(!a||a.length)return"";var b="",d=i(a),f=g(a),j=h(a);return a.s&&a.s.length?b=a.s:a._meta&&(a._meta["twitter:description"]&&a._meta["twitter:description"].length?b=a._meta["twitter:description"]:a._meta["og:description"]&&a._meta["og:description"].length?b=a._meta["og:description"]:a._meta.description&&a._meta.description.length&&(b=a._meta.description)),b=b.length?'<blockquote class="press-this-suggested-content">'+e(b)+"</blockquote>":"",(d.length&&c("newPost")!==d||j.length)&&f.length&&(b+='<p class="press-this-suggested-source">',b+=c("source"),b+=" <cite>",b+=c("sourceLink").replace("%1$s",encodeURI(f)).replace("%2$s",e(d||j)),b+="</cite></p>"),b||(b=""),b.replace(/\\/g,"")}function k(a){return a?a.match(/\/\/(m\.|www\.)?youtube\.com\/watch\?/)||a.match(/\/youtu\.be\/.+$/)?!0:a.match(/\/\/vimeo\.com\/(.+\/)?[\d]+$/)?!0:a.match(/\/\/(www\.)?dailymotion\.com\/video\/.+$/)?!0:a.match(/\/\/soundcloud\.com\/.+$/)?!0:a.match(/\/\/twitter\.com\/[^\/]+\/status\/[\d]+$/)?!0:a.match(/\/\/vine\.co\/v\/[^\/]+/)?!0:!1:!1}function l(a){return a.match(/\/ad[sx]{1}?\//)?!0:a.match(/(\/share-?this[^\.]+?\.[a-z0-9]{3,4})(\?.*)?$/)?!0:a.match(/\/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)/)?!0:a.match(/\/([^\.\/]+[-_]{1})?(spinner|loading|spacer|blank)s?([-_]{1}[^\.\/]+)?\.[a-z0-9]{3,4}/)?!0:a.match(/([^\.\/]+[-_]{1})?thumb[^.]*\.(gif|jpg|png)$/)?!0:a.match(/\/wp-includes\//)?!0:a.match(/[^\d]{1}\d{1,2}x\d+\.(gif|jpg|png)$/)?!0:a.indexOf("/g.gif")>-1?!0:a.indexOf("/pixel.mathtag.com")>-1?!0:!1}function m(){var b=L._embed||[],c=[],d=[];return b.length&&a.each(b,function(b,e){if(e&&e.length&&k(e)){var f=e.replace(/^https?:/,"");a.inArray(f,d)>-1||(c.push(e),d.push(f))}}),c}function n(a){var b="";return a&&a._meta?(a._meta["twitter:image0:src"]&&a._meta["twitter:image0:src"].length?b=a._meta["twitter:image0:src"]:a._meta["twitter:image0"]&&a._meta["twitter:image0"].length?b=a._meta["twitter:image0"]:a._meta["twitter:image:src"]&&a._meta["twitter:image:src"].length?b=a._meta["twitter:image:src"]:a._meta["twitter:image"]&&a._meta["twitter:image"].length?b=a._meta["twitter:image"]:a._meta["og:image"]&&a._meta["og:image"].length?b=a._meta["og:image"]:a._meta["og:image:secure_url"]&&a._meta["og:image:secure_url"].length&&(b=a._meta["og:image:secure_url"]),b=f(b),l(b)?"":b):""}function o(b){var c=b._img||[],d=n(b)||"",e=[],g=[];return d.length&&(e.push(d),g.push(d.replace(/^https?:/,""))),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&&g.indexOf(c)>-1||l(b)||b.indexOf("avatar")>-1&&e.length>=15||(e.push(b),g.push(c))}}),e}function p(){a("#spinner").addClass("show"),a(".post-actions button").each(function(){a(this).attr("disabled","disabled")})}function q(){a("#spinner").removeClass("show"),a(".post-actions button").each(function(){a(this).removeAttr("disabled")})}function r(c){J=!1,p();var d=a("#pressthis-form");"publish"===c&&a("#post_status").val("publish"),I&&I.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&&K.redir_in_parent){try{b.opener.location.href=a.data.redirect}catch(c){}b.self.close()}else b.location.href=a.data.redirect}else x(a.data.errorMessage),q()}})}function s(a,b,c){var d="";I&&(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",S?I.execCommand("mceInsertContent",!1,d):I.setContent(d+I.getContent()),S=!0)}function t(b){b&&K&&K.post_formats&&K.post_formats[b]&&a("#post-option-post-format").text(K.post_formats[b])}function u(){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)}),H()}else x(b.data.errorMessage)}))}function v(){L.u&&L.u.match(/^https?:/)&&a("#scanbar").hide()}function w(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 x(a){w(a,!0)}function y(){L.errors&&L.errors.length&&a.each(L.errors,function(a,b){x(b)}),L.v&&L._version&&L.v+""!=L._version+""&&a(".should-upgrade-bookmarklet").removeClass("is-hidden")}function z(){var b=Q||"",c=a("#title-container");P||(a("#title-field").val(b),c.text(b),a(".post-title-placeholder").addClass("is-hidden")),c.on("keyup",function(){J=!0}).on("paste",function(){J=!0,setTimeout(function(){c.text(c.text())},100)})}function A(){R&&R.length&&(I||(I=b.tinymce.get("pressthis")),I&&(I.setContent(R),I.on("focus",function(){S=!0})))}function B(){var b=a("#featured-media-container"),d=a("#all-media-container"),e=0;return d.empty(),(O&&O.length||N&&N.length)&&d.append('<h2 class="screen-reader-text">'+c("allMediaHeading")+'</h2><ul class="wppt-all-media-list"/>'),O&&O.length&&a.each(O,function(b,g){if(g=f(g),k(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.length?"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)&&s("embed",g)}).appendTo(".wppt-all-media-list",d),e++}}),N&&N.length&&a.each(N,function(b,g){g=f(g);var h=g.replace(/^(http[^\?]+)(\?.*)?$/,"$1");h=g.indexOf("files.wordpress.com/")>-1?h.replace(/\?.*$/,"")+"?w="+M:g.indexOf("gravatar.com/")>-1?h.replace(/\?.*$/,"")+"?s="+M: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",function(a){("click"===a.type||13===a.which)&&s("img",g,L.u)}).appendTo(".wppt-all-media-list",d),e++}),e?void b.removeClass("no-media").addClass("all-media-visible"):void b.removeClass("all-media-visible").addClass("no-media")}function C(){var b="is-off-screen",c="is-hidden",d=a(".post-options"),e=a(".post-option"),f=a(".setting-modal"),g=a(".modal-close");e.on("click",function(e){var g=a(this).index(),h=f.eq(g);e.preventDefault(),d.addClass(b).one(U,function(){a(this).addClass(c)}),h.removeClass(b+" "+c).one(U,function(){a(this).find(".modal-close").focus()})}),g.on("click",function(f){var g=a(this).parent(),h=g.index();f.preventDefault(),d.removeClass(b+" "+c),g.addClass(b).one(U,function(){a(this).addClass(c),e.eq(h-1).focus()}),U||setTimeout(function(){g.addClass(c),e.eq(h-1).focus()},350)})}function D(){var b=a(".options-open"),c=a(".options-close"),d=a(".post-option"),e=a(".options-panel"),f=a(".press-this-actions"),g=a("#scanbar"),h="is-off-screen",i="is-hidden",j=h+" "+i;b.on("click",function(){b.addClass(i),c.removeClass(i),f.addClass(i),g.addClass(i),e.removeClass(j).one("transitionend",function(){d.eq(0).focus()})}),c.on("click",function(){c.addClass(i),b.removeClass(i),f.removeClass(i),g.removeClass(i),e.addClass(h).one("transitionend",function(){a(this).addClass(i),a(".post-options").removeClass(j),a(".setting-modal").addClass(j)})})}function E(){var b=a("#title-container"),c=a(".post-title-placeholder");b.on("focus",function(){c.addClass("is-hidden")}),b.on("blur",function(){var b=a(this).text().length;b||c.removeClass("is-hidden")})}function F(){v(),z(),B(),a(document).on("tinymce-editor-init",A),y()}function G(){return a("#current-site a").click(function(a){a.preventDefault()}),a("#draft-field").on("click",function(){r("draft")}),a("#publish-field").on("click",function(){r("publish")}),C(),D(),E(),a("#post-formats-select input").on("change",function(){var b=a(this);b.is(":checked")&&t(b.attr("id").replace(/^post-format-(.+)$/,"$1"))}),a("#tax-input-post_tag").on("change",function(){var b=a(this).val();a("#post-option-tags").text(b.length?b.replace(/,([^\s])/g,", $1"):"")}),a(b).on("beforeunload.press-this",function(){return J||I&&I.isDirty()?c("saveAlert"):void 0}),a("button.add-cat-toggle").on("click.press-this",function(){var b=a(this);b.toggleClass("is-toggled"),b.attr("aria-expanded",!b.attr("aria-expanded")),a(".setting-modal .add-category, .categories-search-wrapper").toggleClass("is-hidden")}),a("button.add-cat-submit").on("click.press-this",u),a(".categories-search").on("keyup.press-this",function(){var b=a(this).val().toLowerCase()||"";/[\x20-\xFF]+/.test(b)&&b.length<2||(a.each(T,function(a,b){b.node.removeClass("is-hidden searched-parent")}),b&&a.each(T,function(a,c){-1===c.text.indexOf(b)?c.node.addClass("is-hidden"):c.parents.addClass("searched-parent")}))}),!0}function H(){a(".categories-select").find("li").each(function(){var b=a(this);T.push({node:b,parents:b.parents("li"),text:b.children("label").text().toLowerCase()})})}var I,J=!1,K=b.wpPressThisConfig||{},L=b.wpPressThisData||{},M=128,N=o(L)||[],O=m(L)||[],P=!1,Q=i(L),R=j(L),S=!1,T=[],U=function(){var a=document.documentElement.style;return"undefined"!=typeof a.transition?"transitionend":"undefined"!=typeof a.WebkitTransition?"webkitTransitionEnd":!1}();return a(document).ready(function(){F(),G(),H()}),{renderNotice:w,renderError:x}};b.wp=b.wp||{},b.wp.pressThis=new c}(jQuery,window);