nice-elements 1.7.7 → 1.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +19 -21
- package/dist/nice.min.js +1 -1
- package/package.json +1 -1
- package/src/components/nice-quantity/nice-quantity.html +3 -3
- package/src/components/nice-quantity/nice-quantity.js +16 -18
package/package.json
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
<!------------------------- Field ------------------------->
|
|
7
7
|
<div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]">
|
|
8
8
|
<div class="input-group">
|
|
9
|
-
<button class="btn btn-default btn-left" ng-click="sub()" type="button" ng-disabled="isDisabled" tabindex="-1">
|
|
9
|
+
<button class="btn btn-default btn-left" ng-click="sub()" type="button" ng-disabled="model <= min || isDisabled" tabindex="-1">
|
|
10
10
|
<nice-icon icon="icon-minus"></nice-icon>
|
|
11
11
|
</button>
|
|
12
|
-
<input class="value form-control" ng-model="model" type="number" ng-change="handleChange()" ng-disabled="isDisabled" />
|
|
13
|
-
<button class="btn btn-default btn-right" ng-click="add()" type="button" ng-disabled="isDisabled" tabindex="-1">
|
|
12
|
+
<input class="value form-control" ng-model="model" type="number" min="{{ min }}" max="{{ max }}" ng-change="handleChange()" ng-disabled="isDisabled" />
|
|
13
|
+
<button class="btn btn-default btn-right" ng-click="add()" type="button" ng-disabled="model >= max || isDisabled" tabindex="-1">
|
|
14
14
|
<nice-icon icon="icon-plus"></nice-icon>
|
|
15
15
|
</button>
|
|
16
16
|
</div>
|
|
@@ -14,7 +14,8 @@ angular.module('niceElements')
|
|
|
14
14
|
scope: {
|
|
15
15
|
title: '@',
|
|
16
16
|
model: '=',
|
|
17
|
-
|
|
17
|
+
min: '=?',
|
|
18
|
+
max: '=?',
|
|
18
19
|
onChange: '&?',
|
|
19
20
|
noMargin: '@',
|
|
20
21
|
fieldWidth: '@',
|
|
@@ -24,32 +25,29 @@ angular.module('niceElements')
|
|
|
24
25
|
help: '@',
|
|
25
26
|
},
|
|
26
27
|
controller: function ($scope) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
$scope.min = Number($scope.min) || 0;
|
|
29
|
+
$scope.max = Number($scope.max) || Infinity;
|
|
30
|
+
if (!$scope.model) $scope.model = Number($scope.min);
|
|
30
31
|
|
|
31
32
|
$scope.add = function () {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
$scope.model += 1;
|
|
35
|
-
if ($scope.onChange) $scope.onChange({ model: $scope.model });
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
$scope.model += 1;
|
|
39
|
-
if ($scope.onChange) $scope.onChange({ model: $scope.model });
|
|
40
|
-
}
|
|
33
|
+
$scope.model += 1;
|
|
34
|
+
$scope.handleChange();
|
|
41
35
|
};
|
|
42
36
|
|
|
43
37
|
$scope.sub = function () {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if ($scope.onChange) $scope.onChange({ model: $scope.model });
|
|
47
|
-
}
|
|
38
|
+
$scope.model -= 1;
|
|
39
|
+
$scope.handleChange();
|
|
48
40
|
};
|
|
49
41
|
|
|
50
42
|
$scope.handleChange = function () {
|
|
51
|
-
if ($scope.model) {
|
|
43
|
+
if ($scope.model != undefined) {
|
|
52
44
|
$scope.model = Number($scope.model);
|
|
45
|
+
if ($scope.model < $scope.min) $scope.model = angular.copy($scope.min);
|
|
46
|
+
if ($scope.model > $scope.max) $scope.model = angular.copy($scope.max);
|
|
47
|
+
if ($scope.onChange) $scope.onChange({ model: $scope.model });
|
|
48
|
+
} else {
|
|
49
|
+
$scope.model = angular.copy($scope.min);
|
|
50
|
+
$scope.handleChange();
|
|
53
51
|
}
|
|
54
52
|
};
|
|
55
53
|
}
|