nice-elements 1.9.14 → 1.9.15
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 +6 -0
- package/LICENSE.md +1 -1
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +87 -74
- package/dist/nice.min.js +1 -1
- package/package.json +1 -1
- package/src/components/nice-input/nice-input.js +86 -73
- package/src/components/nice-toggle/nice-toggle.js +1 -1
- package/src/services/nice-service.js +1 -1
package/CHANGELOG.md
CHANGED
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
# Nice elements v1.9.
|
|
3
|
+
# Nice elements v1.9.15
|
|
4
4
|
|
|
5
5
|
Nice elements is an AngularJS v1.5.8 module that contains nice form elements like inputs, choice fields, search, toggle, dropdown, etc.
|
|
6
6
|
|
package/bower.json
CHANGED
package/dist/nice.js
CHANGED
|
@@ -3705,7 +3705,7 @@ angular.module('niceElements')
|
|
|
3705
3705
|
};
|
|
3706
3706
|
});
|
|
3707
3707
|
angular.module('niceElements')
|
|
3708
|
-
.directive('niceInput', function () {
|
|
3708
|
+
.directive('niceInput', function ($timeout) {
|
|
3709
3709
|
return {
|
|
3710
3710
|
templateUrl: 'src/components/nice-input/nice-input.html',
|
|
3711
3711
|
restrict: 'E',
|
|
@@ -3742,118 +3742,131 @@ angular.module('niceElements')
|
|
|
3742
3742
|
onChange: '&?',
|
|
3743
3743
|
onClear: '&?',
|
|
3744
3744
|
numbersOnly: '=', // Allow only numbers in the input
|
|
3745
|
-
positiveOnly: '
|
|
3745
|
+
positiveOnly: '=?', // Allow only positive numbers in the input
|
|
3746
3746
|
multilanguage: '=?', // Multiple languages object
|
|
3747
3747
|
multilanguageField: '@?', // Multiple languages field name
|
|
3748
3748
|
},
|
|
3749
3749
|
|
|
3750
3750
|
link: function (scope, element, attrs) {
|
|
3751
|
-
if (!attrs.type) { attrs.type = 'text'; }
|
|
3752
|
-
if (!attrs.title) { attrs.title = ''; }
|
|
3753
|
-
if (!attrs.regex) { attrs.regex = null; }
|
|
3754
|
-
if (!attrs.placeholder) { attrs.placeholder = ''; }
|
|
3755
|
-
if (!attrs.minlength) { attrs.minlength = 1; }
|
|
3756
|
-
if (!attrs.maxlength) { attrs.maxlength = 100; }
|
|
3757
|
-
if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
|
|
3758
|
-
if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
|
|
3759
|
-
if (!attrs.textAreaLines) { attrs.textAreaLines = 3; }
|
|
3760
|
-
if (!attrs.symbol) { attrs.symbol = ''; }
|
|
3761
|
-
if (!attrs.help) { attrs.help = ''; }
|
|
3762
|
-
if (!attrs.name) { attrs.name = ''; }
|
|
3763
|
-
if (!attrs.minDecimalsCutZeros) { attrs.minDecimalsCutZeros = 0; }
|
|
3764
|
-
attrs.hideValid = angular.isDefined(attrs.hideValid);
|
|
3765
|
-
attrs.showValid = angular.isDefined(attrs.showValid);
|
|
3766
|
-
attrs.textArea = angular.isDefined(attrs.textArea);
|
|
3767
|
-
attrs.noMargin = angular.isDefined(attrs.noMargin);
|
|
3768
|
-
attrs.required = attrs.required === 'true';
|
|
3769
|
-
scope.inputMode = null;
|
|
3770
|
-
//attrs.required = angular.isDefined(attrs.required);
|
|
3771
3751
|
|
|
3772
|
-
|
|
3773
|
-
|
|
3752
|
+
},
|
|
3753
|
+
|
|
3754
|
+
controller: function ($scope, $attrs, $rootScope, $element, ngDialog) {
|
|
3755
|
+
if (!$attrs.type) { $attrs.type = 'text'; }
|
|
3756
|
+
if (!$attrs.title) { $attrs.title = ''; }
|
|
3757
|
+
if (!$attrs.regex) { $attrs.regex = null; }
|
|
3758
|
+
if (!$attrs.placeholder) { $attrs.placeholder = ''; }
|
|
3759
|
+
if (!$attrs.minlength) { $attrs.minlength = 1; }
|
|
3760
|
+
if (!$attrs.maxlength) { $attrs.maxlength = 100; }
|
|
3761
|
+
if (!$attrs.fieldWidth) { $attrs.fieldWidth = 'col-sm-8'; }
|
|
3762
|
+
if (!$attrs.labelWidth) { $attrs.labelWidth = 'col-sm-4'; }
|
|
3763
|
+
if (!$attrs.textAreaLines) { $attrs.textAreaLines = 3; }
|
|
3764
|
+
if (!$attrs.symbol) { $attrs.symbol = ''; }
|
|
3765
|
+
if (!$attrs.help) { $attrs.help = ''; }
|
|
3766
|
+
if (!$attrs.name) { $attrs.name = ''; }
|
|
3767
|
+
if (!$attrs.minDecimalsCutZeros) { $attrs.minDecimalsCutZeros = 0; }
|
|
3768
|
+
$attrs.hideValid = angular.isDefined($attrs.hideValid);
|
|
3769
|
+
$attrs.showValid = angular.isDefined($attrs.showValid);
|
|
3770
|
+
$attrs.textArea = angular.isDefined($attrs.textArea);
|
|
3771
|
+
$attrs.noMargin = angular.isDefined($attrs.noMargin);
|
|
3772
|
+
$attrs.required = $attrs.required === 'true';
|
|
3773
|
+
$scope.inputMode = null;
|
|
3774
|
+
$scope.lastKey = null;
|
|
3775
|
+
|
|
3776
|
+
if (!$scope.textArea) {
|
|
3777
|
+
$scope.elementType = "input";
|
|
3774
3778
|
} else {
|
|
3775
|
-
scope.elementType = "textarea";
|
|
3779
|
+
$scope.elementType = "textarea";
|
|
3776
3780
|
}
|
|
3777
3781
|
|
|
3778
|
-
if (scope.isFocused) {
|
|
3779
|
-
|
|
3782
|
+
if ($scope.isFocused) {
|
|
3783
|
+
const input = $element[0].getElementsByTagName($scope.elementType)[0];
|
|
3780
3784
|
if (input) input.focus();
|
|
3781
3785
|
}
|
|
3782
3786
|
|
|
3783
|
-
if (scope.numbersOnly) {
|
|
3784
|
-
scope.inputMode = "numeric";
|
|
3787
|
+
if ($scope.numbersOnly) {
|
|
3788
|
+
$scope.inputMode = "numeric";
|
|
3785
3789
|
}
|
|
3786
3790
|
|
|
3787
3791
|
// Set internal type
|
|
3788
|
-
scope.internalType =
|
|
3789
|
-
if (
|
|
3790
|
-
scope.internalType = "percent";
|
|
3791
|
-
scope.inputMode = "decimal";
|
|
3792
|
-
|
|
3793
|
-
} else if (
|
|
3794
|
-
scope.internalType = "text";
|
|
3795
|
-
scope.inputMode = "decimal";
|
|
3796
|
-
if (scope.model != null) {
|
|
3797
|
-
scope.model = Number(scope.model);
|
|
3792
|
+
$scope.internalType = $scope.type;
|
|
3793
|
+
if ($scope.type == "percent") {
|
|
3794
|
+
$scope.internalType = "percent";
|
|
3795
|
+
$scope.inputMode = "decimal";
|
|
3796
|
+
$scope.symbol = '%';
|
|
3797
|
+
} else if ($scope.type == "number") {
|
|
3798
|
+
$scope.internalType = "text";
|
|
3799
|
+
$scope.inputMode = "decimal";
|
|
3800
|
+
if ($scope.model != null) {
|
|
3801
|
+
$scope.model = Number($scope.model);
|
|
3798
3802
|
} else {
|
|
3799
|
-
scope.model = null;
|
|
3803
|
+
$scope.model = null;
|
|
3800
3804
|
}
|
|
3801
|
-
} else if (
|
|
3802
|
-
scope.internalType = "text";
|
|
3803
|
-
scope.inputMode = "numeric";
|
|
3804
|
-
scope.model = Number(scope.model);
|
|
3805
|
-
} else if (
|
|
3806
|
-
scope.inputMode = "email";
|
|
3805
|
+
} else if ($scope.type == "integer") {
|
|
3806
|
+
$scope.internalType = "text";
|
|
3807
|
+
$scope.inputMode = "numeric";
|
|
3808
|
+
$scope.model = Number($scope.model);
|
|
3809
|
+
} else if ($scope.type == "email") {
|
|
3810
|
+
$scope.inputMode = "email";
|
|
3807
3811
|
// TODO: get rid of the errors
|
|
3808
|
-
scope.regexexp = new RegExp('^[_a-zA-Z0-9]+(.[_a-zA-Z0-9]+)*@[a-zA-Z0-9]+(.[a-zA-Z0-9]+)+(.[a-zA-Z]{2,4})');
|
|
3812
|
+
$scope.regexexp = new RegExp('^[_a-zA-Z0-9]+(.[_a-zA-Z0-9]+)*@[a-zA-Z0-9]+(.[a-zA-Z0-9]+)+(.[a-zA-Z]{2,4})');
|
|
3809
3813
|
}
|
|
3810
3814
|
|
|
3811
|
-
if (angular.isDefined(
|
|
3812
|
-
scope.valid = scope.forma;
|
|
3815
|
+
if (angular.isDefined($scope.valid)) {
|
|
3816
|
+
$scope.valid = $scope.forma;
|
|
3813
3817
|
}
|
|
3814
3818
|
|
|
3815
|
-
if (scope.model && angular.isDefined(
|
|
3816
|
-
scope.model = Number(scope.model);
|
|
3817
|
-
if (scope.model.toString().split('.').length < 2 || scope.model.toString().split('.')[1].length < parseInt(
|
|
3818
|
-
scope.model = Number((Number(scope.model)).toFixed(parseInt(
|
|
3819
|
+
if ($scope.model && angular.isDefined($scope.minDecimalsCutZeros) && $scope.type == 'number') {
|
|
3820
|
+
$scope.model = Number($scope.model);
|
|
3821
|
+
if ($scope.model.toString().split('.').length < 2 || $scope.model.toString().split('.')[1].length < parseInt($scope.minDecimalsCutZeros)) {
|
|
3822
|
+
$scope.model = Number((Number($scope.model)).toFixed(parseInt($scope.minDecimalsCutZeros)));
|
|
3819
3823
|
}
|
|
3820
3824
|
}
|
|
3821
3825
|
|
|
3822
|
-
if (angular.isDefined(scope.regex) && scope.regex != '') {
|
|
3823
|
-
scope.regexexp = new RegExp(scope.regex);
|
|
3826
|
+
if (angular.isDefined($scope.regex) && $scope.regex != '') {
|
|
3827
|
+
$scope.regexexp = new RegExp($scope.regex);
|
|
3824
3828
|
}
|
|
3825
3829
|
|
|
3826
|
-
if (angular.isDefined(scope.regexRaw) && scope.regexRaw != '') {
|
|
3827
|
-
scope.regexexp = regexRaw;
|
|
3830
|
+
if (angular.isDefined($scope.regexRaw) && $scope.regexRaw != '') {
|
|
3831
|
+
$scope.regexexp = regexRaw;
|
|
3828
3832
|
}
|
|
3829
3833
|
|
|
3830
|
-
scope.$watch('model', function (value_new, value_old) {
|
|
3831
|
-
scope.
|
|
3834
|
+
$scope.$watch('model', function (value_new, value_old) {
|
|
3835
|
+
if ($scope.type == "number" && value_old && value_old[value_old.length-1] == ".") {
|
|
3836
|
+
|
|
3837
|
+
} else {
|
|
3838
|
+
$scope.internalModel = angular.copy($scope.model);
|
|
3839
|
+
}
|
|
3832
3840
|
|
|
3833
3841
|
// Check if number is positive
|
|
3834
|
-
if (scope.type == "number" && scope.positiveOnly) {
|
|
3835
|
-
scope.forma.$setValidity('positiveOnly', Number(scope.model) >= 0);
|
|
3842
|
+
if ($scope.type == "number" && $scope.positiveOnly) {
|
|
3843
|
+
$scope.forma.$setValidity('positiveOnly', Number($scope.model) >= 0);
|
|
3836
3844
|
}
|
|
3837
3845
|
});
|
|
3838
3846
|
|
|
3839
|
-
scope.$watch('internalModel', function (value_new, value_old) {
|
|
3840
|
-
if (
|
|
3847
|
+
$scope.$watch('internalModel', function (value_new, value_old) {
|
|
3848
|
+
if ($scope.type == "number" && value_new) {
|
|
3841
3849
|
if (typeof value_new != "number") {
|
|
3842
|
-
scope.internalModel = value_new.replace(',', '.');
|
|
3843
|
-
scope.model = angular.copy(scope.internalModel);
|
|
3844
|
-
|
|
3850
|
+
$scope.internalModel = value_new.replace(',', '.');
|
|
3851
|
+
$scope.model = angular.copy($scope.internalModel);
|
|
3852
|
+
$scope.handleChange();
|
|
3845
3853
|
} else {
|
|
3846
|
-
scope.model = angular.copy(scope.internalModel);
|
|
3847
|
-
|
|
3854
|
+
$scope.model = angular.copy($scope.internalModel);
|
|
3855
|
+
$scope.handleChange();
|
|
3848
3856
|
}
|
|
3849
3857
|
} else {
|
|
3850
|
-
scope.model = angular.copy(scope.internalModel);
|
|
3851
|
-
|
|
3858
|
+
$scope.model = angular.copy($scope.internalModel);
|
|
3859
|
+
$scope.handleChange();
|
|
3852
3860
|
}
|
|
3853
3861
|
});
|
|
3854
|
-
},
|
|
3855
3862
|
|
|
3856
|
-
|
|
3863
|
+
$scope.handleChange = function() {
|
|
3864
|
+
if ($scope.onChange) {
|
|
3865
|
+
$timeout(function() {
|
|
3866
|
+
$scope.onChange({ model: $scope.model });
|
|
3867
|
+
})
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3857
3870
|
$scope.id = Math.random().toString(36).substring(7);
|
|
3858
3871
|
|
|
3859
3872
|
// Handle multiple language field if empty
|
|
@@ -5445,7 +5458,7 @@ angular.module('niceElements')
|
|
|
5445
5458
|
}
|
|
5446
5459
|
|
|
5447
5460
|
if ($scope.onChange) $scope.onChange({ model: $scope.model });
|
|
5448
|
-
$scope.
|
|
5461
|
+
$scope.formToggle.$setDirty();
|
|
5449
5462
|
}
|
|
5450
5463
|
};
|
|
5451
5464
|
|
|
@@ -5841,7 +5854,7 @@ angular.module('niceElements')
|
|
|
5841
5854
|
.service('NiceService', function () {
|
|
5842
5855
|
var service = {
|
|
5843
5856
|
name: "Nice elements",
|
|
5844
|
-
version: "1.9.
|
|
5857
|
+
version: "1.9.15",
|
|
5845
5858
|
getHeader: function () {
|
|
5846
5859
|
return {};
|
|
5847
5860
|
}
|