nice-elements 1.13.8 → 1.14.0

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/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
 
@@ -2652,8 +2666,6 @@ angular.module('niceElements')
2652
2666
  $scope.popper = Popper.createPopper(button, tooltip, {
2653
2667
  strategy: 'fixed',
2654
2668
  placement: $scope.placement,
2655
- scroll: true,
2656
- resize: true,
2657
2669
  modifiers: [
2658
2670
  {
2659
2671
  name: 'offset',
@@ -2683,10 +2695,17 @@ angular.module('niceElements')
2683
2695
  });
2684
2696
  };
2685
2697
 
2686
- $timeout(function () {
2698
+ const setupTimer = $timeout(function () {
2687
2699
  $scope.setupPopper();
2688
2700
  });
2689
2701
 
2702
+ // Popper adds scroll/resize listeners to window; remove them with the component
2703
+ $scope.$on('$destroy', function () {
2704
+ $timeout.cancel(setupTimer);
2705
+ if ($scope.popper) $scope.popper.destroy();
2706
+ $scope.popper = null;
2707
+ });
2708
+
2690
2709
 
2691
2710
  // ----------------------------------- Open -----------------------------------
2692
2711
  $scope.toggle = function () {
@@ -2703,13 +2722,13 @@ angular.module('niceElements')
2703
2722
  };
2704
2723
 
2705
2724
  $scope.open = function () {
2706
- $scope.popper.update();
2725
+ if ($scope.popper) $scope.popper.update();
2707
2726
  if ($scope.filterFunction) $scope.internalList = $scope.filterFunction($scope.originalList, $scope.model);
2708
2727
  $timeout(function () {
2709
2728
  $scope.isOpen = true;
2710
2729
  if ($scope.onOpen) $scope.onOpen();
2711
2730
  $timeout(function () {
2712
- $scope.popper.update();
2731
+ if ($scope.popper) $scope.popper.update();
2713
2732
  });
2714
2733
  });
2715
2734
  $timeout(function () {
@@ -3065,16 +3084,12 @@ angular.module('niceElements')
3065
3084
 
3066
3085
  // ----------------------------------- Handle add button function -----------------------------------
3067
3086
  $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
- }
3087
+ // Blur the clicked button. closest() stops at the root instead of
3088
+ // walking past it (the old loop crashed if no <button> was found).
3089
+ const button = $event && $event.target && $event.target.closest ? $event.target.closest('button') : null;
3090
+ if (button) button.blur();
3091
+ if ($scope.addButtonFunction) $scope.addButtonFunction();
3092
+ };
3078
3093
  }
3079
3094
  };
3080
3095
  });
@@ -3922,6 +3937,8 @@ angular.module('niceElements')
3922
3937
  * @name niceElements.directive:niceHelp
3923
3938
  * @description
3924
3939
  * # niceHelp
3940
+ * Help icon with a hover popup. Positioning is pure CSS (anchor positioning,
3941
+ * with an absolute-position fallback), so there are no JS listeners to clean up.
3925
3942
  */
3926
3943
  angular.module('niceElements')
3927
3944
  .directive('niceHelp', function () {
@@ -3931,45 +3948,16 @@ angular.module('niceElements')
3931
3948
  replace: true,
3932
3949
  scope: {
3933
3950
  text: '@',
3934
- placement: '@', // Describes the preferred placement of the popper
3951
+ placement: '@', // top (default) | bottom | left | right
3935
3952
  },
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
- // });
3953
+ controller: function ($scope) {
3954
+ const placements = ['top', 'bottom', 'left', 'right'];
3955
+ // Popper-style values like "top-start" map to their base side
3956
+ const side = ($scope.placement || 'top').split('-')[0];
3957
+ $scope.placement = placements.indexOf(side) >= 0 ? side : 'top';
3969
3958
 
3970
- $scope.onHover = function () {
3971
- $scope.setupPopper();
3972
- }
3959
+ // Unique anchor name so each popup attaches to its own icon
3960
+ $scope.id = Math.random().toString(36).substring(2, 9);
3973
3961
  }
3974
3962
  };
3975
3963
  });
@@ -4105,8 +4093,6 @@ angular.module('niceElements')
4105
4093
  } else if ($scope.type == "email") {
4106
4094
  $scope.inputMode = "email";
4107
4095
  $scope.regexexp = new RegExp("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$");
4108
- } else {
4109
- $scope.internalType = "text";
4110
4096
  }
4111
4097
 
4112
4098
  if (angular.isDefined($scope.valid)) {
@@ -4139,8 +4125,6 @@ angular.module('niceElements')
4139
4125
  } else if ($scope.type == "number" && value_old && value_old[value_old.length - 1] == ".") {
4140
4126
  // IGNORE
4141
4127
  } else {
4142
- // Parent switched to plain value (null keeps Decimal, e.g. cleared input)
4143
- if ($scope.model != null) $scope.decimalConstructor = null;
4144
4128
  $scope.internalModel = angular.copy($scope.model);
4145
4129
  }
4146
4130
 
@@ -4229,6 +4213,10 @@ angular.module('niceElements')
4229
4213
  };
4230
4214
  };
4231
4215
 
4216
+ $scope.togglePasswordType = function () {
4217
+ $scope.internalType = $scope.internalType == 'password' ? 'text' : 'password';
4218
+ };
4219
+
4232
4220
  $scope.keypress = function (event) {
4233
4221
  if ($scope.numbersOnly) {
4234
4222
  if ((event.charCode >= 48 && event.charCode <= 58) || event.charCode == 0) { // Allow only numbers
@@ -4380,12 +4368,35 @@ angular.module('niceElements')
4380
4368
  .factory('NiceNotification', function ($timeout, $http, $compile, $templateCache, $rootScope, $sce) {
4381
4369
 
4382
4370
  let startTop = 10;
4383
- let startRight = 10;
4384
4371
  let verticalSpacing = 10;
4385
- let horizontalSpacing = 10;
4386
4372
  let delay = 5000;
4387
4373
 
4388
- const messageElements = [];
4374
+ // Default icon per type (primary has none). Override with notify.config({ icons: { ... } })
4375
+ const icons = {
4376
+ success: 'icon-check-circle',
4377
+ error: 'icon-alert-triangle',
4378
+ warning: 'icon-alert-circle',
4379
+ info: 'icon-info',
4380
+ };
4381
+
4382
+ // All notifications live in one fixed container; CSS (flexbox) does the stacking
4383
+ let container = null;
4384
+
4385
+ const applyConfig = function () {
4386
+ if (!container) return;
4387
+ container.style.setProperty('--nice-notification-top', startTop + 'px');
4388
+ container.style.setProperty('--nice-notification-spacing', verticalSpacing + 'px');
4389
+ };
4390
+
4391
+ const getContainer = function () {
4392
+ if (!container || !document.body.contains(container)) {
4393
+ container = document.createElement('div');
4394
+ container.className = 'nice-notifications';
4395
+ applyConfig();
4396
+ document.body.appendChild(container);
4397
+ }
4398
+ return container;
4399
+ };
4389
4400
 
4390
4401
  const notify = function (args, t) {
4391
4402
 
@@ -4403,6 +4414,8 @@ angular.module('niceElements')
4403
4414
  scope.message = $sce.trustAsHtml(args.message);
4404
4415
  scope.title = $sce.trustAsHtml(args.title);
4405
4416
  scope.t = args.type.substr(0, 1);
4417
+ // icon: undefined → type default, false/null/'' → no icon, string → that icon id
4418
+ scope.icon = angular.isUndefined(args.icon) ? icons[args.type] : args.icon;
4406
4419
  scope.delay = args.delay;
4407
4420
 
4408
4421
  if (typeof args.scope === 'object') {
@@ -4411,54 +4424,42 @@ angular.module('niceElements')
4411
4424
  }
4412
4425
  }
4413
4426
 
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
4427
  const templateElement = $compile(template)(scope);
4441
4428
  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
4429
 
4451
- $timeout(function () {
4430
+ let closed = false;
4431
+ let closeTimer = null;
4432
+
4433
+ // Single exit path: safe to call any number of times (click + timer)
4434
+ const close = function () {
4435
+ if (closed) return;
4436
+ closed = true;
4437
+ if (closeTimer) $timeout.cancel(closeTimer);
4438
+
4439
+ // Mark as closed; the leave animation is defined entirely in CSS (.killed).
4440
+ // Remove the element once whatever CSS animations it has are done
4441
+ // (resolves right away if there are none, e.g. a custom template).
4442
+ const el = templateElement[0];
4452
4443
  templateElement.addClass('killed');
4453
- templateElement.remove();
4454
- messageElements.splice(messageElements.indexOf(templateElement), 1);
4455
- reposite();
4456
- }, args.delay);
4444
+ const running = el.getAnimations ? el.getAnimations() : [];
4445
+ // An interrupted enter animation rejects its promise; treat that as done
4446
+ // so it doesn't cut the leave transitions short.
4447
+ Promise.all(running.map(function (a) { return a.finished.catch(angular.noop); }))
4448
+ .then(function () {
4449
+ templateElement.remove();
4450
+ scope.$destroy();
4451
+ });
4452
+ };
4453
+
4454
+ templateElement.on('click', close);
4457
4455
 
4458
- angular.element(document.getElementsByTagName('body')).append(templateElement);
4459
- messageElements.push(templateElement);
4456
+ // Newest on top; the CSS enter animation runs on insertion
4457
+ const list = getContainer();
4458
+ list.insertBefore(templateElement[0], list.firstChild);
4460
4459
 
4461
- $timeout(reposite);
4460
+ if (args.delay > 0) {
4461
+ closeTimer = $timeout(close, args.delay);
4462
+ }
4462
4463
 
4463
4464
  }).error(function (data) {
4464
4465
  throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
@@ -4468,6 +4469,13 @@ angular.module('niceElements')
4468
4469
  notify.config = function (args) {
4469
4470
  startTop = args.top ? args.top : startTop;
4470
4471
  verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
4472
+ applyConfig();
4473
+ if (args.icons) {
4474
+ // Use 'primary' as the key for the default type
4475
+ angular.forEach(args.icons, function (icon, type) {
4476
+ icons[type === 'primary' ? '' : type] = icon;
4477
+ });
4478
+ }
4471
4479
  };
4472
4480
 
4473
4481
  notify.primary = function (args) {
@@ -4493,6 +4501,7 @@ angular.module('niceElements')
4493
4501
 
4494
4502
  return notify;
4495
4503
  });
4504
+
4496
4505
  'use strict';
4497
4506
 
4498
4507
  /**
@@ -4976,8 +4985,6 @@ angular.module('niceElements')
4976
4985
  $scope.popper = Popper.createPopper(target, content, {
4977
4986
  placement: $scope.placement,
4978
4987
  strategy: $scope.strategy,
4979
- scroll: true,
4980
- resize: true,
4981
4988
  modifiers: [
4982
4989
  {
4983
4990
  name: 'offset',
@@ -5009,10 +5016,17 @@ angular.module('niceElements')
5009
5016
  });
5010
5017
  };
5011
5018
 
5012
- $timeout(function () {
5019
+ const setupTimer = $timeout(function () {
5013
5020
  $scope.setupPopper();
5014
5021
  });
5015
5022
 
5023
+ // Popper adds scroll/resize listeners to window; remove them with the component
5024
+ $scope.$on('$destroy', function () {
5025
+ $timeout.cancel(setupTimer);
5026
+ if ($scope.popper) $scope.popper.destroy();
5027
+ $scope.popper = null;
5028
+ });
5029
+
5016
5030
  // -----------------------------------Open -----------------------------------
5017
5031
  $scope.toggle = function () {
5018
5032
  if ($scope.isOpen) {
@@ -5028,11 +5042,11 @@ angular.module('niceElements')
5028
5042
  };
5029
5043
 
5030
5044
  $scope.open = function () {
5031
- $scope.popper.update();
5045
+ if ($scope.popper) $scope.popper.update();
5032
5046
  $scope.isOpen = true;
5033
5047
  if ($scope.onChange) $scope.onChange($scope.isOpen);
5034
5048
  $timeout(function () {
5035
- $scope.popper.update();
5049
+ if ($scope.popper) $scope.popper.update();
5036
5050
  });
5037
5051
  };
5038
5052
  }
@@ -5481,10 +5495,17 @@ angular.module('niceElements')
5481
5495
  });
5482
5496
  };
5483
5497
 
5484
- $timeout(function () {
5498
+ const setupTimer = $timeout(function () {
5485
5499
  $scope.setupPopper();
5486
5500
  });
5487
5501
 
5502
+ // Popper adds scroll/resize listeners to window; remove them with the component
5503
+ $scope.$on('$destroy', function () {
5504
+ $timeout.cancel(setupTimer);
5505
+ if ($scope.popper) $scope.popper.destroy();
5506
+ $scope.popper = null;
5507
+ });
5508
+
5488
5509
 
5489
5510
  // ------------------- On focus -------------------
5490
5511
  $scope.onFocus = function () {
@@ -5522,7 +5543,7 @@ angular.module('niceElements')
5522
5543
  // if (input) input.blur();
5523
5544
 
5524
5545
  $timeout(function () {
5525
- $scope.popper.update();
5546
+ if ($scope.popper) $scope.popper.update();
5526
5547
  });
5527
5548
  };
5528
5549
 
@@ -5621,8 +5642,9 @@ angular.module('niceElements')
5621
5642
  };
5622
5643
 
5623
5644
 
5624
- // ----------------------------------- Watch for keydown and keypress -----------------------------------
5625
- $element.bind("keydown keypress", function (event) {
5645
+ // ----------------------------------- Watch for keydown -----------------------------------
5646
+ // keydown only: Enter also fires keypress, which used to select the item twice
5647
+ $element.bind("keydown", function (event) {
5626
5648
  // Arrow Up
5627
5649
  if (event.keyCode == 38) {
5628
5650
  event.preventDefault();
@@ -5653,7 +5675,9 @@ angular.module('niceElements')
5653
5675
  if (event.keyCode == 13) {
5654
5676
  event.preventDefault();
5655
5677
  $timeout(function () {
5656
- $scope.selectItem($scope.results[$scope.selectedIndex], $scope.selectedIndex);
5678
+ // Only select a result that exists (no results → no onSelect(undefined))
5679
+ const item = $scope.results ? $scope.results[$scope.selectedIndex] : undefined;
5680
+ if (item !== undefined) $scope.selectItem(item);
5657
5681
  });
5658
5682
  }
5659
5683
 
@@ -6267,7 +6291,8 @@ angular.module('niceElements')
6267
6291
 
6268
6292
  // ------------------------- Prepare data -------------------------
6269
6293
  $scope.prepareData = function() {
6270
- $scope.items = Array.from($scope.data, (data, index) => ({
6294
+ // data is often loaded asynchronously, so it can still be undefined/null here
6295
+ $scope.items = Array.from($scope.data || [], (data, index) => ({
6271
6296
  id: index + 1,
6272
6297
  height: Number($scope.rowHeight), // Default placeholder height
6273
6298
  offsetTop: index * Number($scope.rowHeight), // Approximate offset
@@ -6281,6 +6306,12 @@ angular.module('niceElements')
6281
6306
 
6282
6307
  // ------------------------- On scroll -------------------------
6283
6308
  $scope.onScroll = function() {
6309
+ // Can run (e.g. from the ResizeObserver) before prepareData has built items
6310
+ if (!$scope.items || $scope.items.length === 0) {
6311
+ $scope.visibleItems = [];
6312
+ return;
6313
+ }
6314
+
6284
6315
  const container = $element[0].getBoundingClientRect();
6285
6316
  const scrollTop = $element[0].scrollTop;
6286
6317
  const viewportHeight = container.height;
@@ -6300,11 +6331,16 @@ angular.module('niceElements')
6300
6331
  });
6301
6332
 
6302
6333
  // ------------------------- Watch for element resize -------------------------
6303
- new ResizeObserver(function() {
6334
+ const resizeObserver = new ResizeObserver(function() {
6304
6335
  $timeout(function() {
6305
6336
  $scope.onScroll();
6306
6337
  });
6307
- }).observe($element[0]);
6338
+ });
6339
+ resizeObserver.observe($element[0]);
6340
+
6341
+ $scope.$on('$destroy', function () {
6342
+ resizeObserver.disconnect();
6343
+ });
6308
6344
 
6309
6345
  // Initial render
6310
6346
  $scope.prepareData();
@@ -6553,12 +6589,16 @@ angular.module('niceElements')
6553
6589
  $scope.isOpen = value == 'true';
6554
6590
  });
6555
6591
 
6556
- $timeout(function () {
6592
+ let eventHandler = null;
6593
+
6594
+ // Registered up front (not inside the timeout) so cleanup still happens
6595
+ // when the element is destroyed before the listeners are attached.
6596
+ const setupTimer = $timeout(function () {
6557
6597
  // postpone linking to next digest to allow for unique id generation
6558
6598
  const classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [];
6559
6599
  let fn;
6560
6600
 
6561
- function eventHandler(e) {
6601
+ eventHandler = function (e) {
6562
6602
  if ($scope.isOpen) {
6563
6603
  let i, element, r, id, classNames, l;
6564
6604
 
@@ -6607,7 +6647,7 @@ angular.module('niceElements')
6607
6647
  fn($scope, { event: e });
6608
6648
  });
6609
6649
  }
6610
- }
6650
+ };
6611
6651
 
6612
6652
 
6613
6653
  // if the devices has a touchscreen, listen for this event
@@ -6617,25 +6657,27 @@ angular.module('niceElements')
6617
6657
 
6618
6658
  // still listen for the click event even if there is touch to cater for touchscreen laptops
6619
6659
  $document.on('click', eventHandler);
6660
+ });
6620
6661
 
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
-
6662
+ // when the scope is destroyed, clean up the documents event handlers as we don't want it hanging around
6663
+ $scope.$on('$destroy', function () {
6664
+ $timeout.cancel(setupTimer);
6665
+ if (eventHandler) {
6666
+ // off() is a no-op for events that were never bound, so no touch check needed
6667
+ $document.off('touchstart', eventHandler);
6627
6668
  $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;
6669
+ eventHandler = null;
6637
6670
  }
6638
6671
  });
6672
+
6673
+ /**
6674
+ * @description Private function to attempt to figure out if we are on a touch device
6675
+ * @private
6676
+ **/
6677
+ function _hasTouch() {
6678
+ // works on most browsers, IE10/11 and Surface
6679
+ return 'ontouchstart' in window || navigator.maxTouchPoints;
6680
+ }
6639
6681
  }
6640
6682
  };
6641
6683
  });
@@ -6684,7 +6726,7 @@ angular.module('niceElements')
6684
6726
  .directive('niceTooltip', function () {
6685
6727
  return {
6686
6728
  restrict: 'A',
6687
- controller: function ($scope, $element, $attrs, $compile) {
6729
+ controller: function ($scope, $element, $attrs, $injector) {
6688
6730
  const id = Math.random().toString(36).substring(7);
6689
6731
  const showEvents = ['mouseenter', 'focus'];
6690
6732
  const hideEvents = ['mouseleave', 'blur'];
@@ -6696,9 +6738,19 @@ angular.module('niceElements')
6696
6738
  tooltipWindow.className = 'nice-tooltip-window';
6697
6739
  tooltipWindow.id = 'nice-tooltip-window-' + id;
6698
6740
 
6699
- // Popper body
6700
- const content = $compile("<div class='nice-tooltip-body'>" + $attrs.niceTooltip + "</div>")($scope);
6701
- tooltipWindow.append(content[0]);
6741
+ // Popper body. The attribute's {{ }} is interpolated by Angular, but the
6742
+ // resulting text is never compiled, so user data can't run as a template.
6743
+ // Safe HTML is kept when the app loads ngSanitize; otherwise it's plain text.
6744
+ const content = document.createElement('div');
6745
+ content.className = 'nice-tooltip-body';
6746
+ tooltipWindow.append(content);
6747
+
6748
+ const $sanitize = $injector.has('$sanitize') ? $injector.get('$sanitize') : null;
6749
+ $attrs.$observe('niceTooltip', function (value) {
6750
+ value = value == null ? '' : String(value);
6751
+ if ($sanitize) content.innerHTML = $sanitize(value);
6752
+ else content.textContent = value;
6753
+ });
6702
6754
 
6703
6755
  // Popper arrow
6704
6756
  const tooltipWindowArrow = document.createElement('div');
@@ -7633,13 +7685,12 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7633
7685
 
7634
7686
 
7635
7687
  $templateCache.put('src/components/nice-help/nice-help.html',
7636
- "<div class=\"nice-help\" ng-mouseover=\"onHover()\">\n" +
7688
+ "<div class=\"nice-help\" ng-class=\"'nice-help-' + placement\" style=\"anchor-name: --nice-help-{{ id }}\">\n" +
7637
7689
  " <nice-icon icon=\"icon-help-circle\" class=\"nice-help-button\"></nice-icon>\n" +
7638
- " <div class=\"nice-help-popup\">\n" +
7690
+ " <div class=\"nice-help-popup\" role=\"tooltip\" style=\"position-anchor: --nice-help-{{ id }}\">\n" +
7639
7691
  " <span ng-bind-html=\"text\">{{ text }}</span>\n" +
7640
- " <div data-popper-arrow class=\"nice-help-arrow\"></div>\n" +
7641
7692
  " </div>\n" +
7642
- "</div>"
7693
+ "</div>\n"
7643
7694
  );
7644
7695
 
7645
7696
 
@@ -7675,6 +7726,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7675
7726
  " <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
7727
  "\n" +
7677
7728
  " <div class=\"input-group-addon\" ng-if=\"symbol\">{{ symbol }}</div>\n" +
7729
+ " <button type=\"button\" class=\"input-group-btn\" ng-if=\"type=='password'\" ng-click=\"togglePasswordType()\">\n" +
7730
+ " <nice-icon icon=\"icon-eye\"></nice-icon>\n" +
7731
+ " </button>\n" +
7678
7732
  " <button type=\"button\" class=\"input-group-btn\" ng-if=\"!multilanguageDisabled && multilanguageField\" ng-click=\"openMultilanguage()\">\n" +
7679
7733
  " <nice-icon icon=\"icon-translate\"></nice-icon>\n" +
7680
7734
  " <div class=\"nice-input-addon-bubble\" ng-if=\"numberOfLanguages > 0\">{{ numberOfLanguages }}</div>\n" +
@@ -7743,10 +7797,15 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7743
7797
 
7744
7798
 
7745
7799
  $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>"
7800
+ "<div class=\"notification\" ng-class=\"{ 'has-icon': icon }\">\n" +
7801
+ " <div class=\"notification-inner\">\n" +
7802
+ " <nice-icon ng-if=\"icon\" class=\"notification-icon\" icon=\"{{ icon }}\"></nice-icon>\n" +
7803
+ " <div class=\"notification-content\">\n" +
7804
+ " <div class=\"notification-title\" ng-show=\"title\" ng-bind-html=\"title\"></div>\n" +
7805
+ " <div class=\"notification-message\" ng-bind-html=\"message\"></div>\n" +
7806
+ " </div>\n" +
7807
+ " </div>\n" +
7808
+ "</div>\n"
7750
7809
  );
7751
7810
 
7752
7811