diff options
Diffstat (limited to 'pyload/web/app/scripts')
-rw-r--r-- | pyload/web/app/scripts/views/dashboard/fileView.js | 21 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/headerView.js | 7 |
2 files changed, 16 insertions, 12 deletions
diff --git a/pyload/web/app/scripts/views/dashboard/fileView.js b/pyload/web/app/scripts/views/dashboard/fileView.js index ed2d2ea40..8b461454f 100644 --- a/pyload/web/app/scripts/views/dashboard/fileView.js +++ b/pyload/web/app/scripts/views/dashboard/fileView.js @@ -18,7 +18,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'views/abst this.listenTo(this.model, 'change', this.render); // This will be triggered manually and changed before with silent=true this.listenTo(this.model, 'change:visible', this.visibility_changed); - this.listenTo(this.model, 'change:progress', this.progress_changed); + this.listenTo(this.model, 'change:progress', this.onProgressChanged); this.listenTo(this.model, 'remove', this.unrender); this.listenTo(App.vent, 'dashboard:destroyContent', this.destroy); }, @@ -77,17 +77,26 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'views/abst } }, - progress_changed: function() { + onProgressChanged: function(prog) { // TODO: progress for non download statuses if (!this.model.isDownload()) return; + // criteria for re-rendering + // ensure that the dl bar is rendered + var render = !this.$('.progress .bar') || this.model.get('size') !== prog.get('total'); + + this.model.set({ + progress: prog.getPercent(), + eta: prog.get('eta'), + size: prog.get('total') + }, {silent: true}); + if (this.model.get('download').status === Api.DownloadStatus.Downloading) { - var bar = this.$('.progress .bar'); - if (!bar) { // ensure that the dl bar is rendered + if (render) this.render(); - bar = this.$('.progress .bar'); - } + + var bar = this.$('.progress .bar'); bar.width(this.model.get('progress') + '%'); bar.html(' ' + formatTime(this.model.get('eta'))); diff --git a/pyload/web/app/scripts/views/headerView.js b/pyload/web/app/scripts/views/headerView.js index 1fad32642..49298d450 100644 --- a/pyload/web/app/scripts/views/headerView.js +++ b/pyload/web/app/scripts/views/headerView.js @@ -233,13 +233,8 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle if (prog.isDownload() && App.dashboard.files) { var file = App.dashboard.files.get(prog.get('download').fid); if (file) { - file.set({ - progress: prog.getPercent(), - eta: prog.get('eta'), - size: prog.get('total') - }, {silent: true}); file.setDownloadStatus(prog.get('download').status); - file.trigger('change:progress'); + file.trigger('change:progress', prog); } } }); |