nice-elements 1.8.1 → 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,13 @@
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
+
3
11
  ## v1.8.1 (16.3.2023)
4
12
 
5
13
  - worked on nice-search and nice-search2
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.1
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.1",
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
+ };
1937
1954
 
1938
- // Valid
1939
- $scope.dropdownDateForm.$setValidity('validDate', true);
1940
- $scope.dropdownDateForm.$setDirty();
1955
+
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
  };
@@ -5032,7 +5044,7 @@ angular.module('niceElements')
5032
5044
  * # niceTimePicker
5033
5045
  */
5034
5046
  angular.module('niceElements')
5035
- .directive('niceTimePicker', function() {
5047
+ .directive('niceTimePicker', function () {
5036
5048
  return {
5037
5049
  scope: {
5038
5050
  model: '=',
@@ -5047,60 +5059,60 @@ angular.module('niceElements')
5047
5059
  },
5048
5060
  restrict: 'E',
5049
5061
  templateUrl: 'src/components/nice-time-picker/nice-time-picker.html',
5050
- link: function($scope, $element, $attrs) {
5051
- if(!$scope.model) $scope.model = moment();
5062
+ link: function ($scope, $element, $attrs) {
5063
+ if (!$scope.model) $scope.model = moment();
5052
5064
  $scope.open = false;
5053
5065
 
5054
5066
 
5055
- $scope.close = function(){
5067
+ $scope.close = function () {
5056
5068
  $scope.open = false;
5057
5069
  };
5058
5070
 
5059
5071
 
5060
- $scope.validateDate = function(){
5072
+ $scope.validateDate = function () {
5061
5073
  $scope.checkDate($scope.modelString);
5062
5074
  };
5063
5075
 
5064
5076
 
5065
- $scope.checkDate = function(date){
5077
+ $scope.checkDate = function (date) {
5066
5078
  var parsedDate = moment(date, "HH:mm");
5067
- if(parsedDate.isValid()){
5068
- $scope.forma.$setValidity("valid-time", true);
5079
+ if (parsedDate.isValid()) {
5080
+ if ($scope.forma) $scope.forma.$setValidity("valid-time", true);
5069
5081
  $scope.model = parsedDate;
5070
5082
  $scope.refreshTime();
5071
5083
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
5072
5084
  } else {
5073
- $scope.forma.$setValidity("valid-time", false);
5085
+ if ($scope.forma) $scope.forma.$setValidity("valid-time", false);
5074
5086
  $scope.modelString = "";
5075
5087
  }
5076
5088
  };
5077
5089
 
5078
5090
 
5079
- $scope.refreshTime = function(){
5091
+ $scope.refreshTime = function () {
5080
5092
  $scope.hours = $scope.model.format("HH");
5081
5093
  $scope.minutes = $scope.model.format("mm");
5082
5094
  $scope.modelString = $scope.model.format("HH:mm");
5083
5095
  };
5084
5096
 
5085
5097
 
5086
- $scope.changeHour = function(add){
5087
- if(add) $scope.model.add(1, 'hour');
5098
+ $scope.changeHour = function (add) {
5099
+ if (add) $scope.model.add(1, 'hour');
5088
5100
  else $scope.model.subtract(1, 'hour');
5089
5101
  $scope.refreshTime();
5090
5102
  $scope.forma.$setDirty();
5091
5103
  };
5092
5104
 
5093
- $scope.changeMinutes = function(add){
5094
- if(add) $scope.model.add(1, 'minutes');
5105
+ $scope.changeMinutes = function (add) {
5106
+ if (add) $scope.model.add(1, 'minutes');
5095
5107
  else $scope.model.subtract(1, 'minutes');
5096
5108
  $scope.refreshTime();
5097
5109
  $scope.forma.$setDirty();
5098
5110
  };
5099
5111
 
5100
5112
 
5101
- $scope.$watch("model", function(value, oldValue){
5113
+ $scope.$watch("model", function (value, oldValue) {
5102
5114
  $scope.refreshTime();
5103
- if(!value.isSame(oldValue)){
5115
+ if (!value.isSame(oldValue)) {
5104
5116
  $scope.checkDate(value);
5105
5117
  }
5106
5118
  })
@@ -5391,11 +5403,13 @@ angular.module('niceElements')
5391
5403
  subtitle: '@',
5392
5404
  collapsable: '=',
5393
5405
  collapsed: '@',
5406
+ noPadding: '@',
5407
+ stickyHeader: '@',
5408
+ stickyFooter: '@',
5394
5409
  },
5395
5410
  controller: function ($scope, $transclude) {
5396
5411
  $scope.isOpen = true;
5397
5412
  if ($scope.collapsed) $scope.isOpen = false;
5398
-
5399
5413
  $scope.hasTitle = $transclude.isSlotFilled('title');
5400
5414
  $scope.hasSubtitle = $transclude.isSlotFilled('subtitle');
5401
5415
  $scope.hasFooter = $transclude.isSlotFilled('footer');
@@ -5566,7 +5580,7 @@ angular.module('niceElements')
5566
5580
  .service('NiceService', function () {
5567
5581
  var service = {
5568
5582
  name: "Nice elements",
5569
- version: "1.8.0",
5583
+ version: "1.8.2",
5570
5584
  getHeader: function () {
5571
5585
  return {};
5572
5586
  }
@@ -5697,7 +5711,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5697
5711
  "<div class=\"nice-field col-xs-12\" ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
5698
5712
  "<ul class=\"list-unstyled\" ng-class=\"{ 'disabled': isDisabled }\">\n" +
5699
5713
  "<li ng-repeat=\"item in internalList\" ng-class=\"{ 'selected' : isItemSelected(item) }\" ng-click=\"toggle(item)\">\n" +
5700
- "<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" +
5701
5715
  "<nice-icon ng-if=\"multiple\" icon=\"icon-check\"></nice-icon>\n" +
5702
5716
  "<div ng-if=\"!multiple\" class=\"multiple-circle\"></div>\n" +
5703
5717
  "</button>\n" +
@@ -7369,7 +7383,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7369
7383
 
7370
7384
 
7371
7385
  $templateCache.put('src/components/nice-wrapper/nice-wrapper.html',
7372
- "<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" +
7373
7387
  "<div class=\"nice-wrapper-header\" ng-if=\"hasHeader\" ng-click=\"toggle()\">\n" +
7374
7388
  "<div class=\"nice-wrapper-info\">\n" +
7375
7389
  "<div class=\"nice-wrapper-title\" ng-transclude=\"title\">{{ title }}</div>\n" +
@@ -7379,7 +7393,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7379
7393
  "<nice-icon icon=\"icon-chevron-down\"></nice-icon>\n" +
7380
7394
  "</button>\n" +
7381
7395
  "</div>\n" +
7382
- "<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" +
7383
7397
  "<div class=\"nice-wrapper-footer\" ng-if=\"isOpen && hasFooter\" ng-transclude=\"footer\"></div>\n" +
7384
7398
  "</div>"
7385
7399
  );