]>
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 // dijit/form/HorizontalRuleLabels
11 return declare("dijit.form.HorizontalRuleLabels", HorizontalRule
, {
13 // Labels for `dijit/form/HorizontalSlider`
15 templateString
: '<div class="dijitRuleContainer dijitRuleContainerH dijitRuleLabelsContainer dijitRuleLabelsContainerH"></div>',
18 // CSS style to apply to individual text labels
22 // Array of text labels to render - evenly spaced from left-to-right or bottom-to-top.
23 // Alternately, minimum and maximum can be specified, to get numeric labels.
26 // numericMargin: Integer
27 // Number of generated numeric labels that should be rendered as '' on the ends when labels[] are not specified
30 // numericMinimum: Integer
31 // Leftmost label value for generated numeric labels when labels[] are not specified
34 // numericMaximum: Integer
35 // Rightmost label value for generated numeric labels when labels[] are not specified
38 // constraints: Object
39 // pattern, places, lang, et al (see dojo.number) for generated numeric labels when labels[] are not specified
40 constraints
: {pattern
:"#%"},
42 _positionPrefix
: '<div class="dijitRuleLabelContainer dijitRuleLabelContainerH" style="left:',
43 _labelPrefix
: '"><div class="dijitRuleLabel dijitRuleLabelH">',
44 _suffix
: '</div></div>',
46 _calcPosition: function(pos
){
48 // Returns the value to be used in HTML for the label as part of the left: attribute
50 // protected extension
54 _genHTML: function(pos
, ndx
){
55 return this._positionPrefix
+ this._calcPosition(pos
) + this._positionSuffix
+ this.labelStyle
+ this._labelPrefix
+ this.labels
[ndx
] + this._suffix
;
58 getLabels: function(){
60 // Overridable function to return array of labels to use for this slider.
61 // Can specify a getLabels() method instead of a labels[] array, or min/max attributes.
63 // protected extension
65 // if the labels array was not specified directly, then see if <li> children were
66 var labels
= this.labels
;
67 if(!labels
.length
&& this.srcNodeRef
){
68 // for markup creation, labels are specified as child elements
69 labels
= query("> li", this.srcNodeRef
).map(function(node
){
70 return String(node
.innerHTML
);
73 // if the labels were not specified directly and not as <li> children, then calculate numeric labels
74 if(!labels
.length
&& this.count
> 1){
75 var start
= this.minimum
;
76 var inc
= (this.maximum
- start
) / (this.count
-1);
77 for(var i
=0; i
< this.count
; i
++){
78 labels
.push((i
< this.numericMargin
|| i
>= (this.count
-this.numericMargin
)) ? '' : number
.format(start
, this.constraints
));
85 postMixInProperties: function(){
86 this.inherited(arguments
);
87 this.labels
= this.getLabels();
88 this.count
= this.labels
.length
;