HorizontalRule.js 2.1 KB

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