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

1 line
11 KiB
JavaScript
Raw Normal View History

!function(F,K){K.wp=K.wp||{},K.wp.pressThis=new function(){var r,l,d,e,c=F(K),p=F(document),u=!1,s=document.createElement("textarea"),h=!1,a=K.wpPressThisConfig||{},f=K.wpPressThisData||{},t=128,g=!1,m=[],v="is-off-screen",C="is-hidden",b=v+" "+C,n=/iPad|iPod|iPhone/.test(K.navigator.userAgent),x=F("#pressthis"),i=x[0],o=600,y=0,w=void 0!==(e=document.documentElement.style).transition?"transitionend":void 0!==e.WebkitTransition&&"webkitTransitionEnd";function k(e){return e&&K.pressThisL10n?K.pressThisL10n[e]||e:e||""}function T(e){return(e=e||"").replace(/<!--[\s\S]*?(-->|$)/g,"").replace(/<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/gi,"").replace(/<\/?[a-z][\s\S]*?(>|$)/gi,"")}function E(e){return e=F.trim(e||""),/^(?:https?:)?\/\//.test(e)?(e=T(e)).replace(/["\\]+/g,""):""}function O(e){r&&!r.isHidden()||(e="reset"===e||y&&y>i.value.length,i.style.height,e?(e=K.pageYOffset,i.style.height="auto",i.style.height=Math.max(i.scrollHeight,o)+"px",K.scrollTo(K.pageXOffset,e)):parseInt(i.style.height,10)<i.scrollHeight&&(i.style.height=i.scrollHeight+"px"),y=i.value.length)}function _(e){var t=K.tinymce.util.VK,e=e.keyCode;e<=47&&e!==t.SPACEBAR&&e!==t.ENTER&&e!==t.DELETE&&e!==t.BACKSPACE&&e!==t.UP&&e!==t.LEFT&&e!==t.DOWN&&e!==t.UP||91<=e&&e<=93||112<=e&&e<=123||144===e||145===e||A(e)}function A(e){var t,s,a,n=function(){if(!r)return!1;var e,t,s,a=r.selection.getNode();if(r.wp&&r.wp.getView&&(t=r.wp.getView(a)))s=t.getBoundingClientRect();else{e=r.selection.getRng();try{s=e.getClientRects()[0]}catch(e){}s=s||a.getBoundingClientRect()}return!!s.height&&s}(),i=K.tinymce.util.VK;n&&(s=(t=n.top+r.iframeElement.getBoundingClientRect().top)+n.height,t-=50,s+=65,(a=c.height())<n.height||(t<0&&(e===i.UP||e===i.LEFT||e===i.BACKSPACE)?K.scrollTo(K.pageXOffset,t+K.pageYOffset):a<s&&K.scrollTo(K.pageXOffset,s+K.pageYOffset-a)))}function D(){var e=F("#title-container");return e.find("img.emoji").each(function(){var e=F(this);e.replaceWith(F("<span>").text(e.attr("alt")))}),function(e){var t=T(e);try{s.innerHTML=t,t=T(s.value)}catch(e){}return t}(e.text())}function P(){var s=F("#pressthis-form"),a=F('<input type="hidden" name="post_category[]" value="">');r&&r.save(),F("#post_title").val(D()),K.tagBox&&F("div.tagsdiv").each(function(){K.tagBox.flushTags(this,!1,1)}),F(".categories-select .category").each(function(e,t){t=F(t);t.hasClass("selected")&&s.append(a.clone().val(t.attr("data-term-id")||""))})}function B(e){u=!1,F(".spinner").addClass("is-active"),F(".post-actions button").attr("disabled","disabled"),"publish"===e&&F("#post_status").val("publish"),P(),e=F("#pressthis-form").serialize(),F.ajax({type:"post",url:K.ajaxurl,data:e}).always(function(){F(".spinner").removeClass("is-active"),F(".post-actions button").removeAttr("disabled"),F("div.alerts").empty(),F(".publish-button").removeClass("is-saving")}).done(function(t){if(t.success){if(t.data.redirect)if(K.opener&&(a.redirInParent||t.data.force))try{K.opener.location.href=t.data.redirect,K.setTimeout(function(){K.self.close()},200)}catch(e){K.location.href=t.data.redirect}else K.location.href=t.data.redirect}else $(t.data.errorMessage)}).fail(function(){$(k("serverError"))})}function R(){var e=F("#new-category").val();e&&(e={action:"press-this-add-category",post_id:F("#post_ID").val()||0,name:e,new_cat_nonce:F("#_ajax_nonce-add-category").val()||"",parent:F("#new-category-parent").val()||0},F.post(K.ajaxurl,e,function(e){var a,n,i;e.success?(i=F("ul.categories-select"),F.each(e.data,function(e,t){var s=F("<li>").append(F('<div class="category selected" tabindex="0" role="checkbox" aria-checked="true">').attr("data-term-id",t.term_id).text(t.name));t.parent?(n&&n.length||(a=i.find('div[data-term-id="'+t.parent+'"]').parent(),(n=a.find("ul.children:first")).length||(n=F('<ul class="children">').appendTo(a))),n.prepend(s)):i.prepend(s),s.focus()}),z()):$(e.data.errorMessage)}))}function S(e,t){t=t?"is-error":"is-notice";F(".editor-wrapper div.alerts").append(F('<p class="alert '+t+'">').text(e))}function $(e){S(e,!0)}function j(){var c=0;l=F("ul.media-list"),d=F('<li class="suggested-media