nice-elements 1.8.3 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.8.4 (2.6.2023)
4
+
5
+ - added filterFunction to nice dropdown,
6
+ - worked on nice-datetimerange-picker-2 mobile style,
7
+ - added size param to nice-icon,
8
+ - worked on nice-icon demo view
9
+
3
10
  ## v1.8.3 (30.5.2023)
4
11
 
5
12
  - added clickDisabled prop to nice-checkbox component
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Nice elements](https://github.com/Klemen1337/angularjs-nice-elements/raw/master/demo/assets/logo.png)
2
2
 
3
- # Nice elements v1.8.3
3
+ # Nice elements v1.8.4
4
4
 
5
5
  Nice elements is an AngularJS v1.5.8 module that contains nice form elements like inputs, choice fields, search, toggle, dropdown, etc.
6
6
 
package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -18,7 +18,7 @@ angular.module('niceElements')
18
18
  label: '@'
19
19
  },
20
20
  link: function postLink(scope, element, attrs) {
21
- if (angular.isDefined(scope.model)) {
21
+ if (angular.isDefined(scope.model)){
22
22
  scope.model = false;
23
23
  }
24
24
  }
@@ -655,14 +655,14 @@ angular.module('niceElements')
655
655
  * # clickOutside
656
656
  */
657
657
  angular.module('niceElements')
658
- .directive('clickOutside', function ($document, $parse, $timeout) {
658
+ .directive('clickOutside', function($document, $parse, $timeout){
659
659
  return {
660
660
  restrict: 'A',
661
661
  link: function ($scope, elem, attr) {
662
662
  $scope.isOpen = false;
663
663
 
664
664
  // watch for is open
665
- attr.$observe('isOpen', function (value) {
665
+ attr.$observe('isOpen', function(value){
666
666
  $scope.isOpen = value == 'true';
667
667
  });
668
668
 
@@ -717,7 +717,7 @@ angular.module('niceElements')
717
717
  // if we have got this far, then we are good to go with processing the command passed in via the click-outside attribute
718
718
  $timeout(function () {
719
719
  fn = $parse(attr['clickOutside']);
720
- fn($scope, { event: e });
720
+ fn($scope, {event: e});
721
721
  });
722
722
  }
723
723
  }
@@ -751,7 +751,7 @@ angular.module('niceElements')
751
751
  });
752
752
  }
753
753
  };
754
- });
754
+ });
755
755
  'use strict';
756
756
 
757
757
  /**
@@ -942,7 +942,7 @@ angular.module('niceElements')
942
942
  */
943
943
  angular.module('niceElements')
944
944
 
945
- .directive('niceDateRange', function () {
945
+ .directive('niceDateRange', function() {
946
946
  return {
947
947
  restrict: 'E',
948
948
  transclude: true,
@@ -962,16 +962,16 @@ angular.module('niceElements')
962
962
  onChange: '&?'
963
963
  },
964
964
 
965
- link: function (scope, attrs) {
965
+ link: function(scope, attrs){
966
966
  if (!attrs.title) { attrs.title = ''; }
967
967
  if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
968
968
  if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
969
969
  if (!attrs.format) { attrs.format = 'dd.MM.yyyy'; }
970
970
  attrs.noMargin = angular.isDefined(attrs.noMargin);
971
971
 
972
- if (!angular.isDefined(scope.model)) {
972
+ if(!angular.isDefined(scope.model)) {
973
973
  var model = null;
974
- if (!angular.isDefined(scope.startOfTheYear)) {
974
+ if(!angular.isDefined(scope.startOfTheYear)){
975
975
  model = {
976
976
  startDate: moment().format(),
977
977
  endDate: moment().format()
@@ -987,7 +987,7 @@ angular.module('niceElements')
987
987
  }
988
988
  },
989
989
 
990
- controller: function ($scope) {
990
+ controller: function($scope) {
991
991
  $scope.opts = {
992
992
  locale: {
993
993
  applyClass: 'btn-green',
@@ -1003,7 +1003,7 @@ angular.module('niceElements')
1003
1003
  $scope.opts.ranges[gettextCatalog.getString("Last 30 days", null, "Nice")] = [moment().subtract(30, 'days'), moment()];
1004
1004
  $scope.opts.ranges[gettextCatalog.getString("This month", null, "Nice")] = [moment().startOf('month'), moment().endOf('month')];
1005
1005
 
1006
- if (angular.isDefined($scope.format)) $scope.opts.format = format;
1006
+ if(angular.isDefined($scope.format)) $scope.opts.format = format;
1007
1007
  }
1008
1008
 
1009
1009
  };
@@ -2347,6 +2347,7 @@ angular.module('niceElements')
2347
2347
  selectedText: '@',
2348
2348
  dropdownDistance: '@',
2349
2349
  searchFunction: '=?',
2350
+ filterFunction: '=?',
2350
2351
  isInline: '=',
2351
2352
  clearOnSelect: '@',
2352
2353
  enableLoadMore: '@' // Enable load more
@@ -2524,7 +2525,8 @@ angular.module('niceElements')
2524
2525
  $scope.handleSearch = function () {
2525
2526
  $scope.loading = true;
2526
2527
  $scope.searchFunction($scope.internal.search).then(function (response) {
2527
- $scope.internalList = response;
2528
+ if ($scope.filterFunction) $scope.internalList = $scope.filterFunction(response);
2529
+ else $scope.internalList = response;
2528
2530
  $scope.loading = false;
2529
2531
  $scope.handleDefault();
2530
2532
  }, function (error) {
@@ -2626,7 +2628,8 @@ angular.module('niceElements')
2626
2628
 
2627
2629
  // ----------------------------------- Watch for list change -----------------------------------
2628
2630
  $scope.$watchCollection('list', function (value_new, value_old) {
2629
- $scope.internalList = angular.copy($scope.list);
2631
+ if ($scope.filterFunction) $scope.internalList = $scope.filterFunction(angular.copy($scope.list));
2632
+ else $scope.internalList = angular.copy($scope.list);
2630
2633
  $scope.handleDefault();
2631
2634
  });
2632
2635
 
@@ -3633,24 +3636,25 @@ angular.module('niceElements')
3633
3636
  };
3634
3637
  });
3635
3638
 
3636
- 'use strict';
3637
-
3638
- /**
3639
- * @ngdoc directive
3640
- * @name niceElements.directive:niceIcon
3641
- * @description
3642
- * # niceIcon
3643
- */
3644
- angular.module('niceElements')
3645
- .directive('niceIcon', function () {
3646
- return {
3647
- templateUrl: 'src/components/nice-icon/nice-icon.html',
3648
- restrict: 'E',
3649
- replace: true,
3650
- scope: {
3651
- icon: '@'
3652
- },
3653
- };
3639
+ 'use strict';
3640
+
3641
+ /**
3642
+ * @ngdoc directive
3643
+ * @name niceElements.directive:niceIcon
3644
+ * @description
3645
+ * # niceIcon
3646
+ */
3647
+ angular.module('niceElements')
3648
+ .directive('niceIcon', function () {
3649
+ return {
3650
+ templateUrl: 'src/components/nice-icon/nice-icon.html',
3651
+ restrict: 'E',
3652
+ replace: true,
3653
+ scope: {
3654
+ icon: '@',
3655
+ size: '=',
3656
+ },
3657
+ };
3654
3658
  });
3655
3659
  angular.module('niceElements')
3656
3660
  .directive('niceInput', function () {
@@ -3890,42 +3894,42 @@ angular.module('niceElements')
3890
3894
 
3891
3895
  var messageElements = [];
3892
3896
 
3893
- var notify = function (args, t) {
3897
+ var notify = function(args, t){
3894
3898
 
3895
- if (typeof args !== 'object') {
3896
- args = { message: args };
3899
+ if (typeof args !== 'object'){
3900
+ args = {message:args};
3897
3901
  }
3898
3902
 
3899
3903
  args.template = args.template ? args.template : 'src/components/nice-notification/nice-notification.html';
3900
3904
  args.delay = !angular.isUndefined(args.delay) ? args.delay : delay;
3901
3905
  args.type = t ? t : '';
3902
3906
 
3903
- $http.get(args.template, { cache: $templateCache }).success(function (template) {
3907
+ $http.get(args.template,{cache: $templateCache}).success(function(template) {
3904
3908
 
3905
3909
  var scope = $rootScope.$new();
3906
3910
  scope.message = $sce.trustAsHtml(args.message);
3907
3911
  scope.title = $sce.trustAsHtml(args.title);
3908
- scope.t = args.type.substr(0, 1);
3912
+ scope.t = args.type.substr(0,1);
3909
3913
  scope.delay = args.delay;
3910
3914
 
3911
- if (typeof args.scope === 'object') {
3912
- for (var key in args.scope) {
3915
+ if (typeof args.scope === 'object'){
3916
+ for (var key in args.scope){
3913
3917
  scope[key] = args.scope[key];
3914
3918
  }
3915
3919
  }
3916
3920
 
3917
- var reposite = function () {
3921
+ var reposite = function() {
3918
3922
  var j = 0;
3919
3923
  var k = 0;
3920
3924
  var lastTop = startTop;
3921
3925
  var lastRight = startRight;
3922
- for (var i = messageElements.length - 1; i >= 0; i--) {
3926
+ for(var i = messageElements.length - 1; i >= 0; i --) {
3923
3927
  var element = messageElements[i];
3924
3928
  var elHeight = parseInt(element[0].offsetHeight);
3925
3929
  var elWidth = parseInt(element[0].offsetWidth);
3926
3930
  if ((top + elHeight) > window.innerHeight) {
3927
3931
  lastTop = startTop;
3928
- k++;
3932
+ k ++;
3929
3933
  j = 0;
3930
3934
  }
3931
3935
  var top = lastTop + (j === 0 ? 0 : verticalSpacing);
@@ -3935,22 +3939,22 @@ angular.module('niceElements')
3935
3939
  element.css('right', right + 'px');
3936
3940
 
3937
3941
  lastTop = top + elHeight;
3938
- j++;
3942
+ j ++;
3939
3943
  }
3940
3944
  };
3941
3945
 
3942
3946
  var templateElement = $compile(template)(scope);
3943
3947
  templateElement.addClass(args.type);
3944
- templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
3948
+ templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function(e){
3945
3949
  e = e.originalEvent || e;
3946
- if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
3950
+ if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)){
3947
3951
  templateElement.remove();
3948
3952
  messageElements.splice(messageElements.indexOf(templateElement), 1);
3949
3953
  reposite();
3950
3954
  }
3951
3955
  });
3952
3956
 
3953
- $timeout(function () {
3957
+ $timeout(function() {
3954
3958
  templateElement.addClass('killed');
3955
3959
  templateElement.remove();
3956
3960
  messageElements.splice(messageElements.indexOf(templateElement), 1);
@@ -3962,34 +3966,34 @@ angular.module('niceElements')
3962
3966
 
3963
3967
  $timeout(reposite);
3964
3968
 
3965
- }).error(function (data) {
3966
- throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
3969
+ }).error(function(data){
3970
+ throw new Error('Template ('+args.template+') could not be loaded. ' + data);
3967
3971
  });
3968
3972
 
3969
3973
  };
3970
3974
 
3971
- notify.config = function (args) {
3972
- startTop = args.top ? args.top : startTop;
3973
- verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
3975
+ notify.config = function(args){
3976
+ startTop = args.top ? args.top : startTop;
3977
+ verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
3974
3978
  };
3975
3979
 
3976
- notify.primary = function () {
3980
+ notify.primary = function() {
3977
3981
  this(args, '');
3978
3982
  };
3979
3983
 
3980
- notify.error = function (args) {
3984
+ notify.error = function(args) {
3981
3985
  this(args, 'error');
3982
3986
  };
3983
3987
 
3984
- notify.success = function (args) {
3988
+ notify.success = function(args) {
3985
3989
  this(args, 'success');
3986
3990
  };
3987
3991
 
3988
- notify.info = function (args) {
3992
+ notify.info = function(args) {
3989
3993
  this(args, 'info');
3990
3994
  };
3991
3995
 
3992
- notify.warning = function (args) {
3996
+ notify.warning = function(args) {
3993
3997
  this(args, 'warning');
3994
3998
  };
3995
3999
 
@@ -4390,7 +4394,7 @@ angular.module('niceElements')
4390
4394
  * # niceProgressBar
4391
4395
  */
4392
4396
  angular.module('niceElements')
4393
- .directive('niceProgressBar', function () {
4397
+ .directive('niceProgressBar', function() {
4394
4398
  return {
4395
4399
  restrict: 'E',
4396
4400
  replace: true,
@@ -4405,29 +4409,29 @@ angular.module('niceElements')
4405
4409
  help: '@'
4406
4410
  },
4407
4411
 
4408
- controller: function ($scope, $element, $timeout) {
4412
+ controller: function($scope, $element, $timeout) {
4409
4413
  $scope.width = 0;
4410
- $scope.resize = function () {
4411
- $timeout(function () {
4414
+ $scope.resize = function(){
4415
+ $timeout(function() {
4412
4416
  $scope.width = $element[0].getElementsByClassName("progress")[0].offsetWidth;
4413
- }, 100);
4417
+ },100);
4414
4418
  };
4415
- window.onresize = function () {
4419
+ window.onresize = function() {
4416
4420
  $scope.resize();
4417
4421
  };
4418
4422
  $scope.resize();
4419
4423
 
4424
+
4420
4425
 
4421
-
4422
- $scope.$watch("value", function (valueNew, valueOld) {
4426
+ $scope.$watch("value", function(valueNew, valueOld){
4423
4427
  $scope.calculate();
4424
4428
  });
4425
4429
 
4426
- $scope.$watch("max", function (valueNew, valueOld) {
4430
+ $scope.$watch("max", function(valueNew, valueOld){
4427
4431
  $scope.calculate();
4428
4432
  });
4429
4433
 
4430
- $scope.calculate = function () {
4434
+ $scope.calculate = function(){
4431
4435
  $scope.percentage = ($scope.value / $scope.max) * 100;
4432
4436
  };
4433
4437
 
@@ -5453,24 +5457,24 @@ angular.module('niceElements')
5453
5457
  isInline: '=',
5454
5458
  help: '@'
5455
5459
  },
5456
- controller: function ($scope, gettextCatalog) {
5460
+ controller: function($scope, gettextCatalog) {
5457
5461
  if (!$scope.yes) { $scope.yes = gettextCatalog.getString('Yes', null, "Nice"); }
5458
5462
  if (!$scope.no) { $scope.no = gettextCatalog.getString('No', null, "Nice"); }
5459
5463
  if (!$scope.title) { $scope.title = ''; }
5460
5464
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
5461
5465
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
5462
- if (!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
5463
- if (!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
5466
+ if(!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
5467
+ if(!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
5464
5468
 
5465
5469
  $scope.defaultFalse = angular.isDefined($scope.defaultFalse);
5466
5470
  $scope.noMargin = angular.isDefined($scope.noMargin);
5467
5471
 
5468
5472
  $scope.buttonClass = "";
5469
-
5473
+
5470
5474
 
5471
5475
  // ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
5472
- $scope.setButtonPosition = function (state) {
5473
- if (state) {
5476
+ $scope.setButtonPosition = function(state) {
5477
+ if(state) {
5474
5478
  $scope.buttonClass = "yesno-button-yes";
5475
5479
  } else {
5476
5480
  $scope.buttonClass = "yesno-button-no";
@@ -5478,48 +5482,48 @@ angular.module('niceElements')
5478
5482
  };
5479
5483
 
5480
5484
  // ------------------------- Watch for changes from outside -------------------------
5481
- $scope.$watch('model', function (value_new, value_old) {
5482
- if (angular.isDefined($scope.model)) {
5485
+ $scope.$watch('model', function(value_new, value_old){
5486
+ if(angular.isDefined($scope.model)){
5483
5487
  $scope.setButtonLabel($scope.model);
5484
5488
  $scope.setButtonPosition($scope.model);
5485
5489
  }
5486
5490
  });
5487
5491
 
5488
5492
  // ------------------------- Watch for model value -------------------------
5489
- $scope.$watch('modelValue', function (value_new, value_old) {
5490
- if ($scope.options) {
5493
+ $scope.$watch('modelValue', function(value_new, value_old){
5494
+ if($scope.options){
5491
5495
  $scope.model = $scope.modelValue == $scope.options[0];
5492
5496
  }
5493
5497
  });
5494
5498
 
5495
5499
  // ------------------------- Set button label -------------------------
5496
- $scope.setButtonLabel = function (state) {
5500
+ $scope.setButtonLabel = function(state){
5497
5501
  if (state) {
5498
5502
  $scope.state = $scope.yes;
5499
5503
  } else {
5500
5504
  $scope.state = $scope.no;
5501
5505
  }
5502
5506
  };
5503
-
5507
+
5504
5508
  // ------------------------- Set width -------------------------
5505
- $scope.setWidth = function (width, el) {
5509
+ $scope.setWidth = function(width, el){
5506
5510
  el.style.width = width;
5507
5511
  };
5508
-
5512
+
5509
5513
 
5510
5514
  // ------------------------- Switch -------------------------
5511
- $scope.switch = function () {
5512
- if (!$scope.isDisabled) {
5515
+ $scope.switch = function(){
5516
+ if(!$scope.isDisabled){
5513
5517
  $scope.model = !$scope.model;
5514
-
5515
- if ($scope.options) {
5516
- if ($scope.model) {
5518
+
5519
+ if($scope.options){
5520
+ if($scope.model){
5517
5521
  $scope.modelValue = $scope.options[0];
5518
5522
  } else {
5519
5523
  $scope.modelValue = $scope.options[1];
5520
5524
  }
5521
5525
  }
5522
-
5526
+
5523
5527
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
5524
5528
  $scope.formYesno.$setDirty();
5525
5529
  }
@@ -5581,7 +5585,7 @@ angular.module('niceElements')
5581
5585
  .service('NiceService', function () {
5582
5586
  var service = {
5583
5587
  name: "Nice elements",
5584
- version: "1.8.3",
5588
+ version: "1.8.4",
5585
5589
  getHeader: function () {
5586
5590
  return {};
5587
5591
  }
@@ -5589,7 +5593,7 @@ angular.module('niceElements')
5589
5593
 
5590
5594
  return service;
5591
5595
  })
5592
- angular.module('niceElements').run(['$templateCache', function ($templateCache) {
5596
+ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5593
5597
  'use strict';
5594
5598
 
5595
5599
  $templateCache.put('src/components/nice-button-toggle/nice-button-toggle.html',
@@ -6174,7 +6178,7 @@ angular.module('niceElements').run(['$templateCache', function ($templateCache)
6174
6178
 
6175
6179
 
6176
6180
  $templateCache.put('src/components/nice-icon/nice-icon.html',
6177
- "<svg class=\"nice-icon\">\n" +
6181
+ "<svg class=\"nice-icon\" ng-style=\"{ 'width': size + 'px', 'height': size + 'px' }\">\n" +
6178
6182
  "<use ng-attr-xlink:href=\"{{ '#' + icon }}\" xlink:href=\"\"></use>\n" +
6179
6183
  "</svg>"
6180
6184
  );