0
|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
3
|
|
4 <html>
|
|
5 <head>
|
|
6 <title>Slider (WebFX)</title>
|
|
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
8 <script type="text/javascript" src="local/webfxlayout.js"></script>
|
|
9
|
|
10 <script type="text/javascript" src="js/range.js"></script>
|
|
11 <script type="text/javascript" src="js/timer.js"></script>
|
|
12 <script type="text/javascript" src="js/slider.js"></script>
|
|
13 <link type="text/css" rel="StyleSheet" href="css/bluecurve/bluecurve.css" />
|
|
14
|
|
15 </head>
|
|
16 <body>
|
|
17 <!-- WebFX Layout Include -->
|
|
18 <script type="text/javascript">
|
|
19
|
|
20 var articleMenu= new WebFXMenu;
|
|
21 articleMenu.left = 384;
|
|
22 articleMenu.top = 86;
|
|
23 articleMenu.width = 140;
|
|
24 articleMenu.add(new WebFXMenuItem("Slider", "slider.html"));
|
|
25 articleMenu.add(new WebFXMenuItem("Implementation", "implementation.html"));
|
|
26 articleMenu.add(new WebFXMenuItem("API", "api.html"));
|
|
27 articleMenu.add(new WebFXMenuItem("Demo", "demo.html"));
|
|
28 articleMenu.add(new WebFXMenuSeparator);
|
|
29 articleMenu.add(new WebFXMenuItem("Download", "http://webfx.eae.net/download/slider102.zip"));
|
|
30 webfxMenuBar.add(new WebFXMenuButton("Article Menu", null, null, articleMenu));
|
|
31
|
|
32 webfxLayout.writeTitle("Slider");
|
|
33 webfxLayout.writeMenu();
|
|
34 webfxLayout.writeDesignedByEdger();
|
|
35
|
|
36 </script>
|
|
37 <div class="webfx-main-body">
|
|
38 <!-- end WebFX Layout Includes -->
|
|
39
|
|
40 <p>
|
|
41 <span class="date">2002-10-07</span>: First public version released<br />
|
|
42 <span class="date">2006-05-28</span>: Changed license to Apache Software License 2.0.<br />
|
|
43 </p>
|
|
44
|
|
45 <h2>Introduction</h2>
|
|
46
|
|
47 <p>Sliders are useful controls for choosing a value in a range of values.
|
|
48 Common uses are volume controls, seekers for movie and sound files as well
|
|
49 as color pickers. A few people have asked for an update to the old
|
|
50 <a href="http://webfx.eae.net/dhtml/slidebar/slidebar.html">Slidebar</a>
|
|
51 component to make it work in Mozilla and work better in IE. But since the
|
|
52 original control was very basic and was not very usable I decided to
|
|
53 create a new one.</p>
|
|
54
|
|
55 <form onsubmit="return false;">
|
|
56 <div class="slider" id="slider-1" tabIndex="1" style="width: auto; margin: 10px;">
|
|
57 <input class="slider-input" id="slider-input-1"/>
|
|
58 </div>
|
|
59 </form>
|
|
60
|
|
61 <script type="text/javascript">
|
|
62
|
|
63 var sliderEl = document.getElementById ? document.getElementById("slider-1") : null;
|
|
64 var inputEl = document.forms[0]["slider-input-1"];
|
|
65 var s = new Slider(sliderEl, inputEl);
|
|
66 s.onchange = function () {
|
|
67 window.status = "Value: " + s.getValue();
|
|
68 };
|
|
69 s.setValue(50);
|
|
70
|
|
71 </script>
|
|
72
|
|
73 <p>When starting with the new slider a few main features where kept in mind:</p>
|
|
74
|
|
75 <ul>
|
|
76 <li>Degrade gracefully for browser without the needed DOM support. This is
|
|
77 achieved by using a basic text input as the base for the control. In case
|
|
78 the browser does not support the needed features then the input can be used
|
|
79 in the normal way.</li>
|
|
80 <li>Full mouse support. Lots of slider controls does not support anything beyond dragging
|
|
81 the handle. The goal was to allow the user to be able to both drag the handle
|
|
82 and hold down the mouse anywhere on the slider to move the handle towards the
|
|
83 mouse.</li>
|
|
84 <li>Full keyboard support. Once the slider is focused the arrow keys and Page Up /
|
|
85 Page Down can be used to change the value.</li>
|
|
86 <li>Mouse wheel support where available.</li>
|
|
87 <li>Skinable using different CSS files.</li>
|
|
88 </ul>
|
|
89
|
|
90 <h2>Requirements</h2>
|
|
91
|
|
92 <p>The slider works in <strong>any</strong> browser but the GUI component works in
|
|
93 browsers with simple DOM level 1 support with one IE extended proprietary property.
|
|
94 That property is <code>offsetWidth</code> (and <code>offsetHeight</code>) and this is
|
|
95 known to be supported by IE5+, Mozilla 1.0+, Konqueror 3+ and it is assumed other future
|
|
96 browsers will support this as well because it has become a de facto standard.</p>
|
|
97
|
|
98 <h2>Usage</h2>
|
|
99
|
|
100 <p>To use the slider we have to include a few JS files and a CSS file.</p>
|
|
101
|
|
102 <pre>
|
|
103 <script type="text/javascript" src="<a href="js/range.js">js/range.js</a>"></script>
|
|
104 <script type="text/javascript" src="<a href="js/timer.js">js/timer.js</a>"></script>
|
|
105 <script type="text/javascript" src="<a href="js/slider.js">js/slider.js</a>"></script>
|
|
106 <link type="text/css" rel="StyleSheet" href="<a href="css/winclassic.css">css/winclassic.css</a>" />
|
|
107 </pre>
|
|
108
|
|
109 <p>Then we need to define the HTML to use for the slider. Something like this:</p>
|
|
110
|
|
111 <pre>
|
|
112 <div class="slider" id="slider-1" tabIndex="1">
|
|
113 <input class="slider-input" id="slider-input-1"
|
|
114 name="slider-input-1"/>
|
|
115 </div>
|
|
116 </pre>
|
|
117
|
|
118 <p>After this we have to create the JS object that handles the logic. If we only
|
|
119 plan to use this in pages and applications that you know will support the dynamic
|
|
120 slider control we can use the following script block. This should be placed directly
|
|
121 after the slider div.</p>
|
|
122
|
|
123 <pre>
|
|
124 <script type="text/javascript">
|
|
125
|
|
126 var s = new Slider(document.getElementById("slider-1"),
|
|
127 document.getElementById("slider-input-1"));
|
|
128
|
|
129 </script>
|
|
130 </pre>
|
|
131
|
|
132 <p>If we however cannot guarantee that all user uses browsers that support
|
|
133 <code>document.getElementById</code> we should use <code>document.forms</code>
|
|
134 to find the input and test whether <code>document.getElementById</code> is
|
|
135 defined.</p>
|
|
136
|
|
137 <pre>
|
|
138 <script type="text/javascript">
|
|
139
|
|
140 var sliderEl = document.getElementById ?
|
|
141 document.getElementById("slider-1") : null;
|
|
142 var inputEl = document.forms[0]["slider-input-1"];
|
|
143 var s = new Slider(sliderEl, inputEl);
|
|
144
|
|
145 </script>
|
|
146 </pre>
|
|
147
|
|
148 <p>
|
|
149 <a href="slider.html">Slider</a><br />
|
|
150 <a href="implementation.html">Implementation</a><br />
|
|
151 <a href="api.html">API</a><br />
|
|
152 <a href="demo.html">Demo</a><br />
|
|
153 <a href="http://webfx.eae.net/download/slider102.zip">Download</a>
|
|
154 </p>
|
|
155
|
|
156 <p class="author">Author: Erik Arvidsson</p>
|
|
157
|
|
158 <!-- end webfx-main-body -->
|
|
159 </div>
|
|
160
|
|
161 </body>
|
|
162 </html>
|