nice-elements 1.9.4 → 1.9.6

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.6 (26.10.2023)
4
+
5
+ - added no search prop to nice dropdown
6
+
7
+ ## v1.9.5 (22.9.2023)
8
+
9
+ - fixed multiple select key only in nice dropdown
10
+
3
11
  ## v1.9.4 (19.9.2023)
4
12
 
5
13
  - added select all and none button for multiple dropdown select,
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.4
3
+ # Nice elements v1.9.6
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.4",
3
+ "version": "1.9.6",
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
  };
@@ -2345,6 +2345,7 @@ angular.module('niceElements')
2345
2345
  noDataText: '@',
2346
2346
  selectText: '@',
2347
2347
  searchText: '@',
2348
+ noSearch: '=',
2348
2349
  nullableText: '@',
2349
2350
  selectedText: '@',
2350
2351
  dropdownDistance: '@',
@@ -2626,19 +2627,21 @@ angular.module('niceElements')
2626
2627
 
2627
2628
  if ($scope.selected != null) {
2628
2629
  // Remove selected flag
2629
- if ($scope.multiple) {
2630
- angular.forEach(obj, function (o) {
2631
- o._selected = undefined;
2632
- });
2633
- } else {
2634
- obj._selected = undefined;
2630
+ if (!$scope.selectedIsKey) {
2631
+ if ($scope.multiple) {
2632
+ angular.forEach(obj, function (o) {
2633
+ o._selected = undefined;
2634
+ });
2635
+ } else {
2636
+ obj._selected = undefined;
2637
+ }
2635
2638
  }
2636
2639
 
2637
2640
  // Selected is object
2638
2641
  if ($scope.selectedIsKey) {
2639
2642
  if ($scope.multiple) {
2640
- angular.forEach(obj, function (o) {
2641
- o = o[$scope.objKey];
2643
+ obj = obj.map(function (o) {
2644
+ return o[$scope.objKey];
2642
2645
  });
2643
2646
  } else {
2644
2647
  obj = obj[$scope.objKey];
@@ -2691,10 +2694,11 @@ angular.module('niceElements')
2691
2694
  // Not object
2692
2695
  if ($scope.multiple) {
2693
2696
  // Multiple
2694
- angular.forEach($scope.selected, function (s) {
2697
+ angular.forEach($scope.selected, function (s, index) {
2695
2698
  if (i[$scope.objKey] == s) {
2696
2699
  i._selected = true;
2697
2700
  // $scope.selected.push(i);
2701
+ $scope.selected[index] = i
2698
2702
  // $scope.selectedIndex = index;
2699
2703
  }
2700
2704
  });
@@ -3679,25 +3683,25 @@ angular.module('niceElements')
3679
3683
  };
3680
3684
  });
3681
3685
 
3682
- 'use strict';
3683
-
3684
- /**
3685
- * @ngdoc directive
3686
- * @name niceElements.directive:niceIcon
3687
- * @description
3688
- * # niceIcon
3689
- */
3690
- angular.module('niceElements')
3691
- .directive('niceIcon', function () {
3692
- return {
3693
- templateUrl: 'src/components/nice-icon/nice-icon.html',
3694
- restrict: 'E',
3695
- replace: true,
3696
- scope: {
3697
- icon: '@',
3698
- size: '=',
3699
- },
3700
- };
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
+ };
3701
3705
  });
3702
3706
  angular.module('niceElements')
3703
3707
  .directive('niceInput', function () {
@@ -3994,42 +3998,42 @@ angular.module('niceElements')
3994
3998
 
3995
3999
  var messageElements = [];
3996
4000
 
3997
- var notify = function (args, t) {
4001
+ var notify = function(args, t){
3998
4002
 
3999
- if (typeof args !== 'object') {
4000
- args = { message: args };
4003
+ if (typeof args !== 'object'){
4004
+ args = {message:args};
4001
4005
  }
4002
4006
 
4003
4007
  args.template = args.template ? args.template : 'src/components/nice-notification/nice-notification.html';
4004
4008
  args.delay = !angular.isUndefined(args.delay) ? args.delay : delay;
4005
4009
  args.type = t ? t : '';
4006
4010
 
4007
- $http.get(args.template, { cache: $templateCache }).success(function (template) {
4011
+ $http.get(args.template,{cache: $templateCache}).success(function(template) {
4008
4012
 
4009
4013
  var scope = $rootScope.$new();
4010
4014
  scope.message = $sce.trustAsHtml(args.message);
4011
4015
  scope.title = $sce.trustAsHtml(args.title);
4012
- scope.t = args.type.substr(0, 1);
4016
+ scope.t = args.type.substr(0,1);
4013
4017
  scope.delay = args.delay;
4014
4018
 
4015
- if (typeof args.scope === 'object') {
4016
- for (var key in args.scope) {
4019
+ if (typeof args.scope === 'object'){
4020
+ for (var key in args.scope){
4017
4021
  scope[key] = args.scope[key];
4018
4022
  }
4019
4023
  }
4020
4024
 
4021
- var reposite = function () {
4025
+ var reposite = function() {
4022
4026
  var j = 0;
4023
4027
  var k = 0;
4024
4028
  var lastTop = startTop;
4025
4029
  var lastRight = startRight;
4026
- for (var i = messageElements.length - 1; i >= 0; i--) {
4030
+ for(var i = messageElements.length - 1; i >= 0; i --) {
4027
4031
  var element = messageElements[i];
4028
4032
  var elHeight = parseInt(element[0].offsetHeight);
4029
4033
  var elWidth = parseInt(element[0].offsetWidth);
4030
4034
  if ((top + elHeight) > window.innerHeight) {
4031
4035
  lastTop = startTop;
4032
- k++;
4036
+ k ++;
4033
4037
  j = 0;
4034
4038
  }
4035
4039
  var top = lastTop + (j === 0 ? 0 : verticalSpacing);
@@ -4039,22 +4043,22 @@ angular.module('niceElements')
4039
4043
  element.css('right', right + 'px');
4040
4044
 
4041
4045
  lastTop = top + elHeight;
4042
- j++;
4046
+ j ++;
4043
4047
  }
4044
4048
  };
4045
4049
 
4046
4050
  var templateElement = $compile(template)(scope);
4047
4051
  templateElement.addClass(args.type);
4048
- templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
4052
+ templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function(e){
4049
4053
  e = e.originalEvent || e;
4050
- if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
4054
+ if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)){
4051
4055
  templateElement.remove();
4052
4056
  messageElements.splice(messageElements.indexOf(templateElement), 1);
4053
4057
  reposite();
4054
4058
  }
4055
4059
  });
4056
4060
 
4057
- $timeout(function () {
4061
+ $timeout(function() {
4058
4062
  templateElement.addClass('killed');
4059
4063
  templateElement.remove();
4060
4064
  messageElements.splice(messageElements.indexOf(templateElement), 1);
@@ -4066,34 +4070,34 @@ angular.module('niceElements')
4066
4070
 
4067
4071
  $timeout(reposite);
4068
4072
 
4069
- }).error(function (data) {
4070
- throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
4073
+ }).error(function(data){
4074
+ throw new Error('Template ('+args.template+') could not be loaded. ' + data);
4071
4075
  });
4072
4076
 
4073
4077
  };
4074
4078
 
4075
- notify.config = function (args) {
4076
- startTop = args.top ? args.top : startTop;
4077
- verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
4079
+ notify.config = function(args){
4080
+ startTop = args.top ? args.top : startTop;
4081
+ verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
4078
4082
  };
4079
4083
 
4080
- notify.primary = function () {
4084
+ notify.primary = function() {
4081
4085
  this(args, '');
4082
4086
  };
4083
4087
 
4084
- notify.error = function (args) {
4088
+ notify.error = function(args) {
4085
4089
  this(args, 'error');
4086
4090
  };
4087
4091
 
4088
- notify.success = function (args) {
4092
+ notify.success = function(args) {
4089
4093
  this(args, 'success');
4090
4094
  };
4091
4095
 
4092
- notify.info = function (args) {
4096
+ notify.info = function(args) {
4093
4097
  this(args, 'info');
4094
4098
  };
4095
4099
 
4096
- notify.warning = function (args) {
4100
+ notify.warning = function(args) {
4097
4101
  this(args, 'warning');
4098
4102
  };
4099
4103
 
@@ -4524,7 +4528,7 @@ angular.module('niceElements')
4524
4528
  * # niceProgressBar
4525
4529
  */
4526
4530
  angular.module('niceElements')
4527
- .directive('niceProgressBar', function () {
4531
+ .directive('niceProgressBar', function() {
4528
4532
  return {
4529
4533
  restrict: 'E',
4530
4534
  replace: true,
@@ -4539,29 +4543,29 @@ angular.module('niceElements')
4539
4543
  help: '@'
4540
4544
  },
4541
4545
 
4542
- controller: function ($scope, $element, $timeout) {
4546
+ controller: function($scope, $element, $timeout) {
4543
4547
  $scope.width = 0;
4544
- $scope.resize = function () {
4545
- $timeout(function () {
4548
+ $scope.resize = function(){
4549
+ $timeout(function() {
4546
4550
  $scope.width = $element[0].getElementsByClassName("progress")[0].offsetWidth;
4547
- }, 100);
4551
+ },100);
4548
4552
  };
4549
- window.onresize = function () {
4553
+ window.onresize = function() {
4550
4554
  $scope.resize();
4551
4555
  };
4552
4556
  $scope.resize();
4553
4557
 
4558
+
4554
4559
 
4555
-
4556
- $scope.$watch("value", function (valueNew, valueOld) {
4560
+ $scope.$watch("value", function(valueNew, valueOld){
4557
4561
  $scope.calculate();
4558
4562
  });
4559
4563
 
4560
- $scope.$watch("max", function (valueNew, valueOld) {
4564
+ $scope.$watch("max", function(valueNew, valueOld){
4561
4565
  $scope.calculate();
4562
4566
  });
4563
4567
 
4564
- $scope.calculate = function () {
4568
+ $scope.calculate = function(){
4565
4569
  $scope.percentage = ($scope.value / $scope.max) * 100;
4566
4570
  };
4567
4571
 
@@ -5594,24 +5598,24 @@ angular.module('niceElements')
5594
5598
  isInline: '=',
5595
5599
  help: '@'
5596
5600
  },
5597
- controller: function ($scope, gettextCatalog) {
5601
+ controller: function($scope, gettextCatalog) {
5598
5602
  if (!$scope.yes) { $scope.yes = gettextCatalog.getString('Yes', null, "Nice"); }
5599
5603
  if (!$scope.no) { $scope.no = gettextCatalog.getString('No', null, "Nice"); }
5600
5604
  if (!$scope.title) { $scope.title = ''; }
5601
5605
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
5602
5606
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
5603
- if (!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
5604
- if (!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
5607
+ if(!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
5608
+ if(!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
5605
5609
 
5606
5610
  $scope.defaultFalse = angular.isDefined($scope.defaultFalse);
5607
5611
  $scope.noMargin = angular.isDefined($scope.noMargin);
5608
5612
 
5609
5613
  $scope.buttonClass = "";
5610
-
5614
+
5611
5615
 
5612
5616
  // ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
5613
- $scope.setButtonPosition = function (state) {
5614
- if (state) {
5617
+ $scope.setButtonPosition = function(state) {
5618
+ if(state) {
5615
5619
  $scope.buttonClass = "yesno-button-yes";
5616
5620
  } else {
5617
5621
  $scope.buttonClass = "yesno-button-no";
@@ -5619,48 +5623,48 @@ angular.module('niceElements')
5619
5623
  };
5620
5624
 
5621
5625
  // ------------------------- Watch for changes from outside -------------------------
5622
- $scope.$watch('model', function (value_new, value_old) {
5623
- if (angular.isDefined($scope.model)) {
5626
+ $scope.$watch('model', function(value_new, value_old){
5627
+ if(angular.isDefined($scope.model)){
5624
5628
  $scope.setButtonLabel($scope.model);
5625
5629
  $scope.setButtonPosition($scope.model);
5626
5630
  }
5627
5631
  });
5628
5632
 
5629
5633
  // ------------------------- Watch for model value -------------------------
5630
- $scope.$watch('modelValue', function (value_new, value_old) {
5631
- if ($scope.options) {
5634
+ $scope.$watch('modelValue', function(value_new, value_old){
5635
+ if($scope.options){
5632
5636
  $scope.model = $scope.modelValue == $scope.options[0];
5633
5637
  }
5634
5638
  });
5635
5639
 
5636
5640
  // ------------------------- Set button label -------------------------
5637
- $scope.setButtonLabel = function (state) {
5641
+ $scope.setButtonLabel = function(state){
5638
5642
  if (state) {
5639
5643
  $scope.state = $scope.yes;
5640
5644
  } else {
5641
5645
  $scope.state = $scope.no;
5642
5646
  }
5643
5647
  };
5644
-
5648
+
5645
5649
  // ------------------------- Set width -------------------------
5646
- $scope.setWidth = function (width, el) {
5650
+ $scope.setWidth = function(width, el){
5647
5651
  el.style.width = width;
5648
5652
  };
5649
-
5653
+
5650
5654
 
5651
5655
  // ------------------------- Switch -------------------------
5652
- $scope.switch = function () {
5653
- if (!$scope.isDisabled) {
5656
+ $scope.switch = function(){
5657
+ if(!$scope.isDisabled){
5654
5658
  $scope.model = !$scope.model;
5655
-
5656
- if ($scope.options) {
5657
- if ($scope.model) {
5659
+
5660
+ if($scope.options){
5661
+ if($scope.model){
5658
5662
  $scope.modelValue = $scope.options[0];
5659
5663
  } else {
5660
5664
  $scope.modelValue = $scope.options[1];
5661
5665
  }
5662
5666
  }
5663
-
5667
+
5664
5668
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
5665
5669
  $scope.formYesno.$setDirty();
5666
5670
  }
@@ -5722,7 +5726,7 @@ angular.module('niceElements')
5722
5726
  .service('NiceService', function () {
5723
5727
  var service = {
5724
5728
  name: "Nice elements",
5725
- version: "1.9.4",
5729
+ version: "1.9.5",
5726
5730
  getHeader: function () {
5727
5731
  return {};
5728
5732
  }
@@ -5798,7 +5802,7 @@ angular.module('niceElements')
5798
5802
  };
5799
5803
  });
5800
5804
 
5801
- angular.module('niceElements').run(['$templateCache', function ($templateCache) {
5805
+ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5802
5806
  'use strict';
5803
5807
 
5804
5808
  $templateCache.put('src/components/nice-button-toggle/nice-button-toggle.html',
@@ -6265,7 +6269,7 @@ angular.module('niceElements').run(['$templateCache', function ($templateCache)
6265
6269
  "</button>\n" +
6266
6270
  "<div class=\"nice-dropdown-menu-wrapper\">\n" +
6267
6271
  "<div class=\"nice-dropdown-menu\" ng-if=\"isOpen\">\n" +
6268
- "<div class=\"search-bar\" ng-if=\"searchFunction\">\n" +
6272
+ "<div class=\"search-bar\" ng-if=\"!noSearch && searchFunction\">\n" +
6269
6273
  "<input ng-model=\"internal.search\" ng-model-options=\"{ debounce: 500 }\" ng-change=\"handleSearch()\" placeholder=\"{{ searchText }}\">\n" +
6270
6274
  "<div class=\"count\" ng-if=\"internalList && internalList._metadata && enableLoadMore\">{{ internalList.length }}/{{ internalList._metadata.count }}</div>\n" +
6271
6275
  "<nice-icon ng-if=\"!internal.search\" class=\"icon\" icon=\"icon-search\"></nice-icon>\n" +
@@ -6273,11 +6277,11 @@ angular.module('niceElements').run(['$templateCache', function ($templateCache)
6273
6277
  "</div>\n" +
6274
6278
  "<div class=\"nice-dropdown-actions\" ng-if=\"multiple\">\n" +
6275
6279
  "<button class=\"btn btn-default btn-sm\" ng-click=\"selectAll()\" translate translate-context=\"Nice\">All</button>\n" +
6276
- "<button class=\"btn btn-default btn-sm\" ng-click=\"selectNone()\" translate translate-context=\"Nice\">None</button>\n" +
6280
+ "<button class=\"btn btn-default btn-sm\" ng-click=\"selectNone()\">{{ nullableText }}</button>\n" +
6277
6281
  "</div>\n" +
6278
6282
  "<div class=\"nice-dropdown-items\" aria-labelledby=\"nice-dropdown-{{ id }}\" role=\"listbox\">\n" +
6279
6283
  "<div role=\"none\" class=\"nice-no-data\" ng-if=\"internalList && internalList.length == 0\">{{ noDataText }}</div>\n" +
6280
- "<button role=\"option\" class=\"nice-dropdown-item null-item\" ng-if=\"nullable && internalList.length != 0\" ng-click=\"handleSelected(null, -1)\" ng-disabled=\"isDisabled\">\n" +
6284
+ "<button role=\"option\" class=\"nice-dropdown-item null-item\" ng-if=\"!multiple && nullable && internalList.length != 0\" ng-click=\"handleSelected(null, -1)\" ng-disabled=\"isDisabled\">\n" +
6281
6285
  "{{ nullableText }}\n" +
6282
6286
  "</button>\n" +
6283
6287
  "<button role=\"option\" class=\"nice-dropdown-item\" ng-repeat=\"item in internalList\" ng-click=\"handleSelected(item, $index)\" ng-class=\"{ 'selected': item._selected }\" ng-disabled=\"isDisabled\">\n" +