File: formatting.js

package info (click to toggle)
node-nouislider 15.8.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,928 kB
  • sloc: javascript: 5,234; php: 474; sh: 32; python: 28; makefile: 11
file content (31 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var formatSlider = document.getElementById('formatting-slider');

noUiSlider.create(formatSlider, {
    // Values are parsed as numbers using the "from" function in "format"
    start: ['20.0', '80.0'],
    range: {
        'min': 0,
        'max': 100
    },
    format: formatForSlider,
    tooltips: {
        // tooltips are output only, so only a "to" is needed
        to: function(numericValue) {
            return numericValue.toFixed(1);
        }
    }
});

// Values are parsed as numbers using the "from" function in "format"
formatSlider.noUiSlider.set(['25.666', '57.66']);

var formatValues = [
    document.getElementById('formatting-start'),
    document.getElementById('formatting-end')
];

formatSlider.noUiSlider.on('update', function (values, handle, unencoded) {
    // "values" has the "to" function from "format" applied
    // "unencoded" contains the raw numerical slider values
    formatValues[handle].innerHTML = values[handle] + '<br><strong>No format:</strong> ' + unencoded[handle];
});