Skip to content

Commit dcdca89

Browse files
committed
added slider api
1 parent 7a6b28d commit dcdca89

File tree

4 files changed

+423
-0
lines changed

4 files changed

+423
-0
lines changed

docs/forms/sliders/events.html

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>jQuery Mobile Docs - Select events</title>
7+
<link rel="stylesheet" href="../../../themes/default/" />
8+
<link rel="stylesheet" href="../../_assets/css/jqm-docs.css"/>
9+
<script src="../../../js/jquery.js"></script>
10+
<script src="../../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
11+
<script src="../../_assets/js/jqm-docs.js"></script>
12+
<script src="../../../js/"></script>
13+
</head>
14+
<body>
15+
16+
<div data-role="page" class="type-interior">
17+
18+
<div data-role="header" data-theme="f">
19+
<h1>Select Menus</h1>
20+
<a href="../../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
21+
</div><!-- /header -->
22+
23+
<div data-role="content">
24+
<div class="content-primary">
25+
26+
<form action="#" method="get">
27+
28+
<h2>Sliders</h2>
29+
30+
<ul data-role="controlgroup" data-type="horizontal" class="localnav">
31+
<li><a href="index.html" data-role="button" data-transition="fade">Basics</a></li>
32+
<li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
33+
<li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
34+
<li><a href="events.html" data-role="button" data-transition="fade" class="ui-btn-active">Events</a></li>
35+
</ul>
36+
37+
<p>Since the native input field is used as a proxy for the custom slider, you can watch for events on the original, native input field instead of needing to go through the slider plugin. Bind to the change event by type: change, blur, focus, keypress, click, etc.</p>
38+
<pre><code>
39+
$( ".selector" ).bind( "change", function(event, ui) {
40+
...
41+
});
42+
</code></pre>
43+
44+
<p>The slider plugin has the following custom event:</p>
45+
46+
<dl>
47+
48+
<dt><code>create</code> triggered when a slider is created</dt>
49+
<dd>
50+
<p>This event is used to find out when a custom slider was created. It is not used to create a custom slider. The slider create event can be used like this: </p>
51+
52+
<pre><code>
53+
$( ".selector" ).slider({
54+
create: function(event, ui) { ... }
55+
});
56+
</code></pre>
57+
</dd>
58+
59+
60+
</dl>
61+
62+
</form>
63+
</div><!--/content-primary -->
64+
65+
<div class="content-secondary">
66+
67+
<div data-role="collapsible" data-collapsed="true" data-theme="b">
68+
69+
<h3>More in this section</h3>
70+
71+
<ul data-role="listview" data-theme="c" data-dividertheme="d">
72+
73+
<li data-role="list-divider">Form elements</li>
74+
<li><a href="../docs-forms.html">Form basics</a></li>
75+
<li><a href="../forms-all.html">Form element gallery</a></li>
76+
<li><a href="../texts/index.html">Text inputs</a></li>
77+
<li><a href="../forms-search.html">Search inputs</a></li>
78+
<li data-theme="a"><a href="index.html">Slider</a></li>
79+
<li><a href="../forms-switch.html">Flip toggle switch</a></li>
80+
<li><a href="../forms-radiobuttons.html">Radio buttons</a></li>
81+
<li><a href="../forms-checkboxes.html">Checkboxes</a></li>
82+
<li><a href="../selects/index.html">Select menus</a></li>
83+
<li><a href="../forms-themes.html">Theming forms</a></li>
84+
<li><a href="../forms-all-native.html">Native form elements</a></li>
85+
<li><a href="../forms-sample.html">Submitting forms</a></li>
86+
<li><a href="../plugin-eventsmethods.html">Plugin methods</a></li>
87+
88+
</ul>
89+
</div>
90+
</div>
91+
92+
</div><!-- /content -->
93+
94+
<div data-role="footer" class="footer-docs" data-theme="c">
95+
<p>&copy; 2011 The jQuery Project</p>
96+
</div>
97+
98+
</div><!-- /page -->
99+
100+
</body>
101+
</html>
102+

docs/forms/sliders/index.html

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>jQuery Mobile Docs - Select</title>
7+
<link rel="stylesheet" href="../../../themes/default/" />
8+
<link rel="stylesheet" href="../../_assets/css/jqm-docs.css"/>
9+
<script src="../../../js/jquery.js"></script>
10+
<script src="../../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
11+
<script src="../../_assets/js/jqm-docs.js"></script>
12+
<script src="../../../js/"></script>
13+
</head>
14+
<body>
15+
16+
<div data-role="page" class="type-interior">
17+
18+
<div data-role="header" data-theme="f">
19+
<h1>Select Menus</h1>
20+
<a href="../../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
21+
</div><!-- /header -->
22+
23+
<div data-role="content">
24+
<div class="content-primary">
25+
26+
<form action="#" method="get">
27+
<h2>Sliders</h2>
28+
29+
<ul data-role="controlgroup" data-type="horizontal" class="localnav">
30+
<li><a href="index.html" data-role="button" data-transition="fade" class="ui-btn-active">Basics</a></li>
31+
<li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
32+
<li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
33+
<li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
34+
</ul>
35+
36+
<p>To add a slider widget to your page, start with an <code>input</code> with a new HTML5 <code>type="range"</code> attribute. Specify the <code>value</code> (current value), <code>min</code> and <code>max</code> attribute values to configure the slider. The framework will parse these attributes to configure the slider. </p>
37+
<p>As you drag the slider, the input will update and vice-versa so they are always in sync so you can submit the slider value with form in a simple way. Set the <code>for</code> attribute of the <code>label</code> to match the ID of the <code>input</code> so they are semantically associated and wrap them in a <code>div</code> with the <code> data-role="fieldcontain"</code> attribute to group them.</p>
38+
39+
<pre><code>
40+
&lt;div data-role=&quot;fieldcontain&quot;&gt;
41+
&lt;label for=&quot;slider&quot;&gt;Input slider:&lt;/label&gt;
42+
&lt;input type=&quot;range&quot; name=&quot;slider&quot; id=&quot;slider&quot; value=&quot;0&quot; min=&quot;0&quot; max=&quot;100&quot; /&gt;
43+
&lt;/div&gt;
44+
</code></pre>
45+
46+
<p>An example of a slider and input is displayed like this:</p>
47+
<div data-role="fieldcontain">
48+
<label for="slider-1">Input slider:</label>
49+
<input type="range" name="slider-1" id="slider-1" value="0" min="0" max="100" data-theme="b" data-track-theme="a" />
50+
</div>
51+
52+
<p>By setting the <code>min</code> and <code>max</code>attributes you can configure the allowable number range of the slider track. The <code>value</code> of the input is used to configure the starting position of the handle and the value populated in the text input.</p>
53+
54+
<p>The slider with a min of 500, max of 5,000 and initial value of 2,500</p>
55+
<div data-role="fieldcontain">
56+
<label for="slider-2">Input slider:</label>
57+
<input type="range" name="slider-2" id="slider-2" value="2500" min="500" max="5000" />
58+
</div>
59+
60+
<p>Sliders also respond to the keyboards shortcuts. To increase the current value the Right Arrow, Up Arrow, and Page Up keys can be used. To decrease the current value the Left Arrow, Down Arrow, and Page Down keys can be used. To move the slider to its minimum or maximum value use the Home and End keys respectively.</p>
61+
62+
63+
<h2>Refreshing a slider</h2>
64+
65+
<p>If you manipulate a slider via JavaScript, you must call the refresh method on it to update the visual styling. Here is an example:</p>
66+
67+
<code>
68+
$("input[type=range]").val(60).slider("refresh");
69+
</code>
70+
71+
72+
</form>
73+
</div><!--/content-primary -->
74+
75+
<div class="content-secondary">
76+
77+
<div data-role="collapsible" data-collapsed="true" data-theme="b">
78+
79+
<h3>More in this section</h3>
80+
81+
<ul data-role="listview" data-theme="c" data-dividertheme="d">
82+
83+
<li data-role="list-divider">Form elements</li>
84+
<li><a href="../docs-forms.html">Form basics</a></li>
85+
<li><a href="../forms-all.html">Form element gallery</a></li>
86+
<li><a href="../texts/index.html">Text inputs</a></li>
87+
<li><a href="../forms-search.html">Search inputs</a></li>
88+
<li data-theme="a"><a href="index.html">Slider</a></li>
89+
<li><a href="../forms-switch.html">Flip toggle switch</a></li>
90+
<li><a href="../forms-radiobuttons.html">Radio buttons</a></li>
91+
<li><a href="../forms-checkboxes.html">Checkboxes</a></li>
92+
<li><a href="../selects/index.html">Select menus</a></li>
93+
<li><a href="../forms-themes.html">Theming forms</a></li>
94+
<li><a href="../forms-all-native.html">Native form elements</a></li>
95+
<li><a href="../forms-sample.html">Submitting forms</a></li>
96+
<li><a href="../plugin-eventsmethods.html">Plugin methods</a></li>
97+
98+
</ul>
99+
</div>
100+
</div>
101+
102+
</div><!-- /content -->
103+
104+
<div data-role="footer" class="footer-docs" data-theme="c">
105+
<p>&copy; 2011 The jQuery Project</p>
106+
</div>
107+
108+
</div><!-- /page -->
109+
110+
</body>
111+
</html>
112+

docs/forms/sliders/methods.html

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>jQuery Mobile Docs - Select methods</title>
7+
<link rel="stylesheet" href="../../../themes/default/" />
8+
<link rel="stylesheet" href="../../_assets/css/jqm-docs.css"/>
9+
<script src="../../../js/jquery.js"></script>
10+
<script src="../../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
11+
<script src="../../_assets/js/jqm-docs.js"></script>
12+
<script src="../../../js/"></script>
13+
</head>
14+
<body>
15+
16+
<div data-role="page" class="type-interior">
17+
18+
<div data-role="header" data-theme="f">
19+
<h2>Sliders</h2>
20+
<a href="../../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
21+
</div><!-- /header -->
22+
23+
<div data-role="content">
24+
<div class="content-primary">
25+
26+
<form action="#" method="get">
27+
28+
<h2>Sliders</h2>
29+
30+
<ul data-role="controlgroup" data-type="horizontal" class="localnav">
31+
<li><a href="index.html" data-role="button" data-transition="fade">Basics</a></li>
32+
<li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
33+
<li><a href="methods.html" data-role="button" data-transition="fade" class="ui-btn-active">Methods</a></li>
34+
<li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
35+
</ul>
36+
37+
<p>The slider plugin has the following methods:</p>
38+
39+
<dl>
40+
<dt><code>enable</code> enable a disabled select</dt>
41+
<dd>
42+
<pre><code>
43+
$('select').slider('enable');
44+
</code></pre>
45+
</dd>
46+
47+
<dt><code>disable</code> disable a select.</dt>
48+
<dd>
49+
<pre><code>
50+
$('select').slider('disable');
51+
</code></pre>
52+
</dd>
53+
54+
<dt><code>refresh</code> update the slider</dt>
55+
<dd>
56+
This is used to update the slider to reflect the native input element's value. Also, if you pass a true argument you can force the rebuild to happen.
57+
<pre><code>
58+
//refresh value
59+
$('select').slider('refresh');
60+
61+
//refresh and force rebuild
62+
$('select').slider('refresh', true);
63+
</code></pre>
64+
</dd>
65+
66+
</dl>
67+
68+
</form>
69+
</div><!--/content-primary -->
70+
71+
<div class="content-secondary">
72+
73+
<div data-role="collapsible" data-collapsed="true" data-theme="b">
74+
75+
<h3>More in this section</h3>
76+
77+
<ul data-role="listview" data-theme="c" data-dividertheme="d">
78+
79+
<li data-role="list-divider">Form elements</li>
80+
<li><a href="../docs-forms.html">Form basics</a></li>
81+
<li><a href="../forms-all.html">Form element gallery</a></li>
82+
<li><a href="../texts/index.html">Text inputs</a></li>
83+
<li><a href="../forms-search.html">Search inputs</a></li>
84+
<li data-theme="a"><a href="index.html">Slider</a></li>
85+
<li><a href="../forms-switch.html">Flip toggle switch</a></li>
86+
<li><a href="../forms-radiobuttons.html">Radio buttons</a></li>
87+
<li><a href="../forms-checkboxes.html">Checkboxes</a></li>
88+
<li><a href="../selects/index.html">Select menus</a></li>
89+
<li><a href="../forms-themes.html">Theming forms</a></li>
90+
<li><a href="../forms-all-native.html">Native form elements</a></li>
91+
<li><a href="../forms-sample.html">Submitting forms</a></li>
92+
<li><a href="../plugin-eventsmethods.html">Plugin methods</a></li>
93+
94+
</ul>
95+
</div>
96+
</div>
97+
98+
</div><!-- /content -->
99+
100+
<div data-role="footer" class="footer-docs" data-theme="c">
101+
<p>&copy; 2011 The jQuery Project</p>
102+
</div>
103+
104+
</div><!-- /page -->
105+
106+
</body>
107+
</html>
108+

0 commit comments

Comments
 (0)