angular-ui-slider
Advanced tools
Comparing version 0.1.2 to 0.2.1
{ | ||
"name": "angular-ui-slider", | ||
"version": "0.1.2", | ||
"description": "This directive allows you to add a slider to your form elements.", | ||
@@ -21,3 +20,3 @@ "author": "https://github.com/angular-ui/ui-slider/graphs/contributors", | ||
"dependencies": { | ||
"angular": ">=1.0.0 <1.4.0", | ||
"angular": ">=1.0.0 <1.5.0", | ||
"jquery-ui": "~1.10.x", | ||
@@ -24,0 +23,0 @@ "jquery": ">= 1.9" |
{ | ||
"name": "angular-ui-slider", | ||
"version": "0.1.2", | ||
"version": "0.2.1", | ||
"description": "This directive allows you to add a slider to your form elements.", | ||
@@ -5,0 +5,0 @@ "author": "https://github.com/angular-ui/ui-slider/graphs/contributors", |
@@ -13,3 +13,3 @@ # ui-slider directive | ||
Check the [demo](http://angular-ui.github.io/ui-slider/demo/demo.html) for an example on how it works. | ||
Check the [demo](https://htmlpreview.github.io/?https://github.com/angular-ui/ui-slider/master/demo/index.html) for an example on how it works. | ||
@@ -15,3 +15,4 @@ /* | ||
var options = angular.extend(scope.$eval(attrs.uiSlider) || {}, uiSliderConfig); | ||
var directiveOptions = angular.copy(scope.$eval(attrs.uiSlider)); | ||
var options = angular.extend(directiveOptions || {}, uiSliderConfig); | ||
// Object holding range values | ||
@@ -113,2 +114,3 @@ var prevRangeValues = { | ||
ngModel.$setViewValue(ui.values || ui.value); | ||
$(ui.handle).find('.ui-slider-tip').text(ui.value); | ||
scope.$apply(); | ||
@@ -118,3 +120,3 @@ | ||
setTimeout(function() { | ||
elm.slider('value', ui.values || ui.values); | ||
elm.slider('value', ui.values || ui.value); | ||
}, 0); | ||
@@ -130,3 +132,3 @@ | ||
var method = options.range === true ? 'values' : 'value'; | ||
if (options.range !== true && isNaN(ngModel.$viewValue) && !(ngModel.$viewValue instanceof Array)) { | ||
@@ -141,3 +143,9 @@ ngModel.$viewValue = 0; | ||
if (options.range === true) { | ||
// previously, the model was a string b/c it was in a text input, need to convert to a array. | ||
// make sure input exists, comma exists once, and it is a string. | ||
if (ngModel.$viewValue && angular.isString(ngModel.$viewValue) && (ngModel.$viewValue.match(/,/g) || []).length === 1) { | ||
// transform string model into array. | ||
var valueArr = ngModel.$viewValue.split(','); | ||
ngModel.$viewValue = [Number(valueArr[0]), Number(valueArr[1])]; | ||
} | ||
// Check outer bounds for min and max values | ||
@@ -155,7 +163,7 @@ if (angular.isDefined(options.min) && options.min > ngModel.$viewValue[0]) { | ||
if (prevRangeValues.min >= ngModel.$viewValue[1]) { | ||
ngModel.$viewValue[0] = prevRangeValues.min; | ||
ngModel.$viewValue[1] = prevRangeValues.min; | ||
} | ||
// Max value should be less to equal to min value | ||
if (prevRangeValues.max <= ngModel.$viewValue[0]) { | ||
ngModel.$viewValue[1] = prevRangeValues.max; | ||
ngModel.$viewValue[0] = prevRangeValues.max; | ||
} | ||
@@ -192,3 +200,3 @@ } | ||
var options = angular.extend({}, scope.$eval(attrs.uiSlider)); | ||
var properties = ['max', 'step', 'tick']; | ||
var properties = ['min', 'max', 'step', 'tick', 'tip']; | ||
angular.forEach(properties, function(property) { | ||
@@ -200,3 +208,3 @@ if (angular.isDefined(attrs[property])) { | ||
if (angular.isDefined(options['tick']) && angular.isDefined(options['step'])) { | ||
var total = parseInt(parseInt(options['max'])/parseInt(options['step'])); | ||
var total = parseInt( (parseInt(options['max']) - parseInt(options['min'])) /parseInt(options['step'])); | ||
for (var i = total; i >= 0; i--) { | ||
@@ -207,2 +215,5 @@ var left = ((i / total) * 100) + '%'; | ||
} | ||
if(angular.isDefined(options['tip'])) { | ||
$timeout(function(){element.find('.ui-slider-handle').append('<div class="ui-slider-tip">'+ngModel.$viewValue+'</div>')},10); | ||
} | ||
} | ||
@@ -209,0 +220,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
29978
237
1