nice-elements 1.4.8 → 1.4.10

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.
@@ -29,6 +29,10 @@ angular.module('niceElements')
29
29
  templateUrl: 'src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html',
30
30
  controller: function ($element, $timeout, $scope) {
31
31
  $scope.isOpen = false;
32
+ $scope.model = {
33
+ innerStartDate: null,
34
+ innerEndDate: null,
35
+ }
32
36
 
33
37
 
34
38
  // Set defaults
@@ -46,14 +50,14 @@ angular.module('niceElements')
46
50
  if(!$scope.startDate) {
47
51
  $scope.startDate = moment();
48
52
  } else {
49
- $scope.innerStartDate = angular.copy($scope.startDate);
53
+ $scope.model.innerStartDate = angular.copy($scope.startDate);
50
54
  }
51
55
 
52
56
  // Set end date
53
57
  if(!$scope.endDate) {
54
58
  $scope.endDate = moment();
55
59
  } else {
56
- $scope.innerEndDate = angular.copy($scope.endDate);
60
+ $scope.model.innerEndDate = angular.copy($scope.endDate);
57
61
  }
58
62
 
59
63
 
@@ -95,41 +99,41 @@ angular.module('niceElements')
95
99
 
96
100
 
97
101
  $scope.close = function() {
98
- $scope.innerStartDate = angular.copy($scope.startDate);
99
- $scope.innerEndDate = angular.copy($scope.endDate);
102
+ $scope.model.innerStartDate = angular.copy($scope.startDate);
103
+ $scope.model.innerEndDate = angular.copy($scope.endDate);
100
104
  $scope.isOpen = false;
101
105
  };
102
106
 
103
107
 
104
108
  $scope.confirm = function() {
105
- $scope.startDate = angular.copy($scope.innerStartDate);
106
- $scope.endDate = angular.copy($scope.innerEndDate);
107
- if ($scope.onChange) $scope.onChange({ model: $scope.model });
108
- $scope.close();
109
+ $scope.startDate = angular.copy($scope.model.innerStartDate);
110
+ $scope.endDate = angular.copy($scope.model.innerEndDate);
111
+ if ($scope.onChange) $scope.onChange({ startDate: $scope.startDate, endDate: $scope.endDate });
112
+ $scope.isOpen = false;
109
113
  };
110
114
 
111
115
 
112
116
  $scope.selectToday = function(){
113
- $scope.innerStartDate = moment().startOf('day');
114
- $scope.innerEndDate = moment().endOf('day');
117
+ $scope.model.innerStartDate = moment().startOf('day');
118
+ $scope.model.innerEndDate = moment().endOf('day');
115
119
  };
116
120
 
117
121
 
118
122
  $scope.selectLastNDays = function(days){
119
- $scope.innerStartDate = moment().subtract(days, 'days').startOf('day');
120
- $scope.innerEndDate = moment().endOf('day');
123
+ $scope.model.innerStartDate = moment().subtract(days, 'days').startOf('day');
124
+ $scope.model.innerEndDate = moment().endOf('day');
121
125
  };
122
126
 
123
127
 
124
128
  $scope.selectLastMonth = function(){
125
- $scope.innerStartDate = moment().subtract(1, 'months').startOf('month').startOf('date');
126
- $scope.innerEndDate = moment().subtract(1, 'months').endOf('month').endOf('date');
129
+ $scope.model.innerStartDate = moment().subtract(1, 'months').startOf('month').startOf('date');
130
+ $scope.model.innerEndDate = moment().subtract(1, 'months').endOf('month').endOf('date');
127
131
  };
128
132
 
129
133
 
130
134
  $scope.selectThisMonth = function(){
131
- $scope.innerStartDate = moment().startOf('month').startOf('date');
132
- $scope.innerEndDate = moment().endOf('month').endOf('date');
135
+ $scope.model.innerStartDate = moment().startOf('month').startOf('date');
136
+ $scope.model.innerEndDate = moment().endOf('month').endOf('date');
133
137
  };
134
138
 
135
139
 
@@ -139,28 +143,30 @@ angular.module('niceElements')
139
143
  };
140
144
 
141
145
 
142
- $scope.$watchGroup(["innerStartDate", "innerEndDate"], function(newValues){
143
- if (newValues[0] && newValues[1]) {
144
- // Check if start date is after end date
145
- if ($scope.innerStartDate.isAfter($scope.innerEndDate)) {
146
- var temp = angular.copy($scope.innerStartDate);
147
- $scope.innerStartDate = angular.copy($scope.innerEndDate);
148
- $scope.innerEndDate = temp;
149
- }
146
+ $scope.dateChanged = function() {
147
+ $timeout(function() {
148
+ if ($scope.model.innerStartDate && $scope.model.innerEndDate) {
149
+ // Check if start date is after end date
150
+ if ($scope.model.innerStartDate.isAfter($scope.model.innerEndDate)) {
151
+ var temp = angular.copy($scope.model.innerStartDate);
152
+ $scope.model.innerStartDate = angular.copy($scope.model.innerEndDate);
153
+ $scope.model.innerEndDate = temp;
154
+ }
150
155
 
151
- // Check if end date is before start date
152
- if ($scope.innerEndDate.isBefore($scope.innerStartDate)) {
153
- var temp = angular.copy($scope.innerStartDate);
154
- $scope.innerStartDate = angular.copy($scope.innerEndDate);
155
- $scope.innerEndDate = temp;
156
+ // Check if end date is before start date
157
+ if ($scope.model.innerEndDate.isBefore($scope.model.innerStartDate)) {
158
+ var temp = angular.copy($scope.model.innerStartDate);
159
+ $scope.model.innerStartDate = angular.copy($scope.model.innerEndDate);
160
+ $scope.model.innerEndDate = temp;
161
+ }
156
162
  }
157
- }
158
- });
163
+ });
164
+ }
159
165
 
160
166
 
161
- $scope.$watchGroup(["startDate", "endDate"], function(){
162
- $scope.innerStartDate = angular.copy($scope.startDate);
163
- $scope.innerEndDate = angular.copy($scope.endDate);
167
+ $scope.$watchGroup(["startDate", "endDate"], function() {
168
+ $scope.model.innerStartDate = angular.copy($scope.startDate);
169
+ $scope.model.innerEndDate = angular.copy($scope.endDate);
164
170
  $scope.format();
165
171
  });
166
172
  }
@@ -1,4 +1,7 @@
1
- <div class="nice-help">
2
- <i class="fa fa-question-circle"></i>
3
- <div class="help-window" ng-bind-html="text">{{ text }}</div>
4
- </div>
1
+ <div class="nice-help" ng-mouseover="onHover()">
2
+ <i class="fa fa-question-circle nice-help-button" aria-label=""></i>
3
+ <div class="nice-help-popup">
4
+ <span ng-bind-html="text">{{ text }}</span>
5
+ <div data-popper-arrow class="nice-help-arrow"></div>
6
+ </div>
7
+ </div>
@@ -13,6 +13,42 @@ angular.module('niceElements')
13
13
  restrict: 'E',
14
14
  scope: {
15
15
  text: '@'
16
+ },
17
+ controller: function ($scope, $element, $timeout) {
18
+ // Setup popper
19
+ // https://popper.js.org/docs/v2/constructors/
20
+ $scope.setupPopper = function () {
21
+ var button = $element[0].getElementsByClassName('nice-help-button')[0];
22
+ var tooltip = $element[0].getElementsByClassName('nice-help-popup')[0];
23
+ $scope.popper = Popper.createPopper(button, tooltip, {
24
+ strategy: 'fixed',
25
+ placement: 'top',
26
+ scroll: true,
27
+ resize: true,
28
+ modifiers: [
29
+ {
30
+ name: 'offset',
31
+ options: {
32
+ offset: [0, 5],
33
+ },
34
+ },
35
+ {
36
+ name: 'arrow',
37
+ options: {
38
+ padding: 2,
39
+ },
40
+ }
41
+ ],
42
+ });
43
+ };
44
+
45
+ // $timeout(function () {
46
+ // $scope.setupPopper();
47
+ // });
48
+
49
+ $scope.onHover = function () {
50
+ $scope.setupPopper();
51
+ }
16
52
  }
17
53
  };
18
54
  });
@@ -3,30 +3,26 @@
3
3
  position: relative;
4
4
  display: inline-block;
5
5
 
6
- i{
6
+ i {
7
7
  font-size: 14px;
8
8
  cursor: help;
9
9
  }
10
10
 
11
- &:hover{
12
- .help-window{
11
+ &:hover {
12
+ .nice-help-popup {
13
13
  display: block;
14
14
  }
15
15
  }
16
16
 
17
- .help-window{
17
+ .nice-help-popup {
18
18
  display: none;
19
- position: absolute;
19
+ z-index: 9999;
20
20
  background: $nice-help-popup-color;
21
21
  color: white;
22
22
  max-width: 200px;
23
23
  width: max-content;
24
- bottom: 100%;
25
- left: 50%;
26
24
  border-radius: $nice-border-radius;
27
25
  font-size: 12px;
28
- z-index: 99999;
29
- transform: translate(-50%, -3px);
30
26
  line-height: 1.3;
31
27
  padding: 7px 10px;
32
28
  font-weight: normal;
@@ -37,20 +33,40 @@
37
33
  text-transform: none;
38
34
  }
39
35
 
36
+ .nice-help-arrow,
37
+ .nice-help-arrow::before {
38
+ position: absolute;
39
+ width: 8px;
40
+ height: 8px;
41
+ background: inherit;
42
+ }
43
+
44
+ .nice-help-arrow {
45
+ visibility: hidden;
46
+ }
40
47
 
41
- &:before {
48
+ .nice-help-arrow::before {
49
+ visibility: visible;
42
50
  content: "";
43
- width: 0;
44
- height: 0;
45
- position: absolute;
46
- bottom: -3px;
47
- left: 50%;
48
- margin-left: -5px;
51
+ transform: rotate(45deg);
52
+ }
53
+
54
+ &[data-popper-placement^="top"]>.nice-help-arrow {
55
+ bottom: -2px;
56
+ margin-left: -4px;
57
+ }
58
+
59
+ &[data-popper-placement^="bottom"]>.nice-help-arrow {
60
+ top: -2px;
61
+ margin-left: -4px;
62
+ }
63
+
64
+ &[data-popper-placement^="left"]>.nice-help-arrow {
65
+ right: 1px;
66
+ }
49
67
 
50
- border-bottom: 0px solid transparent;
51
- border-left: 5px solid transparent;
52
- border-right: 5px solid transparent;
53
- border-top: 3px solid $nice-help-popup-color;
68
+ &[data-popper-placement^="right"]>.nice-help-arrow {
69
+ left: -6px;
54
70
  }
55
71
  }
56
- }
72
+ }