");jQuery("#dismiss-"+c).click(function(){jQuery(this).parents(".file-error").slideUp(200,function(){jQuery(this).empty()})})}function deleteSuccess(b,c){if(b=="-1"){return itemAjaxError(this.id,"You do not have permission. Has your session expired?")}if(b=="0"){return itemAjaxError(this.id,"Could not be deleted. Has it been deleted already?")}var a=jQuery("#media-item-"+this.id);if(type=jQuery("#type-of-"+this.id).val()){jQuery("#"+type+"-counter").text(jQuery("#"+type+"-counter").text()-1)}if(a.hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(jQuery("#attachments-count").text()-1)}if(jQuery(".type-form #media-items>*").length==1&&jQuery("#media-items .hidden").length>0){jQuery(".toggle").toggle();jQuery(".slidetoggle").slideUp(200).siblings().removeClass("hidden")}jQuery("#media-item-"+this.id+" .filename:empty").remove();jQuery("#media-item-"+this.id+" .filename").append(' '+swfuploadL10n.deleted+"").siblings("a.toggle").remove();jQuery("#media-item-"+this.id).children(".describe").css({backgroundColor:"#fff"}).end().animate({backgroundColor:"#ffc0c0"},{queue:false,duration:50}).animate({minHeight:0,height:36},400,null,function(){jQuery(this).children(".describe").remove()}).animate({backgroundColor:"#fff"},400).animate({height:0},800,null,function(){jQuery(this).remove();updateMediaForm()});return}function deleteError(c,b,a){}function updateMediaForm(){storeState();if(jQuery(".type-form #media-items>*").length==1){jQuery("#media-items .slidetoggle").slideDown(500).parent().eq(0).children(".toggle").toggle();jQuery(".type-form .slidetoggle").siblings().addClass("hidden")}if(jQuery("#media-items>*").not(".media-blank").length>0){jQuery(".savebutton").show()}else{jQuery(".savebutton").hide()}if(jQuery("#media-items>*").length>1){jQuery(".insert-gallery").show()}else{jQuery(".insert-gallery").hide()}}function uploadSuccess(b,a){if(a.match("media-upload-error")){jQuery("#media-item-"+b.id).html(a);return}prepareMediaItem(b,a);updateMediaForm();if(jQuery("#media-item-"+b.id).hasClass("child-of-"+post_id)){jQuery("#attachments-count").text(1*jQuery("#attachments-count").text()+1)}}function uploadComplete(a){if(swfu.getStats().files_queued==0){jQuery("#cancel-upload").attr("disabled","disabled");jQuery("#insert-gallery").attr("disabled","")}}function wpQueueError(a){jQuery("#media-upload-error").show().text(a)}function wpFileError(b,a){jQuery("#media-item-"+b.id+" .filename").after('
"+a+"
").siblings(".toggle").remove();jQuery("#dismiss-"+b.id).click(function(){jQuery(this).parents(".media-item").slideUp(200,function(){jQuery(this).remove()})})}function fileQueueError(c,a,b){if(a==SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){wpQueueError(swfuploadL10n.queue_limit_exceeded)}else{if(a==SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT){fileQueued(c);wpFileError(c,swfuploadL10n.file_exceeds_size_limit)}else{if(a==SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE){fileQueued(c);wpFileError(c,swfuploadL10n.zero_byte_file)}else{if(a==SWFUpload.QUEUE_ERROR.INVALID_FILETYPE){fileQueued(c);wpFileError(c,swfuploadL10n.invalid_filetype)}else{wpQueueError(swfuploadL10n.default_error)}}}}}function fileDialogComplete(b){try{if(b>0){this.startUpload()}}catch(a){this.debug(a)}}function switchUploader(b){var c=document.getElementById(swfu.customSettings.swfupload_element_id),a=document.getElementById(swfu.customSettings.degraded_element_id);if(b){c.style.display="block";a.style.display="none"}else{c.style.display="none";a.style.display="block"}}function swfuploadPreLoad(){if(!uploaderMode){switchUploader(1)}else{switchUploader(0)}}function swfuploadLoadFailed(){switchUploader(0);jQuery(".upload-html-bypass").hide()}function uploadError(b,c,a){switch(c){case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:wpFileError(b,swfuploadL10n.missing_upload_url);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:wpFileError(b,swfuploadL10n.upload_limit_exceeded);break;case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:wpQueueError(swfuploadL10n.http_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:wpQueueError(swfuploadL10n.upload_failed);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:wpQueueError(swfuploadL10n.io_error);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:wpQueueError(swfuploadL10n.security_error);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:jQuery("#media-item-"+b.id).remove();break;default:wpFileError(b,swfuploadL10n.default_error)}}function cancelUpload(){swfu.cancelQueue()}var storeState;(function(a){storeState=function(){var c=getUserSetting("align")||"",b=getUserSetting("imgsize")||"";a('tr.align input[type="radio"]').click(function(){setUserSetting("align",a(this).val())}).filter(function(){if(a(this).val()==c){return true}return false}).attr("checked","checked");a('tr.image-size input[type="radio"]').click(function(){setUserSetting("imgsize",a(this).val())}).filter(function(){if(a(this).attr("disabled")||a(this).val()!=b){return false}return true}).attr("checked","checked");a("tr.url button").click(function(){var d=this.className||"";d=d.replace(/.*?(url[^ '"]+).*/,"$1");if(d){setUserSetting("urlbutton",d)}a(this).siblings(".urlfield").val(a(this).attr("title"))});a("tr.url .urlfield").each(function(){var d=getUserSetting("urlbutton");a(this).val(a(this).siblings("button."+d).attr("title"))})}})(jQuery);
\ No newline at end of file
+var topWin = window.dialogArguments || opener || parent || top;
+
+function fileDialogStart() {
+ jQuery("#media-upload-error").empty();
+}
+
+// progress and success handlers for media multi uploads
+function fileQueued(fileObj) {
+ // Get rid of unused form
+ jQuery('.media-blank').remove();
+ // Collapse a single item
+ 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');
+ }
+ // Create a progress bar containing the filename
+ jQuery('#media-items').append('
' + fileObj.name + '
');
+ // Display the progress div
+ jQuery('.progress', '#media-item-' + fileObj.id).show();
+
+ // Disable submit and enable cancel
+ jQuery('#insert-gallery').prop('disabled', true);
+ jQuery('#cancel-upload').prop('disabled', false);
+}
+
+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) {
+ // Lengthen the progress bar
+ 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('' + swfuploadL10n.crunching + '');
+}
+
+function prepareMediaItem(fileObj, serverData) {
+ var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
+ // Move the progress bar to 100%
+ 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){}
+
+ // Old style: Append the HTML returned by the server -- thumbnail and form inputs
+ if ( isNaN(serverData) || !serverData ) {
+ item.append(serverData);
+ prepareMediaItemInit(fileObj);
+ }
+ // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server
+ 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);
+ // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename
+ jQuery('.thumbnail', item).clone().attr('class', 'pinkynail toggle').prependTo(item);
+
+ // Replace the original filename with the new (unique) one assigned during upload
+ jQuery('.filename.original', item).replaceWith( jQuery('.filename.new', item) );
+
+ // Also bind toggle to the links
+ 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;
+ });
+
+ // Bind AJAX to the new Delete button
+ jQuery('a.delete', item).click(function(){
+ // Tell the server to delete it. TODO: handle exceptions
+ jQuery.ajax({
+ url: ajaxurl,
+ 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;
+ });
+
+ // Bind AJAX to the new Undo button
+ jQuery('a.undo', item).click(function(){
+ // Tell the server to untrash it. TODO: handle exceptions
+ jQuery.ajax({
+ url: ajaxurl,
+ 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;
+ });
+
+ // Open this item if it says to start open (e.g. to display an error)
+ 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('