1 if(!dojo._hasResource["dijit.ProgressBar"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dijit.ProgressBar"] = true;
3 dojo.provide("dijit.ProgressBar");
5 dojo.require("dojo.fx");
6 dojo.require("dojo.number");
8 dojo.require("dijit._Widget");
9 dojo.require("dijit._Templated");
11 dojo.declare("dijit.ProgressBar", [dijit._Widget, dijit._Templated], {
12 // summary: A progress indication widget
15 // | <div dojoType="ProgressBar"
17 // | progress="..." maximum="...">
20 // progress: String (Percentage or Number)
21 // initial progress value.
22 // with "%": percentage value, 0% <= progress <= 100%
23 // or without "%": absolute value, 0 <= progress <= maximum
31 // number of places to show in values; 0 by default
34 // indeterminate: Boolean
35 // If false: show progress.
36 // If true: show that a process is underway but that the progress is unknown
39 templateString:"<div class=\"dijitProgressBar dijitProgressBarEmpty\"\n\t><div waiRole=\"progressbar\" tabindex=\"0\" dojoAttachPoint=\"internalProgress\" class=\"dijitProgressBarFull\"\n\t\t><div class=\"dijitProgressBarTile\"></div\n\t\t><span style=\"visibility:hidden\"> </span\n\t></div\n\t><div dojoAttachPoint=\"label\" class=\"dijitProgressBarLabel\" id=\"${id}_label\"> </div\n\t><img dojoAttachPoint=\"inteterminateHighContrastImage\" class=\"dijitProgressBarIndeterminateHighContrastImage\"\n\t></img\n></div>\n",
41 _indeterminateHighContrastImagePath:
42 dojo.moduleUrl("dijit", "themes/a11y/indeterminate_progress.gif"),
45 postCreate: function(){
46 this.inherited("postCreate",arguments);
47 this.inteterminateHighContrastImage.setAttribute("src",
48 this._indeterminateHighContrastImagePath);
52 update: function(/*Object?*/attributes){
53 // summary: update progress information
55 // attributes: may provide progress and/or maximum properties on this parameter,
56 // see attribute specs for details.
57 dojo.mixin(this, attributes||{});
58 var percent = 1, classFunc;
59 if(this.indeterminate){
60 classFunc = "addClass";
61 dijit.removeWaiState(this.internalProgress, "valuenow");
62 dijit.removeWaiState(this.internalProgress, "valuemin");
63 dijit.removeWaiState(this.internalProgress, "valuemax");
65 classFunc = "removeClass";
66 if(String(this.progress).indexOf("%") != -1){
67 percent = Math.min(parseFloat(this.progress)/100, 1);
68 this.progress = percent * this.maximum;
70 this.progress = Math.min(this.progress, this.maximum);
71 percent = this.progress / this.maximum;
73 var text = this.report(percent);
74 this.label.firstChild.nodeValue = text;
75 dijit.setWaiState(this.internalProgress, "describedby", this.label.id);
76 dijit.setWaiState(this.internalProgress, "valuenow", this.progress);
77 dijit.setWaiState(this.internalProgress, "valuemin", 0);
78 dijit.setWaiState(this.internalProgress, "valuemax", this.maximum);
80 dojo[classFunc](this.domNode, "dijitProgressBarIndeterminate");
81 this.internalProgress.style.width = (percent * 100) + "%";
85 report: function(/*float*/percent){
86 // Generates message to show; may be overridden by user
87 return dojo.number.format(percent, {type: "percent", places: this.places, locale: this.lang});
91 // summary: User definable function fired when progress updates.