2236 target.noUiSlider = api;
2237 return api;
2238 }
2239 var nouislider = {2240 // Exposed for unit testing, don't use this in your application.2241 __spectrum: Spectrum,2242 // A reference to the default classes, allows global changes.2243 // Use the cssClasses option for changes to one slider.2244 cssClasses: cssClasses,2245 create: initialize,2246 };2247
2248 exports.create = initialize;
2249 exports.cssClasses = cssClasses;
2232 }
2233 // Test the options and create the slider environment;
2234 var options = testOptions(originalOptions);
2235 var api = scope(target, options, originalOptions);2236 target.noUiSlider = api;
2237 return api;
2238 }
2231 throw new Error("noUiSlider: Slider was already initialized.");
2232 }
2233 // Test the options and create the slider environment;
2234 var options = testOptions(originalOptions);2235 var api = scope(target, options, originalOptions);
2236 target.noUiSlider = api;
2237 return api;
2190 aria();
2191 }
2192 setupSlider();
2193 var scope_Self = {2194 destroy: destroy,2195 steps: getNextSteps,2196 on: bindEvent,2197 off: removeEvent,2198 get: valueGet,2199 set: valueSet,2200 setHandle: valueSetHandle,2201 reset: valueReset,2202 // Exposed for unit testing, don't use this in your application.2203 __moveHandles: function (upward, proposal, handleNumbers) {2204 moveHandles(upward, proposal, scope_Locations, handleNumbers);2205 },2206 options: originalOptions,2207 updateOptions: updateOptions,2208 target: scope_Target,2209 removePips: removePips,2210 removeTooltips: removeTooltips,2211 getPositions: function () {2212 return scope_Locations.slice();2213 },2214 getTooltips: function () {2215 return scope_Tooltips;2216 },2217 getOrigins: function () {2218 return scope_Handles;2219 },2220 pips: pips, // Issue #5942221 };2222 return scope_Self;
2223 }
2224 // Run the standard initializer
2141 originalOptions[name] = optionsToUpdate[name];
2142 }
2143 });
2144 var newOptions = testOptions(originalOptions);2145 // Load new options into the slider state
2146 updateAble.forEach(function (name) {
2147 if (optionsToUpdate[name] !== undefined) {
Declare variables at the top of their scope as it improves code readability, performance and also helps in code navigation.
The vars-on-top
rule generates warnings when variable declarations are not used serially at the top of a function scope or the top of a program. By default variable declarations are always moved (“hoisted”) invisibly to the top of their containing scope by the JavaScript interpreter. This rule forces the programmer to represent that behavior by manually moving the variable declaration to the top of its containing scope.
// Variable declarations in a block:
function doSomething() {
var first;
if (true) {
first = true;
}
var second;
}
// Variable declaration in for initializer:
function doSomething() {
for (var i=0; i<10; i++) {}
}
function doSomething() {
var first;
var second; //multiple declarations are allowed at the top
if (true) {
first = true;
}
}
function doSomething() {
var i;
for (i=0; i<10; i++) {}
}