HorizontalRule.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. define("dijit/form/HorizontalRule", [
  2. "dojo/_base/declare", // declare
  3. "../_Widget",
  4. "../_TemplatedMixin"
  5. ], function(declare, _Widget, _TemplatedMixin){
  6. /*=====
  7. var _Widget = dijit._Widget;
  8. var _TemplatedMixin = dijit._TemplatedMixin;
  9. =====*/
  10. // module:
  11. // dijit/form/HorizontalRule
  12. // summary:
  13. // Hash marks for `dijit.form.HorizontalSlider`
  14. return declare("dijit.form.HorizontalRule", [_Widget, _TemplatedMixin], {
  15. // summary:
  16. // Hash marks for `dijit.form.HorizontalSlider`
  17. templateString: '<div class="dijitRuleContainer dijitRuleContainerH"></div>',
  18. // count: Integer
  19. // Number of hash marks to generate
  20. count: 3,
  21. // container: String
  22. // For HorizontalSlider, this is either "topDecoration" or "bottomDecoration",
  23. // and indicates whether this rule goes above or below the slider.
  24. container: "containerNode",
  25. // ruleStyle: String
  26. // CSS style to apply to individual hash marks
  27. ruleStyle: "",
  28. _positionPrefix: '<div class="dijitRuleMark dijitRuleMarkH" style="left:',
  29. _positionSuffix: '%;',
  30. _suffix: '"></div>',
  31. _genHTML: function(pos){
  32. return this._positionPrefix + pos + this._positionSuffix + this.ruleStyle + this._suffix;
  33. },
  34. // _isHorizontal: [protected extension] Boolean
  35. // VerticalRule will override this...
  36. _isHorizontal: true,
  37. buildRendering: function(){
  38. this.inherited(arguments);
  39. var innerHTML;
  40. if(this.count == 1){
  41. innerHTML = this._genHTML(50, 0);
  42. }else{
  43. var i;
  44. var interval = 100 / (this.count-1);
  45. if(!this._isHorizontal || this.isLeftToRight()){
  46. innerHTML = this._genHTML(0, 0);
  47. for(i=1; i < this.count-1; i++){
  48. innerHTML += this._genHTML(interval*i, i);
  49. }
  50. innerHTML += this._genHTML(100, this.count-1);
  51. }else{
  52. innerHTML = this._genHTML(100, 0);
  53. for(i=1; i < this.count-1; i++){
  54. innerHTML += this._genHTML(100-interval*i, i);
  55. }
  56. innerHTML += this._genHTML(0, this.count-1);
  57. }
  58. }
  59. this.domNode.innerHTML = innerHTML;
  60. }
  61. });
  62. });