zhuguifei
2026-03-10 2c1fd10c6fbabb8e9f0e9f07fe66fb36c008e883
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/**
    @name Edo.controls.Progress
    @class
    @typeName progress
    @description 进度条
    @extend Edo.core.UIComponent
*/
Edo.controls.Progress = function(){
    
    /**
        @name Edo.controls.Progress#progresschange
        @event
        @desction 进度改变事件
        @property {Number} progress 进度
        @property {String} text 进度文本
    */    
 
    Edo.controls.Progress.superclass.constructor.call(this);
};
Edo.controls.Progress.extend(Edo.core.UIComponent,{
    valueField: 'progress',
    defaultValue: 0,
 
    minWidth: 50,
    defaultWidth: 100,
    /**
        @name Edo.controls.Progress#showText
        @property
        @type Boolean
        @default true
        @description 是否显示文本
    */    
    showText: true,
    /**
        @name Edo.controls.Progress#progress
        @property
        @type Number
        @default 0(0~100)
        @description 进度值
    */
    progress: 0,
    /**
        @name Edo.controls.Progress#text
        @property
        @type String   
        @description 文本
    */
    text: '',
    
    elCls: 'e-progress e-div',
    _setProgress: function(value){
        if(value <0) value = 0;
        if(value > 100) value = 100;
        if(this.progress != value){
            this.progress = value;
            if(this.el){
                this.textEl.innerHTML = this.getProgressDesc();
                Edo.util.Dom.setWidth(this.progressEl, this.getProgressWidth());
            }
            this.changeProperty('progress');
            
            this.fireEvent('progresschange', {
                type: 'progresschange',
                source: this,
                progress: value,
                text: this.text
            });
        }
    },
    _setText: function(value){
        if(this.text != value){
            this.text = value;
            if(this.el){
                this.textEl.innerHTML =  this.getProgressDesc();
            }
            this.changeProperty('text');
        }
    },
    getProgressDesc: function(){        
        return this.showText ? this.progress+'% '+this.text : '&#160';
    },
    getProgressWidth: function(){
        return parseInt(this.realWidth * this.progress / 100) - 1;
    },
    getInnerHtml: function(sb){
        sb[sb.length] = '<div class="e-progress-bar"></div><div class="e-progress-text"></div>';
    },
    createChildren: function(el){
        Edo.controls.Label.superclass.createChildren.call(this, el);
        
        this.progressEl = this.el.firstChild;        
        this.textEl = this.el.lastChild;        
    }
});
 
Edo.controls.Progress.regType('progress');