Wordpress/wp-admin/js/post-formats.min.js

1 line
5.3 KiB
JavaScript
Raw Normal View History

window.wp=window.wp||{};(function(c){var x,n,k,t,q,j,v,m=/\s?\bwp-format-[^ ]+/g,g=120,s=360,u="standard",b="short-format",e=["status"],i=["status","aside","image","audio","video"],f=["status","aside"],d=["standard","chat","status","aside","gallery"];function w(B,z){var A=c("#"+B.settings.drop_element+" .media-progress-bar div");A.width(z.percent+"%")}function a(z){c("#"+z.settings.drop_element+" .wp-format-media-select").append('<div class="media-progress-bar"><div></div></div>')}function r(){c(".media-progress-bar",c(".wp-format-media-holder[data-format=image]")).remove()}function l(C){var B,A,z=wp.media.string.image({size:"full",align:false,link:getUserSetting("urlbutton")},C.attributes);B=c(".wp-format-media-holder[data-format=image]");c(".media-progress-bar",B).remove();if("image"!==C.attributes.type){return}A=c("#wp_format_"+B.data("format"));A.val(z);c("#image-preview").remove();B.parent().prepend(['<div id="image-preview" class="wp-format-media-preview">','<img src="',C.get("url"),'"',C.get("width")?' width="'+C.get("width")+'"':"",C.get("height")?' height="'+C.get("height")+'"':""," />","</div>"].join(""))}var p={dropzone:c(".wp-format-media-holder[data-format=image]"),success:l,error:r,plupload:{},params:{}};p=new wp.Uploader(p);p.uploader.bind("BeforeUpload",a);p.uploader.bind("UploadProgress",w);function y(z){q.val(z);c.each([k,t,j],function(B,A){A.prop("className",A.prop("className").replace(m,"")).addClass("wp-format-"+z)})}function h(C,A){var z,B=c("#content, #content_ifr");z=B.outerHeight();if(g<z){s=z}if(-1<c.inArray(C,f)){if(!B.hasClass(b)){B.addClass(b);_(B).each(function(D){c(D)[A?"css":"animate"]({height:g})})}}else{B.removeClass(b).animate({height:s})}}function o(z){var F,D,A,C,H=z.data("wp-format"),G=c("#title-prompt-text"),I=c(".post-format-description"),J=c("#title"),B=c(".post-formats-fields"),E=c(".post-format-change span.icon");if(H===postFormats.currentPostFormat){return}z.addClass("active").siblings().removeClass("active");A=-1<c.inArray(H,i);C=-1<c.inArray(postFormats.currentPostFormat,i);if(C?!A:A){n.fadeToggle(200).css("display","inline-block")}A=-1<c.inArray(H,e);C=-1<c.inArray(postFormats.currentPostFormat,e);if(C?!A:A){c("#titlewrap").fadeToggle(200)}A=-1<c.inArray(H,d);C=-1<c.inArray(postFormats.currentPostFormat,d);if(A&&C){y(H);B.hide()}else{if(C){B.hide();y(H);B.slideDown(400)}else{if(A){B.slideUp(200,function(){y(H)})}else{B.slideUp(200,function(){y(H);B.slideDown(400)})}}}h(H);J.focus();if(""===J.val()){G.removeClass("screen-reader-text");J.keydown(function(K){G.addClass("screen-reader-text");c(K.currentTarget).unbind(K)})}I.html(z.data("description"));E.show().prop("className",E.prop("className").replace(m,"")).addClass("wp-format-"+H);if(I.not(":visible")){I.slideDown("fast")}if(typeof tinymce!=="undefined"){F=tinymce.get("content");if(F){D=F.getBody();D.className=D.className.replace(/\bpost-format-[^ ]+/,"");F.dom.addClass(D,"post-format-"+H)}}n.toggleClass("gallery","gallery"===H);postFormats.currentPostFormat=H}c(function(){j=c("body");k=c("#post-body-content");t=c(".icon32");q=c("#post_format");n=c("#insert-media-button").toggleClass("gallery","gallery"===postFormats.currentPostFormat);u=c(".post-format-options .active").data("wp-format");if(-1<c.inArray(u,f)){h(u,true)}c("#show_post_format_ui").on("change",function(){c(".wp-post-format-ui").toggleClass("no-ui",!this.checked);c.post(ajaxurl,{action:"show-post-format-ui",post_type:c("#post_type").val(),show:this.checked?1:0,nonce:c("#show_post_format_ui_nonce").val()})});c(".post-format-options").on("click","a",function(z){z.preventDefault();o(c(z.currentTarget))});c(".use-url-or-html").on("click","a",function(z){z.preventDefault();c(".wp-format-media-holder, .wp-format-image-textarea").toggle();c(this).closest("p").find("span").toggle()});c(".wp-format-media-select").click(function(E){E.preventDefault();var z=c(E.currentTarget),B,D="image",C,A;C=z.closest(".wp-format-media-holder");A=c("#wp_format_"+C.data("format"));D=C.data("format");if(x&&v===D){x.open();return}v=D;x=wp.media.frames.formatMedia=wp.media({button:{text:z.