nice-elements 1.9.9 → 1.9.11

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.9.11 (7.12.2023)
4
+
5
+ - fixed nice input model default 0
6
+
7
+ ## v1.9.10 (5.12.2023)
8
+
9
+ - fixed default number is null instead of 0
10
+
3
11
  ## v1.9.9 (5.12.2023)
4
12
 
5
13
  - changed input internal type to text if type is number,
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.9
3
+ # Nice elements v1.9.11
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.9",
3
+ "version": "1.9.11",
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 () {
@@ -3791,7 +3791,7 @@ angular.module('niceElements')
3791
3791
  } else if (attrs.type == "number") {
3792
3792
  scope.internalType = "text";
3793
3793
  scope.inputMode = "decimal";
3794
- if (scope.model) {
3794
+ if (scope.model != null) {
3795
3795
  scope.model = Number(scope.model);
3796
3796
  } else {
3797
3797
  scope.model = null;
@@ -3810,7 +3810,7 @@ angular.module('niceElements')
3810
3810
  scope.valid = scope.form;
3811
3811
  }
3812
3812
 
3813
- if (angular.isDefined(attrs.minDecimalsCutZeros) && attrs.type == 'number') {
3813
+ if (scope.model && angular.isDefined(attrs.minDecimalsCutZeros) && attrs.type == 'number') {
3814
3814
  scope.model = Number(scope.model);
3815
3815
  if (scope.model.toString().split('.').length < 2 || scope.model.toString().split('.')[1].length < parseInt(attrs.minDecimalsCutZeros)) {
3816
3816
  scope.model = Number((Number(scope.model)).toFixed(parseInt(attrs.minDecimalsCutZeros)));
@@ -4007,42 +4007,42 @@ angular.module('niceElements')
4007
4007
 
4008
4008
  var messageElements = [];
4009
4009
 
4010
- var notify = function(args, t){
4010
+ var notify = function (args, t) {
4011
4011
 
4012
- if (typeof args !== 'object'){
4013
- args = {message:args};
4012
+ if (typeof args !== 'object') {
4013
+ args = { message: args };
4014
4014
  }
4015
4015
 
4016
4016
  args.template = args.template ? args.template : 'src/components/nice-notification/nice-notification.html';
4017
4017
  args.delay = !angular.isUndefined(args.delay) ? args.delay : delay;
4018
4018
  args.type = t ? t : '';
4019
4019
 
4020
- $http.get(args.template,{cache: $templateCache}).success(function(template) {
4020
+ $http.get(args.template, { cache: $templateCache }).success(function (template) {
4021
4021
 
4022
4022
  var scope = $rootScope.$new();
4023
4023
  scope.message = $sce.trustAsHtml(args.message);
4024
4024
  scope.title = $sce.trustAsHtml(args.title);
4025
- scope.t = args.type.substr(0,1);
4025
+ scope.t = args.type.substr(0, 1);
4026
4026
  scope.delay = args.delay;
4027
4027
 
4028
- if (typeof args.scope === 'object'){
4029
- for (var key in args.scope){
4028
+ if (typeof args.scope === 'object') {
4029
+ for (var key in args.scope) {
4030
4030
  scope[key] = args.scope[key];
4031
4031
  }
4032
4032
  }
4033
4033
 
4034
- var reposite = function() {
4034
+ var reposite = function () {
4035
4035
  var j = 0;
4036
4036
  var k = 0;
4037
4037
  var lastTop = startTop;
4038
4038
  var lastRight = startRight;
4039
- for(var i = messageElements.length - 1; i >= 0; i --) {
4039
+ for (var i = messageElements.length - 1; i >= 0; i--) {
4040
4040
  var element = messageElements[i];
4041
4041
  var elHeight = parseInt(element[0].offsetHeight);
4042
4042
  var elWidth = parseInt(element[0].offsetWidth);
4043
4043
  if ((top + elHeight) > window.innerHeight) {
4044
4044
  lastTop = startTop;
4045
- k ++;
4045
+ k++;
4046
4046
  j = 0;
4047
4047
  }
4048
4048
  var top = lastTop + (j === 0 ? 0 : verticalSpacing);
@@ -4052,22 +4052,22 @@ angular.module('niceElements')
4052
4052
  element.css('right', right + 'px');
4053
4053
 
4054
4054
  lastTop = top + elHeight;
4055
- j ++;
4055
+ j++;
4056
4056
  }
4057
4057
  };
4058
4058
 
4059
4059
  var templateElement = $compile(template)(scope);
4060
4060
  templateElement.addClass(args.type);
4061
- templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function(e){
4061
+ templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
4062
4062
  e = e.originalEvent || e;
4063
- if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)){
4063
+ if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
4064
4064
  templateElement.remove();
4065
4065
  messageElements.splice(messageElements.indexOf(templateElement), 1);
4066
4066
  reposite();
4067
4067
  }
4068
4068
  });
4069
4069
 
4070
- $timeout(function() {
4070
+ $timeout(function () {
4071
4071
  templateElement.addClass('killed');
4072
4072
  templateElement.remove();
4073
4073
  messageElements.splice(messageElements.indexOf(templateElement), 1);
@@ -4079,34 +4079,34 @@ angular.module('niceElements')
4079
4079
 
4080
4080
  $timeout(reposite);
4081
4081
 
4082
- }).error(function(data){
4083
- 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);
4084
4084
  });
4085
4085
 
4086
4086
  };
4087
4087
 
4088
- notify.config = function(args){
4089
- startTop = args.top ? args.top : startTop;
4090
- 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;
4091
4091
  };
4092
4092
 
4093
- notify.primary = function() {
4093
+ notify.primary = function () {
4094
4094
  this(args, '');
4095
4095
  };
4096
4096
 
4097
- notify.error = function(args) {
4097
+ notify.error = function (args) {
4098
4098
  this(args, 'error');
4099
4099
  };
4100
4100
 
4101
- notify.success = function(args) {
4101
+ notify.success = function (args) {
4102
4102
  this(args, 'success');
4103
4103
  };
4104
4104
 
4105
- notify.info = function(args) {
4105
+ notify.info = function (args) {
4106
4106
  this(args, 'info');
4107
4107
  };
4108
4108
 
4109
- notify.warning = function(args) {
4109
+ notify.warning = function (args) {
4110
4110
  this(args, 'warning');
4111
4111
  };
4112
4112
 
@@ -4537,7 +4537,7 @@ angular.module('niceElements')
4537
4537
  * # niceProgressBar
4538
4538
  */
4539
4539
  angular.module('niceElements')
4540
- .directive('niceProgressBar', function() {
4540
+ .directive('niceProgressBar', function () {
4541
4541
  return {
4542
4542
  restrict: 'E',
4543
4543
  replace: true,
@@ -4552,29 +4552,29 @@ angular.module('niceElements')
4552
4552
  help: '@'
4553
4553
  },
4554
4554
 
4555
- controller: function($scope, $element, $timeout) {
4555
+ controller: function ($scope, $element, $timeout) {
4556
4556
  $scope.width = 0;
4557
- $scope.resize = function(){
4558
- $timeout(function() {
4557
+ $scope.resize = function () {
4558
+ $timeout(function () {
4559
4559
  $scope.width = $element[0].getElementsByClassName("progress")[0].offsetWidth;
4560
- },100);
4560
+ }, 100);
4561
4561
  };
4562
- window.onresize = function() {
4562
+ window.onresize = function () {
4563
4563
  $scope.resize();
4564
4564
  };
4565
4565
  $scope.resize();
4566
4566
 
4567
-
4568
4567
 
4569
- $scope.$watch("value", function(valueNew, valueOld){
4568
+
4569
+ $scope.$watch("value", function (valueNew, valueOld) {
4570
4570
  $scope.calculate();
4571
4571
  });
4572
4572
 
4573
- $scope.$watch("max", function(valueNew, valueOld){
4573
+ $scope.$watch("max", function (valueNew, valueOld) {
4574
4574
  $scope.calculate();
4575
4575
  });
4576
4576
 
4577
- $scope.calculate = function(){
4577
+ $scope.calculate = function () {
4578
4578
  $scope.percentage = ($scope.value / $scope.max) * 100;
4579
4579
  };
4580
4580
 
@@ -5705,24 +5705,24 @@ angular.module('niceElements')
5705
5705
  isInline: '=',
5706
5706
  help: '@'
5707
5707
  },
5708
- controller: function($scope, gettextCatalog) {
5708
+ controller: function ($scope, gettextCatalog) {
5709
5709
  if (!$scope.yes) { $scope.yes = gettextCatalog.getString('Yes', null, "Nice"); }
5710
5710
  if (!$scope.no) { $scope.no = gettextCatalog.getString('No', null, "Nice"); }
5711
5711
  if (!$scope.title) { $scope.title = ''; }
5712
5712
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
5713
5713
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
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];
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];
5716
5716
 
5717
5717
  $scope.defaultFalse = angular.isDefined($scope.defaultFalse);
5718
5718
  $scope.noMargin = angular.isDefined($scope.noMargin);
5719
5719
 
5720
5720
  $scope.buttonClass = "";
5721
-
5721
+
5722
5722
 
5723
5723
  // ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
5724
- $scope.setButtonPosition = function(state) {
5725
- if(state) {
5724
+ $scope.setButtonPosition = function (state) {
5725
+ if (state) {
5726
5726
  $scope.buttonClass = "yesno-button-yes";
5727
5727
  } else {
5728
5728
  $scope.buttonClass = "yesno-button-no";
@@ -5730,48 +5730,48 @@ angular.module('niceElements')
5730
5730
  };
5731
5731
 
5732
5732
  // ------------------------- Watch for changes from outside -------------------------
5733
- $scope.$watch('model', function(value_new, value_old){
5734
- if(angular.isDefined($scope.model)){
5733
+ $scope.$watch('model', function (value_new, value_old) {
5734
+ if (angular.isDefined($scope.model)) {
5735
5735
  $scope.setButtonLabel($scope.model);
5736
5736
  $scope.setButtonPosition($scope.model);
5737
5737
  }
5738
5738
  });
5739
5739
 
5740
5740
  // ------------------------- Watch for model value -------------------------
5741
- $scope.$watch('modelValue', function(value_new, value_old){
5742
- if($scope.options){
5741
+ $scope.$watch('modelValue', function (value_new, value_old) {
5742
+ if ($scope.options) {
5743
5743
  $scope.model = $scope.modelValue == $scope.options[0];
5744
5744
  }
5745
5745
  });
5746
5746
 
5747
5747
  // ------------------------- Set button label -------------------------
5748
- $scope.setButtonLabel = function(state){
5748
+ $scope.setButtonLabel = function (state) {
5749
5749
  if (state) {
5750
5750
  $scope.state = $scope.yes;
5751
5751
  } else {
5752
5752
  $scope.state = $scope.no;
5753
5753
  }
5754
5754
  };
5755
-
5755
+
5756
5756
  // ------------------------- Set width -------------------------
5757
- $scope.setWidth = function(width, el){
5757
+ $scope.setWidth = function (width, el) {
5758
5758
  el.style.width = width;
5759
5759
  };
5760
-
5760
+
5761
5761
 
5762
5762
  // ------------------------- Switch -------------------------
5763
- $scope.switch = function(){
5764
- if(!$scope.isDisabled){
5763
+ $scope.switch = function () {
5764
+ if (!$scope.isDisabled) {
5765
5765
  $scope.model = !$scope.model;
5766
-
5767
- if($scope.options){
5768
- if($scope.model){
5766
+
5767
+ if ($scope.options) {
5768
+ if ($scope.model) {
5769
5769
  $scope.modelValue = $scope.options[0];
5770
5770
  } else {
5771
5771
  $scope.modelValue = $scope.options[1];
5772
5772
  }
5773
5773
  }
5774
-
5774
+
5775
5775
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
5776
5776
  $scope.formYesno.$setDirty();
5777
5777
  }
@@ -5833,7 +5833,7 @@ angular.module('niceElements')
5833
5833
  .service('NiceService', function () {
5834
5834
  var service = {
5835
5835
  name: "Nice elements",
5836
- version: "1.9.9",
5836
+ version: "1.9.11",
5837
5837
  getHeader: function () {
5838
5838
  return {};
5839
5839
  }
@@ -5909,7 +5909,7 @@ angular.module('niceElements')
5909
5909
  };
5910
5910
  });
5911
5911
 
5912
- angular.module('niceElements').run(['$templateCache', function($templateCache) {
5912
+ angular.module('niceElements').run(['$templateCache', function ($templateCache) {
5913
5913
  'use strict';
5914
5914
 
5915
5915
  $templateCache.put('src/components/nice-button-toggle/nice-button-toggle.html',