-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Slider related widgets into separate files, refs #8017 !strict
Slider.js remains for backwards compatibility, but developers should dojo.require() HorizontalSlider, HorizontalRule etc. directly. git-svn-id: http://svn.dojotoolkit.org/src/dijit/trunk@16273 560b804f-0ae3-0310-86f3-f6aa0a117693
- Loading branch information
Showing
10 changed files
with
536 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,57 @@ | ||
dojo.provide("dijit.form.HorizontalRule"); | ||
dojo.require("dijit.form.Slider"); | ||
|
||
dojo.require("dijit._Widget"); | ||
dojo.require("dijit._Templated"); | ||
|
||
dojo.declare("dijit.form.HorizontalRule", [dijit._Widget, dijit._Templated], | ||
{ | ||
// Summary: | ||
// Create hash marks for the Horizontal slider | ||
templateString: '<div class="dijitRuleContainer dijitRuleContainerH"></div>', | ||
|
||
// count: Integer | ||
// Number of hash marks to generate | ||
count: 3, | ||
|
||
// container: Node | ||
// If this is a child widget, connect it to this parent node | ||
container: "containerNode", | ||
|
||
// ruleStyle: String | ||
// CSS style to apply to individual hash marks | ||
ruleStyle: "", | ||
|
||
_positionPrefix: '<div class="dijitRuleMark dijitRuleMarkH" style="left:', | ||
_positionSuffix: '%;', | ||
_suffix: '"></div>', | ||
|
||
_genHTML: function(pos, ndx){ | ||
return this._positionPrefix + pos + this._positionSuffix + this.ruleStyle + this._suffix; | ||
}, | ||
|
||
_isHorizontal: true, | ||
|
||
postCreate: function(){ | ||
var innerHTML; | ||
if(this.count==1){ | ||
innerHTML = this._genHTML(50, 0); | ||
}else{ | ||
var i; | ||
var interval = 100 / (this.count-1); | ||
if(!this._isHorizontal || this.isLeftToRight()){ | ||
innerHTML = this._genHTML(0, 0); | ||
for(i=1; i < this.count-1; i++){ | ||
innerHTML += this._genHTML(interval*i, i); | ||
} | ||
innerHTML += this._genHTML(100, this.count-1); | ||
}else{ | ||
innerHTML = this._genHTML(100, 0); | ||
for(i=1; i < this.count-1; i++){ | ||
innerHTML += this._genHTML(100-interval*i, i); | ||
} | ||
innerHTML += this._genHTML(0, this.count-1); | ||
} | ||
} | ||
this.domNode.innerHTML = innerHTML; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,78 @@ | ||
dojo.provide("dijit.form.HorizontalRuleLabels"); | ||
dojo.require("dijit.form.Slider"); | ||
|
||
dojo.require("dijit.form.HorizontalRule"); | ||
|
||
dojo.declare("dijit.form.HorizontalRuleLabels", dijit.form.HorizontalRule, | ||
{ | ||
// Summary: | ||
// Create labels for the Horizontal slider | ||
templateString: '<div class="dijitRuleContainer dijitRuleContainerH dijitRuleLabelsContainer dijitRuleLabelsContainerH"></div>', | ||
|
||
// labelStyle: String | ||
// CSS style to apply to individual text labels | ||
labelStyle: "", | ||
|
||
// labels: Array | ||
// Array of text labels to render - evenly spaced from left-to-right or bottom-to-top | ||
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: '"><span class="dijitRuleLabel dijitRuleLabelH">', | ||
_suffix: '</span></div>', | ||
|
||
_calcPosition: function(pos){ | ||
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: user replaceable function to return the labels array | ||
|
||
// 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; | ||
} | ||
}); | ||
|
||
|
Oops, something went wrong.