summaryrefslogtreecommitdiff
path: root/lib/dijit/form/HorizontalRuleLabels.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-11-08 20:40:44 +0400
committerAndrew Dolgov <[email protected]>2011-11-08 20:40:44 +0400
commit81bea17aefb26859f825b9293c7c99192874806e (patch)
treefb244408ca271affa2899adb634788802c9a89d8 /lib/dijit/form/HorizontalRuleLabels.js
parent870a70e109ac9e80a88047044530de53d0404ec7 (diff)
upgrade Dojo to 1.6.1
Diffstat (limited to 'lib/dijit/form/HorizontalRuleLabels.js')
-rw-r--r--lib/dijit/form/HorizontalRuleLabels.js115
1 files changed, 87 insertions, 28 deletions
diff --git a/lib/dijit/form/HorizontalRuleLabels.js b/lib/dijit/form/HorizontalRuleLabels.js
index 6cf6742c5..d923e8081 100644
--- a/lib/dijit/form/HorizontalRuleLabels.js
+++ b/lib/dijit/form/HorizontalRuleLabels.js
@@ -1,38 +1,97 @@
/*
- Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
-if(!dojo._hasResource["dijit.form.HorizontalRuleLabels"]){
-dojo._hasResource["dijit.form.HorizontalRuleLabels"]=true;
+if(!dojo._hasResource["dijit.form.HorizontalRuleLabels"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dijit.form.HorizontalRuleLabels"] = true;
dojo.provide("dijit.form.HorizontalRuleLabels");
dojo.require("dijit.form.HorizontalRule");
-dojo.declare("dijit.form.HorizontalRuleLabels",dijit.form.HorizontalRule,{templateString:"<div class=\"dijitRuleContainer dijitRuleContainerH dijitRuleLabelsContainer dijitRuleLabelsContainerH\"></div>",labelStyle:"",labels:[],numericMargin:0,minimum:0,maximum:1,constraints:{pattern:"#%"},_positionPrefix:"<div class=\"dijitRuleLabelContainer dijitRuleLabelContainerH\" style=\"left:",_labelPrefix:"\"><div class=\"dijitRuleLabel dijitRuleLabelH\">",_suffix:"</div></div>",_calcPosition:function(_1){
-return _1;
-},_genHTML:function(_2,_3){
-return this._positionPrefix+this._calcPosition(_2)+this._positionSuffix+this.labelStyle+this._labelPrefix+this.labels[_3]+this._suffix;
-},getLabels:function(){
-var _4=this.labels;
-if(!_4.length){
-_4=dojo.query("> li",this.srcNodeRef).map(function(_5){
-return String(_5.innerHTML);
+
+
+dojo.declare("dijit.form.HorizontalRuleLabels", dijit.form.HorizontalRule,
+{
+ // summary:
+ // Labels for `dijit.form.HorizontalSlider`
+
+ templateString: '<div class="dijitRuleContainer dijitRuleContainerH dijitRuleLabelsContainer dijitRuleLabelsContainerH"></div>',
+
+ // labelStyle: String
+ // CSS style to apply to individual text labels
+ labelStyle: "",
+
+ // labels: String[]?
+ // Array of text labels to render - evenly spaced from left-to-right or bottom-to-top.
+ // Alternately, minimum and maximum can be specified, to get numeric labels.
+ labels: [],
+
+ // numericMargin: Integer
+ // Number of generated numeric labels that should be rendered as '' on the ends when labels[] are not specified
+ numericMargin: 0,
+
+ // numericMinimum: Integer
+ // Leftmost label value for generated numeric labels when labels[] are not specified
+ minimum: 0,
+
+ // numericMaximum: Integer
+ // Rightmost label value for generated numeric labels when labels[] are not specified
+ maximum: 1,
+
+ // constraints: Object
+ // pattern, places, lang, et al (see dojo.number) for generated numeric labels when labels[] are not specified
+ constraints: {pattern:"#%"},
+
+ _positionPrefix: '<div class="dijitRuleLabelContainer dijitRuleLabelContainerH" style="left:',
+ _labelPrefix: '"><div class="dijitRuleLabel dijitRuleLabelH">',
+ _suffix: '</div></div>',
+
+ _calcPosition: function(pos){
+ // summary:
+ // Returns the value to be used in HTML for the label as part of the left: attribute
+ // tags:
+ // protected extension
+ return pos;
+ },
+
+ _genHTML: function(pos, ndx){
+ return this._positionPrefix + this._calcPosition(pos) + this._positionSuffix + this.labelStyle + this._labelPrefix + this.labels[ndx] + this._suffix;
+ },
+
+ getLabels: function(){
+ // summary:
+ // Overridable function to return array of labels to use for this slider.
+ // Can specify a getLabels() method instead of a labels[] array, or min/max attributes.
+ // tags:
+ // protected extension
+
+ // if the labels array was not specified directly, then see if <li> children were
+ var labels = this.labels;
+ if(!labels.length){
+ // for markup creation, labels are specified as child elements
+ labels = dojo.query("> li", this.srcNodeRef).map(function(node){
+ return String(node.innerHTML);
+ });
+ }
+ this.srcNodeRef.innerHTML = '';
+ // if the labels were not specified directly and not as <li> children, then calculate numeric labels
+ if(!labels.length && this.count > 1){
+ var start = this.minimum;
+ var inc = (this.maximum - start) / (this.count-1);
+ for(var i=0; i < this.count; i++){
+ labels.push((i < this.numericMargin || i >= (this.count-this.numericMargin)) ? '' : dojo.number.format(start, this.constraints));
+ start += inc;
+ }
+ }
+ return labels;
+ },
+
+ postMixInProperties: function(){
+ this.inherited(arguments);
+ this.labels = this.getLabels();
+ this.count = this.labels.length;
+ }
});
-}
-this.srcNodeRef.innerHTML="";
-if(!_4.length&&this.count>1){
-var _6=this.minimum;
-var _7=(this.maximum-_6)/(this.count-1);
-for(var i=0;i<this.count;i++){
-_4.push((i<this.numericMargin||i>=(this.count-this.numericMargin))?"":dojo.number.format(_6,this.constraints));
-_6+=_7;
-}
-}
-return _4;
-},postMixInProperties:function(){
-this.inherited(arguments);
-this.labels=this.getLabels();
-this.count=this.labels.length;
-}});
+
}