2150 |
mathias |
1 |
if(!dojo._hasResource["dijit.form.Slider"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dijit.form.Slider"] = true;
|
|
|
3 |
dojo.provide("dijit.form.Slider");
|
|
|
4 |
|
|
|
5 |
dojo.require("dijit.form._FormWidget");
|
|
|
6 |
dojo.require("dijit._Container");
|
|
|
7 |
dojo.require("dojo.dnd.move");
|
|
|
8 |
dojo.require("dijit.form.Button");
|
|
|
9 |
dojo.require("dojo.number");
|
|
|
10 |
|
|
|
11 |
dojo.declare(
|
|
|
12 |
"dijit.form.HorizontalSlider",
|
|
|
13 |
[dijit.form._FormWidget, dijit._Container],
|
|
|
14 |
{
|
|
|
15 |
// summary
|
|
|
16 |
// A form widget that allows one to select a value with a horizontally draggable image
|
|
|
17 |
|
|
|
18 |
templateString:"<table class=\"dijit dijitReset dijitSlider\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" rules=\"none\"\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t\t><td dojoAttachPoint=\"containerNode,topDecoration\" class=\"dijitReset\" style=\"text-align:center;width:100%;\"></td\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitHorizontalSliderButtonContainer\"\n\t\t\t><div class=\"dijitHorizontalSliderDecrementIcon\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"decrementButton\" dojoAttachEvent=\"onclick: decrement\"><span class=\"dijitSliderButtonInner\">-</span></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><div class=\"dijitSliderBar dijitSliderBumper dijitHorizontalSliderBumper dijitSliderLeftBumper dijitHorizontalSliderLeftBumper\"></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><input dojoAttachPoint=\"valueNode\" type=\"hidden\" name=\"${name}\"\n\t\t\t/><div style=\"position:relative;\" dojoAttachPoint=\"sliderBarContainer\"\n\t\t\t\t><div dojoAttachPoint=\"progressBar\" class=\"dijitSliderBar dijitHorizontalSliderBar dijitSliderProgressBar dijitHorizontalSliderProgressBar\" dojoAttachEvent=\"onclick:_onBarClick\"\n\t\t\t\t\t><div dojoAttachPoint=\"sliderHandle,focusNode\" class=\"dijitSliderMoveable dijitHorizontalSliderMoveable\" dojoAttachEvent=\"onkeypress:_onKeyPress,onclick:_onHandleClick\" waiRole=\"slider\" valuemin=\"${minimum}\" valuemax=\"${maximum}\"\n\t\t\t\t\t\t><div class=\"dijitSliderImageHandle dijitHorizontalSliderImageHandle\"></div\n\t\t\t\t\t></div\n\t\t\t\t></div\n\t\t\t\t><div dojoAttachPoint=\"remainingBar\" class=\"dijitSliderBar dijitHorizontalSliderBar dijitSliderRemainingBar dijitHorizontalSliderRemainingBar\" dojoAttachEvent=\"onclick:_onBarClick\"></div\n\t\t\t></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><div class=\"dijitSliderBar dijitSliderBumper dijitHorizontalSliderBumper dijitSliderRightBumper dijitHorizontalSliderRightBumper\"></div\n\t\t></td\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitHorizontalSliderButtonContainer\" style=\"right:0px;\"\n\t\t\t><div class=\"dijitHorizontalSliderIncrementIcon\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"incrementButton\" dojoAttachEvent=\"onclick: increment\"><span class=\"dijitSliderButtonInner\">+</span></div\n\t\t></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t\t><td dojoAttachPoint=\"containerNode,bottomDecoration\" class=\"dijitReset\" style=\"text-align:center;\"></td\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t></tr\n></table>\n",
|
|
|
19 |
value: 0,
|
|
|
20 |
|
|
|
21 |
// showButtons: boolean
|
|
|
22 |
// Show increment/decrement buttons at the ends of the slider?
|
|
|
23 |
showButtons: true,
|
|
|
24 |
|
|
|
25 |
// minimum:: integer
|
|
|
26 |
// The minimum value allowed.
|
|
|
27 |
minimum: 0,
|
|
|
28 |
|
|
|
29 |
// maximum: integer
|
|
|
30 |
// The maximum allowed value.
|
|
|
31 |
maximum: 100,
|
|
|
32 |
|
|
|
33 |
// discreteValues: integer
|
|
|
34 |
// The maximum allowed values dispersed evenly between minimum and maximum (inclusive).
|
|
|
35 |
discreteValues: Infinity,
|
|
|
36 |
|
|
|
37 |
// pageIncrement: integer
|
|
|
38 |
// The amount of change with shift+arrow
|
|
|
39 |
pageIncrement: 2,
|
|
|
40 |
|
|
|
41 |
// clickSelect: boolean
|
|
|
42 |
// If clicking the progress bar changes the value or not
|
|
|
43 |
clickSelect: true,
|
|
|
44 |
|
|
|
45 |
widgetsInTemplate: true,
|
|
|
46 |
|
|
|
47 |
attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap),
|
|
|
48 |
{id:"", name:"valueNode"}),
|
|
|
49 |
|
|
|
50 |
baseClass: "dijitSlider",
|
|
|
51 |
|
|
|
52 |
_mousePixelCoord: "pageX",
|
|
|
53 |
_pixelCount: "w",
|
|
|
54 |
_startingPixelCoord: "x",
|
|
|
55 |
_startingPixelCount: "l",
|
|
|
56 |
_handleOffsetCoord: "left",
|
|
|
57 |
_progressPixelSize: "width",
|
|
|
58 |
_upsideDown: false,
|
|
|
59 |
|
|
|
60 |
_onKeyPress: function(/*Event*/ e){
|
|
|
61 |
if(this.disabled || e.altKey || e.ctrlKey){ return; }
|
|
|
62 |
switch(e.keyCode){
|
|
|
63 |
case dojo.keys.HOME:
|
|
|
64 |
this.setValue(this.minimum, false);
|
|
|
65 |
break;
|
|
|
66 |
case dojo.keys.END:
|
|
|
67 |
this.setValue(this.maximum, false);
|
|
|
68 |
break;
|
|
|
69 |
case dojo.keys.UP_ARROW:
|
|
|
70 |
case (this._isReversed() ? dojo.keys.LEFT_ARROW : dojo.keys.RIGHT_ARROW):
|
|
|
71 |
case dojo.keys.PAGE_UP:
|
|
|
72 |
this.increment(e);
|
|
|
73 |
break;
|
|
|
74 |
case dojo.keys.DOWN_ARROW:
|
|
|
75 |
case (this._isReversed() ? dojo.keys.RIGHT_ARROW : dojo.keys.LEFT_ARROW):
|
|
|
76 |
case dojo.keys.PAGE_DOWN:
|
|
|
77 |
this.decrement(e);
|
|
|
78 |
break;
|
|
|
79 |
default:
|
|
|
80 |
this.inherited("_onKeyPress", arguments);
|
|
|
81 |
return;
|
|
|
82 |
}
|
|
|
83 |
dojo.stopEvent(e);
|
|
|
84 |
},
|
|
|
85 |
|
|
|
86 |
_onHandleClick: function(e){
|
|
|
87 |
if(this.disabled){ return; }
|
|
|
88 |
if(!dojo.isIE){
|
|
|
89 |
// make sure you get focus when dragging the handle
|
|
|
90 |
// (but don't do on IE because it causes a flicker on mouse up (due to blur then focus)
|
|
|
91 |
dijit.focus(this.sliderHandle);
|
|
|
92 |
}
|
|
|
93 |
dojo.stopEvent(e);
|
|
|
94 |
},
|
|
|
95 |
|
|
|
96 |
_isReversed: function() {
|
|
|
97 |
return !(this._upsideDown || this.isLeftToRight());
|
|
|
98 |
},
|
|
|
99 |
|
|
|
100 |
_onBarClick: function(e){
|
|
|
101 |
if(this.disabled || !this.clickSelect){ return; }
|
|
|
102 |
dijit.focus(this.sliderHandle);
|
|
|
103 |
dojo.stopEvent(e);
|
|
|
104 |
var abspos = dojo.coords(this.sliderBarContainer, true);
|
|
|
105 |
var pixelValue = e[this._mousePixelCoord] - abspos[this._startingPixelCoord];
|
|
|
106 |
this._setPixelValue(this._isReversed() || this._upsideDown ? (abspos[this._pixelCount] - pixelValue) : pixelValue, abspos[this._pixelCount], true);
|
|
|
107 |
},
|
|
|
108 |
|
|
|
109 |
_setPixelValue: function(/*Number*/ pixelValue, /*Number*/ maxPixels, /*Boolean, optional*/ priorityChange){
|
|
|
110 |
if(this.disabled){ return; }
|
|
|
111 |
pixelValue = pixelValue < 0 ? 0 : maxPixels < pixelValue ? maxPixels : pixelValue;
|
|
|
112 |
var count = this.discreteValues;
|
|
|
113 |
if(count <= 1 || count == Infinity){ count = maxPixels; }
|
|
|
114 |
count--;
|
|
|
115 |
var pixelsPerValue = maxPixels / count;
|
|
|
116 |
var wholeIncrements = Math.round(pixelValue / pixelsPerValue);
|
|
|
117 |
this.setValue((this.maximum-this.minimum)*wholeIncrements/count + this.minimum, priorityChange);
|
|
|
118 |
},
|
|
|
119 |
|
|
|
120 |
setValue: function(/*Number*/ value, /*Boolean, optional*/ priorityChange){
|
|
|
121 |
this.valueNode.value = this.value = value;
|
|
|
122 |
this.inherited('setValue', arguments);
|
|
|
123 |
var percent = (value - this.minimum) / (this.maximum - this.minimum);
|
|
|
124 |
this.progressBar.style[this._progressPixelSize] = (percent*100) + "%";
|
|
|
125 |
this.remainingBar.style[this._progressPixelSize] = ((1-percent)*100) + "%";
|
|
|
126 |
},
|
|
|
127 |
|
|
|
128 |
_bumpValue: function(signedChange){
|
|
|
129 |
if(this.disabled){ return; }
|
|
|
130 |
var s = dojo.getComputedStyle(this.sliderBarContainer);
|
|
|
131 |
var c = dojo._getContentBox(this.sliderBarContainer, s);
|
|
|
132 |
var count = this.discreteValues;
|
|
|
133 |
if(count <= 1 || count == Infinity){ count = c[this._pixelCount]; }
|
|
|
134 |
count--;
|
|
|
135 |
var value = (this.value - this.minimum) * count / (this.maximum - this.minimum) + signedChange;
|
|
|
136 |
if(value < 0){ value = 0; }
|
|
|
137 |
if(value > count){ value = count; }
|
|
|
138 |
value = value * (this.maximum - this.minimum) / count + this.minimum;
|
|
|
139 |
this.setValue(value, true);
|
|
|
140 |
},
|
|
|
141 |
|
|
|
142 |
decrement: function(e){
|
|
|
143 |
// summary
|
|
|
144 |
// decrement slider by 1 unit
|
|
|
145 |
this._bumpValue(e.keyCode == dojo.keys.PAGE_DOWN?-this.pageIncrement:-1);
|
|
|
146 |
},
|
|
|
147 |
|
|
|
148 |
increment: function(e){
|
|
|
149 |
// summary
|
|
|
150 |
// increment slider by 1 unit
|
|
|
151 |
this._bumpValue(e.keyCode == dojo.keys.PAGE_UP?this.pageIncrement:1);
|
|
|
152 |
},
|
|
|
153 |
|
|
|
154 |
_mouseWheeled: function(/*Event*/ evt){
|
|
|
155 |
dojo.stopEvent(evt);
|
|
|
156 |
var scrollAmount = 0;
|
|
|
157 |
if(typeof evt.wheelDelta == 'number'){ // IE
|
|
|
158 |
scrollAmount = evt.wheelDelta;
|
|
|
159 |
}else if(typeof evt.detail == 'number'){ // Mozilla+Firefox
|
|
|
160 |
scrollAmount = -evt.detail;
|
|
|
161 |
}
|
|
|
162 |
if(scrollAmount > 0){
|
|
|
163 |
this.increment(evt);
|
|
|
164 |
}else if(scrollAmount < 0){
|
|
|
165 |
this.decrement(evt);
|
|
|
166 |
}
|
|
|
167 |
},
|
|
|
168 |
|
|
|
169 |
startup: function(){
|
|
|
170 |
dojo.forEach(this.getChildren(), function(child){
|
|
|
171 |
if(this[child.container] != this.containerNode){
|
|
|
172 |
this[child.container].appendChild(child.domNode);
|
|
|
173 |
}
|
|
|
174 |
}, this);
|
|
|
175 |
},
|
|
|
176 |
|
|
|
177 |
_onBlur: function(){
|
|
|
178 |
dijit.form.HorizontalSlider.superclass.setValue.call(this, this.value, true);
|
|
|
179 |
},
|
|
|
180 |
|
|
|
181 |
postCreate: function(){
|
|
|
182 |
if(this.showButtons){
|
|
|
183 |
this.incrementButton.style.display="";
|
|
|
184 |
this.decrementButton.style.display="";
|
|
|
185 |
}
|
|
|
186 |
this.connect(this.domNode, dojo.isIE ? "onmousewheel" : 'DOMMouseScroll', "_mouseWheeled");
|
|
|
187 |
|
|
|
188 |
// define a custom constructor for a SliderMover that points back to me
|
|
|
189 |
var _self = this;
|
|
|
190 |
var mover = function(){
|
|
|
191 |
dijit.form._SliderMover.apply(this, arguments);
|
|
|
192 |
this.widget = _self;
|
|
|
193 |
};
|
|
|
194 |
dojo.extend(mover, dijit.form._SliderMover.prototype);
|
|
|
195 |
|
|
|
196 |
this._movable = new dojo.dnd.Moveable(this.sliderHandle, {mover: mover});
|
|
|
197 |
this.inherited('postCreate', arguments);
|
|
|
198 |
},
|
|
|
199 |
|
|
|
200 |
destroy: function(){
|
|
|
201 |
this._movable.destroy();
|
|
|
202 |
this.inherited('destroy', arguments);
|
|
|
203 |
}
|
|
|
204 |
});
|
|
|
205 |
|
|
|
206 |
dojo.declare(
|
|
|
207 |
"dijit.form.VerticalSlider",
|
|
|
208 |
dijit.form.HorizontalSlider,
|
|
|
209 |
{
|
|
|
210 |
// summary
|
|
|
211 |
// A form widget that allows one to select a value with a vertically draggable image
|
|
|
212 |
|
|
|
213 |
templateString:"<table class=\"dijitReset dijitSlider\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" rules=\"none\"\n><tbody class=\"dijitReset\"\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\"></td\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitVerticalSliderButtonContainer\"\n\t\t\t><div class=\"dijitVerticalSliderIncrementIcon\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"incrementButton\" dojoAttachEvent=\"onclick: increment\"><span class=\"dijitSliderButtonInner\">+</span></div\n\t\t></td\n\t\t><td class=\"dijitReset\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\"></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><center><div class=\"dijitSliderBar dijitSliderBumper dijitVerticalSliderBumper dijitSliderTopBumper dijitVerticalSliderTopBumper\"></div></center\n\t\t></td\n\t\t><td class=\"dijitReset\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td dojoAttachPoint=\"leftDecoration\" class=\"dijitReset\" style=\"text-align:center;height:100%;\"></td\n\t\t><td class=\"dijitReset\" style=\"height:100%;\"\n\t\t\t><input dojoAttachPoint=\"valueNode\" type=\"hidden\" name=\"${name}\"\n\t\t\t/><center style=\"position:relative;height:100%;\" dojoAttachPoint=\"sliderBarContainer\"\n\t\t\t\t><div dojoAttachPoint=\"remainingBar\" class=\"dijitSliderBar dijitVerticalSliderBar dijitSliderRemainingBar dijitVerticalSliderRemainingBar\" dojoAttachEvent=\"onclick:_onBarClick\"></div\n\t\t\t\t><div dojoAttachPoint=\"progressBar\" class=\"dijitSliderBar dijitVerticalSliderBar dijitSliderProgressBar dijitVerticalSliderProgressBar\" dojoAttachEvent=\"onclick:_onBarClick\"\n\t\t\t\t\t><div dojoAttachPoint=\"sliderHandle,focusNode\" class=\"dijitSliderMoveable\" dojoAttachEvent=\"onkeypress:_onKeyPress,onclick:_onHandleClick\" style=\"vertical-align:top;\" waiRole=\"slider\" valuemin=\"${minimum}\" valuemax=\"${maximum}\"\n\t\t\t\t\t\t><div class=\"dijitSliderImageHandle dijitVerticalSliderImageHandle\"></div\n\t\t\t\t\t></div\n\t\t\t\t></div\n\t\t\t></center\n\t\t></td\n\t\t><td dojoAttachPoint=\"containerNode,rightDecoration\" class=\"dijitReset\" style=\"text-align:center;height:100%;\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\"></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><center><div class=\"dijitSliderBar dijitSliderBumper dijitVerticalSliderBumper dijitSliderBottomBumper dijitVerticalSliderBottomBumper\"></div></center\n\t\t></td\n\t\t><td class=\"dijitReset\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\"></td\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitVerticalSliderButtonContainer\"\n\t\t\t><div class=\"dijitVerticalSliderDecrementIcon\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"decrementButton\" dojoAttachEvent=\"onclick: decrement\"><span class=\"dijitSliderButtonInner\">-</span></div\n\t\t></td\n\t\t><td class=\"dijitReset\"></td\n\t></tr\n></tbody></table>\n",
|
|
|
214 |
_mousePixelCoord: "pageY",
|
|
|
215 |
_pixelCount: "h",
|
|
|
216 |
_startingPixelCoord: "y",
|
|
|
217 |
_startingPixelCount: "t",
|
|
|
218 |
_handleOffsetCoord: "top",
|
|
|
219 |
_progressPixelSize: "height",
|
|
|
220 |
_upsideDown: true
|
|
|
221 |
});
|
|
|
222 |
|
|
|
223 |
dojo.declare("dijit.form._SliderMover",
|
|
|
224 |
dojo.dnd.Mover,
|
|
|
225 |
{
|
|
|
226 |
onMouseMove: function(e){
|
|
|
227 |
var widget = this.widget;
|
|
|
228 |
var c = this.constraintBox;
|
|
|
229 |
if(!c){
|
|
|
230 |
var container = widget.sliderBarContainer;
|
|
|
231 |
var s = dojo.getComputedStyle(container);
|
|
|
232 |
var c = dojo._getContentBox(container, s);
|
|
|
233 |
c[widget._startingPixelCount] = 0;
|
|
|
234 |
this.constraintBox = c;
|
|
|
235 |
}
|
|
|
236 |
var m = this.marginBox;
|
|
|
237 |
var pixelValue = widget._isReversed() ?
|
|
|
238 |
e[widget._mousePixelCoord] - dojo._abs(widget.sliderBarContainer).x :
|
|
|
239 |
m[widget._startingPixelCount] + e[widget._mousePixelCoord];
|
|
|
240 |
dojo.hitch(widget, "_setPixelValue")(widget._isReversed() || widget._upsideDown? (c[widget._pixelCount]-pixelValue) : pixelValue, c[widget._pixelCount]);
|
|
|
241 |
},
|
|
|
242 |
|
|
|
243 |
destroy: function(e){
|
|
|
244 |
var widget = this.widget;
|
|
|
245 |
widget.setValue(widget.value, true);
|
|
|
246 |
dojo.dnd.Mover.prototype.destroy.call(this);
|
|
|
247 |
}
|
|
|
248 |
});
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
dojo.declare("dijit.form.HorizontalRule", [dijit._Widget, dijit._Templated],
|
|
|
252 |
{
|
|
|
253 |
// Summary:
|
|
|
254 |
// Create hash marks for the Horizontal slider
|
|
|
255 |
templateString: '<div class="RuleContainer HorizontalRuleContainer"></div>',
|
|
|
256 |
|
|
|
257 |
// count: Integer
|
|
|
258 |
// Number of hash marks to generate
|
|
|
259 |
count: 3,
|
|
|
260 |
|
|
|
261 |
// container: Node
|
|
|
262 |
// If this is a child widget, connect it to this parent node
|
|
|
263 |
container: "containerNode",
|
|
|
264 |
|
|
|
265 |
// ruleStyle: String
|
|
|
266 |
// CSS style to apply to individual hash marks
|
|
|
267 |
ruleStyle: "",
|
|
|
268 |
|
|
|
269 |
_positionPrefix: '<div class="RuleMark HorizontalRuleMark" style="left:',
|
|
|
270 |
_positionSuffix: '%;',
|
|
|
271 |
_suffix: '"></div>',
|
|
|
272 |
|
|
|
273 |
_genHTML: function(pos, ndx){
|
|
|
274 |
return this._positionPrefix + pos + this._positionSuffix + this.ruleStyle + this._suffix;
|
|
|
275 |
},
|
|
|
276 |
|
|
|
277 |
_isHorizontal: true,
|
|
|
278 |
|
|
|
279 |
postCreate: function(){
|
|
|
280 |
if(this.count==1){
|
|
|
281 |
var innerHTML = this._genHTML(50, 0);
|
|
|
282 |
}else{
|
|
|
283 |
var interval = 100 / (this.count-1);
|
|
|
284 |
if(!this._isHorizontal || this.isLeftToRight()){
|
|
|
285 |
var innerHTML = this._genHTML(0, 0);
|
|
|
286 |
for(var i=1; i < this.count-1; i++){
|
|
|
287 |
innerHTML += this._genHTML(interval*i, i);
|
|
|
288 |
}
|
|
|
289 |
innerHTML += this._genHTML(100, this.count-1);
|
|
|
290 |
}else{
|
|
|
291 |
var innerHTML = this._genHTML(100, 0);
|
|
|
292 |
for(var i=1; i < this.count-1; i++){
|
|
|
293 |
innerHTML += this._genHTML(100-interval*i, i);
|
|
|
294 |
}
|
|
|
295 |
innerHTML += this._genHTML(0, this.count-1);
|
|
|
296 |
}
|
|
|
297 |
}
|
|
|
298 |
this.domNode.innerHTML = innerHTML;
|
|
|
299 |
}
|
|
|
300 |
});
|
|
|
301 |
|
|
|
302 |
dojo.declare("dijit.form.VerticalRule", dijit.form.HorizontalRule,
|
|
|
303 |
{
|
|
|
304 |
// Summary:
|
|
|
305 |
// Create hash marks for the Vertical slider
|
|
|
306 |
templateString: '<div class="RuleContainer VerticalRuleContainer"></div>',
|
|
|
307 |
_positionPrefix: '<div class="RuleMark VerticalRuleMark" style="top:',
|
|
|
308 |
|
|
|
309 |
_isHorizontal: false
|
|
|
310 |
});
|
|
|
311 |
|
|
|
312 |
dojo.declare("dijit.form.HorizontalRuleLabels", dijit.form.HorizontalRule,
|
|
|
313 |
{
|
|
|
314 |
// Summary:
|
|
|
315 |
// Create labels for the Horizontal slider
|
|
|
316 |
templateString: '<div class="RuleContainer HorizontalRuleContainer"></div>',
|
|
|
317 |
|
|
|
318 |
// labelStyle: String
|
|
|
319 |
// CSS style to apply to individual text labels
|
|
|
320 |
labelStyle: "",
|
|
|
321 |
|
|
|
322 |
// labels: Array
|
|
|
323 |
// Array of text labels to render - evenly spaced from left-to-right or bottom-to-top
|
|
|
324 |
labels: [],
|
|
|
325 |
|
|
|
326 |
// numericMargin: Integer
|
|
|
327 |
// Number of generated numeric labels that should be rendered as '' on the ends when labels[] are not specified
|
|
|
328 |
numericMargin: 0,
|
|
|
329 |
|
|
|
330 |
// numericMinimum: Integer
|
|
|
331 |
// Leftmost label value for generated numeric labels when labels[] are not specified
|
|
|
332 |
minimum: 0,
|
|
|
333 |
|
|
|
334 |
// numericMaximum: Integer
|
|
|
335 |
// Rightmost label value for generated numeric labels when labels[] are not specified
|
|
|
336 |
maximum: 1,
|
|
|
337 |
|
|
|
338 |
// constraints: object
|
|
|
339 |
// pattern, places, lang, et al (see dojo.number) for generated numeric labels when labels[] are not specified
|
|
|
340 |
constraints: {pattern:"#%"},
|
|
|
341 |
|
|
|
342 |
_positionPrefix: '<div class="RuleLabelContainer HorizontalRuleLabelContainer" style="left:',
|
|
|
343 |
_labelPrefix: '"><span class="RuleLabel HorizontalRuleLabel">',
|
|
|
344 |
_suffix: '</span></div>',
|
|
|
345 |
|
|
|
346 |
_calcPosition: function(pos){
|
|
|
347 |
return pos;
|
|
|
348 |
},
|
|
|
349 |
|
|
|
350 |
_genHTML: function(pos, ndx){
|
|
|
351 |
return this._positionPrefix + this._calcPosition(pos) + this._positionSuffix + this.labelStyle + this._labelPrefix + this.labels[ndx] + this._suffix;
|
|
|
352 |
},
|
|
|
353 |
|
|
|
354 |
getLabels: function(){
|
|
|
355 |
// summary: user replaceable function to return the labels array
|
|
|
356 |
|
|
|
357 |
// if the labels array was not specified directly, then see if <li> children were
|
|
|
358 |
var labels = this.labels;
|
|
|
359 |
if(!labels.length){
|
|
|
360 |
// for markup creation, labels are specified as child elements
|
|
|
361 |
labels = dojo.query("> li", this.srcNodeRef).map(function(node){
|
|
|
362 |
return String(node.innerHTML);
|
|
|
363 |
});
|
|
|
364 |
}
|
|
|
365 |
this.srcNodeRef.innerHTML = '';
|
|
|
366 |
// if the labels were not specified directly and not as <li> children, then calculate numeric labels
|
|
|
367 |
if(!labels.length && this.count > 1){
|
|
|
368 |
var start = this.minimum;
|
|
|
369 |
var inc = (this.maximum - start) / (this.count-1);
|
|
|
370 |
for (var i=0; i < this.count; i++){
|
|
|
371 |
labels.push((i<this.numericMargin||i>=(this.count-this.numericMargin))? '' : dojo.number.format(start, this.constraints));
|
|
|
372 |
start += inc;
|
|
|
373 |
}
|
|
|
374 |
}
|
|
|
375 |
return labels;
|
|
|
376 |
},
|
|
|
377 |
|
|
|
378 |
postMixInProperties: function(){
|
|
|
379 |
this.inherited('postMixInProperties', arguments);
|
|
|
380 |
this.labels = this.getLabels();
|
|
|
381 |
this.count = this.labels.length;
|
|
|
382 |
}
|
|
|
383 |
});
|
|
|
384 |
|
|
|
385 |
dojo.declare("dijit.form.VerticalRuleLabels", dijit.form.HorizontalRuleLabels,
|
|
|
386 |
{
|
|
|
387 |
// Summary:
|
|
|
388 |
// Create labels for the Vertical slider
|
|
|
389 |
templateString: '<div class="RuleContainer VerticalRuleContainer"></div>',
|
|
|
390 |
|
|
|
391 |
_positionPrefix: '<div class="RuleLabelContainer VerticalRuleLabelContainer" style="top:',
|
|
|
392 |
_labelPrefix: '"><span class="RuleLabel VerticalRuleLabel">',
|
|
|
393 |
|
|
|
394 |
_calcPosition: function(pos){
|
|
|
395 |
return 100-pos;
|
|
|
396 |
},
|
|
|
397 |
|
|
|
398 |
_isHorizontal: false
|
|
|
399 |
});
|
|
|
400 |
|
|
|
401 |
}
|