nice-elements 1.10.15 → 1.10.16

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 (38) hide show
  1. package/.vscode/settings.json +0 -1
  2. package/CHANGELOG.md +8 -0
  3. package/README.md +1 -1
  4. package/bower.json +1 -1
  5. package/dist/nice.js +320 -299
  6. package/dist/nice.min.js +1 -1
  7. package/dist/style.css.map +1 -1
  8. package/eslint.config.mjs +6 -2
  9. package/package.json +4 -4
  10. package/src/components/nice-calendar/nice-calendar.js +16 -16
  11. package/src/components/nice-choice/nice-choice.js +6 -6
  12. package/src/components/nice-click-outside/nice-click-outside.js +7 -7
  13. package/src/components/nice-comment/nice-comment.js +2 -2
  14. package/src/components/nice-date/nice-date.js +5 -3
  15. package/src/components/nice-date-input/nice-date-input.js +3 -3
  16. package/src/components/nice-date-range/nice-date-range.js +2 -2
  17. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.js +21 -21
  18. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +8 -7
  19. package/src/components/nice-dropdown/nice-dropdown.js +29 -22
  20. package/src/components/nice-dropdown/nice-dropdown.scss +1 -1
  21. package/src/components/nice-dropdown-date/nice-dropdown-date.js +9 -5
  22. package/src/components/nice-dropdown-date/nice-dropdown-date.scss +5 -1
  23. package/src/components/nice-dropdown-old/nice-dropdown-old.js +26 -27
  24. package/src/components/nice-dtp/nice-dtp.js +85 -85
  25. package/src/components/nice-help/nice-help.js +7 -4
  26. package/src/components/nice-input/nice-input.js +8 -8
  27. package/src/components/nice-notification/nice-notification.js +42 -42
  28. package/src/components/nice-number/nice-number.js +3 -3
  29. package/src/components/nice-percent/nice-percent.js +1 -1
  30. package/src/components/nice-popup/nice-popup.js +2 -2
  31. package/src/components/nice-search/nice-search.js +12 -9
  32. package/src/components/nice-search2/nice-search2.js +15 -13
  33. package/src/components/nice-time-picker/nice-time-picker.js +1 -1
  34. package/src/components/nice-toast/nice-toast.js +2 -2
  35. package/src/components/nice-upload/nice-upload.js +4 -4
  36. package/src/filters/nice-date.js +1 -1
  37. package/src/filters/nice-highlight.js +2 -2
  38. package/src/services/nice-service.js +2 -2
package/dist/nice.js CHANGED
@@ -162,7 +162,7 @@ angular.module('niceElements')
162
162
  }
163
163
 
164
164
  scope.month = angular.copy(moment(scope.startDate));
165
- var start = angular.copy(moment(scope.startDate));
165
+ const start = angular.copy(moment(scope.startDate));
166
166
  _removeTimeWithDate(start.date(0));
167
167
  _buildMonth(scope, start, scope.month);
168
168
  }
@@ -173,7 +173,7 @@ angular.module('niceElements')
173
173
  // ------------------ Day was selected ------------------
174
174
  scope.select = function (day) {
175
175
  if (!day.isDisabled) {
176
- var selectedDate = angular.copy(day.date);
176
+ const selectedDate = angular.copy(day.date);
177
177
 
178
178
  if (scope.selectStart) {
179
179
  if (!scope.time) {
@@ -286,7 +286,7 @@ angular.module('niceElements')
286
286
 
287
287
  // ------------------ Go to next month ------------------
288
288
  scope.next = function () {
289
- var next = angular.copy(scope.month);
289
+ const next = angular.copy(scope.month);
290
290
  _removeTimeWithDate(next.month(next.month() + 1).date(0));
291
291
  scope.month.month(scope.month.month() + 1);
292
292
  _buildMonth(scope, next, scope.month);
@@ -295,7 +295,7 @@ angular.module('niceElements')
295
295
 
296
296
  // ------------------ Go to previous month ------------------
297
297
  scope.previous = function () {
298
- var previous = angular.copy(scope.month);
298
+ const previous = angular.copy(scope.month);
299
299
  _removeTimeWithDate(previous.month(previous.month() - 1).date(0));
300
300
  scope.month.month(scope.month.month() - 1);
301
301
  _buildMonth(scope, previous, scope.month);
@@ -304,8 +304,8 @@ angular.module('niceElements')
304
304
 
305
305
  // ------------------ Check if dates are equal without time ------------------
306
306
  scope.isSameDay = function (date1, date2) {
307
- var d1 = _removeTime(angular.copy(date1));
308
- var d2 = _removeTime(angular.copy(date2));
307
+ const d1 = _removeTime(angular.copy(date1));
308
+ const d2 = _removeTime(angular.copy(date2));
309
309
  return d1.isSame(d2);
310
310
  };
311
311
 
@@ -325,25 +325,25 @@ angular.module('niceElements')
325
325
 
326
326
  // ------------------ Lighten color by 20% ------------------
327
327
  scope.lighten = function (col) {
328
- var amt = 20;
329
- var usePound = false;
328
+ const amt = 20;
329
+ let usePound = false;
330
330
 
331
331
  if (col[0] == "#") {
332
332
  col = col.slice(1);
333
333
  usePound = true;
334
334
  }
335
335
 
336
- var num = parseInt(col, 16);
337
- var r = (num >> 16) + amt;
336
+ const num = parseInt(col, 16);
337
+ let r = (num >> 16) + amt;
338
338
 
339
339
  if (r > 255) r = 255;
340
340
  else if (r < 0) r = 0;
341
341
 
342
- var b = ((num >> 8) & 0x00FF) + amt;
342
+ let b = ((num >> 8) & 0x00FF) + amt;
343
343
  if (b > 255) b = 255;
344
344
  else if (b < 0) b = 0;
345
345
 
346
- var g = (num & 0x0000FF) + amt;
346
+ let g = (num & 0x0000FF) + amt;
347
347
  if (g > 255) g = 255;
348
348
  else if (g < 0) g = 0;
349
349
 
@@ -365,7 +365,7 @@ angular.module('niceElements')
365
365
  // ------------------ Build month ------------------
366
366
  function _buildMonth(scope, start, month) {
367
367
  scope.weeks = [];
368
- var done = false, date = start.clone().startOf('week').isoWeekday(1), monthIndex = date.month(), count = 0;
368
+ let done = false, date = start.clone().startOf('week').isoWeekday(1), monthIndex = date.month(), count = 0;
369
369
  date.add(1, "w");
370
370
  while (!done) {
371
371
  scope.weeks.push({ days: _buildWeek(date.clone(), month) });
@@ -378,9 +378,9 @@ angular.module('niceElements')
378
378
 
379
379
  // ------------------ Build week ------------------
380
380
  function _buildWeek(date, month) {
381
- var days = [];
382
- for (var i = 0; i < 7; i++) {
383
- var day = {
381
+ const days = [];
382
+ for (let i = 0; i < 7; i++) {
383
+ const day = {
384
384
  name: date.format("dd"),
385
385
  number: date.date(),
386
386
  isCurrentMonth: date.month() === month.month(),
@@ -503,7 +503,7 @@ angular.module('niceElements')
503
503
  scope.internalList = scope.list;
504
504
  } else {
505
505
  scope.internalList = _.map(scope.list, function (val) {
506
- var obj = {};
506
+ const obj = {};
507
507
  obj[scope.objKey] = val;
508
508
  obj[scope.objValue] = val;
509
509
  return obj;
@@ -516,14 +516,14 @@ angular.module('niceElements')
516
516
  } else {
517
517
  if (scope.multiple) {
518
518
  scope.internalSelected = _.map(scope.model, function (val) {
519
- var obj = {};
519
+ const obj = {};
520
520
  obj[scope.objKey] = val;
521
521
  obj[scope.objValue] = val;
522
522
  return obj;
523
523
  });
524
524
  } else {
525
525
  if (scope.model) {
526
- var obj = {};
526
+ const obj = {};
527
527
  obj[scope.objKey] = scope.model;
528
528
  obj[scope.objValue] = scope.model;
529
529
  scope.internalSelected = obj;
@@ -534,9 +534,9 @@ angular.module('niceElements')
534
534
  }
535
535
  },
536
536
  controller: function ($rootScope, $scope) {
537
- var getFilter = function (item) {
537
+ const getFilter = function (item) {
538
538
  // Create filter for finding object by objValue with _.where()
539
- var filter = {};
539
+ const filter = {};
540
540
  if (item.hasOwnProperty($scope.objKey))
541
541
  filter[$scope.objKey] = item[$scope.objKey];
542
542
  else
@@ -593,7 +593,7 @@ angular.module('niceElements')
593
593
  $scope.internalList = $scope.list;
594
594
  } else {
595
595
  $scope.internalList = _.map($scope.list, function (val) {
596
- var obj = {};
596
+ const obj = {};
597
597
  obj[$scope.objKey] = val;
598
598
  obj[$scope.objValue] = val;
599
599
  return obj;
@@ -661,25 +661,25 @@ angular.module('niceElements')
661
661
  * # clickOutside
662
662
  */
663
663
  angular.module('niceElements')
664
- .directive('clickOutside', function($document, $parse, $timeout){
664
+ .directive('clickOutside', function ($document, $parse, $timeout) {
665
665
  return {
666
666
  restrict: 'A',
667
667
  link: function ($scope, elem, attr) {
668
668
  $scope.isOpen = false;
669
669
 
670
670
  // watch for is open
671
- attr.$observe('isOpen', function(value){
671
+ attr.$observe('isOpen', function (value) {
672
672
  $scope.isOpen = value == 'true';
673
673
  });
674
674
 
675
675
  $timeout(function () {
676
676
  // postpone linking to next digest to allow for unique id generation
677
- var classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [];
678
- var fn;
677
+ const classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [];
678
+ let fn;
679
679
 
680
680
  function eventHandler(e) {
681
681
  if ($scope.isOpen) {
682
- var i, element, r, id, classNames, l;
682
+ let i, element, r, id, classNames, l;
683
683
 
684
684
  // if there is no click target, no point going on
685
685
  if (!e || !e.target) {
@@ -723,7 +723,7 @@ angular.module('niceElements')
723
723
  // if we have got this far, then we are good to go with processing the command passed in via the click-outside attribute
724
724
  $timeout(function () {
725
725
  fn = $parse(attr['clickOutside']);
726
- fn($scope, {event: e});
726
+ fn($scope, { event: e });
727
727
  });
728
728
  }
729
729
  }
@@ -757,7 +757,7 @@ angular.module('niceElements')
757
757
  });
758
758
  }
759
759
  };
760
- });
760
+ });
761
761
  'use strict';
762
762
 
763
763
  /**
@@ -795,7 +795,7 @@ angular.module('niceElements')
795
795
  if (!attrs.help) { attrs.help = ''; }
796
796
  if (!attrs.rows) { attrs.rows = 1; }
797
797
 
798
- var textareas = element.find('textarea');
798
+ const textareas = element.find('textarea');
799
799
 
800
800
  scope.edit = function () {
801
801
  scope.editing = true;
@@ -808,7 +808,7 @@ angular.module('niceElements')
808
808
  autosize();
809
809
 
810
810
  function autosize() {
811
- var el = textareas[0];
811
+ const el = textareas[0];
812
812
  $timeout(function () {
813
813
  el.style.cssText = 'height:auto; padding:0';
814
814
 
@@ -888,7 +888,7 @@ angular.module('niceElements')
888
888
 
889
889
  // -------------------- On date change --------------------
890
890
  $scope.handleChange = function () {
891
- var newModel = moment($scope.modelDate + " " + $scope.modelTime, $scope.formatDate + " " + $scope.formatTime).seconds(0).milliseconds(0);
891
+ const newModel = moment($scope.modelDate + " " + $scope.modelTime, $scope.formatDate + " " + $scope.formatTime).seconds(0).milliseconds(0);
892
892
  if (newModel.isValid()) {
893
893
  $scope.model = newModel;
894
894
  $scope.niceDateInputForm.$setValidity('validDate', true);
@@ -909,7 +909,7 @@ angular.module('niceElements')
909
909
 
910
910
  // -------------------- Date --------------------
911
911
  $scope.dateBlur = function () {
912
- var newDate = moment($scope.modelDate, $scope.formatDate);
912
+ const newDate = moment($scope.modelDate, $scope.formatDate);
913
913
  if (newDate.isValid()) {
914
914
  $scope.niceDateInputForm.$setValidity('validDate', true);
915
915
  $scope.handleChange();
@@ -920,7 +920,7 @@ angular.module('niceElements')
920
920
 
921
921
  // -------------------- Time --------------------
922
922
  $scope.timeBlur = function () {
923
- var newTime = moment($scope.modelTime, $scope.formatTime);
923
+ const newTime = moment($scope.modelTime, $scope.formatTime);
924
924
  if (newTime.isValid()) {
925
925
  $scope.niceDateInputForm.$setValidity('validDate', true);
926
926
  $scope.handleChange();
@@ -982,7 +982,7 @@ angular.module('niceElements')
982
982
  attrs.noMargin = angular.isDefined(attrs.noMargin);
983
983
 
984
984
  if (!angular.isDefined(scope.model)) {
985
- var model = null;
985
+ let model = null;
986
986
  if (!angular.isDefined(scope.startOfTheYear)) {
987
987
  model = {
988
988
  startDate: moment().format(),
@@ -1015,7 +1015,7 @@ angular.module('niceElements')
1015
1015
  $scope.opts.ranges[gettextCatalog.getString("Last 30 days", null, "Nice")] = [moment().subtract(30, 'days'), moment()];
1016
1016
  $scope.opts.ranges[gettextCatalog.getString("This month", null, "Nice")] = [moment().startOf('month'), moment().endOf('month')];
1017
1017
 
1018
- if (angular.isDefined($scope.format)) $scope.opts.format = format;
1018
+ if (angular.isDefined($scope.format)) $scope.opts.format = $scope.format;
1019
1019
  }
1020
1020
 
1021
1021
  };
@@ -1053,10 +1053,12 @@ angular.module('niceElements')
1053
1053
  isDisabled: '=',
1054
1054
  isInline: '=',
1055
1055
  onChange: '&?',
1056
- required: '='
1056
+ required: '=',
1057
+ placement: '@', // Describes the preferred placement of the popper
1057
1058
  },
1058
1059
  controller: function ($scope, $element, $timeout, gettextCatalog) {
1059
1060
  $scope.isOpen = false;
1061
+ if (!$scope.placement) { $scope.placement = "bottom-start"; }
1060
1062
  if ($scope.date == undefined) $scope.date = true;
1061
1063
  if ($scope.time == undefined) $scope.time = false;
1062
1064
  $scope.hours = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];
@@ -1119,7 +1121,7 @@ angular.module('niceElements')
1119
1121
  const tooltip = $element[0].getElementsByClassName('nice-date-dropdown-wrapper')[0];
1120
1122
  $scope.popper = Popper.createPopper(button, tooltip, {
1121
1123
  strategy: 'fixed',
1122
- placement: 'bottom-start',
1124
+ placement: $scope.placement,
1123
1125
  modifiers: [
1124
1126
  {
1125
1127
  name: 'offset',
@@ -1305,7 +1307,7 @@ angular.module('niceElements')
1305
1307
 
1306
1308
 
1307
1309
  // ------------------ Watch for model change ------------------
1308
- $scope.$watchGroup(["model", 'minDate', 'maxDate', 'nextDate'], function (value) {
1310
+ $scope.$watchGroup(["model", 'minDate', 'maxDate', 'nextDate'], function () {
1309
1311
  $scope.bootstrap();
1310
1312
  });
1311
1313
 
@@ -1471,7 +1473,8 @@ angular.module('niceElements')
1471
1473
  help: '@',
1472
1474
  isInline: '=',
1473
1475
  onChange: '&?',
1474
- required: '='
1476
+ required: '=',
1477
+ placement: '@', // Describes the preferred placement of the popper
1475
1478
  },
1476
1479
  templateUrl: 'src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html',
1477
1480
  controller: function ($element, $timeout, $scope) {
@@ -1484,7 +1487,7 @@ angular.module('niceElements')
1484
1487
 
1485
1488
  // Set defaults
1486
1489
  if ($scope.time == undefined) $scope.time = false;
1487
-
1490
+ if (!$scope.placement) { $scope.placement = "bottom-start"; }
1488
1491
 
1489
1492
  // Set format string
1490
1493
  if (!$scope.formatString) {
@@ -1510,11 +1513,11 @@ angular.module('niceElements')
1510
1513
  // Setup popper
1511
1514
  // https://popper.js.org/docs/v2/constructors/
1512
1515
  $scope.setupPopper = function () {
1513
- var button = $element[0].getElementsByClassName('nice-daterange-picker-button')[0];
1514
- var tooltip = $element[0].getElementsByClassName('nice-daterange-picker-wrapper')[0];
1516
+ const button = $element[0].getElementsByClassName('nice-daterange-picker-button')[0];
1517
+ const tooltip = $element[0].getElementsByClassName('nice-daterange-picker-wrapper')[0];
1515
1518
  $scope.popper = Popper.createPopper(button, tooltip, {
1516
1519
  strategy: 'fixed',
1517
- placement: 'bottom-start',
1520
+ placement: $scope.placement,
1518
1521
  modifiers: [
1519
1522
  {
1520
1523
  name: 'offset',
@@ -1594,14 +1597,14 @@ angular.module('niceElements')
1594
1597
  if ($scope.model.innerStartDate && $scope.model.innerEndDate) {
1595
1598
  // Check if start date is after end date
1596
1599
  if ($scope.model.innerStartDate.isAfter($scope.model.innerEndDate)) {
1597
- var temp = angular.copy($scope.model.innerStartDate);
1600
+ const temp = angular.copy($scope.model.innerStartDate);
1598
1601
  $scope.model.innerStartDate = angular.copy($scope.model.innerEndDate);
1599
1602
  $scope.model.innerEndDate = temp;
1600
1603
  }
1601
1604
 
1602
1605
  // Check if end date is before start date
1603
1606
  if ($scope.model.innerEndDate.isBefore($scope.model.innerStartDate)) {
1604
- var temp = angular.copy($scope.model.innerStartDate);
1607
+ const temp = angular.copy($scope.model.innerStartDate);
1605
1608
  $scope.model.innerStartDate = angular.copy($scope.model.innerEndDate);
1606
1609
  $scope.model.innerEndDate = temp;
1607
1610
  }
@@ -1662,7 +1665,7 @@ angular.module('niceElements')
1662
1665
  pre: function ($scope) {
1663
1666
  console.warn("[NICE ELEMENTS] nice-datetimerange-picker component is deprecated!");
1664
1667
  // Default parameters
1665
- var params = {
1668
+ const params = {
1666
1669
  title: '',
1667
1670
  noMargin: false,
1668
1671
  fieldWidth: 'col-sm-8',
@@ -1684,26 +1687,26 @@ angular.module('niceElements')
1684
1687
 
1685
1688
  if ($scope.formatOutput === undefined) $scope.formatOutput = false;
1686
1689
 
1687
- var setLabelValue = function () {
1688
- var _from = moment($scope.internalStart).format(params.format);
1689
- var _to = moment($scope.internalEnd).format(params.format);
1690
+ const setLabelValue = function () {
1691
+ const _from = moment($scope.internalStart).format(params.format);
1692
+ const _to = moment($scope.internalEnd).format(params.format);
1690
1693
  $scope.value = _from + ' - ' + _to;
1691
1694
  };
1692
1695
 
1693
- var initCurrentDates = function () {
1696
+ const initCurrentDates = function () {
1694
1697
  if (typeof ($scope.modelStart) === 'undefined' || $scope.modelStart === null) {
1695
- var _start = moment().subtract(1, 'days');
1698
+ let _start = moment().subtract(1, 'days');
1696
1699
  if ($scope.formatOutput) _start = _start.format(params.modelFormat);
1697
1700
  $scope.modelStart = _start;
1698
1701
 
1699
1702
  } else {
1700
1703
  if (!params.date && params.time) {
1701
1704
  // if only time
1702
- var _time = moment();
1703
- var i_hour = params.modelFormat.indexOf('HH:mm');
1704
- var i_min = params.modelFormat.indexOf('mm');
1705
- var hours = $scope.model.substring(i_hour, i_hour + 2);
1706
- var minutes = $scope.model.substring(i_min, i_min + 2);
1705
+ const _time = moment();
1706
+ const i_hour = params.modelFormat.indexOf('HH:mm');
1707
+ const i_min = params.modelFormat.indexOf('mm');
1708
+ const hours = $scope.model.substring(i_hour, i_hour + 2);
1709
+ const minutes = $scope.model.substring(i_min, i_min + 2);
1707
1710
 
1708
1711
  if (i_hour > -1 && i_min > -1) {
1709
1712
  _time.hours(hours);
@@ -1721,18 +1724,18 @@ angular.module('niceElements')
1721
1724
 
1722
1725
  // initialize dateEnd
1723
1726
  if (typeof ($scope.modelEnd) === 'undefined' || $scope.modelEnd === null) {
1724
- var _end = moment();
1727
+ let _end = moment();
1725
1728
  if ($scope.formatOutput) _end = _end.format(params.modelFormat);
1726
1729
  $scope.modelEnd = _end;
1727
1730
 
1728
1731
  } else {
1729
1732
  if (!params.date && params.time) {
1730
1733
  // if only time
1731
- var _time = moment();
1732
- var i_hour = params.modelFormat.indexOf('HH:mm');
1733
- var i_min = params.modelFormat.indexOf('mm');
1734
- var hours = $scope.model.substring(i_hour, i_hour + 2);
1735
- var minutes = $scope.model.substring(i_min, i_min + 2);
1734
+ const _time = moment();
1735
+ const i_hour = params.modelFormat.indexOf('HH:mm');
1736
+ const i_min = params.modelFormat.indexOf('mm');
1737
+ const hours = $scope.model.substring(i_hour, i_hour + 2);
1738
+ const minutes = $scope.model.substring(i_min, i_min + 2);
1736
1739
 
1737
1740
  if (i_hour > -1 && i_min > -1) {
1738
1741
  _time.hours(hours);
@@ -1793,11 +1796,11 @@ angular.module('niceElements')
1793
1796
 
1794
1797
  $scope.okClick = function () {
1795
1798
  setLabelValue();
1796
- var _start = moment($scope.internalStart, params.modelFormat);
1799
+ let _start = moment($scope.internalStart, params.modelFormat);
1797
1800
  if ($scope.formatOutput) _start = _start.format(params.modelFormat);
1798
1801
  $scope.modelStart = _start;
1799
1802
 
1800
- var _end = moment($scope.internalEnd, params.modelFormat);
1803
+ let _end = moment($scope.internalEnd, params.modelFormat);
1801
1804
  if ($scope.formatOutput) _end = _end.format(params.modelFormat);
1802
1805
  $scope.modelEnd = _end;
1803
1806
 
@@ -1812,9 +1815,9 @@ angular.module('niceElements')
1812
1815
  $scope.showDtpRange = false;
1813
1816
  //$scope.internalStart = angular.copy($scope.modelStart);
1814
1817
  //$scope.internalEnd = angular.copy($scope.modelEnd);
1815
- var _start = moment($scope.modelStart);
1818
+ let _start = moment($scope.modelStart);
1816
1819
  if ($scope.formatOutput) _start = _start.format(params.modelFormat);
1817
- var _end = moment($scope.modelEnd);
1820
+ let _end = moment($scope.modelEnd);
1818
1821
  if ($scope.formatOutput) _end = _end.format(params.modelFormat);
1819
1822
 
1820
1823
  $scope.internalStart = _start;
@@ -1897,7 +1900,7 @@ angular.module('niceElements')
1897
1900
  onChange: '&?',
1898
1901
  required: '='
1899
1902
  },
1900
- link: function ($scope) {
1903
+ controller: function ($scope, $timeout) {
1901
1904
  $scope.days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31];
1902
1905
  $scope.months = [
1903
1906
  { value: 0, name: gettextCatalog.getString('Jan', null, 'Nice') },
@@ -1928,7 +1931,7 @@ angular.module('niceElements')
1928
1931
 
1929
1932
  // Create years array
1930
1933
  $scope.years = [];
1931
- for (var i = currentYear; i >= oldestYear; i--) {
1934
+ for (let i = currentYear; i >= oldestYear; i--) {
1932
1935
  if (i <= newestYear) {
1933
1936
  $scope.years.push(i);
1934
1937
  }
@@ -1942,7 +1945,7 @@ angular.module('niceElements')
1942
1945
  // Watch for model change
1943
1946
  $scope.$watch('model', function (newDate, oldDate) {
1944
1947
  if (newDate && newDate != oldDate) {
1945
- var date = moment(newDate);
1948
+ const date = moment(newDate);
1946
1949
  $scope.dateFields.day = date.get('date');
1947
1950
  $scope.dateFields.month = date.get('month');
1948
1951
  $scope.dateFields.year = date.get('year');
@@ -1958,11 +1961,15 @@ angular.module('niceElements')
1958
1961
  if (date.isValid()) {
1959
1962
  // Format
1960
1963
  $scope.model = date.format();
1961
- if ($scope.onChange) $scope.onChange({ model: $scope.model });
1964
+ if ($scope.onChange) {
1965
+ $timeout(function () {
1966
+ $scope.onChange({ model: $scope.model });
1967
+ })
1968
+ }
1962
1969
 
1963
1970
  // Change dates
1964
1971
  $scope.days = [];
1965
- for (i = 1; i <= date.daysInMonth(); i++) {
1972
+ for (let i = 1; i <= date.daysInMonth(); i++) {
1966
1973
  $scope.days.push(i);
1967
1974
  }
1968
1975
 
@@ -2063,9 +2070,9 @@ angular.module('niceElements')
2063
2070
 
2064
2071
 
2065
2072
  // ----------------------------------- Get filter -----------------------------------
2066
- var getFilter = function (item) {
2073
+ const getFilter = function (item) {
2067
2074
  // Create filter for finding object by objValue with _.where()
2068
- var filter = {};
2075
+ const filter = {};
2069
2076
  if (item.hasOwnProperty($scope.objKey))
2070
2077
  filter[$scope.objKey] = item[$scope.objKey];
2071
2078
  else
@@ -2075,15 +2082,15 @@ angular.module('niceElements')
2075
2082
 
2076
2083
 
2077
2084
  // ----------------------------------- Set internal list -----------------------------------
2078
- var _set_internal_list = function () {
2085
+ const _set_internal_list = function () {
2079
2086
  $scope.internalList = angular.copy($scope.list);
2080
2087
  };
2081
2088
 
2082
2089
 
2083
2090
  // ----------------------------------- Add null object to internal list -----------------------------------
2084
- var _add_null_object_to_internal = function () {
2091
+ const _add_null_object_to_internal = function () {
2085
2092
  if ($scope.nullable && !$scope.multiple) {
2086
- var nullObj = {};
2093
+ const nullObj = {};
2087
2094
  nullObj[$scope.objKey] = null;
2088
2095
  nullObj[$scope.objValue] = '-';
2089
2096
  $scope.internalList = [nullObj].concat($scope.internalList);
@@ -2092,7 +2099,7 @@ angular.module('niceElements')
2092
2099
 
2093
2100
 
2094
2101
  // ----------------------------------- Get selected object -----------------------------------
2095
- var _get_selected_object = function (selected) {
2102
+ const _get_selected_object = function (selected) {
2096
2103
  if (!selected) return null;
2097
2104
  if ($scope.selectedIsObj) {
2098
2105
  return selected;
@@ -2103,10 +2110,10 @@ angular.module('niceElements')
2103
2110
 
2104
2111
 
2105
2112
  // ----------------------------------- Init -----------------------------------
2106
- var _set_internal_selected_one = function (selected) {
2107
- var obj = {};
2113
+ const _set_internal_selected_one = function (selected) {
2114
+ let obj = {};
2108
2115
 
2109
- var selectedObj = _get_selected_object(selected);
2116
+ const selectedObj = _get_selected_object(selected);
2110
2117
  // console.log('_set_internal_selected_one', selected, selectedObj);
2111
2118
  if (selectedObj && _.find($scope.internalList, getFilter(selected))) {
2112
2119
  obj = selectedObj;
@@ -2119,13 +2126,12 @@ angular.module('niceElements')
2119
2126
 
2120
2127
 
2121
2128
  // ----------------------------------- Get selected objects -----------------------------------
2122
- var _get_selected_objects = function (selected) {
2123
- if (!selected)
2124
- return null;
2129
+ const _get_selected_objects = function (selected) {
2130
+ if (!selected) return null;
2125
2131
 
2126
- if ($scope.selectedIsObj)
2132
+ if ($scope.selectedIsObj) {
2127
2133
  return selected;
2128
- else {
2134
+ } else {
2129
2135
  // from [1,2,3] get list of objects [{}, {}, {}]
2130
2136
  return _.map(selected, function (val) {
2131
2137
  return _.find($scope.internalList, getFilter(val));
@@ -2135,8 +2141,8 @@ angular.module('niceElements')
2135
2141
 
2136
2142
 
2137
2143
  // ----------------------------------- Set internal selected multiple -----------------------------------
2138
- var _set_internal_selected_multiple = function (item) {
2139
- var _selected_objects = _get_selected_objects(item);
2144
+ const _set_internal_selected_multiple = function (item) {
2145
+ const _selected_objects = _get_selected_objects(item);
2140
2146
  if (_selected_objects) {
2141
2147
  $scope.internalSelected = _selected_objects;
2142
2148
  _set_model($scope.internalSelected);
@@ -2148,8 +2154,8 @@ angular.module('niceElements')
2148
2154
 
2149
2155
 
2150
2156
  // ----------------------------------- Set model -----------------------------------
2151
- var _set_model = function (value) {
2152
- var _new = angular.copy($scope.model);
2157
+ const _set_model = function (value) {
2158
+ let _new = angular.copy($scope.model);
2153
2159
 
2154
2160
  if (!$scope.multiple) {
2155
2161
  if (value[$scope.objKey] == null) {
@@ -2180,7 +2186,7 @@ angular.module('niceElements')
2180
2186
 
2181
2187
 
2182
2188
  // ----------------------------------- Init -----------------------------------
2183
- var init = function () {
2189
+ const init = function () {
2184
2190
  _set_internal_list();
2185
2191
  _add_null_object_to_internal();
2186
2192
 
@@ -2211,7 +2217,7 @@ angular.module('niceElements')
2211
2217
  } else {
2212
2218
  // Disable dropdown button if list of items is empty
2213
2219
  $scope.emptyList = true;
2214
- var sel = {};
2220
+ const sel = {};
2215
2221
  sel[$scope.objKey] = null;
2216
2222
  sel[$scope.objValue] = $scope.noOptionsText;
2217
2223
  $scope.internalList = [sel];
@@ -2247,7 +2253,7 @@ angular.module('niceElements')
2247
2253
  $scope.formDropdown.$setDirty();
2248
2254
  if ($scope.multiple) {
2249
2255
  // This actually toggles selection
2250
- var _current = angular.copy($scope.internalSelected);
2256
+ let _current = angular.copy($scope.internalSelected);
2251
2257
  if (!_.find(_current, getFilter(item))) {
2252
2258
  _current.push(item);
2253
2259
  } else {
@@ -2280,10 +2286,11 @@ angular.module('niceElements')
2280
2286
 
2281
2287
  // ----------------------------------- Watch for model change -----------------------------------
2282
2288
  $scope.$watch('model', function (value_new, value_old) {
2289
+ let _new_model_object = null;
2283
2290
  if ($scope.multiple) {
2284
- var _new_model_object = _get_selected_object(value_new);
2291
+ _new_model_object = _get_selected_object(value_new);
2285
2292
  } else {
2286
- var _new_model_object = _get_selected_objects(value_new);
2293
+ _new_model_object = _get_selected_objects(value_new);
2287
2294
  }
2288
2295
 
2289
2296
  if (!_.isEqual(_new_model_object, $scope.internalSelected)) {
@@ -2298,11 +2305,11 @@ angular.module('niceElements')
2298
2305
  $element.bind('keyup', function (e) {
2299
2306
  // bind to keypress events if dropdown list is opened
2300
2307
  if ($scope.isOpen) {
2301
- var char = String.fromCharCode(e.which).toLowerCase();
2308
+ const char = String.fromCharCode(e.which).toLowerCase();
2302
2309
 
2303
2310
  // find first element with value starting on selected char
2304
- var index = _.findIndex($scope.internalList, function (item) {
2305
- var _name = item[$scope.objValue].toLowerCase();
2311
+ const index = _.findIndex($scope.internalList, function (item) {
2312
+ const _name = item[$scope.objValue].toLowerCase();
2306
2313
  return _name.indexOf(char) === 0;
2307
2314
  });
2308
2315
 
@@ -2323,7 +2330,6 @@ angular.module('niceElements')
2323
2330
  $scope.unbindKeypress = function () {
2324
2331
  $element.off('keyup', function (e) { });
2325
2332
  };
2326
-
2327
2333
  }
2328
2334
  };
2329
2335
  });
@@ -2337,7 +2343,7 @@ angular.module('niceElements')
2337
2343
  * # nice-dropdown
2338
2344
  */
2339
2345
  angular.module('niceElements')
2340
- .directive('niceDropdown', function ($window) {
2346
+ .directive('niceDropdown', function () {
2341
2347
  return {
2342
2348
  templateUrl: 'src/components/nice-dropdown/nice-dropdown.html',
2343
2349
  restrict: 'E',
@@ -2379,7 +2385,8 @@ angular.module('niceElements')
2379
2385
  filterFunction: '=?',
2380
2386
  isInline: '=',
2381
2387
  clearOnSelect: '@',
2382
- enableLoadMore: '@' // Enable load more
2388
+ enableLoadMore: '@', // Enable load more
2389
+ placement: '@', // Describes the preferred placement of the popper
2383
2390
  },
2384
2391
  controller: function ($scope, $http, $element, $timeout, gettextCatalog, NiceService) {
2385
2392
  $scope.id = Math.random().toString(36).substring(7);
@@ -2393,6 +2400,7 @@ angular.module('niceElements')
2393
2400
  if (!$scope.selectText) { $scope.selectText = gettextCatalog.getString("None", null, "Nice"); }
2394
2401
  if (!$scope.selectedText) { $scope.selectedText = gettextCatalog.getString("selected", null, "Nice"); }
2395
2402
  if (!$scope.addButtonFunction) { $scope.addButtonFunction = null; }
2403
+ if (!$scope.placement) { $scope.placement = "bottom-start"; }
2396
2404
  $scope.nullable = $scope.nullable === 'true' || $scope.nullable === true;
2397
2405
  $scope.noMargin = $scope.noMargin === 'true' || $scope.noMargin === true;
2398
2406
  $scope.multiple = $scope.multiple === 'true' || $scope.multiple === true;
@@ -2413,10 +2421,11 @@ angular.module('niceElements')
2413
2421
  // Setup popper
2414
2422
  // https://popper.js.org/docs/v2/constructors/
2415
2423
  $scope.setupPopper = function () {
2416
- var button = $element[0].getElementsByClassName('btn-dropdown')[0];
2417
- var tooltip = $element[0].getElementsByClassName('nice-dropdown-menu-wrapper')[0];
2424
+ const button = $element[0].getElementsByClassName('btn-dropdown')[0];
2425
+ const tooltip = $element[0].getElementsByClassName('nice-dropdown-menu-wrapper')[0];
2418
2426
  $scope.popper = Popper.createPopper(button, tooltip, {
2419
2427
  strategy: 'fixed',
2428
+ placement: $scope.placement,
2420
2429
  scroll: true,
2421
2430
  resize: true,
2422
2431
  modifiers: [
@@ -2432,12 +2441,16 @@ angular.module('niceElements')
2432
2441
  phase: "beforeWrite",
2433
2442
  requires: ["computeStyles"],
2434
2443
  fn: function (e) {
2435
- var state = e.state;
2436
- state.styles.popper.width = state.rects.reference.width + "px";
2444
+ const state = e.state;
2445
+ let width = state.rects.reference.width;
2446
+ if (width < 200) width = 200;
2447
+ state.styles.popper.width = width + "px";
2437
2448
  },
2438
2449
  effect: function (e) {
2439
- var state = e.state;
2440
- state.elements.popper.style.width = state.elements.reference.offsetWidth + "px";
2450
+ const state = e.state;
2451
+ let width = state.elements.reference.width;
2452
+ if (width < 200) width = 200;
2453
+ state.elements.popper.style.width = width + "px";
2441
2454
  }
2442
2455
  }
2443
2456
  ],
@@ -2482,12 +2495,12 @@ angular.module('niceElements')
2482
2495
 
2483
2496
 
2484
2497
  // ----------------------------------- Handle scroll to bottom -----------------------------------
2485
- var lastScrollPosition = Infinity;
2498
+ let lastScrollPosition = Infinity;
2486
2499
  $scope.handleScrollToBottom = function () {
2487
2500
  lastScrollPosition = Infinity;
2488
- var element = angular.element($element[0].getElementsByClassName("nice-dropdown-items")[0]);
2501
+ const element = angular.element($element[0].getElementsByClassName("nice-dropdown-items")[0]);
2489
2502
  element.bind("scroll mousewheel", function (e) {
2490
- var scrollPosition = element[0].scrollHeight - element[0].scrollTop;
2503
+ const scrollPosition = element[0].scrollHeight - element[0].scrollTop;
2491
2504
  if (scrollPosition === element[0].clientHeight && lastScrollPosition != scrollPosition) {
2492
2505
  $scope.loadMore();
2493
2506
  }
@@ -2506,7 +2519,7 @@ angular.module('niceElements')
2506
2519
  headers: NiceService.getHeader()
2507
2520
  }).then(function (response) {
2508
2521
  response = response.data;
2509
- var metadata = {
2522
+ const metadata = {
2510
2523
  count: response.count,
2511
2524
  previous: response.previous,
2512
2525
  next: response.next,
@@ -2557,13 +2570,13 @@ angular.module('niceElements')
2557
2570
 
2558
2571
  // ----------------------------------- Scroll to hover -----------------------------------
2559
2572
  $scope.scrollToHover = function (notSmooth) {
2560
- var dropdownMenu = $element[0].getElementsByClassName("nice-dropdown-menu")[0];
2573
+ const dropdownMenu = $element[0].getElementsByClassName("nice-dropdown-menu")[0];
2561
2574
  if (!dropdownMenu) return;
2562
- var dorpdownList = dropdownMenu.getElementsByClassName("nice-dropdown-items")[0];
2563
- var hoverItem = dorpdownList.getElementsByClassName("hover")[0];
2575
+ const dropdownList = dropdownMenu.getElementsByClassName("nice-dropdown-items")[0];
2576
+ const hoverItem = dropdownList.getElementsByClassName("hover")[0];
2564
2577
  if (!hoverItem) return
2565
- var topPos = hoverItem.offsetTop;
2566
- dorpdownList.scroll({
2578
+ const topPos = hoverItem.offsetTop;
2579
+ dropdownList.scroll({
2567
2580
  top: topPos - 120,
2568
2581
  left: 0,
2569
2582
  behavior: notSmooth ? 'auto' : 'smooth'
@@ -2579,7 +2592,7 @@ angular.module('niceElements')
2579
2592
  $scope.handleNewInternalList(response);
2580
2593
  $scope.loading = false;
2581
2594
  $scope.handleDefault();
2582
- }, function (error) {
2595
+ }, function () {
2583
2596
  $scope.internalList = null;
2584
2597
  $scope.loading = false;
2585
2598
  });
@@ -2655,7 +2668,7 @@ angular.module('niceElements')
2655
2668
 
2656
2669
  // ----------------------------------- Handle set model -----------------------------------
2657
2670
  $scope.handleSetModel = function () {
2658
- var obj = angular.copy($scope.selected);
2671
+ let obj = angular.copy($scope.selected);
2659
2672
 
2660
2673
  if ($scope.selected != null) {
2661
2674
  // Remove selected flag
@@ -2822,10 +2835,10 @@ angular.module('niceElements')
2822
2835
  if ($scope.searchFunction) {
2823
2836
  $scope.handleSearch();
2824
2837
  }
2825
-
2826
-
2838
+
2839
+
2827
2840
  // ----------------------------------- Handle add button function -----------------------------------
2828
- $scope.handleAddButton = function($event) {
2841
+ $scope.handleAddButton = function ($event) {
2829
2842
  let element = $event.target;
2830
2843
  while (true) {
2831
2844
  if (element.nodeName == 'BUTTON') {
@@ -2882,7 +2895,7 @@ angular.module('niceElements')
2882
2895
  console.warn("[NICE ELEMENTS] nice-dtp component is deprecated!");
2883
2896
 
2884
2897
  // default parameters
2885
- var params = {
2898
+ const params = {
2886
2899
  title: '',
2887
2900
  noMargin: false,
2888
2901
  fieldWidth: 'col-sm-8',
@@ -2902,7 +2915,7 @@ angular.module('niceElements')
2902
2915
  enableOkButtons: false
2903
2916
  };
2904
2917
 
2905
- var prepareAttrs = function () {
2918
+ const prepareAttrs = function () {
2906
2919
  // prepare attributes
2907
2920
  params.date = $attrs.date === 'true' || $attrs.date === true;
2908
2921
  params.time = $attrs.time === 'true' || $attrs.time === true;
@@ -2941,8 +2954,8 @@ angular.module('niceElements')
2941
2954
  $scope.date = $attrs.date === 'true' || $attrs.date === true;
2942
2955
  $scope.time = $attrs.time === 'true' || $attrs.time === true;
2943
2956
 
2944
- // functions are defined in a variable 'var that', not in $scope
2945
- var that = {
2957
+ // functions are defined in a variable 'const that', not in $scope
2958
+ const that = {
2946
2959
  init: function () {
2947
2960
  //console.log('init', $scope);
2948
2961
 
@@ -2953,7 +2966,7 @@ angular.module('niceElements')
2953
2966
  initDays: function () {
2954
2967
  //console.log('initDays');
2955
2968
  $scope.days = [];
2956
- for (var i = params.weekStart; $scope.days.length < 7; i++) {
2969
+ for (let i = params.weekStart; $scope.days.length < 7; i++) {
2957
2970
  if (i > 6) {
2958
2971
  i = 0;
2959
2972
  }
@@ -3015,7 +3028,7 @@ angular.module('niceElements')
3015
3028
  $scope.showCalendar = true;
3016
3029
  $scope.showTime = false;
3017
3030
 
3018
- var _date = ((typeof ($scope.currentDate) !== 'undefined' && $scope.currentDate !== null) ? $scope.currentDate : null);
3031
+ const _date = ((typeof ($scope.currentDate) !== 'undefined' && $scope.currentDate !== null) ? $scope.currentDate : null);
3019
3032
  $scope.calendar = that.generateCalendar($scope.currentDate);
3020
3033
 
3021
3034
  if (typeof ($scope.calendar.week) !== 'undefined' && typeof ($scope.calendar.days) !== 'undefined') {
@@ -3036,24 +3049,24 @@ angular.module('niceElements')
3036
3049
 
3037
3050
  that.showTime($scope.currentDate);
3038
3051
 
3039
- var pL = 10;
3040
- var pT = 10;
3041
- var mL = 20;
3042
- var mT = 10;
3043
- var r = 100;
3052
+ const pL = 10;
3053
+ const pT = 10;
3054
+ const mL = 20;
3055
+ const mT = 10;
3056
+ const r = 100;
3044
3057
 
3045
- var j = r / 1.55;
3046
- var j_pm = r / 1.15;
3058
+ const j = r / 1.55;
3059
+ const j_pm = r / 1.15;
3047
3060
 
3048
- var _hours = [];
3061
+ const _hours = [];
3049
3062
 
3050
3063
  // AM hours
3051
- for (var h = 0; h < 12; ++h) {
3052
- var cH = (($scope.currentDate.format('HH') == 24) ? 0 : $scope.currentDate.format('HH'));
3053
- var x = j * Math.sin(Math.PI * 2 * (h / 12));
3054
- var y = j * Math.cos(Math.PI * 2 * (h / 12));
3064
+ for (let h = 0; h < 12; ++h) {
3065
+ const cH = (($scope.currentDate.format('HH') == 24) ? 0 : $scope.currentDate.format('HH'));
3066
+ const x = j * Math.sin(Math.PI * 2 * (h / 12));
3067
+ const y = j * Math.cos(Math.PI * 2 * (h / 12));
3055
3068
 
3056
- var _hour = {
3069
+ const _hour = {
3057
3070
  style: {
3058
3071
  x: x,
3059
3072
  y: y,
@@ -3068,12 +3081,12 @@ angular.module('niceElements')
3068
3081
  }
3069
3082
 
3070
3083
  // PM hours
3071
- for (var h = 0; h < 12; ++h) {
3072
- var cH = (($scope.currentDate.format('HH') == 24) ? 0 : $scope.currentDate.format('HH'));
3073
- var x = j_pm * Math.sin(Math.PI * 2 * (h / 12));
3074
- var y = j_pm * Math.cos(Math.PI * 2 * (h / 12));
3084
+ for (let h = 0; h < 12; ++h) {
3085
+ const cH = (($scope.currentDate.format('HH') == 24) ? 0 : $scope.currentDate.format('HH'));
3086
+ const x = j_pm * Math.sin(Math.PI * 2 * (h / 12));
3087
+ const y = j_pm * Math.cos(Math.PI * 2 * (h / 12));
3075
3088
 
3076
- var _hour = {
3089
+ const _hour = {
3077
3090
  style: {
3078
3091
  x: x,
3079
3092
  y: y,
@@ -3101,20 +3114,20 @@ angular.module('niceElements')
3101
3114
 
3102
3115
  that.showTime($scope.currentDate);
3103
3116
 
3104
- var pL = 10;
3105
- var pT = 10;
3106
- var mL = 20;
3107
- var mT = 10;
3108
- var w = 200;
3109
- var r = w / 2;
3110
- var j = r / 1.2;
3111
- var _minutes = [];
3117
+ const pL = 10;
3118
+ const pT = 10;
3119
+ const mL = 20;
3120
+ const mT = 10;
3121
+ const w = 200;
3122
+ const r = w / 2;
3123
+ const j = r / 1.2;
3124
+ const _minutes = [];
3112
3125
 
3113
- for (var m = 0; m < 60; m += 5) {
3114
- var x = j * Math.sin(Math.PI * 2 * (m / 60));
3115
- var y = j * Math.cos(Math.PI * 2 * (m / 60));
3126
+ for (let m = 0; m < 60; m += 5) {
3127
+ const x = j * Math.sin(Math.PI * 2 * (m / 60));
3128
+ const y = j * Math.cos(Math.PI * 2 * (m / 60));
3116
3129
 
3117
- var _minute = {
3130
+ const _minute = {
3118
3131
  style: {
3119
3132
  x: x,
3120
3133
  y: y,
@@ -3133,27 +3146,27 @@ angular.module('niceElements')
3133
3146
  that._centerBox();
3134
3147
  },
3135
3148
  initHands: function (t) {
3136
- var pL = 10;
3137
- var mL = 20;
3138
- var w = 7.5;
3139
- var h = 7.5;
3140
- var r = 100;
3141
- var _hL = r / 1.7;
3142
- var _mL = r / 1.5;
3143
-
3144
- var dtpHourHand = $element[0].getElementsByClassName('dtp-hour-hand')[0];
3149
+ const pL = 10;
3150
+ const mL = 20;
3151
+ const w = 7.5;
3152
+ const h = 7.5;
3153
+ const r = 100;
3154
+ const _hL = r / 1.7;
3155
+ const _mL = r / 1.5;
3156
+
3157
+ const dtpHourHand = $element[0].getElementsByClassName('dtp-hour-hand')[0];
3145
3158
  dtpHourHand.style.left = r + (parseInt(mL) * 1.5) + 'px';
3146
3159
  dtpHourHand.style.height = _hL + 'px';
3147
3160
  dtpHourHand.style.marginTop = (r - _hL - parseInt(pL)) + 'px';
3148
3161
  if (t) dtpHourHand.classList.add("on");
3149
3162
 
3150
- var dtpMinuteHand = $element[0].getElementsByClassName('dtp-minute-hand')[0];
3163
+ const dtpMinuteHand = $element[0].getElementsByClassName('dtp-minute-hand')[0];
3151
3164
  dtpMinuteHand.style.left = r + (parseInt(mL) * 1.5) + 'px';
3152
3165
  dtpMinuteHand.style.height = _mL + 'px';
3153
3166
  dtpMinuteHand.style.marginTop = (r - _mL - parseInt(pL)) + 'px';
3154
3167
  if (t) dtpMinuteHand.classList.add("on");
3155
3168
 
3156
- var dtpClockCenter = $element[0].getElementsByClassName('dtp-clock-center')[0];
3169
+ const dtpClockCenter = $element[0].getElementsByClassName('dtp-clock-center')[0];
3157
3170
  dtpClockCenter.style.left = r + parseInt(pL) + parseInt(mL) - w + 'px';
3158
3171
  dtpClockCenter.style.marginTop = (r - (parseInt(mL) / 2)) - h + 'px';
3159
3172
 
@@ -3162,20 +3175,20 @@ angular.module('niceElements')
3162
3175
  that._centerBox();
3163
3176
  },
3164
3177
  animateHands: function () {
3165
- var h = $scope.currentDate.hour();
3166
- var m = $scope.currentDate.minute();
3178
+ const h = $scope.currentDate.hour();
3179
+ const m = $scope.currentDate.minute();
3167
3180
 
3168
- var dtpHourHand = $element[0].getElementsByClassName('dtp-hour-hand')[0];
3169
- var dtpMinuteHand = $element[0].getElementsByClassName('dtp-minute-hand')[0];
3181
+ const dtpHourHand = $element[0].getElementsByClassName('dtp-hour-hand')[0];
3182
+ const dtpMinuteHand = $element[0].getElementsByClassName('dtp-minute-hand')[0];
3170
3183
  that.rotateElement(dtpHourHand, (360 / 12) * h);
3171
3184
  that.rotateElement(dtpMinuteHand, ((360 / 60) * (5 * Math.round(m / 5))));
3172
3185
  },
3173
3186
  isAfterMinDate: function (date, checkHour, checkMinute) {
3174
- var _return = true;
3187
+ let _return = true;
3175
3188
 
3176
3189
  if (typeof ($scope.minDate) !== 'undefined' && $scope.minDate !== null) {
3177
- var _minDate = moment($scope.minDate);
3178
- var _date = moment(date);
3190
+ const _minDate = moment($scope.minDate);
3191
+ const _date = moment(date);
3179
3192
 
3180
3193
  if (!checkHour && !checkMinute) {
3181
3194
  _minDate.hour(0);
@@ -3203,11 +3216,11 @@ angular.module('niceElements')
3203
3216
  return _return;
3204
3217
  },
3205
3218
  isBeforeMaxDate: function (date, checkTime, checkMinute) {
3206
- var _return = true;
3219
+ let _return = true;
3207
3220
 
3208
3221
  if (typeof ($scope.maxDate) !== 'undefined' && $scope.maxDate !== null) {
3209
- var _maxDate = moment($scope.maxDate);
3210
- var _date = moment(date);
3222
+ const _maxDate = moment($scope.maxDate);
3223
+ const _date = moment(date);
3211
3224
 
3212
3225
  if (!checkTime && !checkMinute) {
3213
3226
  _maxDate.hour(0);
@@ -3251,8 +3264,8 @@ angular.module('niceElements')
3251
3264
  showTime: function (date) {
3252
3265
  //console.log('showTime', date);
3253
3266
  if (date) {
3254
- var _minutes = (5 * Math.round(date.minute() / 5));
3255
- var _time = {
3267
+ const _minutes = (5 * Math.round(date.minute() / 5));
3268
+ const _time = {
3256
3269
  hours: date.format('HH'),
3257
3270
  minutes: ((_minutes.toString().length == 2) ? _minutes : '0' + _minutes)
3258
3271
  };
@@ -3283,22 +3296,22 @@ angular.module('niceElements')
3283
3296
  },
3284
3297
  generateCalendar: function (date) {
3285
3298
  //console.log('generateCalendar');
3286
- var _calendar = {};
3299
+ const _calendar = {};
3287
3300
 
3288
3301
  if (date !== null) {
3289
- var startOfMonth = moment(date).locale(params.lang).startOf('month');
3290
- var endOfMonth = moment(date).locale(params.lang).endOf('month');
3302
+ const startOfMonth = moment(date).locale(params.lang).startOf('month');
3303
+ const endOfMonth = moment(date).locale(params.lang).endOf('month');
3291
3304
 
3292
- var iNumDay = startOfMonth.format('d');
3305
+ const iNumDay = startOfMonth.format('d');
3293
3306
 
3294
3307
  _calendar.week = $scope.days;
3295
3308
  _calendar.days = [];
3296
3309
 
3297
- for (var i = startOfMonth.date(); i <= endOfMonth.date(); i++) {
3310
+ for (let i = startOfMonth.date(); i <= endOfMonth.date(); i++) {
3298
3311
  if (i === startOfMonth.date()) {
3299
- var iWeek = _calendar.week.indexOf(iNumDay.toString());
3312
+ const iWeek = _calendar.week.indexOf(iNumDay.toString());
3300
3313
  if (iWeek > 0) {
3301
- for (var x = 0; x < iWeek; x++) {
3314
+ for (let x = 0; x < iWeek; x++) {
3302
3315
  _calendar.days.push(0);
3303
3316
  }
3304
3317
  }
@@ -3312,24 +3325,24 @@ angular.module('niceElements')
3312
3325
  constructHTMLCalendar: function (date, calendar) {
3313
3326
  $scope.monthAndYear = date.locale(params.lang).format('MMMM YYYY');
3314
3327
 
3315
- var _weekDays = [];
3316
- for (var i = 0; i < calendar.week.length; i++) {
3328
+ const _weekDays = [];
3329
+ for (let i = 0; i < calendar.week.length; i++) {
3317
3330
  _weekDays.push(moment(parseInt(calendar.week[i]), "d").locale(params.lang).format("dd").substring(0, 1));
3318
3331
  }
3319
3332
  $scope.weekDays = _weekDays;
3320
3333
 
3321
- var _weeks = [];
3334
+ const _weeks = [];
3322
3335
 
3323
- var _week = [];
3324
- for (var i = 0; i < calendar.days.length; i++) {
3336
+ let _week = [];
3337
+ for (let i = 0; i < calendar.days.length; i++) {
3325
3338
  if (i % 7 == 0) {
3326
3339
  if (i != 0) {
3327
3340
  _weeks.push(_week);
3328
3341
  }
3329
- var _week = [];
3342
+ _week = [];
3330
3343
  }
3331
3344
 
3332
- var _day = {
3345
+ const _day = {
3333
3346
  label: null,
3334
3347
  selected: false,
3335
3348
  disabled: true,
@@ -3361,10 +3374,10 @@ angular.module('niceElements')
3361
3374
  //console.log('$scope.weekDays', $scope.weekDays);
3362
3375
  },
3363
3376
  setName: function () {
3364
- var text = "";
3365
- var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
3377
+ let text = "";
3378
+ const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
3366
3379
 
3367
- for (var i = 0; i < 5; i++) {
3380
+ for (let i = 0; i < 5; i++) {
3368
3381
  text += possible.charAt(Math.floor(Math.random() * possible.length));
3369
3382
  }
3370
3383
 
@@ -3389,14 +3402,14 @@ angular.module('niceElements')
3389
3402
  },
3390
3403
  toggleButtons: function (date) {
3391
3404
  if (date && date.isValid()) {
3392
- var startOfMonth = moment(date).locale(params.lang).startOf('month');
3393
- var endOfMonth = moment(date).locale(params.lang).endOf('month');
3405
+ const startOfMonth = moment(date).locale(params.lang).startOf('month');
3406
+ const endOfMonth = moment(date).locale(params.lang).endOf('month');
3394
3407
 
3395
3408
  $scope.btnMonthBeforeEnabled = that.isAfterMinDate(startOfMonth, false, false);
3396
3409
  $scope.btnMonthAfterEnabled = that.isBeforeMaxDate(endOfMonth, false, false);
3397
3410
 
3398
- var startOfYear = moment(date).locale(params.lang).startOf('year');
3399
- var endOfYear = moment(date).locale(params.lang).endOf('year');
3411
+ const startOfYear = moment(date).locale(params.lang).startOf('year');
3412
+ const endOfYear = moment(date).locale(params.lang).endOf('year');
3400
3413
 
3401
3414
  $scope.btnYearBeforeEnabled = that.isAfterMinDate(startOfYear, false, false);
3402
3415
  $scope.btnYearAfterEnabled = that.isBeforeMaxDate(endOfYear, false, false);
@@ -3405,7 +3418,7 @@ angular.module('niceElements')
3405
3418
  toggleTime: function (isHours) {
3406
3419
  if (isHours) {
3407
3420
  angular.forEach($scope.hours, function (hour, hourKey) {
3408
- var _date = moment($scope.currentDate);
3421
+ const _date = moment($scope.currentDate);
3409
3422
  _date.hour(that.convertHours(hour.h)).minute(0).second(0);
3410
3423
 
3411
3424
  if (that.isAfterMinDate(_date, true, false) === false || that.isBeforeMaxDate(_date, true, false) === false) {
@@ -3416,8 +3429,8 @@ angular.module('niceElements')
3416
3429
  });
3417
3430
  } else {
3418
3431
  angular.forEach($scope.minutes, function (minute, minuteKey) {
3419
- var _minute = minute.m;
3420
- var _date = moment($scope.currentDate);
3432
+ const _minute = minute.m;
3433
+ const _date = moment($scope.currentDate);
3421
3434
  _date.minute(_minute).second(0);
3422
3435
 
3423
3436
  if (that.isAfterMinDate(_date, true, true) === false || that.isBeforeMaxDate(_date, true, true) === false) {
@@ -3550,7 +3563,7 @@ angular.module('niceElements')
3550
3563
  });
3551
3564
  hourSelected.selected = true;
3552
3565
 
3553
- var dataHour = parseInt(hourSelected.h);
3566
+ let dataHour = parseInt(hourSelected.h);
3554
3567
  if (that.isPM())
3555
3568
  dataHour += 12;
3556
3569
 
@@ -3585,7 +3598,7 @@ angular.module('niceElements')
3585
3598
  }
3586
3599
  },
3587
3600
  convertHours: function (h) {
3588
- var _return = h;
3601
+ let _return = h;
3589
3602
 
3590
3603
  if ((h < 12) && that.isPM())
3591
3604
  _return += 12;
@@ -3690,17 +3703,20 @@ angular.module('niceElements')
3690
3703
  restrict: 'E',
3691
3704
  replace: true,
3692
3705
  scope: {
3693
- text: '@'
3706
+ text: '@',
3707
+ placement: '@', // Describes the preferred placement of the popper
3694
3708
  },
3695
3709
  controller: function ($scope, $element, $timeout) {
3710
+ if (!$scope.placement) { $scope.placement = "top"; }
3711
+
3696
3712
  // Setup popper
3697
3713
  // https://popper.js.org/docs/v2/constructors/
3698
3714
  $scope.setupPopper = function () {
3699
- var button = $element[0].getElementsByClassName('nice-help-button')[0];
3700
- var tooltip = $element[0].getElementsByClassName('nice-help-popup')[0];
3715
+ const button = $element[0].getElementsByClassName('nice-help-button')[0];
3716
+ const tooltip = $element[0].getElementsByClassName('nice-help-popup')[0];
3701
3717
  $scope.popper = Popper.createPopper(button, tooltip, {
3702
3718
  strategy: 'fixed',
3703
- placement: 'top',
3719
+ placement: $scope.placement,
3704
3720
  scroll: true,
3705
3721
  resize: true,
3706
3722
  modifiers: [
@@ -3876,12 +3892,12 @@ angular.module('niceElements')
3876
3892
  }
3877
3893
 
3878
3894
  if (angular.isDefined($scope.regexRaw) && $scope.regexRaw != '') {
3879
- $scope.regexexp = regexRaw;
3895
+ $scope.regexexp = $scope.regexRaw;
3880
3896
  }
3881
3897
 
3882
3898
  $scope.$watch('model', function (value_new, value_old) {
3883
- if ($scope.type == "number" && value_old && value_old[value_old.length-1] == ".") {
3884
-
3899
+ if ($scope.type == "number" && value_old && value_old[value_old.length - 1] == ".") {
3900
+ // IGNORE
3885
3901
  } else {
3886
3902
  $scope.internalModel = angular.copy($scope.model);
3887
3903
  }
@@ -3908,9 +3924,9 @@ angular.module('niceElements')
3908
3924
  }
3909
3925
  });
3910
3926
 
3911
- $scope.handleChange = function() {
3927
+ $scope.handleChange = function () {
3912
3928
  if ($scope.onChange) {
3913
- $timeout(function() {
3929
+ $timeout(function () {
3914
3930
  $scope.onChange({ model: $scope.model });
3915
3931
  })
3916
3932
  }
@@ -3935,8 +3951,8 @@ angular.module('niceElements')
3935
3951
 
3936
3952
  // Open multilanguage modal
3937
3953
  $scope.openMultilanguage = function () {
3938
- var scope = $rootScope.$new(true);
3939
- var dialog = ngDialog.open({
3954
+ const scope = $rootScope.$new(true);
3955
+ const dialog = ngDialog.open({
3940
3956
  template: '<nice-multilangual-modal model="model" multilanguage="multilanguage" multilanguage-field="{{ multilanguageField }}" callback="callback" dialog="dialog"></nice-multilangual-modal>',
3941
3957
  plain: true,
3942
3958
  scope: scope,
@@ -3948,7 +3964,7 @@ angular.module('niceElements')
3948
3964
  scope.multilanguage = angular.copy($scope.multilanguage);
3949
3965
  scope.multilanguageField = $scope.multilanguageField;
3950
3966
  scope.callback = function (newFields) {
3951
- var filteredFields = {};
3967
+ const filteredFields = {};
3952
3968
  angular.forEach(newFields, function (value, key) {
3953
3969
  if (value != '') filteredFields[key] = value;
3954
3970
  })
@@ -4098,75 +4114,76 @@ angular.module('niceElements')
4098
4114
  angular.module('niceElements')
4099
4115
  .factory('NiceNotification', function ($timeout, $http, $compile, $templateCache, $rootScope, $sce) {
4100
4116
 
4101
- var startTop = 10;
4102
- var startRight = 10;
4103
- var verticalSpacing = 10;
4104
- var horizontalSpacing = 10;
4105
- var delay = 5000;
4117
+ let startTop = 10;
4118
+ let startRight = 10;
4119
+ let verticalSpacing = 10;
4120
+ let horizontalSpacing = 10;
4121
+ let delay = 5000;
4106
4122
 
4107
- var messageElements = [];
4123
+ const messageElements = [];
4108
4124
 
4109
- var notify = function(args, t){
4125
+ const notify = function (args, t) {
4110
4126
 
4111
- if (typeof args !== 'object'){
4112
- args = {message:args};
4127
+ if (typeof args !== 'object') {
4128
+ args = { message: args };
4113
4129
  }
4114
4130
 
4115
4131
  args.template = args.template ? args.template : 'src/components/nice-notification/nice-notification.html';
4116
4132
  args.delay = !angular.isUndefined(args.delay) ? args.delay : delay;
4117
4133
  args.type = t ? t : '';
4118
4134
 
4119
- $http.get(args.template,{cache: $templateCache}).success(function(template) {
4135
+ $http.get(args.template, { cache: $templateCache }).success(function (template) {
4120
4136
 
4121
- var scope = $rootScope.$new();
4137
+ const scope = $rootScope.$new();
4122
4138
  scope.message = $sce.trustAsHtml(args.message);
4123
4139
  scope.title = $sce.trustAsHtml(args.title);
4124
- scope.t = args.type.substr(0,1);
4140
+ scope.t = args.type.substr(0, 1);
4125
4141
  scope.delay = args.delay;
4126
4142
 
4127
- if (typeof args.scope === 'object'){
4128
- for (var key in args.scope){
4143
+ if (typeof args.scope === 'object') {
4144
+ for (let key in args.scope) {
4129
4145
  scope[key] = args.scope[key];
4130
4146
  }
4131
4147
  }
4132
4148
 
4133
- var reposite = function() {
4134
- var j = 0;
4135
- var k = 0;
4136
- var lastTop = startTop;
4137
- var lastRight = startRight;
4138
- for(var i = messageElements.length - 1; i >= 0; i --) {
4139
- var element = messageElements[i];
4140
- var elHeight = parseInt(element[0].offsetHeight);
4141
- var elWidth = parseInt(element[0].offsetWidth);
4149
+ const reposite = function () {
4150
+ let j = 0;
4151
+ let k = 0;
4152
+ let lastTop = startTop;
4153
+ let top = 0;
4154
+ // const lastRight = startRight;
4155
+ for (let i = messageElements.length - 1; i >= 0; i--) {
4156
+ const element = messageElements[i];
4157
+ const elHeight = parseInt(element[0].offsetHeight);
4158
+ const elWidth = parseInt(element[0].offsetWidth);
4142
4159
  if ((top + elHeight) > window.innerHeight) {
4143
4160
  lastTop = startTop;
4144
- k ++;
4161
+ k++;
4145
4162
  j = 0;
4146
4163
  }
4147
- var top = lastTop + (j === 0 ? 0 : verticalSpacing);
4148
- var right = startRight + (k * (horizontalSpacing + elWidth));
4164
+ top = lastTop + (j === 0 ? 0 : verticalSpacing);
4165
+ const right = startRight + (k * (horizontalSpacing + elWidth));
4149
4166
 
4150
4167
  element.css('top', top + 'px');
4151
4168
  element.css('right', right + 'px');
4152
4169
 
4153
4170
  lastTop = top + elHeight;
4154
- j ++;
4171
+ j++;
4155
4172
  }
4156
4173
  };
4157
4174
 
4158
- var templateElement = $compile(template)(scope);
4175
+ const templateElement = $compile(template)(scope);
4159
4176
  templateElement.addClass(args.type);
4160
- templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function(e){
4177
+ templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
4161
4178
  e = e.originalEvent || e;
4162
- if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)){
4179
+ if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
4163
4180
  templateElement.remove();
4164
4181
  messageElements.splice(messageElements.indexOf(templateElement), 1);
4165
4182
  reposite();
4166
4183
  }
4167
4184
  });
4168
4185
 
4169
- $timeout(function() {
4186
+ $timeout(function () {
4170
4187
  templateElement.addClass('killed');
4171
4188
  templateElement.remove();
4172
4189
  messageElements.splice(messageElements.indexOf(templateElement), 1);
@@ -4178,34 +4195,33 @@ angular.module('niceElements')
4178
4195
 
4179
4196
  $timeout(reposite);
4180
4197
 
4181
- }).error(function(data){
4182
- throw new Error('Template ('+args.template+') could not be loaded. ' + data);
4198
+ }).error(function (data) {
4199
+ throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
4183
4200
  });
4184
-
4185
4201
  };
4186
4202
 
4187
- notify.config = function(args){
4188
- startTop = args.top ? args.top : startTop;
4189
- verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
4203
+ notify.config = function (args) {
4204
+ startTop = args.top ? args.top : startTop;
4205
+ verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
4190
4206
  };
4191
4207
 
4192
- notify.primary = function() {
4208
+ notify.primary = function (args) {
4193
4209
  this(args, '');
4194
4210
  };
4195
4211
 
4196
- notify.error = function(args) {
4212
+ notify.error = function (args) {
4197
4213
  this(args, 'error');
4198
4214
  };
4199
4215
 
4200
- notify.success = function(args) {
4216
+ notify.success = function (args) {
4201
4217
  this(args, 'success');
4202
4218
  };
4203
4219
 
4204
- notify.info = function(args) {
4220
+ notify.info = function (args) {
4205
4221
  this(args, 'info');
4206
4222
  };
4207
4223
 
4208
- notify.warning = function(args) {
4224
+ notify.warning = function (args) {
4209
4225
  this(args, 'warning');
4210
4226
  };
4211
4227
 
@@ -4347,7 +4363,7 @@ angular.module('niceElements')
4347
4363
  $scope.$watch("model", function (oldModel, newModel) {
4348
4364
  $scope.check();
4349
4365
  if ($scope.onChange && oldModel != newModel) {
4350
- $timeout(function() {
4366
+ $timeout(function () {
4351
4367
  $scope.onChange({ model: $scope.model });
4352
4368
  })
4353
4369
  }
@@ -4356,7 +4372,7 @@ angular.module('niceElements')
4356
4372
 
4357
4373
  // Add to the value
4358
4374
  $scope.add = function () {
4359
- var result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).plus($scope.step).toNumber(); //.toFixed($scope.decimals);
4375
+ const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).plus($scope.step).toNumber(); //.toFixed($scope.decimals);
4360
4376
  if ($scope.max) {
4361
4377
  if (result <= parseFloat($scope.max)) {
4362
4378
  $scope.model = result;
@@ -4372,7 +4388,7 @@ angular.module('niceElements')
4372
4388
 
4373
4389
  // Subtract to the value
4374
4390
  $scope.subtract = function () {
4375
- var result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).minus($scope.step).toNumber();
4391
+ const result = new Decimal($scope.model != undefined ? $scope.model : $scope.defaultValue).minus($scope.step).toNumber();
4376
4392
  if (result >= Number($scope.min)) {
4377
4393
  $scope.model = result;
4378
4394
  $scope.niceNumberForm.$setDirty();
@@ -4428,7 +4444,7 @@ angular.module('niceElements')
4428
4444
  $scope.valid = $scope.form;
4429
4445
  }
4430
4446
 
4431
- var roundN = function (number, decimals) {
4447
+ const roundN = function (number, decimals) {
4432
4448
  return Number(new Decimal(String(number)).toFixed(decimals, 4));
4433
4449
  };
4434
4450
 
@@ -4565,8 +4581,8 @@ angular.module('niceElements')
4565
4581
  // Setup popper
4566
4582
  // https://popper.js.org/docs/v2/constructors/
4567
4583
  $scope.setupPopper = function () {
4568
- var target = $element[0].getElementsByClassName('nice-popup-target')[0];
4569
- var content = $element[0].getElementsByClassName('nice-popup-content')[0];
4584
+ const target = $element[0].getElementsByClassName('nice-popup-target')[0];
4585
+ const content = $element[0].getElementsByClassName('nice-popup-content')[0];
4570
4586
  $scope.popper = Popper.createPopper(target, content, {
4571
4587
  placement: $scope.placement,
4572
4588
  strategy: $scope.strategy,
@@ -4819,7 +4835,7 @@ angular.module('niceElements')
4819
4835
  scope.modelString = scope.model;
4820
4836
  }
4821
4837
 
4822
- var setValid = function (isValid) {
4838
+ const setValid = function (isValid) {
4823
4839
  if (scope.required && scope.form) {
4824
4840
  scope.form.$setValidity('objectSelected', isValid);
4825
4841
  }
@@ -4864,8 +4880,8 @@ angular.module('niceElements')
4864
4880
  };
4865
4881
 
4866
4882
  // Close the dropdown if clicked outside
4867
- var onClick = function (event) {
4868
- var isClickedElementChildOfPopup = element.find(event.target).length > 0;
4883
+ const onClick = function (event) {
4884
+ const isClickedElementChildOfPopup = element.find(event.target).length > 0;
4869
4885
 
4870
4886
  if (isClickedElementChildOfPopup) return;
4871
4887
 
@@ -4877,7 +4893,7 @@ angular.module('niceElements')
4877
4893
  angular.element(element).on('click', onClick);
4878
4894
 
4879
4895
  // Keyboard up/down on search results
4880
- var onKeyDown = function (event) {
4896
+ const onKeyDown = function (event) {
4881
4897
  if ((event.keyCode == 38 || event.keyCode == 40 || event.keyCode == 13 || event.keyCode == 27) && scope.results && scope.results.length > 0) {
4882
4898
  event.preventDefault();
4883
4899
 
@@ -4919,7 +4935,7 @@ angular.module('niceElements')
4919
4935
  $scope.requests = 0;
4920
4936
 
4921
4937
  $scope.focus = function () {
4922
- var input = $element[0].getElementsByTagName('input')[0];
4938
+ const input = $element[0].getElementsByTagName('input')[0];
4923
4939
  if (input) {
4924
4940
  input.focus();
4925
4941
  }
@@ -4931,7 +4947,7 @@ angular.module('niceElements')
4931
4947
  }
4932
4948
 
4933
4949
  $scope.results = [];
4934
- var updateList = function (results, requestNumber) {
4950
+ const updateList = function (results, requestNumber) {
4935
4951
 
4936
4952
  if (results) {
4937
4953
  if ($scope.requests == requestNumber) {
@@ -4950,13 +4966,16 @@ angular.module('niceElements')
4950
4966
  $scope.updateSearch = function () {
4951
4967
  $scope.loading = true;
4952
4968
 
4953
- if ($scope.timer_promise)
4954
- $timeout.cancel($scope.timer_promise);
4969
+ if ($scope.timer_promise) $timeout.cancel($scope.timer_promise);
4955
4970
 
4956
4971
  $scope.timer_promise = $timeout(function () {
4957
4972
  if ($scope.onChange) $scope.onChange({ model: $scope.model, modelString: $scope.modelString });
4973
+ if (!$scope.refreshFunction) {
4974
+ $scope.loading = false;
4975
+ return console.warn("[NICE ELEMENTS] No refresh function set to the nice-search component!");
4976
+ }
4958
4977
  $scope.requests = $scope.requests + 1;
4959
- var requestNumber = angular.copy($scope.requests);
4978
+ const requestNumber = angular.copy($scope.requests);
4960
4979
  $scope.refreshFunction($scope.modelString).then(function (response) {
4961
4980
  updateList(response, requestNumber);
4962
4981
  }, function (error) {
@@ -5019,7 +5038,8 @@ angular.module('niceElements')
5019
5038
  keyForInputLabel: '@',
5020
5039
  debounceTime: '@',
5021
5040
  isInline: '=',
5022
- help: '@'
5041
+ help: '@',
5042
+ placement: '@', // Describes the preferred placement of the popper
5023
5043
  },
5024
5044
  controller: function ($scope, $timeout, $element) {
5025
5045
  $scope.loading = false;
@@ -5032,15 +5052,16 @@ angular.module('niceElements')
5032
5052
 
5033
5053
  if (!$scope.debounceTime) $scope.debounceTime = 500;
5034
5054
  if (!$scope.model) $scope.model = "";
5055
+ if (!$scope.placement) { $scope.placement = "bottom-start"; }
5035
5056
 
5036
5057
  // Setup popper
5037
5058
  // https://popper.js.org/docs/v2/constructors/
5038
5059
  $scope.setupPopper = function () {
5039
- var button = $element[0].getElementsByClassName('nice-search-button')[0];
5040
- var tooltip = $element[0].getElementsByClassName('nice-search-dropdown-wrapper')[0];
5060
+ const button = $element[0].getElementsByClassName('nice-search-button')[0];
5061
+ const tooltip = $element[0].getElementsByClassName('nice-search-dropdown-wrapper')[0];
5041
5062
  $scope.popper = Popper.createPopper(button, tooltip, {
5042
5063
  strategy: 'fixed',
5043
- placement: 'bottom-start',
5064
+ placement: $scope.placement,
5044
5065
  modifiers: [
5045
5066
  {
5046
5067
  name: 'offset',
@@ -5054,11 +5075,11 @@ angular.module('niceElements')
5054
5075
  phase: "beforeWrite",
5055
5076
  requires: ["computeStyles"],
5056
5077
  fn: function (e) {
5057
- var state = e.state;
5078
+ const state = e.state;
5058
5079
  state.styles.popper.width = state.rects.reference.width + "px";
5059
5080
  },
5060
5081
  effect: function (e) {
5061
- var state = e.state;
5082
+ const state = e.state;
5062
5083
  state.elements.popper.style.width = state.elements.reference.offsetWidth + "px";
5063
5084
  }
5064
5085
  }
@@ -5079,7 +5100,7 @@ angular.module('niceElements')
5079
5100
 
5080
5101
  $scope.open();
5081
5102
 
5082
- var input = $element[0].getElementsByTagName('input')[0];
5103
+ const input = $element[0].getElementsByTagName('input')[0];
5083
5104
  if (input) input.focus();
5084
5105
  };
5085
5106
 
@@ -5103,7 +5124,7 @@ angular.module('niceElements')
5103
5124
  $scope.close = function () {
5104
5125
  $scope.isOpen = false;
5105
5126
 
5106
- var input = $element[0].getElementsByTagName('input')[0];
5127
+ const input = $element[0].getElementsByTagName('input')[0];
5107
5128
  if (input) input.blur();
5108
5129
 
5109
5130
  $timeout(function () {
@@ -5130,7 +5151,7 @@ angular.module('niceElements')
5130
5151
  if ($scope.refreshFunction != null) {
5131
5152
  $scope.loading = true;
5132
5153
  $scope.requestNumber += 1;
5133
- var requestNumber = angular.copy($scope.requestNumber);
5154
+ const requestNumber = angular.copy($scope.requestNumber);
5134
5155
  $scope.refreshFunction(keywords).then(function (results) {
5135
5156
  if ($scope.requestNumber == requestNumber) {
5136
5157
  $timeout(function () {
@@ -5145,7 +5166,7 @@ angular.module('niceElements')
5145
5166
  }
5146
5167
  });
5147
5168
  }
5148
- }, function (error) {
5169
+ }, function () {
5149
5170
  $scope.loading = false;
5150
5171
  $scope.close();
5151
5172
  });
@@ -5193,10 +5214,10 @@ angular.module('niceElements')
5193
5214
 
5194
5215
  // ----------------------------------- Scroll to hover -----------------------------------
5195
5216
  $scope.scrollToHover = function (notSmooth) {
5196
- var dropdownMenu = $element[0].getElementsByClassName("nice-dropdown")[0];
5197
- var hoverItem = dropdownMenu.getElementsByClassName("active")[0];
5217
+ const dropdownMenu = $element[0].getElementsByClassName("nice-dropdown")[0];
5218
+ const hoverItem = dropdownMenu.getElementsByClassName("active")[0];
5198
5219
  if (hoverItem) {
5199
- var topPos = hoverItem.offsetTop;
5220
+ const topPos = hoverItem.offsetTop;
5200
5221
  dropdownMenu.scroll({
5201
5222
  top: topPos - 120,
5202
5223
  left: 0,
@@ -5408,7 +5429,7 @@ angular.module('niceElements')
5408
5429
 
5409
5430
 
5410
5431
  $scope.checkDate = function (date) {
5411
- var parsedDate = moment(date, "HH:mm");
5432
+ const parsedDate = moment(date, "HH:mm");
5412
5433
  if (parsedDate.isValid()) {
5413
5434
  if ($scope.forma) $scope.forma.$setValidity("valid-time", true);
5414
5435
  $scope.model = parsedDate;
@@ -5505,7 +5526,7 @@ angular.module('niceElements')
5505
5526
  // -------------------------- Create toast --------------------------
5506
5527
  $scope.createToast = function (message, type) {
5507
5528
  // Create new toast
5508
- var toast = {
5529
+ const toast = {
5509
5530
  id: Math.random().toString(36).replace(/[^a-z]+/g, '').substr(2, 10),
5510
5531
  message: message,
5511
5532
  type: type || "default"
@@ -5523,7 +5544,7 @@ angular.module('niceElements')
5523
5544
 
5524
5545
  // -------------------------- Remove toast --------------------------
5525
5546
  $scope.removeToast = function (toast) {
5526
- var toastIndex = $scope.toasts.findIndex(function (a) { return a.id == toast.id })
5547
+ const toastIndex = $scope.toasts.findIndex(function (a) { return a.id == toast.id })
5527
5548
  if (toastIndex >= 0) {
5528
5549
  $scope.toasts.splice(toastIndex, 1);
5529
5550
  }
@@ -5722,7 +5743,7 @@ angular.module('niceElements')
5722
5743
 
5723
5744
  scope.dragging = false;
5724
5745
  scope.draggingGlobal = false;
5725
- var inputElement = element[0].querySelector(".input-file");
5746
+ const inputElement = element[0].querySelector(".input-file");
5726
5747
  // document.addEventListener("dragenter", scope.startDraggingGlobal);
5727
5748
  // document.addEventListener("drop", scope.endDraggingGlobal);
5728
5749
  // document.addEventListener("dragend", scope.endDraggingGlobal);
@@ -5754,12 +5775,12 @@ angular.module('niceElements')
5754
5775
  $timeout(function () {
5755
5776
  scope.loading = true;
5756
5777
  scope.error = null;
5757
- var inputObj = changeEvent.target;
5758
- var reader = new FileReader();
5778
+ const inputObj = changeEvent.target;
5779
+ const reader = new FileReader();
5759
5780
 
5760
5781
  if (inputObj.files) {
5761
5782
  try {
5762
- var fileSize = inputObj.files[0].size; // in bytes
5783
+ const fileSize = inputObj.files[0].size; // in bytes
5763
5784
 
5764
5785
  reader.onload = function (event) {
5765
5786
  $timeout(function () {
@@ -6030,7 +6051,7 @@ angular.module('niceElements')
6030
6051
  */
6031
6052
  angular.module('niceElements').filter('niceDate', function () {
6032
6053
  return function (object, addTime, addSeconds) {
6033
- var formatString = "D.M.YYYY";
6054
+ let formatString = "D.M.YYYY";
6034
6055
  if (addTime) {
6035
6056
  formatString = "D.M.YYYY • H:mm";
6036
6057
  if (addSeconds) formatString += ":ss";
@@ -6049,8 +6070,8 @@ angular.module('niceElements').filter('niceDate', function () {
6049
6070
  angular.module('niceElements').filter('niceHighlight', function () {
6050
6071
  return function (value, highlightedText) {
6051
6072
  if (!value) return "";
6052
- var regex = new RegExp(highlightedText, 'gmi');
6053
- var newValue = String(value).replace(regex, "<span class='nice-highligh'>$&</span>");
6073
+ const regex = new RegExp(highlightedText, 'gmi');
6074
+ const newValue = String(value).replace(regex, "<span class='nice-highligh'>$&</span>");
6054
6075
  return newValue;
6055
6076
  };
6056
6077
  });
@@ -6065,7 +6086,7 @@ angular.module('niceElements').filter('niceHighlight', function () {
6065
6086
  */
6066
6087
  angular.module('niceElements')
6067
6088
  .service('NiceService', function ($rootScope) {
6068
- var service = {
6089
+ const service = {
6069
6090
  name: "Nice elements",
6070
6091
  version: "1.10.15",
6071
6092
  getHeader: function () {