mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 22:43:19 +00:00
initial import
This commit is contained in:
87
www/upload/js/fileprogress.js
Executable file
87
www/upload/js/fileprogress.js
Executable file
@@ -0,0 +1,87 @@
|
||||
|
||||
function FileProgress(file, targetID) {
|
||||
this.fileProgressID = file.id;
|
||||
|
||||
this.opacity = 100;
|
||||
this.height = 0;
|
||||
|
||||
|
||||
this.fileProgressWrapper = $('#'+this.fileProgressID);
|
||||
this.fileProgressCanceller = $('#'+this.fileProgressID+' a.progressCancel');
|
||||
this.fileProgressContainer = $('#'+this.fileProgressID+' div.progressContainer');
|
||||
this.fileProgressStatus = $('#'+this.fileProgressID+' div.progressBarStatus');
|
||||
this.fileProgressBar = $('#'+this.fileProgressID+' div.progressBarInProgress');
|
||||
|
||||
if (this.fileProgressWrapper.length == 0) {
|
||||
|
||||
var elem = '<li class="progressWrapper" id="'+this.fileProgressID+'">'+
|
||||
'<div class="progressContainer">'+
|
||||
'<a class="progressCancel" href="#" style="visibility:hidden"> </a>'+
|
||||
'<div class="progressName">'+file.name+'</div>'+
|
||||
'<div class="progressBarStatus"> </div>'+
|
||||
'<div class="progressBarInProgress"></div>'+
|
||||
'</div>'+
|
||||
'</li>';
|
||||
|
||||
$('#'+targetID).append(elem);
|
||||
|
||||
this.fileProgressWrapper = $('#'+this.fileProgressID);
|
||||
|
||||
$.each($('#'+this.fileProgressID+' .slider_status'),function(){
|
||||
activeSliders($(this));
|
||||
swfu.addFileParam(file.id,'status[4]',$(this).slider('value'));
|
||||
});
|
||||
} else {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
this.fileProgressCanceller = $('#'+this.fileProgressID+' a.progressCancel');
|
||||
this.fileProgressContainer = $('#'+this.fileProgressID+' div.progressContainer');
|
||||
this.fileProgressStatus = $('#'+this.fileProgressID+' div.progressBarStatus');
|
||||
this.fileProgressBar = $('#'+this.fileProgressID+' div.progressBarInProgress');
|
||||
this.height = this.fileProgressWrapper.offsetHeight;
|
||||
}
|
||||
|
||||
FileProgress.prototype.reset = function () {
|
||||
this.fileProgressContainer.removeClass('green blue red');
|
||||
this.fileProgressStatus.html(' ');
|
||||
this.fileProgressBar.css('width','0%');
|
||||
this.fileProgressWrapper.show();
|
||||
};
|
||||
|
||||
FileProgress.prototype.setProgress = function (percentage) {
|
||||
this.fileProgressContainer.addClass('green');
|
||||
this.fileProgressBar.css('width',percentage+'%');
|
||||
this.fileProgressWrapper.show();
|
||||
};
|
||||
FileProgress.prototype.setComplete = function () {
|
||||
this.fileProgressWrapper.addClass('done');
|
||||
this.fileProgressContainer.addClass('green');
|
||||
this.fileProgressBar.addClass('complete').css('width','auto');
|
||||
};
|
||||
FileProgress.prototype.setError = function () {
|
||||
this.fileProgressWrapper.addClass('done');
|
||||
this.fileProgressContainer.removeClass('green blue').addClass('red');
|
||||
this.fileProgressBar.removeClass('progressBarInProgress').addClass('progressBarError').css('width','auto');
|
||||
};
|
||||
FileProgress.prototype.setCancelled = function () {
|
||||
this.fileProgressWrapper.addClass('done');
|
||||
this.fileProgressContainer.removeClass('green blue red');
|
||||
this.fileProgressBar.removeClass('progressBarInProgress').addClass('progressBarError').css('width','auto');
|
||||
this.fileProgressWrapper.fadeOut();
|
||||
};
|
||||
FileProgress.prototype.setStatus = function (status) {
|
||||
this.fileProgressStatus.html(status);
|
||||
};
|
||||
|
||||
// Show/Hide the cancel button
|
||||
FileProgress.prototype.toggleCancel = function (show, swfUploadInstance) {
|
||||
this.fileProgressCanceller.css('visibility',(show ? "visible" : "hidden"));
|
||||
if (swfUploadInstance) {
|
||||
var fileID = this.fileProgressID;
|
||||
this.fileProgressCanceller.bind('click', function () {
|
||||
swfUploadInstance.cancelUpload(fileID);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
159
www/upload/js/handlers.js
Executable file
159
www/upload/js/handlers.js
Executable file
@@ -0,0 +1,159 @@
|
||||
function fileQueued(file) {
|
||||
try {
|
||||
var progress = new FileProgress(file, this.customSettings.progressTarget);
|
||||
progress.setStatus("Pending...");
|
||||
progress.toggleCancel(true, this);
|
||||
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fileQueueError(file, errorCode, message) {
|
||||
try {
|
||||
if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
|
||||
alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
|
||||
return;
|
||||
}
|
||||
|
||||
var progress = new FileProgress(file, this.customSettings.progressTarget);
|
||||
progress.setError();
|
||||
progress.toggleCancel(false);
|
||||
|
||||
switch (errorCode) {
|
||||
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
|
||||
progress.setStatus("File is too big.");
|
||||
this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
|
||||
break;
|
||||
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
||||
progress.setStatus("Cannot upload Zero Byte files.");
|
||||
this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
|
||||
break;
|
||||
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
|
||||
progress.setStatus("Invalid File Type.");
|
||||
this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
|
||||
break;
|
||||
default:
|
||||
if (file !== null) {
|
||||
progress.setStatus("Unhandled Error");
|
||||
}
|
||||
this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
|
||||
break;
|
||||
}
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function fileDialogComplete(numFilesSelected, numFilesQueued) {
|
||||
try {
|
||||
if (numFilesSelected > 0) {
|
||||
document.getElementById(this.customSettings.cancelButtonId).disabled = false;
|
||||
}
|
||||
|
||||
/* I want auto start the upload and I can do that here */
|
||||
// this.startUpload();
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadStart(file) {
|
||||
try {
|
||||
/* I don't want to do any file validation or anything, I'll just update the UI and
|
||||
return true to indicate that the upload should start.
|
||||
It's important to update the UI here because in Linux no uploadProgress events are called. The best
|
||||
we can do is say we are uploading.
|
||||
*/
|
||||
var progress = new FileProgress(file, this.customSettings.progressTarget);
|
||||
progress.setStatus("Uploading...");
|
||||
progress.toggleCancel(true, this);
|
||||
}
|
||||
catch (ex) {}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function uploadProgress(file, bytesLoaded, bytesTotal) {
|
||||
try {
|
||||
var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
|
||||
|
||||
var progress = new FileProgress(file, this.customSettings.progressTarget);
|
||||
progress.setProgress(percent);
|
||||
progress.setStatus("Uploading...");
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadSuccess(file, serverData) {
|
||||
try {
|
||||
var progress = new FileProgress(file, this.customSettings.progressTarget);
|
||||
progress.setComplete();
|
||||
progress.setStatus("Complete.");
|
||||
progress.toggleCancel(false);
|
||||
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadError(file, errorCode, message) {
|
||||
try {
|
||||
var progress = new FileProgress(file, this.customSettings.progressTarget);
|
||||
progress.setError();
|
||||
progress.toggleCancel(false);
|
||||
|
||||
switch (errorCode) {
|
||||
case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
|
||||
progress.setStatus("Upload Error: " + message);
|
||||
this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message);
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
|
||||
progress.setStatus("Upload Failed.");
|
||||
this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.IO_ERROR:
|
||||
progress.setStatus("Server (IO) Error");
|
||||
this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message);
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
|
||||
progress.setStatus("Security Error");
|
||||
this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message);
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
|
||||
progress.setStatus("Upload limit exceeded.");
|
||||
this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
|
||||
progress.setStatus("Failed Validation. Upload skipped.");
|
||||
this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
|
||||
// If there aren't any files left (they were all cancelled) disable the cancel button
|
||||
if (this.getStats().files_queued === 0) {
|
||||
document.getElementById(this.customSettings.cancelButtonId).disabled = true;
|
||||
}
|
||||
progress.setStatus("Cancelled");
|
||||
progress.setCancelled();
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
|
||||
progress.setStatus("Stopped");
|
||||
break;
|
||||
default:
|
||||
progress.setStatus("Unhandled Error: " + errorCode);
|
||||
this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
|
||||
break;
|
||||
}
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadComplete(file) {
|
||||
if (this.getStats().files_queued === 0) {
|
||||
document.getElementById(this.customSettings.cancelButtonId).disabled = true;
|
||||
}
|
||||
}
|
||||
|
438
www/upload/js/main.js
Normal file
438
www/upload/js/main.js
Normal file
@@ -0,0 +1,438 @@
|
||||
$(function() {
|
||||
$("#fsUploadProgress").sortable({
|
||||
placeholder: 'ui-state-highlight'
|
||||
});
|
||||
$("#fsUploadProgress").disableSelection();
|
||||
});
|
||||
|
||||
function do_global_action()
|
||||
{
|
||||
var cont = $('#global_operation');
|
||||
var action = $('select[name=action]', cont).val();
|
||||
|
||||
var delete_prev = $('input.delete_previous', cont).attr('checked');
|
||||
|
||||
if(action == '')
|
||||
{
|
||||
alert(language.pleaseselect);
|
||||
return;
|
||||
}
|
||||
var ret = {
|
||||
'add':[],
|
||||
'substitute':[],
|
||||
'delete':[]
|
||||
};
|
||||
$.each($('.lazaret_item:visible'), function(i,n)
|
||||
{
|
||||
|
||||
var manual = false;
|
||||
var from, to, id;
|
||||
var elem = [];
|
||||
|
||||
if(!manual && action == 'delete')
|
||||
{
|
||||
elem = $('.lazaret_deleter', n);
|
||||
id = $(elem).closest('form').find('input[name=lazaret_id]').val();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!manual && action == 'substitute')
|
||||
{
|
||||
manual = $('select[name=record_id]',n).length > 0;
|
||||
if(!manual)
|
||||
{
|
||||
elem = $('.lazaret_substituter', n);
|
||||
from = $(elem).closest('form').find('input[name=lazaret_id]').val();
|
||||
to = $(elem).closest('form').find('[name=record_id]').val();
|
||||
}
|
||||
}
|
||||
if(!manual && (action == 'add' || elem.length == 0))
|
||||
{
|
||||
elem = $('.lazaret_base_adder', n);
|
||||
id = $(elem).closest('form').find('input[name=lazaret_id]').val();
|
||||
action = 'add';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(elem.length > 0)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case 'delete':
|
||||
var obj = {
|
||||
id:id
|
||||
};
|
||||
break;
|
||||
case 'add':
|
||||
var obj = {
|
||||
id:id
|
||||
};
|
||||
break;
|
||||
case 'substitute':
|
||||
var obj = {
|
||||
from:from,
|
||||
to:to
|
||||
};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ret[action].push(obj);
|
||||
}
|
||||
if(delete_prev)
|
||||
{
|
||||
$.each($(this).closest('td').find('.more_uploads .lazaret_deleter'), function(){
|
||||
var obj = {
|
||||
id:$(this).closest('form').find('input[name=lazaret_id]').val()
|
||||
};
|
||||
ret['delete'].push(obj);
|
||||
});
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/upload/uploadFeedback.php",
|
||||
dataType:'json',
|
||||
data: {
|
||||
action: "lazaret_global_operation",
|
||||
actions:ret
|
||||
},
|
||||
success: function(data){
|
||||
if(data.error)
|
||||
alert(data.message);
|
||||
$('.tabs').tabs('load', 1);
|
||||
checkQuarantineSize();
|
||||
$('#global_operation')
|
||||
.dialog('close');
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$.each($('#status_wrapper .slider_status'),function(){
|
||||
activeSliders(this);
|
||||
});
|
||||
showStatus();
|
||||
$('.tabs').tabs({
|
||||
select: function(event, ui) {
|
||||
if($(ui.tab).attr('id') == 'quarantine-tab'){
|
||||
if($('#QUEUE li:not(.done)').length > 0)
|
||||
{
|
||||
alert(language.transfert_active);
|
||||
return false;
|
||||
}
|
||||
if($('#fsUploadProgress li').length > 0)
|
||||
{
|
||||
if(!confirm(langage.queue_not_empty))
|
||||
return false;
|
||||
}
|
||||
$('#fsUploadProgress li, #QUEUE li').remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('.tooltip').tooltip();
|
||||
|
||||
var buttons = {};
|
||||
buttons[language.ok] =
|
||||
function(){
|
||||
|
||||
do_global_action();
|
||||
};
|
||||
buttons[language.annuler] =
|
||||
function(){
|
||||
$('#global_operation')
|
||||
.dialog('close');
|
||||
};
|
||||
$('#global_operation').dialog({
|
||||
width:500,
|
||||
height:200,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
buttons:buttons
|
||||
}).dialog('close');
|
||||
$('.global_operation_trigger').live('click', function(event){
|
||||
$('#global_operation')
|
||||
.dialog('open');
|
||||
|
||||
return false;
|
||||
});
|
||||
$('.lazaret_base_adder').live('click', function(event){
|
||||
var id = $(this).closest('form').find('input[name=lazaret_id]').val();
|
||||
|
||||
$this = $(this).closest('.group');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/upload/uploadFeedback.php",
|
||||
dataType:'html',
|
||||
data: {
|
||||
action: "lazaret_add_record_to_base",
|
||||
id:id
|
||||
},
|
||||
success: function(data){
|
||||
if(data != '1')
|
||||
alert(data);
|
||||
else
|
||||
$('.lazaret_item_'+id).fadeOut('fast', function(){
|
||||
$(this).remove();
|
||||
clean($this);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.lazaret_deleter').live('click', function(event){
|
||||
var id = $(this).closest('form').find('input[name=lazaret_id]').val();
|
||||
|
||||
$this = $(this).closest('.group');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/upload/uploadFeedback.php",
|
||||
dataType:'html',
|
||||
data: {
|
||||
action: "lazaret_delete_record",
|
||||
id:id
|
||||
},
|
||||
success: function(data){
|
||||
if(data != '1')
|
||||
alert(data);
|
||||
else
|
||||
$('.lazaret_item_'+id).fadeOut('fast', function(){
|
||||
$(this).remove();
|
||||
clean($this);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.lazaret_substituter').live('click', function(event){
|
||||
var from_id = $(this).closest('form').find('input[name=lazaret_id]').val();
|
||||
var to_id = $(this).closest('form').find('[name=record_id]').val();
|
||||
|
||||
if(to_id == '')
|
||||
{
|
||||
alert(language.norecordselected);
|
||||
return;
|
||||
}
|
||||
|
||||
$this = $(this).closest('.group');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/upload/uploadFeedback.php",
|
||||
dataType:'html',
|
||||
data: {
|
||||
action: "lazaret_substitute_record",
|
||||
from_id:from_id,
|
||||
to_id:to_id
|
||||
},
|
||||
success: function(data){
|
||||
|
||||
if(data != '1')
|
||||
alert(data);
|
||||
else
|
||||
$('.lazaret_item_'+from_id).fadeOut('fast', function(){
|
||||
$(this).remove();
|
||||
clean($this);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
$(window).bind('resize', function(){
|
||||
resize();
|
||||
}).trigger('resize');
|
||||
});
|
||||
|
||||
function checkQuarantineSize()
|
||||
{
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/upload/uploadFeedback.php",
|
||||
dataType:'json',
|
||||
data: {
|
||||
action: "get_lazaret_count"
|
||||
},
|
||||
success: function(data){
|
||||
var q_size = $('#quarantine_size');
|
||||
q_size.empty();
|
||||
if(!data.error)
|
||||
q_size.append('('+data.count+')');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clean(el)
|
||||
{
|
||||
if($('.lazaret_item', el).length == 0)
|
||||
{
|
||||
el.slideUp('fast',function(){
|
||||
el.remove();
|
||||
});
|
||||
return;
|
||||
}
|
||||
if($('.main_item', el).length == 0)
|
||||
{
|
||||
if($('.more_item', el).length > 0)
|
||||
{
|
||||
var clone = $('.more_item:first', el)
|
||||
.clone()
|
||||
.removeClass('more_item')
|
||||
.addClass('main_item');
|
||||
$('.main_container', el).append(clone);
|
||||
$('.more_uploads .more_item:first', el).remove();
|
||||
}
|
||||
}
|
||||
if($('.more_uploads .lazaret_item', el).length == 0)
|
||||
{
|
||||
$('.more_title, .more_uploads', el).remove();
|
||||
}
|
||||
}
|
||||
|
||||
function resize()
|
||||
{
|
||||
$('.ui-tabs-panel').height(
|
||||
$(window).height() - $('.ui-tabs-panel:visible').offset().top - 2
|
||||
);
|
||||
}
|
||||
function showStatus()
|
||||
{
|
||||
$('#status_wrapper .status_box').hide();
|
||||
$("#status_"+$('#coll_selector select option:selected').val()).show();
|
||||
|
||||
|
||||
}
|
||||
function getCurrentStatusValue(slider)
|
||||
{
|
||||
|
||||
var ret = 0;
|
||||
var parent = $(slider).parent().parent();
|
||||
var parent_active = $(parent).find('td.active');
|
||||
|
||||
if(parent_active.length == 0)
|
||||
{
|
||||
parent_active = $(parent).find('td:first');
|
||||
parent_active.addClass('active');
|
||||
}
|
||||
|
||||
if(parent_active.length >1)
|
||||
{
|
||||
$(parent).find('td').removeClass('active');
|
||||
parent_active = $(parent).find('td:first');
|
||||
parent_active.addClass('active');
|
||||
}
|
||||
|
||||
if(parent_active.length == 1)
|
||||
{
|
||||
if(parent_active.hasClass('status_on'))
|
||||
ret = 1;
|
||||
if(parent_active.hasClass('status_off'))
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function activeSliders(slider){
|
||||
$(slider).slider({
|
||||
value:getCurrentStatusValue($(slider)),
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 1,
|
||||
slide: function(event, ui) {
|
||||
var el = $(this).parent().parent();
|
||||
$(el).find('td.active').removeClass('active');
|
||||
if(ui.value == 0)
|
||||
$(el).find('td.status_off').addClass('active');
|
||||
else
|
||||
if(ui.value == 1)
|
||||
$(el).find('td.status_on').addClass('active');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
var swfu;
|
||||
function startIt(){
|
||||
|
||||
var classic = !!$('#step2classic').is(':visible');
|
||||
var els;
|
||||
|
||||
if(!classic)
|
||||
{
|
||||
$('#fsUploadProgress a.progressCancel').remove();
|
||||
els = $('#fsUploadProgress li');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#classic_parms').empty();
|
||||
els = $('input[type=file]');
|
||||
}
|
||||
|
||||
$.each(els,function(){
|
||||
var id = $(this).attr('id');
|
||||
|
||||
var val = $('#coll_selector select option:selected').val();
|
||||
|
||||
if(!classic)
|
||||
swfu.addFileParam(id, 'coll', val);
|
||||
else
|
||||
$('#classic_parms').append(
|
||||
'<input type="hidden" name="coll" value="'+val+'"/>'
|
||||
);
|
||||
$.each($('#status_wrapper td.active:visible'),function(){
|
||||
if($(this).hasClass('status_on') || $(this).hasClass('status_off'))
|
||||
{
|
||||
var val = 0;
|
||||
if($(this).hasClass('status_on'))
|
||||
val = 1;
|
||||
if(!classic)
|
||||
{
|
||||
swfu.addFileParam(
|
||||
id,
|
||||
'status['+$(this).attr('id').split('_').pop()+']',
|
||||
val
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#classic_parms').append(
|
||||
'<input type="hidden" '+
|
||||
'name="status['+$(this).attr('id').split('_').pop()+']" '+
|
||||
'value="'+val+'"/>');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if(classic)
|
||||
{
|
||||
$('body').append('<iframe style="display:none;" '+
|
||||
'name="classic_upload"></iframe>');
|
||||
$('#classic_loader').show();
|
||||
$('#form1').submit();
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = $('#fsUploadProgress').html();
|
||||
$('#fsUploadProgress').empty();
|
||||
$('#QUEUE').append('<ul>'+list+'</ul>');
|
||||
|
||||
swfu.startUpload();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function classic_uploaded(message)
|
||||
{
|
||||
$('#classic_loader').hide();
|
||||
alert(message);
|
||||
$('input[type=file]').val('');
|
||||
$('iframe[name=classic_upload]').remove();
|
||||
}
|
90
www/upload/js/swfupload.queue.js
Executable file
90
www/upload/js/swfupload.queue.js
Executable file
@@ -0,0 +1,90 @@
|
||||
|
||||
var SWFUpload;
|
||||
if (typeof(SWFUpload) === "function") {
|
||||
SWFUpload.queue = {};
|
||||
|
||||
SWFUpload.prototype.initSettings = (function (oldInitSettings) {
|
||||
return function () {
|
||||
if (typeof(oldInitSettings) === "function") {
|
||||
oldInitSettings.call(this);
|
||||
}
|
||||
|
||||
this.queueSettings = {};
|
||||
|
||||
this.queueSettings.queue_cancelled_flag = false;
|
||||
this.queueSettings.queue_upload_count = 0;
|
||||
|
||||
this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
|
||||
this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
|
||||
this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
|
||||
this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
|
||||
|
||||
this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
|
||||
};
|
||||
})(SWFUpload.prototype.initSettings);
|
||||
|
||||
SWFUpload.prototype.startUpload = function (fileID) {
|
||||
fileID = $('#QUEUE li.progressWrapper:not(.done):first').attr('id');
|
||||
if(typeof(fileID) == 'undefined')
|
||||
return;
|
||||
$('#QUEUE li.progressWrapper:not(.done):first').addClass('done');
|
||||
this.queueSettings.queue_cancelled_flag = false;
|
||||
this.callFlash("StartUpload", [fileID]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.cancelQueue = function () {
|
||||
this.queueSettings.queue_cancelled_flag = true;
|
||||
this.stopUpload();
|
||||
|
||||
var stats = this.getStats();
|
||||
while (stats.files_queued > 0) {
|
||||
this.cancelUpload();
|
||||
stats = this.getStats();
|
||||
}
|
||||
};
|
||||
|
||||
SWFUpload.queue.uploadStartHandler = function (file) {
|
||||
var returnValue;
|
||||
if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
|
||||
returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
|
||||
}
|
||||
|
||||
// To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
|
||||
returnValue = (returnValue === false) ? false : true;
|
||||
|
||||
this.queueSettings.queue_cancelled_flag = !returnValue;
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
SWFUpload.queue.uploadCompleteHandler = function (file) {
|
||||
var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
|
||||
var continueUpload;
|
||||
|
||||
if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
|
||||
this.queueSettings.queue_upload_count++;
|
||||
}
|
||||
|
||||
if (typeof(user_upload_complete_handler) === "function") {
|
||||
continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
|
||||
} else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
|
||||
// If the file was stopped and re-queued don't restart the upload
|
||||
continueUpload = false;
|
||||
} else {
|
||||
continueUpload = true;
|
||||
}
|
||||
|
||||
if (continueUpload) {
|
||||
var stats = this.getStats();
|
||||
if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
|
||||
this.startUpload();
|
||||
} else if (this.queueSettings.queue_cancelled_flag === false) {
|
||||
this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
|
||||
this.queueSettings.queue_upload_count = 0;
|
||||
} else {
|
||||
this.queueSettings.queue_cancelled_flag = false;
|
||||
this.queueSettings.queue_upload_count = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user