nice-elements 1.4.2 → 1.4.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.
@@ -11,50 +11,51 @@
11
11
  <div class="disabled-shield" ng-if="isDisabled"></div>
12
12
 
13
13
  <div class="nice-calendar-wrapper">
14
- <div class="header">
15
- <i class="fa fa-angle-left" ng-click="previous()" title="{{ 'Previous month' | translate:'Nice' }}"></i>
16
- <span title="{{ month.format('M.YYYY' )}}">{{ month.format("MMMM, YYYY" )}}</span>
17
- <i class="fa fa-angle-right" ng-click="next()" title="{{ 'Next month' | translate:'Nice' }}"></i>
18
- </div>
14
+ <div class="nice-calendar-weeks">
15
+ <div class="header">
16
+ <i class="fa fa-angle-left" ng-click="previous()" title="{{ 'Previous month' | translate:'Nice' }}"></i>
17
+ <span title="{{ month.format('M.YYYY' )}}">{{ month.format("MMMM, YYYY" )}}</span>
18
+ <i class="fa fa-angle-right" ng-click="next()" title="{{ 'Next month' | translate:'Nice' }}"></i>
19
+ </div>
19
20
 
20
- <div class="week names">
21
- <span class="day" translate translate-context="Nice">Mon</span>
22
- <span class="day" translate translate-context="Nice">Tue</span>
23
- <span class="day" translate translate-context="Nice">Wed</span>
24
- <span class="day" translate translate-context="Nice">Thu</span>
25
- <span class="day" translate translate-context="Nice">Fri</span>
26
- <span class="day weekend" translate translate-context="Nice">Sat</span>
27
- <span class="day weekend" translate translate-context="Nice">Sun</span>
28
- </div>
21
+ <div class="week names">
22
+ <span class="day" translate translate-context="Nice">Mon</span>
23
+ <span class="day" translate translate-context="Nice">Tue</span>
24
+ <span class="day" translate translate-context="Nice">Wed</span>
25
+ <span class="day" translate translate-context="Nice">Thu</span>
26
+ <span class="day" translate translate-context="Nice">Fri</span>
27
+ <span class="day weekend" translate translate-context="Nice">Sat</span>
28
+ <span class="day weekend" translate translate-context="Nice">Sun</span>
29
+ </div>
29
30
 
30
- <div class="week" ng-repeat="week in weeks">
31
- <span
32
- class="day"
33
- title="{{ day.date.format('D.M.YYYY') }}"
34
- ng-class="{
35
- today: day.isToday,
36
- 'different-month': !day.isCurrentMonth,
37
- 'start-selected': isSameDay(day.date, startDate),
38
- 'end-selected': isSameDay(day.date, endDate),
39
- 'selected': isBetweenRange(day.date),
40
- 'selecting-start': selectStart,
41
- 'selecting-end': !selectStart,
42
- 'weekend': day.isWeekday,
43
- 'disabled': day.isDisabled
44
- }"
45
- ng-style="
46
- (color && isBetweenRange(day.date)) && {'background-color': lighten(color) } ||
47
- (color && isSameDay(day.date, startDate)) && {'background-color': color } ||
48
- (color && isSameDay(day.date, endDate)) && {'background-color': color }
49
- "
50
- ng-click="select(day)"
51
- ng-repeat="day in week.days"
52
- >
53
- {{ day.number }}
54
- <p class="popup" ng-if="!hideHover">{{ popupText }}</p>
55
- </span>
31
+ <div class="week" ng-repeat="week in weeks">
32
+ <span
33
+ class="day"
34
+ title="{{ day.date.format('D.M.YYYY') }}"
35
+ ng-class="{
36
+ today: day.isToday,
37
+ 'different-month': !day.isCurrentMonth,
38
+ 'start-selected': isSameDay(day.date, startDate),
39
+ 'end-selected': isSameDay(day.date, endDate),
40
+ 'selected': isBetweenRange(day.date),
41
+ 'selecting-start': selectStart,
42
+ 'selecting-end': !selectStart,
43
+ 'weekend': day.isWeekday,
44
+ 'disabled': day.isDisabled
45
+ }"
46
+ ng-style="
47
+ (color && isBetweenRange(day.date)) && {'background-color': lighten(color) } ||
48
+ (color && isSameDay(day.date, startDate)) && {'background-color': color } ||
49
+ (color && isSameDay(day.date, endDate)) && {'background-color': color }
50
+ "
51
+ ng-click="select(day)"
52
+ ng-repeat="day in week.days"
53
+ >
54
+ {{ day.number }}
55
+ <p class="popup" ng-if="!hideHover">{{ popupText }}</p>
56
+ </span>
57
+ </div>
56
58
  </div>
57
- <div class="clearfix"></div>
58
59
 
59
60
 
60
61
  <div class="nice-calendar-time" ng-if="time">
@@ -112,7 +113,6 @@
112
113
  <label translate translate-context="Nice">End</label>
113
114
  <div ng-class="endTimeClass">{{ formatDate(endDate) }}</div>
114
115
  </div>
115
- <div class="clearfix"></div>
116
116
  </div>
117
117
  </div>
118
118
  </div>
@@ -7,7 +7,7 @@
7
7
  * # niceCalendar
8
8
  */
9
9
  angular.module('niceElements')
10
- .directive("niceCalendar", function($timeout, gettextCatalog) {
10
+ .directive("niceCalendar", function ($timeout, gettextCatalog) {
11
11
  return {
12
12
  restrict: "E",
13
13
  templateUrl: "src/components/nice-calendar/nice-calendar.html",
@@ -18,7 +18,7 @@ angular.module('niceElements')
18
18
  minDate: '=',
19
19
  maxDate: '=',
20
20
  hideHover: '=',
21
- time: '@',
21
+ time: '=',
22
22
  noMargin: '@',
23
23
  color: '@',
24
24
  endDate: '=',
@@ -28,7 +28,7 @@ angular.module('niceElements')
28
28
  isInline: '=',
29
29
  onChange: '&?'
30
30
  },
31
- link: function(scope, element) {
31
+ link: function (scope, element) {
32
32
  // ------------------ Init default values ------------------
33
33
  scope.selectStart = true;
34
34
  scope.popupText = gettextCatalog.getString("Select start date", null, "Nice");
@@ -43,37 +43,52 @@ angular.module('niceElements')
43
43
 
44
44
 
45
45
  // ------------------ Check if attributes are set ------------------
46
- if(!scope.startDate) scope.startDate = moment().minutes(0).second(0).millisecond(0);
47
- if(!scope.endDate) scope.endDate = moment().minutes(0).second(0).millisecond(0);
46
+ if (!scope.startDate) scope.startDate = moment().minutes(0).second(0).millisecond(0);
47
+ if (!scope.endDate) scope.endDate = moment().minutes(0).second(0).millisecond(0);
48
48
 
49
49
 
50
50
  // ------------------ Look for model changes ------------------
51
- scope.$watch("startDate", function(value, valueOld){
51
+ scope.$watch("startDate", function (value, valueOld) {
52
52
  bootstrap();
53
53
  });
54
54
 
55
- scope.$watch("endDate", function(value, valueOld){
55
+ scope.$watch("endDate", function (value, valueOld) {
56
56
  bootstrap();
57
57
  });
58
58
 
59
- scope.$watch("minDate", function(value, valueOld){
59
+ scope.$watch("minDate", function (value, valueOld) {
60
60
  bootstrap();
61
61
  });
62
62
 
63
- scope.$watch("maxDate", function(value, valueOld){
63
+ scope.$watch("maxDate", function (value, valueOld) {
64
64
  bootstrap();
65
65
  });
66
66
 
67
67
 
68
68
  // ------------------ Bootstrap calendar ------------------
69
69
  function bootstrap() {
70
- //scope.startDate = moment(scope.startDate.second(0).millisecond(0));
71
- //scope.endDate = moment(scope.endDate.second(0).millisecond(0));
72
-
73
- scope.startDateHour = moment(scope.startDate).hours();
74
- scope.startDateMinute = moment(scope.startDate).minutes();
75
- scope.endDateHour = moment(scope.endDate).hours();
76
- scope.endDateMinute = moment(scope.endDate).minutes();
70
+ // scope.startDate = moment(scope.startDate.second(0).millisecond(0));
71
+ // scope.endDate = moment(scope.endDate.second(0).millisecond(0));
72
+
73
+ if (!scope.time) {
74
+ scope.startDateHour = 0;
75
+ scope.startDateMinute = 0;
76
+ scope.startDate.hours(0);
77
+ scope.startDate.minutes(0);
78
+ scope.startDate.seconds(0);
79
+ scope.startDate.millisecond(0);
80
+ scope.endDateHour = 0;
81
+ scope.endDateMinut = 0;
82
+ scope.endDate.hours(23);
83
+ scope.endDate.minutes(59);
84
+ scope.endDate.seconds(59);
85
+ scope.endDate.millisecond(999);
86
+ } else {
87
+ scope.startDateHour = moment(scope.startDate).hours();
88
+ scope.startDateMinute = moment(scope.startDate).minutes();
89
+ scope.endDateHour = moment(scope.endDate).hours();
90
+ scope.endDateMinute = moment(scope.endDate).minutes();
91
+ }
77
92
 
78
93
  scope.month = angular.copy(moment(scope.startDate));
79
94
  var start = angular.copy(moment(scope.startDate));
@@ -85,13 +100,20 @@ angular.module('niceElements')
85
100
 
86
101
 
87
102
  // ------------------ Day was selected ------------------
88
- scope.select = function(day) {
89
- if(!day.isDisabled){
103
+ scope.select = function (day) {
104
+ if (!day.isDisabled) {
90
105
  var selectedDate = angular.copy(day.date);
91
106
 
92
- if(scope.selectStart){
93
- selectedDate.hours(scope.startDateHour);
94
- selectedDate.minutes(scope.startDateMinute);
107
+ if (scope.selectStart) {
108
+ if (!scope.time) {
109
+ selectedDate.hours(0);
110
+ selectedDate.minutes(0);
111
+ selectedDate.seconds(0);
112
+ selectedDate.millisecond(0);
113
+ } else {
114
+ selectedDate.hours(scope.startDateHour);
115
+ selectedDate.minutes(scope.startDateMinute);
116
+ }
95
117
 
96
118
  // Set start date
97
119
  scope.startDate = selectedDate;
@@ -101,12 +123,22 @@ angular.module('niceElements')
101
123
  scope.displayStartChange();
102
124
 
103
125
  // If start date is after end date
104
- if(scope.startDate.isAfter(scope.endDate)){
126
+ if (scope.startDate.isAfter(scope.endDate)) {
105
127
  scope.endDate = angular.copy(scope.startDate);
106
128
  }
107
129
  } else {
108
- selectedDate.hours(scope.endDateHour);
109
- selectedDate.minutes(scope.endDateMinute);
130
+
131
+
132
+ if (!scope.time) {
133
+ selectedDate.hours(23);
134
+ selectedDate.minutes(59);
135
+ selectedDate.seconds(59);
136
+ selectedDate.millisecond(999);
137
+ } else {
138
+ selectedDate.hours(scope.endDateHour);
139
+ selectedDate.minutes(scope.endDateMinute);
140
+ }
141
+
110
142
 
111
143
  // Set end date
112
144
  scope.endDate = selectedDate;
@@ -116,34 +148,34 @@ angular.module('niceElements')
116
148
  scope.displayEndChange();
117
149
 
118
150
  // If end date is before start date
119
- if(scope.endDate.isBefore(scope.startDate)){
151
+ if (scope.endDate.isBefore(scope.startDate)) {
120
152
  scope.startDate = angular.copy(scope.endDate);
121
153
  }
122
154
  }
123
155
 
124
- if (scope.onChange) scope.onChange({ model: {startDate: scope.startDate, endDate: scope.endDate}, element: element });
156
+ if (scope.onChange) scope.onChange({ model: { startDate: scope.startDate, endDate: scope.endDate }, element: element });
125
157
  }
126
158
  };
127
159
 
128
160
 
129
161
  // ------------------ Display date changes ------------------
130
- scope.displayStartChange = function(){
162
+ scope.displayStartChange = function () {
131
163
  scope.startTimeClass = "change";
132
- $timeout(function(){
164
+ $timeout(function () {
133
165
  scope.startTimeClass = "";
134
166
  }, 1000);
135
167
  };
136
168
 
137
- scope.displayEndChange = function(){
169
+ scope.displayEndChange = function () {
138
170
  scope.endTimeClass = "change";
139
- $timeout(function(){
171
+ $timeout(function () {
140
172
  scope.endTimeClass = "";
141
173
  }, 1000);
142
174
  };
143
175
 
144
176
 
145
177
  // ------------------ Time changes ------------------
146
- scope.startHourChange = function(value){
178
+ scope.startHourChange = function (value) {
147
179
  scope.startDateHour = value;
148
180
  scope.startDate = moment(scope.startDate).hours(scope.startDateHour);
149
181
  scope.formCalendar.$setDirty();
@@ -151,7 +183,7 @@ angular.module('niceElements')
151
183
  };
152
184
 
153
185
 
154
- scope.startMinuteChange = function(value) {
186
+ scope.startMinuteChange = function (value) {
155
187
  scope.startDateMinute = value;
156
188
  scope.startDate = moment(scope.startDate).minutes(scope.startDateMinute);
157
189
  scope.formCalendar.$setDirty();
@@ -159,7 +191,7 @@ angular.module('niceElements')
159
191
  };
160
192
 
161
193
 
162
- scope.endHourChange = function(value){
194
+ scope.endHourChange = function (value) {
163
195
  scope.endDateHour = value;
164
196
  scope.endDate = moment(scope.endDate).hours(scope.endDateHour);
165
197
  scope.formCalendar.$setDirty();
@@ -167,7 +199,7 @@ angular.module('niceElements')
167
199
  };
168
200
 
169
201
 
170
- scope.endMinuteChange = function(value) {
202
+ scope.endMinuteChange = function (value) {
171
203
  scope.endDateMinute = value;
172
204
  scope.endDate = moment(scope.endDate).minutes(scope.endDateMinute);
173
205
  scope.formCalendar.$setDirty();
@@ -176,25 +208,25 @@ angular.module('niceElements')
176
208
 
177
209
 
178
210
  // ------------------ Go to next month ------------------
179
- scope.next = function() {
211
+ scope.next = function () {
180
212
  var next = angular.copy(scope.month);
181
- _removeTimeWithDate(next.month(next.month()+1).date(0));
182
- scope.month.month(scope.month.month()+1);
213
+ _removeTimeWithDate(next.month(next.month() + 1).date(0));
214
+ scope.month.month(scope.month.month() + 1);
183
215
  _buildMonth(scope, next, scope.month);
184
216
  };
185
217
 
186
218
 
187
219
  // ------------------ Go to previous month ------------------
188
- scope.previous = function() {
220
+ scope.previous = function () {
189
221
  var previous = angular.copy(scope.month);
190
- _removeTimeWithDate(previous.month(previous.month()-1).date(0));
191
- scope.month.month(scope.month.month()-1);
222
+ _removeTimeWithDate(previous.month(previous.month() - 1).date(0));
223
+ scope.month.month(scope.month.month() - 1);
192
224
  _buildMonth(scope, previous, scope.month);
193
225
  };
194
226
 
195
227
 
196
228
  // ------------------ Check if dates are equal without time ------------------
197
- scope.isSameDay = function(date1, date2){
229
+ scope.isSameDay = function (date1, date2) {
198
230
  var d1 = _removeTime(angular.copy(date1));
199
231
  var d2 = _removeTime(angular.copy(date2));
200
232
  return d1.isSame(d2);
@@ -202,20 +234,20 @@ angular.module('niceElements')
202
234
 
203
235
 
204
236
  // ------------------ Check if date is between start and end date ------------------
205
- scope.isBetweenRange = function(date){
237
+ scope.isBetweenRange = function (date) {
206
238
  return (date.isBefore(moment(scope.endDate)) && date.isAfter(moment(scope.startDate)));
207
239
  };
208
240
 
209
241
 
210
242
  // ------------------ Format date ------------------
211
- scope.formatDate = function(date){
212
- if(scope.time) return moment(date).format('D.M.YYYY • H:mm');
243
+ scope.formatDate = function (date) {
244
+ if (scope.time) return moment(date).format('D.M.YYYY • H:mm');
213
245
  else return moment(date).format('D.M.YYYY');
214
246
  };
215
247
 
216
248
 
217
249
  // ------------------ Lighten color by 20% ------------------
218
- scope.lighten = function(col){
250
+ scope.lighten = function (col) {
219
251
  var amt = 20;
220
252
  var usePound = false;
221
253
 
@@ -224,21 +256,21 @@ angular.module('niceElements')
224
256
  usePound = true;
225
257
  }
226
258
 
227
- var num = parseInt(col,16);
259
+ var num = parseInt(col, 16);
228
260
  var r = (num >> 16) + amt;
229
261
 
230
262
  if (r > 255) r = 255;
231
- else if (r < 0) r = 0;
263
+ else if (r < 0) r = 0;
232
264
 
233
265
  var b = ((num >> 8) & 0x00FF) + amt;
234
266
  if (b > 255) b = 255;
235
- else if (b < 0) b = 0;
267
+ else if (b < 0) b = 0;
236
268
 
237
269
  var g = (num & 0x0000FF) + amt;
238
270
  if (g > 255) g = 255;
239
271
  else if (g < 0) g = 0;
240
272
 
241
- return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16);
273
+ return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
242
274
  };
243
275
 
244
276
 
@@ -280,9 +312,9 @@ angular.module('niceElements')
280
312
  date: date
281
313
  };
282
314
 
283
- if(scope.minDate) day.isDisabled = date.isBefore(moment(scope.minDate));
284
- if(scope.maxDate) day.isDisabled = date.isAfter(moment(scope.maxDate));
285
- if(scope.minDate && scope.maxDate) day.isDisabled = !date.isBetween(moment(scope.minDate), moment(scope.maxDate));
315
+ if (scope.minDate) day.isDisabled = date.isBefore(moment(scope.minDate));
316
+ if (scope.maxDate) day.isDisabled = date.isAfter(moment(scope.maxDate));
317
+ if (scope.minDate && scope.maxDate) day.isDisabled = !date.isBetween(moment(scope.minDate), moment(scope.maxDate));
286
318
 
287
319
  days.push(day);
288
320
  date = date.clone();
@@ -293,4 +325,4 @@ angular.module('niceElements')
293
325
  }
294
326
  }
295
327
  };
296
- });
328
+ });
@@ -2,34 +2,34 @@
2
2
  display: block;
3
3
 
4
4
  .nice-selected-dates {
5
- padding: 5px 10px;
5
+ padding: 0 10px 5px 10px;
6
+ display: flex;
6
7
 
7
8
  .nice-start-date, .nice-end-date{
8
9
  width: 50%;
9
- float: left;
10
10
  color: $nice-font-color;
11
11
  transition: all 0.3s ease;
12
12
 
13
13
  label{
14
14
  font-size: 9px;
15
15
  font-weight: normal;
16
+ margin: 0;
17
+ line-height: 1;
16
18
  }
17
19
  }
18
20
 
19
- .nice-start-date{
20
- padding-right: 10px;
21
- }
22
-
23
- .nice-end-date{
24
- padding-left: 10px;
21
+ .nice-end-date {
25
22
  text-align: right;
26
23
  }
27
24
  }
28
25
 
26
+ .nice-calendar-weeks {
27
+ border-bottom: 1px solid $nice-border-color;
28
+ }
29
+
29
30
 
30
- .nice-calendar-time{
31
- border-top: 1px solid $nice-border-color;
32
- position: relative;
31
+ .nice-calendar-time {
32
+ display: flex;
33
33
 
34
34
  .no-border-right{
35
35
  .time-picker-minute{
@@ -40,7 +40,6 @@
40
40
  .time-picker{
41
41
  position: relative;
42
42
  width: 20%;
43
- float: left;
44
43
  height: 30px;
45
44
 
46
45
  &:after{
@@ -145,7 +144,7 @@
145
144
  }
146
145
 
147
146
  .week {
148
- float: left;
147
+ display: flex;
149
148
  width: 100%;
150
149
  border-top: solid 1px $nice-border-color;
151
150
 
@@ -155,7 +154,6 @@
155
154
 
156
155
  .day {
157
156
  position: relative;
158
- float: left;
159
157
  width: $day-width;
160
158
  height: $day-height;
161
159
  line-height: $day-height;