nice-elements 1.9.14 → 1.9.16

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.
Files changed (136) hide show
  1. package/.vscode/settings.json +17 -17
  2. package/CHANGELOG.md +401 -390
  3. package/LICENSE.md +21 -21
  4. package/README.md +93 -93
  5. package/bower.json +10 -10
  6. package/dist/nice.js +7930 -7954
  7. package/dist/nice.min.js +1 -1
  8. package/dist/style.css +7 -7
  9. package/dist/style.min.css +7 -7
  10. package/package.json +40 -40
  11. package/src/components/nice-button/nice-button.html +4 -4
  12. package/src/components/nice-button/nice-button.js +41 -41
  13. package/src/components/nice-button/nice-button.scss +16 -16
  14. package/src/components/nice-button-toggle/nice-button-toggle.html +9 -9
  15. package/src/components/nice-button-toggle/nice-button-toggle.js +23 -23
  16. package/src/components/nice-button-toggle/nice-button-toggle.scss +2 -2
  17. package/src/components/nice-calendar/nice-calendar.html +91 -91
  18. package/src/components/nice-calendar/nice-calendar.js +334 -334
  19. package/src/components/nice-calendar/nice-calendar.scss +285 -285
  20. package/src/components/nice-checkbox/nice-checkbox.html +5 -5
  21. package/src/components/nice-checkbox/nice-checkbox.js +33 -33
  22. package/src/components/nice-checkbox/nice-checkbox.scss +91 -91
  23. package/src/components/nice-choice/nice-choice.html +18 -18
  24. package/src/components/nice-choice/nice-choice.js +210 -210
  25. package/src/components/nice-choice/nice-choice.scss +110 -110
  26. package/src/components/nice-click-outside/nice-click-outside.js +105 -105
  27. package/src/components/nice-comment/nice-comment.html +10 -10
  28. package/src/components/nice-comment/nice-comment.js +69 -69
  29. package/src/components/nice-comment/nice-comment.scss +39 -39
  30. package/src/components/nice-date/nice-date.html +74 -74
  31. package/src/components/nice-date/nice-date.js +327 -327
  32. package/src/components/nice-date/nice-date.scss +302 -302
  33. package/src/components/nice-date-input/nice-date-input.html +41 -41
  34. package/src/components/nice-date-input/nice-date-input.js +109 -109
  35. package/src/components/nice-date-input/nice-date-input.scss +45 -45
  36. package/src/components/nice-date-range/nice-date-range.html +15 -15
  37. package/src/components/nice-date-range/nice-date-range.js +76 -76
  38. package/src/components/nice-date-range/nice-date-range.scss +390 -390
  39. package/src/components/nice-datetime-picker/nice-datetime-picker.html +29 -29
  40. package/src/components/nice-datetime-picker/nice-datetime-picker.js +87 -87
  41. package/src/components/nice-datetime-picker/nice-datetime-picker.scss +428 -428
  42. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +55 -55
  43. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.js +246 -246
  44. package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.scss +73 -73
  45. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +44 -44
  46. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +172 -172
  47. package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +127 -127
  48. package/src/components/nice-dropdown/nice-dropdown.html +60 -60
  49. package/src/components/nice-dropdown/nice-dropdown.js +489 -489
  50. package/src/components/nice-dropdown/nice-dropdown.scss +249 -249
  51. package/src/components/nice-dropdown-date/nice-dropdown-date.html +28 -28
  52. package/src/components/nice-dropdown-date/nice-dropdown-date.js +126 -126
  53. package/src/components/nice-dropdown-date/nice-dropdown-date.scss +82 -82
  54. package/src/components/nice-dropdown-old/nice-dropdown-old.html +44 -44
  55. package/src/components/nice-dropdown-old/nice-dropdown-old.js +330 -330
  56. package/src/components/nice-dropdown-old/nice-dropdown-old.scss +129 -129
  57. package/src/components/nice-dtp/nice-dtp.html +91 -91
  58. package/src/components/nice-dtp/nice-dtp.js +833 -833
  59. package/src/components/nice-help/nice-help.html +6 -6
  60. package/src/components/nice-help/nice-help.js +55 -55
  61. package/src/components/nice-help/nice-help.scss +78 -78
  62. package/src/components/nice-input/nice-input.html +48 -48
  63. package/src/components/nice-input/nice-input.js +244 -231
  64. package/src/components/nice-input/nice-input.scss +130 -130
  65. package/src/components/nice-label/nice-label.html +10 -10
  66. package/src/components/nice-label/nice-label.js +30 -30
  67. package/src/components/nice-loader/nice-loader.html +6 -6
  68. package/src/components/nice-loader/nice-loader.js +28 -28
  69. package/src/components/nice-loader/nice-loader.scss +47 -47
  70. package/src/components/nice-notification/nice-notification.html +3 -3
  71. package/src/components/nice-notification/nice-notification.js +124 -124
  72. package/src/components/nice-notification/nice-notification.scss +66 -66
  73. package/src/components/nice-number/nice-number.html +40 -40
  74. package/src/components/nice-number/nice-number.js +169 -166
  75. package/src/components/nice-number/nice-number.scss +18 -18
  76. package/src/components/nice-percent/nice-percent.html +24 -24
  77. package/src/components/nice-percent/nice-percent.js +94 -94
  78. package/src/components/nice-pill/nice-pill.html +3 -3
  79. package/src/components/nice-pill/nice-pill.js +29 -29
  80. package/src/components/nice-pill/nice-pill.scss +25 -25
  81. package/src/components/nice-popup/nice-popup.html +6 -6
  82. package/src/components/nice-popup/nice-popup.js +122 -122
  83. package/src/components/nice-popup/nice-popup.scss +43 -43
  84. package/src/components/nice-progress-bar/nice-progress-bar.html +15 -15
  85. package/src/components/nice-progress-bar/nice-progress-bar.js +54 -54
  86. package/src/components/nice-progress-bar/nice-progress-bar.scss +47 -47
  87. package/src/components/nice-quantity/nice-quantity.html +22 -22
  88. package/src/components/nice-quantity/nice-quantity.js +55 -55
  89. package/src/components/nice-quantity/nice-quantity.scss +51 -51
  90. package/src/components/nice-search/nice-search.html +44 -44
  91. package/src/components/nice-search/nice-search.js +239 -239
  92. package/src/components/nice-search/nice-search.scss +90 -90
  93. package/src/components/nice-search2/nice-search2.html +32 -32
  94. package/src/components/nice-search2/nice-search2.js +264 -264
  95. package/src/components/nice-search2/nice-search2.scss +80 -80
  96. package/src/components/nice-slot/nice-slot.html +10 -10
  97. package/src/components/nice-slot/nice-slot.js +29 -29
  98. package/src/components/nice-steps/nice-steps.scss +81 -81
  99. package/src/components/nice-svgs/nice-svgs.html +1262 -1262
  100. package/src/components/nice-svgs/nice-svgs.js +16 -16
  101. package/src/components/nice-time-picker/nice-time-picker.html +43 -43
  102. package/src/components/nice-time-picker/nice-time-picker.js +83 -83
  103. package/src/components/nice-time-picker/nice-time-picker.scss +37 -37
  104. package/src/components/nice-title/nice-title.html +3 -3
  105. package/src/components/nice-title/nice-title.js +21 -21
  106. package/src/components/nice-toast/nice-toast.html +2 -2
  107. package/src/components/nice-toast/nice-toast.js +56 -56
  108. package/src/components/nice-toast/nice-toast.scss +74 -74
  109. package/src/components/nice-toggle/nice-toggle.html +12 -12
  110. package/src/components/nice-toggle/nice-toggle.js +95 -95
  111. package/src/components/nice-toggle/nice-toggle.scss +67 -67
  112. package/src/components/nice-tooltip/_nice-tooltip.scss +71 -71
  113. package/src/components/nice-tooltip/nice-tooltip.js +23 -23
  114. package/src/components/nice-upload/nice-upload.html +22 -22
  115. package/src/components/nice-upload/nice-upload.js +157 -157
  116. package/src/components/nice-upload/nice-upload.scss +85 -85
  117. package/src/components/nice-wrapper/_nice-wrapper.scss +87 -87
  118. package/src/components/nice-wrapper/nice-wrapper.html +12 -12
  119. package/src/components/nice-wrapper/nice-wrapper.js +43 -43
  120. package/src/components/nice-yesno/nice-yesno.html +14 -14
  121. package/src/components/nice-yesno/nice-yesno.js +109 -109
  122. package/src/components/nice-yesno/nice-yesno.scss +95 -95
  123. package/src/filters/nice-date.js +17 -17
  124. package/src/filters/nice-highlight.js +16 -16
  125. package/src/modals/nice-multilangual-modal/nice-multilangual-modal.html +30 -30
  126. package/src/modals/nice-multilangual-modal/nice-multilangual-modal.js +67 -67
  127. package/src/modals/nice-multilangual-modal/nice-multilangual-modal.scss +19 -19
  128. package/src/nice.js +2 -2
  129. package/src/services/nice-service.js +19 -19
  130. package/src/styles/_bootstrap-variables.scss +178 -178
  131. package/src/styles/_nice-buttons.scss +403 -403
  132. package/src/styles/_nice-common.scss +471 -471
  133. package/src/styles/_nice-ngdialog.scss +85 -85
  134. package/src/styles/_nice-spacing.scss +283 -283
  135. package/src/styles/_nice.scss +65 -65
  136. package/src/styles/_variables.scss +195 -195
@@ -1,334 +1,334 @@
1
- 'use strict';
2
-
3
- /**
4
- * @ngdoc directive
5
- * @name niceElements.directive:niceCalendar
6
- * @description
7
- * # niceCalendar
8
- */
9
- angular.module('niceElements')
10
- .directive("niceCalendar", function ($timeout, gettextCatalog) {
11
- return {
12
- restrict: "E",
13
- templateUrl: "src/components/nice-calendar/nice-calendar.html",
14
- scope: {
15
- title: '@',
16
- fieldWidth: '@',
17
- labelWidth: '@',
18
- minDate: '=',
19
- maxDate: '=',
20
- hideHover: '=',
21
- time: '=',
22
- noMargin: '@',
23
- color: '@',
24
- endDate: '=',
25
- startDate: '=',
26
- isDisabled: '=',
27
- help: '@',
28
- isInline: '=',
29
- onChange: '&?'
30
- },
31
- link: function (scope, element) {
32
- // ------------------ Init default values ------------------
33
- scope.selectStart = true;
34
- scope.popupText = gettextCatalog.getString("Select start date", null, "Nice");
35
-
36
- scope.hours = [
37
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
38
- ];
39
-
40
- scope.minutes = [
41
- 0, 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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59
42
- ];
43
-
44
-
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);
48
-
49
-
50
- // ------------------ Look for model changes ------------------
51
- scope.$watch("startDate", function (value, valueOld) {
52
- bootstrap();
53
- });
54
-
55
- scope.$watch("endDate", function (value, valueOld) {
56
- bootstrap();
57
- });
58
-
59
- scope.$watch("minDate", function (value, valueOld) {
60
- bootstrap();
61
- });
62
-
63
- scope.$watch("maxDate", function (value, valueOld) {
64
- bootstrap();
65
- });
66
-
67
-
68
- // ------------------ Bootstrap calendar ------------------
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
- 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
- }
92
-
93
- scope.month = angular.copy(moment(scope.startDate));
94
- var start = angular.copy(moment(scope.startDate));
95
- _removeTimeWithDate(start.date(0));
96
- _buildMonth(scope, start, scope.month);
97
- }
98
-
99
- bootstrap();
100
-
101
-
102
- // ------------------ Day was selected ------------------
103
- scope.select = function (day) {
104
- if (!day.isDisabled) {
105
- var selectedDate = angular.copy(day.date);
106
-
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
- }
117
-
118
- // Set start date
119
- scope.startDate = selectedDate;
120
- scope.selectStart = false;
121
- scope.popupText = gettextCatalog.getString("Select end date", null, "Nice");
122
- scope.formCalendar.$setDirty();
123
- scope.displayStartChange();
124
-
125
- // If start date is after end date
126
- if (scope.startDate.isAfter(scope.endDate)) {
127
- scope.endDate = angular.copy(scope.startDate);
128
- }
129
- } else {
130
- if (!scope.time) {
131
- selectedDate.hours(23);
132
- selectedDate.minutes(59);
133
- selectedDate.seconds(59);
134
- selectedDate.millisecond(999);
135
- } else {
136
- selectedDate.hours(scope.endDateHour);
137
- selectedDate.minutes(scope.endDateMinute);
138
- }
139
-
140
- // Set end date
141
- scope.endDate = selectedDate;
142
- scope.selectStart = true;
143
- scope.popupText = gettextCatalog.getString("Select start date", null, "Nice");
144
- scope.formCalendar.$setDirty();
145
- scope.displayEndChange();
146
-
147
- // If end date is before start date
148
- if (scope.endDate.isBefore(scope.startDate)) {
149
- scope.startDate = angular.copy(scope.endDate);
150
- }
151
- }
152
-
153
- if (scope.onChange) scope.onChange({ model: { startDate: scope.startDate, endDate: scope.endDate }, element: element });
154
- }
155
- };
156
-
157
-
158
- // ------------------ Display date changes ------------------
159
- scope.displayStartChange = function () {
160
- scope.startTimeClass = "change";
161
- $timeout(function () {
162
- scope.startTimeClass = "";
163
- }, 1000);
164
- };
165
-
166
- scope.displayEndChange = function () {
167
- scope.endTimeClass = "change";
168
- $timeout(function () {
169
- scope.endTimeClass = "";
170
- }, 1000);
171
- };
172
-
173
-
174
- // ------------------ Time changes ------------------
175
- scope.startHourChange = function (value) {
176
- scope.startDateHour = value;
177
- scope.startDate = moment(scope.startDate).hours(scope.startDateHour);
178
- scope.formCalendar.$setDirty();
179
- scope.displayStartChange();
180
- scope.handleUpdate();
181
- };
182
-
183
-
184
- scope.startMinuteChange = function (value) {
185
- scope.startDateMinute = value;
186
- scope.startDate = moment(scope.startDate).minutes(scope.startDateMinute);
187
- scope.formCalendar.$setDirty();
188
- scope.displayStartChange();
189
- scope.handleUpdate();
190
- };
191
-
192
-
193
- scope.endHourChange = function (value) {
194
- scope.endDateHour = value;
195
- scope.endDate = moment(scope.endDate).hours(scope.endDateHour);
196
- scope.formCalendar.$setDirty();
197
- scope.displayEndChange();
198
- scope.handleUpdate();
199
- };
200
-
201
-
202
- scope.endMinuteChange = function (value) {
203
- scope.endDateMinute = value;
204
- scope.endDate = moment(scope.endDate).minutes(scope.endDateMinute);
205
- scope.formCalendar.$setDirty();
206
- scope.displayEndChange();
207
- scope.handleUpdate();
208
- };
209
-
210
-
211
- scope.handleUpdate = function () {
212
- if (scope.onChange) scope.onChange({ model: { startDate: scope.startDate, endDate: scope.endDate }, element: element });
213
- };
214
-
215
-
216
- // ------------------ Go to next month ------------------
217
- scope.next = function () {
218
- var next = angular.copy(scope.month);
219
- _removeTimeWithDate(next.month(next.month() + 1).date(0));
220
- scope.month.month(scope.month.month() + 1);
221
- _buildMonth(scope, next, scope.month);
222
- };
223
-
224
-
225
- // ------------------ Go to previous month ------------------
226
- scope.previous = function () {
227
- var previous = angular.copy(scope.month);
228
- _removeTimeWithDate(previous.month(previous.month() - 1).date(0));
229
- scope.month.month(scope.month.month() - 1);
230
- _buildMonth(scope, previous, scope.month);
231
- };
232
-
233
-
234
- // ------------------ Check if dates are equal without time ------------------
235
- scope.isSameDay = function (date1, date2) {
236
- var d1 = _removeTime(angular.copy(date1));
237
- var d2 = _removeTime(angular.copy(date2));
238
- return d1.isSame(d2);
239
- };
240
-
241
-
242
- // ------------------ Check if date is between start and end date ------------------
243
- scope.isBetweenRange = function (date) {
244
- return (date.isBefore(moment(scope.endDate)) && date.isAfter(moment(scope.startDate)));
245
- };
246
-
247
-
248
- // ------------------ Format date ------------------
249
- scope.formatDate = function (date) {
250
- if (scope.time) return moment(date).format('D.M.YYYY • H:mm');
251
- else return moment(date).format('D.M.YYYY');
252
- };
253
-
254
-
255
- // ------------------ Lighten color by 20% ------------------
256
- scope.lighten = function (col) {
257
- var amt = 20;
258
- var usePound = false;
259
-
260
- if (col[0] == "#") {
261
- col = col.slice(1);
262
- usePound = true;
263
- }
264
-
265
- var num = parseInt(col, 16);
266
- var r = (num >> 16) + amt;
267
-
268
- if (r > 255) r = 255;
269
- else if (r < 0) r = 0;
270
-
271
- var b = ((num >> 8) & 0x00FF) + amt;
272
- if (b > 255) b = 255;
273
- else if (b < 0) b = 0;
274
-
275
- var g = (num & 0x0000FF) + amt;
276
- if (g > 255) g = 255;
277
- else if (g < 0) g = 0;
278
-
279
- return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
280
- };
281
-
282
-
283
- // ------------------ Remove time from date ------------------
284
- function _removeTime(date) {
285
- return moment(date).hour(0).minute(0).second(0).millisecond(0);
286
- }
287
-
288
- function _removeTimeWithDate(date) {
289
- return date.day(0).hour(0).minute(0).second(0).millisecond(0);
290
- }
291
-
292
-
293
-
294
- // ------------------ Build month ------------------
295
- function _buildMonth(scope, start, month) {
296
- scope.weeks = [];
297
- var done = false, date = start.clone().startOf('week').isoWeekday(1), monthIndex = date.month(), count = 0;
298
- date.add(1, "w");
299
- while (!done) {
300
- scope.weeks.push({ days: _buildWeek(date.clone(), month) });
301
- date.add(1, "w");
302
- done = count++ > 2 && monthIndex !== date.month();
303
- monthIndex = date.month();
304
- }
305
- }
306
-
307
-
308
- // ------------------ Build week ------------------
309
- function _buildWeek(date, month) {
310
- var days = [];
311
- for (var i = 0; i < 7; i++) {
312
- var day = {
313
- name: date.format("dd"),
314
- number: date.date(),
315
- isCurrentMonth: date.month() === month.month(),
316
- isToday: date.isSame(new Date(), "day"),
317
- isWeekday: date.weekday() == 0 || date.weekday() == 6,
318
- date: date
319
- };
320
-
321
- if (scope.minDate) day.isDisabled = date.isBefore(moment(scope.minDate));
322
- if (scope.maxDate) day.isDisabled = date.isAfter(moment(scope.maxDate));
323
- if (scope.minDate && scope.maxDate) day.isDisabled = !date.isBetween(moment(scope.minDate), moment(scope.maxDate));
324
-
325
- days.push(day);
326
- date = date.clone();
327
- date.add(1, "d");
328
- }
329
-
330
- return days;
331
- }
332
- }
333
- };
334
- });
1
+ 'use strict';
2
+
3
+ /**
4
+ * @ngdoc directive
5
+ * @name niceElements.directive:niceCalendar
6
+ * @description
7
+ * # niceCalendar
8
+ */
9
+ angular.module('niceElements')
10
+ .directive("niceCalendar", function ($timeout, gettextCatalog) {
11
+ return {
12
+ restrict: "E",
13
+ templateUrl: "src/components/nice-calendar/nice-calendar.html",
14
+ scope: {
15
+ title: '@',
16
+ fieldWidth: '@',
17
+ labelWidth: '@',
18
+ minDate: '=',
19
+ maxDate: '=',
20
+ hideHover: '=',
21
+ time: '=',
22
+ noMargin: '@',
23
+ color: '@',
24
+ endDate: '=',
25
+ startDate: '=',
26
+ isDisabled: '=',
27
+ help: '@',
28
+ isInline: '=',
29
+ onChange: '&?'
30
+ },
31
+ link: function (scope, element) {
32
+ // ------------------ Init default values ------------------
33
+ scope.selectStart = true;
34
+ scope.popupText = gettextCatalog.getString("Select start date", null, "Nice");
35
+
36
+ scope.hours = [
37
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
38
+ ];
39
+
40
+ scope.minutes = [
41
+ 0, 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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59
42
+ ];
43
+
44
+
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);
48
+
49
+
50
+ // ------------------ Look for model changes ------------------
51
+ scope.$watch("startDate", function (value, valueOld) {
52
+ bootstrap();
53
+ });
54
+
55
+ scope.$watch("endDate", function (value, valueOld) {
56
+ bootstrap();
57
+ });
58
+
59
+ scope.$watch("minDate", function (value, valueOld) {
60
+ bootstrap();
61
+ });
62
+
63
+ scope.$watch("maxDate", function (value, valueOld) {
64
+ bootstrap();
65
+ });
66
+
67
+
68
+ // ------------------ Bootstrap calendar ------------------
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
+ 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
+ }
92
+
93
+ scope.month = angular.copy(moment(scope.startDate));
94
+ var start = angular.copy(moment(scope.startDate));
95
+ _removeTimeWithDate(start.date(0));
96
+ _buildMonth(scope, start, scope.month);
97
+ }
98
+
99
+ bootstrap();
100
+
101
+
102
+ // ------------------ Day was selected ------------------
103
+ scope.select = function (day) {
104
+ if (!day.isDisabled) {
105
+ var selectedDate = angular.copy(day.date);
106
+
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
+ }
117
+
118
+ // Set start date
119
+ scope.startDate = selectedDate;
120
+ scope.selectStart = false;
121
+ scope.popupText = gettextCatalog.getString("Select end date", null, "Nice");
122
+ scope.formCalendar.$setDirty();
123
+ scope.displayStartChange();
124
+
125
+ // If start date is after end date
126
+ if (scope.startDate.isAfter(scope.endDate)) {
127
+ scope.endDate = angular.copy(scope.startDate);
128
+ }
129
+ } else {
130
+ if (!scope.time) {
131
+ selectedDate.hours(23);
132
+ selectedDate.minutes(59);
133
+ selectedDate.seconds(59);
134
+ selectedDate.millisecond(999);
135
+ } else {
136
+ selectedDate.hours(scope.endDateHour);
137
+ selectedDate.minutes(scope.endDateMinute);
138
+ }
139
+
140
+ // Set end date
141
+ scope.endDate = selectedDate;
142
+ scope.selectStart = true;
143
+ scope.popupText = gettextCatalog.getString("Select start date", null, "Nice");
144
+ scope.formCalendar.$setDirty();
145
+ scope.displayEndChange();
146
+
147
+ // If end date is before start date
148
+ if (scope.endDate.isBefore(scope.startDate)) {
149
+ scope.startDate = angular.copy(scope.endDate);
150
+ }
151
+ }
152
+
153
+ if (scope.onChange) scope.onChange({ model: { startDate: scope.startDate, endDate: scope.endDate }, element: element });
154
+ }
155
+ };
156
+
157
+
158
+ // ------------------ Display date changes ------------------
159
+ scope.displayStartChange = function () {
160
+ scope.startTimeClass = "change";
161
+ $timeout(function () {
162
+ scope.startTimeClass = "";
163
+ }, 1000);
164
+ };
165
+
166
+ scope.displayEndChange = function () {
167
+ scope.endTimeClass = "change";
168
+ $timeout(function () {
169
+ scope.endTimeClass = "";
170
+ }, 1000);
171
+ };
172
+
173
+
174
+ // ------------------ Time changes ------------------
175
+ scope.startHourChange = function (value) {
176
+ scope.startDateHour = value;
177
+ scope.startDate = moment(scope.startDate).hours(scope.startDateHour);
178
+ scope.formCalendar.$setDirty();
179
+ scope.displayStartChange();
180
+ scope.handleUpdate();
181
+ };
182
+
183
+
184
+ scope.startMinuteChange = function (value) {
185
+ scope.startDateMinute = value;
186
+ scope.startDate = moment(scope.startDate).minutes(scope.startDateMinute);
187
+ scope.formCalendar.$setDirty();
188
+ scope.displayStartChange();
189
+ scope.handleUpdate();
190
+ };
191
+
192
+
193
+ scope.endHourChange = function (value) {
194
+ scope.endDateHour = value;
195
+ scope.endDate = moment(scope.endDate).hours(scope.endDateHour);
196
+ scope.formCalendar.$setDirty();
197
+ scope.displayEndChange();
198
+ scope.handleUpdate();
199
+ };
200
+
201
+
202
+ scope.endMinuteChange = function (value) {
203
+ scope.endDateMinute = value;
204
+ scope.endDate = moment(scope.endDate).minutes(scope.endDateMinute);
205
+ scope.formCalendar.$setDirty();
206
+ scope.displayEndChange();
207
+ scope.handleUpdate();
208
+ };
209
+
210
+
211
+ scope.handleUpdate = function () {
212
+ if (scope.onChange) scope.onChange({ model: { startDate: scope.startDate, endDate: scope.endDate }, element: element });
213
+ };
214
+
215
+
216
+ // ------------------ Go to next month ------------------
217
+ scope.next = function () {
218
+ var next = angular.copy(scope.month);
219
+ _removeTimeWithDate(next.month(next.month() + 1).date(0));
220
+ scope.month.month(scope.month.month() + 1);
221
+ _buildMonth(scope, next, scope.month);
222
+ };
223
+
224
+
225
+ // ------------------ Go to previous month ------------------
226
+ scope.previous = function () {
227
+ var previous = angular.copy(scope.month);
228
+ _removeTimeWithDate(previous.month(previous.month() - 1).date(0));
229
+ scope.month.month(scope.month.month() - 1);
230
+ _buildMonth(scope, previous, scope.month);
231
+ };
232
+
233
+
234
+ // ------------------ Check if dates are equal without time ------------------
235
+ scope.isSameDay = function (date1, date2) {
236
+ var d1 = _removeTime(angular.copy(date1));
237
+ var d2 = _removeTime(angular.copy(date2));
238
+ return d1.isSame(d2);
239
+ };
240
+
241
+
242
+ // ------------------ Check if date is between start and end date ------------------
243
+ scope.isBetweenRange = function (date) {
244
+ return (date.isBefore(moment(scope.endDate)) && date.isAfter(moment(scope.startDate)));
245
+ };
246
+
247
+
248
+ // ------------------ Format date ------------------
249
+ scope.formatDate = function (date) {
250
+ if (scope.time) return moment(date).format('D.M.YYYY • H:mm');
251
+ else return moment(date).format('D.M.YYYY');
252
+ };
253
+
254
+
255
+ // ------------------ Lighten color by 20% ------------------
256
+ scope.lighten = function (col) {
257
+ var amt = 20;
258
+ var usePound = false;
259
+
260
+ if (col[0] == "#") {
261
+ col = col.slice(1);
262
+ usePound = true;
263
+ }
264
+
265
+ var num = parseInt(col, 16);
266
+ var r = (num >> 16) + amt;
267
+
268
+ if (r > 255) r = 255;
269
+ else if (r < 0) r = 0;
270
+
271
+ var b = ((num >> 8) & 0x00FF) + amt;
272
+ if (b > 255) b = 255;
273
+ else if (b < 0) b = 0;
274
+
275
+ var g = (num & 0x0000FF) + amt;
276
+ if (g > 255) g = 255;
277
+ else if (g < 0) g = 0;
278
+
279
+ return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
280
+ };
281
+
282
+
283
+ // ------------------ Remove time from date ------------------
284
+ function _removeTime(date) {
285
+ return moment(date).hour(0).minute(0).second(0).millisecond(0);
286
+ }
287
+
288
+ function _removeTimeWithDate(date) {
289
+ return date.day(0).hour(0).minute(0).second(0).millisecond(0);
290
+ }
291
+
292
+
293
+
294
+ // ------------------ Build month ------------------
295
+ function _buildMonth(scope, start, month) {
296
+ scope.weeks = [];
297
+ var done = false, date = start.clone().startOf('week').isoWeekday(1), monthIndex = date.month(), count = 0;
298
+ date.add(1, "w");
299
+ while (!done) {
300
+ scope.weeks.push({ days: _buildWeek(date.clone(), month) });
301
+ date.add(1, "w");
302
+ done = count++ > 2 && monthIndex !== date.month();
303
+ monthIndex = date.month();
304
+ }
305
+ }
306
+
307
+
308
+ // ------------------ Build week ------------------
309
+ function _buildWeek(date, month) {
310
+ var days = [];
311
+ for (var i = 0; i < 7; i++) {
312
+ var day = {
313
+ name: date.format("dd"),
314
+ number: date.date(),
315
+ isCurrentMonth: date.month() === month.month(),
316
+ isToday: date.isSame(new Date(), "day"),
317
+ isWeekday: date.weekday() == 0 || date.weekday() == 6,
318
+ date: date
319
+ };
320
+
321
+ if (scope.minDate) day.isDisabled = date.isBefore(moment(scope.minDate));
322
+ if (scope.maxDate) day.isDisabled = date.isAfter(moment(scope.maxDate));
323
+ if (scope.minDate && scope.maxDate) day.isDisabled = !date.isBetween(moment(scope.minDate), moment(scope.maxDate));
324
+
325
+ days.push(day);
326
+ date = date.clone();
327
+ date.add(1, "d");
328
+ }
329
+
330
+ return days;
331
+ }
332
+ }
333
+ };
334
+ });