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