mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-10 06:38:42 +02:00
Part prop: Michael-Arestad. Fixes #31443. Built from https://develop.svn.wordpress.org/trunk@31765 git-svn-id: http://core.svn.wordpress.org/trunk@31745 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
8.4 KiB
JavaScript
1 line
8.4 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][\s\S]*?(>|$)/gi,"")}function e(a){var b=d(a);try{C.innerHTML=b,b=d(C.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="">');A&&A.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;B=!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&&E.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="";A&&(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",H||A.focus(),A.execCommand("mceInsertContent",!1,d),H=!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>").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()}),z()}else o(b.data.errorMessage)}))}function m(){F.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(){F.errors&&a.each(F.errors,function(a,b){o(b)}),F.v&&E.version&&F.v+""!=E.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(),(F._embeds||F._images)&&d.append('<h2 class="screen-reader-text">'+c("allMediaHeading")+'</h2><ul class="wppt-all-media-list" />'),F._embeds&&a.each(F._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++}),F._images&&a.each(F._images,function(b,g){g=f(g);var h=g.replace(/^(http[^\?]+)(\?.*)?$/,"$1");h=g.indexOf("files.wordpress.com/")>-1?h.replace(/\?.*$/,"")+"?w="+G:g.indexOf("gravatar.com/")>-1?h.replace(/\?.*$/,"")+"?s="+G: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)&&k("img",g,F.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 r(){var b=a(".post-options"),c=a(".post-option"),d=a(".setting-modal"),e=a(".modal-close");c.on("click",function(){var c=a(this).index(),e=d.eq(c);b.addClass(J).one(M,function(){a(this).addClass(K)}),e.removeClass(L).one(M,function(){a(this).find(".modal-close").focus()})}),e.on("click",function(){var d=a(this).parent(),e=d.index();b.removeClass(L),d.addClass(J),M?d.one(M,function(){a(this).addClass(K),c.eq(e-1).focus()}):setTimeout(function(){d.addClass(K),c.eq(e-1).focus()},350)})}function s(){D=!0,a(".options-open, .press-this-actions, #scanbar").addClass(K),a(".options-close, .options-panel-back").removeClass(K),a(".options-panel").removeClass(L).one("transitionend",function(){a(".post-option:first").focus()})}function t(){D=!1,a(".options-close, .options-panel-back").addClass(K),a(".options-open, .press-this-actions, #scanbar").removeClass(K),a(".options-panel").addClass(J).one("transitionend",function(){a(this).addClass(K),a(".post-options").removeClass(L),a(".setting-modal").addClass(L)})}function u(){var b=a("#title-container"),c=a(".post-title-placeholder");b.on("focus",function(){c.addClass("is-hidden")}).on("blur",function(){b.text()||c.removeClass("is-hidden")}),b.text()&&c.addClass("is-hidden")}function v(a){a.hasClass("selected")?a.removeClass("selected").attr("aria-checked","false"):a.addClass("selected").attr("aria-checked","true")}function w(){a(".categories-select").on("click.press-this keydown.press-this",function(b){var c=a(b.target);if(c.is("div.category")){if("keydown"===b.type&&32!==b.keyCode)return;v(c),b.preventDefault()}})}function x(){m(),q(),p(),b.tagBox&&b.tagBox.init()}function y(){return a(document).on("tinymce-editor-init",function(a,b){A=b,b.on("focus",function(){H=!0})}),a("#current-site a").click(function(a){a.preventDefault()}),a(".post-actions").on("click.press-this",function(c){var d=a(c.target);d.hasClass("draft-button")?j("draft"):d.hasClass("publish-button")?j("publish"):d.hasClass("preview-button")&&(i(),b.opener&&b.opener.focus(),a("#wp-preview").val("dopreview"),a("#pressthis-form").attr("target","_blank").submit().attr("target",""),a("#wp-preview").val(""))}),r(),u(),w(),a(".options-open").on("click.press-this",s),a(".options-close").on("click.press-this",t),a(".options-panel, .options-panel-back").on("focusout.press-this",function(){setTimeout(function(){var b=document.activeElement,c=a(b);!D||!b||c.hasClass("options-panel-back")||"BODY"!==b.nodeName&&(c.closest(".options-panel").length||c.closest(".options-open").length)||t()},50)}),a("#post-formats-select input").on("change",function(){var b=a(this);b.is(":checked")&&a("#post-option-post-format").text(a('label[for="'+b.attr("id")+'"]').text()||"")}),a(b).on("beforeunload.press-this",function(){return B||A&&A.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","false"===b.attr("aria-expanded")?"true":"false"),a(".setting-modal .add-category, .categories-search-wrapper").toggleClass("is-hidden")}),a("button.add-cat-submit").on("click.press-this",l),a(".categories-search").on("keyup.press-this",function(){var b=a(this).val().toLowerCase()||"";/[\x20-\xFF]+/.test(b)&&b.length<2||(a.each(I,function(a,b){b.node.removeClass("is-hidden searched-parent")}),b&&a.each(I,function(a,c){-1===c.text.indexOf(b)?c.node.addClass("is-hidden"):c.parents.addClass("searched-parent")}))}),!0}function z(){a(".categories-select").find("li").each(function(){var b=a(this);I.push({node:b,parents:b.parents("li"),text:b.children(".category").text().toLowerCase()})})}var A,B=!1,C=document.createElement("textarea"),D=!1,E=b.wpPressThisConfig||{},F=b.wpPressThisData||{},G=128,H=!1,I=[],J="is-off-screen",K="is-hidden",L=J+" "+K,M=function(){var a=document.documentElement.style;return"undefined"!=typeof a.transition?"transitionend":"undefined"!=typeof a.WebkitTransition?"webkitTransitionEnd":!1}();return a(document).ready(function(){x(),y(),z()}),{renderNotice:n,renderError:o}};b.wp=b.wp||{},b.wp.pressThis=new c}(jQuery,window); |