| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>Dojo Slider Widget Demo</title> |
| 6 |
|
| 7 |
<style type="text/css"> |
| 8 |
@import "../../themes/claro/document.css"; |
| 9 |
@import "../css/dijitTests.css"; |
| 10 |
@import "../../../util/doh/robot/robot.css"; |
| 11 |
#slider2 .dijitButtonNode { |
| 12 |
width:12px; |
| 13 |
height:12px; |
| 14 |
border: none; |
| 15 |
font-size:11px; |
| 16 |
padding:0; |
| 17 |
} |
| 18 |
</style> |
| 19 |
|
| 20 |
<script type="text/javascript" src="../boilerplate.js"></script> |
| 21 |
|
| 22 |
<script type="text/javascript"> |
| 23 |
var registry, dom; |
| 24 |
require([ |
| 25 |
"dojo/dom", |
| 26 |
"dojo/parser", |
| 27 |
"dijit/registry", |
| 28 |
|
| 29 |
// used by parser |
| 30 |
"dijit/form/Button", |
| 31 |
"dijit/form/HorizontalSlider", |
| 32 |
"dijit/form/VerticalSlider", |
| 33 |
"dijit/form/HorizontalRule", |
| 34 |
"dijit/form/VerticalRule", |
| 35 |
"dijit/form/HorizontalRuleLabels", |
| 36 |
"dijit/form/VerticalRuleLabels", |
| 37 |
"dojo/domReady!" |
| 38 |
], function(dm, parser, rgstry){ |
| 39 |
// used by event handlers |
| 40 |
dom = dm; |
| 41 |
registry = rgstry; |
| 42 |
|
| 43 |
parser.parse(); |
| 44 |
}); |
| 45 |
</script> |
| 46 |
</head> |
| 47 |
|
| 48 |
<body role="main"> |
| 49 |
<h1 class="testTitle">Slider</h1> |
| 50 |
Also try using the arrow keys, buttons, or clicking on the progress bar to move the slider. |
| 51 |
<br> |
| 52 |
|
| 53 |
|
| 54 |
<form id="form1" action="" name="example" method="post"> |
| 55 |
|
| 56 |
<h2>Horizontal Slider Example</h2> |
| 57 |
initial value=10, min=0, max=100, pageIncrement=100, onChange event triggers input box value change immediately<br> |
| 58 |
<div id="slider1" data-dojo-type="dijit/form/HorizontalSlider" aria-label="slider 1" data-dojo-props='name:"horizontal1", |
| 59 |
onChange:function(val){ dom.byId("slider1input").value=dojo.number.format(val/100,{places:1,pattern:"#%"}); }, |
| 60 |
value:10, |
| 61 |
maximum:100, |
| 62 |
minimum:0, |
| 63 |
pageIncrement:100, |
| 64 |
showButtons:true, |
| 65 |
intermediateChanges:true, |
| 66 |
slideDuration:500, |
| 67 |
style:{width:"50%", height:"20px"} |
| 68 |
'> |
| 69 |
<ol data-dojo-type="dijit/form/HorizontalRuleLabels" data-dojo-props='container:"topDecoration", style:{height:"1.2em",fontSize:"75%"}, count:6, numericMargin:1'></ol> |
| 70 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='container:"topDecoration", count:6, style:{height:"5px"}'></div> |
| 71 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='container:"bottomDecoration", count:5, style:{height:"5px"}'></div> |
| 72 |
<ol data-dojo-type="dijit/form/HorizontalRuleLabels" data-dojo-props='container:"bottomDecoration", style:{height:"1em",fontSize:"75%"}'> |
| 73 |
<li>lowest</li> |
| 74 |
<li>normal</li> |
| 75 |
<li>highest</li> |
| 76 |
</ol> |
| 77 |
</div> |
| 78 |
|
| 79 |
<label for="slider1input">Slider1 Value:</label><input readonly id="slider1input" size="4" value="10.0%"/> |
| 80 |
<br> |
| 81 |
<button id="disableButton" data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ registry.byId("slider1").set("disabled", true);registry.byId("disableButton").set("disabled",true);registry.byId("enableButton").set("disabled",false); }'>Disable previous slider</button> |
| 82 |
<button id="enableButton" data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ registry.byId("slider1").set("disabled",false);registry.byId("disableButton").set("disabled",false);registry.byId("enableButton").set("disabled", true); }, disabled:true'>Enable previous slider</button> |
| 83 |
|
| 84 |
<h2>Vertical Slider Example</h2> |
| 85 |
initial value=10, min=0, max=100, onChange event triggers input box value change when you mouse up or tab away<br> |
| 86 |
<div id="slider2" data-dojo-type="dijit/form/VerticalSlider" data-dojo-props='name:"vertical1", |
| 87 |
onChange:function(val){ dom.byId("slider2input").value = val; }, |
| 88 |
value:10, |
| 89 |
maximum:100, |
| 90 |
minimum:0, |
| 91 |
discreteValues:11, |
| 92 |
"aria-label":"slider 2", |
| 93 |
style:{height:"300px"} |
| 94 |
'> |
| 95 |
<ol data-dojo-type="dijit/form/VerticalRuleLabels" data-dojo-props='container:"leftDecoration", style:{width:"2em"}, labelStyle: document.documentElement.dir=="rtl" ? "left:3px;" : "right:3px;"'> |
| 96 |
<li>0</li> |
| 97 |
<li>100</li> |
| 98 |
</ol> |
| 99 |
<div data-dojo-type="dijit/form/VerticalRule" data-dojo-props='container:"leftDecoration", count:11, style:{width:"5px"}, ruleStyle:"border-color: #888"'></div> |
| 100 |
<div data-dojo-type="dijit/form/VerticalRule" data-dojo-props='container:"rightDecoration", count:11, style:{width:"5px"}, ruleStyle:"border-color: #888"'></div> |
| 101 |
<ol data-dojo-type="dijit/form/VerticalRuleLabels" data-dojo-props='container:"rightDecoration", style:{width:"2em"}, count:6, numericMargin:1, maximum:100, constraints:{pattern:"#"}'></ol> |
| 102 |
</div> |
| 103 |
<label for="slider2input">Slider2 Value:</label><input readonly id="slider2input" size="3" value="10"/> |
| 104 |
|
| 105 |
<h2>Fancy HTML labels (no slide animation):</h2> |
| 106 |
<div id="slider3" data-dojo-type="dijit/form/HorizontalSlider" aria-label="slider 3" data-dojo-props='name:"horizontal2", |
| 107 |
title:"Fancy HTML Labels", |
| 108 |
minimum:1, |
| 109 |
value:2, |
| 110 |
maximum:3, |
| 111 |
discreteValues:3, |
| 112 |
showButtons:false, |
| 113 |
intermediateChanges:true, |
| 114 |
slideDuration:0, |
| 115 |
style:"width:300px; height: 40px;" |
| 116 |
'> |
| 117 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='container:"bottomDecoration", count:3, style:{height:"5px"}'></div> |
| 118 |
<ol data-dojo-type="dijit/form/HorizontalRuleLabels" data-dojo-props='container:"bottomDecoration", style:{height:"1em", fontSize:"75%"}'> |
| 119 |
<li><img width=10 height=10 alt="small" src="../images/note.gif"/><br><span style="font-size: small">small</span></li> |
| 120 |
<li><img width=15 height=15 alt="medium" src="../images/note.gif"/><br><span style="font-size: medium">medium</span></li> |
| 121 |
<li><img width=20 height=20 alt="large" src="../images/note.gif"/><br><span style="font-size: large">large</span></li> |
| 122 |
</ol> |
| 123 |
</div> |
| 124 |
<br><br> |
| 125 |
|
| 126 |
<h2>Standalone ruler example:</h2> |
| 127 |
|
| 128 |
<div style="width:2in;border-top:1px solid black;"> |
| 129 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='count:17, style:{height:".4em"}'></div> |
| 130 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='count:9, style:{height:".4em"}'></div> |
| 131 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='count:5, style:{height:".4em"}'></div> |
| 132 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='count:3, style:{height:".4em"}'></div> |
| 133 |
<ol data-dojo-type="dijit/form/HorizontalRuleLabels" data-dojo-props='labelStyle:"font-style:monospace;fontSize:.7em;margin:-1em 0px 0px -.35em;"'> |
| 134 |
<li></li> |
| 135 |
<li>1</li> |
| 136 |
<li>2</li> |
| 137 |
</ol> |
| 138 |
</div> |
| 139 |
|
| 140 |
<h2>Horizontal, with buttons, disabled (to show styling):</h2> |
| 141 |
|
| 142 |
<div id="sliderH2" aria-label="horizontal slider 2" data-dojo-type="dijit/form/HorizontalSlider" data-dojo-props='name:"horizontalH2", |
| 143 |
onChange:function(val){ dom.byId("slider1input").value = val; }, |
| 144 |
value:10, |
| 145 |
maximum:100, |
| 146 |
minimum:0, |
| 147 |
disabled:true, |
| 148 |
showButtons:true, |
| 149 |
intermediateChanges:true, |
| 150 |
style:{width:"50%", height:"20px"} |
| 151 |
'> |
| 152 |
<ol data-dojo-type="dijit/form/HorizontalRuleLabels" data-dojo-props='container:"topDecoration", style:{height:"1.2em", fontSize:"75%"}, count:7, constraints:{pattern:"#.00%"}'></ol> |
| 153 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='container:"topDecoration", count:7, style:"height:5px;"'></div> |
| 154 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='container:"bottomDecoration", count:5, style:"height:5px;"'></div> |
| 155 |
<ol data-dojo-type="dijit/form/HorizontalRuleLabels" data-dojo-props='container:"bottomDecoration", style:{height:"1em", fontSize:"75%"}'> |
| 156 |
<li>lowest</li> |
| 157 |
<li>normal</li> |
| 158 |
<li>highest</li> |
| 159 |
</ol> |
| 160 |
</div> |
| 161 |
|
| 162 |
|
| 163 |
<script> |
| 164 |
// so robot can get to it easily |
| 165 |
document.displayData=function(){ |
| 166 |
var f = document.getElementById("form1"); |
| 167 |
var s = ""; |
| 168 |
for(var i = 0; i < f.elements.length; i++){ |
| 169 |
var elem = f.elements[i]; |
| 170 |
if(elem.nodeName.toLowerCase() == "button" || elem.type=="submit" || elem.type=="button") { continue; } |
| 171 |
s += elem.name + ": " + elem.value + "\n"; |
| 172 |
} |
| 173 |
return s; |
| 174 |
} |
| 175 |
</script> |
| 176 |
|
| 177 |
<div> |
| 178 |
<button name="button" onclick="alert(displayData()); return false;">view data</button> |
| 179 |
<input type="submit" name="submit" /> |
| 180 |
</div> |
| 181 |
|
| 182 |
</form> |
| 183 |
|
| 184 |
<h2>Fractional Slider Example</h2> |
| 185 |
initial value=0.28, min=0, max=2, onChange event triggers input box value change when you mouse up or tab away<br><br> |
| 186 |
<div id="fractionalSlider" data-dojo-type="dijit/form/HorizontalSlider" data-dojo-props=' |
| 187 |
onChange:function(val){ dom.byId("fractionalSliderInput").value = val; }, |
| 188 |
value:0.28, |
| 189 |
maximum:2, |
| 190 |
minimum:0, |
| 191 |
discreteValues:101, |
| 192 |
"aria-label":"fractional slider", |
| 193 |
style:{width:"357px"} |
| 194 |
'> |
| 195 |
<div data-dojo-type="dijit/form/HorizontalRule" data-dojo-props='container:"bottomDecoration", count:101, style:{height:"5px"}'></div> |
| 196 |
</div> |
| 197 |
<label for="fractionalSliderInput">Fractional Slider Value:</label><input readonly id="fractionalSliderInput" size="10" value="0.28"/> |
| 198 |
</body> |
| 199 |
</html> |