Restructuring code in file-upload.js
Signed-off-by: Tomasz Grobelny <tomasz@grobelny.net>
This commit is contained in:
parent
ea17e962bf
commit
296e69fe04
|
@ -757,14 +757,6 @@ OC.Uploader.prototype = _.extend({
|
||||||
callbacks.onNoConflicts(selection);
|
callbacks.onNoConflicts(selection);
|
||||||
},
|
},
|
||||||
|
|
||||||
_hideProgressBar: function() {
|
|
||||||
var self = this;
|
|
||||||
$('#uploadprogresswrapper .stop').fadeOut();
|
|
||||||
$('#uploadprogressbar').fadeOut(function() {
|
|
||||||
self.$uploadEl.trigger(new $.Event('resized'));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
_updateProgressBarOnUploadStop: function() {
|
_updateProgressBarOnUploadStop: function() {
|
||||||
if (this._pendingUploadDoneCount === 0) {
|
if (this._pendingUploadDoneCount === 0) {
|
||||||
// All the uploads ended and there is no pending operation, so hide
|
// All the uploads ended and there is no pending operation, so hide
|
||||||
|
@ -778,19 +770,49 @@ OC.Uploader.prototype = _.extend({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#uploadprogressbar .label .mobile').text(t('core', '…'));
|
this._setProgressBarText(t('core', 'Processing files …'), t('core', '…'));
|
||||||
$('#uploadprogressbar .label .desktop').text(t('core', 'Processing files …'));
|
|
||||||
|
|
||||||
// Nothing is being uploaded at this point, and the pending operations
|
// Nothing is being uploaded at this point, and the pending operations
|
||||||
// can not be cancelled, so the cancel button should be hidden.
|
// can not be cancelled, so the cancel button should be hidden.
|
||||||
|
this._hideCancelButton();
|
||||||
|
},
|
||||||
|
|
||||||
|
_hideProgressBar: function() {
|
||||||
|
var self = this;
|
||||||
|
$('#uploadprogresswrapper .stop').fadeOut();
|
||||||
|
$('#uploadprogressbar').fadeOut(function() {
|
||||||
|
self.$uploadEl.trigger(new $.Event('resized'));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_hideCancelButton: function() {
|
||||||
$('#uploadprogresswrapper .stop').fadeOut();
|
$('#uploadprogresswrapper .stop').fadeOut();
|
||||||
},
|
},
|
||||||
|
|
||||||
_showProgressBar: function() {
|
_showProgressBar: function() {
|
||||||
|
$('#uploadprogresswrapper .stop').show();
|
||||||
|
$('#uploadprogresswrapper .label').show();
|
||||||
$('#uploadprogressbar').fadeIn();
|
$('#uploadprogressbar').fadeIn();
|
||||||
this.$uploadEl.trigger(new $.Event('resized'));
|
this.$uploadEl.trigger(new $.Event('resized'));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setProgressBarValue: function(value) {
|
||||||
|
$('#uploadprogressbar').progressbar({value: value});
|
||||||
|
},
|
||||||
|
|
||||||
|
_setProgressBarText: function(textDesktop, textMobile, title) {
|
||||||
|
$('#uploadprogressbar .ui-progressbar-value').
|
||||||
|
html('<em class="label inner"><span class="desktop">'
|
||||||
|
+ textDesktop
|
||||||
|
+ '</span><span class="mobile">'
|
||||||
|
+ textMobile
|
||||||
|
+ '</span></em>');
|
||||||
|
$('#uploadprogressbar').tooltip({placement: 'bottom'});
|
||||||
|
if(title) {
|
||||||
|
$('#uploadprogressbar').attr('original-title', title);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the given file is known to be a received shared file
|
* Returns whether the given file is known to be a received shared file
|
||||||
*
|
*
|
||||||
|
@ -1096,16 +1118,8 @@ OC.Uploader.prototype = _.extend({
|
||||||
// add progress handlers
|
// add progress handlers
|
||||||
fileupload.on('fileuploadstart', function(e, data) {
|
fileupload.on('fileuploadstart', function(e, data) {
|
||||||
self.log('progress handle fileuploadstart', e, data);
|
self.log('progress handle fileuploadstart', e, data);
|
||||||
$('#uploadprogresswrapper .stop').show();
|
self._setProgressBarText(t('files', 'Uploading …'), t('files', '…'));
|
||||||
$('#uploadprogresswrapper .label').show();
|
self._setProgressBarValue(0);
|
||||||
$('#uploadprogressbar').progressbar({value: 0});
|
|
||||||
$('#uploadprogressbar .ui-progressbar-value').
|
|
||||||
html('<em class="label inner"><span class="desktop">'
|
|
||||||
+ t('files', 'Uploading …')
|
|
||||||
+ '</span><span class="mobile">'
|
|
||||||
+ t('files', '…')
|
|
||||||
+ '</span></em>');
|
|
||||||
$('#uploadprogressbar').tooltip({placement: 'bottom'});
|
|
||||||
self._showProgressBar();
|
self._showProgressBar();
|
||||||
// initial remaining time variables
|
// initial remaining time variables
|
||||||
lastUpdate = new Date().getTime();
|
lastUpdate = new Date().getTime();
|
||||||
|
@ -1155,16 +1169,12 @@ OC.Uploader.prototype = _.extend({
|
||||||
// show "Uploading ..." for durations longer than 4 hours
|
// show "Uploading ..." for durations longer than 4 hours
|
||||||
h = t('files', 'Uploading …');
|
h = t('files', 'Uploading …');
|
||||||
}
|
}
|
||||||
$('#uploadprogressbar .label .mobile').text(h);
|
self._setProgressBarText(h, h, t('files', '{loadedSize} of {totalSize} ({bitrate})' , {
|
||||||
$('#uploadprogressbar .label .desktop').text(h);
|
|
||||||
$('#uploadprogressbar').attr('original-title',
|
|
||||||
t('files', '{loadedSize} of {totalSize} ({bitrate})' , {
|
|
||||||
loadedSize: humanFileSize(data.loaded),
|
loadedSize: humanFileSize(data.loaded),
|
||||||
totalSize: humanFileSize(data.total),
|
totalSize: humanFileSize(data.total),
|
||||||
bitrate: humanFileSize(data.bitrate / 8) + '/s'
|
bitrate: humanFileSize(data.bitrate / 8) + '/s'
|
||||||
})
|
}));
|
||||||
);
|
self._setProgressBarValue(progress);
|
||||||
$('#uploadprogressbar').progressbar('value', progress);
|
|
||||||
self.trigger('progressall', e, data);
|
self.trigger('progressall', e, data);
|
||||||
});
|
});
|
||||||
fileupload.on('fileuploadstop', function(e, data) {
|
fileupload.on('fileuploadstop', function(e, data) {
|
||||||
|
|
Loading…
Reference in New Issue