Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
leongersen committed Apr 2, 2018
2 parents 14a96d1 + ebeac7d commit 1f629e4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion documentation/_run/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

$url = strtolower($_SERVER['REQUEST_URI']);

if ( strpos($url, '.js') || strpos($url, '.css') ) {
if ( strpos($url, '.js') || strpos($url, '.css') || strpos($url, '.html') ) {
return false;
}

Expand Down
11 changes: 8 additions & 3 deletions documentation/more.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,24 @@

<div class="view">

<p>noUiSlider has an update method that can change the <code>'margin'</code>, <code>'limit'</code>, <code>'step'</code>, <code>'range'</code>, <code>'animate'</code> and <code>'snap'</code> options.</p>
<p>noUiSlider has an update method that can change the <code>'margin'</code>, <code>'limit'</code>, <code>'step'</code>, <code>'range'</code>, <code>'pips'</code>, <code>'animate'</code> and <code>'snap'</code> options.</p>

<p>All other options require changes to the slider's HTML or event bindings.</p>

<p>To update any other option, destroy the slider using <code>slider.noUiSlider.destroy()</code> and create a new one. Events are unbound when destroying a slider.</p>

<p>The update method can be called as <code>slider.noUiSlider.updateOptions(newOptions, [fireSetEvent])</code>.</p>
<p>The update method can be called as:</p>

<pre><code>slider.noUiSlider.updateOptions(
newOptions, // Object
true // Boolean 'fireSetEvent'
);</code></pre>

<p>Options that can not be updated will be ignored without errors.</p>

<p>The <code>'update'</code> event fires after updating the slider.</p>

<p>By default, the sliders <strong>values remain unchanged</strong>. To update the slider values, <code>newOptions</code> may also contain a <code>start</code> property</a> that matches the signature of the <a href="/nouislider/slider-read-write/#section-setting"><code>set</code></a> method.</p>
<p>By default, the sliders <strong>values remain unchanged</strong>. To update the slider values, <code>newOptions</code> may also contain a <code>start</code> property</a> that matches the signature of the <a href="/nouislider/slider-read-write/#section-setting"><code>.set()</code></a> method.</p>

<p>The <code>'set'</code> event fires when the slider values are restored. If this is unwanted, you can pass <code>false</code> as the second parameter, <code>fireSetEvent</code>.</p>

Expand Down
4 changes: 3 additions & 1 deletion documentation/slider-read-write.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@

<p>By default, noUiSlider will format output with <strong>2 decimals</strong>.</p>

<p>Manual formatting can be very tedious, so noUiSlider has support for <a href="/wnumb">the wNumb formatting library</a>. wNumb offers a wide range of options and provides number validation.</p>
<p>Manual formatting can be error-prone, so noUiSlider has support for <a href="/wnumb">the wNumb formatting library</a>. wNumb offers a wide range of options and provides number validation.</p>

<p>Note that if the <code>.to()</code> method returns a <code>Number</code>, noUiSlider's <code>.get()</code> will also return <code>Number</code>s. See <a href="https://github.com/leongersen/noUiSlider/issues/813">this issue </a> for more details.

<div class="example">
<div id="slider-format"></div>
<input id="input-format">
Expand Down
4 changes: 4 additions & 0 deletions src/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
el.parentElement.removeChild(el);
}

function isSet ( value ) {
return value !== null && value !== undefined;
}

// Bindable version
function preventDefault ( e ) {
e.preventDefault();
Expand Down
16 changes: 8 additions & 8 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@
throw new Error("noUiSlider (" + VERSION + "): 'padding' option must be a positive number(s).");
}

if ( parsed.padding[0] >= 50 || parsed.padding[1] >= 50 ) {
throw new Error("noUiSlider (" + VERSION + "): 'padding' option must be less than half the range.");
if ( parsed.padding[0] + parsed.padding[1] >= 100 ) {
throw new Error("noUiSlider (" + VERSION + "): 'padding' option must not exceed 100% of the range.");
}
}

Expand Down Expand Up @@ -314,7 +314,7 @@

function testCssPrefix ( parsed, entry ) {

if ( entry !== undefined && typeof entry !== 'string' && entry !== false ) {
if ( typeof entry !== 'string' && entry !== false ) {
throw new Error("noUiSlider (" + VERSION + "): 'cssPrefix' must be a string or `false`.");
}

Expand All @@ -323,7 +323,7 @@

function testCssClasses ( parsed, entry ) {

if ( entry !== undefined && typeof entry !== 'object' ) {
if ( typeof entry !== 'object' ) {
throw new Error("noUiSlider (" + VERSION + "): 'cssClasses' must be an object.");
}

Expand Down Expand Up @@ -375,8 +375,8 @@
'ariaFormat': { r: false, t: testAriaFormat },
'format': { r: false, t: testFormat },
'tooltips': { r: false, t: testTooltips },
'cssPrefix': { r: false, t: testCssPrefix },
'cssClasses': { r: false, t: testCssClasses }
'cssPrefix': { r: true, t: testCssPrefix },
'cssClasses': { r: true, t: testCssClasses }
};

var defaults = {
Expand Down Expand Up @@ -433,7 +433,7 @@
Object.keys(tests).forEach(function( name ){

// If the option isn't set, but it is required, throw an error.
if ( options[name] === undefined && defaults[name] === undefined ) {
if ( !isSet(options[name]) && defaults[name] === undefined ) {

if ( tests[name].r ) {
throw new Error("noUiSlider (" + VERSION + "): '" + name + "' is required.");
Expand All @@ -442,7 +442,7 @@
return true;
}

tests[name].t( parsed, options[name] === undefined ? defaults[name] : options[name] );
tests[name].t( parsed, !isSet(options[name]) ? defaults[name] : options[name] );
});

// Forward pips options
Expand Down
1 change: 1 addition & 0 deletions src/nouislider.core.less
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
left: 0;
height: 100%;
width: 100%;
-ms-transform-origin: 0 0;
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/slider_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@
noUiSlider.create(slider, {
start: 1,
margin: 0, // Does not throw, issue #582
cssPrefix: null, // #856
step: null,
range: {
'min': 0,
'max': 10
Expand Down

0 comments on commit 1f629e4

Please sign in to comment.