Skip to content

Commit

Permalink
pips classes
Browse files Browse the repository at this point in the history
  • Loading branch information
leongersen committed Apr 24, 2016
1 parent 3971cd9 commit 772dc92
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 68 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ An extensive documentation, including **examples**, **options** and **configurat

Changelog
---------
### 8.5.0 (latest)
### 8.5.1 (latest)
- Fix: class mixup in 8.5.0 merge
- Change: position pips markers relatively

### 8.5.0
- Added: ability to completely override the classes used by the slider
- Fix: removed invalid stopPropagation loop
- Fix: source properly lints
Expand Down
61 changes: 36 additions & 25 deletions distribute/nouislider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! nouislider - 8.5.0 - 2016-04-24 14:53:53 */
/*! nouislider - 8.5.1 - 2016-04-24 16:00:29 */

(function (factory) {

Expand Down Expand Up @@ -760,7 +760,12 @@
markerNormal: 'marker-normal',
markerLarge: 'marker-large',
markerSub: 'marker-sub',
value: 'value'
value: 'value',
valueHorizontal: 'value-horizontal',
valueVertical: 'value-vertical',
valueNormal: 'value-normal',
valueLarge: 'value-large',
valueSub: 'value-sub'
}
};

Expand Down Expand Up @@ -1147,35 +1152,40 @@ function closure ( target, options, originalOptions ){

function addMarking ( spread, filterFunc, formatter ) {

var classPips, classMarker,
element = document.createElement('div'),
out = '';
var element = document.createElement('div'),
out = '',
valueSizeClasses = [
options.cssClasses.valueNormal,
options.cssClasses.valueLarge,
options.cssClasses.valueSub
],
markerSizeClasses = [
options.cssClasses.markerNormal,
options.cssClasses.markerLarge,
options.cssClasses.markerSub
],
valueOrientationClasses = [
options.cssClasses.valueHorizontal,
options.cssClasses.valueVertical
],
markerOrientationClasses = [
options.cssClasses.markerHorizontal,
options.cssClasses.markerVertical
];

addClass(element, options.cssClasses.pips);
addClass(element, options.ort === 0 ? options.cssClasses.pipsHorizontal : options.cssClasses.pipsVertical);

if ( options.ort === 0 ) {
classPips = options.cssClasses.pipsHorizontal;
classMarker = options.cssClasses.markerHorizontal;
} else {
classPips = options.cssClasses.pipsVertical;
classMarker = options.cssClasses.markerVertical;
}

addClass(element, classPips);
function getClasses( type, source ){
var a = source === options.cssClasses.value,
orientationClasses = a ? valueOrientationClasses : markerOrientationClasses,
sizeClasses = a ? valueSizeClasses : markerSizeClasses;

function getSizeClass( type ){
return [
options.cssClasses.markerNormal,
options.cssClasses.markerLarge,
options.cssClasses.markerSub
][type];
return source + ' ' + orientationClasses[options.ort] + ' ' + sizeClasses[type];
}

function getTags( offset, source, values ) {
return 'class="' + source + ' ' +
classMarker + ' ' +
getSizeClass(values[1]) +
'" style="' + options.style + ': ' + offset + '%"';
return 'class="' + getClasses(values[1], source) + '" style="' + options.style + ': ' + offset + '%"';
}

function addSpread ( offset, values ){
Expand All @@ -1192,14 +1202,15 @@ function closure ( target, options, originalOptions ){

// Values are only appended for points marked '1' or '2'.
if ( values[1] ) {
out += '<div '+getTags(offset, options.cssClasses.marker, values)+'>' + formatter.to(values[0]) + '</div>';
out += '<div ' + getTags(offset, options.cssClasses.value, values) + '>' + formatter.to(values[0]) + '</div>';
}
}

// Append all points.
Object.keys(spread).forEach(function(a){
addSpread(a, spread[a]);
});

element.innerHTML = out;

return element;
Expand Down
4 changes: 2 additions & 2 deletions distribute/nouislider.min.css

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

4 changes: 2 additions & 2 deletions distribute/nouislider.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion documentation/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<p>noUiSlider is open source, and you can use it <strong>for free</strong> in any personal or commercial product. No attribution required. Both the uncompressed and compressed version of noUiSlider are available in a <code>.zip</code> release, which is hosted by Github and available over <code>https</code>.</p>

<a class="button" href="https://github.com/leongersen/noUiSlider/releases/download/8.5.0/noUiSlider.8.5.0.zip" data-category="convert" data-action="download">Download noUiSlider from Github</a>
<a class="button" href="https://github.com/leongersen/noUiSlider/releases/download/8.5.1/noUiSlider.8.5.1.zip" data-category="convert" data-action="download">Download noUiSlider from Github</a>

<div class="share">
<iframe src="https://ghbtns.com/github-btn.html?user=leongersen&repo=noUiSlider&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
Expand Down
4 changes: 2 additions & 2 deletions documentation/pips.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@

<h4 class="before-example">Vertical and vertical, bottom-to-top:</h4>

<div class="example vertical" style="float: left">
<div class="example vertical" style="width: 150px; float: left">
<div class="pips-range" id="pips-range-vertical"></div>
</div>

<div class="example vertical">
<div class="example vertical" style="width: 150px">
<div class="pips-range" id="pips-range-vertical-rtl"></div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nouislider",
"version": "8.5.0",
"version": "8.5.1",
"main": "distribute/nouislider",
"style": "distribute/nouislider.min.css",
"license": "WTFPL",
Expand Down
7 changes: 6 additions & 1 deletion src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@
markerNormal: 'marker-normal',
markerLarge: 'marker-large',
markerSub: 'marker-sub',
value: 'value'
value: 'value',
valueHorizontal: 'value-horizontal',
valueVertical: 'value-vertical',
valueNormal: 'value-normal',
valueLarge: 'value-large',
valueSub: 'value-sub'
}
};

Expand Down
52 changes: 29 additions & 23 deletions src/js/pips.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,35 +162,40 @@

function addMarking ( spread, filterFunc, formatter ) {

var classPips, classMarker,
element = document.createElement('div'),
out = '';
var element = document.createElement('div'),
out = '',
valueSizeClasses = [
options.cssClasses.valueNormal,
options.cssClasses.valueLarge,
options.cssClasses.valueSub
],
markerSizeClasses = [
options.cssClasses.markerNormal,
options.cssClasses.markerLarge,
options.cssClasses.markerSub
],
valueOrientationClasses = [
options.cssClasses.valueHorizontal,
options.cssClasses.valueVertical
],
markerOrientationClasses = [
options.cssClasses.markerHorizontal,
options.cssClasses.markerVertical
];

addClass(element, options.cssClasses.pips);
addClass(element, options.ort === 0 ? options.cssClasses.pipsHorizontal : options.cssClasses.pipsVertical);

if ( options.ort === 0 ) {
classPips = options.cssClasses.pipsHorizontal;
classMarker = options.cssClasses.markerHorizontal;
} else {
classPips = options.cssClasses.pipsVertical;
classMarker = options.cssClasses.markerVertical;
}

addClass(element, classPips);
function getClasses( type, source ){
var a = source === options.cssClasses.value,
orientationClasses = a ? valueOrientationClasses : markerOrientationClasses,
sizeClasses = a ? valueSizeClasses : markerSizeClasses;

function getSizeClass( type ){
return [
options.cssClasses.markerNormal,
options.cssClasses.markerLarge,
options.cssClasses.markerSub
][type];
return source + ' ' + orientationClasses[options.ort] + ' ' + sizeClasses[type];
}

function getTags( offset, source, values ) {
return 'class="' + source + ' ' +
classMarker + ' ' +
getSizeClass(values[1]) +
'" style="' + options.style + ': ' + offset + '%"';
return 'class="' + getClasses(values[1], source) + '" style="' + options.style + ': ' + offset + '%"';
}

function addSpread ( offset, values ){
Expand All @@ -207,14 +212,15 @@

// Values are only appended for points marked '1' or '2'.
if ( values[1] ) {
out += '<div '+getTags(offset, options.cssClasses.marker, values)+'>' + formatter.to(values[0]) + '</div>';
out += '<div ' + getTags(offset, options.cssClasses.value, values) + '>' + formatter.to(values[0]) + '</div>';
}
}

// Append all points.
Object.keys(spread).forEach(function(a){
addSpread(a, spread[a]);
});

element.innerHTML = out;

return element;
Expand Down
16 changes: 6 additions & 10 deletions src/nouislider.pips.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
*/
.noUi-value {
width: 40px;
position: absolute;
text-align: center;
}
Expand Down Expand Up @@ -44,17 +43,14 @@
*/
.noUi-pips-horizontal {
padding: 10px 0;
height: 50px;
height: 80px;
top: 100%;
left: 0;
width: 100%;
}
.noUi-value-horizontal {
margin-left: -20px;
padding-top: 20px;
}
.noUi-value-horizontal.noUi-value-sub {
padding-top: 15px;
-webkit-transform: translate3d(-50%,50%,0);
transform: translate3d(-50%,50%,0);
}

.noUi-marker-horizontal.noUi-marker {
Expand All @@ -79,9 +75,9 @@
left: 100%;
}
.noUi-value-vertical {
width: 15px;
margin-left: 20px;
margin-top: -5px;
-webkit-transform: translate3d(0,-50%,0);
transform: translate3d(0,-50%,0);
padding-left: 25px;
}

.noUi-marker-vertical.noUi-marker {
Expand Down

0 comments on commit 772dc92

Please sign in to comment.