Skip to content

Commit

Permalink
[ merge hughbris ]
Browse files Browse the repository at this point in the history
- tidy up some small things that bothered me
- remove a tiny bit of redundant code

- merges and closes simeydotme#88
- merges and closes simeydotme#86
- closes simeydotme#87
  • Loading branch information
simeydotme committed Mar 15, 2016
1 parent 22092c8 commit 5df6b22
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/js/jquery-ui-slider-pips.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@
}


// we don't want the step ever to be a floating point or negative (or 0 actually, so we'll set it to 1 in that case).
slider.options.pipStep = Math.abs(Math.round( options.step )) || 1;
// we don't want the step ever to be a floating point or negative
// (or 0 actually, so we'll set it to 1 in that case).
slider.options.pipStep = Math.abs( Math.round( options.step ) ) || 1;

// get rid of all pips that might already exist.
slider.element
Expand Down Expand Up @@ -288,7 +289,10 @@
classes = "ui-slider-pip",
css = "",
value = slider.value(),
values = slider.values();
values = slider.values(),
labelValue,
classLabel,
labelIndex;

if ( which === "first" ) {

Expand All @@ -301,19 +305,21 @@
}

// labelValue is the actual value of the pip based on the min/step
var labelValue = min + ( slider.options.step * number );
labelValue = min + ( slider.options.step * number );

// classLabel replaces any decimals with hyphens
var classLabel = labelValue.toString().replace(".","-");
classLabel = labelValue.toString().replace(".", "-");

// get the index needed for selecting labels out of the array
labelIndex = Math.round( ( number - min ) / options.step );

// we need to set the human-readable label to either the
// corresponding element in the array, or the appropriate
// item in the object... or an empty string.

if ( $.type(options.labels) === "array" ) {

var labelIndex = Math.round( ( number - min ) / options.step );
label = options.labels[labelIndex] || "";
label = options.labels[ labelIndex ] || "";

} else if ( $.type( options.labels ) === "object" ) {

Expand All @@ -331,9 +337,7 @@

// set other labels, but our index should start at -1
// because of the first pip.

var labelIndex = Math.round( ( number - min ) / options.step ) - 1;
label = options.labels.rest[labelIndex] || "";
label = options.labels.rest[ labelIndex - 1 ] || "";

} else {

Expand Down Expand Up @@ -448,9 +452,9 @@
// create our first pip
collection += createPip("first");

// for every stop in the slider; we create a pip.
for ( p = slider.options.pipStep; p < pips; p = p + slider.options.pipStep ) {
collection += createPip( p );
// for every stop in the slider where we need a pip; create one.
for ( p = slider.options.pipStep; p < pips; p += slider.options.pipStep ) {
collection += createPip( p );
}

// create our last pip
Expand Down

0 comments on commit 5df6b22

Please sign in to comment.