root / trunk / web / dojo / dijit / ProgressBar.js @ 13
History | View | Annotate | Download (2.5 KB)
| 1 | 9 | andrej.cim | /*
|
|---|---|---|---|
| 2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
| 3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
| 4 | see: http://dojotoolkit.org/license for details
|
||
| 5 | */
|
||
| 6 | |||
| 7 | |||
| 8 | if(!dojo._hasResource["dijit.ProgressBar"]){ |
||
| 9 | dojo._hasResource["dijit.ProgressBar"]=true; |
||
| 10 | dojo.provide("dijit.ProgressBar");
|
||
| 11 | dojo.require("dojo.fx");
|
||
| 12 | dojo.require("dojo.number");
|
||
| 13 | dojo.require("dijit._Widget");
|
||
| 14 | dojo.require("dijit._Templated");
|
||
| 15 | dojo.declare("dijit.ProgressBar",[dijit._Widget,dijit._Templated],{progress:"0",maximum:100,places:0,indeterminate:false,name:"",templateString:dojo.cache("dijit","templates/ProgressBar.html","<div class=\"dijitProgressBar dijitProgressBarEmpty\"\n\t><div waiRole=\"progressbar\" 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=\"indeterminateHighContrastImage\" class=\"dijitProgressBarIndeterminateHighContrastImage\" alt=\"\"\n/></div>\n"),_indeterminateHighContrastImagePath:dojo.moduleUrl("dijit","themes/a11y/indeterminate_progress.gif"),postCreate:function(){ |
||
| 16 | this.inherited(arguments); |
||
| 17 | this.indeterminateHighContrastImage.setAttribute("src",this._indeterminateHighContrastImagePath.toString()); |
||
| 18 | this.update();
|
||
| 19 | },update:function(_1){ |
||
| 20 | dojo.mixin(this,_1||{});
|
||
| 21 | var _2=this.internalProgress; |
||
| 22 | var _3=1,_4; |
||
| 23 | if(this.indeterminate){ |
||
| 24 | _4="addClass";
|
||
| 25 | dijit.removeWaiState(_2,"valuenow");
|
||
| 26 | dijit.removeWaiState(_2,"valuemin");
|
||
| 27 | dijit.removeWaiState(_2,"valuemax");
|
||
| 28 | }else{
|
||
| 29 | _4="removeClass";
|
||
| 30 | if(String(this.progress).indexOf("%")!=-1){ |
||
| 31 | _3=Math.min(parseFloat(this.progress)/100,1); |
||
| 32 | this.progress=_3*this.maximum; |
||
| 33 | }else{
|
||
| 34 | this.progress=Math.min(this.progress,this.maximum); |
||
| 35 | _3=this.progress/this.maximum; |
||
| 36 | } |
||
| 37 | var _5=this.report(_3); |
||
| 38 | this.label.firstChild.nodeValue=_5;
|
||
| 39 | dijit.setWaiState(_2,"describedby",this.label.id); |
||
| 40 | dijit.setWaiState(_2,"valuenow",this.progress); |
||
| 41 | dijit.setWaiState(_2,"valuemin",0); |
||
| 42 | dijit.setWaiState(_2,"valuemax",this.maximum); |
||
| 43 | } |
||
| 44 | dojo[_4](this.domNode,"dijitProgressBarIndeterminate"); |
||
| 45 | _2.style.width=(_3*100)+"%"; |
||
| 46 | this.onChange();
|
||
| 47 | },_setValueAttr:function(v){ |
||
| 48 | if(v==Infinity){ |
||
| 49 | this.update({indeterminate:true}); |
||
| 50 | }else{
|
||
| 51 | this.update({indeterminate:false,progress:v}); |
||
| 52 | } |
||
| 53 | },_getValueAttr:function(){ |
||
| 54 | return this.progress; |
||
| 55 | },report:function(_6){ |
||
| 56 | return dojo.number.format(_6,{type:"percent",places:this.places,locale:this.lang}); |
||
| 57 | },onChange:function(){ |
||
| 58 | }}); |
||
| 59 | } |