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.
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "editor.formatOnSave": true,
3
- "html.format.wrapLineLength": 0
3
+ "html.format.wrapLineLength": 0,
4
+ "prettier.printWidth": 0
4
5
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.4.3 (28.4.2022)
4
+
5
+ - worked on nice calendar time prop,
6
+ - added nice calendar demo
7
+
3
8
  ## v1.4.2 (22.4.2022)
4
9
 
5
10
  - created nice-tooltip component,
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Nice elements v1.4.2
1
+ # Nice elements v1.4.3
2
2
 
3
3
  Nice elements is an AngularJS v1.5.8 module that contains nice form elements like inputs, choice fields, search, toggle, dropdown, etc.
4
4
 
package/bower.json CHANGED
@@ -1,10 +1,18 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.4.2",
4
- "authors": ["Klemen Kastelic <klemen@olaii.com>"],
3
+ "version": "1.4.3",
4
+ "authors": [
5
+ "Klemen Kastelic <klemen@olaii.com>"
6
+ ],
5
7
  "description": "Nice elements",
6
8
  "keywords": [],
7
9
  "license": "MIT",
8
10
  "main": "dist/nice.js",
9
- "ignore": ["**/.*", "node_modules", "bower_components", "test", "tests"]
11
+ "ignore": [
12
+ "**/.*",
13
+ "node_modules",
14
+ "bower_components",
15
+ "test",
16
+ "tests"
17
+ ]
10
18
  }
package/dist/nice.js CHANGED
@@ -75,7 +75,7 @@ angular.module('niceElements')
75
75
  * # niceCalendar
76
76
  */
77
77
  angular.module('niceElements')
78
- .directive("niceCalendar", function($timeout, gettextCatalog) {
78
+ .directive("niceCalendar", function ($timeout, gettextCatalog) {
79
79
  return {
80
80
  restrict: "E",
81
81
  templateUrl: "src/components/nice-calendar/nice-calendar.html",
@@ -86,7 +86,7 @@ angular.module('niceElements')
86
86
  minDate: '=',
87
87
  maxDate: '=',
88
88
  hideHover: '=',
89
- time: '@',
89
+ time: '=',
90
90
  noMargin: '@',
91
91
  color: '@',
92
92
  endDate: '=',
@@ -96,7 +96,7 @@ angular.module('niceElements')
96
96
  isInline: '=',
97
97
  onChange: '&?'
98
98
  },
99
- link: function(scope, element) {
99
+ link: function (scope, element) {
100
100
  // ------------------ Init default values ------------------
101
101
  scope.selectStart = true;
102
102
  scope.popupText = gettextCatalog.getString("Select start date", null, "Nice");
@@ -111,37 +111,52 @@ angular.module('niceElements')
111
111
 
112
112
 
113
113
  // ------------------ Check if attributes are set ------------------
114
- if(!scope.startDate) scope.startDate = moment().minutes(0).second(0).millisecond(0);
115
- if(!scope.endDate) scope.endDate = moment().minutes(0).second(0).millisecond(0);
114
+ if (!scope.startDate) scope.startDate = moment().minutes(0).second(0).millisecond(0);
115
+ if (!scope.endDate) scope.endDate = moment().minutes(0).second(0).millisecond(0);
116
116
 
117
117
 
118
118
  // ------------------ Look for model changes ------------------
119
- scope.$watch("startDate", function(value, valueOld){
119
+ scope.$watch("startDate", function (value, valueOld) {
120
120
  bootstrap();
121
121
  });
122
122
 
123
- scope.$watch("endDate", function(value, valueOld){
123
+ scope.$watch("endDate", function (value, valueOld) {
124
124
  bootstrap();
125
125
  });
126
126
 
127
- scope.$watch("minDate", function(value, valueOld){
127
+ scope.$watch("minDate", function (value, valueOld) {
128
128
  bootstrap();
129
129
  });
130
130
 
131
- scope.$watch("maxDate", function(value, valueOld){
131
+ scope.$watch("maxDate", function (value, valueOld) {
132
132
  bootstrap();
133
133
  });
134
134
 
135
135
 
136
136
  // ------------------ Bootstrap calendar ------------------
137
137
  function bootstrap() {
138
- //scope.startDate = moment(scope.startDate.second(0).millisecond(0));
139
- //scope.endDate = moment(scope.endDate.second(0).millisecond(0));
140
-
141
- scope.startDateHour = moment(scope.startDate).hours();
142
- scope.startDateMinute = moment(scope.startDate).minutes();
143
- scope.endDateHour = moment(scope.endDate).hours();
144
- scope.endDateMinute = moment(scope.endDate).minutes();
138
+ // scope.startDate = moment(scope.startDate.second(0).millisecond(0));
139
+ // scope.endDate = moment(scope.endDate.second(0).millisecond(0));
140
+
141
+ if (!scope.time) {
142
+ scope.startDateHour = 0;
143
+ scope.startDateMinute = 0;
144
+ scope.startDate.hours(0);
145
+ scope.startDate.minutes(0);
146
+ scope.startDate.seconds(0);
147
+ scope.startDate.millisecond(0);
148
+ scope.endDateHour = 0;
149
+ scope.endDateMinut = 0;
150
+ scope.endDate.hours(23);
151
+ scope.endDate.minutes(59);
152
+ scope.endDate.seconds(59);
153
+ scope.endDate.millisecond(999);
154
+ } else {
155
+ scope.startDateHour = moment(scope.startDate).hours();
156
+ scope.startDateMinute = moment(scope.startDate).minutes();
157
+ scope.endDateHour = moment(scope.endDate).hours();
158
+ scope.endDateMinute = moment(scope.endDate).minutes();
159
+ }
145
160
 
146
161
  scope.month = angular.copy(moment(scope.startDate));
147
162
  var start = angular.copy(moment(scope.startDate));
@@ -153,13 +168,20 @@ angular.module('niceElements')
153
168
 
154
169
 
155
170
  // ------------------ Day was selected ------------------
156
- scope.select = function(day) {
157
- if(!day.isDisabled){
171
+ scope.select = function (day) {
172
+ if (!day.isDisabled) {
158
173
  var selectedDate = angular.copy(day.date);
159
174
 
160
- if(scope.selectStart){
161
- selectedDate.hours(scope.startDateHour);
162
- selectedDate.minutes(scope.startDateMinute);
175
+ if (scope.selectStart) {
176
+ if (!scope.time) {
177
+ selectedDate.hours(0);
178
+ selectedDate.minutes(0);
179
+ selectedDate.seconds(0);
180
+ selectedDate.millisecond(0);
181
+ } else {
182
+ selectedDate.hours(scope.startDateHour);
183
+ selectedDate.minutes(scope.startDateMinute);
184
+ }
163
185
 
164
186
  // Set start date
165
187
  scope.startDate = selectedDate;
@@ -169,12 +191,22 @@ angular.module('niceElements')
169
191
  scope.displayStartChange();
170
192
 
171
193
  // If start date is after end date
172
- if(scope.startDate.isAfter(scope.endDate)){
194
+ if (scope.startDate.isAfter(scope.endDate)) {
173
195
  scope.endDate = angular.copy(scope.startDate);
174
196
  }
175
197
  } else {
176
- selectedDate.hours(scope.endDateHour);
177
- selectedDate.minutes(scope.endDateMinute);
198
+
199
+
200
+ if (!scope.time) {
201
+ selectedDate.hours(23);
202
+ selectedDate.minutes(59);
203
+ selectedDate.seconds(59);
204
+ selectedDate.millisecond(999);
205
+ } else {
206
+ selectedDate.hours(scope.endDateHour);
207
+ selectedDate.minutes(scope.endDateMinute);
208
+ }
209
+
178
210
 
179
211
  // Set end date
180
212
  scope.endDate = selectedDate;
@@ -184,34 +216,34 @@ angular.module('niceElements')
184
216
  scope.displayEndChange();
185
217
 
186
218
  // If end date is before start date
187
- if(scope.endDate.isBefore(scope.startDate)){
219
+ if (scope.endDate.isBefore(scope.startDate)) {
188
220
  scope.startDate = angular.copy(scope.endDate);
189
221
  }
190
222
  }
191
223
 
192
- if (scope.onChange) scope.onChange({ model: {startDate: scope.startDate, endDate: scope.endDate}, element: element });
224
+ if (scope.onChange) scope.onChange({ model: { startDate: scope.startDate, endDate: scope.endDate }, element: element });
193
225
  }
194
226
  };
195
227
 
196
228
 
197
229
  // ------------------ Display date changes ------------------
198
- scope.displayStartChange = function(){
230
+ scope.displayStartChange = function () {
199
231
  scope.startTimeClass = "change";
200
- $timeout(function(){
232
+ $timeout(function () {
201
233
  scope.startTimeClass = "";
202
234
  }, 1000);
203
235
  };
204
236
 
205
- scope.displayEndChange = function(){
237
+ scope.displayEndChange = function () {
206
238
  scope.endTimeClass = "change";
207
- $timeout(function(){
239
+ $timeout(function () {
208
240
  scope.endTimeClass = "";
209
241
  }, 1000);
210
242
  };
211
243
 
212
244
 
213
245
  // ------------------ Time changes ------------------
214
- scope.startHourChange = function(value){
246
+ scope.startHourChange = function (value) {
215
247
  scope.startDateHour = value;
216
248
  scope.startDate = moment(scope.startDate).hours(scope.startDateHour);
217
249
  scope.formCalendar.$setDirty();
@@ -219,7 +251,7 @@ angular.module('niceElements')
219
251
  };
220
252
 
221
253
 
222
- scope.startMinuteChange = function(value) {
254
+ scope.startMinuteChange = function (value) {
223
255
  scope.startDateMinute = value;
224
256
  scope.startDate = moment(scope.startDate).minutes(scope.startDateMinute);
225
257
  scope.formCalendar.$setDirty();
@@ -227,7 +259,7 @@ angular.module('niceElements')
227
259
  };
228
260
 
229
261
 
230
- scope.endHourChange = function(value){
262
+ scope.endHourChange = function (value) {
231
263
  scope.endDateHour = value;
232
264
  scope.endDate = moment(scope.endDate).hours(scope.endDateHour);
233
265
  scope.formCalendar.$setDirty();
@@ -235,7 +267,7 @@ angular.module('niceElements')
235
267
  };
236
268
 
237
269
 
238
- scope.endMinuteChange = function(value) {
270
+ scope.endMinuteChange = function (value) {
239
271
  scope.endDateMinute = value;
240
272
  scope.endDate = moment(scope.endDate).minutes(scope.endDateMinute);
241
273
  scope.formCalendar.$setDirty();
@@ -244,25 +276,25 @@ angular.module('niceElements')
244
276
 
245
277
 
246
278
  // ------------------ Go to next month ------------------
247
- scope.next = function() {
279
+ scope.next = function () {
248
280
  var next = angular.copy(scope.month);
249
- _removeTimeWithDate(next.month(next.month()+1).date(0));
250
- scope.month.month(scope.month.month()+1);
281
+ _removeTimeWithDate(next.month(next.month() + 1).date(0));
282
+ scope.month.month(scope.month.month() + 1);
251
283
  _buildMonth(scope, next, scope.month);
252
284
  };
253
285
 
254
286
 
255
287
  // ------------------ Go to previous month ------------------
256
- scope.previous = function() {
288
+ scope.previous = function () {
257
289
  var previous = angular.copy(scope.month);
258
- _removeTimeWithDate(previous.month(previous.month()-1).date(0));
259
- scope.month.month(scope.month.month()-1);
290
+ _removeTimeWithDate(previous.month(previous.month() - 1).date(0));
291
+ scope.month.month(scope.month.month() - 1);
260
292
  _buildMonth(scope, previous, scope.month);
261
293
  };
262
294
 
263
295
 
264
296
  // ------------------ Check if dates are equal without time ------------------
265
- scope.isSameDay = function(date1, date2){
297
+ scope.isSameDay = function (date1, date2) {
266
298
  var d1 = _removeTime(angular.copy(date1));
267
299
  var d2 = _removeTime(angular.copy(date2));
268
300
  return d1.isSame(d2);
@@ -270,20 +302,20 @@ angular.module('niceElements')
270
302
 
271
303
 
272
304
  // ------------------ Check if date is between start and end date ------------------
273
- scope.isBetweenRange = function(date){
305
+ scope.isBetweenRange = function (date) {
274
306
  return (date.isBefore(moment(scope.endDate)) && date.isAfter(moment(scope.startDate)));
275
307
  };
276
308
 
277
309
 
278
310
  // ------------------ Format date ------------------
279
- scope.formatDate = function(date){
280
- if(scope.time) return moment(date).format('D.M.YYYY • H:mm');
311
+ scope.formatDate = function (date) {
312
+ if (scope.time) return moment(date).format('D.M.YYYY • H:mm');
281
313
  else return moment(date).format('D.M.YYYY');
282
314
  };
283
315
 
284
316
 
285
317
  // ------------------ Lighten color by 20% ------------------
286
- scope.lighten = function(col){
318
+ scope.lighten = function (col) {
287
319
  var amt = 20;
288
320
  var usePound = false;
289
321
 
@@ -292,21 +324,21 @@ angular.module('niceElements')
292
324
  usePound = true;
293
325
  }
294
326
 
295
- var num = parseInt(col,16);
327
+ var num = parseInt(col, 16);
296
328
  var r = (num >> 16) + amt;
297
329
 
298
330
  if (r > 255) r = 255;
299
- else if (r < 0) r = 0;
331
+ else if (r < 0) r = 0;
300
332
 
301
333
  var b = ((num >> 8) & 0x00FF) + amt;
302
334
  if (b > 255) b = 255;
303
- else if (b < 0) b = 0;
335
+ else if (b < 0) b = 0;
304
336
 
305
337
  var g = (num & 0x0000FF) + amt;
306
338
  if (g > 255) g = 255;
307
339
  else if (g < 0) g = 0;
308
340
 
309
- return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16);
341
+ return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
310
342
  };
311
343
 
312
344
 
@@ -348,9 +380,9 @@ angular.module('niceElements')
348
380
  date: date
349
381
  };
350
382
 
351
- if(scope.minDate) day.isDisabled = date.isBefore(moment(scope.minDate));
352
- if(scope.maxDate) day.isDisabled = date.isAfter(moment(scope.maxDate));
353
- if(scope.minDate && scope.maxDate) day.isDisabled = !date.isBetween(moment(scope.minDate), moment(scope.maxDate));
383
+ if (scope.minDate) day.isDisabled = date.isBefore(moment(scope.minDate));
384
+ if (scope.maxDate) day.isDisabled = date.isAfter(moment(scope.maxDate));
385
+ if (scope.minDate && scope.maxDate) day.isDisabled = !date.isBetween(moment(scope.minDate), moment(scope.maxDate));
354
386
 
355
387
  days.push(day);
356
388
  date = date.clone();
@@ -361,7 +393,7 @@ angular.module('niceElements')
361
393
  }
362
394
  }
363
395
  };
364
- });
396
+ });
365
397
 
366
398
  'use strict';
367
399
 
@@ -4884,6 +4916,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
4884
4916
  "<div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]\">\n" +
4885
4917
  "<div class=\"disabled-shield\" ng-if=\"isDisabled\"></div>\n" +
4886
4918
  "<div class=\"nice-calendar-wrapper\">\n" +
4919
+ "<div class=\"nice-calendar-weeks\">\n" +
4887
4920
  "<div class=\"header\">\n" +
4888
4921
  "<i class=\"fa fa-angle-left\" ng-click=\"previous()\" title=\"{{ 'Previous month' | translate:'Nice' }}\"></i>\n" +
4889
4922
  "<span title=\"{{ month.format('M.YYYY' )}}\">{{ month.format(\"MMMM, YYYY\" )}}</span>\n" +
@@ -4900,25 +4933,25 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
4900
4933
  "</div>\n" +
4901
4934
  "<div class=\"week\" ng-repeat=\"week in weeks\">\n" +
4902
4935
  "<span class=\"day\" title=\"{{ day.date.format('D.M.YYYY') }}\" ng-class=\"{\n" +
4903
- " today: day.isToday,\n" +
4904
- " 'different-month': !day.isCurrentMonth,\n" +
4905
- " 'start-selected': isSameDay(day.date, startDate),\n" +
4906
- " 'end-selected': isSameDay(day.date, endDate),\n" +
4907
- " 'selected': isBetweenRange(day.date),\n" +
4908
- " 'selecting-start': selectStart,\n" +
4909
- " 'selecting-end': !selectStart,\n" +
4910
- " 'weekend': day.isWeekday,\n" +
4911
- " 'disabled': day.isDisabled\n" +
4912
- " }\" ng-style=\"\n" +
4913
- " (color && isBetweenRange(day.date)) && {'background-color': lighten(color) } ||\n" +
4914
- " (color && isSameDay(day.date, startDate)) && {'background-color': color } ||\n" +
4915
- " (color && isSameDay(day.date, endDate)) && {'background-color': color }\n" +
4916
- " \" ng-click=\"select(day)\" ng-repeat=\"day in week.days\">\n" +
4936
+ " today: day.isToday,\n" +
4937
+ " 'different-month': !day.isCurrentMonth,\n" +
4938
+ " 'start-selected': isSameDay(day.date, startDate),\n" +
4939
+ " 'end-selected': isSameDay(day.date, endDate),\n" +
4940
+ " 'selected': isBetweenRange(day.date),\n" +
4941
+ " 'selecting-start': selectStart,\n" +
4942
+ " 'selecting-end': !selectStart,\n" +
4943
+ " 'weekend': day.isWeekday,\n" +
4944
+ " 'disabled': day.isDisabled\n" +
4945
+ " }\" ng-style=\"\n" +
4946
+ " (color && isBetweenRange(day.date)) && {'background-color': lighten(color) } ||\n" +
4947
+ " (color && isSameDay(day.date, startDate)) && {'background-color': color } ||\n" +
4948
+ " (color && isSameDay(day.date, endDate)) && {'background-color': color }\n" +
4949
+ " \" ng-click=\"select(day)\" ng-repeat=\"day in week.days\">\n" +
4917
4950
  "{{ day.number }}\n" +
4918
4951
  "<p class=\"popup\" ng-if=\"!hideHover\">{{ popupText }}</p>\n" +
4919
4952
  "</span>\n" +
4920
4953
  "</div>\n" +
4921
- "<div class=\"clearfix\"></div>\n" +
4954
+ "</div>\n" +
4922
4955
  "<div class=\"nice-calendar-time\" ng-if=\"time\">\n" +
4923
4956
  "<div class=\"time-picker\">\n" +
4924
4957
  "<select title=\"{{ 'Select start time' | translate:'Nice' }}\" class=\"time-picker-hour\" ng-model=\"startDateHour\" ng-change=\"startHourChange(startDateHour)\" ng-options=\"hour for hour in hours\">\n" +
@@ -4949,7 +4982,6 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
4949
4982
  "<label translate translate-context=\"Nice\">End</label>\n" +
4950
4983
  "<div ng-class=\"endTimeClass\">{{ formatDate(endDate) }}</div>\n" +
4951
4984
  "</div>\n" +
4952
- "<div class=\"clearfix\"></div>\n" +
4953
4985
  "</div>\n" +
4954
4986
  "</div>\n" +
4955
4987
  "</div>\n" +