WordPress/wp-includes/js/plupload/handlers.min.js

1 line
10 KiB
JavaScript
Raw Permalink Normal View History

var uploader,uploader_init,topWin=window.dialogArguments||opener||parent||top;function fileQueued(e){jQuery(".media-blank").remove();var r=jQuery("#media-items").children(),a=post_id||0;1==r.length&&r.removeClass("open").find(".slidetoggle").slideUp(200),jQuery('<div class="media-item">').attr("id","media-item-"+e.id).addClass("child-of-"+a).append('<div class="progress"><div class="percent">0%</div><div class="bar"></div></div>',jQuery('<div class="filename original">').text(" "+e.name)).appendTo(jQuery("#media-items")),jQuery("#insert-gallery").prop("disabled",!0)}function uploadStart(){try{void 0!==topWin.tb_remove&&topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}catch(e){}return!0}function uploadProgress(e,r){var a=jQuery("#media-item-"+r.id);jQuery(".bar",a).width(200*r.loaded/r.size),jQuery(".percent",a).html(r.percent+"%")}function fileUploading(e,r){var a=104857600;a<parseInt(e.settings.max_file_size,10)&&r.size>a&&setTimeout(function(){r.status<3&&0===r.loaded&&(wpFileError(r,pluploadL10n.big_upload_failed.replace("%1$s",'<a class="uploader-html" href="#">').replace("%2$s","</a>")),e.stop(),e.removeFile(r),e.start())},1e4)}function updateMediaForm(){var e=jQuery("#media-items").children();1==e.length?(e.addClass("open").find(".slidetoggle").show(),jQuery(".insert-gallery").hide()):1<e.length&&(e.removeClass("open"),jQuery(".insert-gallery").show()),0<e.not(".media-blank").length?jQuery(".savebutton").show():jQuery(".savebutton").hide()}function uploadSuccess(e,r){var a=jQuery("#media-item-"+e.id);(r=r.replace(/^<pre>(\d+)<\/pre>$/,"$1")).match(/media-upload-error|error-div/)?a.html(r):(jQuery(".percent",a).html(pluploadL10n.crunching),prepareMediaItem(e,r),updateMediaForm(),post_id&&a.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(+jQuery("#attachments-count").text()+1))}function setResize(e){e?window.resize_width&&window.resize_height?uploader.settings.resize={enabled:!0,width:window.resize_width,height:window.resize_height,quality:100}:uploader.settings.multipart_params.image_resize=!0:delete uploader.settings.multipart_params.image_resize}function prepareMediaItem(e,r){var a="undefined"==typeof shortform?1:2,i=jQuery("#media-item-"+e.id);2==a&&2<shortform&&(a=shortform);try{void 0!==topWin.tb_remove&&topWin.jQuery("#TB_overlay").click(topWin.tb_remove)}catch(e){}isNaN(r)||!r?(i.append(r),prepareMediaItemInit(e)):i.load("async-upload.php",{attachment_id:r,fetch:a},function(){prepareMediaItemInit(e),updateMediaForm()})}function prepareMediaItemInit(a){var e=jQuery("#media-item-"+a.id);jQuery(".thumbnail",e).clone().attr("class","pinkynail toggle").prependTo(e),jQuery(".filename.original",e).replaceWith(jQuery(".filename.new",e)),jQuery("a.delete",e).click(function(){return jQuery.ajax({url:ajaxurl,type:"post",success:deleteSuccess,error:deleteError,id:a.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}}),!1}),jQuery("a.undo",e).click(function(){return jQuery.ajax({url:ajaxurl,type:"post",id:a.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(){var e,r=jQuery("#media-item-"+a.id);(e=jQuery("#type-of-"+a.id).val())&&jQuery("#"+e+"-counter").text(+jQuery("#"+e+"-counter").text()+1),post_id&&r.hasClass("child-of-"+post_id)&&jQuery("#attachments-count").text(+jQuery("#attachments-count").text()+1),jQuery(".filename .trashnotice",r).remove(),jQuery(".filename .title",r).css("font-weight","normal"),jQuery("a.undo",r).addClass("hidden"),jQuery(".menu_order_input",r).show(),r.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},{queue:!1,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}}),!1}),jQuery("#media-item-"+a.id+".startopen").removeClass("startopen").addClass("open").find("slidetoggle").fadeIn()}function wpQueueError(e){jQuery("#media-upload-error").show().html('<div class="error"><p>'+e+"</p></div>")}function wpFileError(e,r){itemAjaxError(e.id,r)}function itemAjaxError(e,r){var a=jQue