diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5c89aa8..9f3a019 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
+# 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.
diff --git a/README.md b/README.md
index bd2a995..1abeb57 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/demo/demo.js b/demo/demo.js
index 5fe680a..e75a0e1 100644
--- a/demo/demo.js
+++ b/demo/demo.js
@@ -13,6 +13,7 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
options: {
floor: 0,
ceil: 100,
+ rightToLeft: true,
step: 1
}
};
@@ -137,6 +138,41 @@ app.controller('MainCtrl', function($scope, $rootScope, $timeout, $modal) {
}
};
+ //Slider config with logarithmic scale
+ $scope.slider_log = {
+ value: 1,
+ options: {
+ floor: 1,
+ ceil: 100,
+ 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);
+ }
+ }
+ };
+
//Right to left slider with floor, ceil and step
$scope.slider_floor_ceil_rtl = {
value: 12,
@@ -232,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]
}
};
@@ -322,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)
@@ -564,8 +599,8 @@ app.directive('clickableLabel', function() {
scope: {label: '='},
replace: true,
template: "",
- link: function(scope, elem, attrs){
- scope.onclick = function(label){
+ link: function(scope, elem, attrs) {
+ scope.onclick = function(label) {
alert("I'm " + label);
};
}
diff --git a/demo/index.html b/demo/index.html
index 8bd87af..0eb6ed6 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -119,6 +119,22 @@
Slider with custom floor/ceil/step
>
+
+
Slider with logarithmic scale
+
+
+
+
+
Slider with custom scale
+
+
+
Right to left slider with custom floor/ceil/step
center;
if (isModelGreaterThanCenter) {
dimension = this.minH.rzsp - centerPosition;
@@ -1374,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
@@ -1419,43 +1424,78 @@
},
/**
- * Translate value to pixel offset
+ * Returns a value that is within slider range
*
* @param {number} val
* @returns {number}
*/
- valueToOffset: function(val) {
- if (this.options.rightToLeft) {
- return (this.maxValue - this.sanitizeValue(val)) * this.maxPos / this.valueRange || 0;
- }
- return (this.sanitizeValue(val) - this.minValue) * this.maxPos / this.valueRange || 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) {
- if (this.options.rightToLeft) {
- return (1 - (offset / this.maxPos)) * this.valueRange + this.minValue;
- }
- return (offset / this.maxPos) * this.valueRange + this.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;
},
- // Events
+ linearPositionToValue: function(percent, minVal, maxVal) {
+ return percent * (maxVal - minVal) + minVal;
+ },
+ 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
*
@@ -1523,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;
},
/**
@@ -1676,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
@@ -1848,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);
@@ -1863,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;
@@ -1884,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) {
@@ -1895,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;
}
}
}
@@ -1914,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,
@@ -1931,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
@@ -1974,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
*/
@@ -2034,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;
}
@@ -2081,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();
}
@@ -2202,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
diff --git a/dist/rzslider.min.js b/dist/rzslider.min.js
index e515100..b9cd017 100644
--- a/dist/rzslider.min.js
+++ b/dist/rzslider.min.js
@@ -1,2 +1,2 @@
/*! angularjs-slider - v5.6.0 - (c) Rafal Zajac , Valentin Hervieu , Jussi Saarivirta , Angelin Sirbu - 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,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;d0&&0===b.rzsd)&&(f=!0,b.rzsv=e),g||b.html(e),this.scope[c+"Label"]=e,f&&this.getDimension(b)},setMinAndMax:function(){this.step=+this.options.step,this.precision=+this.options.precision,this.minValue=this.options.floor,this.options.enforceStep&&(this.lowValue=this.roundStep(this.lowValue),this.range&&(this.highValue=this.roundStep(this.highValue))),null!=this.options.ceil?this.maxValue=this.options.ceil:this.maxValue=this.options.ceil=this.range?this.highValue:this.lowValue,this.options.enforceRange&&(this.lowValue=this.sanitizeValue(this.lowValue),this.range&&(this.highValue=this.sanitizeValue(this.highValue))),this.applyLowValue(),this.range&&this.applyHighValue(),this.valueRange=this.maxValue-this.minValue},addAccessibility:function(){this.minH.attr("role","slider"),this.updateAriaAttributes(),!this.options.keyboardSupport||this.options.readOnly||this.options.disabled?this.minH.attr("tabindex",""):this.minH.attr("tabindex","0"),this.options.vertical&&this.minH.attr("aria-orientation","vertical"),this.range&&(this.maxH.attr("role","slider"),!this.options.keyboardSupport||this.options.readOnly||this.options.disabled?this.maxH.attr("tabindex",""):this.maxH.attr("tabindex","0"),this.options.vertical&&this.maxH.attr("aria-orientation","vertical"))},updateAriaAttributes:function(){this.minH.attr({"aria-valuenow":this.scope.rzSliderModel,"aria-valuetext":this.customTrFn(this.scope.rzSliderModel,this.options.id,"model"),"aria-valuemin":this.minValue,"aria-valuemax":this.maxValue}),this.range&&this.maxH.attr({"aria-valuenow":this.scope.rzSliderHigh,"aria-valuetext":this.customTrFn(this.scope.rzSliderHigh,this.options.id,"high"),"aria-valuemin":this.minValue,"aria-valuemax":this.maxValue})},calcViewDimensions:function(){var a=this.getDimension(this.minH);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=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){return this.options.rightToLeft?(this.maxValue-this.sanitizeValue(a))*this.maxPos/this.valueRange||0:(this.sanitizeValue(a)-this.minValue)*this.maxPos/this.valueRange||0},sanitizeValue:function(a){return Math.min(Math.max(a,this.minValue),this.maxValue)},offsetToValue:function(a){return this.options.rightToLeft?(1-a/this.maxPos)*this.valueRange+this.minValue:a/this.maxPos*this.valueRange+this.minValue},getEventXY:function(a){var b=this.options.vertical?"clientY":"clientX";return 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=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=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&&athis.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&&athis.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&&athis.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&&cthis.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",'