|
1 | | -/*! nouislider - 13.0.0 - 2/6/2019 */ |
| 1 | +/*! nouislider - 13.1.0 - 2/8/2019 */ |
2 | 2 | (function(factory) { |
3 | 3 | if (typeof define === "function" && define.amd) { |
4 | 4 | // AMD. Register as an anonymous module. |
|
13 | 13 | })(function() { |
14 | 14 | "use strict"; |
15 | 15 |
|
16 | | - var VERSION = "13.0.0"; |
| 16 | + var VERSION = "13.1.0"; |
17 | 17 |
|
18 | 18 | function isValidFormatter(entry) { |
19 | 19 | return typeof entry === "object" && typeof entry.to === "function" && typeof entry.from === "function"; |
|
958 | 958 | var scope_Handles; |
959 | 959 | var scope_Connects; |
960 | 960 | var scope_Pips; |
| 961 | + var scope_Tooltips; |
961 | 962 |
|
962 | 963 | // Override for the 'animate' option |
963 | 964 | var scope_ShouldAnimate = true; |
|
1094 | 1095 | return handleOrigin.hasAttribute("disabled"); |
1095 | 1096 | } |
1096 | 1097 |
|
| 1098 | + function removeTooltips() { |
| 1099 | + if (scope_Tooltips) { |
| 1100 | + removeEvent("update.tooltips"); |
| 1101 | + scope_Tooltips.forEach(function(tooltip) { |
| 1102 | + if (tooltip) { |
| 1103 | + removeElement(tooltip); |
| 1104 | + } |
| 1105 | + }); |
| 1106 | + scope_Tooltips = null; |
| 1107 | + } |
| 1108 | + } |
| 1109 | + |
1097 | 1110 | // The tooltips option is a shorthand for using the 'update' event. |
1098 | 1111 | function tooltips() { |
| 1112 | + removeTooltips(); |
| 1113 | + |
1099 | 1114 | // Tooltips are added with options.tooltips in original order. |
1100 | | - var tips = scope_Handles.map(addTooltip); |
| 1115 | + scope_Tooltips = scope_Handles.map(addTooltip); |
1101 | 1116 |
|
1102 | | - bindEvent("update", function(values, handleNumber, unencoded) { |
1103 | | - if (!tips[handleNumber]) { |
| 1117 | + bindEvent("update.tooltips", function(values, handleNumber, unencoded) { |
| 1118 | + if (!scope_Tooltips[handleNumber]) { |
1104 | 1119 | return; |
1105 | 1120 | } |
1106 | 1121 |
|
|
1110 | 1125 | formattedValue = options.tooltips[handleNumber].to(unencoded[handleNumber]); |
1111 | 1126 | } |
1112 | 1127 |
|
1113 | | - tips[handleNumber].innerHTML = formattedValue; |
| 1128 | + scope_Tooltips[handleNumber].innerHTML = formattedValue; |
1114 | 1129 | }); |
1115 | 1130 | } |
1116 | 1131 |
|
|
2284 | 2299 | // If 'snap' and 'step' are not passed, they should remain unchanged. |
2285 | 2300 | var v = valueGet(); |
2286 | 2301 |
|
2287 | | - var updateAble = ["margin", "limit", "padding", "range", "animate", "snap", "step", "format"]; |
| 2302 | + var updateAble = [ |
| 2303 | + "margin", |
| 2304 | + "limit", |
| 2305 | + "padding", |
| 2306 | + "range", |
| 2307 | + "animate", |
| 2308 | + "snap", |
| 2309 | + "step", |
| 2310 | + "format", |
| 2311 | + "pips", |
| 2312 | + "tooltips" |
| 2313 | + ]; |
2288 | 2314 |
|
2289 | 2315 | // Only change options that we're actually passed to update. |
2290 | 2316 | updateAble.forEach(function(name) { |
| 2317 | + // Check for undefined. null removes the value. |
2291 | 2318 | if (optionsToUpdate[name] !== undefined) { |
2292 | 2319 | originalOptions[name] = optionsToUpdate[name]; |
2293 | 2320 | } |
|
2312 | 2339 | // Update pips, removes existing. |
2313 | 2340 | if (options.pips) { |
2314 | 2341 | pips(options.pips); |
| 2342 | + } else { |
| 2343 | + removePips(); |
| 2344 | + } |
| 2345 | + |
| 2346 | + // Update tooltips, removes existing. |
| 2347 | + if (options.tooltips) { |
| 2348 | + tooltips(); |
| 2349 | + } else { |
| 2350 | + removeTooltips(); |
2315 | 2351 | } |
2316 | 2352 |
|
2317 | 2353 | // Invalidate the current positioning so valueSet forces an update. |
|
2364 | 2400 | updateOptions: updateOptions, |
2365 | 2401 | target: scope_Target, // Issue #597 |
2366 | 2402 | removePips: removePips, |
| 2403 | + removeTooltips: removeTooltips, |
2367 | 2404 | pips: pips // Issue #594 |
2368 | 2405 | }; |
2369 | 2406 |
|
|
0 commit comments