]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/HorizontalRuleLabels.js.uncompressed.js
1 define("dijit/form/HorizontalRuleLabels", [
2 "dojo/_base/declare", // declare
3 "dojo/number", // number.format
6 ], function(declare
, number
, query
, HorizontalRule
){
9 var HorizontalRule = dijit.form.HorizontalRule;
13 // dijit/form/HorizontalRuleLabels
15 // Labels for `dijit.form.HorizontalSlider`
17 return declare("dijit.form.HorizontalRuleLabels", HorizontalRule
, {
19 // Labels for `dijit.form.HorizontalSlider`
21 templateString
: '<div class="dijitRuleContainer dijitRuleContainerH dijitRuleLabelsContainer dijitRuleLabelsContainerH"></div>',
24 // CSS style to apply to individual text labels
28 // Array of text labels to render - evenly spaced from left-to-right or bottom-to-top.
29 // Alternately, minimum and maximum can be specified, to get numeric labels.
32 // numericMargin: Integer
33 // Number of generated numeric labels that should be rendered as '' on the ends when labels[] are not specified
36 // numericMinimum: Integer
37 // Leftmost label value for generated numeric labels when labels[] are not specified
40 // numericMaximum: Integer
41 // Rightmost label value for generated numeric labels when labels[] are not specified
44 // constraints: Object
45 // pattern, places, lang, et al (see dojo.number) for generated numeric labels when labels[] are not specified
46 constraints
: {pattern
:"#%"},
48 _positionPrefix
: '<div class="dijitRuleLabelContainer dijitRuleLabelContainerH" style="left:',
49 _labelPrefix
: '"><div class="dijitRuleLabel dijitRuleLabelH">',
50 _suffix
: '</div></div>',
52 _calcPosition: function(pos
){
54 // Returns the value to be used in HTML for the label as part of the left: attribute
56 // protected extension
60 _genHTML: function(pos
, ndx
){
61 return this._positionPrefix
+ this._calcPosition(pos
) + this._positionSuffix
+ this.labelStyle
+ this._labelPrefix
+ this.labels
[ndx
] + this._suffix
;
64 getLabels: function(){
66 // Overridable function to return array of labels to use for this slider.
67 // Can specify a getLabels() method instead of a labels[] array, or min/max attributes.
69 // protected extension
71 // if the labels array was not specified directly, then see if <li> children were
72 var labels
= this.labels
;
74 // for markup creation, labels are specified as child elements
75 labels
= query("> li", this.srcNodeRef
).map(function(node
){
76 return String(node
.innerHTML
);
79 this.srcNodeRef
.innerHTML
= '';
80 // if the labels were not specified directly and not as <li> children, then calculate numeric labels
81 if(!labels
.length
&& this.count
> 1){
82 var start
= this.minimum
;
83 var inc
= (this.maximum
- start
) / (this.count
-1);
84 for(var i
=0; i
< this.count
; i
++){
85 labels
.push((i
< this.numericMargin
|| i
>= (this.count
-this.numericMargin
)) ? '' : number
.format(start
, this.constraints
));
92 postMixInProperties: function(){
93 this.inherited(arguments
);
94 this.labels
= this.getLabels();
95 this.count
= this.labels
.length
;