2010-05-23 06:59:52 -04:00
|
|
|
var topWin=window.dialogArguments||opener||parent||top;function fileDialogStart(){jQuery("#media-upload-error").empty()}function fileQueued(fileObj){jQuery(".media-blank").remove();if(jQuery("form.type-form #media-items").children().length==1&&jQuery(".hidden","#media-items").length>0){jQuery(".describe-toggle-on").show();jQuery(".describe-toggle-off").hide();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-items").append('<div id="media-item-'+fileObj.id+'" class="media-item child-of-'+post_id+'"><div class="progress"><div class="bar"></div></div><div class="filename original"><span class="percent"></span> '+fileObj.name+"</div></div>");jQuery(".progress","#media-item-"+fileObj.id).show();jQuery("#insert-gallery").attr("disabled","disabled");jQuery("#cancel-upload").attr("disabled","")}function uploadStart(fileObj){try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").unbind("click",topWin.tb_remove)}}catch(e){}return true}function uploadProgress(fileObj,bytesDone,bytesTotal){var w=jQuery("#media-items").width()-2,item=jQuery("#media-item-"+fileObj.id);jQuery(".bar",item).width(w*bytesDone/bytesTotal);jQuery(".percent",item).html(Math.ceil(bytesDone/bytesTotal*100)+"%");if(bytesDone==bytesTotal){jQuery(".bar",item).html('<strong class="crunching">'+swfuploadL10n.crunching+"</strong>")}}function prepareMediaItem(fileObj,serverData){var f=(typeof shortform=="undefined")?1:2,item=jQuery("#media-item-"+fileObj.id);jQuery(".bar",item).remove();jQuery(".progress",item).hide();try{if(typeof topWin.tb_remove!="undefined"){topWin.jQuery("#TB_overlay").click(topWin.tb_remove)}}catch(e){}if(isNaN(serverData)||!serverData){item.append(serverData);prepareMediaItemInit(fileObj)}else{item.load("async-upload.php",{attachment_id:serverData,fetch:f},function(){prepareMediaItemInit(fileObj);updateMediaForm()})}}function prepareMediaItemInit(fileObj){var item=jQuery("#media-item-"+fileObj.id);jQuery(".thumbnail",item).clone().attr("className","pinkynail toggle").prependTo(item);jQuery(".filename.original",item).replaceWith(jQuery(".filename.new",item));jQuery("a.toggle",item).click(function(){jQuery(this).siblings(".slidetoggle").slideToggle(350,function(){var w=jQuery(window).height(),t=jQuery(this).offset().top,h=jQuery(this).height(),b;if(w&&t&&h){b=t+h;if(b>w&&(h+48)<w){window.scrollBy(0,b-w+13)}else{if(b>w){window.scrollTo(0,t-36)}}}});jQuery(this).siblings(".toggle").andSelf().toggle();jQuery(this).siblings("a.toggle").focus();return false});jQuery("a.delete",item).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",success:deleteSuccess,error:deleteError,id:fileObj.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"trash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")}});return false});jQuery("a.undo",item).click(function(){jQuery.ajax({url:"admin-ajax.php",type:"post",id:fileObj.id,data:{id:this.id.replace(/[^0-9]/g,""),action:"untrash-post",_ajax_nonce:this.href.replace(/^.*wpnonce=/,"")},success:function(data,textStatus){var item=jQuery("#media-item-"+fileObj.id);if(type=jQuery("#type-of-"+fileObj.id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-0+1)}if(item.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-0+1)}jQuery(".filename .trashnotice",item).remove();jQuery(".filename .title",item).css("font-weight","normal");jQuery("a.undo",item).addClass("hidden");jQuery("a.describe-toggle-on, .menu_order_input",item).show();item.css({backgroundColor:"#ceb"}).animate({backgroundColor:"#fff"},{queue:false,duration:500,complete:function(){jQuery(this).css({backgroundColor:""})}}).removeClass("undo")}});return false});jQuery("#media-item-"+fileObj.id+".startopen").removeClass("startopen").slideToggle(500).siblings(".toggle").toggle()}function itemAjaxError(id,html){var item=jQuery("#media-item-"+id);var filename=jQuery(".filename",item).text();item.html('<div class="error-div"><a class="dismiss" href="#">'+swfuploadL10n.dismiss+"</a><strong>"+swfuploadL10n.error_uploading.replace("%s",file
|