Commit 7328dc61 authored by Valentin Hervieu's avatar Valentin Hervieu

Refactor logScale feature

parent 468ed3d7
# 5.7.0 (2016-10-16)
## Features
- Add a `logScale` option to display the slider using a logarithmic scale (#280).
- Add `customValueToPosition` and `customPositionToValue` options to display the slider using a custom scale (#280).
# 5.6.0 (2016-10-16)
## Features
- Add an `ticksArray` to display ticks at specific positions (#426).
- Add a `ticksArray` option to display ticks at specific positions (#426).
To enable this new feature, the way the ticks are rendered has been changed. Now each tick is positioned absolutely using a `transform: translate()` instruction.
......
......@@ -239,7 +239,10 @@ The default options are:
rightToLeft: false,
boundPointerLabels: true,
mergeRangeLabelsIfSame: false,
customTemplateScope: null
customTemplateScope: null,
logScale: false,
customValueToPosition: null,
customPositionToValue: null
}
````
......@@ -382,6 +385,14 @@ _Changing this value at runtime is not currently supported._
**customTemplateScope** - _Object (default to null)_: The properties defined in this object will be exposed in the slider template under `custom.X`.
**logScale** - _Boolean (defaults to false)_: Set to true to use a logarithmic scale to display the slider.
For custom scales:
**customValueToPosition** - _Function(val, minVal, maxVal): percent_: Function that returns the position on the slider for a given value. The position must be a percentage between 0 and 1.
**customPositionToValue** - _Function(percent, minVal, maxVal): value_: Function that returns the value for a given position on the slider. The position is a percentage between 0 and 1.
## Change default options
If you want the change the default options for all the sliders displayed in your application, you can set them using the `RzSliderOptions.options()` method:
```js
......
......@@ -13,6 +13,7 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
options: {
floor: 0,
ceil: 100,
rightToLeft: true,
step: 1
}
};
......@@ -143,7 +144,32 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
options: {
floor: 1,
ceil: 100,
logScale: true
logScale: true,
showTicks: true
}
};
//Slider config with custom scale
$scope.slider_custom_scale = {
value: 50,
options: {
floor: 0,
ceil: 100,
step: 10,
showTicksValues: true,
customValueToPosition: function(val, minVal, maxVal) {
val = Math.sqrt(val);
minVal = Math.sqrt(minVal);
maxVal = Math.sqrt(maxVal);
var range = maxVal - minVal;
return (val - minVal) / range;
},
customPositionToValue: function(percent, minVal, maxVal) {
minVal = Math.sqrt(minVal);
maxVal = Math.sqrt(maxVal);
var value = percent * (maxVal - minVal) + minVal;
return Math.pow(value, 2);
}
}
};
......@@ -242,8 +268,7 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
options: {
ceil: 10,
floor: 0,
ticksArray: [0, 1, 3, 8, 10],
showTicksValues: true
ticksArray: [0, 1, 3, 8, 10]
}
};
......@@ -332,7 +357,7 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
step: 50,
showSelectionBar: true,
showTicks: true,
getTickColor: function(value){
getTickColor: function(value) {
if (value < 300)
return 'red';
if (value < 600)
......@@ -574,8 +599,8 @@ app.directive('clickableLabel', function() {
scope: {label: '='},
replace: true,
template: "<button ng-click='onclick(label)' style='cursor: pointer;'>click me - {{label}}</button>",
link: function(scope, elem, attrs){
scope.onclick = function(label){
link: function(scope, elem, attrs) {
scope.onclick = function(label) {
alert("I'm " + label);
};
}
......
......@@ -127,6 +127,14 @@
></rzslider>
</article>
<article>
<h2>Slider with custom scale</h2>
<rzslider
rz-slider-model="slider_custom_scale.value"
rz-slider-options="slider_custom_scale.options"
></rzslider>
</article>
<article>
<h2>Right to left slider with custom floor/ceil/step</h2>
<rzslider
......
......@@ -62,7 +62,6 @@
getTickColor: null,
getPointerColor: null,
keyboardSupport: true,
logScale: false,
scale: 1,
enforceStep: true,
enforceRange: false,
......@@ -74,7 +73,10 @@
rightToLeft: false,
boundPointerLabels: true,
mergeRangeLabelsIfSame: false,
customTemplateScope: null
customTemplateScope: null,
logScale: false,
customValueToPosition: null,
customPositionToValue: null
};
var globalOptions = {};
......@@ -198,7 +200,7 @@
active: false,
value: 0,
difference: 0,
offset: 0,
position: 0,
lowLimit: 0,
highLimit: 0
};
......@@ -499,7 +501,7 @@
if (this.range)
this.syncHighValue();
this.setMinAndMax();
this.updateLowHandle(this.valueToOffset(this.lowValue));
this.updateLowHandle(this.valueToPosition(this.lowValue));
this.updateSelectionBar();
this.updateTicksScale();
this.updateAriaAttributes();
......@@ -515,7 +517,7 @@
this.syncLowValue();
this.syncHighValue();
this.setMinAndMax();
this.updateHighHandle(this.valueToOffset(this.highValue));
this.updateHighHandle(this.valueToPosition(this.highValue));
this.updateSelectionBar();
this.updateTicksScale();
this.updateCmbLabel();
......@@ -670,7 +672,7 @@
}, this);
// Initialize offset cache properties
// Initialize position cache properties
this.selBar.rzsp = 0;
this.minH.rzsp = 0;
this.maxH.rzsp = 0;
......@@ -764,14 +766,14 @@
* @returns {undefined}
*/
initHandles: function() {
this.updateLowHandle(this.valueToOffset(this.lowValue));
this.updateLowHandle(this.valueToPosition(this.lowValue));
/*
the order here is important since the selection bar should be
updated after the high handle but before the combined label
*/
if (this.range)
this.updateHighHandle(this.valueToOffset(this.highValue));
this.updateHighHandle(this.valueToPosition(this.highValue));
this.updateSelectionBar();
if (this.range)
this.updateCmbLabel();
......@@ -834,7 +836,7 @@
this.minValue = this.options.floor;
if (this.options.logScale && this.minValue === 0)
throw new Error("Can't use floor=0 with logarithmic scale");
throw Error("Can't use floor=0 with logarithmic scale");
if (this.options.enforceStep) {
this.lowValue = this.roundStep(this.lowValue);
......@@ -949,19 +951,19 @@
translate = this.options.vertical ? 'translateY' : 'translateX',
self = this;
if(this.options.rightToLeft)
if (this.options.rightToLeft)
ticksArray.reverse();
this.scope.ticks = ticksArray.map(function(value){
var offset = self.valueToOffset(value);
this.scope.ticks = ticksArray.map(function(value) {
var position = self.valueToPosition(value);
if (self.options.vertical)
offset = self.maxPos - offset;
position = self.maxPos - position;
var tick = {
selected: self.isTickSelected(value),
style: {
transform: translate + '(' + offset + 'px)'
transform: translate + '(' + position + 'px)'
}
};
if (tick.selected && self.options.getSelectionBarColor) {
......@@ -1050,13 +1052,13 @@
* Update slider handles and label positions
*
* @param {string} which
* @param {number} newOffset
* @param {number} newPos
*/
updateHandles: function(which, newOffset) {
updateHandles: function(which, newPos) {
if (which === 'lowValue')
this.updateLowHandle(newOffset);
this.updateLowHandle(newPos);
else
this.updateHighHandle(newOffset);
this.updateHighHandle(newPos);
this.updateSelectionBar();
this.updateTicksScale();
......@@ -1068,13 +1070,13 @@
* Helper function to work out the position for handle labels depending on RTL or not
*
* @param {string} labelName maxLab or minLab
* @param newOffset
* @param newPos
*
* @returns {number}
*/
getHandleLabelPos: function(labelName, newOffset) {
getHandleLabelPos: function(labelName, newPos) {
var labelRzsd = this[labelName].rzsd,
nearHandlePos = newOffset - labelRzsd / 2 + this.handleHalfDim,
nearHandlePos = newPos - labelRzsd / 2 + this.handleHalfDim,
endOfBarPos = this.barDimension - labelRzsd;
if (!this.options.boundPointerLabels)
......@@ -1090,13 +1092,13 @@
/**
* Update low slider handle position and label
*
* @param {number} newOffset
* @param {number} newPos
* @returns {undefined}
*/
updateLowHandle: function(newOffset) {
this.setPosition(this.minH, newOffset);
updateLowHandle: function(newPos) {
this.setPosition(this.minH, newPos);
this.translateFn(this.lowValue, this.minLab, 'model');
this.setPosition(this.minLab, this.getHandleLabelPos('minLab', newOffset));
this.setPosition(this.minLab, this.getHandleLabelPos('minLab', newPos));
if (this.options.getPointerColor) {
var pointercolor = this.getPointerColor('min');
......@@ -1113,13 +1115,13 @@
/**
* Update high slider handle position and label
*
* @param {number} newOffset
* @param {number} newPos
* @returns {undefined}
*/
updateHighHandle: function(newOffset) {
this.setPosition(this.maxH, newOffset);
updateHighHandle: function(newPos) {
this.setPosition(this.maxH, newPos);
this.translateFn(this.highValue, this.maxLab, 'high');
this.setPosition(this.maxLab, this.getHandleLabelPos('maxLab', newOffset));
this.setPosition(this.maxLab, this.getHandleLabelPos('maxLab', newPos));
if (this.options.getPointerColor) {
var pointercolor = this.getPointerColor('max');
......@@ -1217,7 +1219,7 @@
else {
if (this.options.showSelectionBarFromValue !== null) {
var center = this.options.showSelectionBarFromValue,
centerPosition = this.valueToOffset(center),
centerPosition = this.valueToPosition(center),
isModelGreaterThanCenter = this.options.rightToLeft ? this.lowValue <= center : this.lowValue > center;
if (isModelGreaterThanCenter) {
dimension = this.minH.rzsp - centerPosition;
......@@ -1377,7 +1379,7 @@
},
/**
* Set element left/top offset depending on whether slider is horizontal or vertical
* Set element left/top position depending on whether slider is horizontal or vertical
*
* @param {jqLite} elem The jqLite wrapped DOM element
* @param {number} pos
......@@ -1422,56 +1424,78 @@
},
/**
* Translate value to pixel offset
* Returns a value that is within slider range
*
* @param {number} val
* @returns {number}
*/
valueToOffset: function(val) {
var sanitizedValue = this.sanitizeValue(val),
minValue = this.options.logScale ? Math.log(this.minValue) : this.minValue,
maxValue = this.options.logScale ? Math.log(this.maxValue) : this.maxValue,
range = maxValue - minValue;
if (this.options.logScale)
sanitizedValue = Math.log(sanitizedValue);
if (this.options.rightToLeft)
return (maxValue - sanitizedValue) * this.maxPos / range || 0;
return (sanitizedValue - minValue) * this.maxPos / range || 0;
sanitizeValue: function(val) {
return Math.min(Math.max(val, this.minValue), this.maxValue);
},
/**
* Returns a value that is within slider range
* Translate value to pixel position
*
* @param {number} val
* @returns {number}
*/
sanitizeValue: function(val) {
return Math.min(Math.max(val, this.minValue), this.maxValue);
valueToPosition: function(val) {
var fn = this.linearValueToPosition;
if (this.options.customValueToPosition)
fn = this.options.customValueToPosition;
else if (this.options.logScale)
fn = this.logValueToPosition;
val = this.sanitizeValue(val);
var percent = fn(val, this.minValue, this.maxValue) || 0;
if(this.options.rightToLeft)
percent = 1 - percent;
return percent * this.maxPos;
},
linearValueToPosition: function(val, minVal, maxVal) {
var range = maxVal - minVal;
return (val - minVal) / range;
},
logValueToPosition: function(val, minVal, maxVal) {
val = Math.log(val);
minVal = Math.log(minVal);
maxVal = Math.log(maxVal);
var range = maxVal - minVal;
return (val - minVal) / range;
},
/**
* Translate offset to model value
* Translate position to model value
*
* @param {number} offset
* @param {number} position
* @returns {number}
*/
offsetToValue: function(offset) {
var minValue = this.options.logScale ? Math.log(this.minValue) : this.minValue,
maxValue = this.options.logScale ? Math.log(this.maxValue) : this.maxValue,
range = maxValue - minValue,
value = 0;
if (this.options.rightToLeft)
value = (1 - offset / this.maxPos) * range + minValue;
else
value = offset / this.maxPos * range + minValue;
positionToValue: function(position) {
var percent = position / this.maxPos;
if(this.options.rightToLeft)
percent = 1 - percent;
var fn = this.linearPositionToValue;
if (this.options.customPositionToValue)
fn = this.options.customPositionToValue;
else if (this.options.logScale)
fn = this.logPositionToValue;
return fn(percent, this.minValue, this.maxValue) || 0;
},
return this.options.logScale ? Math.exp(value) : value;
linearPositionToValue: function(percent, minVal, maxVal) {
return percent * (maxVal - minVal) + minVal;
},
// Events
logPositionToValue: function(percent, minVal, maxVal) {
minVal = Math.log(minVal);
maxVal = Math.log(maxVal);
var value = percent * (maxVal - minVal) + minVal;
return Math.exp(value);
},
// Events
/**
* Get the X-coordinate or Y-coordinate of an event
*
......@@ -1539,19 +1563,19 @@
if (!this.range) {
return this.minH;
}
var offset = this.getEventPosition(event),
distanceMin = Math.abs(offset - this.minH.rzsp),
distanceMax = Math.abs(offset - this.maxH.rzsp);
var position = this.getEventPosition(event),
distanceMin = Math.abs(position - this.minH.rzsp),
distanceMax = Math.abs(position - this.maxH.rzsp);
if (distanceMin < distanceMax)
return this.minH;
else if (distanceMin > distanceMax)
return this.maxH;
else if (!this.options.rightToLeft)
//if event is at the same distance from min/max then if it's at left of minH, we return minH else maxH
return offset < this.minH.rzsp ? this.minH : this.maxH;
return position < this.minH.rzsp ? this.minH : this.maxH;
else
//reverse in rtl
return offset > this.minH.rzsp ? this.minH : this.maxH;
return position > this.minH.rzsp ? this.minH : this.maxH;
},
/**
......@@ -1692,17 +1716,17 @@
* @returns {undefined}
*/
onMove: function(pointer, event, fromTick) {
var newOffset = this.getEventPosition(event),
var newPos = this.getEventPosition(event),
newValue,
ceilValue = this.options.rightToLeft ? this.minValue : this.maxValue,
flrValue = this.options.rightToLeft ? this.maxValue : this.minValue;
if (newOffset <= 0) {
if (newPos <= 0) {
newValue = flrValue;
} else if (newOffset >= this.maxPos) {
} else if (newPos >= this.maxPos) {
newValue = ceilValue;
} else {
newValue = this.offsetToValue(newOffset);
newValue = this.positionToValue(newPos);
if (fromTick && angular.isNumber(this.options.showTicks))
newValue = this.roundStep(newValue, this.options.showTicks);
else
......@@ -1864,13 +1888,13 @@
* @returns {undefined}
*/
onDragStart: function(pointer, ref, event) {
var offset = this.getEventPosition(event);
var position = this.getEventPosition(event);
this.dragging = {
active: true,
value: this.offsetToValue(offset),
value: this.positionToValue(position),
difference: this.highValue - this.lowValue,
lowLimit: this.options.rightToLeft ? this.minH.rzsp - offset : offset - this.minH.rzsp,
highLimit: this.options.rightToLeft ? offset - this.maxH.rzsp : this.maxH.rzsp - offset
lowLimit: this.options.rightToLeft ? this.minH.rzsp - position : position - this.minH.rzsp,
highLimit: this.options.rightToLeft ? position - this.maxH.rzsp : this.maxH.rzsp - position
};
this.onStart(pointer, ref, event);
......@@ -1879,16 +1903,16 @@
/**
* getValue helper function
*
* gets max or min value depending on whether the newOffset is outOfBounds above or below the bar and rightToLeft
* gets max or min value depending on whether the newPos is outOfBounds above or below the bar and rightToLeft
*
* @param {string} type 'max' || 'min' The value we are calculating
* @param {number} newOffset The new offset
* @param {boolean} outOfBounds Is the new offset above or below the max/min?
* @param {boolean} isAbove Is the new offset above the bar if out of bounds?
* @param {number} newPos The new position
* @param {boolean} outOfBounds Is the new position above or below the max/min?
* @param {boolean} isAbove Is the new position above the bar if out of bounds?
*
* @returns {number}
*/
getValue: function(type, newOffset, outOfBounds, isAbove) {
getValue: function(type, newPos, outOfBounds, isAbove) {
var isRTL = this.options.rightToLeft,
value = null;
......@@ -1900,7 +1924,7 @@
value = isRTL ? this.maxValue - this.dragging.difference : this.minValue;
}
} else {
value = isRTL ? this.offsetToValue(newOffset + this.dragging.lowLimit) : this.offsetToValue(newOffset - this.dragging.lowLimit)
value = isRTL ? this.positionToValue(newPos + this.dragging.lowLimit) : this.positionToValue(newPos - this.dragging.lowLimit)
}
} else {
if (outOfBounds) {
......@@ -1911,9 +1935,9 @@
}
} else {
if (isRTL) {
value = this.offsetToValue(newOffset + this.dragging.lowLimit) + this.dragging.difference
value = this.positionToValue(newPos + this.dragging.lowLimit) + this.dragging.difference
} else {
value = this.offsetToValue(newOffset - this.dragging.lowLimit) + this.dragging.difference;
value = this.positionToValue(newPos - this.dragging.lowLimit) + this.dragging.difference;
}
}
}
......@@ -1930,7 +1954,7 @@
* @returns {undefined}
*/
onDragMove: function(pointer, event) {
var newOffset = this.getEventPosition(event),
var newPos = this.getEventPosition(event),
newMinValue, newMaxValue,
ceilLimit, flrLimit,
isUnderFlrLimit, isOverCeilLimit,
......@@ -1947,28 +1971,28 @@
flrH = this.minH;
ceilH = this.maxH;
}
isUnderFlrLimit = newOffset <= flrLimit;
isOverCeilLimit = newOffset >= this.maxPos - ceilLimit;
isUnderFlrLimit = newPos <= flrLimit;
isOverCeilLimit = newPos >= this.maxPos - ceilLimit;
if (isUnderFlrLimit) {
if (flrH.rzsp === 0)
return;
newMinValue = this.getValue('min', newOffset, true, false);
newMaxValue = this.getValue('max', newOffset, true, false);
newMinValue = this.getValue('min', newPos, true, false);
newMaxValue = this.getValue('max', newPos, true, false);
} else if (isOverCeilLimit) {
if (ceilH.rzsp === this.maxPos)
return;
newMaxValue = this.getValue('max', newOffset, true, true);
newMinValue = this.getValue('min', newOffset, true, true);
newMaxValue = this.getValue('max', newPos, true, true);
newMinValue = this.getValue('min', newPos, true, true);
} else {
newMinValue = this.getValue('min', newOffset, false);
newMaxValue = this.getValue('max', newOffset, false);
newMinValue = this.getValue('min', newPos, false);
newMaxValue = this.getValue('max', newPos, false);
}
this.positionTrackingBar(newMinValue, newMaxValue);
},
/**
* Set the new value and offset for the entire bar
* Set the new value and position for the entire bar
*
* @param {number} newMinValue the new minimum value
* @param {number} newMaxValue the new maximum value
......@@ -1990,12 +2014,12 @@
if (this.range)
this.applyHighValue();
this.applyModel();
this.updateHandles('lowValue', this.valueToOffset(newMinValue));
this.updateHandles('highValue', this.valueToOffset(newMaxValue));
this.updateHandles('lowValue', this.valueToPosition(newMinValue));
this.updateHandles('highValue', this.valueToPosition(newMaxValue));
},
/**
* Set the new value and offset to the current tracking handle
* Set the new value and position to the current tracking handle
*
* @param {number} newValue new model value
*/
......@@ -2050,7 +2074,7 @@
this.applyLowValue();
else
this.applyHighValue();
this.updateHandles(this.tracking, this.valueToOffset(newValue));
this.updateHandles(this.tracking, this.valueToPosition(newValue));
this.updateAriaAttributes();
valueChanged = true;
}
......@@ -2097,13 +2121,13 @@
this.highValue = Math.min(newValue + range, this.maxValue);
newValue = this.highValue - range;
this.applyHighValue();
this.updateHandles('highValue', this.valueToOffset(this.highValue));
this.updateHandles('highValue', this.valueToPosition(this.highValue));
}
else {
this.lowValue = Math.max(newValue - range, this.minValue);
newValue = this.lowValue + range;
this.applyLowValue();
this.updateHandles('lowValue', this.valueToOffset(this.lowValue));
this.updateHandles('lowValue', this.valueToPosition(this.lowValue));
}
this.updateAriaAttributes();
}
......@@ -2218,7 +2242,7 @@
/**
* @name jqLite
*
* @property {number|undefined} rzsp rzslider label position offset
* @property {number|undefined} rzsp rzslider label position position
* @property {number|undefined} rzsd rzslider element dimension
* @property {string|undefined} rzsv rzslider label value/text
* @property {Function} css
......
/*! angularjs-slider - v5.6.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-10-16 */
!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,pushRange:!1,minLimit:null,maxLimit:null,id:null,translate:null,getLegend:null,stepsArray:null,bindIndexForStepsArray:!1,draggableRange:!1,draggableRangeOnly:!1,showSelectionBar:!1,showSelectionBarEnd:!1,showSelectionBarFromValue:null,hidePointerLabels:!1,hideLimitLabels:!1,autoHideLimitLabels:!0,readOnly:!1,disabled:!1,interval:350,showTicks:!1,showTicksValues:!1,ticksArray:null,ticksTooltip:null,ticksValuesTooltip:null,vertical:!1,getSelectionBarColor:null,getTickColor:null,getPointerColor:null,keyboardSupport:!0,logScale:!1,scale:1,enforceStep:!0,enforceRange:!1,noSwitching:!1,onlyBindHandles:!1,onStart:null,onChange:null,onEnd:null,rightToLeft:!1,boundPointerLabels:!0,mergeRangeLabelsIfSame:!1,customTemplateScope:null},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.cmbLabelShown=!1,this.currentFocusElement=null,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),e.currentFocusElement=null})},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.options.bindIndexForStepsArray?this.lowValue=this.scope.rzSliderModel:this.lowValue=this.findStepIndex(this.scope.rzSliderModel):this.lowValue=this.scope.rzSliderModel},syncHighValue:function(){this.options.stepsArray?this.options.bindIndexForStepsArray?this.highValue=this.scope.rzSliderHigh: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.options.bindIndexForStepsArray?this.scope.rzSliderModel=this.lowValue:this.scope.rzSliderModel=this.getStepValue(this.lowValue):this.scope.rzSliderModel=this.lowValue},applyHighValue:function(){this.options.stepsArray?this.options.bindIndexForStepsArray?this.scope.rzSliderHigh=this.highValue: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.options.ticksArray,this.scope.showTicks=this.options.showTicks,(a.isNumber(this.options.showTicks)||this.options.ticksArray)&&(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.getLegend=this.options.getLegend),this.options.vertical&&(this.positionProperty="bottom",this.dimensionProperty="height"),this.options.customTemplateScope&&(this.scope.custom=this.options.customTemplateScope)},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 this.options.bindIndexForStepsArray?this.getStepValue(a):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(),this.refocusPointerIfNeeded()},refocusPointerIfNeeded:function(){this.currentFocusElement&&(this.onPointerFocus(this.currentFocusElement.pointer,this.currentFocusElement.ref),this.focusElement(this.currentFocusElement.pointer))},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,g=b.hasClass("no-label-injection");d?(this.options.stepsArray&&!this.options.bindIndexForStepsArray&&(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),g||b.html(e),this.scope[c+"Label"]=e,f&&this.getDimension(b)},setMinAndMax:function(){if(this.step=+this.options.step,this.precision=+this.options.precision,this.minValue=this.options.floor,this.options.logScale&&0===this.minValue)throw new Error("Can't use floor=0 with logarithmic scale");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);if(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();var c=this;b(function(){c.updateTicksScale()})}},updateTicksScale:function(){if(this.options.showTicks){var a=this.options.ticksArray||this.getTicksArray(),b=this.options.vertical?"translateY":"translateX",c=this;this.options.rightToLeft&&a.reverse(),this.scope.ticks=a.map(function(a){var d=c.valueToOffset(a);c.options.vertical&&(d=c.maxPos-d);var e={selected:c.isTickSelected(a),style:{transform:b+"("+d+"px)"}};if(e.selected&&c.options.getSelectionBarColor&&(e.style["background-color"]=c.getSelectionBarColor()),!e.selected&&c.options.getTickColor&&(e.style["background-color"]=c.getTickColor(a)),c.options.ticksTooltip&&(e.tooltip=c.options.ticksTooltip(a),e.tooltipPlacement=c.options.vertical?"right":"top"),c.options.showTicksValues&&(e.value=c.getDisplayValue(a,"tick-value"),c.options.ticksValuesTooltip&&(e.valueTooltip=c.options.ticksValuesTooltip(a),e.valueTooltipPlacement=c.options.vertical?"right":"top")),c.getLegend){var f=c.getLegend(a,c.options.id);f&&(e.legend=f)}return e})}},getTicksArray:function(){var a=this.step,b=[];this.intermediateTicks&&(a=this.options.showTicks);for(var c=this.minValue;c<=this.maxValue;c+=a)b.push(c);return b},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.options.autoHideLimitLabels&&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.options.autoHideLimitLabels&&this.shFloorCeil()},shFloorCeil:function(){if(!this.options.hidePointerLabels){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.cmbLab.rzsp,k=this.cmbLab.rzsd,l=this.ceilLab.rzsp,m=this.handleHalfDim,n=c?f+g>=d-e-5:d+e+5>=f,o=c?l+m+10>=f-g:f+g>=l-m-10,p=c?l+10>=h-i:h+i>=l-10,q=c?j>=d-e-m:d+e+m>=j,r=c?l+10>=j-k:j+k>=l-10;if(n?(a=!0,this.hideEl(this.flrLab)):(a=!1,this.showEl(this.flrLab)),o?(b=!0,this.hideEl(this.ceilLab)):(b=!1,this.showEl(this.ceilLab)),this.range){var s=this.cmbLabelShown?r:p,t=this.cmbLabelShown?q:n;s?this.hideEl(this.ceilLab):b||this.showEl(this.ceilLab),t?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)},getTickColor:function(a){return this.options.getTickColor(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=this.options.mergeRangeLabelsIfSame&&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.cmbLabelShown=!0,this.hideEl(this.minLab),this.hideEl(this.maxLab),this.showEl(this.cmbLab)}else this.cmbLabelShown=!1,this.showEl(this.maxLab),this.showEl(this.minLab),this.hideEl(this.cmbLab)},getDisplayValue:function(a,b){return this.options.stepsArray&&!this.options.bindIndexForStepsArray&&(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({visibility:"hidden"})},showEl:function(a){return a.rzAlwaysHide?a:a.css({visibility:"visible"})},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){var b=this.sanitizeValue(a),c=this.options.logScale?Math.log(this.minValue):this.minValue,d=this.options.logScale?Math.log(this.maxValue):this.maxValue,e=d-c;return this.options.logScale&&(b=Math.log(b)),this.options.rightToLeft?(d-b)*this.maxPos/e||0:(b-c)*this.maxPos/e||0},sanitizeValue:function(a){return Math.min(Math.max(a,this.minValue),this.maxValue)},offsetToValue:function(a){var b=this.options.logScale?Math.log(this.minValue):this.minValue,c=this.options.logScale?Math.log(this.maxValue):this.maxValue,d=c-b,e=0;return e=this.options.rightToLeft?(1-a/this.maxPos)*d+b:a/this.maxPos*d+b,this.options.logScale?Math.exp(e):e},getEventXY:function(a){var b=this.options.vertical?"clientY":"clientX";return void 0!==a[b]?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"),this.currentFocusElement={pointer:b,ref:c}},onKeyUp:function(){this.firstKeyDown=!0,this.callOnEnd()},onPointerBlur:function(a){a.off("keydown"),a.off("keyup"),this.tracking="",a.removeClass("rz-active"),this.currentFocusElement=null},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){null!=this.options.minLimit&&a<this.options.minLimit&&(a=this.options.minLimit,b=a+this.dragging.difference),null!=this.options.maxLimit&&b>this.options.maxLimit&&(b=this.options.maxLimit,a=b-this.dragging.difference),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&&(this.options.pushRange?(a=this.applyPushRange(a),b=!0):(this.options.noSwitching&&("lowValue"===this.tracking&&a>this.highValue?a=this.applyMinMaxRange(this.highValue):"highValue"===this.tracking&&a<this.lowValue&&(a=this.applyMinMaxRange(this.lowValue))),a=this.applyMinMaxRange(a),"lowValue"===this.tracking&&a>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.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},applyPushRange:function(a){var b="lowValue"===this.tracking?this.highValue-a:a-this.lowValue,c=null!==this.options.minRange?this.options.minRange:this.options.step;return c>b&&("lowValue"===this.tracking?(this.highValue=Math.min(a+c,this.maxValue),a=this.highValue-c,this.applyHighValue(),this.updateHandles("highValue",this.valueToOffset(this.highValue))):(this.lowValue=Math.max(a-c,this.minValue),a=this.lowValue+c,this.applyLowValue(),this.updateHandles("lowValue",this.valueToOffset(this.lowValue))),this.updateAriaAttributes()),a},applyModel:function(){this.internalChange=!0,this.scope.$apply(),this.callOnChange(),this.internalChange=!1},callOnStart:function(){if(this.options.onStart){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onStart(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}},callOnChange:function(){if(this.options.onChange){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onChange(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}},callOnEnd:function(){if(this.options.onEnd){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onEnd(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}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.name});
\ No newline at end of file
!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,pushRange:!1,minLimit:null,maxLimit:null,id:null,translate:null,getLegend:null,stepsArray:null,bindIndexForStepsArray:!1,draggableRange:!1,draggableRangeOnly:!1,showSelectionBar:!1,showSelectionBarEnd:!1,showSelectionBarFromValue:null,hidePointerLabels:!1,hideLimitLabels:!1,autoHideLimitLabels:!0,readOnly:!1,disabled:!1,interval:350,showTicks:!1,showTicksValues:!1,ticksArray:null,ticksTooltip:null,ticksValuesTooltip:null,vertical:!1,getSelectionBarColor:null,getTickColor: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,mergeRangeLabelsIfSame:!1,customTemplateScope:null,logScale:!1,customValueToPosition:null,customPositionToValue:null},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,position: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.cmbLabelShown=!1,this.currentFocusElement=null,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),e.currentFocusElement=null})},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.options.bindIndexForStepsArray?this.lowValue=this.scope.rzSliderModel:this.lowValue=this.findStepIndex(this.scope.rzSliderModel):this.lowValue=this.scope.rzSliderModel},syncHighValue:function(){this.options.stepsArray?this.options.bindIndexForStepsArray?this.highValue=this.scope.rzSliderHigh: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.options.bindIndexForStepsArray?this.scope.rzSliderModel=this.lowValue:this.scope.rzSliderModel=this.getStepValue(this.lowValue):this.scope.rzSliderModel=this.lowValue},applyHighValue:function(){this.options.stepsArray?this.options.bindIndexForStepsArray?this.scope.rzSliderHigh=this.highValue: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.valueToPosition(this.lowValue)),this.updateSelectionBar(),this.updateTicksScale(),this.updateAriaAttributes(),this.range&&this.updateCmbLabel()},onHighHandleChange:function(){this.syncLowValue(),this.syncHighValue(),this.setMinAndMax(),this.updateHighHandle(this.valueToPosition(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.options.ticksArray,this.scope.showTicks=this.options.showTicks,(a.isNumber(this.options.showTicks)||this.options.ticksArray)&&(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.getLegend=this.options.getLegend),this.options.vertical&&(this.positionProperty="bottom",this.dimensionProperty="height"),this.options.customTemplateScope&&(this.scope.custom=this.options.customTemplateScope)},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 this.options.bindIndexForStepsArray?this.getStepValue(a):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(),this.refocusPointerIfNeeded()},refocusPointerIfNeeded:function(){this.currentFocusElement&&(this.onPointerFocus(this.currentFocusElement.pointer,this.currentFocusElement.ref),this.focusElement(this.currentFocusElement.pointer))},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.valueToPosition(this.lowValue)),this.range&&this.updateHighHandle(this.valueToPosition(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,g=b.hasClass("no-label-injection");d?(this.options.stepsArray&&!this.options.bindIndexForStepsArray&&(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),g||b.html(e),this.scope[c+"Label"]=e,f&&this.getDimension(b)},setMinAndMax:function(){if(this.step=+this.options.step,this.precision=+this.options.precision,this.minValue=this.options.floor,this.options.logScale&&0===this.minValue)throw Error("Can't use floor=0 with logarithmic scale");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);if(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();var c=this;b(function(){c.updateTicksScale()})}},updateTicksScale:function(){if(this.options.showTicks){var a=this.options.ticksArray||this.getTicksArray(),b=this.options.vertical?"translateY":"translateX",c=this;this.options.rightToLeft&&a.reverse(),this.scope.ticks=a.map(function(a){var d=c.valueToPosition(a);c.options.vertical&&(d=c.maxPos-d);var e={selected:c.isTickSelected(a),style:{transform:b+"("+d+"px)"}};if(e.selected&&c.options.getSelectionBarColor&&(e.style["background-color"]=c.getSelectionBarColor()),!e.selected&&c.options.getTickColor&&(e.style["background-color"]=c.getTickColor(a)),c.options.ticksTooltip&&(e.tooltip=c.options.ticksTooltip(a),e.tooltipPlacement=c.options.vertical?"right":"top"),c.options.showTicksValues&&(e.value=c.getDisplayValue(a,"tick-value"),c.options.ticksValuesTooltip&&(e.valueTooltip=c.options.ticksValuesTooltip(a),e.valueTooltipPlacement=c.options.vertical?"right":"top")),c.getLegend){var f=c.getLegend(a,c.options.id);f&&(e.legend=f)}return e})}},getTicksArray:function(){var a=this.step,b=[];this.intermediateTicks&&(a=this.options.showTicks);for(var c=this.minValue;c<=this.maxValue;c+=a)b.push(c);return b},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.options.autoHideLimitLabels&&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.options.autoHideLimitLabels&&this.shFloorCeil()},shFloorCeil:function(){if(!this.options.hidePointerLabels){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.cmbLab.rzsp,k=this.cmbLab.rzsd,l=this.ceilLab.rzsp,m=this.handleHalfDim,n=c?f+g>=d-e-5:d+e+5>=f,o=c?l+m+10>=f-g:f+g>=l-m-10,p=c?l+10>=h-i:h+i>=l-10,q=c?j>=d-e-m:d+e+m>=j,r=c?l+10>=j-k:j+k>=l-10;if(n?(a=!0,this.hideEl(this.flrLab)):(a=!1,this.showEl(this.flrLab)),o?(b=!0,this.hideEl(this.ceilLab)):(b=!1,this.showEl(this.ceilLab)),this.range){var s=this.cmbLabelShown?r:p,t=this.cmbLabelShown?q:n;s?this.hideEl(this.ceilLab):b||this.showEl(this.ceilLab),t?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.valueToPosition(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)},getTickColor:function(a){return this.options.getTickColor(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=this.options.mergeRangeLabelsIfSame&&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.cmbLabelShown=!0,this.hideEl(this.minLab),this.hideEl(this.maxLab),this.showEl(this.cmbLab)}else this.cmbLabelShown=!1,this.showEl(this.maxLab),this.showEl(this.minLab),this.hideEl(this.cmbLab)},getDisplayValue:function(a,b){return this.options.stepsArray&&!this.options.bindIndexForStepsArray&&(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({visibility:"hidden"})},showEl:function(a){return a.rzAlwaysHide?a:a.css({visibility:"visible"})},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},sanitizeValue:function(a){return Math.min(Math.max(a,this.minValue),this.maxValue)},valueToPosition:function(a){var b=this.linearValueToPosition;this.options.customValueToPosition?b=this.options.customValueToPosition:this.options.logScale&&(b=this.logValueToPosition),a=this.sanitizeValue(a);var c=b(a,this.minValue,this.maxValue)||0;return this.options.rightToLeft&&(c=1-c),c*this.maxPos},linearValueToPosition:function(a,b,c){var d=c-b;return(a-b)/d},logValueToPosition:function(a,b,c){a=Math.log(a),b=Math.log(b),c=Math.log(c);var d=c-b;return(a-b)/d},positionToValue:function(a){var b=a/this.maxPos;this.options.rightToLeft&&(b=1-b);var c=this.linearPositionToValue;return this.options.customPositionToValue?c=this.options.customPositionToValue:this.options.logScale&&(c=this.logPositionToValue),c(b,this.minValue,this.maxValue)||0},linearPositionToValue:function(a,b,c){return a*(c-b)+b},logPositionToValue:function(a,b,c){b=Math.log(b),c=Math.log(c);var d=a*(c-b)+b;return Math.exp(d)},getEventXY:function(a){var b=this.options.vertical?"clientY":"clientX";return void 0!==a[b]?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.positionToValue(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"),this.currentFocusElement={pointer:b,ref:c}},onKeyUp:function(){this.firstKeyDown=!0,this.callOnEnd()},onPointerBlur:function(a){a.off("keydown"),a.off("keyup"),this.tracking="",a.removeClass("rz-active"),this.currentFocusElement=null},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.positionToValue(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.positionToValue(b+this.dragging.lowLimit):this.positionToValue(b-this.dragging.lowLimit):c?d?e?this.minValue+this.dragging.difference:this.maxValue:e?this.maxValue:this.minValue+this.dragging.difference:e?this.positionToValue(b+this.dragging.lowLimit)+this.dragging.difference:this.positionToValue(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){null!=this.options.minLimit&&a<this.options.minLimit&&(a=this.options.minLimit,b=a+this.dragging.difference),null!=this.options.maxLimit&&b>this.options.maxLimit&&(b=this.options.maxLimit,a=b-this.dragging.difference),this.lowValue=a,this.highValue=b,this.applyLowValue(),this.range&&this.applyHighValue(),this.applyModel(),this.updateHandles("lowValue",this.valueToPosition(a)),this.updateHandles("highValue",this.valueToPosition(b))},positionTrackingHandle:function(a){var b=!1;a=this.applyMinMaxLimit(a),this.range&&(this.options.pushRange?(a=this.applyPushRange(a),b=!0):(this.options.noSwitching&&("lowValue"===this.tracking&&a>this.highValue?a=this.applyMinMaxRange(this.highValue):"highValue"===this.tracking&&a<this.lowValue&&(a=this.applyMinMaxRange(this.lowValue))),a=this.applyMinMaxRange(a),"lowValue"===this.tracking&&a>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.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.valueToPosition(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},applyPushRange:function(a){var b="lowValue"===this.tracking?this.highValue-a:a-this.lowValue,c=null!==this.options.minRange?this.options.minRange:this.options.step;return c>b&&("lowValue"===this.tracking?(this.highValue=Math.min(a+c,this.maxValue),a=this.highValue-c,this.applyHighValue(),this.updateHandles("highValue",this.valueToPosition(this.highValue))):(this.lowValue=Math.max(a-c,this.minValue),a=this.lowValue+c,this.applyLowValue(),this.updateHandles("lowValue",this.valueToPosition(this.lowValue))),this.updateAriaAttributes()),a},applyModel:function(){this.internalChange=!0,this.scope.$apply(),this.callOnChange(),this.internalChange=!1},callOnStart:function(){if(this.options.onStart){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onStart(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}},callOnChange:function(){if(this.options.onChange){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onChange(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}},callOnEnd:function(){if(this.options.onEnd){var a=this,b="lowValue"===this.tracking?"min":"max";this.scope.$evalAsync(function(){a.options.onEnd(a.options.id,a.scope.rzSliderModel,a.scope.rzSliderHigh,b)})}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.name});
\ No newline at end of file
......@@ -8,7 +8,11 @@ module.exports = function (config) {
// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['mocha', 'sinon', 'chai'],
reporters: ['dots', 'coverage'],
reporters: ['mocha', 'coverage'],
mochaReporter: {
showDiff: true
},
// list of files / patterns to load in the browser
files: [
......
......@@ -23,7 +23,7 @@
"devDependencies": {
"angular": "1.4.7",
"angular-mocks": "1.4.8",
"chai": "^3.4.1",
"chai": "^3.5.0",
"codecov.io": "^0.1.6",
"commitizen": "^2.4.6",
"cz-conventional-changelog": "^1.1.5",
......@@ -43,10 +43,11 @@
"karma-chrome-launcher": "^0.2.2",
"karma-coverage": "^0.5.3",
"karma-mocha": "^0.2.1",
"karma-mocha-reporter": "^2.2.0",
"karma-ng-html2js-preprocessor": "^0.2.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sinon": "^1.0.4",
"mocha": "^2.3.4",
"mocha": "^3.1.2",
"phantomjs": "^1.9.19",
"recess": "~1.1.9",
"sinon": "^1.17.2"
......
......@@ -66,7 +66,6 @@
getTickColor: null,
getPointerColor: null,
keyboardSupport: true,
logScale: false,
scale: 1,
enforceStep: true,
enforceRange: false,
......@@ -78,7 +77,10 @@
rightToLeft: false,
boundPointerLabels: true,
mergeRangeLabelsIfSame: false,
customTemplateScope: null
customTemplateScope: null,
logScale: false,
customValueToPosition: null,
customPositionToValue: null
};
var globalOptions = {};
......@@ -202,7 +204,7 @@
active: false,
value: 0,
difference: 0,
offset: 0,
position: 0,
lowLimit: 0,
highLimit: 0
};
......@@ -503,7 +505,7 @@
if (this.range)
this.syncHighValue();
this.setMinAndMax();
this.updateLowHandle(this.valueToOffset(this.lowValue));
this.updateLowHandle(this.valueToPosition(this.lowValue));
this.updateSelectionBar();
this.updateTicksScale();
this.updateAriaAttributes();
......@@ -519,7 +521,7 @@
this.syncLowValue();
this.syncHighValue();
this.setMinAndMax();
this.updateHighHandle(this.valueToOffset(this.highValue));
this.updateHighHandle(this.valueToPosition(this.highValue));
this.updateSelectionBar();
this.updateTicksScale();
this.updateCmbLabel();
......@@ -674,7 +676,7 @@
}, this);
// Initialize offset cache properties
// Initialize position cache properties
this.selBar.rzsp = 0;
this.minH.rzsp = 0;
this.maxH.rzsp = 0;
......@@ -768,14 +770,14 @@
* @returns {undefined}
*/
initHandles: function() {
this.updateLowHandle(this.valueToOffset(this.lowValue));
this.updateLowHandle(this.valueToPosition(this.lowValue));
/*
the order here is important since the selection bar should be
updated after the high handle but before the combined label
*/
if (this.range)
this.updateHighHandle(this.valueToOffset(this.highValue));
this.updateHighHandle(this.valueToPosition(this.highValue));
this.updateSelectionBar();
if (this.range)
this.updateCmbLabel();
......@@ -838,7 +840,7 @@
this.minValue = this.options.floor;
if (this.options.logScale && this.minValue === 0)
throw new Error("Can't use floor=0 with logarithmic scale");
throw Error("Can't use floor=0 with logarithmic scale");
if (this.options.enforceStep) {
this.lowValue = this.roundStep(this.lowValue);
......@@ -953,19 +955,19 @@
translate = this.options.vertical ? 'translateY' : 'translateX',
self = this;
if(this.options.rightToLeft)
if (this.options.rightToLeft)
ticksArray.reverse();
this.scope.ticks = ticksArray.map(function(value){
var offset = self.valueToOffset(value);
this.scope.ticks = ticksArray.map(function(value) {
var position = self.valueToPosition(value);
if (self.options.vertical)
offset = self.maxPos - offset;
position = self.maxPos - position;
var tick = {
selected: self.isTickSelected(value),
style: {
transform: translate + '(' + offset + 'px)'
transform: translate + '(' + position + 'px)'
}
};
if (tick.selected && self.options.getSelectionBarColor) {
......@@ -1054,13 +1056,13 @@
* Update slider handles and label positions
*
* @param {string} which
* @param {number} newOffset
* @param {number} newPos
*/
updateHandles: function(which, newOffset) {
updateHandles: function(which, newPos) {
if (which === 'lowValue')
this.updateLowHandle(newOffset);
this.updateLowHandle(newPos);
else
this.updateHighHandle(newOffset);
this.updateHighHandle(newPos);
this.updateSelectionBar();
this.updateTicksScale();
......@@ -1072,13 +1074,13 @@
* Helper function to work out the position for handle labels depending on RTL or not
*
* @param {string} labelName maxLab or minLab
* @param newOffset
* @param newPos
*
* @returns {number}
*/
getHandleLabelPos: function(labelName, newOffset) {
getHandleLabelPos: function(labelName, newPos) {
var labelRzsd = this[labelName].rzsd,
nearHandlePos = newOffset - labelRzsd / 2 + this.handleHalfDim,
nearHandlePos = newPos - labelRzsd / 2 + this.handleHalfDim,
endOfBarPos = this.barDimension - labelRzsd;
if (!this.options.boundPointerLabels)
......@@ -1094,13 +1096,13 @@
/**
* Update low slider handle position and label
*
* @param {number} newOffset
* @param {number} newPos
* @returns {undefined}
*/
updateLowHandle: function(newOffset) {
this.setPosition(this.minH, newOffset);
updateLowHandle: function(newPos) {
this.setPosition(this.minH, newPos);
this.translateFn(this.lowValue, this.minLab, 'model');
this.setPosition(this.minLab, this.getHandleLabelPos('minLab', newOffset));
this.setPosition(this.minLab, this.getHandleLabelPos('minLab', newPos));
if (this.options.getPointerColor) {
var pointercolor = this.getPointerColor('min');
......@@ -1117,13 +1119,13 @@
/**
* Update high slider handle position and label
*
* @param {number} newOffset
* @param {number} newPos
* @returns {undefined}
*/
updateHighHandle: function(newOffset) {
this.setPosition(this.maxH, newOffset);
updateHighHandle: function(newPos) {
this.setPosition(this.maxH, newPos);
this.translateFn(this.highValue, this.maxLab, 'high');
this.setPosition(this.maxLab, this.getHandleLabelPos('maxLab', newOffset));
this.setPosition(this.maxLab, this.getHandleLabelPos('maxLab', newPos));
if (this.options.getPointerColor) {
var pointercolor = this.getPointerColor('max');
......@@ -1221,7 +1223,7 @@
else {
if (this.options.showSelectionBarFromValue !== null) {
var center = this.options.showSelectionBarFromValue,
centerPosition = this.valueToOffset(center),
centerPosition = this.valueToPosition(center),
isModelGreaterThanCenter = this.options.rightToLeft ? this.lowValue <= center : this.lowValue > center;
if (isModelGreaterThanCenter) {
dimension = this.minH.rzsp - centerPosition;
......@@ -1381,7 +1383,7 @@
},
/**
* Set element left/top offset depending on whether slider is horizontal or vertical
* Set element left/top position depending on whether slider is horizontal or vertical
*
* @param {jqLite} elem The jqLite wrapped DOM element
* @param {number} pos
......@@ -1426,56 +1428,78 @@
},
/**
* Translate value to pixel offset
* Returns a value that is within slider range
*
* @param {number} val
* @returns {number}
*/
valueToOffset: function(val) {
var sanitizedValue = this.sanitizeValue(val),
minValue = this.options.logScale ? Math.log(this.minValue) : this.minValue,
maxValue = this.options.logScale ? Math.log(this.maxValue) : this.maxValue,
range = maxValue - minValue;
if (this.options.logScale)
sanitizedValue = Math.log(sanitizedValue);
if (this.options.rightToLeft)
return (maxValue - sanitizedValue) * this.maxPos / range || 0;
return (sanitizedValue - minValue) * this.maxPos / range || 0;
sanitizeValue: function(val) {
return Math.min(Math.max(val, this.minValue), this.maxValue);
},
/**
* Returns a value that is within slider range
* Translate value to pixel position
*
* @param {number} val
* @returns {number}
*/
sanitizeValue: function(val) {
return Math.min(Math.max(val, this.minValue), this.maxValue);
valueToPosition: function(val) {
var fn = this.linearValueToPosition;
if (this.options.customValueToPosition)
fn = this.options.customValueToPosition;
else if (this.options.logScale)
fn = this.logValueToPosition;
val = this.sanitizeValue(val);
var percent = fn(val, this.minValue, this.maxValue) || 0;
if(this.options.rightToLeft)
percent = 1 - percent;
return percent * this.maxPos;
},
linearValueToPosition: function(val, minVal, maxVal) {
var range = maxVal - minVal;
return (val - minVal) / range;
},
logValueToPosition: function(val, minVal, maxVal) {
val = Math.log(val);
minVal = Math.log(minVal);
maxVal = Math.log(maxVal);
var range = maxVal - minVal;
return (val - minVal) / range;
},
/**
* Translate offset to model value
* Translate position to model value
*
* @param {number} offset
* @param {number} position
* @returns {number}
*/
offsetToValue: function(offset) {
var minValue = this.options.logScale ? Math.log(this.minValue) : this.minValue,
maxValue = this.options.logScale ? Math.log(this.maxValue) : this.maxValue,
range = maxValue - minValue,
value = 0;
if (this.options.rightToLeft)
value = (1 - offset / this.maxPos) * range + minValue;
else
value = offset / this.maxPos * range + minValue;
positionToValue: function(position) {
var percent = position / this.maxPos;
if(this.options.rightToLeft)
percent = 1 - percent;
var fn = this.linearPositionToValue;
if (this.options.customPositionToValue)
fn = this.options.customPositionToValue;
else if (this.options.logScale)
fn = this.logPositionToValue;
return fn(percent, this.minValue, this.maxValue) || 0;
},
return this.options.logScale ? Math.exp(value) : value;
linearPositionToValue: function(percent, minVal, maxVal) {
return percent * (maxVal - minVal) + minVal;
},
// Events
logPositionToValue: function(percent, minVal, maxVal) {
minVal = Math.log(minVal);
maxVal = Math.log(maxVal);
var value = percent * (maxVal - minVal) + minVal;
return Math.exp(value);
},
// Events
/**
* Get the X-coordinate or Y-coordinate of an event
*
......@@ -1543,19 +1567,19 @@
if (!this.range) {
return this.minH;
}
var offset = this.getEventPosition(event),
distanceMin = Math.abs(offset - this.minH.rzsp),
distanceMax = Math.abs(offset - this.maxH.rzsp);
var position = this.getEventPosition(event),
distanceMin = Math.abs(position - this.minH.rzsp),
distanceMax = Math.abs(position - this.maxH.rzsp);
if (distanceMin < distanceMax)
return this.minH;
else if (distanceMin > distanceMax)
return this.maxH;
else if (!this.options.rightToLeft)
//if event is at the same distance from min/max then if it's at left of minH, we return minH else maxH
return offset < this.minH.rzsp ? this.minH : this.maxH;
return position < this.minH.rzsp ? this.minH : this.maxH;
else
//reverse in rtl
return offset > this.minH.rzsp ? this.minH : this.maxH;
return position > this.minH.rzsp ? this.minH : this.maxH;
},
/**
......@@ -1696,17 +1720,17 @@
* @returns {undefined}
*/
onMove: function(pointer, event, fromTick) {
var newOffset = this.getEventPosition(event),
var newPos = this.getEventPosition(event),
newValue,
ceilValue = this.options.rightToLeft ? this.minValue : this.maxValue,
flrValue = this.options.rightToLeft ? this.maxValue : this.minValue;
if (newOffset <= 0) {
if (newPos <= 0) {
newValue = flrValue;
} else if (newOffset >= this.maxPos) {
} else if (newPos >= this.maxPos) {
newValue = ceilValue;
} else {
newValue = this.offsetToValue(newOffset);
newValue = this.positionToValue(newPos);
if (fromTick && angular.isNumber(this.options.showTicks))
newValue = this.roundStep(newValue, this.options.showTicks);
else
......@@ -1868,13 +1892,13 @@
* @returns {undefined}
*/
onDragStart: function(pointer, ref, event) {
var offset = this.getEventPosition(event);
var position = this.getEventPosition(event);
this.dragging = {
active: true,
value: this.offsetToValue(offset),
value: this.positionToValue(position),
difference: this.highValue - this.lowValue,
lowLimit: this.options.rightToLeft ? this.minH.rzsp - offset : offset - this.minH.rzsp,
highLimit: this.options.rightToLeft ? offset - this.maxH.rzsp : this.maxH.rzsp - offset
lowLimit: this.options.rightToLeft ? this.minH.rzsp - position : position - this.minH.rzsp,
highLimit: this.options.rightToLeft ? position - this.maxH.rzsp : this.maxH.rzsp - position
};
this.onStart(pointer, ref, event);
......@@ -1883,16 +1907,16 @@
/**
* getValue helper function
*
* gets max or min value depending on whether the newOffset is outOfBounds above or below the bar and rightToLeft
* gets max or min value depending on whether the newPos is outOfBounds above or below the bar and rightToLeft
*
* @param {string} type 'max' || 'min' The value we are calculating
* @param {number} newOffset The new offset
* @param {boolean} outOfBounds Is the new offset above or below the max/min?
* @param {boolean} isAbove Is the new offset above the bar if out of bounds?
* @param {number} newPos The new position
* @param {boolean} outOfBounds Is the new position above or below the max/min?
* @param {boolean} isAbove Is the new position above the bar if out of bounds?
*
* @returns {number}
*/
getValue: function(type, newOffset, outOfBounds, isAbove) {
getValue: function(type, newPos, outOfBounds, isAbove) {
var isRTL = this.options.rightToLeft,
value = null;
......@@ -1904,7 +1928,7 @@
value = isRTL ? this.maxValue - this.dragging.difference : this.minValue;
}
} else {
value = isRTL ? this.offsetToValue(newOffset + this.dragging.lowLimit) : this.offsetToValue(newOffset - this.dragging.lowLimit)
value = isRTL ? this.positionToValue(newPos + this.dragging.lowLimit) : this.positionToValue(newPos - this.dragging.lowLimit)
}
} else {
if (outOfBounds) {
......@@ -1915,9 +1939,9 @@
}
} else {
if (isRTL) {
value = this.offsetToValue(newOffset + this.dragging.lowLimit) + this.dragging.difference
value = this.positionToValue(newPos + this.dragging.lowLimit) + this.dragging.difference
} else {
value = this.offsetToValue(newOffset - this.dragging.lowLimit) + this.dragging.difference;
value = this.positionToValue(newPos - this.dragging.lowLimit) + this.dragging.difference;
}
}
}
......@@ -1934,7 +1958,7 @@
* @returns {undefined}
*/
onDragMove: function(pointer, event) {
var newOffset = this.getEventPosition(event),
var newPos = this.getEventPosition(event),
newMinValue, newMaxValue,
ceilLimit, flrLimit,
isUnderFlrLimit, isOverCeilLimit,
......@@ -1951,28 +1975,28 @@
flrH = this.minH;
ceilH = this.maxH;
}
isUnderFlrLimit = newOffset <= flrLimit;
isOverCeilLimit = newOffset >= this.maxPos - ceilLimit;
isUnderFlrLimit = newPos <= flrLimit;
isOverCeilLimit = newPos >= this.maxPos - ceilLimit;
if (isUnderFlrLimit) {
if (flrH.rzsp === 0)
return;
newMinValue = this.getValue('min', newOffset, true, false);
newMaxValue = this.getValue('max', newOffset, true, false);
newMinValue = this.getValue('min', newPos, true, false);
newMaxValue = this.getValue('max', newPos, true, false);
} else if (isOverCeilLimit) {
if (ceilH.rzsp === this.maxPos)
return;
newMaxValue = this.getValue('max', newOffset, true, true);
newMinValue = this.getValue('min', newOffset, true, true);
newMaxValue = this.getValue('max', newPos, true, true);
newMinValue = this.getValue('min', newPos, true, true);
} else {
newMinValue = this.getValue('min', newOffset, false);
newMaxValue = this.getValue('max', newOffset, false);
newMinValue = this.getValue('min', newPos, false);
newMaxValue = this.getValue('max', newPos, false);
}
this.positionTrackingBar(newMinValue, newMaxValue);
},
/**
* Set the new value and offset for the entire bar
* Set the new value and position for the entire bar
*
* @param {number} newMinValue the new minimum value
* @param {number} newMaxValue the new maximum value
......@@ -1994,12 +2018,12 @@
if (this.range)
this.applyHighValue();
this.applyModel();
this.updateHandles('lowValue', this.valueToOffset(newMinValue));
this.updateHandles('highValue', this.valueToOffset(newMaxValue));
this.updateHandles('lowValue', this.valueToPosition(newMinValue));
this.updateHandles('highValue', this.valueToPosition(newMaxValue));
},
/**
* Set the new value and offset to the current tracking handle
* Set the new value and position to the current tracking handle
*
* @param {number} newValue new model value
*/
......@@ -2054,7 +2078,7 @@
this.applyLowValue();
else
this.applyHighValue();
this.updateHandles(this.tracking, this.valueToOffset(newValue));
this.updateHandles(this.tracking, this.valueToPosition(newValue));
this.updateAriaAttributes();
valueChanged = true;
}
......@@ -2101,13 +2125,13 @@
this.highValue = Math.min(newValue + range, this.maxValue);
newValue = this.highValue - range;
this.applyHighValue();
this.updateHandles('highValue', this.valueToOffset(this.highValue));
this.updateHandles('highValue', this.valueToPosition(this.highValue));
}
else {
this.lowValue = Math.max(newValue - range, this.minValue);
newValue = this.lowValue + range;
this.applyLowValue();
this.updateHandles('lowValue', this.valueToOffset(this.lowValue));
this.updateHandles('lowValue', this.valueToPosition(this.lowValue));
}
this.updateAriaAttributes();
}
......@@ -2222,7 +2246,7 @@
/**
* @name jqLite
*
* @property {number|undefined} rzsp rzslider label position offset
* @property {number|undefined} rzsp rzslider label position position
* @property {number|undefined} rzsd rzslider element dimension
* @property {string|undefined} rzsv rzslider label value/text
* @property {Function} css
......
......@@ -199,23 +199,23 @@
expect(el.css('height')).to.equal('12px');
});
it('should have a valid valueToOffset for positive sliders', function() {
it('should have a valid valueToPosition for positive sliders', function() {
helper.slider.maxPos = 1000;
expect(helper.slider.valueToOffset(0)).to.equal(0);
expect(helper.slider.valueToOffset(50)).to.equal(500);
expect(helper.slider.valueToOffset(100)).to.equal(1000);
expect(helper.slider.valueToPosition(0)).to.equal(0);
expect(helper.slider.valueToPosition(50)).to.equal(500);
expect(helper.slider.valueToPosition(100)).to.equal(1000);
});
it('should have a valid valueToOffset for negative sliders', function() {
it('should have a valid valueToPosition for negative sliders', function() {
helper.scope.slider.options.floor = -100;
helper.scope.slider.options.ceil = 0;
helper.scope.slider.value = -50;
helper.scope.$digest();
helper.slider.maxPos = 1000;
expect(helper.slider.valueToOffset(0)).to.equal(1000);
expect(helper.slider.valueToOffset(-50)).to.equal(500);
expect(helper.slider.valueToOffset(-100)).to.equal(0);
expect(helper.slider.valueToPosition(0)).to.equal(1000);
expect(helper.slider.valueToPosition(-50)).to.equal(500);
expect(helper.slider.valueToPosition(-100)).to.equal(0);
});
it('should have a valid sanitizeValue', function() {
......@@ -228,23 +228,23 @@
expect(helper.slider.sanitizeValue(110)).to.equal(100);
});
it('should have a valid offsetToValue for positive sliders', function() {
it('should have a valid positionToValue for positive sliders', function() {
helper.slider.maxPos = 1000;
expect(helper.slider.offsetToValue(0)).to.equal(0);
expect(helper.slider.offsetToValue(1000)).to.equal(100);
expect(helper.slider.offsetToValue(500)).to.equal(50);
expect(helper.slider.positionToValue(0)).to.equal(0);
expect(helper.slider.positionToValue(1000)).to.equal(100);
expect(helper.slider.positionToValue(500)).to.equal(50);
});
it('should have a valid offsetToValue for for negative sliders', function() {
it('should have a valid positionToValue for for negative sliders', function() {
helper.scope.slider.options.floor = -100;
helper.scope.slider.options.ceil = 0;
helper.scope.slider.value = -50;
helper.scope.$digest();
helper.slider.maxPos = 1000;
expect(helper.slider.offsetToValue(0)).to.equal(-100);
expect(helper.slider.offsetToValue(1000)).to.equal(0);
expect(helper.slider.offsetToValue(500)).to.equal(-50);
expect(helper.slider.positionToValue(0)).to.equal(-100);
expect(helper.slider.positionToValue(1000)).to.equal(0);
expect(helper.slider.positionToValue(500)).to.equal(-50);
});
it('should have a valid getEventXY for horizontal sliders on desktop browsers', function() {
......@@ -668,42 +668,42 @@
helper.createSlider(sliderConf);
});
it('should have a valid valueToOffset for positive sliders', function() {
it('should have a valid valueToPosition for positive sliders', function() {
helper.slider.maxPos = 1000;
expect(helper.slider.valueToOffset(0)).to.equal(1000);
expect(helper.slider.valueToOffset(50)).to.equal(500);
expect(helper.slider.valueToOffset(100)).to.equal(0);
expect(helper.slider.valueToPosition(0)).to.equal(1000);
expect(helper.slider.valueToPosition(50)).to.equal(500);
expect(helper.slider.valueToPosition(100)).to.equal(0);
});
it('should have a valid valueToOffset for negative sliders', function() {
it('should have a valid valueToPosition for negative sliders', function() {
helper.scope.slider.options.floor = -100;
helper.scope.slider.options.ceil = 0;
helper.scope.slider.value = -50;
helper.scope.$digest();
helper.slider.maxPos = 1000;
expect(helper.slider.valueToOffset(0)).to.equal(0);
expect(helper.slider.valueToOffset(-50)).to.equal(500);
expect(helper.slider.valueToOffset(-100)).to.equal(1000);
expect(helper.slider.valueToPosition(0)).to.equal(0);
expect(helper.slider.valueToPosition(-50)).to.equal(500);
expect(helper.slider.valueToPosition(-100)).to.equal(1000);
});
it('should have a valid offsetToValue for positive sliders', function() {
it('should have a valid positionToValue for positive sliders', function() {
helper.slider.maxPos = 1000;
expect(helper.slider.offsetToValue(0)).to.equal(100);
expect(helper.slider.offsetToValue(1000)).to.equal(0);
expect(helper.slider.offsetToValue(500)).to.equal(50);
expect(helper.slider.positionToValue(0)).to.equal(100);
expect(helper.slider.positionToValue(1000)).to.equal(0);
expect(helper.slider.positionToValue(500)).to.equal(50);
});
it('should have a valid offsetToValue for for negative sliders', function() {
it('should have a valid positionToValue for for negative sliders', function() {
helper.scope.slider.options.floor = -100;
helper.scope.slider.options.ceil = 0;
helper.scope.slider.value = -50;
helper.scope.$digest();
helper.slider.maxPos = 1000;
expect(helper.slider.offsetToValue(0)).to.equal(0);
expect(helper.slider.offsetToValue(1000)).to.equal(-100);
expect(helper.slider.offsetToValue(500)).to.equal(-50);
expect(helper.slider.positionToValue(0)).to.equal(0);
expect(helper.slider.positionToValue(1000)).to.equal(-100);
expect(helper.slider.positionToValue(500)).to.equal(-50);
});
});
});
......
......@@ -123,7 +123,7 @@
};
h.getMousePosition = function(value) {
return h.slider.valueToOffset(value) + h.slider.handleHalfDim + h.slider.sliderElem.rzsp;
return h.slider.valueToPosition(value) + h.slider.handleHalfDim + h.slider.sliderElem.rzsp;
};
h.moveMouseToValue = function(value) {
......
......@@ -84,9 +84,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -103,9 +103,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......@@ -124,8 +124,8 @@
helper.fireMousedown(helper.slider.selBar, 0);
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
helper.fireMousemove(offset);
position = helper.slider.valueToPosition(moveValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
......@@ -187,14 +187,14 @@
it('should a working positionTrackingBar', function() {
var newMin = 50,
newMax = 90,
minOffset = helper.slider.valueToOffset(newMin),
maxOffset = helper.slider.valueToOffset(newMax);
helper.slider.positionTrackingBar(newMin, newMax, minOffset, maxOffset);
minposition = helper.slider.valueToPosition(newMin),
maxposition = helper.slider.valueToPosition(newMax);
helper.slider.positionTrackingBar(newMin, newMax, minposition, maxposition);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(90);
expect(helper.slider.minH.css('left')).to.equal(minOffset + 'px');
expect(helper.slider.maxH.css('left')).to.equal(maxOffset + 'px');
expect(helper.slider.minH.css('left')).to.equal(minposition + 'px');
expect(helper.slider.maxH.css('left')).to.equal(maxposition + 'px');
});
it('should respect minLimit option', function() {
......@@ -262,8 +262,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.minH, 0);
var expectedValue = 50,
offset = helper.getMousePosition(expectedValue);
helper.fireMousemove(offset);
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -274,8 +274,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.maxH, 0);
var expectedValue = 50,
offset = helper.getMousePosition(expectedValue);
helper.fireMousemove(offset);
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.max).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -284,8 +284,8 @@
it('should handle click and drag on minH and switch min/max if needed', function() {
var event = helper.fireMousedown(helper.slider.minH, 0);
var expectedValue = 80,
offset = helper.getMousePosition(expectedValue);
helper.fireMousemove(offset);
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(60);
expect(helper.scope.slider.max).to.equal(80);
......@@ -294,8 +294,8 @@
it('should handle click and drag on maxH and switch min/max if needed', function() {
var event = helper.fireMousedown(helper.slider.maxH, 0);
var expectedValue = 20,
offset = helper.getMousePosition(expectedValue);
helper.fireMousemove(offset);
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(20);
expect(helper.scope.slider.max).to.equal(40);
......@@ -308,9 +308,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -327,9 +327,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......@@ -348,8 +348,8 @@
helper.fireMousedown(helper.slider.selBar, 0);
var moveValue = 10,
offset = helper.slider.maxPos - helper.slider.valueToOffset(moveValue);
helper.fireMousemove(offset);
position = helper.slider.maxPos - helper.slider.valueToPosition(moveValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(30);
expect(helper.scope.slider.max).to.equal(50);
......@@ -411,14 +411,14 @@
it('should a working positionTrackingBar', function() {
var newMin = 50,
newMax = 90,
minOffset = helper.slider.valueToOffset(newMin),
maxOffset = helper.slider.valueToOffset(newMax);
helper.slider.positionTrackingBar(newMin, newMax, minOffset, maxOffset);
minposition = helper.slider.valueToPosition(newMin),
maxposition = helper.slider.valueToPosition(newMax);
helper.slider.positionTrackingBar(newMin, newMax, minposition, maxposition);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(90);
expect(helper.slider.minH.css('left')).to.equal(minOffset + 'px');
expect(helper.slider.maxH.css('left')).to.equal(maxOffset + 'px');
expect(helper.slider.minH.css('left')).to.equal(minposition + 'px');
expect(helper.slider.maxH.css('left')).to.equal(maxposition + 'px');
});
});
}());
......
......@@ -43,8 +43,8 @@
var event = helper.fireMousedown(helper.slider.minH, 0);
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
helper.fireMousemove(offset);
position = helper.slider.valueToPosition(moveValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
......@@ -57,8 +57,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.maxH, 0);
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
helper.fireMousemove(offset);
position = helper.slider.valueToPosition(moveValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
helper.slider.positionTrackingBar.called.should.be.true;
......@@ -69,9 +69,9 @@
sinon.spy(helper.slider, 'callOnStart');
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
position = helper.slider.valueToPosition(moveValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(40);
expect(helper.scope.slider.max).to.equal(60);
......@@ -88,8 +88,8 @@
helper.fireMousedown(helper.slider.selBar, 0);
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
helper.fireMousemove(offset);
position = helper.slider.valueToPosition(moveValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
......@@ -207,8 +207,8 @@
var event = helper.fireMousedown(helper.slider.minH, 0);
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
helper.fireMousemove(offset);
position = helper.slider.valueToPosition(moveValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
......@@ -221,8 +221,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.maxH, 0);
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
helper.fireMousemove(offset);
position = helper.slider.valueToPosition(moveValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
helper.slider.positionTrackingBar.called.should.be.true;
......@@ -233,9 +233,9 @@
sinon.spy(helper.slider, 'callOnStart');
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
position = helper.slider.valueToPosition(moveValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(40);
expect(helper.scope.slider.max).to.equal(60);
......@@ -252,8 +252,8 @@
helper.fireMousedown(helper.slider.selBar, 0);
var moveValue = 10,
offset = helper.slider.valueToOffset(moveValue);
helper.fireMousemove(offset);
position = helper.slider.valueToPosition(moveValue);
helper.fireMousemove(position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
......
......@@ -163,16 +163,16 @@
it('should not modify any value if new range would be smaller than minRange when moving minH', function() {
helper.fireMousedown(helper.slider.minH, 0);
var expectedValue = 50,
offset = helper.getMousePosition(expectedValue);
helper.fireMousemove(-offset);
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(-position);
expect(helper.scope.slider.min).to.equal(45);
});
it('should not modify any value if new range would be smaller than minRange when moving maxH', function() {
helper.fireMousedown(helper.slider.maxH, 0);
var expectedValue = 50,
offset = helper.slider.maxPos - helper.getMousePosition(expectedValue);
helper.fireMousemove(offset);
position = helper.slider.maxPos - helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.max).to.equal(55);
});
......@@ -193,8 +193,8 @@
it('should not switch min/max when moving minH even if the range is large enough', function() {
helper.fireMousedown(helper.slider.minH, 0);
var expectedValue = 80,
offset = helper.getMousePosition(expectedValue);
helper.fireMousemove(-offset);
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(-position);
expect(helper.scope.slider.min).to.equal(45);
expect(helper.scope.slider.max).to.equal(55);
});
......
......@@ -56,9 +56,9 @@
helper.scope.$digest();
var expectedValue = 30,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.fullBar, offset);
helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(30);
expect(helper.scope.slider.max).to.equal(50);
......@@ -69,9 +69,9 @@
helper.scope.$digest();
var expectedValue = 70,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.fullBar, offset);
helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
......@@ -134,9 +134,9 @@
helper.scope.$digest();
var expectedValue = 30,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.fullBar, offset);
helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(30);
expect(helper.scope.slider.max).to.equal(50);
......@@ -147,9 +147,9 @@
helper.scope.$digest();
var expectedValue = 70,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.fullBar, offset);
helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(50);
expect(helper.scope.slider.max).to.equal(70);
......
......@@ -197,9 +197,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -216,9 +216,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......@@ -235,9 +235,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.selBar, offset);
var event = helper.fireMousedown(helper.slider.selBar, position);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -254,9 +254,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.selBar, offset);
var event = helper.fireMousedown(helper.slider.selBar, position);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......@@ -464,9 +464,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -483,9 +483,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.fullBar, offset);
var event = helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......@@ -502,9 +502,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.selBar, offset);
var event = helper.fireMousedown(helper.slider.selBar, position);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -521,9 +521,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.selBar, offset);
var event = helper.fireMousedown(helper.slider.selBar, position);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......
......@@ -112,8 +112,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.minH, 0, true);
var expectedValue = 50,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(position, true);
expect(helper.scope.slider.min).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -124,8 +124,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.maxH, 0, true);
var expectedValue = 50,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(position, true);
expect(helper.scope.slider.max).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -138,8 +138,8 @@
var event = helper.fireMousedown(helper.slider.minH, 0, true);
var expectedValue = 80,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(position, true);
expect(helper.scope.slider.min).to.equal(60);
expect(helper.scope.slider.max).to.equal(80);
......@@ -152,8 +152,8 @@
var event = helper.fireMousedown(helper.slider.maxH, 0, true);
var expectedValue = 20,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(position, true);
expect(helper.scope.slider.min).to.equal(20);
expect(helper.scope.slider.max).to.equal(40);
......@@ -166,9 +166,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
var event = helper.fireMousedown(helper.slider.fullBar, position, true);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -185,9 +185,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
var event = helper.fireMousedown(helper.slider.fullBar, position, true);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......@@ -204,9 +204,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.selBar, offset, true);
var event = helper.fireMousedown(helper.slider.selBar, position, true);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -223,9 +223,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.selBar, offset, true);
var event = helper.fireMousedown(helper.slider.selBar, position, true);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......@@ -348,8 +348,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.minH, 0, true);
var expectedValue = 50,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(position, true);
expect(helper.scope.slider.min).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -360,8 +360,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.maxH, 0, true);
var expectedValue = 50,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(position, true);
expect(helper.scope.slider.max).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -374,8 +374,8 @@
var event = helper.fireMousedown(helper.slider.minH, 0, true);
var expectedValue = 80,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(position, true);
expect(helper.scope.slider.min).to.equal(60);
expect(helper.scope.slider.max).to.equal(80);
......@@ -388,8 +388,8 @@
var event = helper.fireMousedown(helper.slider.maxH, 0, true);
var expectedValue = 20,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(position, true);
expect(helper.scope.slider.min).to.equal(20);
expect(helper.scope.slider.max).to.equal(40);
......@@ -402,9 +402,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
var event = helper.fireMousedown(helper.slider.fullBar, position, true);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -421,9 +421,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
var event = helper.fireMousedown(helper.slider.fullBar, position, true);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......@@ -440,9 +440,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 10,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.selBar, offset, true);
var event = helper.fireMousedown(helper.slider.selBar, position, true);
expect(helper.scope.slider.min).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -459,9 +459,9 @@
sinon.spy(helper.slider, 'focusElement');
var expectedValue = 90,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.selBar, offset, true);
var event = helper.fireMousedown(helper.slider.selBar, position, true);
expect(helper.scope.slider.max).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('highValue');
......
......@@ -75,8 +75,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.minH, 0);
var expectedValue = 50,
offset = helper.getMousePosition(expectedValue);
helper.fireMousemove(offset);
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.value).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -136,9 +136,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 12,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.fullBar, offset);
helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -153,9 +153,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 12,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.selBar, offset);
var event = helper.fireMousedown(helper.slider.selBar, position);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -173,9 +173,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.ticks, offset);
helper.fireMousedown(helper.slider.ticks, position);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -193,9 +193,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.ticks, offset);
helper.fireMousedown(helper.slider.ticks, position);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -280,8 +280,8 @@
sinon.spy(helper.slider, 'callOnChange');
var event = helper.fireMousedown(helper.slider.minH, 0);
var expectedValue = 50,
offset = helper.getMousePosition(expectedValue);
helper.fireMousemove(offset);
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.value).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -340,9 +340,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 12,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.fullBar, offset);
helper.fireMousedown(helper.slider.fullBar, position);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -357,9 +357,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 12,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
var event = helper.fireMousedown(helper.slider.selBar, offset);
var event = helper.fireMousedown(helper.slider.selBar, position);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -377,9 +377,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.ticks, offset);
helper.fireMousedown(helper.slider.ticks, position);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -397,9 +397,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 10,
offset = helper.getMousePosition(expectedValue);
position = helper.getMousePosition(expectedValue);
helper.fireMousedown(helper.slider.ticks, offset);
helper.fireMousedown(helper.slider.ticks, position);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......
......@@ -77,9 +77,9 @@
helper.fireMousedown(helper.slider.minH, 0, true);
var expectedValue = 50,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
helper.fireMousemove(position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -139,9 +139,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 50,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
var event = helper.fireMousedown(helper.slider.fullBar, position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -156,9 +156,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 12,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousedown(helper.slider.selBar, offset, true);
helper.fireMousedown(helper.slider.selBar, position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -176,9 +176,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 10,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousedown(helper.slider.ticks, offset, true);
helper.fireMousedown(helper.slider.ticks, position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -196,9 +196,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 10,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousedown(helper.slider.ticks, offset, true);
helper.fireMousedown(helper.slider.ticks, position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -285,9 +285,9 @@
helper.fireMousedown(helper.slider.minH, 0, true);
var expectedValue = 50,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousemove(offset, true);
helper.fireMousemove(position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
helper.slider.positionTrackingHandle.called.should.be.true;
helper.slider.callOnChange.called.should.be.true;
......@@ -347,9 +347,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 50,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
var event = helper.fireMousedown(helper.slider.fullBar, offset, true);
var event = helper.fireMousedown(helper.slider.fullBar, position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -364,9 +364,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 12,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousedown(helper.slider.selBar, offset, true);
helper.fireMousedown(helper.slider.selBar, position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -384,9 +384,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 10,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousedown(helper.slider.ticks, offset, true);
helper.fireMousedown(helper.slider.ticks, position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......@@ -404,9 +404,9 @@
sinon.spy(helper.slider, 'callOnChange');
var expectedValue = 10,
offset = helper.slider.sliderElem.rzsp - helper.slider.valueToOffset(expectedValue) - helper.slider.handleHalfDim;
position = helper.slider.sliderElem.rzsp - helper.slider.valueToPosition(expectedValue) - helper.slider.handleHalfDim;
helper.fireMousedown(helper.slider.ticks, offset, true);
helper.fireMousedown(helper.slider.ticks, position, true);
expect(helper.scope.slider.value).to.equal(expectedValue);
expect(helper.slider.tracking).to.equal('lowValue');
......
......@@ -223,7 +223,7 @@
{value: 'C', 'foo': 'barC'}
];
helper.scope.slider.options.translate = function(value, sliderId, label) {
return 'value: '+ value
return 'value: ' + value
};
helper.scope.$digest();
expect(helper.slider.options.step).to.equal(1);
......@@ -312,7 +312,7 @@
}
};
helper.createSlider(sliderConf);
var expectedDimension = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
var expectedDimension = helper.slider.valueToPosition(2) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
expect(helper.slider.selBar.css('left')).to.equal('0px');
});
......@@ -327,9 +327,11 @@
}
};
helper.createSlider(sliderConf);
var expectedDimension = helper.slider.valueToOffset(8) + helper.slider.handleHalfDim,
expectedPosition = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
var expectedDimension = Math.floor(helper.slider.valueToPosition(8) + helper.slider.handleHalfDim),
actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width);
expect(actualDimension).to.equal(expectedDimension);
var expectedPosition = helper.slider.valueToPosition(2) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
});
......@@ -343,8 +345,8 @@
}
};
helper.createSlider(sliderConf);
var expectedDimension = helper.slider.valueToOffset(5),
expectedPosition = helper.slider.valueToOffset(10) + helper.slider.handleHalfDim;
var expectedDimension = helper.slider.valueToPosition(5),
expectedPosition = helper.slider.valueToPosition(10) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
});
......@@ -359,9 +361,11 @@
}
};
helper.createSlider(sliderConf);
var expectedDimension = helper.slider.valueToOffset(7),
expectedPosition = helper.slider.valueToOffset(3) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
var expectedDimension = Math.floor(helper.slider.valueToPosition(7)),
actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width);
expect(actualDimension).to.equal(expectedDimension);
var expectedPosition = helper.slider.valueToPosition(3) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
});
......@@ -463,9 +467,12 @@
}
};
helper.createRangeSlider(sliderConf);
var expectedDimension = helper.slider.valueToOffset(6),
expectedPosition = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
var expectedDimension = Math.floor(helper.slider.valueToPosition(6)),
actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width);
expect(actualDimension).to.equal(expectedDimension);
var expectedPosition = helper.slider.valueToPosition(2) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
});
......@@ -1073,10 +1080,10 @@
}
};
helper.createSlider(sliderConf);
var expectedDimension = Math.floor(helper.slider.valueToOffset(8) + helper.slider.handleHalfDim),
var expectedDimension = Math.floor(helper.slider.valueToPosition(8) + helper.slider.handleHalfDim),
actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width);
expect(actualDimension).to.equal(expectedDimension);
expect(helper.slider.selBar.css('left')).to.equal(helper.slider.valueToOffset(2) + helper.slider.handleHalfDim + 'px');
expect(helper.slider.selBar.css('left')).to.equal(helper.slider.valueToPosition(2) + helper.slider.handleHalfDim + 'px');
});
it('should set the correct dimension/position for selection bar for single slider with showSelectionBarEnd=true', function() {
......@@ -1090,8 +1097,9 @@
}
};
helper.createSlider(sliderConf);
var expectedDimension = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
var expectedDimension = Math.floor(helper.slider.valueToPosition(2) + helper.slider.handleHalfDim),
actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width);
expect(actualDimension).to.equal(expectedDimension);
expect(helper.slider.selBar.css('left')).to.equal('0px');
});
......@@ -1106,8 +1114,8 @@
}
};
helper.createSlider(sliderConf);
var expectedDimension = helper.slider.valueToOffset(15),
expectedPosition = helper.slider.valueToOffset(15) + helper.slider.handleHalfDim;
var expectedDimension = helper.slider.valueToPosition(15),
expectedPosition = helper.slider.valueToPosition(15) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
});
......@@ -1123,9 +1131,9 @@
}
};
helper.createSlider(sliderConf);
var expectedDimension = Math.floor(helper.slider.valueToOffset(13)),
var expectedDimension = Math.floor(helper.slider.valueToPosition(13)),
actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width),
expectedPosition = helper.slider.valueToOffset(10) + helper.slider.handleHalfDim;
expectedPosition = helper.slider.valueToPosition(10) + helper.slider.handleHalfDim;
expect(actualDimension).to.equal(expectedDimension);
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
});
......@@ -1164,9 +1172,12 @@
rightToLeft: true
};
helper.createRangeSlider(sliderConf);
var expectedDimension = helper.slider.valueToOffset(6),
expectedPosition = helper.slider.valueToOffset(2) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('width')).to.equal(expectedDimension + 'px');
var expectedDimension = Math.floor(helper.slider.valueToPosition(6)),
actualDimension = Math.floor(helper.slider.selBar[0].getBoundingClientRect().width);
expect(actualDimension).to.equal(expectedDimension);
var expectedPosition = helper.slider.valueToPosition(2) + helper.slider.handleHalfDim;
expect(helper.slider.selBar.css('left')).to.equal(expectedPosition + 'px');
});
......
(function() {
"use strict";
describe('Scale test - ', function() {
var helper,
RzSliderOptions,
$rootScope,
$timeout;
beforeEach(module('test-helper'));
beforeEach(inject(function(TestHelper, _RzSliderOptions_, _$rootScope_, _$timeout_) {
helper = TestHelper;
RzSliderOptions = _RzSliderOptions_;
$rootScope = _$rootScope_;
$timeout = _$timeout_;
}));
afterEach(function() {
helper.clean();
});
describe('Linear scale - ', function() {
beforeEach(function() {
var sliderConf = {
value: 10,
options: {
floor: 0,
ceil: 100,
step: 10
}
};
helper.createSlider(sliderConf);
});
it('should have a correct linearValueToPosition', function() {
var actual = helper.slider.linearValueToPosition(0, 0, 50);
expect(actual).to.equal(0);
actual = helper.slider.linearValueToPosition(25, 0, 50);
expect(actual.toFixed(2)).to.equal('0.50');
actual = helper.slider.linearValueToPosition(50, 0, 50);
expect(actual).to.equal(1);
});
it('should have a correct linearPositionToValue', function() {
var actual = helper.slider.linearPositionToValue(0, 0, 50);
expect(actual).to.equal(0);
actual = helper.slider.linearPositionToValue(0.5, 0, 50);
expect(actual).to.equal(25);
actual = Math.round(helper.slider.linearPositionToValue(1, 0, 50));
expect(actual).to.equal(50);
});
});
describe('Logarithm scale - ', function() {
beforeEach(function() {
var sliderConf = {
value: 10,
options: {
floor: 1,
ceil: 100,
step: 10,
logScale: true
}
};
helper.createSlider(sliderConf);
});
it('should throw an error if floor is 0', function() {
var testFn = function() {
helper.scope.slider.options.floor = 0;
helper.scope.$digest();
};
expect(testFn).to.throw("Can't use floor=0 with logarithmic scale");
});
it('should have a correct logValueToPosition', function() {
var actual = helper.slider.logValueToPosition(1, 1, 50);
expect(actual).to.equal(0);
actual = helper.slider.logValueToPosition(25, 1, 50);
expect(actual.toFixed(2)).to.equal('0.82');
actual = helper.slider.logValueToPosition(50, 1, 50);
expect(actual).to.equal(1);
});
it('should have a correct logPositionToValue', function() {
var actual = helper.slider.logPositionToValue(0, 1, 50);
expect(actual).to.equal(1);
actual = helper.slider.logPositionToValue(0.5, 1, 50);
expect(actual.toFixed(2)).to.equal('7.07');
actual = Math.round(helper.slider.logPositionToValue(1, 1, 50));
expect(actual).to.equal(50);
});
it('should handle click and drag on minH correctly', function () {
helper.fireMousedown(helper.slider.minH, 0);
var expectedValue = 50,
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.value).to.equal(expectedValue + 1); // + 1 because we start at 1
});
});
describe('Custom scale (here a x^2 scale)- ', function() {
beforeEach(function() {
var sliderConf = {
value: 50,
options: {
floor: 0,
ceil: 100,
step: 10,
customValueToPosition: function(val, minVal, maxVal) {
val = Math.sqrt(val);
minVal = Math.sqrt(minVal);
maxVal = Math.sqrt(maxVal);
var range = maxVal - minVal;
return (val - minVal) / range;
},
customPositionToValue: function(percent, minVal, maxVal) {
minVal = Math.sqrt(minVal);
maxVal = Math.sqrt(maxVal);
var value = percent * (maxVal - minVal) + minVal;
return Math.pow(value, 2);
}
}
};
helper.createSlider(sliderConf);
});
-
it('should have a correct valueToPosition', function() {
var actual = helper.slider.valueToPosition(0);
expect(actual).to.equal(0);
actual = helper.slider.valueToPosition(25);
expect(actual).to.equal(helper.slider.maxPos / 2);
actual = helper.slider.valueToPosition(100);
expect(actual).to.equal(helper.slider.maxPos);
});
it('should have a correct positionToValue', function() {
var actual = helper.slider.positionToValue(0);
expect(actual).to.equal(0);
actual = helper.slider.positionToValue(helper.slider.maxPos / 2);
expect(actual).to.equal(25);
actual = Math.round(helper.slider.positionToValue(helper.slider.maxPos));
expect(actual).to.equal(100);
});
it('should handle click and drag on minH correctly', function () {
helper.fireMousedown(helper.slider.minH, 0);
var expectedValue = 50,
position = helper.getMousePosition(expectedValue);
helper.fireMousemove(position);
expect(helper.scope.slider.value).to.equal(expectedValue);
});
});
});
}());
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