Changeset 7501
- Timestamp:
- 03/01/07 08:17:08 (23 months ago)
- Location:
- dijit/trunk
- Files:
-
- 4 modified
-
ProgressBar.js (modified) (15 diffs)
-
templates/ProgressBar.html (modified) (1 diff)
-
tests/test_ProgressBar.html (modified) (3 diffs)
-
themes/tundra/tundra.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dijit/trunk/ProgressBar.js
r7490 r7501 23 23 // (4) higher z-index 24 24 // back and front percent label have the same content: when the vertical line (*) 25 // partially hides the back PercentLabel, the frontPercentLabel becomes visible25 // partially hides the backLabel, the frontLabel becomes visible 26 26 // 27 27 // ________________________(1)_containerNode_________________________________ 28 28 // |__(3)_internalProgress____________ | 29 29 // | | <--- (*) | 30 // | (4) front PercentLabel | (2) backPercentLabel |30 // | (4) frontLabel | (2) backLabel | 31 31 // |__________________________________| | 32 32 // |__________________________________________________________________________| … … 37 37 // places="0" width="..." height="..." dataSource="..." 38 38 // pollInterval="..." 39 // hasText="true|false" isVertical="true|false"39 // numeric="true|false" orientation="vertical" 40 40 // progress="..." maximum="..."></div> 41 41 42 // progress: String 42 // progress: String (Percentage or Number) 43 43 // initial progress value. 44 44 // with "%": percentual value, 0% <= progress <= 100% 45 45 // or without "%": absolute value, 0 <= progress <= maximum 46 progress: 0,47 46 progress: "0", 47 48 48 // maximum: Float 49 49 // max sample number … … 62 62 color: "", 63 63 64 // hasText: Boolean64 // numeric: Boolean 65 65 // if true, the percent label is visible 66 hasText: false,67 68 // isVertical: Boolean69 // if true, the widget is vertical70 isVertical: false,66 numeric: false, 67 68 // orientation: String 69 // whether bar grows along the x-axis (default) or y- axis (vertical) 70 orientation: "", 71 71 72 72 // places: Number … … 100 100 } 101 101 dojo.html.setClass(this.containerNode, "dojoProgressBarEmpty"); 102 if(this. isVertical){102 if(this.orientation == "vertical"){ 103 103 dojo.html.addClass(this.containerNode, "dojoProgressBarVertical"); 104 104 this.internalProgress.style.bottom="0px"; … … 110 110 this._dimension = "width"; 111 111 } 112 dojo.html.setClass(this.frontPercentLabel, "dojoProgressBarFrontPercent");113 dojo.html.setClass(this.backPercentLabel, "dojoProgressBarBackPercent");114 112 this.domNode.style.height = this.height + "px"; 115 113 this.domNode.style.width = this.width + "px"; 116 114 this.setMaximum(this.maximum, true); 117 115 this.setProgress(this.progress, true); 118 this.showText(this.hasText); 119 116 this.showLabel(this.numeric); 120 117 this.render(); 121 118 }, 122 show Text: function(/*Boolean*/visible){119 showLabel: function(/*Boolean*/visible){ 123 120 // summary: shows or hides the labels 124 121 var display = visible ? "block" : "none"; 125 this.back PercentLabel.style.display=display;126 this.front PercentLabel.style.display=display;127 this. hasText= visible;122 this.backLabel.style.display=display; 123 this.frontLabel.style.display=display; 124 this.numeric = visible; 128 125 }, 129 126 _setupAnimation: function(){ 130 var _self = this;127 var self = this; 131 128 this._animation = dojo.lfx.html.slideTo(this.internalProgress, 132 129 {top: 0, left: parseInt(this.width)-parseInt(this.internalProgress.style.width)}, parseInt(this.duration), null, 133 130 function(){ 134 var _backAnim = dojo.lfx.html.slideTo( _self.internalProgress,135 { top: 0, left: 0 }, parseInt( _self.duration));131 var _backAnim = dojo.lfx.html.slideTo(self.internalProgress, 132 { top: 0, left: 0 }, parseInt(self.duration)); 136 133 dojo.event.connect(_backAnim, "onEnd", function(){ 137 if(! _self._animationStopped){138 _self._animation.play();134 if(!self._animationStopped){ 135 self._animation.play(); 139 136 } 140 137 }); 141 if(! _self._animationStopped){138 if(!self._animationStopped){ 142 139 _backAnim.play(); 143 140 } … … 146 143 ); 147 144 }, 148 setMaximum: function( maxValue,noRender){145 setMaximum: function(/*Number*/maximum, /*Boolean?*/noRender){ 149 146 // summary: sets the maximum 150 147 // if noRender is true, only sets the internal max progress value … … 152 149 return; 153 150 } 154 this.maximum = max Value;151 this.maximum = maximum; 155 152 this.setProgress(this.progress, true); 156 153 if(!noRender){ … … 158 155 } 159 156 }, 160 setProgress: function(/*String|Number*/value, /*Boolean */noRender){157 setProgress: function(/*String|Number*/value, /*Boolean?*/noRender){ 161 158 // summary: sets the progress 162 159 // if value ends width "%", does a normalization … … 166 163 return; 167 164 } 168 169 165 if(String(value).indexOf("%") != -1){ 170 166 this._percent = Math.min(parseFloat(value)/100, 1); … … 187 183 // the user doesn't know how much time the operation will last 188 184 if(this._animationStopped){ 189 this._backup = {progress: this.progress, hasText: this.hasText};185 this._backup = {progress: this.progress, numeric: this.numeric}; 190 186 this.setProgress("10%"); 191 187 this._animationStopped = false; 192 188 this._setupAnimation(); 193 this.show Text(false);189 this.showLabel(false); 194 190 this.internalProgress.style.height="105%"; 195 191 this._animation.play(); … … 205 201 dojo.lang.mixin(this, this._backup); 206 202 this.setProgress(this.progress); 207 this.show Text(this.hasText);208 this._position PercentLabels();203 this.showLabel(this.numeric); 204 this._positionLabels(); 209 205 } 210 206 }, 211 207 _showRemoteProgress: function(){ 212 var _self = this; 213 if((this.maximum == this.progress) && 214 this._timer){ 208 var self = this; 209 if((this.maximum == this.progress) && this._timer){ 215 210 clearInterval(this._timer); 216 211 this._timer = null; … … 219 214 } 220 215 var bArgs = { 221 url: _self.dataSource,216 url: self.dataSource, 222 217 method: "POST", 223 218 mimetype: "text/json", … … 226 221 }, 227 222 load: function(type, data, evt){ 228 _self.setProgress(_self._timer ? data.progress : "100%");223 self.setProgress(self._timer ? data.progress : "100%"); 229 224 } 230 225 }; … … 235 230 // summary: renders the ProgressBar, based on current values 236 231 237 this._update PercentLabels(this._percent);232 this._updateLabels(this._percent); 238 233 239 234 var pixels = this._percent * this[this._dimension]; … … 241 236 this.onChange(); 242 237 243 this._positionPercentLabels(); 244 }, 245 246 _positionPercentLabels: function(){ 247 var front = dojo.html.getContentBox(this.frontPercentLabel); 248 var frontLeft = (this.width - front.width)/2; 249 var frontBottom = (this.height - front.height)/2; 250 this.frontPercentLabel.style.left = frontLeft + "px"; 251 this.frontPercentLabel.style.bottom = frontBottom + "px"; 252 var back = dojo.html.getContentBox(this.backPercentLabel); 253 var backLeft = (this.width - back.width)/2; 254 var backBottom = (this.height - back.height)/2; 255 this.backPercentLabel.style.left = backLeft + "px"; 256 this.backPercentLabel.style.bottom = backBottom + "px"; 257 }, 258 _updatePercentLabels: function(/*float*/percentValue){ 238 this._positionLabels(); 239 }, 240 241 _positionLabels: function(){ 259 242 dojo.lang.forEach(["front", "back"], function(name){ 260 var labelNode = this[name+"PercentLabel"]; 261 dojo.dom.textContent(labelNode, dojo.number.format(percentValue, {type: "percent", places: this.places})); 243 var labelNode = this[name+"Label"]; 244 var dim = dojo.html.getContentBox(labelNode); 245 var labelLeft = (this.width - dim.width)/2; 246 var labelBottom = (this.height - dim.height)/2; 247 labelNode.style.left = labelLeft + "px"; 248 labelNode.style.bottom = labelBottom + "px"; 249 }, this); 250 }, 251 _updateLabels: function(/*float*/percent){ 252 dojo.lang.forEach(["front", "back"], function(name){ 253 var labelNode = this[name+"Label"]; 254 dojo.dom.textContent(labelNode, dojo.number.format(percent, {type: "percent", places: this.places})); 262 255 }, this); 263 256 }, -
dijit/trunk/templates/ProgressBar.html
r7482 r7501 1 1 <div dojoAttachPoint="containerNode"> 2 <div style="position:absolute;display:none;width:100%;text-align:center" dojoAttachPoint="back PercentLabel" class="dojoBackPercentLabel"></div>2 <div style="position:absolute;display:none;width:100%;text-align:center" dojoAttachPoint="backLabel" class="dojoProgressBarBackLabel"></div> 3 3 <div style="position:absolute;overflow:hidden;width:100%;height:100%" dojoAttachPoint="internalProgress"> 4 <div style="position:absolute;display:none;width:100%;text-align:center" dojoAttachPoint="front PercentLabel" class="dojoFrontPercentLabel"></div></div>4 <div style="position:absolute;display:none;width:100%;text-align:center" dojoAttachPoint="frontLabel" class="dojoProgressBarFrontLabel"></div></div> 5 5 </div> -
dijit/trunk/tests/test_ProgressBar.html
r7490 r7501 69 69 <input type="button" name="set" id="set" value="set!" /> 70 70 <br /> 71 <div width="400" hasText="true"71 <div width="400" numeric="true" 72 72 maximum="200" id="setTestBar" progress="20" dojoType="dijit.ProgressBar"></div> 73 73 <br /> … … 77 77 <br /> 78 78 <br /> 79 <div width="400" hasText="true"79 <div width="400" numeric="true" 80 80 maximum="256" id="testBar" duration="2000" dojoType="dijit.ProgressBar"></div> 81 81 <input type="button" name="start" id="start" value="start" /> … … 84 84 Small, without text and background image: 85 85 <br /> 86 <div width="440" height="10" color="red" hasText="false" isVertical="false"86 <div width="440" height="10" color="red" orientation="horizontal" 87 87 maximum="256" id="smallTestBar" dojoType="dijit.ProgressBar"></div> 88 88 <br /> 89 89 Show decimal place: 90 <div places="1" width="400" hasText="true" isVertical="false"90 <div places="1" width="400" numeric="true" orientation="horizontal" 91 91 maximum="256" id="testBarInt" dojoType="dijit.ProgressBar"></div> 92 92 <br /> 93 93 <div style="position:absolute;top:70px;left:530px"> 94 94 Vertical: 95 <div progress="0" height="420" width="50" hasText="true" isVertical="true"95 <div progress="0" height="420" width="50" numeric="true" orientation="vertical" 96 96 maximum="256" id="testBar2" dojoType="dijit.ProgressBar"></div> 97 97 </div> 98 <h3>Test 3</h3> 99 No explicit maximum (both 25%) 100 <div width="400" numeric="true" 101 id="implied1" progress="25" dojoType="dijit.ProgressBar"></div> 102 <div width="400" numeric="true" 103 id="implied2" progress="25%" dojoType="dijit.ProgressBar"></div> 98 104 </body> 99 105 </html> 100 -
dijit/trunk/themes/tundra/tundra.css
r7490 r7501 149 149 } 150 150 151 .dojoProgressBarSimpleFrontBar{ 152 background: red; 153 } 154 155 .dojoProgressBarFrontPercent,.dojoProgressBarBackPercent{ 151 .dojoProgressBarFrontLabel,.dojoProgressBarBackLabel{ 156 152 font:bold 13px helvetica; 157 153 } 158 154 159 .dojoProgressBarBack Percent{155 .dojoProgressBarBackLabel{ 160 156 color:#293a4b; 161 157 } 162 .dojoProgressBarFront Percent{158 .dojoProgressBarFrontLabel{ 163 159 color:#fff; 164 160 }