Вход Регистрация
Файл: wordpress/wp-includes/js/swfupload/handlers.js
Строк: 397
<?php
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 == && jQuery('.hidden''#media-items').length ) {
        
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('<div class="media-item">')
        .
attr'id''media-item-' fileObj.id )
        .
addClass('child-of-' post_id)
        .
append('<div class="progress"><div class="bar"></div></div>',
            
jQuery('<div class="filename original"><span class="percent"></span>').text' ' fileObj.name ))
        .
appendTojQuery('#media-items' ) );
    
// 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(fileObjbytesDonebytesTotal) {
    
// Lengthen the progress bar
    
var jQuery('#media-items').width() - 2item jQuery('#media-item-' fileObj.id);
    
jQuery('.bar'item).widthbytesDone bytesTotal );
    
jQuery('.percent'item).htmlMath.ceil(bytesDone bytesTotal 100) + '%' );

    if ( 
bytesDone == bytesTotal )
        
jQuery('.bar'item).html('<strong class="crunching">' swfuploadL10n.crunching '</strong>');
}

function 
prepareMediaItem(fileObjserverData) {
    var 
= ( typeof shortform == 'undefined' ) ? 2item 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:serverDatafetch: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).replaceWithjQuery('.filename.new'item) );

    
// Also bind toggle to the links
    
jQuery('a.toggle'item).click(function(){
        
jQuery(this).siblings('.slidetoggle').slideToggle(350, function(){
            var 
jQuery(window).height(), jQuery(this).offset().topjQuery(this).height(), b;

            if ( 
&& && ) {
                
h;

                if ( 
&& (48) < )
                    
window.scrollBy(013);
                else if ( 
)
                    
window.scrollTo(036);
            }
        });
        
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({
            
urlajaxurl,
            
type'post',
            
successdeleteSuccess,
            
errordeleteError,
            
idfileObj.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({
            
urlajaxurl,
            
type'post',
            
idfileObj.id,
            
data: {
                
id this.id.replace(/[^0-9]/g,''),
                
action'untrash-post',
                
_ajax_noncethis.href.replace(/^.*wpnonce=/,'')
            },
            
success: function(datatextStatus){
                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'}, { queuefalseduration500complete: 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(idhtml) {
    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'filename) + '</strong><br />'
                
html
                
'</div>');
    
item.find('a.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
}

function 
deleteSuccess(datatextStatus) {
    if ( 
data == '-1' )
        return 
itemAjaxError(this.id'You do not have permission. Has your session expired?');
    if ( 
data == '0' )
        return 
itemAjaxError(this.id'Could not be deleted. Has it been deleted already?');

    var 
id this.iditem jQuery('#media-item-' id);

    
// Decrement the counters.
    
if ( type jQuery('#type-of-' id).val() )
        
jQuery('#' type '-counter').textjQuery('#' type '-counter').text() - );
    if ( 
item.hasClass('child-of-'+post_id) )
        
jQuery('#attachments-count').textjQuery('#attachments-count').text() - );

    if ( 
jQuery('form.type-form #media-items').children().length == && jQuery('.hidden''#media-items').length ) {
        
jQuery('.toggle').toggle();
        
jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden');
    }

    
// Vanish it.
    
jQuery('.toggle'item).toggle();
    
jQuery('.slidetoggle'item).slideUp(200).siblings().removeClass('hidden');
    
item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:falseduration:500} ).addClass('undo');

    
jQuery('.filename:empty'item).remove();
    
jQuery('.filename .title'item).css('font-weight','bold');
    
jQuery('.filename'item).append('<span class="trashnotice"> ' swfuploadL10n.deleted ' </span>').siblings('a.toggle').hide();
    
jQuery('.filename'item).appendjQuery('a.undo'item).removeClass('hidden') );
    
jQuery('.menu_order_input'item).hide();

    return;
}

function 
deleteError(XtextStatuserrorThrown) {
    
// TODO
}

function 
updateMediaForm() {
    var 
one jQuery('form.type-form #media-items').children(), items jQuery('#media-items').children();

    
// Just one file, no need for collapsible part
    
if ( one.length == ) {
        
jQuery('.slidetoggle'one).slideDown(500).siblings().addClass('hidden').filter('.toggle').toggle();
    }

    
// Only show Save buttons when there is at least one file.
    
if ( items.not('.media-blank').length )
        
jQuery('.savebutton').show();
    else
        
jQuery('.savebutton').hide();

    
// Only show Gallery buttons when there are at least two files.
    
if ( items.length ) {
        
jQuery('.insert-gallery').show();
    } else {
        
jQuery('.insert-gallery').hide();
    }
}

function 
uploadSuccess(fileObjserverData) {
    
// if async-upload returned an error message, place it in the media item div and return
    
if ( serverData.match('media-upload-error') ) {
        
jQuery('#media-item-' fileObj.id).html(serverData);
        return;
    }

    
prepareMediaItem(fileObjserverData);
    
updateMediaForm();

    
// Increment the counter.
    
if ( jQuery('#media-item-' fileObj.id).hasClass('child-of-' post_id) )
        
jQuery('#attachments-count').text(jQuery('#attachments-count').text() + 1);
}

function 
uploadComplete(fileObj) {
    
// If no more uploads queued, enable the submit button
    
if ( swfu.getStats().files_queued == ) {
        
jQuery('#cancel-upload').prop('disabled'true);
        
jQuery('#insert-gallery').prop('disabled'false);
    }
}


// wp-specific error handlers

// generic message
function wpQueueError(message) {
    
jQuery('#media-upload-error').show().text(message);
}

// file-specific message
function wpFileError(fileObjmessage) {
    var 
item jQuery('#media-item-' fileObj.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'filename) + '</strong><br />'
                
message
                
'</div>');
    
item.find('a.dismiss').click(function(){jQuery(this).parents('.media-item').slideUp(200, function(){jQuery(this).remove();})});
}

function 
fileQueueError(fileObjerror_codemessage)  {
    
// Handle this error separately because we don't want to create a FileProgress element for it.
    
if ( error_code == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED ) {
        
wpQueueError(swfuploadL10n.queue_limit_exceeded);
    }
    else if ( 
error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) {
        
fileQueued(fileObj);
        
wpFileError(fileObjswfuploadL10n.file_exceeds_size_limit);
    }
    else if ( 
error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) {
        
fileQueued(fileObj);
        
wpFileError(fileObjswfuploadL10n.zero_byte_file);
    }
    else if ( 
error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) {
        
fileQueued(fileObj);
        
wpFileError(fileObjswfuploadL10n.invalid_filetype);
    }
    else {
        
wpQueueError(swfuploadL10n.default_error);
    }
}

function 
fileDialogComplete(num_files_queued) {
    try {
        if (
num_files_queued 0) {
            
this.startUpload();
        }
    } catch (
ex) {
        
this.debug(ex);
    }
}

function 
switchUploader(s) {
    var 
document.getElementById(swfu.customSettings.swfupload_element_id), document.getElementById(swfu.customSettings.degraded_element_id);
    if ( 
) {
        
f.style.display 'block';
        
h.style.display 'none';
    } else {
        
f.style.display 'none';
        
h.style.display 'block';
    }
}

function 
swfuploadPreLoad() {
    if ( !
uploaderMode ) {
        
switchUploader(1);
    } else {
        
switchUploader(0);
    }
}

function 
swfuploadLoadFailed() {
    
switchUploader(0);
    
jQuery('.upload-html-bypass').hide();
}

function 
uploadError(fileObjerrorCodemessage) {

    switch (
errorCode) {
        case 
SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
            
wpFileError(fileObjswfuploadL10n.missing_upload_url);
            break;
        case 
SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
            
wpFileError(fileObjswfuploadL10n.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-' fileObj.id).remove();
            break;
        default:
            
wpFileError(fileObjswfuploadL10n.default_error);
    }
}

function 
cancelUpload() {
    
swfu.cancelQueue();
}

// remember the last used image size, alignment and url
jQuery(document).ready(function($){
    $(
'input[type="radio"]''#media-items').live('click', function(){
        var 
tr = $(this).closest('tr');

        if ( $(
tr).hasClass('align') )
            
setUserSetting('align', $(this).val());
        else if ( $(
tr).hasClass('image-size') )
            
setUserSetting('imgsize', $(this).val());
    });

    $(
'button.button''#media-items').live('click', function(){
        var 
this.className || '';
        
c.match(/url([^ '"]+)/);
        if ( c && c[1] ) {
            setUserSetting('
urlbutton', c[1]);
            $(this).siblings('
.urlfield').val( $(this).attr('title') );
        }
    });
});
?>
Онлайн: 0
Реклама