META-INF.resources.scripts.vendor.plugins.uploader.jquery.plupload.queue.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lightadmin Show documentation
Show all versions of lightadmin Show documentation
Pluggable data management solution for Java web applications developed in a "Rapid" manner
(function ( c ) {
var d = {};
function a( e ) {
return plupload.translate( e ) || e
}
function b( f, e ) {
e.contents().each( function ( g, h ) {
h = c( h );
if ( !h.is( ".plupload" ) ) {
h.remove()
}
} );
e.prepend( '' + a( "Filename" ) + ' ' + a( "Status" ) + '' + a( "Size" ) + '
' )
}
c.fn.pluploadQueue = function ( e ) {
if ( e ) {
this.each( function () {
var j, i, k;
i = c( this );
k = i.attr( "id" );
if ( !k ) {
k = plupload.guid();
i.attr( "id", k )
}
j = new plupload.Uploader( c.extend( {dragdrop: true, container: k}, e ) );
d[k] = j;
function h( l ) {
var n;
if ( l.status == plupload.DONE ) {
n = "plupload_done"
}
if ( l.status == plupload.FAILED ) {
n = "plupload_failed"
}
if ( l.status == plupload.QUEUED ) {
n = "plupload_delete"
}
if ( l.status == plupload.UPLOADING ) {
n = "plupload_uploading"
}
var m = c( "#" + l.id ).attr( "class", n ).find( "a" ).css( "display", "block" );
if ( l.hint ) {
m.attr( "title", l.hint )
}
}
function f() {
c( "span.plupload_total_status", i ).html( j.total.percent + "%" );
c( "div.plupload_progress_bar", i ).css( "width", j.total.percent + "%" );
c( "span.plupload_upload_status", i ).text( a( "Uploaded %d/%d files" ).replace( /%d\/%d/, j.total.uploaded + "/" + j.files.length ) )
}
function g() {
var m = c( "ul.plupload_filelist", i ).html( "" ), n = 0, l;
c.each( j.files, function ( p, o ) {
l = "";
if ( o.status == plupload.DONE ) {
if ( o.target_name ) {
l += ''
}
l += '';
l += '';
n++;
c( "#" + k + "_count" ).val( n )
}
m.append( '' + o.name + '' + o.percent + '%' + plupload.formatSize( o.size ) + ' ' + l + " " );
h( o );
c( "#" + o.id + ".plupload_delete a" ).click( function ( q ) {
c( "#" + o.id ).remove();
j.removeFile( o );
q.preventDefault()
} )
} );
c( "span.plupload_total_file_size", i ).html( plupload.formatSize( j.total.size ) );
if ( j.total.queued === 0 ) {
c( "span.plupload_add_text", i ).text( a( "Add files." ) )
} else {
c( "span.plupload_add_text", i ).text( j.total.queued + " files queued." )
}
c( "a.plupload_start", i ).toggleClass( "plupload_disabled", j.files.length == (j.total.uploaded + j.total.failed) );
m[0].scrollTop = m[0].scrollHeight;
f();
if ( !j.files.length && j.features.dragdrop && j.settings.dragdrop ) {
c( "#" + k + "_filelist" ).append( '' + a( "Drag files here." ) + " " )
}
}
j.bind( "UploadFile", function ( l, m ) {
c( "#" + m.id ).addClass( "plupload_current_file" )
} );
j.bind( "Init", function ( l, m ) {
b( k, i );
if ( !e.unique_names && e.rename ) {
c( "#" + k + "_filelist div.plupload_file_name span", i ).live( "click", function ( s ) {
var q = c( s.target ), o, r, n, p = "";
o = l.getFile( q.parents( "li" )[0].id );
n = o.name;
r = /^(.+)(\.[^.]+)$/.exec( n );
if ( r ) {
n = r[1];
p = r[2]
}
q.hide().after( '' );
q.next().val( n ).focus().blur(function () {
q.show().next().remove()
} ).keydown( function ( u ) {
var t = c( this );
if ( u.keyCode == 13 ) {
u.preventDefault();
o.name = t.val() + p;
q.text( o.name );
t.blur()
}
} )
} )
}
c( "a.plupload_add", i ).attr( "id", k + "_browse" );
l.settings.browse_button = k + "_browse";
if ( l.features.dragdrop && l.settings.dragdrop ) {
l.settings.drop_element = k + "_filelist";
c( "#" + k + "_filelist" ).append( '' + a( "Drag files here." ) + " " )
}
c( "#" + k + "_container" ).attr( "title", "Using runtime: " + m.runtime );
c( "a.plupload_start", i ).click( function ( n ) {
if ( !c( this ).hasClass( "plupload_disabled" ) ) {
j.start()
}
n.preventDefault()
} );
c( "a.plupload_stop", i ).click( function ( n ) {
n.preventDefault();
j.stop()
} );
c( "a.plupload_start", i ).addClass( "plupload_disabled" )
} );
j.init();
j.bind( "Error", function ( l, o ) {
var m = o.file, n;
if ( m ) {
n = o.message;
if ( o.details ) {
n += " (" + o.details + ")"
}
if ( o.code == plupload.FILE_SIZE_ERROR ) {
alert( a( "Error: File too large: " ) + m.name )
}
if ( o.code == plupload.FILE_EXTENSION_ERROR ) {
alert( a( "Error: Invalid file extension: " ) + m.name )
}
m.hint = n;
c( "#" + m.id ).attr( "class", "plupload_failed" ).find( "a" ).css( "display", "block" ).attr( "title", n )
}
} );
j.bind( "StateChanged", function () {
if ( j.state === plupload.STARTED ) {
c( "li.plupload_delete a,div.plupload_buttons", i ).hide();
c( "span.plupload_upload_status,div.plupload_progress,a.plupload_stop", i ).css( "display", "block" );
c( "span.plupload_upload_status", i ).text( "Uploaded " + j.total.uploaded + "/" + j.files.length + " files" );
if ( e.multiple_queues ) {
c( "span.plupload_total_status,span.plupload_total_file_size", i ).show()
}
} else {
g();
c( "a.plupload_stop,div.plupload_progress", i ).hide();
c( "a.plupload_delete", i ).css( "display", "block" )
}
} );
j.bind( "QueueChanged", g );
j.bind( "FileUploaded", function ( l, m ) {
h( m )
} );
j.bind( "UploadProgress", function ( l, m ) {
c( "#" + m.id + " div.plupload_file_status", i ).html( m.percent + "%" );
h( m );
f();
if ( e.multiple_queues && j.total.uploaded + j.total.failed == j.files.length ) {
c( ".plupload_buttons,.plupload_upload_status", i ).css( "display", "inline" );
c( ".plupload_start", i ).addClass( "plupload_disabled" );
c( "span.plupload_total_status,span.plupload_total_file_size", i ).hide()
}
} );
if ( e.setup ) {
e.setup( j )
}
} );
return this
} else {
return d[c( this[0] ).attr( "id" )]
}
}
})( jQuery );