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.
@@ -8,118 +8,120 @@
8
8
  */
9
9
  angular.module('niceElements')
10
10
  .directive('niceDropdownDate', function (gettextCatalog) {
11
- return {
12
- restrict: 'E',
13
- replace: true,
14
- templateUrl: "src/components/nice-dropdown-date/nice-dropdown-date.html",
15
- scope: {
16
- model: '=',
17
- title: '@',
18
- fieldWidth: '@',
19
- labelWidth: '@',
20
- noMargin: '@',
21
- isDisabled: '=',
22
- numYears: '@',
23
- startingYear: '@',
24
- mature: '@',
25
- help: '@',
26
- isInline: '=',
27
- onChange: '&?'
28
- },
29
- link: function ($scope) {
30
- $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];
31
- $scope.months = [
32
- { value: 0, name: gettextCatalog.getString('Jan', null, 'Nice') },
33
- { value: 1, name: gettextCatalog.getString('Feb', null, 'Nice') },
34
- { value: 2, name: gettextCatalog.getString('Mar', null, 'Nice') },
35
- { value: 3, name: gettextCatalog.getString('Apr', null, 'Nice') },
36
- { value: 4, name: gettextCatalog.getString('May', null, 'Nice') },
37
- { value: 5, name: gettextCatalog.getString('Jun', null, 'Nice') },
38
- { value: 6, name: gettextCatalog.getString('Jul', null, 'Nice') },
39
- { value: 7, name: gettextCatalog.getString('Aug', null, 'Nice') },
40
- { value: 8, name: gettextCatalog.getString('Sep', null, 'Nice') },
41
- { value: 9, name: gettextCatalog.getString('Oct', null, 'Nice') },
42
- { value: 10, name: gettextCatalog.getString('Nov', null, 'Nice') },
43
- { value: 11, name: gettextCatalog.getString('Dec', null, 'Nice') }
44
- ];
45
-
46
-
47
- // Set the years drop down from attributes or defaults
48
- var currentYear = parseInt($scope.startingYear, 10) || new Date().getFullYear();
49
- var numYears = parseInt($scope.numYears, 10) || 100;
50
- var oldestYear = currentYear - numYears;
51
- var newestYear = currentYear;
52
-
53
-
54
- // If mature
55
- if($scope.mature) newestYear -= 17;
56
-
57
-
58
- // Create years array
59
- $scope.years = [];
60
- for(var i = currentYear; i >= oldestYear; i-- ){
61
- if (i <= newestYear){
62
- $scope.years.push(i);
11
+ return {
12
+ restrict: 'E',
13
+ replace: true,
14
+ templateUrl: "src/components/nice-dropdown-date/nice-dropdown-date.html",
15
+ scope: {
16
+ model: '=',
17
+ title: '@',
18
+ fieldWidth: '@',
19
+ labelWidth: '@',
20
+ noMargin: '@',
21
+ isDisabled: '=',
22
+ numYears: '@',
23
+ startingYear: '@',
24
+ mature: '@',
25
+ help: '@',
26
+ isInline: '=',
27
+ onChange: '&?'
28
+ },
29
+ link: function ($scope) {
30
+ $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];
31
+ $scope.months = [
32
+ { value: 0, name: gettextCatalog.getString('Jan', null, 'Nice') },
33
+ { value: 1, name: gettextCatalog.getString('Feb', null, 'Nice') },
34
+ { value: 2, name: gettextCatalog.getString('Mar', null, 'Nice') },
35
+ { value: 3, name: gettextCatalog.getString('Apr', null, 'Nice') },
36
+ { value: 4, name: gettextCatalog.getString('May', null, 'Nice') },
37
+ { value: 5, name: gettextCatalog.getString('Jun', null, 'Nice') },
38
+ { value: 6, name: gettextCatalog.getString('Jul', null, 'Nice') },
39
+ { value: 7, name: gettextCatalog.getString('Aug', null, 'Nice') },
40
+ { value: 8, name: gettextCatalog.getString('Sep', null, 'Nice') },
41
+ { value: 9, name: gettextCatalog.getString('Oct', null, 'Nice') },
42
+ { value: 10, name: gettextCatalog.getString('Nov', null, 'Nice') },
43
+ { value: 11, name: gettextCatalog.getString('Dec', null, 'Nice') }
44
+ ];
45
+
46
+
47
+ // Set the years drop down from attributes or defaults
48
+ var currentYear = parseInt($scope.startingYear, 10) || new Date().getFullYear();
49
+ var numYears = parseInt($scope.numYears, 10) || 100;
50
+ var oldestYear = currentYear - numYears;
51
+ var newestYear = currentYear;
52
+
53
+
54
+ // If mature
55
+ if ($scope.mature) newestYear -= 17;
56
+
57
+
58
+ // Create years array
59
+ $scope.years = [];
60
+ for (var i = currentYear; i >= oldestYear; i--) {
61
+ if (i <= newestYear) {
62
+ $scope.years.push(i);
63
+ }
63
64
  }
64
- }
65
65
 
66
66
 
67
- // Split the current date into sections
68
- $scope.dateFields = {};
67
+ // Split the current date into sections
68
+ $scope.dateFields = {};
69
+
69
70
 
71
+ // Watch for model change
72
+ $scope.$watch('model', function (newDate, oldDate) {
73
+ if (newDate && newDate != oldDate) {
74
+ var date = moment(newDate);
75
+ $scope.dateFields.day = date.get('date');
76
+ $scope.dateFields.month = date.get('month');
77
+ $scope.dateFields.year = date.get('year');
78
+ $scope.checkDate();
79
+ }
80
+ });
81
+
82
+
83
+ // validate that the date selected is accurate
84
+ $scope.checkDate = function () {
85
+ var date = moment($scope.dateFields.day + "." + ($scope.dateFields.month + 1) + "." + $scope.dateFields.year, "D.M.YYYY");
86
+
87
+ if (date.isValid()) {
88
+ // Format
89
+ $scope.model = date.format();
90
+ if ($scope.onChange) $scope.onChange({ model: $scope.model });
91
+
92
+ // Change dates
93
+ $scope.days = [];
94
+ for (i = 1; i <= date.daysInMonth(); i++) {
95
+ $scope.days.push(i);
96
+ }
97
+
98
+ // Valid
99
+ if ($scope.dropdownDateForm) {
100
+ $scope.dropdownDateForm.$setValidity('validDate', true);
101
+ $scope.dropdownDateForm.$setDirty();
102
+ }
103
+ } else {
104
+ // Invalid
105
+ if ($scope.dropdownDateForm) $scope.dropdownDateForm.$setValidity('validDate', false);
106
+ }
107
+ };
70
108
 
71
- // Watch for model change
72
- $scope.$watch('model', function ( newDate, oldDate ) {
73
- if (newDate && newDate != oldDate){
74
- var date = moment(newDate);
109
+
110
+ // Set current date
111
+ if (!$scope.model) {
112
+ var date = moment();
75
113
  $scope.dateFields.day = date.get('date');
76
114
  $scope.dateFields.month = date.get('month');
77
115
  $scope.dateFields.year = date.get('year');
116
+ if ($scope.mature) $scope.dateFields.year -= 18;
78
117
  $scope.checkDate();
79
- }
80
- });
81
-
82
-
83
- // validate that the date selected is accurate
84
- $scope.checkDate = function(){
85
- var date = moment($scope.dateFields.day + "." + ($scope.dateFields.month + 1) + "." + $scope.dateFields.year, "D.M.YYYY");
86
-
87
- if(date.isValid()){
88
- // Format
89
- $scope.model = date.format();
90
- if ($scope.onChange) $scope.onChange({ model: $scope.model });
91
-
92
- // Change dates
93
- $scope.days = [];
94
- for(i = 1; i <= date.daysInMonth(); i++){
95
- $scope.days.push(i);
96
- }
97
-
98
- // Valid
99
- $scope.dropdownDateForm.$setValidity('validDate', true);
100
- $scope.dropdownDateForm.$setDirty();
101
118
  } else {
102
- // Invalid
103
- $scope.dropdownDateForm.$setValidity('validDate', false);
119
+ var date = moment($scope.model);
120
+ $scope.dateFields.day = date.get('date');
121
+ $scope.dateFields.month = date.get('month');
122
+ $scope.dateFields.year = date.get('year');
123
+ $scope.checkDate();
104
124
  }
105
- };
106
-
107
-
108
- // Set current date
109
- if(!$scope.model){
110
- var date = moment();
111
- $scope.dateFields.day = date.get('date');
112
- $scope.dateFields.month = date.get('month');
113
- $scope.dateFields.year = date.get('year');
114
- if($scope.mature) $scope.dateFields.year -= 18;
115
- $scope.checkDate();
116
- } else {
117
- var date = moment($scope.model);
118
- $scope.dateFields.day = date.get('date');
119
- $scope.dateFields.month = date.get('month');
120
- $scope.dateFields.year = date.get('year');
121
- $scope.checkDate();
122
125
  }
123
- }
124
- };
125
- });
126
+ };
127
+ });
@@ -84,10 +84,12 @@ angular.module('niceElements')
84
84
 
85
85
  // Check canAdd or canSubtract
86
86
  $scope.check = function () {
87
- if ($scope.required && ($scope.model == undefined || $scope.model == null)) {
88
- $scope.niceNumberForm.$setValidity("no-value", false);
89
- } else {
90
- $scope.niceNumberForm.$setValidity("no-value", null);
87
+ if ($scope.niceNumberForm) {
88
+ if ($scope.required && ($scope.model == undefined || $scope.model == null)) {
89
+ $scope.niceNumberForm.$setValidity("no-value", false);
90
+ } else {
91
+ $scope.niceNumberForm.$setValidity("no-value", null);
92
+ }
91
93
  }
92
94
 
93
95
  if ($scope.min && parseFloat($scope.model) <= $scope.min) {
@@ -104,10 +106,12 @@ angular.module('niceElements')
104
106
  $scope.canAdd = true;
105
107
  }
106
108
 
107
- if ($scope.preventZero && parseFloat($scope.model) == 0) {
108
- $scope.niceNumberForm.$setValidity("zero", false);
109
- } else {
110
- $scope.niceNumberForm.$setValidity("zero", null);
109
+ if ($scope.niceNumberForm) {
110
+ if ($scope.preventZero && parseFloat($scope.model) == 0) {
111
+ $scope.niceNumberForm.$setValidity("zero", false);
112
+ } else {
113
+ $scope.niceNumberForm.$setValidity("zero", null);
114
+ }
111
115
  }
112
116
 
113
117
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
@@ -24,9 +24,9 @@
24
24
  </div>
25
25
  </div>
26
26
 
27
- <div class="row">
27
+ <div class="row" ng-if="noResults || results.length">
28
28
  <div ng-class="labelWidth ? labelWidth : 'col-sm-4'" ng-if="title"></div>
29
- <div ng-class="fieldWidth ? fieldWidth : 'col-sm-8'">
29
+ <div class="nice-field col-xs-12" ng-class="fieldWidth ? fieldWidth : 'col-sm-8'">
30
30
  <div class="nice-dropdown-empty" ng-if="noResults">
31
31
  <div class="nice-search-row" translate translate-context="Nice">No results found.</div>
32
32
  </div>
@@ -71,7 +71,7 @@ angular.module('niceElements')
71
71
  }
72
72
 
73
73
  var setValid = function (isValid) {
74
- if (scope.required) {
74
+ if (scope.required && scope.form) {
75
75
  scope.form.$setValidity('objectSelected', isValid);
76
76
  }
77
77
  };
@@ -83,5 +83,9 @@
83
83
  margin: 15px;
84
84
  right: 0;
85
85
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
86
+
87
+ .nice-search-row {
88
+ opacity: 0.4;
89
+ }
86
90
  }
87
91
  }
@@ -26,6 +26,7 @@ angular.module('niceElements')
26
26
  onChange: '&?',
27
27
  noMargin: '@',
28
28
  tabIndex: '@',
29
+ keyForInputLabel: '@',
29
30
  debounceTime: '@',
30
31
  isInline: '=',
31
32
  help: '@'
@@ -7,7 +7,7 @@
7
7
  * # niceTimePicker
8
8
  */
9
9
  angular.module('niceElements')
10
- .directive('niceTimePicker', function() {
10
+ .directive('niceTimePicker', function () {
11
11
  return {
12
12
  scope: {
13
13
  model: '=',
@@ -22,60 +22,60 @@ angular.module('niceElements')
22
22
  },
23
23
  restrict: 'E',
24
24
  templateUrl: 'src/components/nice-time-picker/nice-time-picker.html',
25
- link: function($scope, $element, $attrs) {
26
- if(!$scope.model) $scope.model = moment();
25
+ link: function ($scope, $element, $attrs) {
26
+ if (!$scope.model) $scope.model = moment();
27
27
  $scope.open = false;
28
28
 
29
29
 
30
- $scope.close = function(){
30
+ $scope.close = function () {
31
31
  $scope.open = false;
32
32
  };
33
33
 
34
34
 
35
- $scope.validateDate = function(){
35
+ $scope.validateDate = function () {
36
36
  $scope.checkDate($scope.modelString);
37
37
  };
38
38
 
39
39
 
40
- $scope.checkDate = function(date){
40
+ $scope.checkDate = function (date) {
41
41
  var parsedDate = moment(date, "HH:mm");
42
- if(parsedDate.isValid()){
43
- $scope.forma.$setValidity("valid-time", true);
42
+ if (parsedDate.isValid()) {
43
+ if ($scope.forma) $scope.forma.$setValidity("valid-time", true);
44
44
  $scope.model = parsedDate;
45
45
  $scope.refreshTime();
46
46
  if ($scope.onChange) $scope.onChange({ model: $scope.model });
47
47
  } else {
48
- $scope.forma.$setValidity("valid-time", false);
48
+ if ($scope.forma) $scope.forma.$setValidity("valid-time", false);
49
49
  $scope.modelString = "";
50
50
  }
51
51
  };
52
52
 
53
53
 
54
- $scope.refreshTime = function(){
54
+ $scope.refreshTime = function () {
55
55
  $scope.hours = $scope.model.format("HH");
56
56
  $scope.minutes = $scope.model.format("mm");
57
57
  $scope.modelString = $scope.model.format("HH:mm");
58
58
  };
59
59
 
60
60
 
61
- $scope.changeHour = function(add){
62
- if(add) $scope.model.add(1, 'hour');
61
+ $scope.changeHour = function (add) {
62
+ if (add) $scope.model.add(1, 'hour');
63
63
  else $scope.model.subtract(1, 'hour');
64
64
  $scope.refreshTime();
65
65
  $scope.forma.$setDirty();
66
66
  };
67
67
 
68
- $scope.changeMinutes = function(add){
69
- if(add) $scope.model.add(1, 'minutes');
68
+ $scope.changeMinutes = function (add) {
69
+ if (add) $scope.model.add(1, 'minutes');
70
70
  else $scope.model.subtract(1, 'minutes');
71
71
  $scope.refreshTime();
72
72
  $scope.forma.$setDirty();
73
73
  };
74
74
 
75
75
 
76
- $scope.$watch("model", function(value, oldValue){
76
+ $scope.$watch("model", function (value, oldValue) {
77
77
  $scope.refreshTime();
78
- if(!value.isSame(oldValue)){
78
+ if (!value.isSame(oldValue)) {
79
79
  $scope.checkDate(value);
80
80
  }
81
81
  })
@@ -31,7 +31,6 @@
31
31
 
32
32
  .nice-wrapper-title {
33
33
  font-size: 1.2em;
34
- font-weight: bold;
35
34
  line-height: 1.2;
36
35
  color: var(--nice-primary-color);
37
36
  }
@@ -66,4 +65,24 @@
66
65
  padding-bottom: 0;
67
66
  }
68
67
  }
68
+
69
+ &.nice-wrapper-sticky-footer {
70
+ .nice-wrapper-footer {
71
+ position: sticky;
72
+ bottom: calc(-1 * var(--nice-card-padding));
73
+ background: var(--nice-card-bg);
74
+ }
75
+ }
76
+
77
+ &.nice-wrapper-sticky-header {
78
+ .nice-wrapper-header {
79
+ position: sticky;
80
+ top: calc(-1 * var(--nice-card-padding));
81
+ background: var(--nice-card-bg);
82
+ }
83
+ }
84
+
85
+ .no-padding {
86
+ padding: 0;
87
+ }
69
88
  }
@@ -1,4 +1,4 @@
1
- <div class="nice-wrapper" ng-class="{ 'collapsable': collapsable, 'has-header': hasHeader, 'has-footer': hasFooter }">
1
+ <div class="nice-wrapper" ng-class="{ 'collapsable': collapsable, 'has-header': hasHeader, 'has-footer': hasFooter, 'nice-wrapper-sticky-footer': stickyFooter, 'nice-wrapper-sticky-header': stickyHeader }">
2
2
  <div class="nice-wrapper-header" ng-if="hasHeader" ng-click="toggle()">
3
3
  <div class="nice-wrapper-info">
4
4
  <div class="nice-wrapper-title" ng-transclude="title">{{ title }}</div>
@@ -8,6 +8,6 @@
8
8
  <nice-icon icon="icon-chevron-down"></nice-icon>
9
9
  </button>
10
10
  </div>
11
- <div class="nice-wrapper-body" ng-transclude ng-if="isOpen"></div>
11
+ <div class="nice-wrapper-body" ng-class=" {'no-padding': noPadding }" ng-transclude ng-if="isOpen"></div>
12
12
  <div class="nice-wrapper-footer" ng-if="isOpen && hasFooter" ng-transclude="footer"></div>
13
13
  </div>
@@ -22,11 +22,13 @@ angular.module('niceElements')
22
22
  subtitle: '@',
23
23
  collapsable: '=',
24
24
  collapsed: '@',
25
+ noPadding: '@',
26
+ stickyHeader: '@',
27
+ stickyFooter: '@',
25
28
  },
26
29
  controller: function ($scope, $transclude) {
27
30
  $scope.isOpen = true;
28
31
  if ($scope.collapsed) $scope.isOpen = false;
29
-
30
32
  $scope.hasTitle = $transclude.isSlotFilled('title');
31
33
  $scope.hasSubtitle = $transclude.isSlotFilled('subtitle');
32
34
  $scope.hasFooter = $transclude.isSlotFilled('footer');
@@ -10,7 +10,7 @@ angular.module('niceElements')
10
10
  .service('NiceService', function () {
11
11
  var service = {
12
12
  name: "Nice elements",
13
- version: "1.8.0",
13
+ version: "1.8.2",
14
14
  getHeader: function () {
15
15
  return {};
16
16
  }