Skip to content

Commit

Permalink
Split Slider related widgets into separate files, refs #8017 !strict
Browse files Browse the repository at this point in the history
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
wkeese committed Jan 8, 2009
1 parent 678cb5e commit a82ec6d
Show file tree
Hide file tree
Showing 10 changed files with 536 additions and 494 deletions.
23 changes: 22 additions & 1 deletion dijit-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@ dojo.require("dijit.dijit");

dojo.require("dijit.ColorPalette");
dojo.require("dijit.Declaration");

dojo.require("dijit.Dialog");
dojo.require("dijit.DialogUnderlay");
dojo.require("dijit.TooltipDialog");

dojo.require("dijit.Editor");

dojo.require("dijit.Menu");
dojo.require("dijit.MenuItem");
dojo.require("dijit.PopupMenuItem");
dojo.require("dijit.MenuBar");
dojo.require("dijit.MenuBarItem");
dojo.require("dijit.PopupMenuBarItem");
dojo.require("dijit.MenuSeparator");

dojo.require("dijit.ProgressBar");
dojo.require("dijit.TitlePane");
dojo.require("dijit.Toolbar");
Expand All @@ -29,7 +41,16 @@ dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.NumberSpinner");
dojo.require("dijit.form.NumberTextBox");
dojo.require("dijit.form.Slider");

// slider files
dojo.require("dijit.form.HorizontalSlider");
dojo.require("dijit.form.VerticalSlider");
dojo.require("dijit.form.HorizontalRule");
dojo.require("dijit.form.VerticalRule");
dojo.require("dijit.form.HorizontalRuleLabels");
dojo.require("dijit.form.VerticalRuleLabels");

dojo.require("dijit.form.SimpleTextarea");
dojo.require("dijit.form.Textarea");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.ValidationTextBox");
Expand Down
56 changes: 55 additions & 1 deletion form/HorizontalRule.js
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;
}
});
77 changes: 76 additions & 1 deletion form/HorizontalRuleLabels.js
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;
}
});


Loading

0 comments on commit a82ec6d

Please sign in to comment.