2fb47027fe65a9ae22b38d5ecd65df5e83f8611a.svn-base 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. if (!dojo._hasResource["dijit.ProgressBar"]) { // _hasResource checks added by
  2. // build. Do not use
  3. // _hasResource directly in your
  4. // code.
  5. dojo._hasResource["dijit.ProgressBar"] = true;
  6. dojo.provide("dijit.ProgressBar");
  7. dojo.require("dojo.fx");
  8. dojo.require("dojo.number");
  9. dojo.require("dijit._Widget");
  10. dojo.require("dijit._Templated");
  11. dojo.declare("dijit.ProgressBar", [dijit._Widget, dijit._Templated], {
  12. // summary:
  13. // a progress widget
  14. //
  15. // usage:
  16. // <div dojoType="ProgressBar"
  17. // places="0"
  18. // progress="..." maximum="..."></div>
  19. // progress: String (Percentage or Number)
  20. // initial progress value.
  21. // with "%": percentage value, 0% <= progress <= 100%
  22. // or without "%": absolute value, 0 <= progress <= maximum
  23. progress : "0",
  24. // maximum: Float
  25. // max sample number
  26. maximum : 100,
  27. // places: Number
  28. // number of places to show in values; 0 by default
  29. places : 0,
  30. // indeterminate: Boolean
  31. // false: show progress
  32. // true: show that a process is underway but that the progress is
  33. // unknown
  34. indeterminate : false,
  35. 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\">&nbsp;</span\n\t></div\n\t><div dojoAttachPoint=\"label\" class=\"dijitProgressBarLabel\" id=\"${id}_label\">&nbsp;</div\n\t><img dojoAttachPoint=\"inteterminateHighContrastImage\" class=\"dijitProgressBarIndeterminateHighContrastImage\"\n\t></img\n></div>\n",
  36. _indeterminateHighContrastImagePath : dojo.moduleUrl("dijit",
  37. "themes/a11y/indeterminate_progress.gif"),
  38. // public functions
  39. postCreate : function() {
  40. this.inherited("postCreate", arguments);
  41. this.inteterminateHighContrastImage.setAttribute("src",
  42. this._indeterminateHighContrastImagePath);
  43. this.update();
  44. },
  45. update : function(/* Object? */attributes) {
  46. // summary: update progress information
  47. //
  48. // attributes: may provide progress and/or maximum properties on
  49. // this parameter,
  50. // see attribute specs for details.
  51. dojo.mixin(this, attributes || {});
  52. var percent = 1, classFunc;
  53. if (this.indeterminate) {
  54. classFunc = "addClass";
  55. dijit.removeWaiState(this.internalProgress, "valuenow");
  56. dijit.removeWaiState(this.internalProgress, "valuemin");
  57. dijit.removeWaiState(this.internalProgress, "valuemax");
  58. } else {
  59. classFunc = "removeClass";
  60. if (String(this.progress).indexOf("%") != -1) {
  61. percent = Math.min(parseFloat(this.progress) / 100, 1);
  62. this.progress = percent * this.maximum;
  63. } else {
  64. this.progress = Math.min(this.progress, this.maximum);
  65. percent = this.progress / this.maximum;
  66. }
  67. var text = this.report(percent);
  68. this.label.firstChild.nodeValue = text;
  69. dijit.setWaiState(this.internalProgress, "describedby",
  70. this.label.id);
  71. dijit.setWaiState(this.internalProgress, "valuenow",
  72. this.progress);
  73. dijit.setWaiState(this.internalProgress, "valuemin", 0);
  74. dijit.setWaiState(this.internalProgress, "valuemax",
  75. this.maximum);
  76. }
  77. dojo[classFunc](this.domNode, "dijitProgressBarIndeterminate");
  78. this.internalProgress.style.width = (percent * 100) + "%";
  79. this.onChange();
  80. },
  81. report : function(/* float */percent) {
  82. // Generates message to show; may be overridden by user
  83. return dojo.number.format(percent, {
  84. type : "percent",
  85. places : this.places,
  86. locale : this.lang
  87. });
  88. },
  89. onChange : function() {
  90. }
  91. });
  92. }