-
-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f75b661
commit a43ce8e
Showing
15 changed files
with
542 additions
and
555 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php sect('click-pips'); ?> | ||
<h1>Moving the slider by clicking pips</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
|
||
<p><a href="https://github.com/leongersen/noUiSlider/issues/733">Issue #733</a> asks about clicking pips to move the slider to their value. noUiSlider 11 adds a <code>data-value</code> attribute to all <code>.noUi-value</code> elements that makes this easy.</code></code></p> | ||
|
||
<div class="example"> | ||
<div class="slider" id="slider-pips"></div> | ||
|
||
<?php run('click-pips-setup'); ?> | ||
<?php run('click-pips'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<div class="viewer-header">Setup</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('click-pips-setup'); ?> | ||
</div> | ||
|
||
<?php code('click-pips'); ?> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php sect('colored-connect'); ?> | ||
<h1>Colored Connect Elements</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
|
||
<p>noUiSlider's connect elements can be individually colored or otherwise styled.</p> | ||
|
||
<div class="example"> | ||
<div class="slider" id="slider-color"></div> | ||
<?php run('colored-setup'); ?> | ||
<?php run('colored'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<div class="viewer-header">Slider setup</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('colored-setup'); ?> | ||
</div> | ||
|
||
<?php code('colored'); ?> | ||
<?php loadShowCSS('colored'); ?> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php sect('colorpicker'); ?> | ||
<h1>Colorpicker</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
|
||
<p>We'll initialize all sliders with the same options, and use the <code>slide</code> callback to keep to color in sync with the slider values. This callback fires when the slider is moved by sliding, or when it is clicked or tapped.</p> | ||
|
||
<div id="colorpicker"> | ||
<div class="sliders" id="red"></div> | ||
<div class="sliders" id="green"></div> | ||
<div class="sliders" id="blue"></div> | ||
|
||
<div id="result"></div> | ||
<?php run('colorpicker-setcolor'); ?> | ||
<?php run('colorpicker-slider'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<div class="viewer-header">The HTML</div> | ||
|
||
<div class="viewer-content"> | ||
|
||
<pre class="language-markup"><code><div id="colorpicker"> | ||
<div class="sliders" id="red"></div> | ||
<div class="sliders" id="green"></div> | ||
<div class="sliders" id="blue"></div> | ||
|
||
<div class="result"></div> | ||
</div></code></pre> | ||
|
||
</div> | ||
|
||
<div class="viewer-header">The <code>setColor</code> function</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('colorpicker-setcolor'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Initializing the slider</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('colorpicker-slider'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">CSS</div> | ||
|
||
<div class="viewer-content"> | ||
<?php loadShowCSS('colorpicker'); ?> | ||
</div> | ||
|
||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php sect('dates'); ?> | ||
<h1>Working with dates</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
|
||
<p>As all dates in JavaScript can be represented as time, noUiSlider can handle them, too. This example will show you how to convert dates to numerical ranges, and then use the <code>update</code> event to display them in a pretty format.</p> | ||
|
||
<p>We'll be creating timestamps from strings. In order to do this easily, we'll define a new helper function. This function accepts a string, creates a <code>new Date</code> and then returns it as a timestamp.</p> | ||
|
||
<p>In in overview below you'll find the code used to run this example. For readability, all <strong>helper</strong> functions have been moved into their own tab.</p> | ||
|
||
<div class="example"> | ||
<div id="slider-date"></div> | ||
<span class="example-val" id="event-start"></span> | ||
<span class="example-val" id="event-end"></span> | ||
<?php run('date-timestamp'); ?> | ||
<?php run('date-helpers'); ?> | ||
<?php run('date-setup'); ?> | ||
<?php run('date-link'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<div class="viewer-header">Timestamps</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('date-timestamp'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Setup</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('date-setup'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Slider control</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('date-link'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Helper functions and formatting</div> | ||
|
||
<div class="viewer-content"> | ||
<p>The <code>nth</code> function was borrowed from <a onclick="return trackLink(this, 'outlink','stackoverflow nth')" href="http://stackoverflow.com/questions/15397372/javascript-new-date-ordinal-st-nd-rd-th">this StackOverflow question</a>.</p> | ||
<?php code('date-helpers'); ?> | ||
</div> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php sect('hiding-tooltips'); ?> | ||
<h1>Only showing tooltips when sliding handles</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
|
||
<p><a href="https://github.com/leongersen/noUiSlider/issues/836">Issue #836</a> requested a way to toggle tooltips after slider creation. This effect can be achieved by using the <code>.noUi-active</code> class to show and hide the tooltips. No additional JavaScript is involved.</p> | ||
|
||
<div class="example"> | ||
<div class="slider" id="slider-hide"></div> | ||
|
||
<?php run('hiding-tooltips'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<?php loadShowCSS('hiding-tooltips'); ?> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php sect('html5'); ?> | ||
<h1>Using HTML5 input elements</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
<p>noUiSlider's <code>'update'</code> method is useful for synchronizing with other elements, such as <code><input></code> (<code>type="number"</code>) and <code><select></code>.</p> | ||
|
||
<div class="example"> | ||
<div id="html5"></div> | ||
<select id="input-select"></select> | ||
<input type="number" min="-20" max="40" step="1" id="input-number"> | ||
<?php run('html5-append'); ?> | ||
<?php run('html5-slider'); ?> | ||
<?php run('html5-link'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<div class="viewer-header">Appending <code><option></code> elements</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('html5-append', true); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Initializing the slider</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('html5-slider'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Updating the <code><select></code> and <code><input></code></div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('html5-link'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Example CSS</div> | ||
|
||
<div class="viewer-content"> | ||
<?php loadShowCSS('html5'); ?> | ||
</div> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php sect('huge-numbers'); ?> | ||
<h1>Using the slider with huge numbers</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
|
||
<p>If you are working with arbitrarily large numbers, you should <strong>not use these directly in noUiSlider</strong>, as you'll run into some JavaScript limitations. Instead, you should <strong>map</strong> your values to an <code>array</code>.</p> | ||
|
||
<p>Numbers is JavaScript are <a href="">Double Precision Floats</a>, which can store numbers up to 2^53 <em>(9007199254740992)</em> precisely. For reference, see <a href="http://stackoverflow.com/questions/15529337/prevent-javascript-number-function-from-rounding-big-numbers">this StackOverflow question</a>, or <a href="https://github.com/leongersen/noUiSlider/issues/427">issue #427 filed on GitHub</a>.</p> | ||
|
||
<p>As an example, see the <code>'range'</code> option for a RAM selector offering 14 steps from 512MB to 8GB. The <code>'step'</code> are ommited for clarity. The values are provided as bytes. A better solution would be to abstract the byte values away from the slider, looking up the byte values in an array. This keeps the slider configuration simple and prevents issues with floating point precision.</p> | ||
|
||
<p><em>(These values fit within the limit just fine, but demonstrate the point really well!)</em></p> | ||
|
||
<div class="example"> | ||
<div id="slider-huge"></div> | ||
<span class="example-val" id="huge-value"></span> | ||
<?php run('huge-numbers-setup'); ?> | ||
<?php run('huge-numbers'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<?php code('huge-numbers-direct'); ?> | ||
|
||
<div class="viewer-header">Setup</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('huge-numbers-setup'); ?> | ||
</div> | ||
|
||
<?php code('huge-numbers'); ?> | ||
|
||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php sect('keyboard'); ?> | ||
<h1>Adding keyboard support</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
|
||
<p>Much like the keypress example, handles can be made keyboard-focusable.</p> | ||
|
||
<div class="example"> | ||
<input placeholder="Hit tab to focus on the handle." style="width: 100%"> | ||
<div id="keyboard"></div> | ||
<?php run('keyboard-slider'); ?> | ||
<?php run('keyboard'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<div class="viewer-header">Initializing the slider</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('keyboard-slider'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Listen to <code>keypress</code> on the handle</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('keyboard'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">CSS</div> | ||
|
||
<div class="viewer-content"> | ||
<?php loadShowCSS('keyboard'); ?> | ||
</div> | ||
|
||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php sect('keypress'); ?> | ||
<h1>Changing the slider by keypress</h1> | ||
|
||
<section> | ||
|
||
<div class="view"> | ||
|
||
<p>To keep the library small, features like keyboard interaction haven't been included. However, adding features to input fields linked to a slider is easy. noUiSlider provides API's to help you. In this example, pressing the keyboard arrow keys will increase/decrease the slider by one step.</p> | ||
|
||
<p>This example uses the <code>'step'</code> API to determine by how much the slider should be changed. You don't need this function if your slider is linear. In that case, increase/decrease the value with the ammount of your <code>step</code>.</p> | ||
|
||
<p>We'll listen to keydown on the <code>'#input-with-keypress'</code> element, and pass the event to a function so we can read the code that identifies the key.</p> | ||
|
||
<p>Note that the slider value will be a <code>string</code>, so we'll need to parse it to an integer.</p> | ||
|
||
<div class="example"> | ||
<div id="keypress"></div> | ||
<input type="text" id="input-with-keypress-1"> | ||
<input type="text" id="input-with-keypress-0"> | ||
<?php run('keypress-slider'); ?> | ||
<?php run('keypress-event'); ?> | ||
</div> | ||
</div> | ||
|
||
<div class="side"> | ||
|
||
<div class="viewer-header">Initializing the slider and linking the input</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('keypress-slider'); ?> | ||
</div> | ||
|
||
<div class="viewer-header">Listen to <code>keypress</code> on the input</div> | ||
|
||
<div class="viewer-content"> | ||
<?php code('keypress-event'); ?> | ||
</div> | ||
|
||
</div> | ||
</section> |
Oops, something went wrong.