@osimatic/helpers-js 1.1.50 → 1.1.51

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 (2) hide show
  1. package/form_date.js +38 -38
  2. package/package.json +1 -1
package/form_date.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // input period de type : Du <input type="date" name="start_date" /> au <input type="date" name="end_date" />
2
2
  class InputPeriod {
3
3
 
4
- static addLinks(form, timeZone="Europe/Paris") {
4
+ static addLinks(form) {
5
5
  let divParent = form.find('input[type="date"][data-add_period_select_links]').parent();
6
6
  if (divParent.hasClass('input-group')) {
7
7
  divParent = divParent.parent();
@@ -16,98 +16,98 @@ class InputPeriod {
16
16
  +'<a href="#" class="period_select_current_year">Cette année</a>'
17
17
  +'</div>'
18
18
  );
19
- this.init(form, timeZone);
19
+ this.init(form);
20
20
  }
21
21
 
22
- static init(form, timeZone="Europe/Paris") {
22
+ static init(form) {
23
23
  let link;
24
24
  //console.log(form.find('a.period_select_current_week'));
25
25
 
26
26
  if ((link = form.find('a.period_select_today')).length) {
27
- link.click(function() { InputPeriod.selectToday($(this), timeZone); return false; });
27
+ link.click(function() { InputPeriod.selectToday($(this)); return false; });
28
28
  }
29
29
  if ((link = form.find('a.period_select_yesterday')).length) {
30
- link.click(function() { InputPeriod.selectPreviousDay($(this), 1, timeZone); return false; });
30
+ link.click(function() { InputPeriod.selectPreviousDay($(this), 1); return false; });
31
31
  }
32
32
  if ((link = form.find('a.period_select_tomorrow')).length) {
33
- link.click(function() { InputPeriod.selectFollowingDay($(this), 1, timeZone); return false; });
33
+ link.click(function() { InputPeriod.selectFollowingDay($(this), 1); return false; });
34
34
  }
35
35
  if ((link = form.find('a.period_select_current_week')).length) {
36
- link.click(function() { InputPeriod.selectCurrentWeek($(this), timeZone); return false; });
36
+ link.click(function() { InputPeriod.selectCurrentWeek($(this)); return false; });
37
37
  }
38
38
  if ((link = form.find('a.period_select_last_week')).length) {
39
- link.click(function() { InputPeriod.selectPreviousWeek($(this), 1, timeZone); return false; });
39
+ link.click(function() { InputPeriod.selectPreviousWeek($(this), 1); return false; });
40
40
  }
41
41
  if ((link = form.find('a.period_select_current_month')).length) {
42
- link.click(function() { InputPeriod.selectCurrentMonth($(this), timeZone); return false; });
42
+ link.click(function() { InputPeriod.selectCurrentMonth($(this)); return false; });
43
43
  }
44
44
  if ((link = form.find('a.period_select_last_month')).length) {
45
- link.click(function() { InputPeriod.selectPreviousMonth($(this), 1, timeZone); return false; });
45
+ link.click(function() { InputPeriod.selectPreviousMonth($(this), 1); return false; });
46
46
  }
47
47
  if ((link = form.find('a.period_select_current_year')).length) {
48
- link.click(function() { InputPeriod.selectCurrentYear($(this), timeZone); return false; });
48
+ link.click(function() { InputPeriod.selectCurrentYear($(this)); return false; });
49
49
  }
50
50
  if ((link = form.find('a.period_select_last_year')).length) {
51
- link.click(function() { InputPeriod.selectCurrentYear($(this), 1, timeZone); return false; });
51
+ link.click(function() { InputPeriod.selectPreviousYear($(this), 1); return false; });
52
52
  }
53
53
  }
54
54
 
55
55
 
56
- static selectToday(link, timeZone="Europe/Paris") {
56
+ static selectToday(link) {
57
57
  let date = new Date();
58
- this.selectPeriod(link, date, date, timeZone);
58
+ this.selectPeriod(link, date, date);
59
59
  }
60
60
 
61
- static selectPreviousDay(lien, nbDays, timeZone="Europe/Paris") {
62
- this.selectFollowingDay(lien, -nbDays, timeZone);
61
+ static selectPreviousDay(lien, nbDays) {
62
+ this.selectFollowingDay(lien, -nbDays);
63
63
  }
64
- static selectFollowingDay(lien, nbDays, timeZone="Europe/Paris") {
64
+ static selectFollowingDay(lien, nbDays) {
65
65
  let date = new Date();
66
66
  date.setDate(date.getDate() + nbDays);
67
- this.selectPeriod(lien, date, date, timeZone);
67
+ this.selectPeriod(lien, date, date);
68
68
  }
69
69
 
70
- static selectCurrentWeek(lien, timeZone="Europe/Paris") {
70
+ static selectCurrentWeek(lien) {
71
71
  let date = new Date();
72
72
  this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
73
73
  }
74
- static selectPreviousWeek(lien, nbWeeks, timeZone="Europe/Paris") {
75
- this.selectFollowingWeek(lien, -nbWeeks, timeZone);
74
+ static selectPreviousWeek(lien, nbWeeks) {
75
+ this.selectFollowingWeek(lien, -nbWeeks);
76
76
  }
77
- static selectFollowingWeek(lien, nbWeeks, timeZone="Europe/Paris") {
77
+ static selectFollowingWeek(lien, nbWeeks) {
78
78
  let date = new Date();
79
79
  date.setDate(date.getDate() + (7*nbWeeks));
80
- this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date), timeZone);
80
+ this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
81
81
  }
82
82
 
83
- static selectCurrentMonth(lien, timeZone="Europe/Paris") {
83
+ static selectCurrentMonth(lien) {
84
84
  let date = new Date();
85
- this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date), timeZone);
85
+ this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
86
86
  }
87
- static selectPreviousMonth(lien, nbMonths, timeZone="Europe/Paris") {
88
- this.selectFollowingMonth(lien, -nbMonths, timeZone);
87
+ static selectPreviousMonth(lien, nbMonths) {
88
+ this.selectFollowingMonth(lien, -nbMonths);
89
89
  }
90
- static selectFollowingMonth(lien, nbMonths, timeZone="Europe/Paris") {
90
+ static selectFollowingMonth(lien, nbMonths) {
91
91
  let date = new Date();
92
92
  date.setDate(1);
93
93
  date.setMonth(date.getMonth() + nbMonths);
94
- this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date), timeZone);
94
+ this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
95
95
  }
96
96
 
97
- static selectCurrentYear(lien, timeZone="Europe/Paris") {
98
- this.selectFollowingYear(lien, 0, timeZone);
97
+ static selectCurrentYear(lien) {
98
+ this.selectFollowingYear(lien, 0);
99
99
  }
100
- static selectPreviousYear(lien, nbAnneesMoins, timeZone="Europe/Paris") {
101
- this.selectFollowingYear(lien, -nbAnneesMoins, timeZone);
100
+ static selectPreviousYear(lien, nbAnneesMoins) {
101
+ this.selectFollowingYear(lien, -nbAnneesMoins);
102
102
  }
103
- static selectFollowingYear(lien, nbAnneesMoins, timeZone="Europe/Paris") {
103
+ static selectFollowingYear(lien, nbAnneesMoins) {
104
104
  let date = new Date();
105
105
  date.setFullYear(date.getFullYear() + nbAnneesMoins);
106
- this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date), timeZone);
106
+ this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
107
107
  }
108
108
 
109
109
 
110
- static selectPeriod(link, startDate, endDate, timeZone="Europe/Paris") {
110
+ static selectPeriod(link, startDate, endDate) {
111
111
  let inputPeriodStart = link.parent().parent().find('input[type="date"]').filter('[name="date_start"], [name="start_date"], [name="start_period"], [name="period_start_date"]');
112
112
  let inputPeriodEnd = link.parent().parent().find('input[type="date"]').filter('[name="date_end"], [name="end_date"], [name="end_period"], [name="period_end_date"]');
113
113
  if (inputPeriodStart.length === 0 || inputPeriodEnd.length === 0) {
@@ -115,8 +115,8 @@ class InputPeriod {
115
115
  return;
116
116
  }
117
117
 
118
- inputPeriodStart.val(DateTime.getDateForInputDate(startDate, timeZone));
119
- inputPeriodEnd.val(DateTime.getDateForInputDate(endDate, timeZone));
118
+ inputPeriodStart.val(DateTime.getDateForInputDate(startDate));
119
+ inputPeriodEnd.val(DateTime.getDateForInputDate(endDate));
120
120
  }
121
121
 
122
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.50",
3
+ "version": "1.1.51",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"