]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/form/HorizontalRuleLabels.js.uncompressed.js
update dojo to 1.7.3
[tt-rss.git] / lib / dijit / form / HorizontalRuleLabels.js.uncompressed.js
1 define("dijit/form/HorizontalRuleLabels", [
2 "dojo/_base/declare", // declare
3 "dojo/number", // number.format
4 "dojo/query", // query
5 "./HorizontalRule"
6 ], function(declare, number, query, HorizontalRule){
7
8 /*=====
9 var HorizontalRule = dijit.form.HorizontalRule;
10 =====*/
11
12 // module:
13 // dijit/form/HorizontalRuleLabels
14 // summary:
15 // Labels for `dijit.form.HorizontalSlider`
16
17 return declare("dijit.form.HorizontalRuleLabels", HorizontalRule, {
18 // summary:
19 // Labels for `dijit.form.HorizontalSlider`
20
21 templateString: '<div class="dijitRuleContainer dijitRuleContainerH dijitRuleLabelsContainer dijitRuleLabelsContainerH"></div>',
22
23 // labelStyle: String
24 // CSS style to apply to individual text labels
25 labelStyle: "",
26
27 // labels: String[]?
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.
30 labels: [],
31
32 // numericMargin: Integer
33 // Number of generated numeric labels that should be rendered as '' on the ends when labels[] are not specified
34 numericMargin: 0,
35
36 // numericMinimum: Integer
37 // Leftmost label value for generated numeric labels when labels[] are not specified
38 minimum: 0,
39
40 // numericMaximum: Integer
41 // Rightmost label value for generated numeric labels when labels[] are not specified
42 maximum: 1,
43
44 // constraints: Object
45 // pattern, places, lang, et al (see dojo.number) for generated numeric labels when labels[] are not specified
46 constraints: {pattern:"#%"},
47
48 _positionPrefix: '<div class="dijitRuleLabelContainer dijitRuleLabelContainerH" style="left:',
49 _labelPrefix: '"><div class="dijitRuleLabel dijitRuleLabelH">',
50 _suffix: '</div></div>',
51
52 _calcPosition: function(pos){
53 // summary:
54 // Returns the value to be used in HTML for the label as part of the left: attribute
55 // tags:
56 // protected extension
57 return pos;
58 },
59
60 _genHTML: function(pos, ndx){
61 return this._positionPrefix + this._calcPosition(pos) + this._positionSuffix + this.labelStyle + this._labelPrefix + this.labels[ndx] + this._suffix;
62 },
63
64 getLabels: function(){
65 // summary:
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.
68 // tags:
69 // protected extension
70
71 // if the labels array was not specified directly, then see if <li> children were
72 var labels = this.labels;
73 if(!labels.length){
74 // for markup creation, labels are specified as child elements
75 labels = query("> li", this.srcNodeRef).map(function(node){
76 return String(node.innerHTML);
77 });
78 }
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));
86 start += inc;
87 }
88 }
89 return labels;
90 },
91
92 postMixInProperties: function(){
93 this.inherited(arguments);
94 this.labels = this.getLabels();
95 this.count = this.labels.length;
96 }
97 });
98
99 });