1
0

operationprogressbar.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright (c) 2018
  3. *
  4. * This file is licensed under the Affero General Public License version 3
  5. * or later.
  6. *
  7. * See the COPYING-README file.
  8. *
  9. */
  10. (function() {
  11. var OperationProgressBar = OC.Backbone.View.extend({
  12. tagName: 'div',
  13. id: 'uploadprogresswrapper',
  14. events: {
  15. 'click button.stop': '_onClickCancel'
  16. },
  17. render: function() {
  18. this.$el.html(OCA.Files.Templates['operationprogressbar']({
  19. textCancelButton: t('Cancel operation')
  20. }));
  21. this.setProgressBarText(t('Uploading …'), t('…'));
  22. },
  23. hideProgressBar: function() {
  24. var self = this;
  25. $('#uploadprogresswrapper .stop').fadeOut();
  26. $('#uploadprogressbar').fadeOut(function() {
  27. self.$el.trigger(new $.Event('resized'));
  28. });
  29. },
  30. hideCancelButton: function() {
  31. var self = this;
  32. $('#uploadprogresswrapper .stop').fadeOut(function() {
  33. self.$el.trigger(new $.Event('resized'));
  34. });
  35. },
  36. showProgressBar: function(showCancelButton) {
  37. if (showCancelButton) {
  38. showCancelButton = true;
  39. }
  40. $('#uploadprogressbar').progressbar({value: 0});
  41. if(showCancelButton) {
  42. $('#uploadprogresswrapper .stop').show();
  43. } else {
  44. $('#uploadprogresswrapper .stop').hide();
  45. }
  46. $('#uploadprogresswrapper .label').show();
  47. $('#uploadprogressbar').fadeIn();
  48. this.$el.trigger(new $.Event('resized'));
  49. },
  50. setProgressBarValue: function(value) {
  51. $('#uploadprogressbar').progressbar({value: value});
  52. },
  53. setProgressBarText: function(textDesktop, textMobile, title) {
  54. var labelHtml = OCA.Files.Templates['operationprogressbarlabel']({textDesktop: textDesktop, textMobile: textMobile});
  55. $('#uploadprogressbar .ui-progressbar-value').html(labelHtml);
  56. $('#uploadprogressbar .ui-progressbar-value>em').addClass('inner');
  57. $('#uploadprogressbar>em').replaceWith(labelHtml);
  58. $('#uploadprogressbar>em').addClass('outer');
  59. if (title) {
  60. $('#uploadprogressbar').attr('title', title);
  61. $('#uploadprogresswrapper .tooltip-inner').text(title);
  62. }
  63. if(textDesktop || textMobile) {
  64. $('#uploadprogresswrapper .stop').show();
  65. }
  66. },
  67. _onClickCancel: function (event) {
  68. this.trigger('cancel');
  69. return false;
  70. }
  71. });
  72. OCA.Files.OperationProgressBar = OperationProgressBar;
  73. })(OC, OCA);