Вход Регистрация
Файл: wordpress/wp-admin/js/press-this.min.js
Строк: 435
<?php
!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(/<!--[sS]*?(-->|$)/g,"").replace(/<(script|style)[^>]*>[sS]*?(</1>|$)/gi,"").replace(/</?[a-z][sS]*?(>|$)/gi,"")}function e(a){var b=d(a);try{J.innerHTML=b,b=d(J.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("is-active"),a(".post-actions button").attr("disabled","disabled")}function h(){a(".spinner").removeClass("is-active"),a(".post-actions button").removeAttr("disabled")}function i(){var b=a("#title-container");return b.find("img.emoji").each(function(){var b=a(this);b.replaceWith(a("<span>").text(b.attr("alt")))}),e(b.text())}function j(){var c=a("#pressthis-form"),d=a('<input type="hidden" name="post_category[]" value="">');E&&E.save(),a("#post_title").val(i()),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 k(d){var e,f=a(document.activeElement).hasClass("draft-button");H=!1,g(),"publish"===d&&a("#post_status").val("publish"),j(),e=a("#pressthis-form").serialize(),a.ajax({type:"post",url:b.ajaxurl,data:e}).always(function(){h(),r()}).done(function(c){var d,e;if(c.success)if(c.data.redirect)if(b.opener&&L.redirInParent){try{b.opener.location.href=c.data.redirect}catch(g){}b.self.close()}else b.location.href=c.data.redirect;else c.data.postSaved&&(d=a(".edit-post-link"),e=a(".draft-button"),I=!0,e.fadeOut(200,function(){e.removeClass("is-saving"),d.fadeIn(200,function(){var b=document.activeElement;f&&(b===e[0]||a(b).hasClass("post-actions")||"BODY"===b.nodeName)&&d.focus()})}));else q(c.data.errorMessage)}).fail(function(){q(c("serverError"))})}function l(){I&&(I=!1,a(".edit-post-link").fadeOut(200,function(){a(".draft-button").removeClass("is-saving").fadeIn(200)}))}function m(a){var b,c,d="";E&&(b=f(a.attr("data-wp-src")||""),c=f(M.u),a.hasClass("is-image")?(c||(c=b),d='<a href="'+c+'"><img class="alignnone size-full" src="'+b+'" /></a>'):d="[embed]"+b+"[/embed]",O?E.execCommand("mceInsertContent",!1,d):E.setContent("<p>"+d+"</p>"+E.getContent()))}function n(){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()}),D()}else q(b.data.errorMessage)}))}function o(){M.hasData&&a("#scanbar").hide()}function p(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 q(a){p(a,!0)}function r(){a("div.alerts").empty()}function s(){M.errors&&a.each(M.errors,function(a,b){q(b)})}function t(a,b,d){var e=G.clone().addClass("is-image");e.attr("data-wp-src",a).css("background-image","url("+b+")").find("span").text(c("suggestedImgAlt").replace("%d",d+1)),F.append(e)}function u(){var b=0;F=a("ul.media-list"),G=a('<li class="suggested-media-thumbnail" tabindex="0"><span class="screen-reader-text"></span></li>'),M._embeds&&a.each(M._embeds,function(a,d){var e="",g="",h=G.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+")"),F.append(h),b++}),M._images&&a.each(M._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="+N:c.indexOf("gravatar.com/")>-1?d.replace(/?.*$/,"")+"?s="+N:c,e.onload=function(){e.width&&e.width<256||e.height&&e.height<128||t(c,d,a)},e.src=c,b++}),b&&a(".media-list-container").addClass("has-media")}function v(){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(Q).one(T,function(){a(this).addClass(R)}),e.removeClass(S).one(T,function(){a(this).find(".modal-close").focus()})}),e.on("click",function(){var d=a(this).parent(),e=d.index();b.removeClass(S),d.addClass(Q),T?d.one(T,function(){a(this).addClass(R),c.eq(e-1).focus()}):setTimeout(function(){d.addClass(R),c.eq(e-1).focus()},350)})}function w(){K=!0,a(".options").removeClass("closed").addClass("open"),a(".press-this-actions, #scanbar").addClass(R),a(".options-panel-back").removeClass(R),a(".options-panel").removeClass(S).one(T,function(){a(".post-option:first").focus()})}function x(){K=!1,a(".options").removeClass("open").addClass("closed"),a(".options-panel-back").addClass(R),a(".press-this-actions, #scanbar").removeClass(R),a(".options-panel").addClass(Q).one(T,function(){a(this).addClass(R),a(".post-options").removeClass(S),a(".setting-modal").addClass(S)})}function y(){var c=a("#title-container"),d=a(".post-title-placeholder");c.on("focus",function(){d.addClass("is-hidden"),l()}).on("blur",function(){c.text()||c.html()||d.removeClass("is-hidden")}).on("keyup",function(){H=!0}).on("paste",function(d){var e,f,g=d.originalEvent.clipboardData||b.clipboardData;if(g){try{e=g.getData("Text")||g.getData("text/plain"),e&&(e=a.trim(e.replace(/s+/g," ")),b.getSelection?(f=b.getSelection().getRangeAt(0),f&&(f.collapsed||f.deleteContents(),f.insertNode(document.createTextNode(e)))):document.selection&&(f=document.selection.createRange(),f&&(f.text=e)))}catch(h){}d.preventDefault()}H=!0,setTimeout(function(){c.text(i())},50)}),(c.text()||c.html())&&d.addClass("is-hidden")}function z(a){a.hasClass("selected")?a.removeClass("selected").attr("aria-checked","false"):a.addClass("selected").attr("aria-checked","true")}function A(){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;z(c),b.preventDefault()}})}function B(){o(),u(),s(),b.tagBox&&b.tagBox.init()}function C(){return a(document).on("tinymce-editor-init",function(a,b){E=b,E.on("nodechange",function(){O=!0,l()})}).on("click.press-this keypress.press-this",".suggested-media-thumbnail",function(b){("click"===b.type||13===b.keyCode)&&m(a(this))}),a(".post-actions").on("click.press-this",function(c){var d=a(c.target),e=d.closest("button");e.length?e.hasClass("draft-button")?(e.addClass("is-saving"),k("draft")):e.hasClass("publish-button")?k("publish"):e.hasClass("preview-button")&&(j(),b.opener&&b.opener.focus(),a("#wp-preview").val("dopreview"),a("#pressthis-form").attr("target","_blank").submit().attr("target",""),a("#wp-preview").val("")):d.hasClass("edit-post-link")&&b.opener&&(b.opener.focus(),b.self.close())}),v(),y(),A(),a(".options").on("click.press-this",function(){a(this).hasClass("open")?x():w()}),a(".options-panel, .options-panel-back").on("focusout.press-this",function(){setTimeout(function(){var b=document.activeElement,c=a(b);!K||!b||c.hasClass("options-panel-back")||"BODY"!==b.nodeName&&(c.closest(".options-panel").length||c.closest(".options").length)||x()},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 H||E&&E.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",n),a(".categories-search").on("keyup.press-this",function(){var b=a(this).val().toLowerCase()||"";/[x20-xFF]+/.test(b)&&b.length<2||(a.each(P,function(a,b){b.node.removeClass("is-hidden searched-parent")}),b&&a.each(P,function(a,c){-1===c.text.indexOf(b)?c.node.addClass("is-hidden"):c.parents.addClass("searched-parent")}))}),!0}function D(){a(".categories-select").find("li").each(function(){var b=a(this);P.push({node:b,parents:b.parents("li"),text:b.children(".category").text().toLowerCase()})})}var E,F,G,H=!1,I=!1,J=document.createElement("textarea"),K=!1,L=b.wpPressThisConfig||{},M=b.wpPressThisData||{},N=128,O=!1,P=[],Q="is-off-screen",R="is-hidden",S=Q+" "+R,T=function(){var a=document.documentElement.style;return"undefined"!=typeof a.transition?"transitionend":"undefined"!=typeof a.WebkitTransition?"webkitTransitionEnd":!1}();return a(document).ready(function(){B(),C(),D()}),{renderNotice:p,renderError:q}};b.wp=b.wp||{},b.wp.pressThis=new c}(jQuery,window);
?>
Онлайн: 0
Реклама