nice-elements 1.9.8 → 1.9.10

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.9.10 (5.12.2023)
4
+
5
+ - fixed default number is null instead of 0
6
+
7
+ ## v1.9.9 (5.12.2023)
8
+
9
+ - changed input internal type to text if type is number,
10
+ - added input modes to nice input,
11
+ - worked on demo page
12
+
13
+ ## v1.9.8 (17.11.2023)
14
+
15
+ -
16
+
3
17
  ## v1.9.7 (26.10.2023)
4
18
 
5
19
  - fixed nice search on update
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Nice elements](https://github.com/Klemen1337/angularjs-nice-elements/raw/master/demo/assets/logo.png)
2
2
 
3
- # Nice elements v1.9.8
3
+ # Nice elements v1.9.10
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.9.8",
3
+ "version": "1.9.10",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -18,7 +18,7 @@ angular.module('niceElements')
18
18
  label: '@'
19
19
  },
20
20
  link: function postLink(scope, element, attrs) {
21
- if (angular.isDefined(scope.model)){
21
+ if (angular.isDefined(scope.model)) {
22
22
  scope.model = false;
23
23
  }
24
24
  }
@@ -655,14 +655,14 @@ angular.module('niceElements')
655
655
  * # clickOutside
656
656
  */
657
657
  angular.module('niceElements')
658
- .directive('clickOutside', function($document, $parse, $timeout){
658
+ .directive('clickOutside', function ($document, $parse, $timeout) {
659
659
  return {
660
660
  restrict: 'A',
661
661
  link: function ($scope, elem, attr) {
662
662
  $scope.isOpen = false;
663
663
 
664
664
  // watch for is open
665
- attr.$observe('isOpen', function(value){
665
+ attr.$observe('isOpen', function (value) {
666
666
  $scope.isOpen = value == 'true';
667
667
  });
668
668
 
@@ -717,7 +717,7 @@ angular.module('niceElements')
717
717
  // if we have got this far, then we are good to go with processing the command passed in via the click-outside attribute
718
718
  $timeout(function () {
719
719
  fn = $parse(attr['clickOutside']);
720
- fn($scope, {event: e});
720
+ fn($scope, { event: e });
721
721
  });
722
722
  }
723
723
  }
@@ -751,7 +751,7 @@ angular.module('niceElements')
751
751
  });
752
752
  }
753
753
  };
754
- });
754
+ });
755
755
  'use strict';
756
756
 
757
757
  /**
@@ -942,7 +942,7 @@ angular.module('niceElements')
942
942
  */
943
943
  angular.module('niceElements')
944
944
 
945
- .directive('niceDateRange', function() {
945
+ .directive('niceDateRange', function () {
946
946
  return {
947
947
  restrict: 'E',
948
948
  transclude: true,
@@ -962,16 +962,16 @@ angular.module('niceElements')
962
962
  onChange: '&?'
963
963
  },
964
964
 
965
- link: function(scope, attrs){
965
+ link: function (scope, attrs) {
966
966
  if (!attrs.title) { attrs.title = ''; }
967
967
  if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
968
968
  if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
969
969
  if (!attrs.format) { attrs.format = 'dd.MM.yyyy'; }
970
970
  attrs.noMargin = angular.isDefined(attrs.noMargin);
971
971
 
972
- if(!angular.isDefined(scope.model)) {
972
+ if (!angular.isDefined(scope.model)) {
973
973
  var model = null;
974
- if(!angular.isDefined(scope.startOfTheYear)){
974
+ if (!angular.isDefined(scope.startOfTheYear)) {
975
975
  model = {
976
976
  startDate: moment().format(),
977
977
  endDate: moment().format()
@@ -987,7 +987,7 @@ angular.module('niceElements')
987
987
  }
988
988
  },
989
989
 
990
- controller: function($scope) {
990
+ controller: function ($scope) {
991
991
  $scope.opts = {
992
992
  locale: {
993
993
  applyClass: 'btn-green',
@@ -1003,7 +1003,7 @@ angular.module('niceElements')
1003
1003
  $scope.opts.ranges[gettextCatalog.getString("Last 30 days", null, "Nice")] = [moment().subtract(30, 'days'), moment()];
1004
1004
  $scope.opts.ranges[gettextCatalog.getString("This month", null, "Nice")] = [moment().startOf('month'), moment().endOf('month')];
1005
1005
 
1006
- if(angular.isDefined($scope.format)) $scope.opts.format = format;
1006
+ if (angular.isDefined($scope.format)) $scope.opts.format = format;
1007
1007
  }
1008
1008
 
1009
1009
  };
@@ -3683,25 +3683,25 @@ angular.module('niceElements')
3683
3683
  };
3684
3684
  });
3685
3685
 
3686
- 'use strict';
3687
-
3688
- /**
3689
- * @ngdoc directive
3690
- * @name niceElements.directive:niceIcon
3691
- * @description
3692
- * # niceIcon
3693
- */
3694
- angular.module('niceElements')
3695
- .directive('niceIcon', function () {
3696
- return {
3697
- templateUrl: 'src/components/nice-icon/nice-icon.html',
3698
- restrict: 'E',
3699
- replace: true,
3700
- scope: {
3701
- icon: '@',
3702
- size: '=',
3703
- },
3704
- };
3686
+ 'use strict';
3687
+
3688
+ /**
3689
+ * @ngdoc directive
3690
+ * @name niceElements.directive:niceIcon
3691
+ * @description
3692
+ * # niceIcon
3693
+ */
3694
+ angular.module('niceElements')
3695
+ .directive('niceIcon', function () {
3696
+ return {
3697
+ templateUrl: 'src/components/nice-icon/nice-icon.html',
3698
+ restrict: 'E',
3699
+ replace: true,
3700
+ scope: {
3701
+ icon: '@',
3702
+ size: '=',
3703
+ },
3704
+ };
3705
3705
  });
3706
3706
  angular.module('niceElements')
3707
3707
  .directive('niceInput', function () {
@@ -3764,6 +3764,7 @@ angular.module('niceElements')
3764
3764
  attrs.textArea = angular.isDefined(attrs.textArea);
3765
3765
  attrs.noMargin = angular.isDefined(attrs.noMargin);
3766
3766
  attrs.required = attrs.required === 'true';
3767
+ scope.inputMode = null;
3767
3768
  //attrs.required = angular.isDefined(attrs.required);
3768
3769
 
3769
3770
  if (!scope.textArea) {
@@ -3777,13 +3778,19 @@ angular.module('niceElements')
3777
3778
  if (input) input.focus();
3778
3779
  }
3779
3780
 
3781
+ if (scope.numbersOnly) {
3782
+ scope.inputMode = "numeric";
3783
+ }
3784
+
3780
3785
  // Set internal type
3781
3786
  scope.internalType = attrs.type;
3782
3787
  if (attrs.type == "percent") {
3783
3788
  scope.internalType = "percent";
3789
+ scope.inputMode = "decimal";
3784
3790
  attrs.symbol = '%';
3785
3791
  } else if (attrs.type == "number") {
3786
- scope.internalType = "number";
3792
+ scope.internalType = "text";
3793
+ scope.inputMode = "decimal";
3787
3794
  if (scope.model) {
3788
3795
  scope.model = Number(scope.model);
3789
3796
  } else {
@@ -3791,8 +3798,10 @@ angular.module('niceElements')
3791
3798
  }
3792
3799
  } else if (attrs.type == "integer") {
3793
3800
  scope.internalType = "text";
3801
+ scope.inputMode = "numeric";
3794
3802
  scope.model = Number(scope.model);
3795
3803
  } else if (attrs.type == "email") {
3804
+ scope.inputMode = "email";
3796
3805
  // TODO: get rid of the errors
3797
3806
  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})');
3798
3807
  }
@@ -3801,7 +3810,7 @@ angular.module('niceElements')
3801
3810
  scope.valid = scope.form;
3802
3811
  }
3803
3812
 
3804
- if (angular.isDefined(attrs.minDecimalsCutZeros) && attrs.type == 'number') {
3813
+ if (scope.model && angular.isDefined(attrs.minDecimalsCutZeros) && attrs.type == 'number') {
3805
3814
  scope.model = Number(scope.model);
3806
3815
  if (scope.model.toString().split('.').length < 2 || scope.model.toString().split('.')[1].length < parseInt(attrs.minDecimalsCutZeros)) {
3807
3816
  scope.model = Number((Number(scope.model)).toFixed(parseInt(attrs.minDecimalsCutZeros)));
@@ -3998,42 +4007,42 @@ angular.module('niceElements')
3998
4007
 
3999
4008
  var messageElements = [];
4000
4009
 
4001
- var notify = function(args, t){
4010
+ var notify = function (args, t) {
4002
4011
 
4003
- if (typeof args !== 'object'){
4004
- args = {message:args};
4012
+ if (typeof args !== 'object') {
4013
+ args = { message: args };
4005
4014
  }
4006
4015
 
4007
4016
  args.template = args.template ? args.template : 'src/components/nice-notification/nice-notification.html';
4008
4017
  args.delay = !angular.isUndefined(args.delay) ? args.delay : delay;
4009
4018
  args.type = t ? t : '';
4010
4019
 
4011
- $http.get(args.template,{cache: $templateCache}).success(function(template) {
4020
+ $http.get(args.template, { cache: $templateCache }).success(function (template) {
4012
4021
 
4013
4022
  var scope = $rootScope.$new();
4014
4023
  scope.message = $sce.trustAsHtml(args.message);
4015
4024
  scope.title = $sce.trustAsHtml(args.title);
4016
- scope.t = args.type.substr(0,1);
4025
+ scope.t = args.type.substr(0, 1);
4017
4026
  scope.delay = args.delay;
4018
4027
 
4019
- if (typeof args.scope === 'object'){
4020
- for (var key in args.scope){
4028
+ if (typeof args.scope === 'object') {
4029
+ for (var key in args.scope) {
4021
4030
  scope[key] = args.scope[key];
4022
4031
  }
4023
4032
  }
4024
4033
 
4025
- var reposite = function() {
4034
+ var reposite = function () {
4026
4035
  var j = 0;
4027
4036
  var k = 0;
4028
4037
  var lastTop = startTop;
4029
4038
  var lastRight = startRight;
4030
- for(var i = messageElements.length - 1; i >= 0; i --) {
4039
+ for (var i = messageElements.length - 1; i >= 0; i--) {
4031
4040
  var element = messageElements[i];
4032
4041
  var elHeight = parseInt(element[0].offsetHeight);
4033
4042
  var elWidth = parseInt(element[0].offsetWidth);
4034
4043
  if ((top + elHeight) > window.innerHeight) {
4035
4044
  lastTop = startTop;
4036
- k ++;
4045
+ k++;
4037
4046
  j = 0;
4038
4047
  }
4039
4048
  var top = lastTop + (j === 0 ? 0 : verticalSpacing);
@@ -4043,22 +4052,22 @@ angular.module('niceElements')
4043
4052
  element.css('right', right + 'px');
4044
4053
 
4045
4054
  lastTop = top + elHeight;
4046
- j ++;
4055
+ j++;
4047
4056
  }
4048
4057
  };
4049
4058
 
4050
4059
  var templateElement = $compile(template)(scope);
4051
4060
  templateElement.addClass(args.type);
4052
- templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function(e){
4061
+ templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
4053
4062
  e = e.originalEvent || e;
4054
- if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)){
4063
+ if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
4055
4064
  templateElement.remove();
4056
4065
  messageElements.splice(messageElements.indexOf(templateElement), 1);
4057
4066
  reposite();
4058
4067
  }
4059
4068
  });
4060
4069
 
4061
- $timeout(function() {
4070
+ $timeout(function () {
4062
4071
  templateElement.addClass('killed');
4063
4072
  templateElement.remove();
4064
4073
  messageElements.splice(messageElements.indexOf(templateElement), 1);
@@ -4070,34 +4079,34 @@ angular.module('niceElements')
4070
4079
 
4071
4080
  $timeout(reposite);
4072
4081
 
4073
- }).error(function(data){
4074
- throw new Error('Template ('+args.template+') could not be loaded. ' + data);
4082
+ }).error(function (data) {
4083
+ throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
4075
4084
  });
4076
4085
 
4077
4086
  };
4078
4087
 
4079
- notify.config = function(args){
4080
- startTop = args.top ? args.top : startTop;
4081
- verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
4088
+ notify.config = function (args) {
4089
+ startTop = args.top ? args.top : startTop;
4090
+ verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
4082
4091
  };
4083
4092
 
4084
- notify.primary = function() {
4093
+ notify.primary = function () {
4085
4094
  this(args, '');
4086
4095
  };
4087
4096
 
4088
- notify.error = function(args) {
4097
+ notify.error = function (args) {
4089
4098
  this(args, 'error');
4090
4099
  };
4091
4100
 
4092
- notify.success = function(args) {
4101
+ notify.success = function (args) {
4093
4102
  this(args, 'success');
4094
4103
  };
4095
4104
 
4096
- notify.info = function(args) {
4105
+ notify.info = function (args) {
4097
4106
  this(args, 'info');
4098
4107
  };
4099
4108
 
4100
- notify.warning = function(args) {
4109
+ notify.warning = function (args) {
4101
4110
  this(args, 'warning');
4102
4111
  };
4103
4112
 
@@ -4528,7 +4537,7 @@ angular.module('niceElements')
4528
4537
  * # niceProgressBar
4529
4538
  */
4530
4539
  angular.module('niceElements')
4531
- .directive('niceProgressBar', function() {
4540
+ .directive('niceProgressBar', function () {
4532
4541
  return {
4533
4542
  restrict: 'E',
4534
4543
  replace: true,
@@ -4543,29 +4552,29 @@ angular.module('niceElements')
4543
4552
  help: '@'
4544
4553
  },
4545
4554
 
4546
- controller: function($scope, $element, $timeout) {
4555
+ controller: function ($scope, $element, $timeout) {
4547
4556
  $scope.width = 0;
4548
- $scope.resize = function(){
4549
- $timeout(function() {
4557
+ $scope.resize = function () {
4558
+ $timeout(function () {
4550
4559
  $scope.width = $element[0].getElementsByClassName("progress")[0].offsetWidth;
4551
- },100);
4560
+ }, 100);
4552
4561
  };
4553
- window.onresize = function() {
4562
+ window.onresize = function () {
4554
4563
  $scope.resize();
4555
4564
  };
4556
4565
  $scope.resize();
4557
4566
 
4558
-
4559
4567
 
4560
- $scope.$watch("value", function(valueNew, valueOld){
4568
+
4569
+ $scope.$watch("value", function (valueNew, valueOld) {
4561
4570
  $scope.calculate();
4562
4571
  });
4563
4572
 
4564
- $scope.$watch("max", function(valueNew, valueOld){
4573
+ $scope.$watch("max", function (valueNew, valueOld) {
4565
4574
  $scope.calculate();
4566
4575
  });
4567
4576
 
4568
- $scope.calculate = function(){
4577
+ $scope.calculate = function () {
4569
4578
  $scope.percentage = ($scope.value / $scope.max) * 100;
4570
4579
  };
4571
4580
 
@@ -5696,24 +5705,24 @@ angular.module('niceElements')
5696
5705
  isInline: '=',
5697
5706
  help: '@'
5698
5707
  },
5699
- controller: function($scope, gettextCatalog) {
5708
+ controller: function ($scope, gettextCatalog) {
5700
5709
  if (!$scope.yes) { $scope.yes = gettextCatalog.getString('Yes', null, "Nice"); }
5701
5710
  if (!$scope.no) { $scope.no = gettextCatalog.getString('No', null, "Nice"); }
5702
5711
  if (!$scope.title) { $scope.title = ''; }
5703
5712
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
5704
5713
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
5705
- if(!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
5706
- if(!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
5714
+ if (!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
5715
+ if (!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
5707
5716
 
5708
5717
  $scope.defaultFalse = angular.isDefined($scope.defaultFalse);
5709
5718
  $scope.noMargin = angular.isDefined($scope.noMargin);
5710
5719
 
5711
5720
  $scope.buttonClass = "";
5712
-
5721
+
5713
5722
 
5714
5723
  // ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
5715
- $scope.setButtonPosition = function(state) {
5716
- if(state) {
5724
+ $scope.setButtonPosition = function (state) {
5725
+ if (state) {
5717
5726
  $scope.buttonClass = "yesno-button-yes";
5718
5727
  } else {
5719
5728
  $scope.buttonClass = "yesno-button-no";
@@ -5721,48 +5730,48 @@ angular.module('niceElements')
5721
5730
  };
5722
5731
 
5723
5732
  // ------------------------- Watch for changes from outside -------------------------
5724
- $scope.$watch('model', function(value_new, value_old){
5725
- if(angular.isDefined($scope.model)){
5733
+ $scope.$watch('model', function (value_new, value_old) {
5734
+ if (angular.isDefined($scope.model)) {
5726
5735
  $scope.setButtonLabel($scope.model);
5727
5736
  $scope.setButtonPosition($scope.model);
5728
5737
  }
5729
5738
  });
5730
5739
 
5731
5740
  // ------------------------- Watch for model value -------------------------
5732
- $scope.$watch('modelValue', function(value_new, value_old){
5733
- if($scope.options){
5741
+ $scope.$watch('modelValue', function (value_new, value_old) {
5742
+ if ($scope.options) {
5734
5743
  $scope.model = $scope.modelValue == $scope.options[0];
5735
5744
  }
5736
5745
  });
5737
5746
 
5738
5747
  // ------------------------- Set button label -------------------------
5739
- $scope.setButtonLabel = function(state){
5748
+ $scope.setButtonLabel = function (state) {
5740
5749
  if (state) {
5741
5750
  $scope.state = $scope.yes;
5742
5751
  } else {
5743
5752
  $scope.state = $scope.no;
5744
5753
  }
5745
5754
  };
5746
-
5755
+
5747
5756
  // ------------------------- Set width -------------------------
5748
- $scope.setWidth = function(width, el){
5757
+ $scope.setWidth = function (width, el) {
5749
5758
  el.style.width = width;
5750
5759
  };
5751
-
5760
+
5752
5761
 
5753
5762
  // ------------------------- Switch -------------------------
5754
- $scope.switch = function(){
5755
- if(!$scope.isDisabled){
5763
+ $scope.switch = function () {
5764
+ if (!$scope.isDisabled) {
5756
5765
  $scope.model = !$scope.model;
5757
-
5758
- if($scope.options){
5759
- if($scope.model){
5766
+
5767
+ if ($scope.options) {
5768
+ if ($scope.model) {
5760
5769
  $scope.modelValue = $scope.options[0];
5761
5770
  } else {
5762
5771
  $scope.modelValue = $scope.options[1];
5763
5772
  }
5764
5773
  }
5765
-
5774
+
5766
5775
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
5767
5776
  $scope.formYesno.$setDirty();
5768
5777
  }
@@ -5824,7 +5833,7 @@ angular.module('niceElements')
5824
5833
  .service('NiceService', function () {
5825
5834
  var service = {
5826
5835
  name: "Nice elements",
5827
- version: "1.9.8",
5836
+ version: "1.9.10",
5828
5837
  getHeader: function () {
5829
5838
  return {};
5830
5839
  }
@@ -5900,7 +5909,7 @@ angular.module('niceElements')
5900
5909
  };
5901
5910
  });
5902
5911
 
5903
- angular.module('niceElements').run(['$templateCache', function($templateCache) {
5912
+ angular.module('niceElements').run(['$templateCache', function ($templateCache) {
5904
5913
  'use strict';
5905
5914
 
5906
5915
  $templateCache.put('src/components/nice-button-toggle/nice-button-toggle.html',
@@ -6519,7 +6528,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6519
6528
  " 'nice-disabled': isDisabled\n" +
6520
6529
  " }\">\n" +
6521
6530
  "<textarea ng-if=\"textArea\" class=\"form-control\" ng-model=\"$parent.model\" id=\"{{ id }}\" tabindex=\"{{ tabIndex }}\" placeholder=\"{{ placeholder }}\" rows=\"{{textAreaLines}}\" max=\"{{ max }}\" min=\"{{ min }}\" ng-minlength=\"minlength\" ng-maxlength=\"maxlength\" ng-required=\"required\" ng-pattern=\"regexexp\" ng-disabled=\"isDisabled\"></textarea>\n" +
6522
- "<input ng-if=\"!textArea\" class=\"form-control\" type=\"{{ internalType }}\" ng-model=\"$parent.model\" name=\"{{ name }}\" id=\"{{ id }}\" tabindex=\"{{ tabIndex }}\" placeholder=\"{{ placeholder }}\" max=\"{{ max }}\" min=\"{{ min }}\" ng-minlength=\"minlength\" ng-maxlength=\"maxlength\" ng-required=\"required\" ng-keypress=\"keypress($event)\" ng-pattern=\"regexexp\" ng-disabled=\"isDisabled\">\n" +
6531
+ "<input ng-if=\"!textArea\" class=\"form-control\" type=\"{{ internalType }}\" inputmode=\"{{ inputMode }}\" ng-model=\"$parent.model\" name=\"{{ name }}\" id=\"{{ id }}\" tabindex=\"{{ tabIndex }}\" placeholder=\"{{ placeholder }}\" max=\"{{ max }}\" min=\"{{ min }}\" ng-minlength=\"minlength\" ng-maxlength=\"maxlength\" ng-required=\"required\" ng-keypress=\"keypress($event)\" ng-pattern=\"regexexp\" ng-disabled=\"isDisabled\">\n" +
6523
6532
  "<div class=\"input-group-addon\" ng-if=\"symbol\">{{ symbol }}</div>\n" +
6524
6533
  "<button class=\"input-group-btn\" ng-if=\"multilanguageField\" ng-click=\"openMultilanguage()\">\n" +
6525
6534
  "<nice-icon icon=\"icon-translate\"></nice-icon>\n" +