From 7279755f24851d6d6cc5903100ca9858c1358fe8 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Fri, 20 Feb 2009 22:19:59 +0000 Subject: [PATCH] add a subclass of Ext.ProgressBar that allows for a percentage value to be used --- deluge/ui/web/js/deluge-details.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/deluge/ui/web/js/deluge-details.js b/deluge/ui/web/js/deluge-details.js index 02f51c840..3f6c83503 100644 --- a/deluge/ui/web/js/deluge-details.js +++ b/deluge/ui/web/js/deluge-details.js @@ -1,16 +1,34 @@ Deluge.Details = {} -/*Deluge.ProgressBar = Ext.extend(Ext.ProgressBar, { +Deluge.ProgressBar = Ext.extend(Ext.ProgressBar, { initComponent: function() { - Deluge.ProgressBar.superClass.initComponent.call(this); + Deluge.ProgressBar.superclass.initComponent.call(this); + }, + + updateProgress: function(value, text, animate) { + this.value = value || 0; + if (text) { + this.updateText(text); + } + + if (this.rendered) { + var w = Math.floor(value*this.el.dom.firstChild.offsetWidth / 100.0); + this.progressBar.setWidth(w, animate === true || (animate !== false && this.animate)); + if(this.textTopEl){ + //textTopEl should be the same width as the bar so overflow will clip as the bar moves + this.textTopEl.removeClass('x-hidden').setWidth(w); + } + } + this.fireEvent('update', this, value, text); + return this; } }); -Ext.reg('deluge-progress', Deluge.ProgressBar);*/ +Ext.reg('deluge-progress', Deluge.ProgressBar); Deluge.Details.Status = { onRender: function(panel) { this.panel = panel; - this.progressBar = new Ext.ProgressBar({ + this.progressBar = new Deluge.ProgressBar({ id: 'pbar-status', cls: 'deluge-status-progressbar' });