nice-elements 1.13.8 → 1.14.1

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +1 -1
  3. package/bower.json +1 -1
  4. package/dist/nice.js +233 -169
  5. package/dist/nice.min.js +1 -1
  6. package/dist/style.css +391 -1002
  7. package/dist/style.css.map +1 -59
  8. package/dist/style.min.css +2 -2
  9. package/package.json +6 -6
  10. package/src/components/nice-alert/nice-alert.scss +5 -0
  11. package/src/components/nice-comment/nice-comment.js +11 -11
  12. package/src/components/nice-comment/nice-comment.scss +0 -2
  13. package/src/components/nice-date/nice-date.js +8 -1
  14. package/src/components/nice-date/nice-date.scss +1 -0
  15. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +9 -2
  16. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +1 -0
  17. package/src/components/nice-dropdown/nice-dropdown.html +3 -3
  18. package/src/components/nice-dropdown/nice-dropdown.js +21 -15
  19. package/src/components/nice-dropdown/nice-dropdown.scss +20 -0
  20. package/src/components/nice-help/nice-help.html +3 -4
  21. package/src/components/nice-help/nice-help.js +10 -37
  22. package/src/components/nice-help/nice-help.scss +59 -27
  23. package/src/components/nice-input/nice-input.html +3 -0
  24. package/src/components/nice-input/nice-input.js +4 -4
  25. package/src/components/nice-input/nice-input.scss +1 -1
  26. package/src/components/nice-notification/nice-notification.html +9 -4
  27. package/src/components/nice-notification/nice-notification.js +66 -46
  28. package/src/components/nice-notification/nice-notification.scss +99 -19
  29. package/src/components/nice-percent/nice-percent.html +5 -5
  30. package/src/components/nice-popup/nice-popup.js +10 -5
  31. package/src/components/nice-search2/nice-search2.js +15 -5
  32. package/src/components/nice-toggle/nice-toggle.html +1 -1
  33. package/src/components/nice-toggle/nice-toggle.scss +15 -1
  34. package/src/components/nice-upload/nice-upload.html +1 -1
  35. package/src/components/nice-upload/nice-upload.scss +3 -0
  36. package/src/components/nice-virtual-scroll/nice-virtual-scroll.js +15 -3
  37. package/src/directives/nice-click-outside.js +24 -18
  38. package/src/directives/nice-tooltip/nice-tooltip.js +14 -4
  39. package/src/services/nice-service.js +1 -1
package/dist/nice.js CHANGED
@@ -939,21 +939,21 @@ angular.module('niceElements')
939
939
  });
940
940
  };
941
941
 
942
- textareas[0].addEventListener('keydown', autosize);
943
- autosize();
944
-
942
+ // Resize to fit the content. Runs outside Angular: it only touches the
943
+ // textarea's style, so it never triggers a digest.
945
944
  function autosize() {
946
945
  const el = textareas[0];
947
- $timeout(function () {
948
- el.style.cssText = 'height:auto; padding:0';
946
+ el.style.height = 'auto';
947
+ el.style.height = (el.scrollHeight + 2) + 'px';
948
+ }
949
949
 
950
- // for box-sizing other than "content-box" use:
951
- el.style.cssText = '-moz-box-sizing:content-box';
950
+ // 'input' fires after the value changes (typing, paste, cut), so no timeout is needed
951
+ textareas[0].addEventListener('input', autosize);
952
952
 
953
- // Fix height
954
- el.style.cssText = 'height:' + (el.scrollHeight + 2) + 'px';
955
- });
956
- }
953
+ // Also fit when the model is set from outside; wait for ngModel to render it
954
+ scope.$watch('model', function () {
955
+ $timeout(autosize, 0, false);
956
+ });
957
957
  },
958
958
  controller: function ($scope) {
959
959
  $scope.editing = false;
@@ -1306,10 +1306,17 @@ angular.module('niceElements')
1306
1306
  });
1307
1307
  };
1308
1308
 
1309
- $timeout(function () {
1309
+ const setupTimer = $timeout(function () {
1310
1310
  if (!$scope.inline) $scope.setupPopper();
1311
1311
  }, 100);
1312
1312
 
1313
+ // Popper adds scroll/resize listeners to window; remove them with the component
1314
+ $scope.$on('$destroy', function () {
1315
+ $timeout.cancel(setupTimer);
1316
+ if ($scope.popper) $scope.popper.destroy();
1317
+ $scope.popper = null;
1318
+ });
1319
+
1313
1320
 
1314
1321
  // ------------------ Time changes ------------------
1315
1322
  $scope.timeChange = function () {
@@ -1751,10 +1758,17 @@ angular.module('niceElements')
1751
1758
  });
1752
1759
  };
1753
1760
 
1754
- $timeout(function () {
1761
+ const setupTimer = $timeout(function () {
1755
1762
  $scope.setupPopper();
1756
1763
  });
1757
1764
 
1765
+ // Popper adds scroll/resize listeners to window; remove them with the component
1766
+ $scope.$on('$destroy', function () {
1767
+ $timeout.cancel(setupTimer);
1768
+ if ($scope.popper) $scope.popper.destroy();
1769
+ $scope.popper = null;
1770
+ });
1771
+
1758
1772
 
1759
1773
  $scope.format = function () {
1760
1774
  $scope.modelFormat = $scope.startDate.format($scope.formatString) + " - " + $scope.endDate.format($scope.formatString);
@@ -1764,7 +1778,7 @@ angular.module('niceElements')
1764
1778
  $scope.open = function () {
1765
1779
  if (!$scope.isDisabled) {
1766
1780
  $scope.isOpen = true;
1767
- $scope.popper.update();
1781
+ if ($scope.popper) $scope.popper.update();
1768
1782
  }
1769
1783
  };
1770
1784
 
@@ -2607,6 +2621,8 @@ angular.module('niceElements')
2607
2621
  noSearch: '=',
2608
2622
  nullableText: '@',
2609
2623
  selectedText: '@',
2624
+ maxSelectedShown: '@?', // Multiple: number of selected values shown before "+x more" (default 4)
2625
+ moreText: '@?', // Multiple: text after "+x" (default "more")
2610
2626
  dropdownDistance: '@',
2611
2627
  searchFunction: '=?',
2612
2628
  filterFunction: '=?',
@@ -2626,6 +2642,9 @@ angular.module('niceElements')
2626
2642
  if (!$scope.nullableText) { $scope.nullableText = gettextCatalog.getString("None", null, "Nice"); }
2627
2643
  if (!$scope.selectText) { $scope.selectText = gettextCatalog.getString("None", null, "Nice"); }
2628
2644
  if (!$scope.selectedText) { $scope.selectedText = gettextCatalog.getString("selected", null, "Nice"); }
2645
+ if (!$scope.moreText) { $scope.moreText = gettextCatalog.getString("more", null, "Nice"); }
2646
+ $scope.maxSelectedShown = parseInt($scope.maxSelectedShown, 10);
2647
+ if (isNaN($scope.maxSelectedShown) || $scope.maxSelectedShown < 1) { $scope.maxSelectedShown = 4; }
2629
2648
  if (!$scope.addButtonFunction) { $scope.addButtonFunction = null; }
2630
2649
  if (!$scope.placement) { $scope.placement = "bottom-start"; }
2631
2650
  $scope.noMargin = $scope.noMargin === 'true' || $scope.noMargin === true;
@@ -2652,8 +2671,6 @@ angular.module('niceElements')
2652
2671
  $scope.popper = Popper.createPopper(button, tooltip, {
2653
2672
  strategy: 'fixed',
2654
2673
  placement: $scope.placement,
2655
- scroll: true,
2656
- resize: true,
2657
2674
  modifiers: [
2658
2675
  {
2659
2676
  name: 'offset',
@@ -2683,10 +2700,17 @@ angular.module('niceElements')
2683
2700
  });
2684
2701
  };
2685
2702
 
2686
- $timeout(function () {
2703
+ const setupTimer = $timeout(function () {
2687
2704
  $scope.setupPopper();
2688
2705
  });
2689
2706
 
2707
+ // Popper adds scroll/resize listeners to window; remove them with the component
2708
+ $scope.$on('$destroy', function () {
2709
+ $timeout.cancel(setupTimer);
2710
+ if ($scope.popper) $scope.popper.destroy();
2711
+ $scope.popper = null;
2712
+ });
2713
+
2690
2714
 
2691
2715
  // ----------------------------------- Open -----------------------------------
2692
2716
  $scope.toggle = function () {
@@ -2703,13 +2727,13 @@ angular.module('niceElements')
2703
2727
  };
2704
2728
 
2705
2729
  $scope.open = function () {
2706
- $scope.popper.update();
2730
+ if ($scope.popper) $scope.popper.update();
2707
2731
  if ($scope.filterFunction) $scope.internalList = $scope.filterFunction($scope.originalList, $scope.model);
2708
2732
  $timeout(function () {
2709
2733
  $scope.isOpen = true;
2710
2734
  if ($scope.onOpen) $scope.onOpen();
2711
2735
  $timeout(function () {
2712
- $scope.popper.update();
2736
+ if ($scope.popper) $scope.popper.update();
2713
2737
  });
2714
2738
  });
2715
2739
  $timeout(function () {
@@ -3065,16 +3089,12 @@ angular.module('niceElements')
3065
3089
 
3066
3090
  // ----------------------------------- Handle add button function -----------------------------------
3067
3091
  $scope.handleAddButton = function ($event) {
3068
- let element = $event.target;
3069
- while (true) {
3070
- if (element.nodeName == 'BUTTON') {
3071
- element.blur();
3072
- break;
3073
- }
3074
- element = element.parentElement;
3075
- }
3076
- $scope.addButtonFunction();
3077
- }
3092
+ // Blur the clicked button. closest() stops at the root instead of
3093
+ // walking past it (the old loop crashed if no <button> was found).
3094
+ const button = $event && $event.target && $event.target.closest ? $event.target.closest('button') : null;
3095
+ if (button) button.blur();
3096
+ if ($scope.addButtonFunction) $scope.addButtonFunction();
3097
+ };
3078
3098
  }
3079
3099
  };
3080
3100
  });
@@ -3922,6 +3942,8 @@ angular.module('niceElements')
3922
3942
  * @name niceElements.directive:niceHelp
3923
3943
  * @description
3924
3944
  * # niceHelp
3945
+ * Help icon with a hover popup. Positioning is pure CSS (anchor positioning,
3946
+ * with an absolute-position fallback), so there are no JS listeners to clean up.
3925
3947
  */
3926
3948
  angular.module('niceElements')
3927
3949
  .directive('niceHelp', function () {
@@ -3931,45 +3953,16 @@ angular.module('niceElements')
3931
3953
  replace: true,
3932
3954
  scope: {
3933
3955
  text: '@',
3934
- placement: '@', // Describes the preferred placement of the popper
3956
+ placement: '@', // top (default) | bottom | left | right
3935
3957
  },
3936
- controller: function ($scope, $element, $timeout) {
3937
- if (!$scope.placement) { $scope.placement = "top"; }
3938
-
3939
- // Setup popper
3940
- // https://popper.js.org/docs/v2/constructors/
3941
- $scope.setupPopper = function () {
3942
- const button = $element[0].getElementsByClassName('nice-help-button')[0];
3943
- const tooltip = $element[0].getElementsByClassName('nice-help-popup')[0];
3944
- $scope.popper = Popper.createPopper(button, tooltip, {
3945
- strategy: 'fixed',
3946
- placement: $scope.placement,
3947
- scroll: true,
3948
- resize: true,
3949
- modifiers: [
3950
- {
3951
- name: 'offset',
3952
- options: {
3953
- offset: [0, 5],
3954
- },
3955
- },
3956
- {
3957
- name: 'arrow',
3958
- options: {
3959
- padding: 2,
3960
- },
3961
- }
3962
- ],
3963
- });
3964
- };
3965
-
3966
- // $timeout(function () {
3967
- // $scope.setupPopper();
3968
- // });
3958
+ controller: function ($scope) {
3959
+ const placements = ['top', 'bottom', 'left', 'right'];
3960
+ // Popper-style values like "top-start" map to their base side
3961
+ const side = ($scope.placement || 'top').split('-')[0];
3962
+ $scope.placement = placements.indexOf(side) >= 0 ? side : 'top';
3969
3963
 
3970
- $scope.onHover = function () {
3971
- $scope.setupPopper();
3972
- }
3964
+ // Unique anchor name so each popup attaches to its own icon
3965
+ $scope.id = Math.random().toString(36).substring(2, 9);
3973
3966
  }
3974
3967
  };
3975
3968
  });
@@ -4105,8 +4098,6 @@ angular.module('niceElements')
4105
4098
  } else if ($scope.type == "email") {
4106
4099
  $scope.inputMode = "email";
4107
4100
  $scope.regexexp = new RegExp("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$");
4108
- } else {
4109
- $scope.internalType = "text";
4110
4101
  }
4111
4102
 
4112
4103
  if (angular.isDefined($scope.valid)) {
@@ -4139,8 +4130,6 @@ angular.module('niceElements')
4139
4130
  } else if ($scope.type == "number" && value_old && value_old[value_old.length - 1] == ".") {
4140
4131
  // IGNORE
4141
4132
  } else {
4142
- // Parent switched to plain value (null keeps Decimal, e.g. cleared input)
4143
- if ($scope.model != null) $scope.decimalConstructor = null;
4144
4133
  $scope.internalModel = angular.copy($scope.model);
4145
4134
  }
4146
4135
 
@@ -4229,6 +4218,10 @@ angular.module('niceElements')
4229
4218
  };
4230
4219
  };
4231
4220
 
4221
+ $scope.togglePasswordType = function () {
4222
+ $scope.internalType = $scope.internalType == 'password' ? 'text' : 'password';
4223
+ };
4224
+
4232
4225
  $scope.keypress = function (event) {
4233
4226
  if ($scope.numbersOnly) {
4234
4227
  if ((event.charCode >= 48 && event.charCode <= 58) || event.charCode == 0) { // Allow only numbers
@@ -4380,12 +4373,35 @@ angular.module('niceElements')
4380
4373
  .factory('NiceNotification', function ($timeout, $http, $compile, $templateCache, $rootScope, $sce) {
4381
4374
 
4382
4375
  let startTop = 10;
4383
- let startRight = 10;
4384
4376
  let verticalSpacing = 10;
4385
- let horizontalSpacing = 10;
4386
4377
  let delay = 5000;
4387
4378
 
4388
- const messageElements = [];
4379
+ // Default icon per type (primary has none). Override with notify.config({ icons: { ... } })
4380
+ const icons = {
4381
+ success: 'icon-check-circle',
4382
+ error: 'icon-alert-triangle',
4383
+ warning: 'icon-alert-circle',
4384
+ info: 'icon-info',
4385
+ };
4386
+
4387
+ // All notifications live in one fixed container; CSS (flexbox) does the stacking
4388
+ let container = null;
4389
+
4390
+ const applyConfig = function () {
4391
+ if (!container) return;
4392
+ container.style.setProperty('--nice-notification-top', startTop + 'px');
4393
+ container.style.setProperty('--nice-notification-spacing', verticalSpacing + 'px');
4394
+ };
4395
+
4396
+ const getContainer = function () {
4397
+ if (!container || !document.body.contains(container)) {
4398
+ container = document.createElement('div');
4399
+ container.className = 'nice-notifications';
4400
+ applyConfig();
4401
+ document.body.appendChild(container);
4402
+ }
4403
+ return container;
4404
+ };
4389
4405
 
4390
4406
  const notify = function (args, t) {
4391
4407
 
@@ -4403,6 +4419,8 @@ angular.module('niceElements')
4403
4419
  scope.message = $sce.trustAsHtml(args.message);
4404
4420
  scope.title = $sce.trustAsHtml(args.title);
4405
4421
  scope.t = args.type.substr(0, 1);
4422
+ // icon: undefined → type default, false/null/'' → no icon, string → that icon id
4423
+ scope.icon = angular.isUndefined(args.icon) ? icons[args.type] : args.icon;
4406
4424
  scope.delay = args.delay;
4407
4425
 
4408
4426
  if (typeof args.scope === 'object') {
@@ -4411,54 +4429,42 @@ angular.module('niceElements')
4411
4429
  }
4412
4430
  }
4413
4431
 
4414
- const reposite = function () {
4415
- let j = 0;
4416
- let k = 0;
4417
- let lastTop = startTop;
4418
- let top = 0;
4419
- // const lastRight = startRight;
4420
- for (let i = messageElements.length - 1; i >= 0; i--) {
4421
- const element = messageElements[i];
4422
- const elHeight = parseInt(element[0].offsetHeight);
4423
- const elWidth = parseInt(element[0].offsetWidth);
4424
- if ((top + elHeight) > window.innerHeight) {
4425
- lastTop = startTop;
4426
- k++;
4427
- j = 0;
4428
- }
4429
- top = lastTop + (j === 0 ? 0 : verticalSpacing);
4430
- const right = startRight + (k * (horizontalSpacing + elWidth));
4431
-
4432
- element.css('top', top + 'px');
4433
- element.css('right', right + 'px');
4434
-
4435
- lastTop = top + elHeight;
4436
- j++;
4437
- }
4438
- };
4439
-
4440
4432
  const templateElement = $compile(template)(scope);
4441
4433
  templateElement.addClass(args.type);
4442
- templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
4443
- e = e.originalEvent || e;
4444
- if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
4445
- templateElement.remove();
4446
- messageElements.splice(messageElements.indexOf(templateElement), 1);
4447
- reposite();
4448
- }
4449
- });
4450
4434
 
4451
- $timeout(function () {
4435
+ let closed = false;
4436
+ let closeTimer = null;
4437
+
4438
+ // Single exit path: safe to call any number of times (click + timer)
4439
+ const close = function () {
4440
+ if (closed) return;
4441
+ closed = true;
4442
+ if (closeTimer) $timeout.cancel(closeTimer);
4443
+
4444
+ // Mark as closed; the leave animation is defined entirely in CSS (.killed).
4445
+ // Remove the element once whatever CSS animations it has are done
4446
+ // (resolves right away if there are none, e.g. a custom template).
4447
+ const el = templateElement[0];
4452
4448
  templateElement.addClass('killed');
4453
- templateElement.remove();
4454
- messageElements.splice(messageElements.indexOf(templateElement), 1);
4455
- reposite();
4456
- }, args.delay);
4449
+ const running = el.getAnimations ? el.getAnimations() : [];
4450
+ // An interrupted enter animation rejects its promise; treat that as done
4451
+ // so it doesn't cut the leave transitions short.
4452
+ Promise.all(running.map(function (a) { return a.finished.catch(angular.noop); }))
4453
+ .then(function () {
4454
+ templateElement.remove();
4455
+ scope.$destroy();
4456
+ });
4457
+ };
4457
4458
 
4458
- angular.element(document.getElementsByTagName('body')).append(templateElement);
4459
- messageElements.push(templateElement);
4459
+ templateElement.on('click', close);
4460
4460
 
4461
- $timeout(reposite);
4461
+ // Newest on top; the CSS enter animation runs on insertion
4462
+ const list = getContainer();
4463
+ list.insertBefore(templateElement[0], list.firstChild);
4464
+
4465
+ if (args.delay > 0) {
4466
+ closeTimer = $timeout(close, args.delay);
4467
+ }
4462
4468
 
4463
4469
  }).error(function (data) {
4464
4470
  throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
@@ -4468,6 +4474,13 @@ angular.module('niceElements')
4468
4474
  notify.config = function (args) {
4469
4475
  startTop = args.top ? args.top : startTop;
4470
4476
  verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
4477
+ applyConfig();
4478
+ if (args.icons) {
4479
+ // Use 'primary' as the key for the default type
4480
+ angular.forEach(args.icons, function (icon, type) {
4481
+ icons[type === 'primary' ? '' : type] = icon;
4482
+ });
4483
+ }
4471
4484
  };
4472
4485
 
4473
4486
  notify.primary = function (args) {
@@ -4493,6 +4506,7 @@ angular.module('niceElements')
4493
4506
 
4494
4507
  return notify;
4495
4508
  });
4509
+
4496
4510
  'use strict';
4497
4511
 
4498
4512
  /**
@@ -4976,8 +4990,6 @@ angular.module('niceElements')
4976
4990
  $scope.popper = Popper.createPopper(target, content, {
4977
4991
  placement: $scope.placement,
4978
4992
  strategy: $scope.strategy,
4979
- scroll: true,
4980
- resize: true,
4981
4993
  modifiers: [
4982
4994
  {
4983
4995
  name: 'offset',
@@ -5009,10 +5021,17 @@ angular.module('niceElements')
5009
5021
  });
5010
5022
  };
5011
5023
 
5012
- $timeout(function () {
5024
+ const setupTimer = $timeout(function () {
5013
5025
  $scope.setupPopper();
5014
5026
  });
5015
5027
 
5028
+ // Popper adds scroll/resize listeners to window; remove them with the component
5029
+ $scope.$on('$destroy', function () {
5030
+ $timeout.cancel(setupTimer);
5031
+ if ($scope.popper) $scope.popper.destroy();
5032
+ $scope.popper = null;
5033
+ });
5034
+
5016
5035
  // -----------------------------------Open -----------------------------------
5017
5036
  $scope.toggle = function () {
5018
5037
  if ($scope.isOpen) {
@@ -5028,11 +5047,11 @@ angular.module('niceElements')
5028
5047
  };
5029
5048
 
5030
5049
  $scope.open = function () {
5031
- $scope.popper.update();
5050
+ if ($scope.popper) $scope.popper.update();
5032
5051
  $scope.isOpen = true;
5033
5052
  if ($scope.onChange) $scope.onChange($scope.isOpen);
5034
5053
  $timeout(function () {
5035
- $scope.popper.update();
5054
+ if ($scope.popper) $scope.popper.update();
5036
5055
  });
5037
5056
  };
5038
5057
  }
@@ -5481,10 +5500,17 @@ angular.module('niceElements')
5481
5500
  });
5482
5501
  };
5483
5502
 
5484
- $timeout(function () {
5503
+ const setupTimer = $timeout(function () {
5485
5504
  $scope.setupPopper();
5486
5505
  });
5487
5506
 
5507
+ // Popper adds scroll/resize listeners to window; remove them with the component
5508
+ $scope.$on('$destroy', function () {
5509
+ $timeout.cancel(setupTimer);
5510
+ if ($scope.popper) $scope.popper.destroy();
5511
+ $scope.popper = null;
5512
+ });
5513
+
5488
5514
 
5489
5515
  // ------------------- On focus -------------------
5490
5516
  $scope.onFocus = function () {
@@ -5522,7 +5548,7 @@ angular.module('niceElements')
5522
5548
  // if (input) input.blur();
5523
5549
 
5524
5550
  $timeout(function () {
5525
- $scope.popper.update();
5551
+ if ($scope.popper) $scope.popper.update();
5526
5552
  });
5527
5553
  };
5528
5554
 
@@ -5621,8 +5647,9 @@ angular.module('niceElements')
5621
5647
  };
5622
5648
 
5623
5649
 
5624
- // ----------------------------------- Watch for keydown and keypress -----------------------------------
5625
- $element.bind("keydown keypress", function (event) {
5650
+ // ----------------------------------- Watch for keydown -----------------------------------
5651
+ // keydown only: Enter also fires keypress, which used to select the item twice
5652
+ $element.bind("keydown", function (event) {
5626
5653
  // Arrow Up
5627
5654
  if (event.keyCode == 38) {
5628
5655
  event.preventDefault();
@@ -5653,7 +5680,9 @@ angular.module('niceElements')
5653
5680
  if (event.keyCode == 13) {
5654
5681
  event.preventDefault();
5655
5682
  $timeout(function () {
5656
- $scope.selectItem($scope.results[$scope.selectedIndex], $scope.selectedIndex);
5683
+ // Only select a result that exists (no results → no onSelect(undefined))
5684
+ const item = $scope.results ? $scope.results[$scope.selectedIndex] : undefined;
5685
+ if (item !== undefined) $scope.selectItem(item);
5657
5686
  });
5658
5687
  }
5659
5688
 
@@ -6267,7 +6296,8 @@ angular.module('niceElements')
6267
6296
 
6268
6297
  // ------------------------- Prepare data -------------------------
6269
6298
  $scope.prepareData = function() {
6270
- $scope.items = Array.from($scope.data, (data, index) => ({
6299
+ // data is often loaded asynchronously, so it can still be undefined/null here
6300
+ $scope.items = Array.from($scope.data || [], (data, index) => ({
6271
6301
  id: index + 1,
6272
6302
  height: Number($scope.rowHeight), // Default placeholder height
6273
6303
  offsetTop: index * Number($scope.rowHeight), // Approximate offset
@@ -6281,6 +6311,12 @@ angular.module('niceElements')
6281
6311
 
6282
6312
  // ------------------------- On scroll -------------------------
6283
6313
  $scope.onScroll = function() {
6314
+ // Can run (e.g. from the ResizeObserver) before prepareData has built items
6315
+ if (!$scope.items || $scope.items.length === 0) {
6316
+ $scope.visibleItems = [];
6317
+ return;
6318
+ }
6319
+
6284
6320
  const container = $element[0].getBoundingClientRect();
6285
6321
  const scrollTop = $element[0].scrollTop;
6286
6322
  const viewportHeight = container.height;
@@ -6300,11 +6336,16 @@ angular.module('niceElements')
6300
6336
  });
6301
6337
 
6302
6338
  // ------------------------- Watch for element resize -------------------------
6303
- new ResizeObserver(function() {
6339
+ const resizeObserver = new ResizeObserver(function() {
6304
6340
  $timeout(function() {
6305
6341
  $scope.onScroll();
6306
6342
  });
6307
- }).observe($element[0]);
6343
+ });
6344
+ resizeObserver.observe($element[0]);
6345
+
6346
+ $scope.$on('$destroy', function () {
6347
+ resizeObserver.disconnect();
6348
+ });
6308
6349
 
6309
6350
  // Initial render
6310
6351
  $scope.prepareData();
@@ -6553,12 +6594,16 @@ angular.module('niceElements')
6553
6594
  $scope.isOpen = value == 'true';
6554
6595
  });
6555
6596
 
6556
- $timeout(function () {
6597
+ let eventHandler = null;
6598
+
6599
+ // Registered up front (not inside the timeout) so cleanup still happens
6600
+ // when the element is destroyed before the listeners are attached.
6601
+ const setupTimer = $timeout(function () {
6557
6602
  // postpone linking to next digest to allow for unique id generation
6558
6603
  const classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [];
6559
6604
  let fn;
6560
6605
 
6561
- function eventHandler(e) {
6606
+ eventHandler = function (e) {
6562
6607
  if ($scope.isOpen) {
6563
6608
  let i, element, r, id, classNames, l;
6564
6609
 
@@ -6607,7 +6652,7 @@ angular.module('niceElements')
6607
6652
  fn($scope, { event: e });
6608
6653
  });
6609
6654
  }
6610
- }
6655
+ };
6611
6656
 
6612
6657
 
6613
6658
  // if the devices has a touchscreen, listen for this event
@@ -6617,25 +6662,27 @@ angular.module('niceElements')
6617
6662
 
6618
6663
  // still listen for the click event even if there is touch to cater for touchscreen laptops
6619
6664
  $document.on('click', eventHandler);
6665
+ });
6620
6666
 
6621
- // when the scope is destroyed, clean up the documents event handlers as we don't want it hanging around
6622
- $scope.$on('$destroy', function () {
6623
- if (_hasTouch()) {
6624
- $document.off('touchstart', eventHandler);
6625
- }
6626
-
6667
+ // when the scope is destroyed, clean up the documents event handlers as we don't want it hanging around
6668
+ $scope.$on('$destroy', function () {
6669
+ $timeout.cancel(setupTimer);
6670
+ if (eventHandler) {
6671
+ // off() is a no-op for events that were never bound, so no touch check needed
6672
+ $document.off('touchstart', eventHandler);
6627
6673
  $document.off('click', eventHandler);
6628
- });
6629
-
6630
- /**
6631
- * @description Private function to attempt to figure out if we are on a touch device
6632
- * @private
6633
- **/
6634
- function _hasTouch() {
6635
- // works on most browsers, IE10/11 and Surface
6636
- return 'ontouchstart' in window || navigator.maxTouchPoints;
6674
+ eventHandler = null;
6637
6675
  }
6638
6676
  });
6677
+
6678
+ /**
6679
+ * @description Private function to attempt to figure out if we are on a touch device
6680
+ * @private
6681
+ **/
6682
+ function _hasTouch() {
6683
+ // works on most browsers, IE10/11 and Surface
6684
+ return 'ontouchstart' in window || navigator.maxTouchPoints;
6685
+ }
6639
6686
  }
6640
6687
  };
6641
6688
  });
@@ -6684,7 +6731,7 @@ angular.module('niceElements')
6684
6731
  .directive('niceTooltip', function () {
6685
6732
  return {
6686
6733
  restrict: 'A',
6687
- controller: function ($scope, $element, $attrs, $compile) {
6734
+ controller: function ($scope, $element, $attrs, $injector) {
6688
6735
  const id = Math.random().toString(36).substring(7);
6689
6736
  const showEvents = ['mouseenter', 'focus'];
6690
6737
  const hideEvents = ['mouseleave', 'blur'];
@@ -6696,9 +6743,19 @@ angular.module('niceElements')
6696
6743
  tooltipWindow.className = 'nice-tooltip-window';
6697
6744
  tooltipWindow.id = 'nice-tooltip-window-' + id;
6698
6745
 
6699
- // Popper body
6700
- const content = $compile("<div class='nice-tooltip-body'>" + $attrs.niceTooltip + "</div>")($scope);
6701
- tooltipWindow.append(content[0]);
6746
+ // Popper body. The attribute's {{ }} is interpolated by Angular, but the
6747
+ // resulting text is never compiled, so user data can't run as a template.
6748
+ // Safe HTML is kept when the app loads ngSanitize; otherwise it's plain text.
6749
+ const content = document.createElement('div');
6750
+ content.className = 'nice-tooltip-body';
6751
+ tooltipWindow.append(content);
6752
+
6753
+ const $sanitize = $injector.has('$sanitize') ? $injector.get('$sanitize') : null;
6754
+ $attrs.$observe('niceTooltip', function (value) {
6755
+ value = value == null ? '' : String(value);
6756
+ if ($sanitize) content.innerHTML = $sanitize(value);
6757
+ else content.textContent = value;
6758
+ });
6702
6759
 
6703
6760
  // Popper arrow
6704
6761
  const tooltipWindowArrow = document.createElement('div');
@@ -6769,7 +6826,7 @@ angular.module('niceElements')
6769
6826
  .service('NiceService', function ($rootScope) {
6770
6827
  const service = {
6771
6828
  name: "Nice elements",
6772
- version: "1.13.8",
6829
+ version: "1.14.1",
6773
6830
  getHeader: function () {
6774
6831
  return {};
6775
6832
  },
@@ -7484,9 +7541,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7484
7541
  " <input class=\"hidden-input\" ng-model=\"model\" ng-required=\"required\" ng-disabled=\"disabled\" tabindex=\"-1\">\n" +
7485
7542
  " <div class=\"btn-dropdown-inside\" ng-transclude=\"button\" ng-if=\"selected != null\">\n" +
7486
7543
  " <span ng-if=\"!multiple\">{{ selected[objValue] }}</span>\n" +
7487
- " <span ng-if=\"multiple\">\n" +
7488
- " <span ng-if=\"selected.length > 1\">{{ selected.length }} {{ selectedText }}</span>\n" +
7489
- " <span ng-if=\"selected.length == 1\">{{ selected[0][objValue] }}</span>\n" +
7544
+ " <span ng-if=\"multiple\" class=\"multiple-selected\" ng-class=\"{ 'has-more': selected.length > maxSelectedShown }\">\n" +
7545
+ " <span ng-if=\"selected.length > 0\" class=\"multiple-selected-values\"><span ng-repeat=\"item in selected | limitTo: maxSelectedShown\">{{ item[objValue] }}{{ $last ? '' : ', ' }}</span></span>\n" +
7546
+ " <span ng-if=\"selected.length > maxSelectedShown\" class=\"multiple-selected-more\">+{{ selected.length - maxSelectedShown }} {{ moreText }}</span>\n" +
7490
7547
  " <span ng-if=\"selected.length == 0\" class=\"not-selected\">{{ nullableText }}</span>\n" +
7491
7548
  " </span>\n" +
7492
7549
  " </div>\n" +
@@ -7633,13 +7690,12 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7633
7690
 
7634
7691
 
7635
7692
  $templateCache.put('src/components/nice-help/nice-help.html',
7636
- "<div class=\"nice-help\" ng-mouseover=\"onHover()\">\n" +
7693
+ "<div class=\"nice-help\" ng-class=\"'nice-help-' + placement\" style=\"anchor-name: --nice-help-{{ id }}\">\n" +
7637
7694
  " <nice-icon icon=\"icon-help-circle\" class=\"nice-help-button\"></nice-icon>\n" +
7638
- " <div class=\"nice-help-popup\">\n" +
7695
+ " <div class=\"nice-help-popup\" role=\"tooltip\" style=\"position-anchor: --nice-help-{{ id }}\">\n" +
7639
7696
  " <span ng-bind-html=\"text\">{{ text }}</span>\n" +
7640
- " <div data-popper-arrow class=\"nice-help-arrow\"></div>\n" +
7641
7697
  " </div>\n" +
7642
- "</div>"
7698
+ "</div>\n"
7643
7699
  );
7644
7700
 
7645
7701
 
@@ -7675,6 +7731,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7675
7731
  " <input ng-if=\"!textArea\" class=\"form-control\" type=\"{{ internalType }}\" inputmode=\"{{ inputMode }}\" ng-model=\"$parent.internalModel\" name=\"{{ name }}\" id=\"{{ id }}\" tabindex=\"{{ tabIndex }}\" placeholder=\"{{ placeholder }}\" max=\"{{ max }}\" min=\"{{ min }}\" autocomplete=\"{{ autocomplete }}\" ng-minlength=\"minlength\" ng-maxlength=\"maxlength\" ng-required=\"required\" ng-keypress=\"keypress($event)\" ng-pattern=\"regexexp\" ng-disabled=\"isDisabled\" ng-trim=\"{{ !disableTrim }}\">\n" +
7676
7732
  "\n" +
7677
7733
  " <div class=\"input-group-addon\" ng-if=\"symbol\">{{ symbol }}</div>\n" +
7734
+ " <button type=\"button\" class=\"input-group-btn\" ng-if=\"type=='password'\" ng-click=\"togglePasswordType()\">\n" +
7735
+ " <nice-icon icon=\"icon-eye\"></nice-icon>\n" +
7736
+ " </button>\n" +
7678
7737
  " <button type=\"button\" class=\"input-group-btn\" ng-if=\"!multilanguageDisabled && multilanguageField\" ng-click=\"openMultilanguage()\">\n" +
7679
7738
  " <nice-icon icon=\"icon-translate\"></nice-icon>\n" +
7680
7739
  " <div class=\"nice-input-addon-bubble\" ng-if=\"numberOfLanguages > 0\">{{ numberOfLanguages }}</div>\n" +
@@ -7743,10 +7802,15 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7743
7802
 
7744
7803
 
7745
7804
  $templateCache.put('src/components/nice-notification/nice-notification.html',
7746
- "<div class=\"notification\">\n" +
7747
- " <h3 ng-show=\"title\" ng-bind-html=\"title\"></h3>\n" +
7748
- " <div class=\"message\" ng-bind-html=\"message\"></div>\n" +
7749
- "</div>"
7805
+ "<div class=\"notification\" ng-class=\"{ 'has-icon': icon }\">\n" +
7806
+ " <div class=\"notification-inner\">\n" +
7807
+ " <nice-icon ng-if=\"icon\" class=\"notification-icon\" icon=\"{{ icon }}\"></nice-icon>\n" +
7808
+ " <div class=\"notification-content\">\n" +
7809
+ " <div class=\"notification-title\" ng-show=\"title\" ng-bind-html=\"title\"></div>\n" +
7810
+ " <div class=\"notification-message\" ng-bind-html=\"message\"></div>\n" +
7811
+ " </div>\n" +
7812
+ " </div>\n" +
7813
+ "</div>\n"
7750
7814
  );
7751
7815
 
7752
7816
 
@@ -7823,7 +7887,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7823
7887
 
7824
7888
 
7825
7889
  $templateCache.put('src/components/nice-percent/nice-percent.html',
7826
- "<ng-form class=\"nice-component nice-input\" ng-class=\"{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }\" name=\"form\">\n" +
7890
+ "<ng-form class=\"nice-component nice-percent nice-input nice-input-type-number\" ng-class=\"{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }\" name=\"form\">\n" +
7827
7891
  " <div class=\"row\">\n" +
7828
7892
  " \n" +
7829
7893
  " <nice-title text=\"title || niceTitle\" help=\"help\" required=\"required\" description=\"description\" label-width=\"labelWidth\"></nice-title>\n" +
@@ -7831,10 +7895,10 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7831
7895
  " \n" +
7832
7896
  " <div class=\"nice-field col-xs-12\" ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
7833
7897
  " <div class=\"input-group has-feedback symbol\" ng-class=\"{\n" +
7834
- " 'has-warning': !isDisabled && form.$invalid && form.$dirty && !hideValid,\n" +
7835
- " 'has-success': !isDisabled && form.$valid && form.$dirty && showValid,\n" +
7836
- " 'disabled': isDisabled\n" +
7837
- " }\">\n" +
7898
+ " 'has-warning': !isDisabled && form.$invalid && form.$dirty && !hideValid,\n" +
7899
+ " 'has-success': !isDisabled && form.$valid && form.$dirty && showValid,\n" +
7900
+ " 'disabled': isDisabled\n" +
7901
+ " }\">\n" +
7838
7902
  " <input class=\"form-control\" type=\"text\" max=\"100\" min=\"0\" ng-model=\"internalModel\" placeholder=\"{{ placeholder }}\" ng-required=\"required\" ng-keypress=\"keypress($event)\" ng-change=\"change()\" ng-disabled=\"isDisabled\">\n" +
7839
7903
  " <span class=\"input-group-addon\">%</span>\n" +
7840
7904
  " \n" +
@@ -9485,7 +9549,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
9485
9549
  " <button type=\"button\" class=\"nice-toggle-field\" ng-click=\"toggle()\" ng-disabled=\"isDisabled\">\n" +
9486
9550
  " <div class=\"nice-toggle-field-handle\">\n" +
9487
9551
  " <nice-icon ng-if=\"showIcons && model\" icon=\"icon-check\"></nice-icon>\n" +
9488
- " <nice-icon ng-if=\"showIcons && !model\" icon=\"icon-x\"></nice-icon>\n" +
9552
+ " \n" +
9489
9553
  " </div>\n" +
9490
9554
  " </button>\n" +
9491
9555
  " </div>\n" +
@@ -9511,7 +9575,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
9511
9575
  " <div class=\"text text-placeholder\" ng-if=\"dragging\" translate translate-group=\"Nice\">Drop file here</div>\n" +
9512
9576
  " <div class=\"error\" ng-if=\"error\">{{ error }}</div>\n" +
9513
9577
  " </div>\n" +
9514
- " <div ng-if=\"imageSource\" ng-transclude>\n" +
9578
+ " <div ng-if=\"imageSource && !(loading && uploadProgress != null)\" ng-transclude>\n" +
9515
9579
  " <img data-ng-src=\"{{ imageSource }}\">\n" +
9516
9580
  " </div>\n" +
9517
9581
  " </div>\n" +