Commit 19917076 authored by kvindasAB's avatar kvindasAB

Returning code to original branch state.

parent f557cd4d
......@@ -13,7 +13,7 @@
angular.module('rzModule', [])
.value('throttle',
.value('throttle',
/**
* throttle
*
......@@ -24,7 +24,7 @@ angular.module('rzModule', [])
* @param {ThrottleOptions} options
* @returns {Function}
*/
function throttle(func, wait, options) {
function throttle(func, wait, options) {
var getTime = (Date.now || function() {
return new Date().getTime();
});
......@@ -55,10 +55,10 @@ angular.module('rzModule', [])
}
return result;
}
})
})
.factory('Slider', ['$timeout', '$document', 'throttle', function($timeout, $document, throttle)
{
.factory('Slider', ['$timeout', '$document', 'throttle', function($timeout, $document, throttle)
{
/**
* Slider
*
......@@ -192,7 +192,6 @@ angular.module('rzModule', [])
*/
init: function()
{
//console.log("slider.init...");
var self = this;
if(this.scope.rzSliderTranslate)
......@@ -213,7 +212,10 @@ angular.module('rzModule', [])
self.updateFloorLab();
self.initHandles();
self.bindEvents();
},100);
});
// Recalculate slider view dimensions
this.scope.$on('reCalcViewDimensions', angular.bind(this, this.calcViewDimensions));
// Recalculate stuff if view port dimensions have changed
angular.element(window).on('resize', angular.bind(this, this.calcViewDimensions));
......@@ -224,6 +226,7 @@ angular.module('rzModule', [])
var thrLow = throttle(function()
{
self.setMinAndMax();
self.updateLowHandle(self.valueToOffset(self.scope.rzSliderModel));
if(self.range)
......@@ -236,57 +239,25 @@ angular.module('rzModule', [])
var thrHigh = throttle(function()
{
self.setMinAndMax();
self.updateHighHandle(self.valueToOffset(self.scope.rzSliderHigh));
self.updateSelectionBar();
self.updateCmbLabel();
}, 350, { leading: false });
this.scope.$watch('rzSliderModel', function(newValue, oldValue){
//console.log("sliderModel.changed...");
this.scope.$watch('rzSliderModel', function(newValue, oldValue)
{
if(newValue === oldValue) return;
thrLow();
});
this.scope.$watch('rzSliderHigh', function(newValue, oldValue){
//console.log("sliderHigh.changed...");
if(newValue === oldValue) return;
thrHigh();
});
this.scope.$watch('rzSliderFloor', function(newValue, oldValue){
//console.log("sliderFloor.changed...");
if(newValue === oldValue) return;
self.resetSlider();
});
this.scope.$watch('rzSliderCeil', function(newValue, oldValue){
//console.log("sliderCeil.changed...");
this.scope.$watch('rzSliderHigh', function(newValue, oldValue)
{
if(newValue === oldValue) return;
self.resetSlider();
});
this.scope.$watch('rzSliderForceRender', function(newValue, oldValue){
//console.log("rzSliderForceRender.changed...");
self.resetLabelsWidth();
thrLow();
thrHigh();
self.resetSlider();
});
},
resetLabelsWidth: function() {
this.minLab.rzsv = undefined;
this.maxLab.rzsv = undefined;
},
resetSlider: function() {
this.setMinAndMax();
this.calcViewDimensions();
this.updateCeilLab();
this.updateFloorLab();
},
/**
* Initialize slider handles positions and labels
*
......@@ -340,7 +311,6 @@ angular.module('rzModule', [])
*/
setMinAndMax: function()
{
//console.log("slider.setMinAndMax...");
if(this.scope.rzSliderFloor)
{
this.minValue = +this.scope.rzSliderFloor;
......@@ -505,7 +475,6 @@ angular.module('rzModule', [])
*/
updateLowHandle: function(newOffset)
{
//console.log("updateLowHandle: hhw: " + this.handleHalfWidth + " mh" + newOffset );
this.setLeft(this.minH, newOffset);
this.translateFn(this.scope.rzSliderModel, this.minLab);
this.setLeft(this.minLab, newOffset - this.minLab.rzsw / 2 + this.handleHalfWidth);
......@@ -715,7 +684,6 @@ angular.module('rzModule', [])
*/
valueToOffset: function(val)
{
//console.log("valueToOffset..." + val + " minV: " + this.minValue + " maxL " + this.maxLeft + " vr: " + this.valueRange);
return (val - this.minValue) * this.maxLeft / this.valueRange;
},
......@@ -876,10 +844,10 @@ angular.module('rzModule', [])
};
return Slider;
}])
}])
.directive('rzslider', ['Slider', function(Slider)
{
.directive('rzslider', ['Slider', function(Slider)
{
return {
restrict: 'E',
scope: {
......@@ -889,8 +857,7 @@ angular.module('rzModule', [])
rzSliderPrecision: '@',
rzSliderModel: '=?',
rzSliderHigh: '=?',
rzSliderTranslate: '&',
rzSliderForceRender: '=?'
rzSliderTranslate: '&'
},
template: '<span class="bar"></span>' + // 0 The slider bar
'<span class="bar selection"></span>' + // 1 Highlight between two handles
......@@ -907,7 +874,7 @@ angular.module('rzModule', [])
return new Slider(scope, elem, attr);
}
};
}]);
}]);
// IDE assist
......
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