]>
Commit | Line | Data |
---|---|---|
f0cfe83e AD |
1 | define("dijit/form/HorizontalRule", [ |
2 | "dojo/_base/declare", // declare | |
3 | "../_Widget", | |
4 | "../_TemplatedMixin" | |
5 | ], function(declare, _Widget, _TemplatedMixin){ | |
6 | ||
7 | // module: | |
8 | // dijit/form/HorizontalRule | |
9 | ||
10 | ||
11 | return declare("dijit.form.HorizontalRule", [_Widget, _TemplatedMixin], { | |
12 | // summary: | |
13 | // Hash marks for `dijit/form/HorizontalSlider` | |
14 | ||
15 | templateString: '<div class="dijitRuleContainer dijitRuleContainerH"></div>', | |
16 | ||
17 | // count: Integer | |
18 | // Number of hash marks to generate | |
19 | count: 3, | |
20 | ||
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 | ||
26 | // ruleStyle: String | |
27 | // CSS style to apply to individual hash marks | |
28 | ruleStyle: "", | |
29 | ||
30 | _positionPrefix: '<div class="dijitRuleMark dijitRuleMarkH" style="left:', | |
31 | _positionSuffix: '%;', | |
32 | _suffix: '"></div>', | |
33 | ||
34 | _genHTML: function(pos){ | |
35 | return this._positionPrefix + pos + this._positionSuffix + this.ruleStyle + this._suffix; | |
36 | }, | |
37 | ||
38 | // _isHorizontal: [protected extension] Boolean | |
39 | // VerticalRule will override this... | |
40 | _isHorizontal: true, | |
41 | ||
42 | buildRendering: function(){ | |
43 | this.inherited(arguments); | |
44 | ||
45 | var innerHTML; | |
46 | if(this.count == 1){ | |
47 | innerHTML = this._genHTML(50, 0); | |
48 | }else{ | |
49 | var i; | |
50 | var interval = 100 / (this.count-1); | |
51 | if(!this._isHorizontal || this.isLeftToRight()){ | |
52 | innerHTML = this._genHTML(0, 0); | |
53 | for(i=1; i < this.count-1; i++){ | |
54 | innerHTML += this._genHTML(interval*i, i); | |
55 | } | |
56 | innerHTML += this._genHTML(100, this.count-1); | |
57 | }else{ | |
58 | innerHTML = this._genHTML(100, 0); | |
59 | for(i=1; i < this.count-1; i++){ | |
60 | innerHTML += this._genHTML(100-interval*i, i); | |
61 | } | |
62 | innerHTML += this._genHTML(0, this.count-1); | |
63 | } | |
64 | } | |
65 | this.domNode.innerHTML = innerHTML; | |
66 | } | |
67 | }); | |
68 | ||
69 | }); |