Commit 4cb01328 authored by Valentin Hervieu's avatar Valentin Hervieu

refactor(stepsArray): Bind rzSliderModel and rzSliderHigh to the actual value (#335)

* refactor(stepsArray): Bind rzSliderModel and rzSliderHigh to the actual value

As discussed in #328
parent f81bb673
# 4.0.0 (2016-06-04)
## Improvement
- `stepsArray`: Bind rzSliderModel and rzSliderHigh to the actual value (#335).
## Breaking changes
- From now on, when using the `stepsArray` feature, you should directly provide the actual value to rzSliderModel and rzSliderHigh instead of passing the index of this value.
Thus, you need to update your config like in the following example:
```js
/* before 4.0 version */
vm.slider = {
value: 4, // index of the 'E' value in the array
options: {
stepsArray: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
}
}
/* from 4.0 version */
vm.slider = {
value: 'E',
options: {
stepsArray: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
}
}
```
# 3.0.0 (2016-06-02) # 3.0.0 (2016-06-02)
## Features ## Features
- Add IE8 support (#314). - Add IE8 support (#314).
......
...@@ -275,7 +275,7 @@ $scope.slider = { ...@@ -275,7 +275,7 @@ $scope.slider = {
**id** - _Any (defaults to null)_: If you want to use the same `translate` function for several sliders, just set the `id` to anything you want, and it will be passed to the `translate(value, sliderId)` function as a second argument. **id** - _Any (defaults to null)_: If you want to use the same `translate` function for several sliders, just set the `id` to anything you want, and it will be passed to the `translate(value, sliderId)` function as a second argument.
**stepsArray** - _Array_: If you want to display a slider with non linear/number steps. **stepsArray** - _Array_: If you want to display a slider with non linear/number steps.
Just pass an array with each slider value and that's it; the floor, ceil and step settings of the slider will be computed automatically. The `rz-slider-model` value will be the index of the selected item in the stepsArray. Just pass an array with each slider value and that's it; the floor, ceil and step settings of the slider will be computed automatically. The `rz-slider-model` and `rz-slider-high` values will be the value of the selected item in the stepsArray.
`stepsArray` can also be an array of objects like: `stepsArray` can also be an array of objects like:
......
...@@ -197,7 +197,7 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) { ...@@ -197,7 +197,7 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
//Slider config with steps array of letters //Slider config with steps array of letters
$scope.slider_alphabet = { $scope.slider_alphabet = {
value: 0, value: 'E',
options: { options: {
stepsArray: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('') stepsArray: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
} }
...@@ -274,8 +274,6 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) { ...@@ -274,8 +274,6 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
$scope.slider_ticks_legend = { $scope.slider_ticks_legend = {
value: 5, value: 5,
options: { options: {
ceil: 10,
floor: 0,
showTicksValues: true, showTicksValues: true,
stepsArray: [ stepsArray: [
{value: 1, legend: 'Very poor'}, {value: 1, legend: 'Very poor'},
......
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
Min Value: <input type="number" ng-model="rangeSlider.minValue"/><br/> Min Value: <input type="number" ng-model="rangeSlider.minValue"/><br/>
Max Value: <input type="number" ng-model="rangeSlider.maxValue"/><br/> Max Value: <input type="number" ng-model="rangeSlider.maxValue"/><br/>
<rzslider <rzslider
rz-slider-model="rangeSlider.minValue" data-rz-slider-model="rangeSlider.minValue"
rz-slider-high="rangeSlider.maxValue" data-rz-slider-high="rangeSlider.maxValue"
rz-slider-options="rangeSlider.options" data-rz-slider-options="rangeSlider.options"
></rzslider> ></rzslider>
</article> </article>
...@@ -150,6 +150,7 @@ ...@@ -150,6 +150,7 @@
<article> <article>
<h2>Slider with Alphabet</h2> <h2>Slider with Alphabet</h2>
Current letter: {{ slider_alphabet.value }}
<rzslider <rzslider
rz-slider-model="slider_alphabet.value" rz-slider-model="slider_alphabet.value"
rz-slider-options="slider_alphabet.options" rz-slider-options="slider_alphabet.options"
......
/*! angularjs-slider - v3.0.0 - /*! angularjs-slider - v2.14.0 -
(c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> - (c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> -
https://github.com/angular-slider/angularjs-slider - https://github.com/angular-slider/angularjs-slider -
2016-06-02 */ 2016-05-25 */
.rzslider { .rzslider {
position: relative; position: relative;
display: inline-block; display: inline-block;
......
/*! angularjs-slider - v3.0.0 - /*! angularjs-slider - v3.0.0 -
(c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> - (c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> -
https://github.com/angular-slider/angularjs-slider - https://github.com/angular-slider/angularjs-slider -
2016-06-02 */ 2016-06-04 */
/*jslint unparam: true */ /*jslint unparam: true */
/*global angular: false, console: false, define, module */ /*global angular: false, console: false, define, module */
(function(root, factory) { (function(root, factory) {
...@@ -155,6 +155,18 @@ ...@@ -155,6 +155,18 @@
*/ */
this.scope = scope; this.scope = scope;
/**
* The slider inner low value (linked to rzSliderModel)
* @type {number}
*/
this.lowValue = 0;
/**
* The slider inner high value (linked to rzSliderHigh)
* @type {number}
*/
this.highValue = 0;
/** /**
* Slider element wrapped in jqLite * Slider element wrapped in jqLite
* *
...@@ -272,7 +284,7 @@ ...@@ -272,7 +284,7 @@
* *
* @type {boolean} * @type {boolean}
*/ */
this.firstKeyDown = false this.firstKeyDown = false;
/** /**
* Internal flag to prevent watchers to be called when the sliders value are modified internally. * Internal flag to prevent watchers to be called when the sliders value are modified internally.
...@@ -313,6 +325,9 @@ ...@@ -313,6 +325,9 @@
}; };
this.applyOptions(); this.applyOptions();
this.syncLowValue();
if (this.range)
this.syncHighValue();
this.initElemHandles(); this.initElemHandles();
this.manageElementsStyle(); this.manageElementsStyle();
this.setDisabledState(); this.setDisabledState();
...@@ -355,7 +370,10 @@ ...@@ -355,7 +370,10 @@
this.scope.$watch('rzSliderOptions()', function(newValue, oldValue) { this.scope.$watch('rzSliderOptions()', function(newValue, oldValue) {
if (newValue === oldValue) if (newValue === oldValue)
return; return;
self.applyOptions(); self.applyOptions(); // need to be called before synchronizing the values
self.syncLowValue();
if (self.range)
self.syncHighValue();
self.resetSlider(); self.resetSlider();
}, true); }, true);
...@@ -386,12 +404,66 @@ ...@@ -386,12 +404,66 @@
}); });
}, },
findStepIndex: function(modelValue) {
var index = 0;
for (var i = 0; i < this.options.stepsArray.length; i++) {
var step = this.options.stepsArray[i];
if (step === modelValue) {
index = i;
break;
}
else if (angular.isObject(step) && step.value === modelValue) {
index = i;
break;
}
}
return index;
},
syncLowValue: function() {
if (this.options.stepsArray)
this.lowValue = this.findStepIndex(this.scope.rzSliderModel);
else
this.lowValue = this.scope.rzSliderModel;
},
syncHighValue: function() {
if (this.options.stepsArray)
this.highValue = this.findStepIndex(this.scope.rzSliderHigh);
else
this.highValue = this.scope.rzSliderHigh;
},
getStepValue: function(sliderValue) {
var step = this.options.stepsArray[sliderValue];
if (angular.isObject(step))
return step.value;
return step;
},
applyLowValue: function() {
if (this.options.stepsArray)
this.scope.rzSliderModel = this.getStepValue(this.lowValue);
else
this.scope.rzSliderModel = this.lowValue;
},
applyHighValue: function() {
if (this.options.stepsArray)
this.scope.rzSliderHigh = this.getStepValue(this.highValue);
else
this.scope.rzSliderHigh = this.highValue;
},
/* /*
* Reflow the slider when the low handle changes (called with throttle) * Reflow the slider when the low handle changes (called with throttle)
*/ */
onLowHandleChange: function() { onLowHandleChange: function() {
this.syncLowValue();
if (this.range)
this.syncHighValue();
this.setMinAndMax(); this.setMinAndMax();
this.updateLowHandle(this.valueToOffset(this.scope.rzSliderModel)); this.updateLowHandle(this.valueToOffset(this.lowValue));
this.updateSelectionBar(); this.updateSelectionBar();
this.updateTicksScale(); this.updateTicksScale();
this.updateAriaAttributes(); this.updateAriaAttributes();
...@@ -404,8 +476,10 @@ ...@@ -404,8 +476,10 @@
* Reflow the slider when the high handle changes (called with throttle) * Reflow the slider when the high handle changes (called with throttle)
*/ */
onHighHandleChange: function() { onHighHandleChange: function() {
this.syncLowValue();
this.syncHighValue();
this.setMinAndMax(); this.setMinAndMax();
this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh)); this.updateHighHandle(this.valueToOffset(this.highValue));
this.updateSelectionBar(); this.updateSelectionBar();
this.updateTicksScale(); this.updateTicksScale();
this.updateCmbLabel(); this.updateCmbLabel();
...@@ -472,11 +546,8 @@ ...@@ -472,11 +546,8 @@
this.customTrFn = this.options.translate; this.customTrFn = this.options.translate;
} }
else { else {
this.customTrFn = function(index) { this.customTrFn = function(modelValue) {
var step = this.options.stepsArray[index]; return modelValue;
if (angular.isObject(step))
return step.value;
return step;
}; };
} }
...@@ -646,14 +717,14 @@ ...@@ -646,14 +717,14 @@
* @returns {undefined} * @returns {undefined}
*/ */
initHandles: function() { initHandles: function() {
this.updateLowHandle(this.valueToOffset(this.scope.rzSliderModel)); this.updateLowHandle(this.valueToOffset(this.lowValue));
/* /*
the order here is important since the selection bar should be the order here is important since the selection bar should be
updated after the high handle but before the combined label updated after the high handle but before the combined label
*/ */
if (this.range) if (this.range)
this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh)); this.updateHighHandle(this.valueToOffset(this.highValue));
this.updateSelectionBar(); this.updateSelectionBar();
if (this.range) if (this.range)
this.updateCmbLabel(); this.updateCmbLabel();
...@@ -666,15 +737,25 @@ ...@@ -666,15 +737,25 @@
* *
* @param {number|string} value * @param {number|string} value
* @param {jqLite} label * @param {jqLite} label
* @param {String} which
* @param {boolean} [useCustomTr] * @param {boolean} [useCustomTr]
* @returns {undefined} * @returns {undefined}
*/ */
translateFn: function(value, label, which, useCustomTr) { translateFn: function(value, label, which, useCustomTr) {
useCustomTr = useCustomTr === undefined ? true : useCustomTr; useCustomTr = useCustomTr === undefined ? true : useCustomTr;
var valStr = String((useCustomTr ? this.customTrFn(value, this.options.id, which) : value)), var valStr = '',
getDimension = false; getDimension = false;
if (useCustomTr) {
if (this.options.stepsArray)
value = this.getStepValue(value);
valStr = String(this.customTrFn(value, this.options.id, which));
}
else {
valStr = String(value)
}
if (label.rzsv === undefined || label.rzsv.length !== valStr.length || (label.rzsv.length > 0 && label.rzsd === 0)) { if (label.rzsv === undefined || label.rzsv.length !== valStr.length || (label.rzsv.length > 0 && label.rzsd === 0)) {
getDimension = true; getDimension = true;
label.rzsv = valStr; label.rzsv = valStr;
...@@ -701,22 +782,26 @@ ...@@ -701,22 +782,26 @@
this.minValue = this.options.floor; this.minValue = this.options.floor;
if (this.options.enforceStep) { if (this.options.enforceStep) {
this.scope.rzSliderModel = this.roundStep(this.scope.rzSliderModel); this.lowValue = this.roundStep(this.lowValue);
if (this.range) if (this.range)
this.scope.rzSliderHigh = this.roundStep(this.scope.rzSliderHigh); this.highValue = this.roundStep(this.highValue);
} }
if (this.options.ceil != null) if (this.options.ceil != null)
this.maxValue = this.options.ceil; this.maxValue = this.options.ceil;
else else
this.maxValue = this.options.ceil = this.range ? this.scope.rzSliderHigh : this.scope.rzSliderModel; this.maxValue = this.options.ceil = this.range ? this.highValue : this.lowValue;
if (this.options.enforceRange) { if (this.options.enforceRange) {
this.scope.rzSliderModel = this.sanitizeValue(this.scope.rzSliderModel); this.lowValue = this.sanitizeValue(this.lowValue);
if (this.range) if (this.range)
this.scope.rzSliderHigh = this.sanitizeValue(this.scope.rzSliderHigh); this.highValue = this.sanitizeValue(this.highValue);
} }
this.applyLowValue();
if (this.range)
this.applyHighValue();
this.valueRange = this.maxValue - this.minValue; this.valueRange = this.maxValue - this.minValue;
}, },
...@@ -843,19 +928,19 @@ ...@@ -843,19 +928,19 @@
if (!this.range) { if (!this.range) {
if (this.options.showSelectionBarFromValue !== null) { if (this.options.showSelectionBarFromValue !== null) {
var center = this.options.showSelectionBarFromValue; var center = this.options.showSelectionBarFromValue;
if (this.scope.rzSliderModel > center && value >= center && value <= this.scope.rzSliderModel) if (this.lowValue > center && value >= center && value <= this.lowValue)
return true; return true;
else if (this.scope.rzSliderModel < center && value <= center && value >= this.scope.rzSliderModel) else if (this.lowValue < center && value <= center && value >= this.lowValue)
return true; return true;
} }
else if (this.options.showSelectionBarEnd) { else if (this.options.showSelectionBarEnd) {
if (value >= this.scope.rzSliderModel) if (value >= this.lowValue)
return true; return true;
} }
else if (this.options.showSelectionBar && value <= this.scope.rzSliderModel) else if (this.options.showSelectionBar && value <= this.lowValue)
return true; return true;
} }
if (this.range && value >= this.scope.rzSliderModel && value <= this.scope.rzSliderHigh) if (this.range && value >= this.lowValue && value <= this.highValue)
return true; return true;
return false; return false;
}, },
...@@ -891,7 +976,7 @@ ...@@ -891,7 +976,7 @@
* @param {number} newOffset * @param {number} newOffset
*/ */
updateHandles: function(which, newOffset) { updateHandles: function(which, newOffset) {
if (which === 'rzSliderModel') if (which === 'lowValue')
this.updateLowHandle(newOffset); this.updateLowHandle(newOffset);
else else
this.updateHighHandle(newOffset); this.updateHighHandle(newOffset);
...@@ -933,7 +1018,7 @@ ...@@ -933,7 +1018,7 @@
*/ */
updateLowHandle: function(newOffset) { updateLowHandle: function(newOffset) {
this.setPosition(this.minH, newOffset); this.setPosition(this.minH, newOffset);
this.translateFn(this.scope.rzSliderModel, this.minLab, 'model'); this.translateFn(this.lowValue, this.minLab, 'model');
this.setPosition(this.minLab, this.getHandleLabelPos('minLab', newOffset)); this.setPosition(this.minLab, this.getHandleLabelPos('minLab', newOffset));
if (this.options.getPointerColor) { if (this.options.getPointerColor) {
...@@ -954,7 +1039,7 @@ ...@@ -954,7 +1039,7 @@
*/ */
updateHighHandle: function(newOffset) { updateHighHandle: function(newOffset) {
this.setPosition(this.maxH, newOffset); this.setPosition(this.maxH, newOffset);
this.translateFn(this.scope.rzSliderHigh, this.maxLab, 'high'); this.translateFn(this.highValue, this.maxLab, 'high');
this.setPosition(this.maxLab, this.getHandleLabelPos('maxLab', newOffset)); this.setPosition(this.maxLab, this.getHandleLabelPos('maxLab', newOffset));
if (this.options.getPointerColor) { if (this.options.getPointerColor) {
...@@ -1041,7 +1126,7 @@ ...@@ -1041,7 +1126,7 @@
if (this.options.showSelectionBarFromValue !== null) { if (this.options.showSelectionBarFromValue !== null) {
var center = this.options.showSelectionBarFromValue, var center = this.options.showSelectionBarFromValue,
centerPosition = this.valueToOffset(center), centerPosition = this.valueToOffset(center),
isModelGreaterThanCenter = this.options.rightToLeft ? this.scope.rzSliderModel <= center : this.scope.rzSliderModel > center; isModelGreaterThanCenter = this.options.rightToLeft ? this.lowValue <= center : this.lowValue > center;
if (isModelGreaterThanCenter) { if (isModelGreaterThanCenter) {
dimension = this.minH.rzsp - centerPosition; dimension = this.minH.rzsp - centerPosition;
position = centerPosition + this.handleHalfDim; position = centerPosition + this.handleHalfDim;
...@@ -1104,8 +1189,8 @@ ...@@ -1104,8 +1189,8 @@
} }
if (isLabelOverlap) { if (isLabelOverlap) {
var lowTr = this.getDisplayValue(this.scope.rzSliderModel, 'model'), var lowTr = this.getDisplayValue(this.lowValue, 'model'),
highTr = this.getDisplayValue(this.scope.rzSliderHigh, 'high'), highTr = this.getDisplayValue(this.highValue, 'high'),
labelVal = ''; labelVal = '';
if (lowTr === highTr) { if (lowTr === highTr) {
labelVal = lowTr; labelVal = lowTr;
...@@ -1140,6 +1225,9 @@ ...@@ -1140,6 +1225,9 @@
* @returns {*} * @returns {*}
*/ */
getDisplayValue: function(value, which) { getDisplayValue: function(value, which) {
if (this.options.stepsArray) {
value = this.getStepValue(value);
}
return this.customTrFn(value, this.options.id, which); return this.customTrFn(value, this.options.id, which);
}, },
...@@ -1374,7 +1462,7 @@ ...@@ -1374,7 +1462,7 @@
barStart = this.onDragStart; barStart = this.onDragStart;
barMove = this.onDragMove; barMove = this.onDragMove;
} else { } else {
barTracking = 'rzSliderModel'; barTracking = 'lowValue';
barStart = this.onStart; barStart = this.onStart;
barMove = this.onMove; barMove = this.onMove;
} }
...@@ -1388,9 +1476,9 @@ ...@@ -1388,9 +1476,9 @@
this.minH.on('mousedown', angular.bind(this, barStart, null, barTracking)); this.minH.on('mousedown', angular.bind(this, barStart, null, barTracking));
this.maxH.on('mousedown', angular.bind(this, barStart, null, barTracking)); this.maxH.on('mousedown', angular.bind(this, barStart, null, barTracking));
} else { } else {
this.minH.on('mousedown', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); this.minH.on('mousedown', angular.bind(this, this.onStart, this.minH, 'lowValue'));
if (this.range) { if (this.range) {
this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'highValue'));
} }
if (!this.options.onlyBindHandles) { if (!this.options.onlyBindHandles) {
this.fullBar.on('mousedown', angular.bind(this, this.onStart, null, null)); this.fullBar.on('mousedown', angular.bind(this, this.onStart, null, null));
...@@ -1408,9 +1496,9 @@ ...@@ -1408,9 +1496,9 @@
this.minH.on('touchstart', angular.bind(this, barStart, null, barTracking)); this.minH.on('touchstart', angular.bind(this, barStart, null, barTracking));
this.maxH.on('touchstart', angular.bind(this, barStart, null, barTracking)); this.maxH.on('touchstart', angular.bind(this, barStart, null, barTracking));
} else { } else {
this.minH.on('touchstart', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); this.minH.on('touchstart', angular.bind(this, this.onStart, this.minH, 'lowValue'));
if (this.range) { if (this.range) {
this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'highValue'));
} }
if (!this.options.onlyBindHandles) { if (!this.options.onlyBindHandles) {
this.fullBar.on('touchstart', angular.bind(this, this.onStart, null, null)); this.fullBar.on('touchstart', angular.bind(this, this.onStart, null, null));
...@@ -1421,9 +1509,9 @@ ...@@ -1421,9 +1509,9 @@
} }
if (this.options.keyboardSupport) { if (this.options.keyboardSupport) {
this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'rzSliderModel')); this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'lowValue'));
if (this.range) { if (this.range) {
this.maxH.on('focus', angular.bind(this, this.onPointerFocus, this.maxH, 'rzSliderHigh')); this.maxH.on('focus', angular.bind(this, this.onPointerFocus, this.maxH, 'highValue'));
} }
} }
}, },
...@@ -1464,7 +1552,7 @@ ...@@ -1464,7 +1552,7 @@
this.tracking = ref; this.tracking = ref;
} else { } else {
pointer = this.getNearestHandle(event); pointer = this.getNearestHandle(event);
this.tracking = pointer === this.minH ? 'rzSliderModel' : 'rzSliderHigh'; this.tracking = pointer === this.minH ? 'lowValue' : 'highValue';
} }
pointer.addClass('rz-active'); pointer.addClass('rz-active');
...@@ -1592,7 +1680,7 @@ ...@@ -1592,7 +1680,7 @@
}, },
onKeyboardEvent: function(event) { onKeyboardEvent: function(event) {
var currentValue = this.scope[this.tracking], var currentValue = this[this.tracking],
keyCode = event.keyCode || event.which, keyCode = event.keyCode || event.which,
keys = { keys = {
38: 'UP', 38: 'UP',
...@@ -1620,10 +1708,11 @@ ...@@ -1620,10 +1708,11 @@
var newValue = self.roundStep(self.sanitizeValue(action)); var newValue = self.roundStep(self.sanitizeValue(action));
if (!self.options.draggableRangeOnly) { if (!self.options.draggableRangeOnly) {
self.positionTrackingHandle(newValue); self.positionTrackingHandle(newValue);
} else { }
var difference = self.scope.rzSliderHigh - self.scope.rzSliderModel, else {
var difference = self.highValue - self.lowValue,
newMinValue, newMaxValue; newMinValue, newMaxValue;
if (self.tracking === 'rzSliderModel') { if (self.tracking === 'lowValue') {
newMinValue = newValue; newMinValue = newValue;
newMaxValue = newValue + difference; newMaxValue = newValue + difference;
if (newMaxValue > self.maxValue) { if (newMaxValue > self.maxValue) {
...@@ -1658,7 +1747,7 @@ ...@@ -1658,7 +1747,7 @@
this.dragging = { this.dragging = {
active: true, active: true,
value: this.offsetToValue(offset), value: this.offsetToValue(offset),
difference: this.scope.rzSliderHigh - this.scope.rzSliderModel, difference: this.highValue - this.lowValue,
lowLimit: this.options.rightToLeft ? this.minH.rzsp - offset : offset - this.minH.rzsp, lowLimit: this.options.rightToLeft ? this.minH.rzsp - offset : offset - this.minH.rzsp,
highLimit: this.options.rightToLeft ? offset - this.maxH.rzsp : this.maxH.rzsp - offset highLimit: this.options.rightToLeft ? offset - this.maxH.rzsp : this.maxH.rzsp - offset
}; };
...@@ -1764,11 +1853,14 @@ ...@@ -1764,11 +1853,14 @@
* @param {number} newMaxValue the new maximum value * @param {number} newMaxValue the new maximum value
*/ */
positionTrackingBar: function(newMinValue, newMaxValue) { positionTrackingBar: function(newMinValue, newMaxValue) {
this.scope.rzSliderModel = newMinValue; this.lowValue = newMinValue;
this.scope.rzSliderHigh = newMaxValue; this.highValue = newMaxValue;
this.updateHandles('rzSliderModel', this.valueToOffset(newMinValue)); this.applyLowValue();
this.updateHandles('rzSliderHigh', this.valueToOffset(newMaxValue)); if (this.range)
this.applyHighValue();
this.applyModel(); this.applyModel();
this.updateHandles('lowValue', this.valueToOffset(newMinValue));
this.updateHandles('highValue', this.valueToOffset(newMaxValue));
}, },
/** /**
...@@ -1783,30 +1875,32 @@ ...@@ -1783,30 +1875,32 @@
if (this.range) { if (this.range) {
newValue = this.applyMinMaxRange(newValue); newValue = this.applyMinMaxRange(newValue);
/* This is to check if we need to switch the min and max handles */ /* This is to check if we need to switch the min and max handles */
if (this.tracking === 'rzSliderModel' && newValue > this.scope.rzSliderHigh) { if (this.tracking === 'lowValue' && newValue > this.highValue) {
if (this.options.noSwitching && this.scope.rzSliderHigh !== this.minValue) { if (this.options.noSwitching && this.highValue !== this.minValue) {
newValue = this.applyMinMaxRange(this.scope.rzSliderHigh); newValue = this.applyMinMaxRange(this.highValue);
} }
else { else {
this.scope[this.tracking] = this.scope.rzSliderHigh; this.lowValue = this.highValue;
this.applyLowValue();
this.updateHandles(this.tracking, this.maxH.rzsp); this.updateHandles(this.tracking, this.maxH.rzsp);
this.updateAriaAttributes(); this.updateAriaAttributes();
this.tracking = 'rzSliderHigh'; this.tracking = 'highValue';
this.minH.removeClass('rz-active'); this.minH.removeClass('rz-active');
this.maxH.addClass('rz-active'); this.maxH.addClass('rz-active');
if (this.options.keyboardSupport) if (this.options.keyboardSupport)
this.focusElement(this.maxH); this.focusElement(this.maxH);
} }
valueChanged = true; valueChanged = true;
} else if (this.tracking === 'rzSliderHigh' && newValue < this.scope.rzSliderModel) { } else if (this.tracking === 'highValue' && newValue < this.lowValue) {
if (this.options.noSwitching && this.scope.rzSliderModel !== this.maxValue) { if (this.options.noSwitching && this.lowValue !== this.maxValue) {
newValue = this.applyMinMaxRange(this.scope.rzSliderModel); newValue = this.applyMinMaxRange(this.lowValue);
} }
else { else {
this.scope[this.tracking] = this.scope.rzSliderModel; this.highValue = this.lowValue;
this.applyHighValue();
this.updateHandles(this.tracking, this.minH.rzsp); this.updateHandles(this.tracking, this.minH.rzsp);
this.updateAriaAttributes(); this.updateAriaAttributes();
this.tracking = 'rzSliderModel'; this.tracking = 'lowValue';
this.maxH.removeClass('rz-active'); this.maxH.removeClass('rz-active');
this.minH.addClass('rz-active'); this.minH.addClass('rz-active');
if (this.options.keyboardSupport) if (this.options.keyboardSupport)
...@@ -1816,8 +1910,12 @@ ...@@ -1816,8 +1910,12 @@
} }
} }
if (this.scope[this.tracking] !== newValue) { if (this[this.tracking] !== newValue) {
this.scope[this.tracking] = newValue; this[this.tracking] = newValue;
if (this.tracking === 'lowValue')
this.applyLowValue();
else
this.applyHighValue();
this.updateHandles(this.tracking, this.valueToOffset(newValue)); this.updateHandles(this.tracking, this.valueToOffset(newValue));
this.updateAriaAttributes(); this.updateAriaAttributes();
valueChanged = true; valueChanged = true;
...@@ -1836,22 +1934,22 @@ ...@@ -1836,22 +1934,22 @@
}, },
applyMinMaxRange: function(newValue) { applyMinMaxRange: function(newValue) {
var oppositeValue = this.tracking === 'rzSliderModel' ? this.scope.rzSliderHigh : this.scope.rzSliderModel, var oppositeValue = this.tracking === 'lowValue' ? this.highValue : this.lowValue,
difference = Math.abs(newValue - oppositeValue); difference = Math.abs(newValue - oppositeValue);
if (this.options.minRange != null) { if (this.options.minRange != null) {
if (difference < this.options.minRange) { if (difference < this.options.minRange) {
if (this.tracking === 'rzSliderModel') if (this.tracking === 'lowValue')
return this.scope.rzSliderHigh - this.options.minRange; return this.highValue - this.options.minRange;
else else
return this.scope.rzSliderModel + this.options.minRange; return this.lowValue + this.options.minRange;
} }
} }
if (this.options.maxRange != null) { if (this.options.maxRange != null) {
if (difference > this.options.maxRange) { if (difference > this.options.maxRange) {
if (this.tracking === 'rzSliderModel') if (this.tracking === 'lowValue')
return this.scope.rzSliderHigh - this.options.maxRange; return this.highValue - this.options.maxRange;
else else
return this.scope.rzSliderModel + this.options.maxRange; return this.lowValue + this.options.maxRange;
} }
} }
return newValue; return newValue;
......
/*! angularjs-slider - v3.0.0 - (c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> - https://github.com/angular-slider/angularjs-slider - 2016-06-02 */ /*! angularjs-slider - v2.14.0 - (c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> - https://github.com/angular-slider/angularjs-slider - 2016-05-25 */
.rzslider{position:relative;display:inline-block;width:100%;height:4px;margin:35px 0 15px 0;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.rzslider.with-legend{margin-bottom:40px}.rzslider[disabled]{cursor:not-allowed}.rzslider[disabled] .rz-pointer{cursor:not-allowed;background-color:#d8e0f3}.rzslider span{position:absolute;display:inline-block;white-space:nowrap}.rzslider .rz-base{width:100%;height:100%;padding:0}.rzslider .rz-bar-wrapper{left:0;z-index:1;width:100%;height:32px;padding-top:16px;margin-top:-16px;box-sizing:border-box}.rzslider .rz-bar-wrapper.rz-draggable{cursor:move}.rzslider .rz-bar{left:0;z-index:1;width:100%;height:4px;background:#d8e0f3;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.rzslider .rz-bar.rz-selection{z-index:2;background:#0db9f0;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.rzslider .rz-pointer{top:-14px;z-index:3;width:32px;height:32px;cursor:pointer;background-color:#0db9f0;-webkit-border-radius:16px;-moz-border-radius:16px;border-radius:16px}.rzslider .rz-pointer:after{position:absolute;top:12px;left:12px;width:8px;height:8px;background:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;content:''}.rzslider .rz-pointer:hover:after{background-color:#fff}.rzslider .rz-pointer.rz-active{z-index:4}.rzslider .rz-pointer.rz-active:after{background-color:#451aff}.rzslider .rz-bubble{bottom:16px;padding:1px 3px;color:#55637d;cursor:default}.rzslider .rz-bubble.rz-selection{top:16px}.rzslider .rz-bubble.rz-limit{color:#55637d}.rzslider .rz-ticks{position:absolute;top:-3px;left:0;z-index:1;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;height:0;padding:0 11px;margin:0;list-style:none;box-sizing:border-box;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between}.rzslider .rz-ticks .rz-tick{width:10px;height:10px;text-align:center;cursor:pointer;background:#d8e0f3;border-radius:50%}.rzslider .rz-ticks .rz-tick.rz-selected{background:#0db9f0}.rzslider .rz-ticks .rz-tick .rz-tick-value{position:absolute;top:-30px;transform:translate(-50%,0)}.rzslider .rz-ticks .rz-tick .rz-tick-legend{position:absolute;top:24px;max-width:50px;white-space:normal;transform:translate(-50%,0)}.rzslider .rz-ticks.rz-ticks-values-under .rz-tick-value{top:initial;bottom:-40px}.rzslider.rz-vertical{position:relative;width:4px;height:100%;padding:0;margin:0 20px;vertical-align:baseline}.rzslider.rz-vertical .rz-base{width:100%;height:100%;padding:0}.rzslider.rz-vertical .rz-bar-wrapper{top:auto;left:0;width:32px;height:100%;padding:0 0 0 16px;margin:0 0 0 -16px}.rzslider.rz-vertical .rz-bar{bottom:0;left:auto;width:4px;height:100%}.rzslider.rz-vertical .rz-pointer{top:auto;bottom:0;left:-14px!important}.rzslider.rz-vertical .rz-bubble{bottom:0;left:16px!important;margin-left:3px}.rzslider.rz-vertical .rz-bubble.rz-selection{top:auto;left:16px!important}.rzslider.rz-vertical .rz-ticks{top:0;left:-3px;z-index:1;width:0;height:100%;padding:11px 0;-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse}.rzslider.rz-vertical .rz-ticks .rz-tick{vertical-align:middle}.rzslider.rz-vertical .rz-ticks .rz-tick .rz-tick-value{top:initial;left:22px;transform:translate(0,-28%)}.rzslider.rz-vertical .rz-ticks .rz-tick .rz-tick-legend{top:initial;right:24px;max-width:none;white-space:nowrap;transform:translate(0,-28%)}.rzslider.rz-vertical .rz-ticks.rz-ticks-values-under .rz-tick-value{right:12px;bottom:initial;left:initial} .rzslider{position:relative;display:inline-block;width:100%;height:4px;margin:35px 0 15px 0;vertical-align:middle;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.rzslider.with-legend{margin-bottom:40px}.rzslider[disabled]{cursor:not-allowed}.rzslider[disabled] .rz-pointer{cursor:not-allowed;background-color:#d8e0f3}.rzslider span{position:absolute;display:inline-block;white-space:nowrap}.rzslider .rz-base{width:100%;height:100%;padding:0}.rzslider .rz-bar-wrapper{left:0;z-index:1;width:100%;height:32px;padding-top:16px;margin-top:-16px;box-sizing:border-box}.rzslider .rz-bar-wrapper.rz-draggable{cursor:move}.rzslider .rz-bar{left:0;z-index:1;width:100%;height:4px;background:#d8e0f3;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.rzslider .rz-bar.rz-selection{z-index:2;background:#0db9f0;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}.rzslider .rz-pointer{top:-14px;z-index:3;width:32px;height:32px;cursor:pointer;background-color:#0db9f0;-webkit-border-radius:16px;-moz-border-radius:16px;border-radius:16px}.rzslider .rz-pointer:after{position:absolute;top:12px;left:12px;width:8px;height:8px;background:#fff;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;content:''}.rzslider .rz-pointer:hover:after{background-color:#fff}.rzslider .rz-pointer.rz-active{z-index:4}.rzslider .rz-pointer.rz-active:after{background-color:#451aff}.rzslider .rz-bubble{bottom:16px;padding:1px 3px;color:#55637d;cursor:default}.rzslider .rz-bubble.rz-selection{top:16px}.rzslider .rz-bubble.rz-limit{color:#55637d}.rzslider .rz-ticks{position:absolute;top:-3px;left:0;z-index:1;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;height:0;padding:0 11px;margin:0;list-style:none;box-sizing:border-box;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between}.rzslider .rz-ticks .rz-tick{width:10px;height:10px;text-align:center;cursor:pointer;background:#d8e0f3;border-radius:50%}.rzslider .rz-ticks .rz-tick.rz-selected{background:#0db9f0}.rzslider .rz-ticks .rz-tick .rz-tick-value{position:absolute;top:-30px;transform:translate(-50%,0)}.rzslider .rz-ticks .rz-tick .rz-tick-legend{position:absolute;top:24px;max-width:50px;white-space:normal;transform:translate(-50%,0)}.rzslider .rz-ticks.rz-ticks-values-under .rz-tick-value{top:initial;bottom:-40px}.rzslider.rz-vertical{position:relative;width:4px;height:100%;padding:0;margin:0 20px;vertical-align:baseline}.rzslider.rz-vertical .rz-base{width:100%;height:100%;padding:0}.rzslider.rz-vertical .rz-bar-wrapper{top:auto;left:0;width:32px;height:100%;padding:0 0 0 16px;margin:0 0 0 -16px}.rzslider.rz-vertical .rz-bar{bottom:0;left:auto;width:4px;height:100%}.rzslider.rz-vertical .rz-pointer{top:auto;bottom:0;left:-14px!important}.rzslider.rz-vertical .rz-bubble{bottom:0;left:16px!important;margin-left:3px}.rzslider.rz-vertical .rz-bubble.rz-selection{top:auto;left:16px!important}.rzslider.rz-vertical .rz-ticks{top:0;left:-3px;z-index:1;width:0;height:100%;padding:11px 0;-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse}.rzslider.rz-vertical .rz-ticks .rz-tick{vertical-align:middle}.rzslider.rz-vertical .rz-ticks .rz-tick .rz-tick-value{top:initial;left:22px;transform:translate(0,-28%)}.rzslider.rz-vertical .rz-ticks .rz-tick .rz-tick-legend{top:initial;right:24px;max-width:none;white-space:nowrap;transform:translate(0,-28%)}.rzslider.rz-vertical .rz-ticks.rz-ticks-values-under .rz-tick-value{right:12px;bottom:initial;left:initial}
\ No newline at end of file
/*! angularjs-slider - v3.0.0 - (c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> - https://github.com/angular-slider/angularjs-slider - 2016-06-02 */ /*! angularjs-slider - v3.0.0 - (c) Rafal Zajac <rzajac@gmail.com>, Valentin Hervieu <valentin@hervieu.me>, Jussi Saarivirta <jusasi@gmail.com>, Angelin Sirbu <angelin.sirbu@gmail.com> - https://github.com/angular-slider/angularjs-slider - 2016-06-04 */
!function(a,b){"use strict";"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof module&&module.exports?module.exports=b(require("angular")):b(a.angular)}(this,function(a){"use strict";var b=a.module("rzModule",[]).factory("RzSliderOptions",function(){var b={floor:0,ceil:null,step:1,precision:0,minRange:null,maxRange:null,minLimit:null,maxLimit:null,id:null,translate:null,getLegend:null,stepsArray:null,draggableRange:!1,draggableRangeOnly:!1,showSelectionBar:!1,showSelectionBarEnd:!1,showSelectionBarFromValue:null,hidePointerLabels:!1,hideLimitLabels:!1,readOnly:!1,disabled:!1,interval:350,showTicks:!1,showTicksValues:!1,ticksTooltip:null,ticksValuesTooltip:null,vertical:!1,getSelectionBarColor:null,getPointerColor:null,keyboardSupport:!0,scale:1,enforceStep:!0,enforceRange:!1,noSwitching:!1,onlyBindHandles:!1,onStart:null,onChange:null,onEnd:null,rightToLeft:!1,boundPointerLabels:!0},c={},d={};return d.options=function(b){a.extend(c,b)},d.getOptions=function(d){return a.extend({},b,c,d)},d}).factory("rzThrottle",["$timeout",function(a){return function(b,c,d){var e,f,g,h=Date.now||function(){return(new Date).getTime()},i=null,j=0;d=d||{};var k=function(){j=h(),i=null,g=b.apply(e,f),e=f=null};return function(){var l=h(),m=c-(l-j);return e=this,f=arguments,0>=m?(a.cancel(i),i=null,j=l,g=b.apply(e,f),e=f=null):i||d.trailing===!1||(i=a(k,m)),g}}}]).factory("RzSlider",["$timeout","$document","$window","$compile","RzSliderOptions","rzThrottle",function(b,c,d,e,f,g){var h=function(a,b){this.scope=a,this.sliderElem=b,this.range=void 0!==this.scope.rzSliderModel&&void 0!==this.scope.rzSliderHigh,this.dragging={active:!1,value:0,difference:0,offset:0,lowLimit:0,highLimit:0},this.positionProperty="left",this.dimensionProperty="width",this.handleHalfDim=0,this.maxPos=0,this.precision=0,this.step=1,this.tracking="",this.minValue=0,this.maxValue=0,this.valueRange=0,this.intermediateTicks=!1,this.initHasRun=!1,this.firstKeyDown=!1,this.internalChange=!1,this.fullBar=null,this.selBar=null,this.minH=null,this.maxH=null,this.flrLab=null,this.ceilLab=null,this.minLab=null,this.maxLab=null,this.cmbLab=null,this.ticks=null,this.init()};return h.prototype={init:function(){var b,c,e=this,f=function(){e.calcViewDimensions()};this.applyOptions(),this.initElemHandles(),this.manageElementsStyle(),this.setDisabledState(),this.calcViewDimensions(),this.setMinAndMax(),this.addAccessibility(),this.updateCeilLab(),this.updateFloorLab(),this.initHandles(),this.manageEventsBindings(),this.scope.$on("reCalcViewDimensions",f),a.element(d).on("resize",f),this.initHasRun=!0,b=g(function(){e.onLowHandleChange()},e.options.interval),c=g(function(){e.onHighHandleChange()},e.options.interval),this.scope.$on("rzSliderForceRender",function(){e.resetLabelsValue(),b(),e.range&&c(),e.resetSlider()}),this.scope.$watch("rzSliderOptions()",function(a,b){a!==b&&(e.applyOptions(),e.resetSlider())},!0),this.scope.$watch("rzSliderModel",function(a,c){e.internalChange||a!==c&&b()}),this.scope.$watch("rzSliderHigh",function(a,b){e.internalChange||a!==b&&(null!=a&&c(),(e.range&&null==a||!e.range&&null!=a)&&(e.applyOptions(),e.resetSlider()))}),this.scope.$on("$destroy",function(){e.unbindEvents(),a.element(d).off("resize",f)})},onLowHandleChange:function(){this.setMinAndMax(),this.updateLowHandle(this.valueToOffset(this.scope.rzSliderModel)),this.updateSelectionBar(),this.updateTicksScale(),this.updateAriaAttributes(),this.range&&this.updateCmbLabel()},onHighHandleChange:function(){this.setMinAndMax(),this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh)),this.updateSelectionBar(),this.updateTicksScale(),this.updateCmbLabel(),this.updateAriaAttributes()},applyOptions:function(){var b;b=this.scope.rzSliderOptions?this.scope.rzSliderOptions():{},this.options=f.getOptions(b),this.options.step<=0&&(this.options.step=1),this.range=void 0!==this.scope.rzSliderModel&&void 0!==this.scope.rzSliderHigh,this.options.draggableRange=this.range&&this.options.draggableRange,this.options.draggableRangeOnly=this.range&&this.options.draggableRangeOnly,this.options.draggableRangeOnly&&(this.options.draggableRange=!0),this.options.showTicks=this.options.showTicks||this.options.showTicksValues,this.scope.showTicks=this.options.showTicks,a.isNumber(this.options.showTicks)&&(this.intermediateTicks=!0),this.options.showSelectionBar=this.options.showSelectionBar||this.options.showSelectionBarEnd||null!==this.options.showSelectionBarFromValue,this.options.stepsArray?this.parseStepsArray():(this.options.translate?this.customTrFn=this.options.translate:this.customTrFn=function(a){return String(a)},this.options.getLegend&&(this.getLegend=this.options.getLegend)),this.options.vertical&&(this.positionProperty="bottom",this.dimensionProperty="height")},parseStepsArray:function(){this.options.floor=0,this.options.ceil=this.options.stepsArray.length-1,this.options.step=1,this.options.translate?this.customTrFn=this.options.translate:this.customTrFn=function(b){var c=this.options.stepsArray[b];return a.isObject(c)?c.value:c},this.getLegend=function(b){var c=this.options.stepsArray[b];return a.isObject(c)?c.legend:null}},resetSlider:function(){this.manageElementsStyle(),this.addAccessibility(),this.setMinAndMax(),this.updateCeilLab(),this.updateFloorLab(),this.unbindEvents(),this.manageEventsBindings(),this.setDisabledState(),this.calcViewDimensions()},initElemHandles:function(){a.forEach(this.sliderElem.children(),function(b,c){var d=a.element(b);switch(c){case 0:this.fullBar=d;break;case 1:this.selBar=d;break;case 2:this.minH=d;break;case 3:this.maxH=d;break;case 4:this.flrLab=d;break;case 5:this.ceilLab=d;break;case 6:this.minLab=d;break;case 7:this.maxLab=d;break;case 8:this.cmbLab=d;break;case 9:this.ticks=d}},this),this.selBar.rzsp=0,this.minH.rzsp=0,this.maxH.rzsp=0,this.flrLab.rzsp=0,this.ceilLab.rzsp=0,this.minLab.rzsp=0,this.maxLab.rzsp=0,this.cmbLab.rzsp=0},manageElementsStyle:function(){this.range?this.maxH.css("display",""):this.maxH.css("display","none"),this.alwaysHide(this.flrLab,this.options.showTicksValues||this.options.hideLimitLabels),this.alwaysHide(this.ceilLab,this.options.showTicksValues||this.options.hideLimitLabels);var a=this.options.showTicksValues&&!this.intermediateTicks;this.alwaysHide(this.minLab,a||this.options.hidePointerLabels),this.alwaysHide(this.maxLab,a||!this.range||this.options.hidePointerLabels),this.alwaysHide(this.cmbLab,a||!this.range||this.options.hidePointerLabels),this.alwaysHide(this.selBar,!this.range&&!this.options.showSelectionBar),this.options.vertical&&this.sliderElem.addClass("rz-vertical"),this.options.draggableRange?this.selBar.addClass("rz-draggable"):this.selBar.removeClass("rz-draggable"),this.intermediateTicks&&this.options.showTicksValues&&this.ticks.addClass("rz-ticks-values-under")},alwaysHide:function(a,b){a.rzAlwaysHide=b,b?this.hideEl(a):this.showEl(a)},manageEventsBindings:function(){this.options.disabled||this.options.readOnly?this.unbindEvents():this.bindEvents()},setDisabledState:function(){this.options.disabled?this.sliderElem.attr("disabled","disabled"):this.sliderElem.attr("disabled",null)},resetLabelsValue:function(){this.minLab.rzsv=void 0,this.maxLab.rzsv=void 0},initHandles:function(){this.updateLowHandle(this.valueToOffset(this.scope.rzSliderModel)),this.range&&this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh)),this.updateSelectionBar(),this.range&&this.updateCmbLabel(),this.updateTicksScale()},translateFn:function(a,b,c,d){d=void 0===d?!0:d;var e=String(d?this.customTrFn(a,this.options.id,c):a),f=!1;(void 0===b.rzsv||b.rzsv.length!==e.length||b.rzsv.length>0&&0===b.rzsd)&&(f=!0,b.rzsv=e),b.html(e),f&&this.getDimension(b)},setMinAndMax:function(){this.step=+this.options.step,this.precision=+this.options.precision,this.minValue=this.options.floor,this.options.enforceStep&&(this.scope.rzSliderModel=this.roundStep(this.scope.rzSliderModel),this.range&&(this.scope.rzSliderHigh=this.roundStep(this.scope.rzSliderHigh))),null!=this.options.ceil?this.maxValue=this.options.ceil:this.maxValue=this.options.ceil=this.range?this.scope.rzSliderHigh:this.scope.rzSliderModel,this.options.enforceRange&&(this.scope.rzSliderModel=this.sanitizeValue(this.scope.rzSliderModel),this.range&&(this.scope.rzSliderHigh=this.sanitizeValue(this.scope.rzSliderHigh))),this.valueRange=this.maxValue-this.minValue},addAccessibility:function(){this.minH.attr("role","slider"),this.updateAriaAttributes(),!this.options.keyboardSupport||this.options.readOnly||this.options.disabled?this.minH.attr("tabindex",""):this.minH.attr("tabindex","0"),this.options.vertical&&this.minH.attr("aria-orientation","vertical"),this.range&&(this.maxH.attr("role","slider"),!this.options.keyboardSupport||this.options.readOnly||this.options.disabled?this.maxH.attr("tabindex",""):this.maxH.attr("tabindex","0"),this.options.vertical&&this.maxH.attr("aria-orientation","vertical"))},updateAriaAttributes:function(){this.minH.attr({"aria-valuenow":this.scope.rzSliderModel,"aria-valuetext":this.customTrFn(this.scope.rzSliderModel,this.options.id,"model"),"aria-valuemin":this.minValue,"aria-valuemax":this.maxValue}),this.range&&this.maxH.attr({"aria-valuenow":this.scope.rzSliderHigh,"aria-valuetext":this.customTrFn(this.scope.rzSliderHigh,this.options.id,"high"),"aria-valuemin":this.minValue,"aria-valuemax":this.maxValue})},calcViewDimensions:function(){var a=this.getDimension(this.minH);this.handleHalfDim=a/2,this.barDimension=this.getDimension(this.fullBar),this.maxPos=this.barDimension-a,this.getDimension(this.sliderElem),this.sliderElem.rzsp=this.sliderElem[0].getBoundingClientRect()[this.positionProperty],this.initHasRun&&(this.updateFloorLab(),this.updateCeilLab(),this.initHandles())},updateTicksScale:function(){if(this.options.showTicks){var a=this.step;this.intermediateTicks&&(a=this.options.showTicks);var b=Math.round((this.maxValue-this.minValue)/a)+1;this.scope.ticks=[];for(var c=0;b>c;c++){var d=this.roundStep(this.minValue+c*a),e={selected:this.isTickSelected(d)};if(e.selected&&this.options.getSelectionBarColor&&(e.style={"background-color":this.getSelectionBarColor()}),this.options.ticksTooltip&&(e.tooltip=this.options.ticksTooltip(d),e.tooltipPlacement=this.options.vertical?"right":"top"),this.options.showTicksValues&&(e.value=this.getDisplayValue(d,"tick-value"),this.options.ticksValuesTooltip&&(e.valueTooltip=this.options.ticksValuesTooltip(d),e.valueTooltipPlacement=this.options.vertical?"right":"top")),this.getLegend){var f=this.getLegend(d,this.options.id);f&&(e.legend=f)}this.options.rightToLeft?this.scope.ticks.unshift(e):this.scope.ticks.push(e)}}},isTickSelected:function(a){if(!this.range)if(null!==this.options.showSelectionBarFromValue){var b=this.options.showSelectionBarFromValue;if(this.scope.rzSliderModel>b&&a>=b&&a<=this.scope.rzSliderModel)return!0;if(this.scope.rzSliderModel<b&&b>=a&&a>=this.scope.rzSliderModel)return!0}else if(this.options.showSelectionBarEnd){if(a>=this.scope.rzSliderModel)return!0}else if(this.options.showSelectionBar&&a<=this.scope.rzSliderModel)return!0;return this.range&&a>=this.scope.rzSliderModel&&a<=this.scope.rzSliderHigh?!0:!1},updateFloorLab:function(){this.translateFn(this.minValue,this.flrLab,"floor"),this.getDimension(this.flrLab);var a=this.options.rightToLeft?this.barDimension-this.flrLab.rzsd:0;this.setPosition(this.flrLab,a)},updateCeilLab:function(){this.translateFn(this.maxValue,this.ceilLab,"ceil"),this.getDimension(this.ceilLab);var a=this.options.rightToLeft?0:this.barDimension-this.ceilLab.rzsd;this.setPosition(this.ceilLab,a)},updateHandles:function(a,b){"rzSliderModel"===a?this.updateLowHandle(b):this.updateHighHandle(b),this.updateSelectionBar(),this.updateTicksScale(),this.range&&this.updateCmbLabel()},getHandleLabelPos:function(a,b){var c=this[a].rzsd,d=b-c/2+this.handleHalfDim,e=this.barDimension-c;return this.options.boundPointerLabels?this.options.rightToLeft&&"minLab"===a||!this.options.rightToLeft&&"maxLab"===a?Math.min(d,e):Math.min(Math.max(d,0),e):d},updateLowHandle:function(a){if(this.setPosition(this.minH,a),this.translateFn(this.scope.rzSliderModel,this.minLab,"model"),this.setPosition(this.minLab,this.getHandleLabelPos("minLab",a)),this.options.getPointerColor){var b=this.getPointerColor("min");this.scope.minPointerStyle={backgroundColor:b}}this.shFloorCeil()},updateHighHandle:function(a){if(this.setPosition(this.maxH,a),this.translateFn(this.scope.rzSliderHigh,this.maxLab,"high"),this.setPosition(this.maxLab,this.getHandleLabelPos("maxLab",a)),this.options.getPointerColor){var b=this.getPointerColor("max");this.scope.maxPointerStyle={backgroundColor:b}}this.shFloorCeil()},shFloorCeil:function(){var a=!1,b=!1,c=this.options.rightToLeft,d=this.flrLab.rzsp,e=this.flrLab.rzsd,f=this.minLab.rzsp,g=this.minLab.rzsd,h=this.maxLab.rzsp,i=this.maxLab.rzsd,j=this.ceilLab.rzsp,k=this.handleHalfDim,l=c?f+g>=d-e-5:d+e+5>=f,m=c?j+k+10>=f-g:f+g>=j-k-10,n=c?h>=d-e-k:d+e+k>=h,o=c?j+10>=h-i:h+i>=j-10;l?(a=!0,this.hideEl(this.flrLab)):(a=!1,this.showEl(this.flrLab)),m?(b=!0,this.hideEl(this.ceilLab)):(b=!1,this.showEl(this.ceilLab)),this.range&&(o?this.hideEl(this.ceilLab):b||this.showEl(this.ceilLab),n?this.hideEl(this.flrLab):a||this.showEl(this.flrLab))},updateSelectionBar:function(){var a=0,b=0,c=this.options.rightToLeft?!this.options.showSelectionBarEnd:this.options.showSelectionBarEnd,d=this.options.rightToLeft?this.maxH.rzsp+this.handleHalfDim:this.minH.rzsp+this.handleHalfDim;if(this.range)b=Math.abs(this.maxH.rzsp-this.minH.rzsp),a=d;else if(null!==this.options.showSelectionBarFromValue){var e=this.options.showSelectionBarFromValue,f=this.valueToOffset(e),g=this.options.rightToLeft?this.scope.rzSliderModel<=e:this.scope.rzSliderModel>e;g?(b=this.minH.rzsp-f,a=f+this.handleHalfDim):(b=f-this.minH.rzsp,a=this.minH.rzsp+this.handleHalfDim)}else c?(b=Math.abs(this.maxPos-this.minH.rzsp)+this.handleHalfDim,a=this.minH.rzsp+this.handleHalfDim):(b=Math.abs(this.maxH.rzsp-this.minH.rzsp)+this.handleHalfDim,a=0);if(this.setDimension(this.selBar,b),this.setPosition(this.selBar,a),this.options.getSelectionBarColor){var h=this.getSelectionBarColor();this.scope.barStyle={backgroundColor:h}}},getSelectionBarColor:function(){return this.range?this.options.getSelectionBarColor(this.scope.rzSliderModel,this.scope.rzSliderHigh):this.options.getSelectionBarColor(this.scope.rzSliderModel)},getPointerColor:function(a){return"max"===a?this.options.getPointerColor(this.scope.rzSliderHigh,a):this.options.getPointerColor(this.scope.rzSliderModel,a)},updateCmbLabel:function(){var a=null;if(a=this.options.rightToLeft?this.minLab.rzsp-this.minLab.rzsd-10<=this.maxLab.rzsp:this.minLab.rzsp+this.minLab.rzsd+10>=this.maxLab.rzsp){var b=this.getDisplayValue(this.scope.rzSliderModel,"model"),c=this.getDisplayValue(this.scope.rzSliderHigh,"high"),d="";d=b===c?b:this.options.rightToLeft?c+" - "+b:b+" - "+c,this.translateFn(d,this.cmbLab,"cmb",!1);var e=this.options.boundPointerLabels?Math.min(Math.max(this.selBar.rzsp+this.selBar.rzsd/2-this.cmbLab.rzsd/2,0),this.barDimension-this.cmbLab.rzsd):this.selBar.rzsp+this.selBar.rzsd/2-this.cmbLab.rzsd/2;this.setPosition(this.cmbLab,e),this.hideEl(this.minLab),this.hideEl(this.maxLab),this.showEl(this.cmbLab)}else this.showEl(this.maxLab),this.showEl(this.minLab),this.hideEl(this.cmbLab)},getDisplayValue:function(a,b){return this.customTrFn(a,this.options.id,b)},roundStep:function(a,b){var c=b?b:this.step,d=parseFloat((a-this.minValue)/c).toPrecision(12);d=Math.round(+d)*c;var e=(this.minValue+d).toFixed(this.precision);return+e},hideEl:function(a){return a.css({opacity:0})},showEl:function(a){return a.rzAlwaysHide?a:a.css({opacity:1})},setPosition:function(a,b){a.rzsp=b;var c={};return c[this.positionProperty]=b+"px",a.css(c),b},getDimension:function(a){var b=a[0].getBoundingClientRect();return this.options.vertical?a.rzsd=(b.bottom-b.top)*this.options.scale:a.rzsd=(b.right-b.left)*this.options.scale,a.rzsd},setDimension:function(a,b){a.rzsd=b;var c={};return c[this.dimensionProperty]=b+"px",a.css(c),b},valueToOffset:function(a){return this.options.rightToLeft?(this.maxValue-this.sanitizeValue(a))*this.maxPos/this.valueRange||0:(this.sanitizeValue(a)-this.minValue)*this.maxPos/this.valueRange||0},sanitizeValue:function(a){return Math.min(Math.max(a,this.minValue),this.maxValue)},offsetToValue:function(a){return this.options.rightToLeft?(1-a/this.maxPos)*this.valueRange+this.minValue:a/this.maxPos*this.valueRange+this.minValue},getEventXY:function(a){var b=this.options.vertical?"clientY":"clientX";return b in a?a[b]:void 0===a.originalEvent?a.touches[0][b]:a.originalEvent.touches[0][b]},getEventPosition:function(a){var b=this.sliderElem.rzsp,c=0;return c=this.options.vertical?-this.getEventXY(a)+b:this.getEventXY(a)-b,(c-this.handleHalfDim)*this.options.scale},getEventNames:function(a){var b={moveEvent:"",endEvent:""};return a.touches||void 0!==a.originalEvent&&a.originalEvent.touches?(b.moveEvent="touchmove",b.endEvent="touchend"):(b.moveEvent="mousemove",b.endEvent="mouseup"),b},getNearestHandle:function(a){if(!this.range)return this.minH;var b=this.getEventPosition(a),c=Math.abs(b-this.minH.rzsp),d=Math.abs(b-this.maxH.rzsp);return d>c?this.minH:c>d?this.maxH:this.options.rightToLeft?b>this.minH.rzsp?this.minH:this.maxH:b<this.minH.rzsp?this.minH:this.maxH},focusElement:function(a){var b=0;a[b].focus()},bindEvents:function(){var b,c,d;this.options.draggableRange?(b="rzSliderDrag",c=this.onDragStart,d=this.onDragMove):(b="rzSliderModel",c=this.onStart,d=this.onMove),this.options.onlyBindHandles||(this.selBar.on("mousedown",a.bind(this,c,null,b)),this.selBar.on("mousedown",a.bind(this,d,this.selBar))),this.options.draggableRangeOnly?(this.minH.on("mousedown",a.bind(this,c,null,b)),this.maxH.on("mousedown",a.bind(this,c,null,b))):(this.minH.on("mousedown",a.bind(this,this.onStart,this.minH,"rzSliderModel")),this.range&&this.maxH.on("mousedown",a.bind(this,this.onStart,this.maxH,"rzSliderHigh")),this.options.onlyBindHandles||(this.fullBar.on("mousedown",a.bind(this,this.onStart,null,null)),this.fullBar.on("mousedown",a.bind(this,this.onMove,this.fullBar)),this.ticks.on("mousedown",a.bind(this,this.onStart,null,null)),this.ticks.on("mousedown",a.bind(this,this.onTickClick,this.ticks)))),this.options.onlyBindHandles||(this.selBar.on("touchstart",a.bind(this,c,null,b)),this.selBar.on("touchstart",a.bind(this,d,this.selBar))),this.options.draggableRangeOnly?(this.minH.on("touchstart",a.bind(this,c,null,b)),this.maxH.on("touchstart",a.bind(this,c,null,b))):(this.minH.on("touchstart",a.bind(this,this.onStart,this.minH,"rzSliderModel")),this.range&&this.maxH.on("touchstart",a.bind(this,this.onStart,this.maxH,"rzSliderHigh")),this.options.onlyBindHandles||(this.fullBar.on("touchstart",a.bind(this,this.onStart,null,null)),this.fullBar.on("touchstart",a.bind(this,this.onMove,this.fullBar)),this.ticks.on("touchstart",a.bind(this,this.onStart,null,null)),this.ticks.on("touchstart",a.bind(this,this.onTickClick,this.ticks)))),this.options.keyboardSupport&&(this.minH.on("focus",a.bind(this,this.onPointerFocus,this.minH,"rzSliderModel")),this.range&&this.maxH.on("focus",a.bind(this,this.onPointerFocus,this.maxH,"rzSliderHigh")))},unbindEvents:function(){this.minH.off(),this.maxH.off(),this.fullBar.off(),this.selBar.off(),this.ticks.off()},onStart:function(b,d,e){var f,g,h=this.getEventNames(e);e.stopPropagation(),e.preventDefault(),this.calcViewDimensions(),b?this.tracking=d:(b=this.getNearestHandle(e),this.tracking=b===this.minH?"rzSliderModel":"rzSliderHigh"),b.addClass("rz-active"),this.options.keyboardSupport&&this.focusElement(b),f=a.bind(this,this.dragging.active?this.onDragMove:this.onMove,b),g=a.bind(this,this.onEnd,f),c.on(h.moveEvent,f),c.one(h.endEvent,g),this.callOnStart()},onMove:function(b,c,d){var e,f=this.getEventPosition(c),g=this.options.rightToLeft?this.minValue:this.maxValue,h=this.options.rightToLeft?this.maxValue:this.minValue;0>=f?e=h:f>=this.maxPos?e=g:(e=this.offsetToValue(f),e=d&&a.isNumber(this.options.showTicks)?this.roundStep(e,this.options.showTicks):this.roundStep(e)),this.positionTrackingHandle(e)},onEnd:function(a,b){var d=this.getEventNames(b).moveEvent;this.options.keyboardSupport||(this.minH.removeClass("rz-active"),this.maxH.removeClass("rz-active"),this.tracking=""),this.dragging.active=!1,c.off(d,a),this.callOnEnd()},onTickClick:function(a,b){this.onMove(a,b,!0)},onPointerFocus:function(b,c){this.tracking=c,b.one("blur",a.bind(this,this.onPointerBlur,b)),b.on("keydown",a.bind(this,this.onKeyboardEvent)),b.on("keyup",a.bind(this,this.onKeyUp)),this.firstKeyDown=!0,b.addClass("rz-active")},onKeyUp:function(){this.firstKeyDown=!0,this.callOnEnd()},onPointerBlur:function(a){a.off("keydown"),a.off("keyup"),this.tracking="",a.removeClass("rz-active")},getKeyActions:function(a){var b=a+this.step,c=a-this.step,d=a+this.valueRange/10,e=a-this.valueRange/10,f={UP:b,DOWN:c,LEFT:c,RIGHT:b,PAGEUP:d,PAGEDOWN:e,HOME:this.minValue,END:this.maxValue};return this.options.rightToLeft&&(f.LEFT=b,f.RIGHT=c,this.options.vertical&&(f.UP=c,f.DOWN=b)),f},onKeyboardEvent:function(a){var c=this.scope[this.tracking],d=a.keyCode||a.which,e={38:"UP",40:"DOWN",37:"LEFT",39:"RIGHT",33:"PAGEUP",34:"PAGEDOWN",36:"HOME",35:"END"},f=this.getKeyActions(c),g=e[d],h=f[g];if(null!=h&&""!==this.tracking){a.preventDefault(),this.firstKeyDown&&(this.firstKeyDown=!1,this.callOnStart());var i=this;b(function(){var a=i.roundStep(i.sanitizeValue(h));if(i.options.draggableRangeOnly){var b,c,d=i.scope.rzSliderHigh-i.scope.rzSliderModel;"rzSliderModel"===i.tracking?(b=a,c=a+d,c>i.maxValue&&(c=i.maxValue,b=c-d)):(c=a,b=a-d,b<i.minValue&&(b=i.minValue,c=b+d)),i.positionTrackingBar(b,c)}else i.positionTrackingHandle(a)})}},onDragStart:function(a,b,c){var d=this.getEventPosition(c);this.dragging={active:!0,value:this.offsetToValue(d),difference:this.scope.rzSliderHigh-this.scope.rzSliderModel,lowLimit:this.options.rightToLeft?this.minH.rzsp-d:d-this.minH.rzsp,highLimit:this.options.rightToLeft?d-this.maxH.rzsp:this.maxH.rzsp-d},this.onStart(a,b,c)},getValue:function(a,b,c,d){var e=this.options.rightToLeft,f=null;return f="min"===a?c?d?e?this.minValue:this.maxValue-this.dragging.difference:e?this.maxValue-this.dragging.difference:this.minValue:e?this.offsetToValue(b+this.dragging.lowLimit):this.offsetToValue(b-this.dragging.lowLimit):c?d?e?this.minValue+this.dragging.difference:this.maxValue:e?this.maxValue:this.minValue+this.dragging.difference:e?this.offsetToValue(b+this.dragging.lowLimit)+this.dragging.difference:this.offsetToValue(b-this.dragging.lowLimit)+this.dragging.difference,this.roundStep(f)},onDragMove:function(a,b){var c,d,e,f,g,h,i,j,k=this.getEventPosition(b);if(this.options.rightToLeft?(e=this.dragging.lowLimit,f=this.dragging.highLimit,i=this.maxH,j=this.minH):(e=this.dragging.highLimit,f=this.dragging.lowLimit,i=this.minH,j=this.maxH),g=f>=k,h=k>=this.maxPos-e,g){if(0===i.rzsp)return;c=this.getValue("min",k,!0,!1),d=this.getValue("max",k,!0,!1)}else if(h){if(j.rzsp===this.maxPos)return;d=this.getValue("max",k,!0,!0),c=this.getValue("min",k,!0,!0)}else c=this.getValue("min",k,!1),d=this.getValue("max",k,!1);this.positionTrackingBar(c,d)},positionTrackingBar:function(a,b){this.scope.rzSliderModel=a,this.scope.rzSliderHigh=b,this.updateHandles("rzSliderModel",this.valueToOffset(a)),this.updateHandles("rzSliderHigh",this.valueToOffset(b)),this.applyModel()},positionTrackingHandle:function(a){var b=!1;a=this.applyMinMaxLimit(a),this.range&&(a=this.applyMinMaxRange(a),"rzSliderModel"===this.tracking&&a>this.scope.rzSliderHigh?(this.options.noSwitching&&this.scope.rzSliderHigh!==this.minValue?a=this.applyMinMaxRange(this.scope.rzSliderHigh):(this.scope[this.tracking]=this.scope.rzSliderHigh,this.updateHandles(this.tracking,this.maxH.rzsp),this.updateAriaAttributes(),this.tracking="rzSliderHigh",this.minH.removeClass("rz-active"),this.maxH.addClass("rz-active"),this.options.keyboardSupport&&this.focusElement(this.maxH)),b=!0):"rzSliderHigh"===this.tracking&&a<this.scope.rzSliderModel&&(this.options.noSwitching&&this.scope.rzSliderModel!==this.maxValue?a=this.applyMinMaxRange(this.scope.rzSliderModel):(this.scope[this.tracking]=this.scope.rzSliderModel,this.updateHandles(this.tracking,this.minH.rzsp),this.updateAriaAttributes(),this.tracking="rzSliderModel",this.maxH.removeClass("rz-active"),this.minH.addClass("rz-active"),this.options.keyboardSupport&&this.focusElement(this.minH)),b=!0)),this.scope[this.tracking]!==a&&(this.scope[this.tracking]=a,this.updateHandles(this.tracking,this.valueToOffset(a)),this.updateAriaAttributes(),b=!0),b&&this.applyModel()},applyMinMaxLimit:function(a){return null!=this.options.minLimit&&a<this.options.minLimit?this.options.minLimit:null!=this.options.maxLimit&&a>this.options.maxLimit?this.options.maxLimit:a},applyMinMaxRange:function(a){var b="rzSliderModel"===this.tracking?this.scope.rzSliderHigh:this.scope.rzSliderModel,c=Math.abs(a-b);return null!=this.options.minRange&&c<this.options.minRange?"rzSliderModel"===this.tracking?this.scope.rzSliderHigh-this.options.minRange:this.scope.rzSliderModel+this.options.minRange:null!=this.options.maxRange&&c>this.options.maxRange?"rzSliderModel"===this.tracking?this.scope.rzSliderHigh-this.options.maxRange:this.scope.rzSliderModel+this.options.maxRange:a},applyModel:function(){this.internalChange=!0,this.scope.$apply(),this.callOnChange(),this.internalChange=!1},callOnStart:function(){if(this.options.onStart){var a=this;this.scope.$evalAsync(function(){a.options.onStart(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh)})}},callOnChange:function(){if(this.options.onChange){var a=this;this.scope.$evalAsync(function(){a.options.onChange(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh)})}},callOnEnd:function(){if(this.options.onEnd){var a=this;this.scope.$evalAsync(function(){a.options.onEnd(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh)})}this.scope.$emit("slideEnded")}},h}]).directive("rzslider",["RzSlider",function(a){return{restrict:"AE",replace:!0,scope:{rzSliderModel:"=?",rzSliderHigh:"=?",rzSliderOptions:"&?",rzSliderTplUrl:"@"},templateUrl:function(a,b){return b.rzSliderTplUrl||"rzSliderTpl.html"},link:function(b,c){b.slider=new a(b,c)}}}]);return b.run(["$templateCache",function(a){a.put("rzSliderTpl.html",'<div class=rzslider><span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class="rz-bar rz-selection" ng-style=barStyle></span></span> <span class="rz-pointer rz-pointer-min" ng-style=minPointerStyle></span> <span class="rz-pointer rz-pointer-max" ng-style=maxPointerStyle></span> <span class="rz-bubble rz-limit rz-floor"></span> <span class="rz-bubble rz-limit rz-ceil"></span> <span class=rz-bubble></span> <span class=rz-bubble></span> <span class=rz-bubble></span><ul ng-show=showTicks class=rz-ticks><li ng-repeat="t in ticks track by $index" class=rz-tick ng-class="{\'rz-selected\': t.selected}" ng-style=t.style ng-attr-uib-tooltip="{{ t.tooltip }}" ng-attr-tooltip-placement={{t.tooltipPlacement}} ng-attr-tooltip-append-to-body="{{ t.tooltip ? true : undefined}}"><span ng-if="t.value != null" class=rz-tick-value ng-attr-uib-tooltip="{{ t.valueTooltip }}" ng-attr-tooltip-placement={{t.valueTooltipPlacement}}>{{ t.value }}</span> <span ng-if="t.legend != null" class=rz-tick-legend>{{ t.legend }}</span></li></ul></div>')}]),b}); !function(a,b){"use strict";"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof module&&module.exports?module.exports=b(require("angular")):b(a.angular)}(this,function(a){"use strict";var b=a.module("rzModule",[]).factory("RzSliderOptions",function(){var b={floor:0,ceil:null,step:1,precision:0,minRange:null,maxRange:null,minLimit:null,maxLimit:null,id:null,translate:null,getLegend:null,stepsArray:null,draggableRange:!1,draggableRangeOnly:!1,showSelectionBar:!1,showSelectionBarEnd:!1,showSelectionBarFromValue:null,hidePointerLabels:!1,hideLimitLabels:!1,readOnly:!1,disabled:!1,interval:350,showTicks:!1,showTicksValues:!1,ticksTooltip:null,ticksValuesTooltip:null,vertical:!1,getSelectionBarColor:null,getPointerColor:null,keyboardSupport:!0,scale:1,enforceStep:!0,enforceRange:!1,noSwitching:!1,onlyBindHandles:!1,onStart:null,onChange:null,onEnd:null,rightToLeft:!1,boundPointerLabels:!0},c={},d={};return d.options=function(b){a.extend(c,b)},d.getOptions=function(d){return a.extend({},b,c,d)},d}).factory("rzThrottle",["$timeout",function(a){return function(b,c,d){var e,f,g,h=Date.now||function(){return(new Date).getTime()},i=null,j=0;d=d||{};var k=function(){j=h(),i=null,g=b.apply(e,f),e=f=null};return function(){var l=h(),m=c-(l-j);return e=this,f=arguments,0>=m?(a.cancel(i),i=null,j=l,g=b.apply(e,f),e=f=null):i||d.trailing===!1||(i=a(k,m)),g}}}]).factory("RzSlider",["$timeout","$document","$window","$compile","RzSliderOptions","rzThrottle",function(b,c,d,e,f,g){var h=function(a,b){this.scope=a,this.lowValue=0,this.highValue=0,this.sliderElem=b,this.range=void 0!==this.scope.rzSliderModel&&void 0!==this.scope.rzSliderHigh,this.dragging={active:!1,value:0,difference:0,offset:0,lowLimit:0,highLimit:0},this.positionProperty="left",this.dimensionProperty="width",this.handleHalfDim=0,this.maxPos=0,this.precision=0,this.step=1,this.tracking="",this.minValue=0,this.maxValue=0,this.valueRange=0,this.intermediateTicks=!1,this.initHasRun=!1,this.firstKeyDown=!1,this.internalChange=!1,this.fullBar=null,this.selBar=null,this.minH=null,this.maxH=null,this.flrLab=null,this.ceilLab=null,this.minLab=null,this.maxLab=null,this.cmbLab=null,this.ticks=null,this.init()};return h.prototype={init:function(){var b,c,e=this,f=function(){e.calcViewDimensions()};this.applyOptions(),this.syncLowValue(),this.range&&this.syncHighValue(),this.initElemHandles(),this.manageElementsStyle(),this.setDisabledState(),this.calcViewDimensions(),this.setMinAndMax(),this.addAccessibility(),this.updateCeilLab(),this.updateFloorLab(),this.initHandles(),this.manageEventsBindings(),this.scope.$on("reCalcViewDimensions",f),a.element(d).on("resize",f),this.initHasRun=!0,b=g(function(){e.onLowHandleChange()},e.options.interval),c=g(function(){e.onHighHandleChange()},e.options.interval),this.scope.$on("rzSliderForceRender",function(){e.resetLabelsValue(),b(),e.range&&c(),e.resetSlider()}),this.scope.$watch("rzSliderOptions()",function(a,b){a!==b&&(e.applyOptions(),e.syncLowValue(),e.range&&e.syncHighValue(),e.resetSlider())},!0),this.scope.$watch("rzSliderModel",function(a,c){e.internalChange||a!==c&&b()}),this.scope.$watch("rzSliderHigh",function(a,b){e.internalChange||a!==b&&(null!=a&&c(),(e.range&&null==a||!e.range&&null!=a)&&(e.applyOptions(),e.resetSlider()))}),this.scope.$on("$destroy",function(){e.unbindEvents(),a.element(d).off("resize",f)})},findStepIndex:function(b){for(var c=0,d=0;d<this.options.stepsArray.length;d++){var e=this.options.stepsArray[d];if(e===b){c=d;break}if(a.isObject(e)&&e.value===b){c=d;break}}return c},syncLowValue:function(){this.options.stepsArray?this.lowValue=this.findStepIndex(this.scope.rzSliderModel):this.lowValue=this.scope.rzSliderModel},syncHighValue:function(){this.options.stepsArray?this.highValue=this.findStepIndex(this.scope.rzSliderHigh):this.highValue=this.scope.rzSliderHigh},getStepValue:function(b){var c=this.options.stepsArray[b];return a.isObject(c)?c.value:c},applyLowValue:function(){this.options.stepsArray?this.scope.rzSliderModel=this.getStepValue(this.lowValue):this.scope.rzSliderModel=this.lowValue},applyHighValue:function(){this.options.stepsArray?this.scope.rzSliderHigh=this.getStepValue(this.highValue):this.scope.rzSliderHigh=this.highValue},onLowHandleChange:function(){this.syncLowValue(),this.range&&this.syncHighValue(),this.setMinAndMax(),this.updateLowHandle(this.valueToOffset(this.lowValue)),this.updateSelectionBar(),this.updateTicksScale(),this.updateAriaAttributes(),this.range&&this.updateCmbLabel()},onHighHandleChange:function(){this.syncLowValue(),this.syncHighValue(),this.setMinAndMax(),this.updateHighHandle(this.valueToOffset(this.highValue)),this.updateSelectionBar(),this.updateTicksScale(),this.updateCmbLabel(),this.updateAriaAttributes()},applyOptions:function(){var b;b=this.scope.rzSliderOptions?this.scope.rzSliderOptions():{},this.options=f.getOptions(b),this.options.step<=0&&(this.options.step=1),this.range=void 0!==this.scope.rzSliderModel&&void 0!==this.scope.rzSliderHigh,this.options.draggableRange=this.range&&this.options.draggableRange,this.options.draggableRangeOnly=this.range&&this.options.draggableRangeOnly,this.options.draggableRangeOnly&&(this.options.draggableRange=!0),this.options.showTicks=this.options.showTicks||this.options.showTicksValues,this.scope.showTicks=this.options.showTicks,a.isNumber(this.options.showTicks)&&(this.intermediateTicks=!0),this.options.showSelectionBar=this.options.showSelectionBar||this.options.showSelectionBarEnd||null!==this.options.showSelectionBarFromValue,this.options.stepsArray?this.parseStepsArray():(this.options.translate?this.customTrFn=this.options.translate:this.customTrFn=function(a){return String(a)},this.options.getLegend&&(this.getLegend=this.options.getLegend)),this.options.vertical&&(this.positionProperty="bottom",this.dimensionProperty="height")},parseStepsArray:function(){this.options.floor=0,this.options.ceil=this.options.stepsArray.length-1,this.options.step=1,this.options.translate?this.customTrFn=this.options.translate:this.customTrFn=function(a){return a},this.getLegend=function(b){var c=this.options.stepsArray[b];return a.isObject(c)?c.legend:null}},resetSlider:function(){this.manageElementsStyle(),this.addAccessibility(),this.setMinAndMax(),this.updateCeilLab(),this.updateFloorLab(),this.unbindEvents(),this.manageEventsBindings(),this.setDisabledState(),this.calcViewDimensions()},initElemHandles:function(){a.forEach(this.sliderElem.children(),function(b,c){var d=a.element(b);switch(c){case 0:this.fullBar=d;break;case 1:this.selBar=d;break;case 2:this.minH=d;break;case 3:this.maxH=d;break;case 4:this.flrLab=d;break;case 5:this.ceilLab=d;break;case 6:this.minLab=d;break;case 7:this.maxLab=d;break;case 8:this.cmbLab=d;break;case 9:this.ticks=d}},this),this.selBar.rzsp=0,this.minH.rzsp=0,this.maxH.rzsp=0,this.flrLab.rzsp=0,this.ceilLab.rzsp=0,this.minLab.rzsp=0,this.maxLab.rzsp=0,this.cmbLab.rzsp=0},manageElementsStyle:function(){this.range?this.maxH.css("display",""):this.maxH.css("display","none"),this.alwaysHide(this.flrLab,this.options.showTicksValues||this.options.hideLimitLabels),this.alwaysHide(this.ceilLab,this.options.showTicksValues||this.options.hideLimitLabels);var a=this.options.showTicksValues&&!this.intermediateTicks;this.alwaysHide(this.minLab,a||this.options.hidePointerLabels),this.alwaysHide(this.maxLab,a||!this.range||this.options.hidePointerLabels),this.alwaysHide(this.cmbLab,a||!this.range||this.options.hidePointerLabels),this.alwaysHide(this.selBar,!this.range&&!this.options.showSelectionBar),this.options.vertical&&this.sliderElem.addClass("rz-vertical"),this.options.draggableRange?this.selBar.addClass("rz-draggable"):this.selBar.removeClass("rz-draggable"),this.intermediateTicks&&this.options.showTicksValues&&this.ticks.addClass("rz-ticks-values-under")},alwaysHide:function(a,b){a.rzAlwaysHide=b,b?this.hideEl(a):this.showEl(a)},manageEventsBindings:function(){this.options.disabled||this.options.readOnly?this.unbindEvents():this.bindEvents()},setDisabledState:function(){this.options.disabled?this.sliderElem.attr("disabled","disabled"):this.sliderElem.attr("disabled",null)},resetLabelsValue:function(){this.minLab.rzsv=void 0,this.maxLab.rzsv=void 0},initHandles:function(){this.updateLowHandle(this.valueToOffset(this.lowValue)),this.range&&this.updateHighHandle(this.valueToOffset(this.highValue)),this.updateSelectionBar(),this.range&&this.updateCmbLabel(),this.updateTicksScale()},translateFn:function(a,b,c,d){d=void 0===d?!0:d;var e="",f=!1;d?(this.options.stepsArray&&(a=this.getStepValue(a)),e=String(this.customTrFn(a,this.options.id,c))):e=String(a),(void 0===b.rzsv||b.rzsv.length!==e.length||b.rzsv.length>0&&0===b.rzsd)&&(f=!0,b.rzsv=e),b.html(e),f&&this.getDimension(b)},setMinAndMax:function(){this.step=+this.options.step,this.precision=+this.options.precision,this.minValue=this.options.floor,this.options.enforceStep&&(this.lowValue=this.roundStep(this.lowValue),this.range&&(this.highValue=this.roundStep(this.highValue))),null!=this.options.ceil?this.maxValue=this.options.ceil:this.maxValue=this.options.ceil=this.range?this.highValue:this.lowValue,this.options.enforceRange&&(this.lowValue=this.sanitizeValue(this.lowValue),this.range&&(this.highValue=this.sanitizeValue(this.highValue))),this.applyLowValue(),this.range&&this.applyHighValue(),this.valueRange=this.maxValue-this.minValue},addAccessibility:function(){this.minH.attr("role","slider"),this.updateAriaAttributes(),!this.options.keyboardSupport||this.options.readOnly||this.options.disabled?this.minH.attr("tabindex",""):this.minH.attr("tabindex","0"),this.options.vertical&&this.minH.attr("aria-orientation","vertical"),this.range&&(this.maxH.attr("role","slider"),!this.options.keyboardSupport||this.options.readOnly||this.options.disabled?this.maxH.attr("tabindex",""):this.maxH.attr("tabindex","0"),this.options.vertical&&this.maxH.attr("aria-orientation","vertical"))},updateAriaAttributes:function(){this.minH.attr({"aria-valuenow":this.scope.rzSliderModel,"aria-valuetext":this.customTrFn(this.scope.rzSliderModel,this.options.id,"model"),"aria-valuemin":this.minValue,"aria-valuemax":this.maxValue}),this.range&&this.maxH.attr({"aria-valuenow":this.scope.rzSliderHigh,"aria-valuetext":this.customTrFn(this.scope.rzSliderHigh,this.options.id,"high"),"aria-valuemin":this.minValue,"aria-valuemax":this.maxValue})},calcViewDimensions:function(){var a=this.getDimension(this.minH);this.handleHalfDim=a/2,this.barDimension=this.getDimension(this.fullBar),this.maxPos=this.barDimension-a,this.getDimension(this.sliderElem),this.sliderElem.rzsp=this.sliderElem[0].getBoundingClientRect()[this.positionProperty],this.initHasRun&&(this.updateFloorLab(),this.updateCeilLab(),this.initHandles())},updateTicksScale:function(){if(this.options.showTicks){var a=this.step;this.intermediateTicks&&(a=this.options.showTicks);var b=Math.round((this.maxValue-this.minValue)/a)+1;this.scope.ticks=[];for(var c=0;b>c;c++){var d=this.roundStep(this.minValue+c*a),e={selected:this.isTickSelected(d)};if(e.selected&&this.options.getSelectionBarColor&&(e.style={"background-color":this.getSelectionBarColor()}),this.options.ticksTooltip&&(e.tooltip=this.options.ticksTooltip(d),e.tooltipPlacement=this.options.vertical?"right":"top"),this.options.showTicksValues&&(e.value=this.getDisplayValue(d,"tick-value"),this.options.ticksValuesTooltip&&(e.valueTooltip=this.options.ticksValuesTooltip(d),e.valueTooltipPlacement=this.options.vertical?"right":"top")),this.getLegend){var f=this.getLegend(d,this.options.id);f&&(e.legend=f)}this.options.rightToLeft?this.scope.ticks.unshift(e):this.scope.ticks.push(e)}}},isTickSelected:function(a){if(!this.range)if(null!==this.options.showSelectionBarFromValue){var b=this.options.showSelectionBarFromValue;if(this.lowValue>b&&a>=b&&a<=this.lowValue)return!0;if(this.lowValue<b&&b>=a&&a>=this.lowValue)return!0}else if(this.options.showSelectionBarEnd){if(a>=this.lowValue)return!0}else if(this.options.showSelectionBar&&a<=this.lowValue)return!0;return this.range&&a>=this.lowValue&&a<=this.highValue?!0:!1},updateFloorLab:function(){this.translateFn(this.minValue,this.flrLab,"floor"),this.getDimension(this.flrLab);var a=this.options.rightToLeft?this.barDimension-this.flrLab.rzsd:0;this.setPosition(this.flrLab,a)},updateCeilLab:function(){this.translateFn(this.maxValue,this.ceilLab,"ceil"),this.getDimension(this.ceilLab);var a=this.options.rightToLeft?0:this.barDimension-this.ceilLab.rzsd;this.setPosition(this.ceilLab,a)},updateHandles:function(a,b){"lowValue"===a?this.updateLowHandle(b):this.updateHighHandle(b),this.updateSelectionBar(),this.updateTicksScale(),this.range&&this.updateCmbLabel()},getHandleLabelPos:function(a,b){var c=this[a].rzsd,d=b-c/2+this.handleHalfDim,e=this.barDimension-c;return this.options.boundPointerLabels?this.options.rightToLeft&&"minLab"===a||!this.options.rightToLeft&&"maxLab"===a?Math.min(d,e):Math.min(Math.max(d,0),e):d},updateLowHandle:function(a){if(this.setPosition(this.minH,a),this.translateFn(this.lowValue,this.minLab,"model"),this.setPosition(this.minLab,this.getHandleLabelPos("minLab",a)),this.options.getPointerColor){var b=this.getPointerColor("min");this.scope.minPointerStyle={backgroundColor:b}}this.shFloorCeil()},updateHighHandle:function(a){if(this.setPosition(this.maxH,a),this.translateFn(this.highValue,this.maxLab,"high"),this.setPosition(this.maxLab,this.getHandleLabelPos("maxLab",a)),this.options.getPointerColor){var b=this.getPointerColor("max");this.scope.maxPointerStyle={backgroundColor:b}}this.shFloorCeil()},shFloorCeil:function(){var a=!1,b=!1,c=this.options.rightToLeft,d=this.flrLab.rzsp,e=this.flrLab.rzsd,f=this.minLab.rzsp,g=this.minLab.rzsd,h=this.maxLab.rzsp,i=this.maxLab.rzsd,j=this.ceilLab.rzsp,k=this.handleHalfDim,l=c?f+g>=d-e-5:d+e+5>=f,m=c?j+k+10>=f-g:f+g>=j-k-10,n=c?h>=d-e-k:d+e+k>=h,o=c?j+10>=h-i:h+i>=j-10;l?(a=!0,this.hideEl(this.flrLab)):(a=!1,this.showEl(this.flrLab)),m?(b=!0,this.hideEl(this.ceilLab)):(b=!1,this.showEl(this.ceilLab)),this.range&&(o?this.hideEl(this.ceilLab):b||this.showEl(this.ceilLab),n?this.hideEl(this.flrLab):a||this.showEl(this.flrLab))},updateSelectionBar:function(){var a=0,b=0,c=this.options.rightToLeft?!this.options.showSelectionBarEnd:this.options.showSelectionBarEnd,d=this.options.rightToLeft?this.maxH.rzsp+this.handleHalfDim:this.minH.rzsp+this.handleHalfDim;if(this.range)b=Math.abs(this.maxH.rzsp-this.minH.rzsp),a=d;else if(null!==this.options.showSelectionBarFromValue){var e=this.options.showSelectionBarFromValue,f=this.valueToOffset(e),g=this.options.rightToLeft?this.lowValue<=e:this.lowValue>e;g?(b=this.minH.rzsp-f,a=f+this.handleHalfDim):(b=f-this.minH.rzsp,a=this.minH.rzsp+this.handleHalfDim)}else c?(b=Math.abs(this.maxPos-this.minH.rzsp)+this.handleHalfDim,a=this.minH.rzsp+this.handleHalfDim):(b=Math.abs(this.maxH.rzsp-this.minH.rzsp)+this.handleHalfDim,a=0);if(this.setDimension(this.selBar,b),this.setPosition(this.selBar,a),this.options.getSelectionBarColor){var h=this.getSelectionBarColor();this.scope.barStyle={backgroundColor:h}}},getSelectionBarColor:function(){return this.range?this.options.getSelectionBarColor(this.scope.rzSliderModel,this.scope.rzSliderHigh):this.options.getSelectionBarColor(this.scope.rzSliderModel)},getPointerColor:function(a){return"max"===a?this.options.getPointerColor(this.scope.rzSliderHigh,a):this.options.getPointerColor(this.scope.rzSliderModel,a)},updateCmbLabel:function(){var a=null;if(a=this.options.rightToLeft?this.minLab.rzsp-this.minLab.rzsd-10<=this.maxLab.rzsp:this.minLab.rzsp+this.minLab.rzsd+10>=this.maxLab.rzsp){var b=this.getDisplayValue(this.lowValue,"model"),c=this.getDisplayValue(this.highValue,"high"),d="";d=b===c?b:this.options.rightToLeft?c+" - "+b:b+" - "+c,this.translateFn(d,this.cmbLab,"cmb",!1);var e=this.options.boundPointerLabels?Math.min(Math.max(this.selBar.rzsp+this.selBar.rzsd/2-this.cmbLab.rzsd/2,0),this.barDimension-this.cmbLab.rzsd):this.selBar.rzsp+this.selBar.rzsd/2-this.cmbLab.rzsd/2;this.setPosition(this.cmbLab,e),this.hideEl(this.minLab),this.hideEl(this.maxLab),this.showEl(this.cmbLab)}else this.showEl(this.maxLab),this.showEl(this.minLab),this.hideEl(this.cmbLab)},getDisplayValue:function(a,b){return this.options.stepsArray&&(a=this.getStepValue(a)),this.customTrFn(a,this.options.id,b)},roundStep:function(a,b){var c=b?b:this.step,d=parseFloat((a-this.minValue)/c).toPrecision(12);d=Math.round(+d)*c;var e=(this.minValue+d).toFixed(this.precision);return+e},hideEl:function(a){return a.css({opacity:0})},showEl:function(a){return a.rzAlwaysHide?a:a.css({opacity:1})},setPosition:function(a,b){a.rzsp=b;var c={};return c[this.positionProperty]=b+"px",a.css(c),b},getDimension:function(a){var b=a[0].getBoundingClientRect();return this.options.vertical?a.rzsd=(b.bottom-b.top)*this.options.scale:a.rzsd=(b.right-b.left)*this.options.scale,a.rzsd},setDimension:function(a,b){a.rzsd=b;var c={};return c[this.dimensionProperty]=b+"px",a.css(c),b},valueToOffset:function(a){return this.options.rightToLeft?(this.maxValue-this.sanitizeValue(a))*this.maxPos/this.valueRange||0:(this.sanitizeValue(a)-this.minValue)*this.maxPos/this.valueRange||0},sanitizeValue:function(a){return Math.min(Math.max(a,this.minValue),this.maxValue)},offsetToValue:function(a){return this.options.rightToLeft?(1-a/this.maxPos)*this.valueRange+this.minValue:a/this.maxPos*this.valueRange+this.minValue},getEventXY:function(a){var b=this.options.vertical?"clientY":"clientX";return b in a?a[b]:void 0===a.originalEvent?a.touches[0][b]:a.originalEvent.touches[0][b]},getEventPosition:function(a){var b=this.sliderElem.rzsp,c=0;return c=this.options.vertical?-this.getEventXY(a)+b:this.getEventXY(a)-b,(c-this.handleHalfDim)*this.options.scale},getEventNames:function(a){var b={moveEvent:"",endEvent:""};return a.touches||void 0!==a.originalEvent&&a.originalEvent.touches?(b.moveEvent="touchmove",b.endEvent="touchend"):(b.moveEvent="mousemove",b.endEvent="mouseup"),b},getNearestHandle:function(a){if(!this.range)return this.minH;var b=this.getEventPosition(a),c=Math.abs(b-this.minH.rzsp),d=Math.abs(b-this.maxH.rzsp);return d>c?this.minH:c>d?this.maxH:this.options.rightToLeft?b>this.minH.rzsp?this.minH:this.maxH:b<this.minH.rzsp?this.minH:this.maxH},focusElement:function(a){var b=0;a[b].focus()},bindEvents:function(){var b,c,d;this.options.draggableRange?(b="rzSliderDrag",c=this.onDragStart,d=this.onDragMove):(b="lowValue",c=this.onStart,d=this.onMove),this.options.onlyBindHandles||(this.selBar.on("mousedown",a.bind(this,c,null,b)),this.selBar.on("mousedown",a.bind(this,d,this.selBar))),this.options.draggableRangeOnly?(this.minH.on("mousedown",a.bind(this,c,null,b)),this.maxH.on("mousedown",a.bind(this,c,null,b))):(this.minH.on("mousedown",a.bind(this,this.onStart,this.minH,"lowValue")),this.range&&this.maxH.on("mousedown",a.bind(this,this.onStart,this.maxH,"highValue")),this.options.onlyBindHandles||(this.fullBar.on("mousedown",a.bind(this,this.onStart,null,null)),this.fullBar.on("mousedown",a.bind(this,this.onMove,this.fullBar)),this.ticks.on("mousedown",a.bind(this,this.onStart,null,null)),this.ticks.on("mousedown",a.bind(this,this.onTickClick,this.ticks)))),this.options.onlyBindHandles||(this.selBar.on("touchstart",a.bind(this,c,null,b)),this.selBar.on("touchstart",a.bind(this,d,this.selBar))),this.options.draggableRangeOnly?(this.minH.on("touchstart",a.bind(this,c,null,b)),this.maxH.on("touchstart",a.bind(this,c,null,b))):(this.minH.on("touchstart",a.bind(this,this.onStart,this.minH,"lowValue")),this.range&&this.maxH.on("touchstart",a.bind(this,this.onStart,this.maxH,"highValue")),this.options.onlyBindHandles||(this.fullBar.on("touchstart",a.bind(this,this.onStart,null,null)),this.fullBar.on("touchstart",a.bind(this,this.onMove,this.fullBar)),this.ticks.on("touchstart",a.bind(this,this.onStart,null,null)),this.ticks.on("touchstart",a.bind(this,this.onTickClick,this.ticks)))),this.options.keyboardSupport&&(this.minH.on("focus",a.bind(this,this.onPointerFocus,this.minH,"lowValue")),this.range&&this.maxH.on("focus",a.bind(this,this.onPointerFocus,this.maxH,"highValue")))},unbindEvents:function(){this.minH.off(),this.maxH.off(),this.fullBar.off(),this.selBar.off(),this.ticks.off()},onStart:function(b,d,e){var f,g,h=this.getEventNames(e);e.stopPropagation(),e.preventDefault(),this.calcViewDimensions(),b?this.tracking=d:(b=this.getNearestHandle(e),this.tracking=b===this.minH?"lowValue":"highValue"),b.addClass("rz-active"),this.options.keyboardSupport&&this.focusElement(b),f=a.bind(this,this.dragging.active?this.onDragMove:this.onMove,b),g=a.bind(this,this.onEnd,f),c.on(h.moveEvent,f),c.one(h.endEvent,g),this.callOnStart()},onMove:function(b,c,d){var e,f=this.getEventPosition(c),g=this.options.rightToLeft?this.minValue:this.maxValue,h=this.options.rightToLeft?this.maxValue:this.minValue;0>=f?e=h:f>=this.maxPos?e=g:(e=this.offsetToValue(f),e=d&&a.isNumber(this.options.showTicks)?this.roundStep(e,this.options.showTicks):this.roundStep(e)),this.positionTrackingHandle(e)},onEnd:function(a,b){var d=this.getEventNames(b).moveEvent;this.options.keyboardSupport||(this.minH.removeClass("rz-active"),this.maxH.removeClass("rz-active"),this.tracking=""),this.dragging.active=!1,c.off(d,a),this.callOnEnd()},onTickClick:function(a,b){this.onMove(a,b,!0)},onPointerFocus:function(b,c){this.tracking=c,b.one("blur",a.bind(this,this.onPointerBlur,b)),b.on("keydown",a.bind(this,this.onKeyboardEvent)),b.on("keyup",a.bind(this,this.onKeyUp)),this.firstKeyDown=!0,b.addClass("rz-active")},onKeyUp:function(){this.firstKeyDown=!0,this.callOnEnd()},onPointerBlur:function(a){a.off("keydown"),a.off("keyup"),this.tracking="",a.removeClass("rz-active")},getKeyActions:function(a){var b=a+this.step,c=a-this.step,d=a+this.valueRange/10,e=a-this.valueRange/10,f={UP:b,DOWN:c,LEFT:c,RIGHT:b,PAGEUP:d,PAGEDOWN:e,HOME:this.minValue,END:this.maxValue};return this.options.rightToLeft&&(f.LEFT=b,f.RIGHT=c,this.options.vertical&&(f.UP=c,f.DOWN=b)),f},onKeyboardEvent:function(a){var c=this[this.tracking],d=a.keyCode||a.which,e={38:"UP",40:"DOWN",37:"LEFT",39:"RIGHT",33:"PAGEUP",34:"PAGEDOWN",36:"HOME",35:"END"},f=this.getKeyActions(c),g=e[d],h=f[g];if(null!=h&&""!==this.tracking){a.preventDefault(),this.firstKeyDown&&(this.firstKeyDown=!1,this.callOnStart());var i=this;b(function(){var a=i.roundStep(i.sanitizeValue(h));if(i.options.draggableRangeOnly){var b,c,d=i.highValue-i.lowValue;"lowValue"===i.tracking?(b=a,c=a+d,c>i.maxValue&&(c=i.maxValue,b=c-d)):(c=a,b=a-d,b<i.minValue&&(b=i.minValue,c=b+d)),i.positionTrackingBar(b,c)}else i.positionTrackingHandle(a)})}},onDragStart:function(a,b,c){var d=this.getEventPosition(c);this.dragging={active:!0,value:this.offsetToValue(d),difference:this.highValue-this.lowValue,lowLimit:this.options.rightToLeft?this.minH.rzsp-d:d-this.minH.rzsp,highLimit:this.options.rightToLeft?d-this.maxH.rzsp:this.maxH.rzsp-d},this.onStart(a,b,c)},getValue:function(a,b,c,d){var e=this.options.rightToLeft,f=null;return f="min"===a?c?d?e?this.minValue:this.maxValue-this.dragging.difference:e?this.maxValue-this.dragging.difference:this.minValue:e?this.offsetToValue(b+this.dragging.lowLimit):this.offsetToValue(b-this.dragging.lowLimit):c?d?e?this.minValue+this.dragging.difference:this.maxValue:e?this.maxValue:this.minValue+this.dragging.difference:e?this.offsetToValue(b+this.dragging.lowLimit)+this.dragging.difference:this.offsetToValue(b-this.dragging.lowLimit)+this.dragging.difference,this.roundStep(f)},onDragMove:function(a,b){var c,d,e,f,g,h,i,j,k=this.getEventPosition(b);if(this.options.rightToLeft?(e=this.dragging.lowLimit,f=this.dragging.highLimit,i=this.maxH,j=this.minH):(e=this.dragging.highLimit,f=this.dragging.lowLimit,i=this.minH,j=this.maxH),g=f>=k,h=k>=this.maxPos-e,g){if(0===i.rzsp)return;c=this.getValue("min",k,!0,!1),d=this.getValue("max",k,!0,!1)}else if(h){if(j.rzsp===this.maxPos)return;d=this.getValue("max",k,!0,!0),c=this.getValue("min",k,!0,!0)}else c=this.getValue("min",k,!1),d=this.getValue("max",k,!1);this.positionTrackingBar(c,d)},positionTrackingBar:function(a,b){this.lowValue=a,this.highValue=b,this.applyLowValue(),this.range&&this.applyHighValue(),this.applyModel(),this.updateHandles("lowValue",this.valueToOffset(a)),this.updateHandles("highValue",this.valueToOffset(b))},positionTrackingHandle:function(a){var b=!1;a=this.applyMinMaxLimit(a),this.range&&(a=this.applyMinMaxRange(a),"lowValue"===this.tracking&&a>this.highValue?(this.options.noSwitching&&this.highValue!==this.minValue?a=this.applyMinMaxRange(this.highValue):(this.lowValue=this.highValue,this.applyLowValue(),this.updateHandles(this.tracking,this.maxH.rzsp),this.updateAriaAttributes(),this.tracking="highValue",this.minH.removeClass("rz-active"),this.maxH.addClass("rz-active"),this.options.keyboardSupport&&this.focusElement(this.maxH)),b=!0):"highValue"===this.tracking&&a<this.lowValue&&(this.options.noSwitching&&this.lowValue!==this.maxValue?a=this.applyMinMaxRange(this.lowValue):(this.highValue=this.lowValue,this.applyHighValue(),this.updateHandles(this.tracking,this.minH.rzsp),this.updateAriaAttributes(),this.tracking="lowValue",this.maxH.removeClass("rz-active"),this.minH.addClass("rz-active"),this.options.keyboardSupport&&this.focusElement(this.minH)),b=!0)),this[this.tracking]!==a&&(this[this.tracking]=a,"lowValue"===this.tracking?this.applyLowValue():this.applyHighValue(),this.updateHandles(this.tracking,this.valueToOffset(a)),this.updateAriaAttributes(),b=!0),b&&this.applyModel()},applyMinMaxLimit:function(a){return null!=this.options.minLimit&&a<this.options.minLimit?this.options.minLimit:null!=this.options.maxLimit&&a>this.options.maxLimit?this.options.maxLimit:a},applyMinMaxRange:function(a){var b="lowValue"===this.tracking?this.highValue:this.lowValue,c=Math.abs(a-b);return null!=this.options.minRange&&c<this.options.minRange?"lowValue"===this.tracking?this.highValue-this.options.minRange:this.lowValue+this.options.minRange:null!=this.options.maxRange&&c>this.options.maxRange?"lowValue"===this.tracking?this.highValue-this.options.maxRange:this.lowValue+this.options.maxRange:a},applyModel:function(){this.internalChange=!0,this.scope.$apply(),this.callOnChange(),this.internalChange=!1},callOnStart:function(){if(this.options.onStart){var a=this;this.scope.$evalAsync(function(){a.options.onStart(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh)})}},callOnChange:function(){if(this.options.onChange){var a=this;this.scope.$evalAsync(function(){a.options.onChange(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh)})}},callOnEnd:function(){if(this.options.onEnd){var a=this;this.scope.$evalAsync(function(){a.options.onEnd(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh)})}this.scope.$emit("slideEnded")}},h}]).directive("rzslider",["RzSlider",function(a){return{restrict:"AE",replace:!0,scope:{rzSliderModel:"=?",rzSliderHigh:"=?",rzSliderOptions:"&?",rzSliderTplUrl:"@"},templateUrl:function(a,b){return b.rzSliderTplUrl||"rzSliderTpl.html"},link:function(b,c){b.slider=new a(b,c)}}}]);return b.run(["$templateCache",function(a){a.put("rzSliderTpl.html",'<div class=rzslider><span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class="rz-bar rz-selection" ng-style=barStyle></span></span> <span class="rz-pointer rz-pointer-min" ng-style=minPointerStyle></span> <span class="rz-pointer rz-pointer-max" ng-style=maxPointerStyle></span> <span class="rz-bubble rz-limit rz-floor"></span> <span class="rz-bubble rz-limit rz-ceil"></span> <span class=rz-bubble></span> <span class=rz-bubble></span> <span class=rz-bubble></span><ul ng-show=showTicks class=rz-ticks><li ng-repeat="t in ticks track by $index" class=rz-tick ng-class="{\'rz-selected\': t.selected}" ng-style=t.style ng-attr-uib-tooltip="{{ t.tooltip }}" ng-attr-tooltip-placement={{t.tooltipPlacement}} ng-attr-tooltip-append-to-body="{{ t.tooltip ? true : undefined}}"><span ng-if="t.value != null" class=rz-tick-value ng-attr-uib-tooltip="{{ t.valueTooltip }}" ng-attr-tooltip-placement={{t.valueTooltipPlacement}}>{{ t.value }}</span> <span ng-if="t.legend != null" class=rz-tick-legend>{{ t.legend }}</span></li></ul></div>')}]),b});
\ No newline at end of file \ No newline at end of file
...@@ -159,6 +159,18 @@ ...@@ -159,6 +159,18 @@
*/ */
this.scope = scope; this.scope = scope;
/**
* The slider inner low value (linked to rzSliderModel)
* @type {number}
*/
this.lowValue = 0;
/**
* The slider inner high value (linked to rzSliderHigh)
* @type {number}
*/
this.highValue = 0;
/** /**
* Slider element wrapped in jqLite * Slider element wrapped in jqLite
* *
...@@ -276,7 +288,7 @@ ...@@ -276,7 +288,7 @@
* *
* @type {boolean} * @type {boolean}
*/ */
this.firstKeyDown = false this.firstKeyDown = false;
/** /**
* Internal flag to prevent watchers to be called when the sliders value are modified internally. * Internal flag to prevent watchers to be called when the sliders value are modified internally.
...@@ -317,6 +329,9 @@ ...@@ -317,6 +329,9 @@
}; };
this.applyOptions(); this.applyOptions();
this.syncLowValue();
if (this.range)
this.syncHighValue();
this.initElemHandles(); this.initElemHandles();
this.manageElementsStyle(); this.manageElementsStyle();
this.setDisabledState(); this.setDisabledState();
...@@ -359,7 +374,10 @@ ...@@ -359,7 +374,10 @@
this.scope.$watch('rzSliderOptions()', function(newValue, oldValue) { this.scope.$watch('rzSliderOptions()', function(newValue, oldValue) {
if (newValue === oldValue) if (newValue === oldValue)
return; return;
self.applyOptions(); self.applyOptions(); // need to be called before synchronizing the values
self.syncLowValue();
if (self.range)
self.syncHighValue();
self.resetSlider(); self.resetSlider();
}, true); }, true);
...@@ -390,12 +408,66 @@ ...@@ -390,12 +408,66 @@
}); });
}, },
findStepIndex: function(modelValue) {
var index = 0;
for (var i = 0; i < this.options.stepsArray.length; i++) {
var step = this.options.stepsArray[i];
if (step === modelValue) {
index = i;
break;
}
else if (angular.isObject(step) && step.value === modelValue) {
index = i;
break;
}
}
return index;
},
syncLowValue: function() {
if (this.options.stepsArray)
this.lowValue = this.findStepIndex(this.scope.rzSliderModel);
else
this.lowValue = this.scope.rzSliderModel;
},
syncHighValue: function() {
if (this.options.stepsArray)
this.highValue = this.findStepIndex(this.scope.rzSliderHigh);
else
this.highValue = this.scope.rzSliderHigh;
},
getStepValue: function(sliderValue) {
var step = this.options.stepsArray[sliderValue];
if (angular.isObject(step))
return step.value;
return step;
},
applyLowValue: function() {
if (this.options.stepsArray)
this.scope.rzSliderModel = this.getStepValue(this.lowValue);
else
this.scope.rzSliderModel = this.lowValue;
},
applyHighValue: function() {
if (this.options.stepsArray)
this.scope.rzSliderHigh = this.getStepValue(this.highValue);
else
this.scope.rzSliderHigh = this.highValue;
},
/* /*
* Reflow the slider when the low handle changes (called with throttle) * Reflow the slider when the low handle changes (called with throttle)
*/ */
onLowHandleChange: function() { onLowHandleChange: function() {
this.syncLowValue();
if (this.range)
this.syncHighValue();
this.setMinAndMax(); this.setMinAndMax();
this.updateLowHandle(this.valueToOffset(this.scope.rzSliderModel)); this.updateLowHandle(this.valueToOffset(this.lowValue));
this.updateSelectionBar(); this.updateSelectionBar();
this.updateTicksScale(); this.updateTicksScale();
this.updateAriaAttributes(); this.updateAriaAttributes();
...@@ -408,8 +480,10 @@ ...@@ -408,8 +480,10 @@
* Reflow the slider when the high handle changes (called with throttle) * Reflow the slider when the high handle changes (called with throttle)
*/ */
onHighHandleChange: function() { onHighHandleChange: function() {
this.syncLowValue();
this.syncHighValue();
this.setMinAndMax(); this.setMinAndMax();
this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh)); this.updateHighHandle(this.valueToOffset(this.highValue));
this.updateSelectionBar(); this.updateSelectionBar();
this.updateTicksScale(); this.updateTicksScale();
this.updateCmbLabel(); this.updateCmbLabel();
...@@ -476,11 +550,8 @@ ...@@ -476,11 +550,8 @@
this.customTrFn = this.options.translate; this.customTrFn = this.options.translate;
} }
else { else {
this.customTrFn = function(index) { this.customTrFn = function(modelValue) {
var step = this.options.stepsArray[index]; return modelValue;
if (angular.isObject(step))
return step.value;
return step;
}; };
} }
...@@ -650,14 +721,14 @@ ...@@ -650,14 +721,14 @@
* @returns {undefined} * @returns {undefined}
*/ */
initHandles: function() { initHandles: function() {
this.updateLowHandle(this.valueToOffset(this.scope.rzSliderModel)); this.updateLowHandle(this.valueToOffset(this.lowValue));
/* /*
the order here is important since the selection bar should be the order here is important since the selection bar should be
updated after the high handle but before the combined label updated after the high handle but before the combined label
*/ */
if (this.range) if (this.range)
this.updateHighHandle(this.valueToOffset(this.scope.rzSliderHigh)); this.updateHighHandle(this.valueToOffset(this.highValue));
this.updateSelectionBar(); this.updateSelectionBar();
if (this.range) if (this.range)
this.updateCmbLabel(); this.updateCmbLabel();
...@@ -670,15 +741,25 @@ ...@@ -670,15 +741,25 @@
* *
* @param {number|string} value * @param {number|string} value
* @param {jqLite} label * @param {jqLite} label
* @param {String} which
* @param {boolean} [useCustomTr] * @param {boolean} [useCustomTr]
* @returns {undefined} * @returns {undefined}
*/ */
translateFn: function(value, label, which, useCustomTr) { translateFn: function(value, label, which, useCustomTr) {
useCustomTr = useCustomTr === undefined ? true : useCustomTr; useCustomTr = useCustomTr === undefined ? true : useCustomTr;
var valStr = String((useCustomTr ? this.customTrFn(value, this.options.id, which) : value)), var valStr = '',
getDimension = false; getDimension = false;
if (useCustomTr) {
if (this.options.stepsArray)
value = this.getStepValue(value);
valStr = String(this.customTrFn(value, this.options.id, which));
}
else {
valStr = String(value)
}
if (label.rzsv === undefined || label.rzsv.length !== valStr.length || (label.rzsv.length > 0 && label.rzsd === 0)) { if (label.rzsv === undefined || label.rzsv.length !== valStr.length || (label.rzsv.length > 0 && label.rzsd === 0)) {
getDimension = true; getDimension = true;
label.rzsv = valStr; label.rzsv = valStr;
...@@ -705,22 +786,26 @@ ...@@ -705,22 +786,26 @@
this.minValue = this.options.floor; this.minValue = this.options.floor;
if (this.options.enforceStep) { if (this.options.enforceStep) {
this.scope.rzSliderModel = this.roundStep(this.scope.rzSliderModel); this.lowValue = this.roundStep(this.lowValue);
if (this.range) if (this.range)
this.scope.rzSliderHigh = this.roundStep(this.scope.rzSliderHigh); this.highValue = this.roundStep(this.highValue);
} }
if (this.options.ceil != null) if (this.options.ceil != null)
this.maxValue = this.options.ceil; this.maxValue = this.options.ceil;
else else
this.maxValue = this.options.ceil = this.range ? this.scope.rzSliderHigh : this.scope.rzSliderModel; this.maxValue = this.options.ceil = this.range ? this.highValue : this.lowValue;
if (this.options.enforceRange) { if (this.options.enforceRange) {
this.scope.rzSliderModel = this.sanitizeValue(this.scope.rzSliderModel); this.lowValue = this.sanitizeValue(this.lowValue);
if (this.range) if (this.range)
this.scope.rzSliderHigh = this.sanitizeValue(this.scope.rzSliderHigh); this.highValue = this.sanitizeValue(this.highValue);
} }
this.applyLowValue();
if (this.range)
this.applyHighValue();
this.valueRange = this.maxValue - this.minValue; this.valueRange = this.maxValue - this.minValue;
}, },
...@@ -847,19 +932,19 @@ ...@@ -847,19 +932,19 @@
if (!this.range) { if (!this.range) {
if (this.options.showSelectionBarFromValue !== null) { if (this.options.showSelectionBarFromValue !== null) {
var center = this.options.showSelectionBarFromValue; var center = this.options.showSelectionBarFromValue;
if (this.scope.rzSliderModel > center && value >= center && value <= this.scope.rzSliderModel) if (this.lowValue > center && value >= center && value <= this.lowValue)
return true; return true;
else if (this.scope.rzSliderModel < center && value <= center && value >= this.scope.rzSliderModel) else if (this.lowValue < center && value <= center && value >= this.lowValue)
return true; return true;
} }
else if (this.options.showSelectionBarEnd) { else if (this.options.showSelectionBarEnd) {
if (value >= this.scope.rzSliderModel) if (value >= this.lowValue)
return true; return true;
} }
else if (this.options.showSelectionBar && value <= this.scope.rzSliderModel) else if (this.options.showSelectionBar && value <= this.lowValue)
return true; return true;
} }
if (this.range && value >= this.scope.rzSliderModel && value <= this.scope.rzSliderHigh) if (this.range && value >= this.lowValue && value <= this.highValue)
return true; return true;
return false; return false;
}, },
...@@ -895,7 +980,7 @@ ...@@ -895,7 +980,7 @@
* @param {number} newOffset * @param {number} newOffset
*/ */
updateHandles: function(which, newOffset) { updateHandles: function(which, newOffset) {
if (which === 'rzSliderModel') if (which === 'lowValue')
this.updateLowHandle(newOffset); this.updateLowHandle(newOffset);
else else
this.updateHighHandle(newOffset); this.updateHighHandle(newOffset);
...@@ -937,7 +1022,7 @@ ...@@ -937,7 +1022,7 @@
*/ */
updateLowHandle: function(newOffset) { updateLowHandle: function(newOffset) {
this.setPosition(this.minH, newOffset); this.setPosition(this.minH, newOffset);
this.translateFn(this.scope.rzSliderModel, this.minLab, 'model'); this.translateFn(this.lowValue, this.minLab, 'model');
this.setPosition(this.minLab, this.getHandleLabelPos('minLab', newOffset)); this.setPosition(this.minLab, this.getHandleLabelPos('minLab', newOffset));
if (this.options.getPointerColor) { if (this.options.getPointerColor) {
...@@ -958,7 +1043,7 @@ ...@@ -958,7 +1043,7 @@
*/ */
updateHighHandle: function(newOffset) { updateHighHandle: function(newOffset) {
this.setPosition(this.maxH, newOffset); this.setPosition(this.maxH, newOffset);
this.translateFn(this.scope.rzSliderHigh, this.maxLab, 'high'); this.translateFn(this.highValue, this.maxLab, 'high');
this.setPosition(this.maxLab, this.getHandleLabelPos('maxLab', newOffset)); this.setPosition(this.maxLab, this.getHandleLabelPos('maxLab', newOffset));
if (this.options.getPointerColor) { if (this.options.getPointerColor) {
...@@ -1045,7 +1130,7 @@ ...@@ -1045,7 +1130,7 @@
if (this.options.showSelectionBarFromValue !== null) { if (this.options.showSelectionBarFromValue !== null) {
var center = this.options.showSelectionBarFromValue, var center = this.options.showSelectionBarFromValue,
centerPosition = this.valueToOffset(center), centerPosition = this.valueToOffset(center),
isModelGreaterThanCenter = this.options.rightToLeft ? this.scope.rzSliderModel <= center : this.scope.rzSliderModel > center; isModelGreaterThanCenter = this.options.rightToLeft ? this.lowValue <= center : this.lowValue > center;
if (isModelGreaterThanCenter) { if (isModelGreaterThanCenter) {
dimension = this.minH.rzsp - centerPosition; dimension = this.minH.rzsp - centerPosition;
position = centerPosition + this.handleHalfDim; position = centerPosition + this.handleHalfDim;
...@@ -1108,8 +1193,8 @@ ...@@ -1108,8 +1193,8 @@
} }
if (isLabelOverlap) { if (isLabelOverlap) {
var lowTr = this.getDisplayValue(this.scope.rzSliderModel, 'model'), var lowTr = this.getDisplayValue(this.lowValue, 'model'),
highTr = this.getDisplayValue(this.scope.rzSliderHigh, 'high'), highTr = this.getDisplayValue(this.highValue, 'high'),
labelVal = ''; labelVal = '';
if (lowTr === highTr) { if (lowTr === highTr) {
labelVal = lowTr; labelVal = lowTr;
...@@ -1144,6 +1229,9 @@ ...@@ -1144,6 +1229,9 @@
* @returns {*} * @returns {*}
*/ */
getDisplayValue: function(value, which) { getDisplayValue: function(value, which) {
if (this.options.stepsArray) {
value = this.getStepValue(value);
}
return this.customTrFn(value, this.options.id, which); return this.customTrFn(value, this.options.id, which);
}, },
...@@ -1378,7 +1466,7 @@ ...@@ -1378,7 +1466,7 @@
barStart = this.onDragStart; barStart = this.onDragStart;
barMove = this.onDragMove; barMove = this.onDragMove;
} else { } else {
barTracking = 'rzSliderModel'; barTracking = 'lowValue';
barStart = this.onStart; barStart = this.onStart;
barMove = this.onMove; barMove = this.onMove;
} }
...@@ -1392,9 +1480,9 @@ ...@@ -1392,9 +1480,9 @@
this.minH.on('mousedown', angular.bind(this, barStart, null, barTracking)); this.minH.on('mousedown', angular.bind(this, barStart, null, barTracking));
this.maxH.on('mousedown', angular.bind(this, barStart, null, barTracking)); this.maxH.on('mousedown', angular.bind(this, barStart, null, barTracking));
} else { } else {
this.minH.on('mousedown', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); this.minH.on('mousedown', angular.bind(this, this.onStart, this.minH, 'lowValue'));
if (this.range) { if (this.range) {
this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); this.maxH.on('mousedown', angular.bind(this, this.onStart, this.maxH, 'highValue'));
} }
if (!this.options.onlyBindHandles) { if (!this.options.onlyBindHandles) {
this.fullBar.on('mousedown', angular.bind(this, this.onStart, null, null)); this.fullBar.on('mousedown', angular.bind(this, this.onStart, null, null));
...@@ -1412,9 +1500,9 @@ ...@@ -1412,9 +1500,9 @@
this.minH.on('touchstart', angular.bind(this, barStart, null, barTracking)); this.minH.on('touchstart', angular.bind(this, barStart, null, barTracking));
this.maxH.on('touchstart', angular.bind(this, barStart, null, barTracking)); this.maxH.on('touchstart', angular.bind(this, barStart, null, barTracking));
} else { } else {
this.minH.on('touchstart', angular.bind(this, this.onStart, this.minH, 'rzSliderModel')); this.minH.on('touchstart', angular.bind(this, this.onStart, this.minH, 'lowValue'));
if (this.range) { if (this.range) {
this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'rzSliderHigh')); this.maxH.on('touchstart', angular.bind(this, this.onStart, this.maxH, 'highValue'));
} }
if (!this.options.onlyBindHandles) { if (!this.options.onlyBindHandles) {
this.fullBar.on('touchstart', angular.bind(this, this.onStart, null, null)); this.fullBar.on('touchstart', angular.bind(this, this.onStart, null, null));
...@@ -1425,9 +1513,9 @@ ...@@ -1425,9 +1513,9 @@
} }
if (this.options.keyboardSupport) { if (this.options.keyboardSupport) {
this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'rzSliderModel')); this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'lowValue'));
if (this.range) { if (this.range) {
this.maxH.on('focus', angular.bind(this, this.onPointerFocus, this.maxH, 'rzSliderHigh')); this.maxH.on('focus', angular.bind(this, this.onPointerFocus, this.maxH, 'highValue'));
} }
} }
}, },
...@@ -1468,7 +1556,7 @@ ...@@ -1468,7 +1556,7 @@
this.tracking = ref; this.tracking = ref;
} else { } else {
pointer = this.getNearestHandle(event); pointer = this.getNearestHandle(event);
this.tracking = pointer === this.minH ? 'rzSliderModel' : 'rzSliderHigh'; this.tracking = pointer === this.minH ? 'lowValue' : 'highValue';
} }
pointer.addClass('rz-active'); pointer.addClass('rz-active');
...@@ -1596,7 +1684,7 @@ ...@@ -1596,7 +1684,7 @@
}, },
onKeyboardEvent: function(event) { onKeyboardEvent: function(event) {
var currentValue = this.scope[this.tracking], var currentValue = this[this.tracking],
keyCode = event.keyCode || event.which, keyCode = event.keyCode || event.which,
keys = { keys = {
38: 'UP', 38: 'UP',
...@@ -1624,10 +1712,11 @@ ...@@ -1624,10 +1712,11 @@
var newValue = self.roundStep(self.sanitizeValue(action)); var newValue = self.roundStep(self.sanitizeValue(action));
if (!self.options.draggableRangeOnly) { if (!self.options.draggableRangeOnly) {
self.positionTrackingHandle(newValue); self.positionTrackingHandle(newValue);
} else { }
var difference = self.scope.rzSliderHigh - self.scope.rzSliderModel, else {
var difference = self.highValue - self.lowValue,
newMinValue, newMaxValue; newMinValue, newMaxValue;
if (self.tracking === 'rzSliderModel') { if (self.tracking === 'lowValue') {
newMinValue = newValue; newMinValue = newValue;
newMaxValue = newValue + difference; newMaxValue = newValue + difference;
if (newMaxValue > self.maxValue) { if (newMaxValue > self.maxValue) {
...@@ -1662,7 +1751,7 @@ ...@@ -1662,7 +1751,7 @@
this.dragging = { this.dragging = {
active: true, active: true,
value: this.offsetToValue(offset), value: this.offsetToValue(offset),
difference: this.scope.rzSliderHigh - this.scope.rzSliderModel, difference: this.highValue - this.lowValue,
lowLimit: this.options.rightToLeft ? this.minH.rzsp - offset : offset - this.minH.rzsp, lowLimit: this.options.rightToLeft ? this.minH.rzsp - offset : offset - this.minH.rzsp,
highLimit: this.options.rightToLeft ? offset - this.maxH.rzsp : this.maxH.rzsp - offset highLimit: this.options.rightToLeft ? offset - this.maxH.rzsp : this.maxH.rzsp - offset
}; };
...@@ -1768,11 +1857,14 @@ ...@@ -1768,11 +1857,14 @@
* @param {number} newMaxValue the new maximum value * @param {number} newMaxValue the new maximum value
*/ */
positionTrackingBar: function(newMinValue, newMaxValue) { positionTrackingBar: function(newMinValue, newMaxValue) {
this.scope.rzSliderModel = newMinValue; this.lowValue = newMinValue;
this.scope.rzSliderHigh = newMaxValue; this.highValue = newMaxValue;
this.updateHandles('rzSliderModel', this.valueToOffset(newMinValue)); this.applyLowValue();
this.updateHandles('rzSliderHigh', this.valueToOffset(newMaxValue)); if (this.range)
this.applyHighValue();
this.applyModel(); this.applyModel();
this.updateHandles('lowValue', this.valueToOffset(newMinValue));
this.updateHandles('highValue', this.valueToOffset(newMaxValue));
}, },
/** /**
...@@ -1787,30 +1879,32 @@ ...@@ -1787,30 +1879,32 @@
if (this.range) { if (this.range) {
newValue = this.applyMinMaxRange(newValue); newValue = this.applyMinMaxRange(newValue);
/* This is to check if we need to switch the min and max handles */ /* This is to check if we need to switch the min and max handles */
if (this.tracking === 'rzSliderModel' && newValue > this.scope.rzSliderHigh) { if (this.tracking === 'lowValue' && newValue > this.highValue) {
if (this.options.noSwitching && this.scope.rzSliderHigh !== this.minValue) { if (this.options.noSwitching && this.highValue !== this.minValue) {
newValue = this.applyMinMaxRange(this.scope.rzSliderHigh); newValue = this.applyMinMaxRange(this.highValue);
} }
else { else {
this.scope[this.tracking] = this.scope.rzSliderHigh; this.lowValue = this.highValue;
this.applyLowValue();
this.updateHandles(this.tracking, this.maxH.rzsp); this.updateHandles(this.tracking, this.maxH.rzsp);
this.updateAriaAttributes(); this.updateAriaAttributes();
this.tracking = 'rzSliderHigh'; this.tracking = 'highValue';
this.minH.removeClass('rz-active'); this.minH.removeClass('rz-active');
this.maxH.addClass('rz-active'); this.maxH.addClass('rz-active');
if (this.options.keyboardSupport) if (this.options.keyboardSupport)
this.focusElement(this.maxH); this.focusElement(this.maxH);
} }
valueChanged = true; valueChanged = true;
} else if (this.tracking === 'rzSliderHigh' && newValue < this.scope.rzSliderModel) { } else if (this.tracking === 'highValue' && newValue < this.lowValue) {
if (this.options.noSwitching && this.scope.rzSliderModel !== this.maxValue) { if (this.options.noSwitching && this.lowValue !== this.maxValue) {
newValue = this.applyMinMaxRange(this.scope.rzSliderModel); newValue = this.applyMinMaxRange(this.lowValue);
} }
else { else {
this.scope[this.tracking] = this.scope.rzSliderModel; this.highValue = this.lowValue;
this.applyHighValue();
this.updateHandles(this.tracking, this.minH.rzsp); this.updateHandles(this.tracking, this.minH.rzsp);
this.updateAriaAttributes(); this.updateAriaAttributes();
this.tracking = 'rzSliderModel'; this.tracking = 'lowValue';
this.maxH.removeClass('rz-active'); this.maxH.removeClass('rz-active');
this.minH.addClass('rz-active'); this.minH.addClass('rz-active');
if (this.options.keyboardSupport) if (this.options.keyboardSupport)
...@@ -1820,8 +1914,12 @@ ...@@ -1820,8 +1914,12 @@
} }
} }
if (this.scope[this.tracking] !== newValue) { if (this[this.tracking] !== newValue) {
this.scope[this.tracking] = newValue; this[this.tracking] = newValue;
if (this.tracking === 'lowValue')
this.applyLowValue();
else
this.applyHighValue();
this.updateHandles(this.tracking, this.valueToOffset(newValue)); this.updateHandles(this.tracking, this.valueToOffset(newValue));
this.updateAriaAttributes(); this.updateAriaAttributes();
valueChanged = true; valueChanged = true;
...@@ -1840,22 +1938,22 @@ ...@@ -1840,22 +1938,22 @@
}, },
applyMinMaxRange: function(newValue) { applyMinMaxRange: function(newValue) {
var oppositeValue = this.tracking === 'rzSliderModel' ? this.scope.rzSliderHigh : this.scope.rzSliderModel, var oppositeValue = this.tracking === 'lowValue' ? this.highValue : this.lowValue,
difference = Math.abs(newValue - oppositeValue); difference = Math.abs(newValue - oppositeValue);
if (this.options.minRange != null) { if (this.options.minRange != null) {
if (difference < this.options.minRange) { if (difference < this.options.minRange) {
if (this.tracking === 'rzSliderModel') if (this.tracking === 'lowValue')
return this.scope.rzSliderHigh - this.options.minRange; return this.highValue - this.options.minRange;
else else
return this.scope.rzSliderModel + this.options.minRange; return this.lowValue + this.options.minRange;
} }
} }
if (this.options.maxRange != null) { if (this.options.maxRange != null) {
if (difference > this.options.maxRange) { if (difference > this.options.maxRange) {
if (this.tracking === 'rzSliderModel') if (this.tracking === 'lowValue')
return this.scope.rzSliderHigh - this.options.maxRange; return this.highValue - this.options.maxRange;
else else
return this.scope.rzSliderModel + this.options.maxRange; return this.lowValue + this.options.maxRange;
} }
} }
return newValue; return newValue;
......
...@@ -203,7 +203,7 @@ ...@@ -203,7 +203,7 @@
it('should have accessible slider when values are text', function() { it('should have accessible slider when values are text', function() {
var sliderConf = { var sliderConf = {
value: 1, value: 'B',
options: { options: {
stepsArray: ['A', 'B', 'C'] stepsArray: ['A', 'B', 'C']
} }
...@@ -211,14 +211,14 @@ ...@@ -211,14 +211,14 @@
helper.createSlider(sliderConf); helper.createSlider(sliderConf);
expect(helper.slider.minH.attr('role')).to.equal('slider'); expect(helper.slider.minH.attr('role')).to.equal('slider');
expect(helper.slider.minH.attr('tabindex')).to.equal('0'); expect(helper.slider.minH.attr('tabindex')).to.equal('0');
expect(helper.slider.minH.attr('aria-valuenow')).to.equal('1'); expect(helper.slider.minH.attr('aria-valuenow')).to.equal('B');
expect(helper.slider.minH.attr('aria-valuetext')).to.equal('B'); expect(helper.slider.minH.attr('aria-valuetext')).to.equal('B');
expect(helper.slider.minH.attr('aria-valuemin')).to.equal('0'); expect(helper.slider.minH.attr('aria-valuemin')).to.equal('0');
expect(helper.slider.minH.attr('aria-valuemax')).to.equal('2'); expect(helper.slider.minH.attr('aria-valuemax')).to.equal('2');
helper.scope.slider.value = 2; helper.scope.slider.value = 'C';
helper.scope.$digest(); helper.scope.$digest();
expect(helper.slider.minH.attr('aria-valuenow')).to.equal('2'); expect(helper.slider.minH.attr('aria-valuenow')).to.equal('C');
expect(helper.slider.minH.attr('aria-valuetext')).to.equal('C'); expect(helper.slider.minH.attr('aria-valuetext')).to.equal('C');
}); });
}); });
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset); var event = helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset); var event = helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
expect(helper.scope.slider.min).to.equal(50); expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70); expect(helper.scope.slider.max).to.equal(70);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingBar.called.should.be.true; helper.slider.positionTrackingBar.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(50); expect(helper.scope.slider.max).to.equal(50);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() { it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() {
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(60); expect(helper.scope.slider.max).to.equal(60);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and move move range when near max and moved right', function() { it('should handle click on selbar and move move range when near max and moved right', function() {
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
expect(helper.scope.slider.min).to.equal(50); expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and don\'t move range when already at max and moved right', function() { it('should handle click on selbar and don\'t move range when already at max and moved right', function() {
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
expect(helper.scope.slider.min).to.equal(40); expect(helper.scope.slider.min).to.equal(40);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should a working positionTrackingBar', function() { it('should a working positionTrackingBar', function() {
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset); var event = helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -314,7 +314,7 @@ ...@@ -314,7 +314,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset); var event = helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -335,7 +335,7 @@ ...@@ -335,7 +335,7 @@
expect(helper.scope.slider.min).to.equal(30); expect(helper.scope.slider.min).to.equal(30);
expect(helper.scope.slider.max).to.equal(50); expect(helper.scope.slider.max).to.equal(50);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingBar.called.should.be.true; helper.slider.positionTrackingBar.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -351,7 +351,7 @@ ...@@ -351,7 +351,7 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(50); expect(helper.scope.slider.max).to.equal(50);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
}); });
it('should handle click on selbar and don\'t move range when already at 0 and moved right', function() { it('should handle click on selbar and don\'t move range when already at 0 and moved right', function() {
...@@ -363,7 +363,7 @@ ...@@ -363,7 +363,7 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(60); expect(helper.scope.slider.max).to.equal(60);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
}); });
it('should handle click on selbar and move range when near max and moved left', function() { it('should handle click on selbar and move range when near max and moved left', function() {
...@@ -375,7 +375,7 @@ ...@@ -375,7 +375,7 @@
expect(helper.scope.slider.min).to.equal(50); expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
}); });
it('should handle click on selbar and don\'t move range when already at max and moved left', function() { it('should handle click on selbar and don\'t move range when already at max and moved left', function() {
...@@ -387,7 +387,7 @@ ...@@ -387,7 +387,7 @@
expect(helper.scope.slider.min).to.equal(40); expect(helper.scope.slider.min).to.equal(40);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
}); });
it('should a working positionTrackingBar', function() { it('should a working positionTrackingBar', function() {
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
expect(helper.scope.slider.min).to.equal(50); expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70); expect(helper.scope.slider.max).to.equal(70);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingBar.called.should.be.true; helper.slider.positionTrackingBar.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(50); expect(helper.scope.slider.max).to.equal(50);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() { it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() {
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(60); expect(helper.scope.slider.max).to.equal(60);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and move range when near max and moved right', function() { it('should handle click on selbar and move range when near max and moved right', function() {
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
expect(helper.scope.slider.min).to.equal(50); expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and don\'t move range when already at max and moved right', function() { it('should handle click on selbar and don\'t move range when already at max and moved right', function() {
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
expect(helper.scope.slider.min).to.equal(40); expect(helper.scope.slider.min).to.equal(40);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and move range when floor is not 0 and handle is dragged below limit', function() { it('should handle click on selbar and move range when floor is not 0 and handle is dragged below limit', function() {
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
expect(helper.scope.slider.min).to.equal(1000); expect(helper.scope.slider.min).to.equal(1000);
expect(helper.scope.slider.max).to.equal(1500); expect(helper.scope.slider.max).to.equal(1500);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
}); });
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
expect(helper.scope.slider.min).to.equal(50); expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70); expect(helper.scope.slider.max).to.equal(70);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingBar.called.should.be.true; helper.slider.positionTrackingBar.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(50); expect(helper.scope.slider.max).to.equal(50);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() { it('should handle click on selbar and don\'t move range when already at 0 and moved left', function() {
...@@ -285,7 +285,7 @@ ...@@ -285,7 +285,7 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(60); expect(helper.scope.slider.max).to.equal(60);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and move range when near max and moved right', function() { it('should handle click on selbar and move range when near max and moved right', function() {
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
expect(helper.scope.slider.min).to.equal(50); expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and don\'t move range when already at max and moved right', function() { it('should handle click on selbar and don\'t move range when already at max and moved right', function() {
...@@ -309,7 +309,7 @@ ...@@ -309,7 +309,7 @@
expect(helper.scope.slider.min).to.equal(40); expect(helper.scope.slider.min).to.equal(40);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
it('should handle click on selbar and move range when floor is not 0 and handle is dragged below limit', function() { it('should handle click on selbar and move range when floor is not 0 and handle is dragged below limit', function() {
...@@ -324,7 +324,7 @@ ...@@ -324,7 +324,7 @@
expect(helper.scope.slider.min).to.equal(1000); expect(helper.scope.slider.min).to.equal(1000);
expect(helper.scope.slider.max).to.equal(1500); expect(helper.scope.slider.max).to.equal(1500);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
}); });
}); });
}()); }());
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
expect(helper.slider.maxH.hasClass('rz-active')).to.be.true; expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
}); });
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
expect(helper.slider.maxH.hasClass('rz-active')).to.be.true; expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
}); });
...@@ -208,7 +208,7 @@ ...@@ -208,7 +208,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset); var event = helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -227,7 +227,7 @@ ...@@ -227,7 +227,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset); var event = helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset); var event = helper.fireMousedown(helper.slider.selBar, offset);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset); var event = helper.fireMousedown(helper.slider.selBar, offset);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -321,7 +321,7 @@ ...@@ -321,7 +321,7 @@
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -340,7 +340,7 @@ ...@@ -340,7 +340,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -356,7 +356,7 @@ ...@@ -356,7 +356,7 @@
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
expect(helper.slider.maxH.hasClass('rz-active')).to.be.true; expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
}); });
...@@ -375,7 +375,7 @@ ...@@ -375,7 +375,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
expect(helper.slider.maxH.hasClass('rz-active')).to.be.true; expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
}); });
...@@ -481,7 +481,7 @@ ...@@ -481,7 +481,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset); var event = helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -500,7 +500,7 @@ ...@@ -500,7 +500,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset); var event = helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -519,7 +519,7 @@ ...@@ -519,7 +519,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset); var event = helper.fireMousedown(helper.slider.selBar, offset);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -538,7 +538,7 @@ ...@@ -538,7 +538,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset); var event = helper.fireMousedown(helper.slider.selBar, offset);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
expect(helper.slider.maxH.hasClass('rz-active')).to.be.true; expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
}); });
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
expect(helper.slider.maxH.hasClass('rz-active')).to.be.true; expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
}); });
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset, true); var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset, true); var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset, true); var event = helper.fireMousedown(helper.slider.selBar, offset, true);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset, true); var event = helper.fireMousedown(helper.slider.selBar, offset, true);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -285,7 +285,7 @@ ...@@ -285,7 +285,7 @@
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -304,7 +304,7 @@ ...@@ -304,7 +304,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -320,7 +320,7 @@ ...@@ -320,7 +320,7 @@
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
expect(helper.slider.maxH.hasClass('rz-active')).to.be.true; expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
}); });
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
expect(helper.slider.maxH.hasClass('rz-active')).to.be.true; expect(helper.slider.maxH.hasClass('rz-active')).to.be.true;
}); });
...@@ -407,7 +407,7 @@ ...@@ -407,7 +407,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset, true); var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -426,7 +426,7 @@ ...@@ -426,7 +426,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset, true); var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -445,7 +445,7 @@ ...@@ -445,7 +445,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset, true); var event = helper.fireMousedown(helper.slider.selBar, offset, true);
expect(helper.scope.slider.min).to.equal(expectedValue); expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
...@@ -464,7 +464,7 @@ ...@@ -464,7 +464,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset, true); var event = helper.fireMousedown(helper.slider.selBar, offset, true);
expect(helper.scope.slider.max).to.equal(expectedValue); expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderHigh'); expect(helper.slider.tracking).to.equal('highValue');
helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.maxH).should.be.true;
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
sinon.spy(helper.slider.scope, '$emit'); sinon.spy(helper.slider.scope, '$emit');
helper.fireMouseup(); helper.fireMouseup();
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
helper.slider.callOnEnd.called.should.be.true; helper.slider.callOnEnd.called.should.be.true;
helper.slider.scope.$emit.calledWith('slideEnded').should.be.true; helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
helper.fireMousedown(helper.slider.fullBar, offset); helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset); var event = helper.fireMousedown(helper.slider.selBar, offset);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
helper.fireMousedown(helper.slider.ticks, offset); helper.fireMousedown(helper.slider.ticks, offset);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -198,7 +198,7 @@ ...@@ -198,7 +198,7 @@
helper.fireMousedown(helper.slider.ticks, offset); helper.fireMousedown(helper.slider.ticks, offset);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -271,7 +271,7 @@ ...@@ -271,7 +271,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -312,7 +312,7 @@ ...@@ -312,7 +312,7 @@
sinon.spy(helper.slider.scope, '$emit'); sinon.spy(helper.slider.scope, '$emit');
helper.fireMouseup(); helper.fireMouseup();
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
helper.slider.callOnEnd.called.should.be.true; helper.slider.callOnEnd.called.should.be.true;
helper.slider.scope.$emit.calledWith('slideEnded').should.be.true; helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
...@@ -345,7 +345,7 @@ ...@@ -345,7 +345,7 @@
helper.fireMousedown(helper.slider.fullBar, offset); helper.fireMousedown(helper.slider.fullBar, offset);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -362,7 +362,7 @@ ...@@ -362,7 +362,7 @@
var event = helper.fireMousedown(helper.slider.selBar, offset); var event = helper.fireMousedown(helper.slider.selBar, offset);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -382,7 +382,7 @@ ...@@ -382,7 +382,7 @@
helper.fireMousedown(helper.slider.ticks, offset); helper.fireMousedown(helper.slider.ticks, offset);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -402,7 +402,7 @@ ...@@ -402,7 +402,7 @@
helper.fireMousedown(helper.slider.ticks, offset); helper.fireMousedown(helper.slider.ticks, offset);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
sinon.spy(helper.slider.scope, '$emit'); sinon.spy(helper.slider.scope, '$emit');
helper.fireMouseup(); helper.fireMouseup();
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
helper.slider.callOnEnd.called.should.be.true; helper.slider.callOnEnd.called.should.be.true;
helper.slider.scope.$emit.calledWith('slideEnded').should.be.true; helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset, true); var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
helper.fireMousedown(helper.slider.selBar, offset, true); helper.fireMousedown(helper.slider.selBar, offset, true);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
helper.fireMousedown(helper.slider.ticks, offset, true); helper.fireMousedown(helper.slider.ticks, offset, true);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
helper.fireMousedown(helper.slider.ticks, offset, true); helper.fireMousedown(helper.slider.ticks, offset, true);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true; helper.slider.focusElement.calledWith(helper.slider.minH).should.be.true;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -275,7 +275,7 @@ ...@@ -275,7 +275,7 @@
helper.slider.focusElement.called.should.be.false; helper.slider.focusElement.called.should.be.false;
event.preventDefault.called.should.be.true; event.preventDefault.called.should.be.true;
event.stopPropagation.called.should.be.true; event.stopPropagation.called.should.be.true;
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
}); });
...@@ -319,7 +319,7 @@ ...@@ -319,7 +319,7 @@
sinon.spy(helper.slider.scope, '$emit'); sinon.spy(helper.slider.scope, '$emit');
helper.fireMouseup(); helper.fireMouseup();
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
expect(helper.slider.minH.hasClass('rz-active')).to.be.true; expect(helper.slider.minH.hasClass('rz-active')).to.be.true;
helper.slider.callOnEnd.called.should.be.true; helper.slider.callOnEnd.called.should.be.true;
helper.slider.scope.$emit.calledWith('slideEnded').should.be.true; helper.slider.scope.$emit.calledWith('slideEnded').should.be.true;
...@@ -352,7 +352,7 @@ ...@@ -352,7 +352,7 @@
var event = helper.fireMousedown(helper.slider.fullBar, offset, true); var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -369,7 +369,7 @@ ...@@ -369,7 +369,7 @@
helper.fireMousedown(helper.slider.selBar, offset, true); helper.fireMousedown(helper.slider.selBar, offset, true);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -389,7 +389,7 @@ ...@@ -389,7 +389,7 @@
helper.fireMousedown(helper.slider.ticks, offset, true); helper.fireMousedown(helper.slider.ticks, offset, true);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
...@@ -409,7 +409,7 @@ ...@@ -409,7 +409,7 @@
helper.fireMousedown(helper.slider.ticks, offset, true); helper.fireMousedown(helper.slider.ticks, offset, true);
expect(helper.scope.slider.value).to.equal(expectedValue); expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('rzSliderModel'); expect(helper.slider.tracking).to.equal('lowValue');
helper.slider.positionTrackingHandle.called.should.be.true; helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnStart.called.should.be.true; helper.slider.callOnStart.called.should.be.true;
helper.slider.callOnChange.called.should.be.true; helper.slider.callOnChange.called.should.be.true;
......
...@@ -105,29 +105,28 @@ ...@@ -105,29 +105,28 @@
}); });
it('should set correct step/floor/ceil and translate function when stepsArray is used with values', function() { it('should set correct step/floor/ceil and translate function when stepsArray is used with values', function() {
helper.scope.slider.value = 'C';
helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']; helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
helper.scope.$digest(); helper.scope.$digest();
expect(helper.slider.options.step).to.equal(1); expect(helper.slider.options.step).to.equal(1);
expect(helper.slider.options.floor).to.equal(0); expect(helper.slider.options.floor).to.equal(0);
expect(helper.slider.options.ceil).to.equal(4); expect(helper.slider.options.ceil).to.equal(4);
expect(helper.slider.lowValue).to.equal(2);
expect(helper.slider.customTrFn(0)).to.equal('A');
expect(helper.slider.customTrFn(2)).to.equal('C');
}); });
it('should set correct step/floor/ceil and translate function when stepsArray is used with values and ticks', function() { it('should set correct step/floor/ceil when stepsArray is used with values and ticks', function() {
helper.scope.slider.value = 'C';
helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']; helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
helper.scope.slider.options.showTicks = true; helper.scope.slider.options.showTicks = true;
helper.scope.$digest(); helper.scope.$digest();
expect(helper.slider.options.step).to.equal(1); expect(helper.slider.options.step).to.equal(1);
expect(helper.slider.options.floor).to.equal(0); expect(helper.slider.options.floor).to.equal(0);
expect(helper.slider.options.ceil).to.equal(4); expect(helper.slider.options.ceil).to.equal(4);
expect(helper.slider.lowValue).to.equal(2);
expect(helper.slider.customTrFn(0)).to.equal('A');
expect(helper.slider.customTrFn(2)).to.equal('C');
}); });
it('should set correct step/floor/ceil and translate function when stepsArray is used with objects', function() { it('should set correct step/floor/ceil when stepsArray is used with objects', function() {
helper.scope.slider.value = 'D';
helper.scope.slider.options.stepsArray = [ helper.scope.slider.options.stepsArray = [
{value: 'A'}, {value: 'A'},
{value: 'B'}, {value: 'B'},
...@@ -139,13 +138,11 @@ ...@@ -139,13 +138,11 @@
expect(helper.slider.options.step).to.equal(1); expect(helper.slider.options.step).to.equal(1);
expect(helper.slider.options.floor).to.equal(0); expect(helper.slider.options.floor).to.equal(0);
expect(helper.slider.options.ceil).to.equal(4); expect(helper.slider.options.ceil).to.equal(4);
expect(helper.slider.lowValue).to.equal(3);
expect(helper.slider.customTrFn(0)).to.equal('A');
expect(helper.slider.customTrFn(2)).to.equal('C');
}); });
it('should set correct step/floor/ceil function when stepsArray is used with objects containing legends', function() {
it('should set correct step/floor/ceil and translate function when stepsArray is used with objects containing legends', function() { helper.scope.slider.value = 'D';
helper.scope.slider.options.stepsArray = [ helper.scope.slider.options.stepsArray = [
{value: 'A'}, {value: 'A'},
{value: 'B', legend: 'Legend B'}, {value: 'B', legend: 'Legend B'},
...@@ -159,9 +156,7 @@ ...@@ -159,9 +156,7 @@
expect(helper.slider.options.step).to.equal(1); expect(helper.slider.options.step).to.equal(1);
expect(helper.slider.options.floor).to.equal(0); expect(helper.slider.options.floor).to.equal(0);
expect(helper.slider.options.ceil).to.equal(4); expect(helper.slider.options.ceil).to.equal(4);
expect(helper.slider.lowValue).to.equal(3);
expect(helper.slider.customTrFn(0)).to.equal('A');
expect(helper.slider.customTrFn(2)).to.equal('C');
expect(helper.slider.getLegend(1)).to.equal('Legend B'); expect(helper.slider.getLegend(1)).to.equal('Legend B');
expect(helper.slider.getLegend(3)).to.equal('Legend D'); expect(helper.slider.getLegend(3)).to.equal('Legend D');
...@@ -610,6 +605,49 @@ ...@@ -610,6 +605,49 @@
expect(helper.scope.slider.min).to.equal(0); expect(helper.scope.slider.min).to.equal(0);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
}); });
it('should set correct step/floor/ceil and translate function when stepsArray is used with values', function() {
helper.scope.slider.min = 'B';
helper.scope.slider.max = 'D';
helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
helper.scope.$digest();
expect(helper.slider.options.step).to.equal(1);
expect(helper.slider.options.floor).to.equal(0);
expect(helper.slider.options.ceil).to.equal(4);
expect(helper.slider.lowValue).to.equal(1);
expect(helper.slider.highValue).to.equal(3);
});
it('should set correct step/floor/ceil when stepsArray is used with values and ticks', function() {
helper.scope.slider.min = 'B';
helper.scope.slider.max = 'D';
helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
helper.scope.slider.options.showTicks = true;
helper.scope.$digest();
expect(helper.slider.options.step).to.equal(1);
expect(helper.slider.options.floor).to.equal(0);
expect(helper.slider.options.ceil).to.equal(4);
expect(helper.slider.lowValue).to.equal(1);
expect(helper.slider.highValue).to.equal(3);
});
it('should set correct step/floor/ceil when stepsArray is used with objects', function() {
helper.scope.slider.min = 'B';
helper.scope.slider.max = 'D';
helper.scope.slider.options.stepsArray = [
{value: 'A'},
{value: 'B'},
{value: 'C'},
{value: 'D'},
{value: 'E'}
];
helper.scope.$digest();
expect(helper.slider.options.step).to.equal(1);
expect(helper.slider.options.floor).to.equal(0);
expect(helper.slider.options.ceil).to.equal(4);
expect(helper.slider.lowValue).to.equal(1);
expect(helper.slider.highValue).to.equal(3);
});
}); });
describe('options expression specific - ', function() { describe('options expression specific - ', function() {
...@@ -761,14 +799,13 @@ ...@@ -761,14 +799,13 @@
}); });
it('should set correct step/floor/ceil and translate function when stepsArray is used', function() { it('should set correct step/floor/ceil and translate function when stepsArray is used', function() {
helper.scope.slider.value = 'C';
helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E']; helper.scope.slider.options.stepsArray = ['A', 'B', 'C', 'D', 'E'];
helper.scope.$digest(); helper.scope.$digest();
expect(helper.slider.options.step).to.equal(1); expect(helper.slider.options.step).to.equal(1);
expect(helper.slider.options.floor).to.equal(0); expect(helper.slider.options.floor).to.equal(0);
expect(helper.slider.options.ceil).to.equal(4); expect(helper.slider.options.ceil).to.equal(4);
expect(helper.slider.lowValue).to.equal(2);
expect(helper.slider.customTrFn(0)).to.equal('A');
expect(helper.slider.customTrFn(2)).to.equal('C');
}); });
it('should sanitize rzSliderModel between floor and ceil', function() { it('should sanitize rzSliderModel between floor and ceil', function() {
...@@ -1117,7 +1154,7 @@ ...@@ -1117,7 +1154,7 @@
}); });
}); });
describe('range slider spcific - ', function() { describe('range slider specific - ', function() {
beforeEach(function() { beforeEach(function() {
var sliderConf = { var sliderConf = {
min: 10, min: 10,
......
...@@ -72,17 +72,17 @@ ...@@ -72,17 +72,17 @@
}); });
it('should round the model value to the step', function() { it('should round the model value to the step', function() {
helper.scope.slider.min = 13; helper.scope.slider.min = 23;
helper.scope.slider.max = 94; helper.scope.slider.max = 84;
helper.scope.$digest(); helper.scope.$digest();
expect(helper.scope.slider.min).to.equal(10); expect(helper.scope.slider.min).to.equal(20);
expect(helper.scope.slider.max).to.equal(90); expect(helper.scope.slider.max).to.equal(80);
helper.scope.slider.min = 15; helper.scope.slider.min = 25;
helper.scope.slider.max = 95; helper.scope.slider.max = 95;
helper.scope.$digest(); helper.scope.$digest();
$timeout.flush(); //to flush the throttle function $timeout.flush(); //to flush the throttle function
expect(helper.scope.slider.min).to.equal(20); expect(helper.scope.slider.min).to.equal(30);
expect(helper.scope.slider.max).to.equal(100); expect(helper.scope.slider.max).to.equal(100);
}); });
......
...@@ -80,6 +80,25 @@ ...@@ -80,6 +80,25 @@
expect(secondTick.text()).to.equal('10'); expect(secondTick.text()).to.equal('10');
}); });
it('should create the correct number of ticks when showTicksValues is true and used with stepsArray', function() {
var sliderConf = {
value: 'C',
options: {
stepsArray: ['A', 'B', 'C', 'D', 'E'],
showTicksValues: true
}
};
helper.createSlider(sliderConf);
expect(helper.element[0].querySelectorAll('.rz-tick')).to.have.length(5);
expect(helper.element[0].querySelectorAll('.rz-tick-value')).to.have.length(5);
var firstTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[0]);
expect(firstTick.text()).to.equal('A');
var secondTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[1]);
expect(secondTick.text()).to.equal('B');
var lasTick = angular.element(helper.element[0].querySelectorAll('.rz-tick-value')[4]);
expect(lasTick.text()).to.equal('E');
});
it('should create the correct number of ticks when showTicksValues is an integer', function() { it('should create the correct number of ticks when showTicksValues is an integer', function() {
var sliderConf = { var sliderConf = {
value: 50, value: 50,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment