]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/ProgressBar.js.uncompressed.js
update dojo to 1.7.3
[tt-rss.git] / lib / dijit / ProgressBar.js.uncompressed.js
1 require({cache:{
2 'url:dijit/templates/ProgressBar.html':"<div class=\"dijitProgressBar dijitProgressBarEmpty\" role=\"progressbar\"\n\t><div data-dojo-attach-point=\"internalProgress\" class=\"dijitProgressBarFull\"\n\t\t><div class=\"dijitProgressBarTile\" role=\"presentation\"></div\n\t\t><span style=\"visibility:hidden\">&#160;</span\n\t></div\n\t><div data-dojo-attach-point=\"labelNode\" class=\"dijitProgressBarLabel\" id=\"${id}_label\"></div\n\t><img data-dojo-attach-point=\"indeterminateHighContrastImage\" class=\"dijitProgressBarIndeterminateHighContrastImage\" alt=\"\"\n/></div>\n"}});
3 define("dijit/ProgressBar", [
4 "require", // require.toUrl
5 "dojo/_base/declare", // declare
6 "dojo/dom-class", // domClass.toggle
7 "dojo/_base/lang", // lang.mixin
8 "dojo/number", // number.format
9 "./_Widget",
10 "./_TemplatedMixin",
11 "dojo/text!./templates/ProgressBar.html"
12 ], function(require, declare, domClass, lang, number, _Widget, _TemplatedMixin, template){
13
14 /*=====
15 var _Widget = dijit._Widget;
16 var _TemplatedMixin = dijit._TemplatedMixin;
17 =====*/
18
19 // module:
20 // dijit/ProgressBar
21 // summary:
22 // A progress indication widget, showing the amount completed
23 // (often the percentage completed) of a task.
24
25
26 return declare("dijit.ProgressBar", [_Widget, _TemplatedMixin], {
27 // summary:
28 // A progress indication widget, showing the amount completed
29 // (often the percentage completed) of a task.
30 //
31 // example:
32 // | <div data-dojo-type="ProgressBar"
33 // | places="0"
34 // | value="..." maximum="...">
35 // | </div>
36
37 // progress: [const] String (Percentage or Number)
38 // Number or percentage indicating amount of task completed.
39 // Deprecated. Use "value" instead.
40 progress: "0",
41
42 // value: String (Percentage or Number)
43 // Number or percentage indicating amount of task completed.
44 // With "%": percentage value, 0% <= progress <= 100%, or
45 // without "%": absolute value, 0 <= progress <= maximum.
46 // Infinity means that the progress bar is indeterminate.
47 value: "",
48
49 // maximum: [const] Float
50 // Max sample number
51 maximum: 100,
52
53 // places: [const] Number
54 // Number of places to show in values; 0 by default
55 places: 0,
56
57 // indeterminate: [const] Boolean
58 // If false: show progress value (number or percentage).
59 // If true: show that a process is underway but that the amount completed is unknown.
60 // Deprecated. Use "value" instead.
61 indeterminate: false,
62
63 // label: String?
64 // Label on progress bar. Defaults to percentage for determinate progress bar and
65 // blank for indeterminate progress bar.
66 label:"",
67
68 // name: String
69 // this is the field name (for a form) if set. This needs to be set if you want to use
70 // this widget in a dijit.form.Form widget (such as dijit.Dialog)
71 name: '',
72
73 templateString: template,
74
75 // _indeterminateHighContrastImagePath: [private] URL
76 // URL to image to use for indeterminate progress bar when display is in high contrast mode
77 _indeterminateHighContrastImagePath:
78 require.toUrl("./themes/a11y/indeterminate_progress.gif"),
79
80 postMixInProperties: function(){
81 this.inherited(arguments);
82 if(!("value" in this.params)){
83 this.value = this.indeterminate ? Infinity : this.progress;
84 }
85 },
86
87 buildRendering: function(){
88 this.inherited(arguments);
89 this.indeterminateHighContrastImage.setAttribute("src",
90 this._indeterminateHighContrastImagePath.toString());
91 this.update();
92 },
93
94 update: function(/*Object?*/attributes){
95 // summary:
96 // Internal method to change attributes of ProgressBar, similar to set(hash). Users should call
97 // set("value", ...) rather than calling this method directly.
98 // attributes:
99 // May provide progress and/or maximum properties on this parameter;
100 // see attribute specs for details.
101 // example:
102 // | myProgressBar.update({'indeterminate': true});
103 // | myProgressBar.update({'progress': 80});
104 // | myProgressBar.update({'indeterminate': true, label:"Loading ..." })
105 // tags:
106 // private
107
108 // TODO: deprecate this method and use set() instead
109
110 lang.mixin(this, attributes || {});
111 var tip = this.internalProgress, ap = this.domNode;
112 var percent = 1;
113 if(this.indeterminate){
114 ap.removeAttribute("aria-valuenow");
115 ap.removeAttribute("aria-valuemin");
116 ap.removeAttribute("aria-valuemax");
117 }else{
118 if(String(this.progress).indexOf("%") != -1){
119 percent = Math.min(parseFloat(this.progress)/100, 1);
120 this.progress = percent * this.maximum;
121 }else{
122 this.progress = Math.min(this.progress, this.maximum);
123 percent = this.maximum ? this.progress / this.maximum : 0;
124 }
125
126 ap.setAttribute("aria-describedby", this.labelNode.id);
127 ap.setAttribute("aria-valuenow", this.progress);
128 ap.setAttribute("aria-valuemin", 0);
129 ap.setAttribute("aria-valuemax", this.maximum);
130 }
131 this.labelNode.innerHTML = this.report(percent);
132
133 domClass.toggle(this.domNode, "dijitProgressBarIndeterminate", this.indeterminate);
134 tip.style.width = (percent * 100) + "%";
135 this.onChange();
136 },
137
138 _setValueAttr: function(v){
139 this._set("value", v);
140 if(v == Infinity){
141 this.update({indeterminate:true});
142 }else{
143 this.update({indeterminate:false, progress:v});
144 }
145 },
146
147 _setLabelAttr: function(label){
148 this._set("label", label);
149 this.update();
150 },
151
152 _setIndeterminateAttr: function(indeterminate){
153 // Deprecated, use set("value", ...) instead
154 this.indeterminate = indeterminate;
155 this.update();
156 },
157
158 report: function(/*float*/percent){
159 // summary:
160 // Generates message to show inside progress bar (normally indicating amount of task completed).
161 // May be overridden.
162 // tags:
163 // extension
164
165 return this.label ? this.label :
166 (this.indeterminate ? "&#160;" : number.format(percent, { type: "percent", places: this.places, locale: this.lang }));
167 },
168
169 onChange: function(){
170 // summary:
171 // Callback fired when progress updates.
172 // tags:
173 // extension
174 }
175 });
176
177 });