nice-elements 1.8.2 → 1.8.3

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.8.3 (30.5.2023)
4
+
5
+ - added clickDisabled prop to nice-checkbox component
6
+
3
7
  ## v1.8.2 (6.4.2023)
4
8
 
5
9
  - added select with mouse down to nice choice,
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.2
3
+ # Nice elements v1.8.3
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.2",
3
+ "version": "1.8.3",
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
  }
@@ -419,6 +419,7 @@ angular.module('niceElements')
419
419
  model: '=',
420
420
  title: '@',
421
421
  noMargin: '@',
422
+ clickDisabled: '@',
422
423
  onChange: '&?',
423
424
  isDisabled: '=',
424
425
  },
@@ -426,7 +427,7 @@ angular.module('niceElements')
426
427
  if ($scope.model === undefined) $scope.model = false;
427
428
 
428
429
  $scope.toggle = function () {
429
- if ($scope.isDisabled) return;
430
+ if ($scope.isDisabled || $scope.clickDisabled) return;
430
431
  $scope.model = !$scope.model;
431
432
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
432
433
  };
@@ -654,14 +655,14 @@ angular.module('niceElements')
654
655
  * # clickOutside
655
656
  */
656
657
  angular.module('niceElements')
657
- .directive('clickOutside', function($document, $parse, $timeout){
658
+ .directive('clickOutside', function ($document, $parse, $timeout) {
658
659
  return {
659
660
  restrict: 'A',
660
661
  link: function ($scope, elem, attr) {
661
662
  $scope.isOpen = false;
662
663
 
663
664
  // watch for is open
664
- attr.$observe('isOpen', function(value){
665
+ attr.$observe('isOpen', function (value) {
665
666
  $scope.isOpen = value == 'true';
666
667
  });
667
668
 
@@ -716,7 +717,7 @@ angular.module('niceElements')
716
717
  // if we have got this far, then we are good to go with processing the command passed in via the click-outside attribute
717
718
  $timeout(function () {
718
719
  fn = $parse(attr['clickOutside']);
719
- fn($scope, {event: e});
720
+ fn($scope, { event: e });
720
721
  });
721
722
  }
722
723
  }
@@ -750,7 +751,7 @@ angular.module('niceElements')
750
751
  });
751
752
  }
752
753
  };
753
- });
754
+ });
754
755
  'use strict';
755
756
 
756
757
  /**
@@ -941,7 +942,7 @@ angular.module('niceElements')
941
942
  */
942
943
  angular.module('niceElements')
943
944
 
944
- .directive('niceDateRange', function() {
945
+ .directive('niceDateRange', function () {
945
946
  return {
946
947
  restrict: 'E',
947
948
  transclude: true,
@@ -961,16 +962,16 @@ angular.module('niceElements')
961
962
  onChange: '&?'
962
963
  },
963
964
 
964
- link: function(scope, attrs){
965
+ link: function (scope, attrs) {
965
966
  if (!attrs.title) { attrs.title = ''; }
966
967
  if (!attrs.fieldWidth) { attrs.fieldWidth = 'col-sm-8'; }
967
968
  if (!attrs.labelWidth) { attrs.labelWidth = 'col-sm-4'; }
968
969
  if (!attrs.format) { attrs.format = 'dd.MM.yyyy'; }
969
970
  attrs.noMargin = angular.isDefined(attrs.noMargin);
970
971
 
971
- if(!angular.isDefined(scope.model)) {
972
+ if (!angular.isDefined(scope.model)) {
972
973
  var model = null;
973
- if(!angular.isDefined(scope.startOfTheYear)){
974
+ if (!angular.isDefined(scope.startOfTheYear)) {
974
975
  model = {
975
976
  startDate: moment().format(),
976
977
  endDate: moment().format()
@@ -986,7 +987,7 @@ angular.module('niceElements')
986
987
  }
987
988
  },
988
989
 
989
- controller: function($scope) {
990
+ controller: function ($scope) {
990
991
  $scope.opts = {
991
992
  locale: {
992
993
  applyClass: 'btn-green',
@@ -1002,7 +1003,7 @@ angular.module('niceElements')
1002
1003
  $scope.opts.ranges[gettextCatalog.getString("Last 30 days", null, "Nice")] = [moment().subtract(30, 'days'), moment()];
1003
1004
  $scope.opts.ranges[gettextCatalog.getString("This month", null, "Nice")] = [moment().startOf('month'), moment().endOf('month')];
1004
1005
 
1005
- if(angular.isDefined($scope.format)) $scope.opts.format = format;
1006
+ if (angular.isDefined($scope.format)) $scope.opts.format = format;
1006
1007
  }
1007
1008
 
1008
1009
  };
@@ -3632,24 +3633,24 @@ angular.module('niceElements')
3632
3633
  };
3633
3634
  });
3634
3635
 
3635
- 'use strict';
3636
-
3637
- /**
3638
- * @ngdoc directive
3639
- * @name niceElements.directive:niceIcon
3640
- * @description
3641
- * # niceIcon
3642
- */
3643
- angular.module('niceElements')
3644
- .directive('niceIcon', function () {
3645
- return {
3646
- templateUrl: 'src/components/nice-icon/nice-icon.html',
3647
- restrict: 'E',
3648
- replace: true,
3649
- scope: {
3650
- icon: '@'
3651
- },
3652
- };
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
+ };
3653
3654
  });
3654
3655
  angular.module('niceElements')
3655
3656
  .directive('niceInput', function () {
@@ -3889,42 +3890,42 @@ angular.module('niceElements')
3889
3890
 
3890
3891
  var messageElements = [];
3891
3892
 
3892
- var notify = function(args, t){
3893
+ var notify = function (args, t) {
3893
3894
 
3894
- if (typeof args !== 'object'){
3895
- args = {message:args};
3895
+ if (typeof args !== 'object') {
3896
+ args = { message: args };
3896
3897
  }
3897
3898
 
3898
3899
  args.template = args.template ? args.template : 'src/components/nice-notification/nice-notification.html';
3899
3900
  args.delay = !angular.isUndefined(args.delay) ? args.delay : delay;
3900
3901
  args.type = t ? t : '';
3901
3902
 
3902
- $http.get(args.template,{cache: $templateCache}).success(function(template) {
3903
+ $http.get(args.template, { cache: $templateCache }).success(function (template) {
3903
3904
 
3904
3905
  var scope = $rootScope.$new();
3905
3906
  scope.message = $sce.trustAsHtml(args.message);
3906
3907
  scope.title = $sce.trustAsHtml(args.title);
3907
- scope.t = args.type.substr(0,1);
3908
+ scope.t = args.type.substr(0, 1);
3908
3909
  scope.delay = args.delay;
3909
3910
 
3910
- if (typeof args.scope === 'object'){
3911
- for (var key in args.scope){
3911
+ if (typeof args.scope === 'object') {
3912
+ for (var key in args.scope) {
3912
3913
  scope[key] = args.scope[key];
3913
3914
  }
3914
3915
  }
3915
3916
 
3916
- var reposite = function() {
3917
+ var reposite = function () {
3917
3918
  var j = 0;
3918
3919
  var k = 0;
3919
3920
  var lastTop = startTop;
3920
3921
  var lastRight = startRight;
3921
- for(var i = messageElements.length - 1; i >= 0; i --) {
3922
+ for (var i = messageElements.length - 1; i >= 0; i--) {
3922
3923
  var element = messageElements[i];
3923
3924
  var elHeight = parseInt(element[0].offsetHeight);
3924
3925
  var elWidth = parseInt(element[0].offsetWidth);
3925
3926
  if ((top + elHeight) > window.innerHeight) {
3926
3927
  lastTop = startTop;
3927
- k ++;
3928
+ k++;
3928
3929
  j = 0;
3929
3930
  }
3930
3931
  var top = lastTop + (j === 0 ? 0 : verticalSpacing);
@@ -3934,22 +3935,22 @@ angular.module('niceElements')
3934
3935
  element.css('right', right + 'px');
3935
3936
 
3936
3937
  lastTop = top + elHeight;
3937
- j ++;
3938
+ j++;
3938
3939
  }
3939
3940
  };
3940
3941
 
3941
3942
  var templateElement = $compile(template)(scope);
3942
3943
  templateElement.addClass(args.type);
3943
- templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function(e){
3944
+ templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
3944
3945
  e = e.originalEvent || e;
3945
- if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)){
3946
+ if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
3946
3947
  templateElement.remove();
3947
3948
  messageElements.splice(messageElements.indexOf(templateElement), 1);
3948
3949
  reposite();
3949
3950
  }
3950
3951
  });
3951
3952
 
3952
- $timeout(function() {
3953
+ $timeout(function () {
3953
3954
  templateElement.addClass('killed');
3954
3955
  templateElement.remove();
3955
3956
  messageElements.splice(messageElements.indexOf(templateElement), 1);
@@ -3961,34 +3962,34 @@ angular.module('niceElements')
3961
3962
 
3962
3963
  $timeout(reposite);
3963
3964
 
3964
- }).error(function(data){
3965
- throw new Error('Template ('+args.template+') could not be loaded. ' + data);
3965
+ }).error(function (data) {
3966
+ throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
3966
3967
  });
3967
3968
 
3968
3969
  };
3969
3970
 
3970
- notify.config = function(args){
3971
- startTop = args.top ? args.top : startTop;
3972
- verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
3971
+ notify.config = function (args) {
3972
+ startTop = args.top ? args.top : startTop;
3973
+ verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
3973
3974
  };
3974
3975
 
3975
- notify.primary = function() {
3976
+ notify.primary = function () {
3976
3977
  this(args, '');
3977
3978
  };
3978
3979
 
3979
- notify.error = function(args) {
3980
+ notify.error = function (args) {
3980
3981
  this(args, 'error');
3981
3982
  };
3982
3983
 
3983
- notify.success = function(args) {
3984
+ notify.success = function (args) {
3984
3985
  this(args, 'success');
3985
3986
  };
3986
3987
 
3987
- notify.info = function(args) {
3988
+ notify.info = function (args) {
3988
3989
  this(args, 'info');
3989
3990
  };
3990
3991
 
3991
- notify.warning = function(args) {
3992
+ notify.warning = function (args) {
3992
3993
  this(args, 'warning');
3993
3994
  };
3994
3995
 
@@ -4389,7 +4390,7 @@ angular.module('niceElements')
4389
4390
  * # niceProgressBar
4390
4391
  */
4391
4392
  angular.module('niceElements')
4392
- .directive('niceProgressBar', function() {
4393
+ .directive('niceProgressBar', function () {
4393
4394
  return {
4394
4395
  restrict: 'E',
4395
4396
  replace: true,
@@ -4404,29 +4405,29 @@ angular.module('niceElements')
4404
4405
  help: '@'
4405
4406
  },
4406
4407
 
4407
- controller: function($scope, $element, $timeout) {
4408
+ controller: function ($scope, $element, $timeout) {
4408
4409
  $scope.width = 0;
4409
- $scope.resize = function(){
4410
- $timeout(function() {
4410
+ $scope.resize = function () {
4411
+ $timeout(function () {
4411
4412
  $scope.width = $element[0].getElementsByClassName("progress")[0].offsetWidth;
4412
- },100);
4413
+ }, 100);
4413
4414
  };
4414
- window.onresize = function() {
4415
+ window.onresize = function () {
4415
4416
  $scope.resize();
4416
4417
  };
4417
4418
  $scope.resize();
4418
4419
 
4419
-
4420
4420
 
4421
- $scope.$watch("value", function(valueNew, valueOld){
4421
+
4422
+ $scope.$watch("value", function (valueNew, valueOld) {
4422
4423
  $scope.calculate();
4423
4424
  });
4424
4425
 
4425
- $scope.$watch("max", function(valueNew, valueOld){
4426
+ $scope.$watch("max", function (valueNew, valueOld) {
4426
4427
  $scope.calculate();
4427
4428
  });
4428
4429
 
4429
- $scope.calculate = function(){
4430
+ $scope.calculate = function () {
4430
4431
  $scope.percentage = ($scope.value / $scope.max) * 100;
4431
4432
  };
4432
4433
 
@@ -5452,24 +5453,24 @@ angular.module('niceElements')
5452
5453
  isInline: '=',
5453
5454
  help: '@'
5454
5455
  },
5455
- controller: function($scope, gettextCatalog) {
5456
+ controller: function ($scope, gettextCatalog) {
5456
5457
  if (!$scope.yes) { $scope.yes = gettextCatalog.getString('Yes', null, "Nice"); }
5457
5458
  if (!$scope.no) { $scope.no = gettextCatalog.getString('No', null, "Nice"); }
5458
5459
  if (!$scope.title) { $scope.title = ''; }
5459
5460
  if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
5460
5461
  if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
5461
- if(!angular.isDefined($scope.model) && !angular.isDefined($scope.options)) $scope.model = !angular.isDefined($scope.defaultFalse);
5462
- if(!angular.isDefined($scope.modelValue) && angular.isDefined($scope.options)) $scope.modelValue = $scope.options[0];
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];
5463
5464
 
5464
5465
  $scope.defaultFalse = angular.isDefined($scope.defaultFalse);
5465
5466
  $scope.noMargin = angular.isDefined($scope.noMargin);
5466
5467
 
5467
5468
  $scope.buttonClass = "";
5468
-
5469
+
5469
5470
 
5470
5471
  // ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
5471
- $scope.setButtonPosition = function(state) {
5472
- if(state) {
5472
+ $scope.setButtonPosition = function (state) {
5473
+ if (state) {
5473
5474
  $scope.buttonClass = "yesno-button-yes";
5474
5475
  } else {
5475
5476
  $scope.buttonClass = "yesno-button-no";
@@ -5477,48 +5478,48 @@ angular.module('niceElements')
5477
5478
  };
5478
5479
 
5479
5480
  // ------------------------- Watch for changes from outside -------------------------
5480
- $scope.$watch('model', function(value_new, value_old){
5481
- if(angular.isDefined($scope.model)){
5481
+ $scope.$watch('model', function (value_new, value_old) {
5482
+ if (angular.isDefined($scope.model)) {
5482
5483
  $scope.setButtonLabel($scope.model);
5483
5484
  $scope.setButtonPosition($scope.model);
5484
5485
  }
5485
5486
  });
5486
5487
 
5487
5488
  // ------------------------- Watch for model value -------------------------
5488
- $scope.$watch('modelValue', function(value_new, value_old){
5489
- if($scope.options){
5489
+ $scope.$watch('modelValue', function (value_new, value_old) {
5490
+ if ($scope.options) {
5490
5491
  $scope.model = $scope.modelValue == $scope.options[0];
5491
5492
  }
5492
5493
  });
5493
5494
 
5494
5495
  // ------------------------- Set button label -------------------------
5495
- $scope.setButtonLabel = function(state){
5496
+ $scope.setButtonLabel = function (state) {
5496
5497
  if (state) {
5497
5498
  $scope.state = $scope.yes;
5498
5499
  } else {
5499
5500
  $scope.state = $scope.no;
5500
5501
  }
5501
5502
  };
5502
-
5503
+
5503
5504
  // ------------------------- Set width -------------------------
5504
- $scope.setWidth = function(width, el){
5505
+ $scope.setWidth = function (width, el) {
5505
5506
  el.style.width = width;
5506
5507
  };
5507
-
5508
+
5508
5509
 
5509
5510
  // ------------------------- Switch -------------------------
5510
- $scope.switch = function(){
5511
- if(!$scope.isDisabled){
5511
+ $scope.switch = function () {
5512
+ if (!$scope.isDisabled) {
5512
5513
  $scope.model = !$scope.model;
5513
-
5514
- if($scope.options){
5515
- if($scope.model){
5514
+
5515
+ if ($scope.options) {
5516
+ if ($scope.model) {
5516
5517
  $scope.modelValue = $scope.options[0];
5517
5518
  } else {
5518
5519
  $scope.modelValue = $scope.options[1];
5519
5520
  }
5520
5521
  }
5521
-
5522
+
5522
5523
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
5523
5524
  $scope.formYesno.$setDirty();
5524
5525
  }
@@ -5580,7 +5581,7 @@ angular.module('niceElements')
5580
5581
  .service('NiceService', function () {
5581
5582
  var service = {
5582
5583
  name: "Nice elements",
5583
- version: "1.8.2",
5584
+ version: "1.8.3",
5584
5585
  getHeader: function () {
5585
5586
  return {};
5586
5587
  }
@@ -5588,7 +5589,7 @@ angular.module('niceElements')
5588
5589
 
5589
5590
  return service;
5590
5591
  })
5591
- angular.module('niceElements').run(['$templateCache', function($templateCache) {
5592
+ angular.module('niceElements').run(['$templateCache', function ($templateCache) {
5592
5593
  'use strict';
5593
5594
 
5594
5595
  $templateCache.put('src/components/nice-button-toggle/nice-button-toggle.html',