2018-11-13 17:30:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
var OperationProgressBar = OC.Backbone.View.extend({
|
|
|
|
tagName: 'div',
|
|
|
|
id: 'uploadprogresswrapper',
|
|
|
|
events: {
|
|
|
|
'click button.stop': '_onClickCancel'
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
this.$el.html(OCA.Files.Templates['operationprogressbar']({
|
|
|
|
textCancelButton: t('Cancel operation')
|
|
|
|
}));
|
2018-11-13 22:19:08 +00:00
|
|
|
this.setProgressBarText(t('Uploading …'), t('…'));
|
2018-11-13 17:30:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
hideProgressBar: function() {
|
|
|
|
var self = this;
|
|
|
|
$('#uploadprogresswrapper .stop').fadeOut();
|
|
|
|
$('#uploadprogressbar').fadeOut(function() {
|
|
|
|
self.$el.trigger(new $.Event('resized'));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
hideCancelButton: function() {
|
2019-02-16 22:27:50 +00:00
|
|
|
var self = this;
|
2018-11-13 17:30:32 +00:00
|
|
|
$('#uploadprogresswrapper .stop').fadeOut(function() {
|
2019-02-16 22:27:50 +00:00
|
|
|
self.$el.trigger(new $.Event('resized'));
|
2018-11-13 17:30:32 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-11-14 21:39:12 +00:00
|
|
|
showProgressBar: function(showCancelButton) {
|
|
|
|
if (showCancelButton) {
|
|
|
|
showCancelButton = true;
|
|
|
|
}
|
|
|
|
$('#uploadprogressbar').progressbar({value: 0});
|
|
|
|
if(showCancelButton) {
|
|
|
|
$('#uploadprogresswrapper .stop').show();
|
|
|
|
} else {
|
|
|
|
$('#uploadprogresswrapper .stop').hide();
|
|
|
|
}
|
2018-11-13 17:30:32 +00:00
|
|
|
$('#uploadprogresswrapper .label').show();
|
|
|
|
$('#uploadprogressbar').fadeIn();
|
|
|
|
this.$el.trigger(new $.Event('resized'));
|
|
|
|
},
|
|
|
|
|
|
|
|
setProgressBarValue: function(value) {
|
|
|
|
$('#uploadprogressbar').progressbar({value: value});
|
|
|
|
},
|
|
|
|
|
|
|
|
setProgressBarText: function(textDesktop, textMobile, title) {
|
2018-11-13 22:19:08 +00:00
|
|
|
var labelHtml = OCA.Files.Templates['operationprogressbarlabel']({textDesktop: textDesktop, textMobile: textMobile});
|
|
|
|
$('#uploadprogressbar .ui-progressbar-value').html(labelHtml);
|
|
|
|
$('#uploadprogressbar .ui-progressbar-value>em').addClass('inner');
|
|
|
|
$('#uploadprogressbar>em').replaceWith(labelHtml);
|
|
|
|
$('#uploadprogressbar>em').addClass('outer');
|
2019-10-23 15:25:27 +00:00
|
|
|
$('#uploadprogressbar').tooltip({placement: 'bottom', container: '#uploadprogresswrapper'});
|
|
|
|
if (title) {
|
2019-10-22 19:01:23 +00:00
|
|
|
$('#uploadprogressbar').attr('data-original-title', title);
|
2019-10-23 15:25:27 +00:00
|
|
|
$('#uploadprogresswrapper .tooltip-inner').text(title);
|
2018-11-13 17:30:32 +00:00
|
|
|
}
|
2019-06-28 16:08:16 +00:00
|
|
|
if(textDesktop || textMobile) {
|
|
|
|
$('#uploadprogresswrapper .stop').show();
|
|
|
|
}
|
2018-11-13 17:30:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onClickCancel: function (event) {
|
|
|
|
this.trigger('cancel');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
OCA.Files.OperationProgressBar = OperationProgressBar;
|
|
|
|
})(OC, OCA);
|