nice-elements 1.8.0 → 1.8.2

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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.8.2 (6.4.2023)
4
+
5
+ - added select with mouse down to nice choice,
6
+ - worked on $setValidity errors,
7
+ - worked on nice wrapper,
8
+ - worked on example tables hover,
9
+ - worked on example navigation
10
+
11
+ ## v1.8.1 (16.3.2023)
12
+
13
+ - worked on nice-search and nice-search2
14
+
3
15
  ## v1.8.0 (16.3.2023)
4
16
 
5
17
  - created nice-wrapper component,
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2022 Klemen Kastelic
3
+ Copyright (c) 2023 Klemen Kastelic
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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.0
3
+ # Nice elements v1.8.2
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.0",
3
+ "version": "1.8.2",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -538,6 +538,12 @@ angular.module('niceElements')
538
538
  return filter;
539
539
  };
540
540
 
541
+ $scope.itemHover = function (event, item) {
542
+ if (event.which == 1) {
543
+ $scope.toggle(item);
544
+ }
545
+ }
546
+
541
547
  $scope.setDefault = function () {
542
548
  if (!$scope.multiple) {
543
549
  $scope.internalSelected = $scope.internalList[0];
@@ -1848,121 +1854,123 @@ angular.module('niceElements')
1848
1854
  */
1849
1855
  angular.module('niceElements')
1850
1856
  .directive('niceDropdownDate', function (gettextCatalog) {
1851
- return {
1852
- restrict: 'E',
1853
- replace: true,
1854
- templateUrl: "src/components/nice-dropdown-date/nice-dropdown-date.html",
1855
- scope: {
1856
- model: '=',
1857
- title: '@',
1858
- fieldWidth: '@',
1859
- labelWidth: '@',
1860
- noMargin: '@',
1861
- isDisabled: '=',
1862
- numYears: '@',
1863
- startingYear: '@',
1864
- mature: '@',
1865
- help: '@',
1866
- isInline: '=',
1867
- onChange: '&?'
1868
- },
1869
- link: function ($scope) {
1870
- $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];
1871
- $scope.months = [
1872
- { value: 0, name: gettextCatalog.getString('Jan', null, 'Nice') },
1873
- { value: 1, name: gettextCatalog.getString('Feb', null, 'Nice') },
1874
- { value: 2, name: gettextCatalog.getString('Mar', null, 'Nice') },
1875
- { value: 3, name: gettextCatalog.getString('Apr', null, 'Nice') },
1876
- { value: 4, name: gettextCatalog.getString('May', null, 'Nice') },
1877
- { value: 5, name: gettextCatalog.getString('Jun', null, 'Nice') },
1878
- { value: 6, name: gettextCatalog.getString('Jul', null, 'Nice') },
1879
- { value: 7, name: gettextCatalog.getString('Aug', null, 'Nice') },
1880
- { value: 8, name: gettextCatalog.getString('Sep', null, 'Nice') },
1881
- { value: 9, name: gettextCatalog.getString('Oct', null, 'Nice') },
1882
- { value: 10, name: gettextCatalog.getString('Nov', null, 'Nice') },
1883
- { value: 11, name: gettextCatalog.getString('Dec', null, 'Nice') }
1884
- ];
1885
-
1886
-
1887
- // Set the years drop down from attributes or defaults
1888
- var currentYear = parseInt($scope.startingYear, 10) || new Date().getFullYear();
1889
- var numYears = parseInt($scope.numYears, 10) || 100;
1890
- var oldestYear = currentYear - numYears;
1891
- var newestYear = currentYear;
1892
-
1893
-
1894
- // If mature
1895
- if($scope.mature) newestYear -= 17;
1896
-
1897
-
1898
- // Create years array
1899
- $scope.years = [];
1900
- for(var i = currentYear; i >= oldestYear; i-- ){
1901
- if (i <= newestYear){
1902
- $scope.years.push(i);
1903
- }
1904
- }
1857
+ return {
1858
+ restrict: 'E',
1859
+ replace: true,
1860
+ templateUrl: "src/components/nice-dropdown-date/nice-dropdown-date.html",
1861
+ scope: {
1862
+ model: '=',
1863
+ title: '@',
1864
+ fieldWidth: '@',
1865
+ labelWidth: '@',
1866
+ noMargin: '@',
1867
+ isDisabled: '=',
1868
+ numYears: '@',
1869
+ startingYear: '@',
1870
+ mature: '@',
1871
+ help: '@',
1872
+ isInline: '=',
1873
+ onChange: '&?'
1874
+ },
1875
+ link: function ($scope) {
1876
+ $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];
1877
+ $scope.months = [
1878
+ { value: 0, name: gettextCatalog.getString('Jan', null, 'Nice') },
1879
+ { value: 1, name: gettextCatalog.getString('Feb', null, 'Nice') },
1880
+ { value: 2, name: gettextCatalog.getString('Mar', null, 'Nice') },
1881
+ { value: 3, name: gettextCatalog.getString('Apr', null, 'Nice') },
1882
+ { value: 4, name: gettextCatalog.getString('May', null, 'Nice') },
1883
+ { value: 5, name: gettextCatalog.getString('Jun', null, 'Nice') },
1884
+ { value: 6, name: gettextCatalog.getString('Jul', null, 'Nice') },
1885
+ { value: 7, name: gettextCatalog.getString('Aug', null, 'Nice') },
1886
+ { value: 8, name: gettextCatalog.getString('Sep', null, 'Nice') },
1887
+ { value: 9, name: gettextCatalog.getString('Oct', null, 'Nice') },
1888
+ { value: 10, name: gettextCatalog.getString('Nov', null, 'Nice') },
1889
+ { value: 11, name: gettextCatalog.getString('Dec', null, 'Nice') }
1890
+ ];
1905
1891
 
1906
1892
 
1907
- // Split the current date into sections
1908
- $scope.dateFields = {};
1893
+ // Set the years drop down from attributes or defaults
1894
+ var currentYear = parseInt($scope.startingYear, 10) || new Date().getFullYear();
1895
+ var numYears = parseInt($scope.numYears, 10) || 100;
1896
+ var oldestYear = currentYear - numYears;
1897
+ var newestYear = currentYear;
1909
1898
 
1910
1899
 
1911
- // Watch for model change
1912
- $scope.$watch('model', function ( newDate, oldDate ) {
1913
- if (newDate && newDate != oldDate){
1914
- var date = moment(newDate);
1915
- $scope.dateFields.day = date.get('date');
1916
- $scope.dateFields.month = date.get('month');
1917
- $scope.dateFields.year = date.get('year');
1918
- $scope.checkDate();
1900
+ // If mature
1901
+ if ($scope.mature) newestYear -= 17;
1902
+
1903
+
1904
+ // Create years array
1905
+ $scope.years = [];
1906
+ for (var i = currentYear; i >= oldestYear; i--) {
1907
+ if (i <= newestYear) {
1908
+ $scope.years.push(i);
1909
+ }
1919
1910
  }
1920
- });
1921
1911
 
1922
1912
 
1923
- // validate that the date selected is accurate
1924
- $scope.checkDate = function(){
1925
- var date = moment($scope.dateFields.day + "." + ($scope.dateFields.month + 1) + "." + $scope.dateFields.year, "D.M.YYYY");
1913
+ // Split the current date into sections
1914
+ $scope.dateFields = {};
1926
1915
 
1927
- if(date.isValid()){
1928
- // Format
1929
- $scope.model = date.format();
1930
- if ($scope.onChange) $scope.onChange({ model: $scope.model });
1931
1916
 
1932
- // Change dates
1933
- $scope.days = [];
1934
- for(i = 1; i <= date.daysInMonth(); i++){
1935
- $scope.days.push(i);
1917
+ // Watch for model change
1918
+ $scope.$watch('model', function (newDate, oldDate) {
1919
+ if (newDate && newDate != oldDate) {
1920
+ var date = moment(newDate);
1921
+ $scope.dateFields.day = date.get('date');
1922
+ $scope.dateFields.month = date.get('month');
1923
+ $scope.dateFields.year = date.get('year');
1924
+ $scope.checkDate();
1925
+ }
1926
+ });
1927
+
1928
+
1929
+ // validate that the date selected is accurate
1930
+ $scope.checkDate = function () {
1931
+ var date = moment($scope.dateFields.day + "." + ($scope.dateFields.month + 1) + "." + $scope.dateFields.year, "D.M.YYYY");
1932
+
1933
+ if (date.isValid()) {
1934
+ // Format
1935
+ $scope.model = date.format();
1936
+ if ($scope.onChange) $scope.onChange({ model: $scope.model });
1937
+
1938
+ // Change dates
1939
+ $scope.days = [];
1940
+ for (i = 1; i <= date.daysInMonth(); i++) {
1941
+ $scope.days.push(i);
1942
+ }
1943
+
1944
+ // Valid
1945
+ if ($scope.dropdownDateForm) {
1946
+ $scope.dropdownDateForm.$setValidity('validDate', true);
1947
+ $scope.dropdownDateForm.$setDirty();
1948
+ }
1949
+ } else {
1950
+ // Invalid
1951
+ if ($scope.dropdownDateForm) $scope.dropdownDateForm.$setValidity('validDate', false);
1936
1952
  }
1953
+ };
1954
+
1937
1955
 
1938
- // Valid
1939
- $scope.dropdownDateForm.$setValidity('validDate', true);
1940
- $scope.dropdownDateForm.$setDirty();
1956
+ // Set current date
1957
+ if (!$scope.model) {
1958
+ var date = moment();
1959
+ $scope.dateFields.day = date.get('date');
1960
+ $scope.dateFields.month = date.get('month');
1961
+ $scope.dateFields.year = date.get('year');
1962
+ if ($scope.mature) $scope.dateFields.year -= 18;
1963
+ $scope.checkDate();
1941
1964
  } else {
1942
- // Invalid
1943
- $scope.dropdownDateForm.$setValidity('validDate', false);
1965
+ var date = moment($scope.model);
1966
+ $scope.dateFields.day = date.get('date');
1967
+ $scope.dateFields.month = date.get('month');
1968
+ $scope.dateFields.year = date.get('year');
1969
+ $scope.checkDate();
1944
1970
  }
1945
- };
1946
-
1947
-
1948
- // Set current date
1949
- if(!$scope.model){
1950
- var date = moment();
1951
- $scope.dateFields.day = date.get('date');
1952
- $scope.dateFields.month = date.get('month');
1953
- $scope.dateFields.year = date.get('year');
1954
- if($scope.mature) $scope.dateFields.year -= 18;
1955
- $scope.checkDate();
1956
- } else {
1957
- var date = moment($scope.model);
1958
- $scope.dateFields.day = date.get('date');
1959
- $scope.dateFields.month = date.get('month');
1960
- $scope.dateFields.year = date.get('year');
1961
- $scope.checkDate();
1962
1971
  }
1963
- }
1964
- };
1965
- });
1972
+ };
1973
+ });
1966
1974
  'use strict';
1967
1975
 
1968
1976
  /**
@@ -2677,7 +2685,7 @@ angular.module('niceElements')
2677
2685
 
2678
2686
  // Handle required
2679
2687
  $timeout(function () {
2680
- $scope.formDropdown.$setValidity('required', !(!$scope.selected && $scope.required));
2688
+ if ($scope.formDropdown) $scope.formDropdown.$setValidity('required', !(!$scope.selected && $scope.required));
2681
2689
  });
2682
2690
  }
2683
2691
 
@@ -4073,10 +4081,12 @@ angular.module('niceElements')
4073
4081
 
4074
4082
  // Check canAdd or canSubtract
4075
4083
  $scope.check = function () {
4076
- if ($scope.required && ($scope.model == undefined || $scope.model == null)) {
4077
- $scope.niceNumberForm.$setValidity("no-value", false);
4078
- } else {
4079
- $scope.niceNumberForm.$setValidity("no-value", null);
4084
+ if ($scope.niceNumberForm) {
4085
+ if ($scope.required && ($scope.model == undefined || $scope.model == null)) {
4086
+ $scope.niceNumberForm.$setValidity("no-value", false);
4087
+ } else {
4088
+ $scope.niceNumberForm.$setValidity("no-value", null);
4089
+ }
4080
4090
  }
4081
4091
 
4082
4092
  if ($scope.min && parseFloat($scope.model) <= $scope.min) {
@@ -4093,10 +4103,12 @@ angular.module('niceElements')
4093
4103
  $scope.canAdd = true;
4094
4104
  }
4095
4105
 
4096
- if ($scope.preventZero && parseFloat($scope.model) == 0) {
4097
- $scope.niceNumberForm.$setValidity("zero", false);
4098
- } else {
4099
- $scope.niceNumberForm.$setValidity("zero", null);
4106
+ if ($scope.niceNumberForm) {
4107
+ if ($scope.preventZero && parseFloat($scope.model) == 0) {
4108
+ $scope.niceNumberForm.$setValidity("zero", false);
4109
+ } else {
4110
+ $scope.niceNumberForm.$setValidity("zero", null);
4111
+ }
4100
4112
  }
4101
4113
 
4102
4114
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
@@ -4552,7 +4564,7 @@ angular.module('niceElements')
4552
4564
  }
4553
4565
 
4554
4566
  var setValid = function (isValid) {
4555
- if (scope.required) {
4567
+ if (scope.required && scope.form) {
4556
4568
  scope.form.$setValidity('objectSelected', isValid);
4557
4569
  }
4558
4570
  };
@@ -4747,6 +4759,7 @@ angular.module('niceElements')
4747
4759
  onChange: '&?',
4748
4760
  noMargin: '@',
4749
4761
  tabIndex: '@',
4762
+ keyForInputLabel: '@',
4750
4763
  debounceTime: '@',
4751
4764
  isInline: '=',
4752
4765
  help: '@'
@@ -5031,7 +5044,7 @@ angular.module('niceElements')
5031
5044
  * # niceTimePicker
5032
5045
  */
5033
5046
  angular.module('niceElements')
5034
- .directive('niceTimePicker', function() {
5047
+ .directive('niceTimePicker', function () {
5035
5048
  return {
5036
5049
  scope: {
5037
5050
  model: '=',
@@ -5046,60 +5059,60 @@ angular.module('niceElements')
5046
5059
  },
5047
5060
  restrict: 'E',
5048
5061
  templateUrl: 'src/components/nice-time-picker/nice-time-picker.html',
5049
- link: function($scope, $element, $attrs) {
5050
- if(!$scope.model) $scope.model = moment();
5062
+ link: function ($scope, $element, $attrs) {
5063
+ if (!$scope.model) $scope.model = moment();
5051
5064
  $scope.open = false;
5052
5065
 
5053
5066
 
5054
- $scope.close = function(){
5067
+ $scope.close = function () {
5055
5068
  $scope.open = false;
5056
5069
  };
5057
5070
 
5058
5071
 
5059
- $scope.validateDate = function(){
5072
+ $scope.validateDate = function () {
5060
5073
  $scope.checkDate($scope.modelString);
5061
5074
  };
5062
5075
 
5063
5076
 
5064
- $scope.checkDate = function(date){
5077
+ $scope.checkDate = function (date) {
5065
5078
  var parsedDate = moment(date, "HH:mm");
5066
- if(parsedDate.isValid()){
5067
- $scope.forma.$setValidity("valid-time", true);
5079
+ if (parsedDate.isValid()) {
5080
+ if ($scope.forma) $scope.forma.$setValidity("valid-time", true);
5068
5081
  $scope.model = parsedDate;
5069
5082
  $scope.refreshTime();
5070
5083
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
5071
5084
  } else {
5072
- $scope.forma.$setValidity("valid-time", false);
5085
+ if ($scope.forma) $scope.forma.$setValidity("valid-time", false);
5073
5086
  $scope.modelString = "";
5074
5087
  }
5075
5088
  };
5076
5089
 
5077
5090
 
5078
- $scope.refreshTime = function(){
5091
+ $scope.refreshTime = function () {
5079
5092
  $scope.hours = $scope.model.format("HH");
5080
5093
  $scope.minutes = $scope.model.format("mm");
5081
5094
  $scope.modelString = $scope.model.format("HH:mm");
5082
5095
  };
5083
5096
 
5084
5097
 
5085
- $scope.changeHour = function(add){
5086
- if(add) $scope.model.add(1, 'hour');
5098
+ $scope.changeHour = function (add) {
5099
+ if (add) $scope.model.add(1, 'hour');
5087
5100
  else $scope.model.subtract(1, 'hour');
5088
5101
  $scope.refreshTime();
5089
5102
  $scope.forma.$setDirty();
5090
5103
  };
5091
5104
 
5092
- $scope.changeMinutes = function(add){
5093
- if(add) $scope.model.add(1, 'minutes');
5105
+ $scope.changeMinutes = function (add) {
5106
+ if (add) $scope.model.add(1, 'minutes');
5094
5107
  else $scope.model.subtract(1, 'minutes');
5095
5108
  $scope.refreshTime();
5096
5109
  $scope.forma.$setDirty();
5097
5110
  };
5098
5111
 
5099
5112
 
5100
- $scope.$watch("model", function(value, oldValue){
5113
+ $scope.$watch("model", function (value, oldValue) {
5101
5114
  $scope.refreshTime();
5102
- if(!value.isSame(oldValue)){
5115
+ if (!value.isSame(oldValue)) {
5103
5116
  $scope.checkDate(value);
5104
5117
  }
5105
5118
  })
@@ -5390,11 +5403,13 @@ angular.module('niceElements')
5390
5403
  subtitle: '@',
5391
5404
  collapsable: '=',
5392
5405
  collapsed: '@',
5406
+ noPadding: '@',
5407
+ stickyHeader: '@',
5408
+ stickyFooter: '@',
5393
5409
  },
5394
5410
  controller: function ($scope, $transclude) {
5395
5411
  $scope.isOpen = true;
5396
5412
  if ($scope.collapsed) $scope.isOpen = false;
5397
-
5398
5413
  $scope.hasTitle = $transclude.isSlotFilled('title');
5399
5414
  $scope.hasSubtitle = $transclude.isSlotFilled('subtitle');
5400
5415
  $scope.hasFooter = $transclude.isSlotFilled('footer');
@@ -5565,7 +5580,7 @@ angular.module('niceElements')
5565
5580
  .service('NiceService', function () {
5566
5581
  var service = {
5567
5582
  name: "Nice elements",
5568
- version: "1.7.12",
5583
+ version: "1.8.2",
5569
5584
  getHeader: function () {
5570
5585
  return {};
5571
5586
  }
@@ -5696,7 +5711,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5696
5711
  "<div class=\"nice-field col-xs-12\" ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
5697
5712
  "<ul class=\"list-unstyled\" ng-class=\"{ 'disabled': isDisabled }\">\n" +
5698
5713
  "<li ng-repeat=\"item in internalList\" ng-class=\"{ 'selected' : isItemSelected(item) }\" ng-click=\"toggle(item)\">\n" +
5699
- "<button class=\"choice-checkbox\" type=\"button\" ng-class=\"{'circle' : !multiple }\" ng-disabled=\"isDisabled\">\n" +
5714
+ "<button class=\"choice-checkbox\" type=\"button\" ng-class=\"{'circle' : !multiple }\" ng-mouseenter=\"itemHover($event, item)\" ng-disabled=\"isDisabled\">\n" +
5700
5715
  "<nice-icon ng-if=\"multiple\" icon=\"icon-check\"></nice-icon>\n" +
5701
5716
  "<div ng-if=\"!multiple\" class=\"multiple-circle\"></div>\n" +
5702
5717
  "</button>\n" +
@@ -6357,9 +6372,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
6357
6372
  "</div>\n" +
6358
6373
  "</div>\n" +
6359
6374
  "</div>\n" +
6360
- "<div class=\"row\">\n" +
6375
+ "<div class=\"row\" ng-if=\"noResults || results.length\">\n" +
6361
6376
  "<div ng-class=\"labelWidth ? labelWidth : 'col-sm-4'\" ng-if=\"title\"></div>\n" +
6362
- "<div ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
6377
+ "<div class=\"nice-field col-xs-12\" ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
6363
6378
  "<div class=\"nice-dropdown-empty\" ng-if=\"noResults\">\n" +
6364
6379
  "<div class=\"nice-search-row\" translate translate-context=\"Nice\">No results found.</div>\n" +
6365
6380
  "</div>\n" +
@@ -7368,7 +7383,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7368
7383
 
7369
7384
 
7370
7385
  $templateCache.put('src/components/nice-wrapper/nice-wrapper.html',
7371
- "<div class=\"nice-wrapper\" ng-class=\"{ 'collapsable': collapsable, 'has-header': hasHeader, 'has-footer': hasFooter }\">\n" +
7386
+ "<div class=\"nice-wrapper\" ng-class=\"{ 'collapsable': collapsable, 'has-header': hasHeader, 'has-footer': hasFooter, 'nice-wrapper-sticky-footer': stickyFooter, 'nice-wrapper-sticky-header': stickyHeader }\">\n" +
7372
7387
  "<div class=\"nice-wrapper-header\" ng-if=\"hasHeader\" ng-click=\"toggle()\">\n" +
7373
7388
  "<div class=\"nice-wrapper-info\">\n" +
7374
7389
  "<div class=\"nice-wrapper-title\" ng-transclude=\"title\">{{ title }}</div>\n" +
@@ -7378,7 +7393,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7378
7393
  "<nice-icon icon=\"icon-chevron-down\"></nice-icon>\n" +
7379
7394
  "</button>\n" +
7380
7395
  "</div>\n" +
7381
- "<div class=\"nice-wrapper-body\" ng-transclude ng-if=\"isOpen\"></div>\n" +
7396
+ "<div class=\"nice-wrapper-body\" ng-class=\" {'no-padding': noPadding }\" ng-transclude ng-if=\"isOpen\"></div>\n" +
7382
7397
  "<div class=\"nice-wrapper-footer\" ng-if=\"isOpen && hasFooter\" ng-transclude=\"footer\"></div>\n" +
7383
7398
  "</div>"
7384
7399
  );