diff options
author | Tomasz Grobelny <tomasz@grobelny.net> | 2018-11-13 18:30:32 +0100 |
---|---|---|
committer | Tomasz Grobelny <tomasz@grobelny.net> | 2018-11-24 23:55:17 +0100 |
commit | e99340dc4da5f3a86ae32a14ef318b0d8b8f20fd (patch) | |
tree | 07a8ed7971c703376d287e649da1e041a7a31552 /apps/files/js/operationprogressbar.js | |
parent | 296e69fe045363286cacdf37feccfde70d4f2444 (diff) | |
download | nextcloud-server-e99340dc4da5f3a86ae32a14ef318b0d8b8f20fd.tar.gz nextcloud-server-e99340dc4da5f3a86ae32a14ef318b0d8b8f20fd.zip |
Move progress bar to separate component
Signed-off-by: Tomasz Grobelny <tomasz@grobelny.net>
Diffstat (limited to 'apps/files/js/operationprogressbar.js')
-rw-r--r-- | apps/files/js/operationprogressbar.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/apps/files/js/operationprogressbar.js b/apps/files/js/operationprogressbar.js new file mode 100644 index 00000000000..1d96c2374d4 --- /dev/null +++ b/apps/files/js/operationprogressbar.js @@ -0,0 +1,73 @@ +/* + * 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']({ + textDesktop: t('Uploading …'), + textMobile: t('…'), + textCancelButton: t('Cancel operation') + })); + }, + + hideProgressBar: function() { + var self = this; + $('#uploadprogresswrapper .stop').fadeOut(); + $('#uploadprogressbar').fadeOut(function() { + self.$el.trigger(new $.Event('resized')); + }); + }, + + hideCancelButton: function() { + $('#uploadprogresswrapper .stop').fadeOut(function() { + this.$el.trigger(new $.Event('resized')); + }); + }, + + showProgressBar: function() { + $('#uploadprogresswrapper .stop').show(); + $('#uploadprogresswrapper .label').show(); + $('#uploadprogressbar').fadeIn(); + this.$el.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); + } + $('#uploadprogresswrapper .stop').show(); + }, + + _onClickCancel: function (event) { + this.trigger('cancel'); + return false; + } + }); + + OCA.Files.OperationProgressBar = OperationProgressBar; +})(OC, OCA); |