Skip to content

Commit

Permalink
Update files for 7.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
leongersen committed Dec 27, 2014
1 parent 89e5940 commit 7f50c48
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 46 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ Bower users can install all compiled and minified files easily using `bower inst

Changelog
---------
###7.0.10
+ Fixed an issue where calling `.val(undefined)` wouldn't match specification (#383);
+ Values in `range` are now properly sorted before being used (and can thus be passed in any order) (#393);
+ Fixed an error in `.noUiSlider('step')` where JS floating point precision would mess up a comparison (#391);
+ Fixed the slider styles failing when CSS `direction: rtl` is set (#275, #377);
+ Fixed throwing an error when running `.noUiSlider` on an empty selection (#325);
+ Fixed the filter function for the pips plugin not always being called (#365);

###7.0.9
+ Fixed an issue when using the pips plugin with sliders not starting at `0`. (#357)

Expand Down
70 changes: 50 additions & 20 deletions distribute/jquery.nouislider.all.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! noUiSlider - 7.0.9 - 2014-10-08 16:49:44 */
/*! noUiSlider - 7.0.10 - 2014-12-27 14:50:46 */

(function(){

Expand Down Expand Up @@ -75,7 +75,7 @@ var

// Rounding away decimals might cause a value of -0
// when using very small ranges. Remove those cases.
if ( decimals && parseFloat(input.toFixed(decimals)) === 0 ) {
if ( decimals !== false && parseFloat(input.toFixed(decimals)) === 0 ) {
input = 0;
}

Expand Down Expand Up @@ -697,6 +697,12 @@ var
return $.isArray(a) ? a : [a];
}

// Counts decimals
function countDecimals ( numStr ) {
var pieces = numStr.split(".");
return pieces.length > 1 ? pieces[1].length : 0;
}


var
// Cache the document selector;
Expand Down Expand Up @@ -933,22 +939,30 @@ var
this.snap = snap;
this.direction = direction;

var that = this, index;
var index, ordered = [ /* [0, 'min'], [1, '50%'], [2, 'max'] */ ];

// Loop all entries.
// Map the object keys to an array.
for ( index in entry ) {
if ( entry.hasOwnProperty(index) ) {
handleEntryPoint(index, entry[index], that);
ordered.push([entry[index], index]);
}
}

// Sort all entries by value (numeric sort).
ordered.sort(function(a, b) { return a[0] - b[0]; });

// Convert all entries to subranges.
for ( index = 0; index < ordered.length; index++ ) {
handleEntryPoint(ordered[index][1], ordered[index][0], this);
}

// Store the actual step values.
that.xNumSteps = that.xSteps.slice(0);
// xSteps is sorted in the same order as xPct and xVal.
this.xNumSteps = this.xSteps.slice(0);

for ( index in that.xNumSteps ) {
if ( that.xNumSteps.hasOwnProperty(index) ) {
handleStepPoint(Number(index), that.xNumSteps[index], that);
}
// Convert all numeric steps to the percentage of the subrange they represent.
for ( index = 0; index < this.xNumSteps.length; index++ ) {
handleStepPoint(index, this.xNumSteps[index], this);
}
}

Expand Down Expand Up @@ -1903,9 +1917,25 @@ function closure ( target, options, originalOptions ){
var retour = $.map($Locations, function( location, index ){

var step = $Spectrum.getApplicableStep( location ),

// As per #391, the comparison for the decrement step can have some rounding issues.
// Round the value to the precision used in the step.
stepDecimals = countDecimals(String(step[2])),

// Get the current numeric value
value = $Values[index],
increment = step[2],
decrement = (value - step[2]) >= step[1] ? step[2] : step[0];

// To move the slider 'one step up', the current step value needs to be added.
// Use null if we are at the maximum slider value.
increment = location === 100 ? null : step[2],

// Going 'one step down' might put the slider in a different sub-range, so we
// need to switch between the current or the previous step.
prev = Number((value - step[2]).toFixed(stepDecimals)),

// If the value fits the step, return the current step value. Otherwise, use the
// previous step. Return null if the slider is at its minimum value.
decrement = location === 0 ? null : (prev >= step[1]) ? step[2] : (step[0] || false);

return [[decrement, increment]];
});
Expand Down Expand Up @@ -1964,11 +1994,6 @@ function closure ( target, options, originalOptions ){
// Run the standard initializer
function initialize ( originalOptions ) {

// Throw error if group is empty.
if ( !this.length ){
throw new Error("noUiSlider: Can't initialize slider on empty selection.");
}

// Test the options once, not for every slider.
var options = testOptions( originalOptions, this );

Expand Down Expand Up @@ -2028,7 +2053,7 @@ function closure ( target, options, originalOptions ){
}

// If no value is passed, this is 'get'.
if ( arg === undefined ) {
if ( !arguments.length ) {
var first = $(this[0]);
return valMethod(first).call(first);
}
Expand Down Expand Up @@ -2224,22 +2249,27 @@ function closure ( target, options, originalOptions ){
element.addClass('noUi-pips noUi-pips-'+style);

function getSize( type, value ){
return [ '-normal', '-large', '-sub' ][(type&&filterFunc) ? filterFunc(value, type) : type];
return [ '-normal', '-large', '-sub' ][type];
}

function getTags( offset, source, values ) {
return 'class="' + source + ' ' +
source + '-' + style + ' ' +
source + getSize(values[1], values[0]) +
'" style="' + CSSstyle + ': ' + offset + '%"';
}

function addSpread ( offset, values ){

if ( direction ) {
offset = 100 - offset;
}

// Apply the filter function, if it is set.
values[1] = (values[1] && filterFunc) ? filterFunc(values[0], values[1]) : values[1];

// Add a marker for every point
element.append('<div '+getTags(offset, 'noUi-marker', values)+'></div>');
element.append('<div ' + getTags(offset, 'noUi-marker', values) + '></div>');

// Values are only appended for points marked '1' or '2'.
if ( values[1] ) {
Expand Down
4 changes: 2 additions & 2 deletions distribute/jquery.nouislider.all.min.js

Large diffs are not rendered by default.

59 changes: 42 additions & 17 deletions distribute/jquery.nouislider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! noUiSlider - 7.0.9 - 2014-10-08 16:49:44 */
/*! noUiSlider - 7.0.10 - 2014-12-27 14:50:46 */

/*jslint browser: true */
/*jslint white: true */
Expand Down Expand Up @@ -49,6 +49,12 @@
return $.isArray(a) ? a : [a];
}

// Counts decimals
function countDecimals ( numStr ) {
var pieces = numStr.split(".");
return pieces.length > 1 ? pieces[1].length : 0;
}


var
// Cache the document selector;
Expand Down Expand Up @@ -285,22 +291,30 @@
this.snap = snap;
this.direction = direction;

var that = this, index;
var index, ordered = [ /* [0, 'min'], [1, '50%'], [2, 'max'] */ ];

// Loop all entries.
// Map the object keys to an array.
for ( index in entry ) {
if ( entry.hasOwnProperty(index) ) {
handleEntryPoint(index, entry[index], that);
ordered.push([entry[index], index]);
}
}

// Sort all entries by value (numeric sort).
ordered.sort(function(a, b) { return a[0] - b[0]; });

// Convert all entries to subranges.
for ( index = 0; index < ordered.length; index++ ) {
handleEntryPoint(ordered[index][1], ordered[index][0], this);
}

// Store the actual step values.
that.xNumSteps = that.xSteps.slice(0);
// xSteps is sorted in the same order as xPct and xVal.
this.xNumSteps = this.xSteps.slice(0);

for ( index in that.xNumSteps ) {
if ( that.xNumSteps.hasOwnProperty(index) ) {
handleStepPoint(Number(index), that.xNumSteps[index], that);
}
// Convert all numeric steps to the percentage of the subrange they represent.
for ( index = 0; index < this.xNumSteps.length; index++ ) {
handleStepPoint(index, this.xNumSteps[index], this);
}
}

Expand Down Expand Up @@ -1255,9 +1269,25 @@ function closure ( target, options, originalOptions ){
var retour = $.map($Locations, function( location, index ){

var step = $Spectrum.getApplicableStep( location ),

// As per #391, the comparison for the decrement step can have some rounding issues.
// Round the value to the precision used in the step.
stepDecimals = countDecimals(String(step[2])),

// Get the current numeric value
value = $Values[index],
increment = step[2],
decrement = (value - step[2]) >= step[1] ? step[2] : step[0];

// To move the slider 'one step up', the current step value needs to be added.
// Use null if we are at the maximum slider value.
increment = location === 100 ? null : step[2],

// Going 'one step down' might put the slider in a different sub-range, so we
// need to switch between the current or the previous step.
prev = Number((value - step[2]).toFixed(stepDecimals)),

// If the value fits the step, return the current step value. Otherwise, use the
// previous step. Return null if the slider is at its minimum value.
decrement = location === 0 ? null : (prev >= step[1]) ? step[2] : (step[0] || false);

return [[decrement, increment]];
});
Expand Down Expand Up @@ -1316,11 +1346,6 @@ function closure ( target, options, originalOptions ){
// Run the standard initializer
function initialize ( originalOptions ) {

// Throw error if group is empty.
if ( !this.length ){
throw new Error("noUiSlider: Can't initialize slider on empty selection.");
}

// Test the options once, not for every slider.
var options = testOptions( originalOptions, this );

Expand Down Expand Up @@ -1380,7 +1405,7 @@ function closure ( target, options, originalOptions ){
}

// If no value is passed, this is 'get'.
if ( arg === undefined ) {
if ( !arguments.length ) {
var first = $(this[0]);
return valMethod(first).call(first);
}
Expand Down
4 changes: 2 additions & 2 deletions distribute/jquery.nouislider.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7f50c48

Please sign in to comment.