@osimatic/helpers-js 1.0.21 → 1.0.24
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.
- package/.idea/helpers-js.iml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/changelog.txt +5 -0
- package/form_date.js +387 -0
- package/form_helper.js +16 -11
- package/index.js +3 -2
- package/media.js +13 -10
- package/number.js +0 -66
- package/package.json +1 -1
- package/todos/form_date.js +0 -262
- package/todos/graphiques.js +0 -281
- package/todos/jquery.js +0 -5
- package/todos/tree.js +0 -71
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/helpers-js.iml" filepath="$PROJECT_DIR$/.idea/helpers-js.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/changelog.txt
CHANGED
|
@@ -26,3 +26,8 @@ getValuesByKeyInArrayOfArrays(array, ...) -> array.getValuesByKeyInArrayOfArrays
|
|
|
26
26
|
hasGetUserMedia() -> non remplacé
|
|
27
27
|
|
|
28
28
|
paginationAsList(...) -> Pagination.paginate(...)
|
|
29
|
+
|
|
30
|
+
getDateObjectSelected(lien) -> getSelectedDate(lien.closest('.form-group')
|
|
31
|
+
selectFormDate(lien) -> setSelectedDate(lien.closest('.form-group')
|
|
32
|
+
majSelectPeriode() / majSelectCompare() -> updatePeriodSelect(form)
|
|
33
|
+
|
package/form_date.js
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
const {Object} = require('./index');
|
|
2
|
+
|
|
3
|
+
class FormDate {
|
|
4
|
+
static initForm(form) {
|
|
5
|
+
// ---------- Choix période (new) ----------
|
|
6
|
+
|
|
7
|
+
// Formulaire de sélection de période
|
|
8
|
+
if (form.find('select.periode').length > 0) {
|
|
9
|
+
form.find('select.periode').change(function() {
|
|
10
|
+
FormDate.updatePeriodSelect($(this).closest('form'));
|
|
11
|
+
});
|
|
12
|
+
FormDate.updatePeriodSelect($(this).closest('form'));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// ---------- Choix période (old) ----------
|
|
17
|
+
|
|
18
|
+
if (form.find('select.day').length > 0 && form.find('select.month').length > 0 && form.find('select.year').length > 0) {
|
|
19
|
+
form.find('select.year').after(
|
|
20
|
+
'<br/>'+
|
|
21
|
+
'<p class="select_date_fastly">'+
|
|
22
|
+
' <a href="#" class="lien_form_today">Auj.</a> - '+
|
|
23
|
+
' <a href="#" class="lien_form_yesterday">Hier</a> - '+
|
|
24
|
+
' <a href="#" class="lien_form_current_month">Ce mois-ci</a> - '+
|
|
25
|
+
' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
|
|
26
|
+
' <a href="#" class="lien_form_current_year">Cette année</a>'+
|
|
27
|
+
' - '+
|
|
28
|
+
' <a href="#" class="lien_form_date_prev_day">Jour précédent</a>'+
|
|
29
|
+
' - '+
|
|
30
|
+
' <a href="#" class="lien_form_date_next_day">Jour suivant</a>'+
|
|
31
|
+
'</p>'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
else if (form.find('select.month').length > 0 && form.find('select.year').length > 0) {
|
|
35
|
+
form.find('select.year').after(
|
|
36
|
+
'<br/>'+
|
|
37
|
+
'<p class="select_date_fastly">'+
|
|
38
|
+
' <a href="#" class="lien_form_current_month">Ce mois-ci</a> - '+
|
|
39
|
+
' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
|
|
40
|
+
' <a href="#" class="lien_form_current_year">Cette année</a>'+
|
|
41
|
+
'</p>'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (form.find('select.dayCompare').length > 0 && form.find('select.monthCompare').length > 0 && form.find('select.yearCompare').length > 0) {
|
|
46
|
+
form.find('select.yearCompare').after(
|
|
47
|
+
'<br/>'+
|
|
48
|
+
'<p class="select_date_fastly">'+
|
|
49
|
+
' <a href="#" class="lien_form_yesterday">Hier</a> - '+
|
|
50
|
+
' <a href="#" class="lien_form_day_moins_7">J-7</a> - '+
|
|
51
|
+
' <a href="#" class="lien_form_day_moins_8">J-8</a> - '+
|
|
52
|
+
' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
|
|
53
|
+
' <a href="#" class="lien_form_month_moins_2">Mois M-2</a> - '+
|
|
54
|
+
' <a href="#" class="lien_form_last_year">L\'année dernière</a>'+
|
|
55
|
+
'</p>'
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Lien de sélection de date
|
|
60
|
+
|
|
61
|
+
if (form.find('a.lien_form_today').length > 0) {
|
|
62
|
+
form.find('a.lien_form_today').click(function() {
|
|
63
|
+
FormDate.setTodaySelected($(this).closest('.form-group'));
|
|
64
|
+
return false;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (form.find('a.lien_form_yesterday').length > 0) {
|
|
68
|
+
form.find('a.lien_form_yesterday').click(function() {
|
|
69
|
+
FormDate.addNbDaysToToday($(this).closest('.form-group'), -1);
|
|
70
|
+
return false;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (form.find('a.lien_form_day_moins_7').length > 0) {
|
|
74
|
+
form.find('a.lien_form_day_moins_7').click(function() {
|
|
75
|
+
FormDate.addNbDaysToToday($(this).closest('.form-group'), -7);
|
|
76
|
+
return false;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (form.find('a.lien_form_day_moins_8').length > 0) {
|
|
80
|
+
form.find('a.lien_form_day_moins_8').click(function() {
|
|
81
|
+
FormDate.addNbDaysToToday($(this).closest('.form-group'), -8);
|
|
82
|
+
return false;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (form.find('a.lien_form_current_month').length > 0) {
|
|
87
|
+
form.find('a.lien_form_current_month').click(function() {
|
|
88
|
+
FormDate.setCurrentMonthSelected($(this).closest('.form-group'));
|
|
89
|
+
return false;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (form.find('a.lien_form_last_month').length > 0) {
|
|
93
|
+
form.find('a.lien_form_last_month').click(function() {
|
|
94
|
+
FormDate.addNbMonthsToToday($(this).closest('.form-group'), -1);
|
|
95
|
+
return false;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (form.find('a.lien_form_month_moins_2').length > 0) {
|
|
99
|
+
form.find('a.lien_form_month_moins_2').click(function() {
|
|
100
|
+
FormDate.addNbMonthsToToday($(this).closest('.form-group'), -2);
|
|
101
|
+
return false;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (form.find('a.lien_form_current_year').length > 0) {
|
|
106
|
+
form.find('a.lien_form_current_year').click(function() {
|
|
107
|
+
FormDate.setCurrentYearSelected($(this).closest('.form-group'));
|
|
108
|
+
return false;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (form.find('a.lien_form_last_year').length > 0) {
|
|
112
|
+
form.find('a.lien_form_last_year').click(function() {
|
|
113
|
+
FormDate.addNbYearsToToday($(this).closest('.form-group'), -1);
|
|
114
|
+
return false;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (form.find('a.lien_form_date_prev_day').length > 0) {
|
|
119
|
+
form.find('a.lien_form_date_prev_day').click(function() {
|
|
120
|
+
FormDate.addNbDaysToSelectedDate($(this).closest('.form-group'), -1);
|
|
121
|
+
return false;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (form.find('a.lien_form_date_next_day').length > 0) {
|
|
125
|
+
form.find('a.lien_form_date_next_day').click(function() {
|
|
126
|
+
FormDate.addNbDaysToSelectedDate($(this).closest('.form-group'), 1);
|
|
127
|
+
return false;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//if ($('form select[name=select_date_fastly]').length > 0) {
|
|
132
|
+
// $('form select[name=select_date_fastly]').change(function() {
|
|
133
|
+
// valueOptionSelected = $('form select[name=select_date_fastly] option:selected').attr('value');
|
|
134
|
+
// if (valueOptionSelected == 'today') {
|
|
135
|
+
// selectFormDateToday();
|
|
136
|
+
// }
|
|
137
|
+
// else if (valueOptionSelected == 'current_month') {
|
|
138
|
+
// selectFormDateCurrentMonth();
|
|
139
|
+
// }
|
|
140
|
+
// });
|
|
141
|
+
//}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
static updatePeriodSelect(form) {
|
|
145
|
+
function updateSelect(select) {
|
|
146
|
+
if (select.val() === 'perso') {
|
|
147
|
+
select.parent().parent().next().removeClass('hide');
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
select.parent().parent().next().addClass('hide');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let periodSelect = form.find('select.period');
|
|
155
|
+
if (periodSelect.length === 0) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
updateSelect(periodSelect);
|
|
160
|
+
|
|
161
|
+
let comparedPeriodSelect = form.find('select.compared_period');
|
|
162
|
+
if (comparedPeriodSelect.length === 0) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let listValues = [];
|
|
167
|
+
let valueDefault = null;
|
|
168
|
+
|
|
169
|
+
comparedPeriodSelect.find('option').attr('disabled', false);
|
|
170
|
+
|
|
171
|
+
let listePeriodeCompare = typeof listePeriodeCompare != 'undefined' ? listePeriodeCompare : {};
|
|
172
|
+
listePeriodeCompare.forEach(([idx, tabListPeriode]) => {
|
|
173
|
+
if (idx != 0) {
|
|
174
|
+
let listKeyPeriode = Object.entries(tabListPeriode['list']).map(([key, value]) => key);
|
|
175
|
+
if (listKeyPeriode.indexOf(periodSelect.val()) !== -1) {
|
|
176
|
+
listValues = listKeyPeriode;
|
|
177
|
+
valueDefault = listKeyPeriode[1];
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
comparedPeriodSelect.find('option[value="' + listKeyPeriode[0] + '"]').parent().children().attr('disabled', true);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
if (periodSelect.val() === 'perso') {
|
|
186
|
+
valueDefault = 'perso';
|
|
187
|
+
}
|
|
188
|
+
else if (comparedPeriodSelect.val() !== 'perso' && listValues.indexOf(comparedPeriodSelect.val()) !== -1) {
|
|
189
|
+
valueDefault = comparedPeriodSelect.val();
|
|
190
|
+
}
|
|
191
|
+
comparedPeriodSelect.val(valueDefault);
|
|
192
|
+
|
|
193
|
+
updateSelect(comparedPeriodSelect);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
static setTodaySelected(periodFormGroup) {
|
|
197
|
+
let date = new Date();
|
|
198
|
+
FormDate.setSelectedDate(periodFormGroup, date.getDate(), (date.getMonth() + 1), date.getFullYear());
|
|
199
|
+
}
|
|
200
|
+
static setCurrentMonthSelected(periodFormGroup) {
|
|
201
|
+
let date = new Date();
|
|
202
|
+
FormDate.setSelectedDate(periodFormGroup, -1, (date.getMonth() + 1), date.getFullYear());
|
|
203
|
+
}
|
|
204
|
+
static setCurrentYearSelected(periodFormGroup) {
|
|
205
|
+
let today = new Date();
|
|
206
|
+
FormDate.setSelectedDate(periodFormGroup, -1, -1, today.getFullYear());
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
static addNbDaysToToday(periodFormGroup, nbDays) {
|
|
210
|
+
FormDate.addNbDaysToSelectedDate(periodFormGroup, nbDays, false);
|
|
211
|
+
}
|
|
212
|
+
static addNbMonthsToToday(periodFormGroup, nbMonths) {
|
|
213
|
+
FormDate.addNbMonthsToSelectedDate(periodFormGroup, nbMonths, false);
|
|
214
|
+
}
|
|
215
|
+
static addNbYearsToToday(periodFormGroup, nbYears) {
|
|
216
|
+
FormDate.addNbYearsToSelectedDate(periodFormGroup, nbYears, false);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
static addNbDaysToSelectedDate(periodFormGroup, nbDays, fromSelectedDate) {
|
|
220
|
+
let date = typeof fromSelectedDate == 'undefined' || fromSelectedDate ? FormDate.getSelectedDate(periodFormGroup) : new Date();
|
|
221
|
+
date.setDate(date.getDate() + nbDays);
|
|
222
|
+
FormDate.setSelectedDate(periodFormGroup, date.getDate(), (date.getMonth() + 1), date.getFullYear());
|
|
223
|
+
}
|
|
224
|
+
static addNbMonthsToSelectedDate(periodFormGroup, nbMonths, fromSelectedDate) {
|
|
225
|
+
let date = typeof fromSelectedDate == 'undefined' || fromSelectedDate ? FormDate.getSelectedDate(periodFormGroup) : new Date();
|
|
226
|
+
date.setDate(1);
|
|
227
|
+
date.setMonth(date.getMonth() - nbMonths);
|
|
228
|
+
FormDate.setSelectedDate(periodFormGroup, -1, (date.getMonth() + 1), date.getFullYear());
|
|
229
|
+
}
|
|
230
|
+
static addNbYearsToSelectedDate(periodFormGroup, nbYears, fromSelectedDate) {
|
|
231
|
+
let date = typeof fromSelectedDate == 'undefined' || fromSelectedDate ? FormDate.getSelectedDate(periodFormGroup) : new Date();
|
|
232
|
+
FormDate.setSelectedDate(periodFormGroup, -1, -1, date.getFullYear() - nbYears);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
static getSelectedDate(periodFormGroup) {
|
|
236
|
+
let day = periodFormGroup.find('select.day').val();
|
|
237
|
+
let month = periodFormGroup.find('select.month').val();
|
|
238
|
+
let year = periodFormGroup.find('select.year').val();
|
|
239
|
+
if (null != day && null != month && null != year) {
|
|
240
|
+
return new Date(year, month - 1, day);
|
|
241
|
+
}
|
|
242
|
+
return new Date();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
static setSelectedDate(periodFormGroup, day, month, year) {
|
|
246
|
+
periodFormGroup.find('select.day').val(day);
|
|
247
|
+
periodFormGroup.find('select.month').val(month);
|
|
248
|
+
periodFormGroup.find('select.year').val(year);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
// deprecated
|
|
269
|
+
|
|
270
|
+
/** @deprecated */
|
|
271
|
+
static majSelectPeriode(select) {
|
|
272
|
+
if (select.find(':selected').attr('value') === 'perso') {
|
|
273
|
+
select.parent().parent().next().removeClass('hide');
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
select.parent().parent().next().addClass('hide');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** @deprecated */
|
|
281
|
+
static majSelectCompare() {
|
|
282
|
+
if ($('form select#periodeCompare').length === 0) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
let listValues = [];
|
|
287
|
+
let periodeSelected = $('form select.periode :selected').attr('value');
|
|
288
|
+
let selectCompare = $('form select#periodeCompare');
|
|
289
|
+
let periodeCompareSelected = selectCompare.find(':selected').attr('value');
|
|
290
|
+
let valueDefault = null;
|
|
291
|
+
|
|
292
|
+
selectCompare.find('option').removeAttr('disabled');
|
|
293
|
+
|
|
294
|
+
$.each(listePeriodeCompare, function (idx, tabListPeriode) {
|
|
295
|
+
if (idx != 0) {
|
|
296
|
+
let listKeyPeriode = array_keys(tabListPeriode.list);
|
|
297
|
+
if (in_array(periodeSelected, listKeyPeriode)) {
|
|
298
|
+
listValues = listKeyPeriode;
|
|
299
|
+
valueDefault = listKeyPeriode[1];
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
selectCompare.find('option[value="' + listKeyPeriode[0] + '"]').parent().children().attr('disabled', 'disabled');
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
if (periodeSelected === 'perso') {
|
|
308
|
+
valueDefault = 'perso';
|
|
309
|
+
}
|
|
310
|
+
else if (periodeCompareSelected !== 'perso' && in_array(periodeCompareSelected, listValues)) {
|
|
311
|
+
valueDefault = periodeCompareSelected;
|
|
312
|
+
}
|
|
313
|
+
selectCompare.find('option[value="' + valueDefault + '"]').attr('selected', 'selected');
|
|
314
|
+
|
|
315
|
+
FormDate.majSelectPeriode(selectCompare);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/** @deprecated */
|
|
319
|
+
static selectFormDateToday(lien) {
|
|
320
|
+
let date = new Date();
|
|
321
|
+
FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** @deprecated */
|
|
325
|
+
static selectFormDateDayMoinsNb(lien, nbJoursMoins) {
|
|
326
|
+
let date = new Date();
|
|
327
|
+
date.setDate(date.getDate() - nbJoursMoins);
|
|
328
|
+
FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** @deprecated */
|
|
332
|
+
static selectFormDateCurrentMonth(lien) {
|
|
333
|
+
let date = new Date();
|
|
334
|
+
FormDate.selectFormDate(lien, -1, (date.getMonth() + 1), date.getFullYear());
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** @deprecated */
|
|
338
|
+
static selectFormDateMonthMoinsNb(lien, nbMoisMoins) {
|
|
339
|
+
let date = new Date();
|
|
340
|
+
date.setDate(1);
|
|
341
|
+
date.setMonth(date.getMonth() - nbMoisMoins);
|
|
342
|
+
FormDate.selectFormDate(lien, -1, (date.getMonth() + 1), date.getFullYear());
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** @deprecated */
|
|
346
|
+
static selectFormDateCurrentYear(lien) {
|
|
347
|
+
let today = new Date();
|
|
348
|
+
FormDate.selectFormDate(lien, -1, -1, today.getFullYear());
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** @deprecated */
|
|
352
|
+
static selectFormDateYearMoinsNb(lien, nbAnneesMoins) {
|
|
353
|
+
let today = new Date();
|
|
354
|
+
FormDate.selectFormDate(lien, -1, -1, today.getFullYear() - nbAnneesMoins);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/** @deprecated */
|
|
358
|
+
static selectFormDateAddDayFromSelectedDay(lien, nbDaysAdded) {
|
|
359
|
+
let date = FormDate.getDateObjectSelected(lien);
|
|
360
|
+
date.setDate(date.getDate() + nbDaysAdded);
|
|
361
|
+
FormDate.selectFormDate(lien, date.getDate(), (date.getMonth() + 1), date.getFullYear());
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** @deprecated */
|
|
365
|
+
static getDateObjectSelected(lien) {
|
|
366
|
+
let selectorDay = '#' + (lien.parent().prev().prev().prev().prev().attr('id')) + ' option:selected';
|
|
367
|
+
let selectorMonth = '#' + (lien.parent().prev().prev().prev().attr('id')) + ' option:selected';
|
|
368
|
+
let selectorYear = '#' + (lien.parent().prev().prev().attr('id')) + ' option:selected';
|
|
369
|
+
if ($(selectorDay).length > 0 && $(selectorMonth).length > 0 && $(selectorYear).length > 0) {
|
|
370
|
+
return new Date($(selectorYear).attr('value'), $(selectorMonth).attr('value') - 1, $(selectorDay).attr('value'));
|
|
371
|
+
}
|
|
372
|
+
return new Date();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** @deprecated */
|
|
376
|
+
static selectFormDate(lien, day, month, year) {
|
|
377
|
+
let selectorDay = '#' + (lien.parent().prev().prev().prev().prev().attr('id')) + ' option[value=' + day + ']';
|
|
378
|
+
let selectorMonth = '#' + (lien.parent().prev().prev().prev().attr('id')) + ' option[value=' + month + ']';
|
|
379
|
+
let selectorYear = '#' + (lien.parent().prev().prev().attr('id')) + ' option[value=' + year + ']';
|
|
380
|
+
if ($(selectorDay).length > 0) $(selectorDay).prop('selected', 'selected');
|
|
381
|
+
if ($(selectorMonth).length > 0) $(selectorMonth).prop('selected', 'selected');
|
|
382
|
+
if ($(selectorYear).length > 0) $(selectorYear).prop('selected', 'selected');
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
module.exports = { FormDate };
|
package/form_helper.js
CHANGED
|
@@ -72,7 +72,7 @@ class FormHelper {
|
|
|
72
72
|
|
|
73
73
|
var input = form.find('[name="'+key+'"]');
|
|
74
74
|
|
|
75
|
-
if (input.prop('type')
|
|
75
|
+
if (input.prop('type') === 'radio' || input.prop('type') === 'checkbox') {
|
|
76
76
|
input.prop('checked', false);
|
|
77
77
|
input.filter('[value="'+value+'"]').prop('checked', true);
|
|
78
78
|
return;
|
|
@@ -187,8 +187,8 @@ class FormHelper {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
static getFormErrorText(errors) {
|
|
190
|
-
|
|
191
|
-
for (
|
|
190
|
+
let errorLabels = '';
|
|
191
|
+
for (let property in errors) {
|
|
192
192
|
if (typeof errors[property] != 'function') {
|
|
193
193
|
errorLabels += '<span>' + errors[property] + '</span><br>';
|
|
194
194
|
}
|
|
@@ -197,8 +197,8 @@ class FormHelper {
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
static getFormErrorTextBis(errors) {
|
|
200
|
-
|
|
201
|
-
for (
|
|
200
|
+
let errorLabels = '';
|
|
201
|
+
for (let property in errors) {
|
|
202
202
|
// console.log(property);
|
|
203
203
|
if (typeof errors[property] != 'function') {
|
|
204
204
|
if (typeof errors[property]['error_description'] === 'undefined') {
|
|
@@ -211,8 +211,8 @@ class FormHelper {
|
|
|
211
211
|
return errorLabels;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
static displayFormErrors(form, btnSubmit, errors) {
|
|
215
|
-
this.displayFormErrorsFromText(form, this.getFormErrorTextBis(errors));
|
|
214
|
+
static displayFormErrors(form, btnSubmit, errors, errorWrapperDiv) {
|
|
215
|
+
this.displayFormErrorsFromText(form, this.getFormErrorTextBis(errors), errorWrapperDiv);
|
|
216
216
|
if (btnSubmit != null) {
|
|
217
217
|
if (btnSubmit.buttonLoader != null) {
|
|
218
218
|
btnSubmit.buttonLoader('reset');
|
|
@@ -226,20 +226,25 @@ class FormHelper {
|
|
|
226
226
|
this.displayFormErrors(form, btnSubmit, xhr.responseJSON);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
static displayFormErrorsFromText(form, errorLabels) {
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
static displayFormErrorsFromText(form, errorLabels, errorWrapperDiv) {
|
|
230
|
+
let errorDiv = '<div class="alert alert-danger form_errors">'+errorLabels+'</div>';
|
|
231
|
+
|
|
232
|
+
if (typeof errorWrapperDiv != 'undefined' && errorWrapperDiv != null) {
|
|
233
|
+
errorWrapperDiv.append(errorDiv);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
232
236
|
|
|
233
237
|
if (form.find('.form_errors_content').length) {
|
|
234
238
|
form.find('.form_errors_content').append(errorDiv);
|
|
235
239
|
return;
|
|
236
240
|
}
|
|
237
241
|
|
|
242
|
+
let errorsParentDiv = form;
|
|
238
243
|
if (form.find('.modal-body').length) {
|
|
239
244
|
errorsParentDiv = form.find('.modal-body');
|
|
240
245
|
}
|
|
241
246
|
|
|
242
|
-
|
|
247
|
+
let firstFormGroup = errorsParentDiv.find('.form-group:first');
|
|
243
248
|
if (firstFormGroup.length) {
|
|
244
249
|
if (firstFormGroup.parent().parent().hasClass('row')) {
|
|
245
250
|
firstFormGroup.parent().parent().before(errorDiv);
|
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// rien à exporter (que des extensions d'objet natif)
|
|
5
5
|
require('./string');
|
|
6
6
|
require('./array');
|
|
7
|
+
require('./number');
|
|
7
8
|
|
|
8
9
|
// exports d'ojets non natif
|
|
9
10
|
const { HTTPRequest, Cookie, UrlAndQueryString } = require('./network');
|
|
@@ -18,6 +19,7 @@ const { Country, PostalAddress, Location } = require('./location');
|
|
|
18
19
|
const { SocialNetwork } = require('./social_network');
|
|
19
20
|
const { sleep, refresh } = require('./util');
|
|
20
21
|
const { chr, ord, trim, empty } = require('./php.min');
|
|
22
|
+
const { FormDate } = require('./form_date');
|
|
21
23
|
|
|
22
24
|
// exports plugins "maison"
|
|
23
25
|
const { DataTable } = require('./data_table');
|
|
@@ -39,11 +41,10 @@ const { GoogleMap } = require('./google_maps');
|
|
|
39
41
|
const { OpenStreetMap } = require('./open_street_map');
|
|
40
42
|
|
|
41
43
|
// deprecated
|
|
42
|
-
const { NumberValue } = require('./number');
|
|
43
44
|
|
|
44
45
|
module.exports = {
|
|
45
46
|
Array, Object, Number, String,
|
|
46
|
-
HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork,
|
|
47
|
+
HTTPRequest, Cookie, UrlAndQueryString, IBAN, BankCard, AudioMedia, UserMedia, PersonName, Email, TelephoneNumber, DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod, Duration, File, CSV, Img, FormHelper, Country, PostalAddress, Location, SocialNetwork, FormDate,
|
|
47
48
|
DataTable, Pagination, Navigation, DetailsSubArray, SelectAll, MultipleActionInTable, ShoppingCart, FlashMessage, CountDown, ImportFromCsv, JwtToken, JwtSession, ListBox,
|
|
48
49
|
sleep, refresh, chr, ord, trim, empty,
|
|
49
50
|
GoogleCharts, GoogleRecaptcha, GoogleMap, OpenStreetMap
|
package/media.js
CHANGED
|
@@ -75,23 +75,31 @@ class AudioMedia {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
//Source : https://www.npmjs.com/package/mic-check
|
|
78
|
-
class UserMedia {
|
|
78
|
+
class UserMedia {
|
|
79
|
+
static hasGetUserMedia() {
|
|
80
|
+
return !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
|
|
81
|
+
}
|
|
82
|
+
|
|
79
83
|
/** SystemPermissionDenied => (macOS) browser does not have permission to access cam/mic */
|
|
80
84
|
/** UserPermissionDenied => user denied permission for site to access cam/mic */
|
|
81
85
|
/** CouldNotStartVideoSource = > (Windows) browser does not have permission to access cam/mic OR camera is in use by another application or browser tab */
|
|
82
86
|
/** Generic => all other errors */
|
|
83
87
|
|
|
84
88
|
static requestMediaPermissions(constraints) {
|
|
89
|
+
/*try {
|
|
90
|
+
console.log(require.resolve("bowser"));
|
|
91
|
+
} catch(e) {
|
|
92
|
+
return;
|
|
93
|
+
}*/
|
|
94
|
+
|
|
85
95
|
return new Promise((resolve, reject) => {
|
|
86
96
|
const bowser = require('bowser');
|
|
87
97
|
const browser = bowser.getParser(window.navigator.userAgent);
|
|
88
98
|
const browserName = browser.getBrowserName();
|
|
89
99
|
|
|
90
100
|
navigator.mediaDevices.getUserMedia(constraints !== 'undefined' ? constraints : { audio: true, video: true })
|
|
91
|
-
.then((stream) =>
|
|
92
|
-
|
|
93
|
-
resolve(stream);
|
|
94
|
-
}).catch((error) => {
|
|
101
|
+
.then((stream) => resolve(stream))
|
|
102
|
+
.catch((error) => {
|
|
95
103
|
const errName = error.name;
|
|
96
104
|
const errMessage = error.message;
|
|
97
105
|
let errorType = "Generic";
|
|
@@ -148,8 +156,3 @@ class UserMedia {
|
|
|
148
156
|
}
|
|
149
157
|
|
|
150
158
|
module.exports = { AudioMedia, UserMedia };
|
|
151
|
-
|
|
152
|
-
//deprecated
|
|
153
|
-
function hasGetUserMedia() {
|
|
154
|
-
return !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
|
|
155
|
-
}
|
package/number.js
CHANGED
|
@@ -1,68 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
/** @deprecated */
|
|
3
|
-
class NumberValue {
|
|
4
|
-
/** @deprecated */
|
|
5
|
-
static isNumeric(sText) {
|
|
6
|
-
var ValidChars = "0123456789.";
|
|
7
|
-
var IsNumber=true;
|
|
8
|
-
var Char;
|
|
9
|
-
for (i = 0; i < sText.length && IsNumber == true; i++){
|
|
10
|
-
Char = sText.charAt(i);
|
|
11
|
-
if (ValidChars.indexOf(Char) == -1){
|
|
12
|
-
IsNumber = false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return IsNumber;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** @deprecated */
|
|
19
|
-
static format(number, nbDecimal, locale) {
|
|
20
|
-
nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
|
|
21
|
-
return new Intl.NumberFormat(locale, {
|
|
22
|
-
minimumFractionDigits: nbDecimal,
|
|
23
|
-
maximumFractionDigits: nbDecimal
|
|
24
|
-
}).format(number);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** @deprecated */
|
|
28
|
-
static formatCurrency(montant, currency, nbDecimal, locale) {
|
|
29
|
-
nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
|
|
30
|
-
return new Intl.NumberFormat(locale, {
|
|
31
|
-
style: 'currency',
|
|
32
|
-
currency: currency,
|
|
33
|
-
minimumFractionDigits: nbDecimal,
|
|
34
|
-
maximumFractionDigits: nbDecimal
|
|
35
|
-
}).format(montant);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** @deprecated */
|
|
39
|
-
static formatPercent(number, nbDecimal, locale) {
|
|
40
|
-
nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
|
|
41
|
-
return new Intl.NumberFormat(locale, {
|
|
42
|
-
style: 'percent',
|
|
43
|
-
minimumFractionDigits: nbDecimal,
|
|
44
|
-
maximumFractionDigits: nbDecimal
|
|
45
|
-
}).format(number);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** @deprecated */
|
|
49
|
-
static random(min, max) {
|
|
50
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** @deprecated */
|
|
54
|
-
static padLeft2(n) {
|
|
55
|
-
return n > 9 ? "" + n: "0" + n;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** @deprecated */
|
|
59
|
-
static roundDecimal(nombre, precision) {
|
|
60
|
-
precision = precision || 2;
|
|
61
|
-
var tmp = Math.pow(10, precision);
|
|
62
|
-
return Math.round(nombre*tmp) / tmp;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
2
|
Number.prototype.format = Number.prototype.format || function(nbDecimal, locale) {
|
|
67
3
|
nbDecimal = (typeof nbDecimal != 'undefined'?nbDecimal:2);
|
|
68
4
|
return new Intl.NumberFormat(locale, {
|
|
@@ -150,5 +86,3 @@ Number.prototype.formatAsPercent = function(locale, minimumFractionDigits) {
|
|
|
150
86
|
minimumFractionDigits = (typeof minimumFractionDigits != 'undefined'?minimumFractionDigits:0);
|
|
151
87
|
return new Intl.NumberFormat(locale, {style: 'percent', minimumFractionDigits:minimumFractionDigits}).format(this);
|
|
152
88
|
};
|
|
153
|
-
|
|
154
|
-
module.exports = { NumberValue };
|
package/package.json
CHANGED
package/todos/form_date.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
$(function() {
|
|
3
|
-
// ---------- Choix période (new) ----------
|
|
4
|
-
|
|
5
|
-
// Formulaire de sélection de période
|
|
6
|
-
|
|
7
|
-
if ($('form select.periode').length > 0) {
|
|
8
|
-
$('form select.periode').change(function() {
|
|
9
|
-
majSelectPeriode($(this));
|
|
10
|
-
|
|
11
|
-
if ($(this).attr('id') == 'periode') {
|
|
12
|
-
majSelectCompare();
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function majSelectPeriode(select) {
|
|
18
|
-
if (select.find(':selected').attr('value') == 'perso') {
|
|
19
|
-
select.parent().parent().next().removeClass('hide');
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
select.parent().parent().next().addClass('hide');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function majSelectCompare() {
|
|
27
|
-
if ($('form select#periodeCompare').length == 0) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var listValues = [];
|
|
32
|
-
periodeSelected = $('form select.periode :selected').attr('value');
|
|
33
|
-
selectCompare = $('form select#periodeCompare');
|
|
34
|
-
periodeCompareSelected = selectCompare.find(':selected').attr('value');
|
|
35
|
-
|
|
36
|
-
selectCompare.find('option').removeAttr('disabled');
|
|
37
|
-
|
|
38
|
-
$.each(listePeriodeCompare, function(idx, tabListPeriode) {
|
|
39
|
-
if (idx != 0) {
|
|
40
|
-
listKeyPeriode = array_keys(tabListPeriode.list);
|
|
41
|
-
if (in_array(periodeSelected, listKeyPeriode)) {
|
|
42
|
-
listValues = listKeyPeriode;
|
|
43
|
-
valueDefault = listKeyPeriode[1];
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
selectCompare.find('option[value="'+listKeyPeriode[0]+'"]').parent().children().attr('disabled', 'disabled');
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
if (periodeSelected == 'perso') {
|
|
52
|
-
valueDefault = 'perso';
|
|
53
|
-
}
|
|
54
|
-
else if (periodeCompareSelected != 'perso' && in_array(periodeCompareSelected, listValues)) {
|
|
55
|
-
valueDefault = periodeCompareSelected;
|
|
56
|
-
}
|
|
57
|
-
selectCompare.find('option[value="'+valueDefault+'"]').attr('selected', 'selected');
|
|
58
|
-
|
|
59
|
-
majSelectPeriode(selectCompare);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
majSelectCompare();
|
|
63
|
-
// majSelectPeriode($('form select#periodeCompare'));
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// ---------- Choix période (old) ----------
|
|
67
|
-
|
|
68
|
-
if ($('form #day').length > 0 && $('form #month').length > 0 && $('form #year').length > 0) {
|
|
69
|
-
$('form #year').after(
|
|
70
|
-
'<br/>'+
|
|
71
|
-
'<p class="select_date_fastly">'+
|
|
72
|
-
' <a href="#" class="lien_form_today">Auj.</a> - '+
|
|
73
|
-
' <a href="#" class="lien_form_yesterday">Hier</a> - '+
|
|
74
|
-
' <a href="#" class="lien_form_current_month">Ce mois-ci</a> - '+
|
|
75
|
-
' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
|
|
76
|
-
' <a href="#" class="lien_form_current_year">Cette année</a>'+
|
|
77
|
-
' - '+
|
|
78
|
-
' <a href="#" class="lien_form_date_prev_day">Jour précédent</a>'+
|
|
79
|
-
' - '+
|
|
80
|
-
' <a href="#" class="lien_form_date_next_day">Jour suivant</a>'+
|
|
81
|
-
'</p>'+
|
|
82
|
-
''
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
else if ($('form #month').length > 0 && $('form #year').length > 0) {
|
|
86
|
-
$('form #year').after(
|
|
87
|
-
'<br/>'+
|
|
88
|
-
'<p class="select_date_fastly">'+
|
|
89
|
-
' <a href="#" class="lien_form_current_month">Ce mois-ci</a> - '+
|
|
90
|
-
' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
|
|
91
|
-
' <a href="#" class="lien_form_current_year">Cette année</a>'+
|
|
92
|
-
'</p>'+
|
|
93
|
-
''
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if ($('form #dayCompare').length > 0 && $('form #monthCompare').length > 0 && $('form #yearCompare').length > 0) {
|
|
98
|
-
$('form #yearCompare').after(
|
|
99
|
-
'<br/>'+
|
|
100
|
-
'<p class="select_date_fastly">'+
|
|
101
|
-
' <a href="#" class="lien_form_yesterday">Hier</a> - '+
|
|
102
|
-
' <a href="#" class="lien_form_day_moins_7">J-7</a> - '+
|
|
103
|
-
' <a href="#" class="lien_form_day_moins_8">J-8</a> - '+
|
|
104
|
-
' <a href="#" class="lien_form_last_month">Le mois dernier</a> - '+
|
|
105
|
-
' <a href="#" class="lien_form_month_moins_2">Mois M-2</a> - '+
|
|
106
|
-
' <a href="#" class="lien_form_last_year">L\'année dernière</a>'+
|
|
107
|
-
'</p>'+
|
|
108
|
-
''
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Lien de sélection de date
|
|
113
|
-
|
|
114
|
-
if ($('form a.lien_form_today').length > 0) {
|
|
115
|
-
$('form a.lien_form_today').click(function() {
|
|
116
|
-
selectFormDateToday($(this));
|
|
117
|
-
return false;
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if ($('form a.lien_form_yesterday').length > 0) {
|
|
122
|
-
$('form a.lien_form_yesterday').click(function() {
|
|
123
|
-
selectFormDateDayMoinsNb($(this), 1);
|
|
124
|
-
return false;
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if ($('form a.lien_form_day_moins_7').length > 0) {
|
|
129
|
-
$('form a.lien_form_day_moins_7').click(function() {
|
|
130
|
-
selectFormDateDayMoinsNb($(this), 7);
|
|
131
|
-
return false;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if ($('form a.lien_form_day_moins_8').length > 0) {
|
|
136
|
-
$('form a.lien_form_day_moins_8').click(function() {
|
|
137
|
-
selectFormDateDayMoinsNb($(this), 8);
|
|
138
|
-
return false;
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if ($('form a.lien_form_current_month').length > 0) {
|
|
143
|
-
$('form a.lien_form_current_month').click(function() {
|
|
144
|
-
selectFormDateCurrentMonth($(this));
|
|
145
|
-
return false;
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if ($('form a.lien_form_last_month').length > 0) {
|
|
150
|
-
$('form a.lien_form_last_month').click(function() {
|
|
151
|
-
selectFormDateMonthMoinsNb($(this), 1);
|
|
152
|
-
return false;
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if ($('form a.lien_form_month_moins_2').length > 0) {
|
|
157
|
-
$('form a.lien_form_month_moins_2').click(function() {
|
|
158
|
-
selectFormDateMonthMoinsNb($(this), 2);
|
|
159
|
-
return false;
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if ($('form a.lien_form_current_year').length > 0) {
|
|
164
|
-
$('form a.lien_form_current_year').click(function() {
|
|
165
|
-
selectFormDateCurrentYear($(this));
|
|
166
|
-
return false;
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if ($('form a.lien_form_last_year').length > 0) {
|
|
171
|
-
$('form a.lien_form_last_year').click(function() {
|
|
172
|
-
selectFormDateYearMoinsNb($(this), 1);
|
|
173
|
-
return false;
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if ($('form a.lien_form_date_prev_day').length > 0) {
|
|
178
|
-
$('form a.lien_form_date_prev_day').click(function() {
|
|
179
|
-
selectFormDateAddDayFromSelectedDay($(this), -1);
|
|
180
|
-
return false;
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if ($('form a.lien_form_date_next_day').length > 0) {
|
|
184
|
-
$('form a.lien_form_date_next_day').click(function() {
|
|
185
|
-
selectFormDateAddDayFromSelectedDay($(this), 1);
|
|
186
|
-
return false;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/*
|
|
191
|
-
if ($('form select[name=select_date_fastly]').length > 0) {
|
|
192
|
-
$('form select[name=select_date_fastly]').change(function() {
|
|
193
|
-
valueOptionSelected = $('form select[name=select_date_fastly] option:selected').attr('value');
|
|
194
|
-
if (valueOptionSelected == 'today') {
|
|
195
|
-
selectFormDateToday();
|
|
196
|
-
}
|
|
197
|
-
else if (valueOptionSelected == 'current_month') {
|
|
198
|
-
selectFormDateCurrentMonth();
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
*/
|
|
203
|
-
|
|
204
|
-
function selectFormDateToday(lien) {
|
|
205
|
-
date = new Date();
|
|
206
|
-
selectFormDate(lien, date.getDate(), (date.getMonth()+1), date.getFullYear());
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function selectFormDateDayMoinsNb(lien, nbJoursMoins) {
|
|
210
|
-
date = new Date();
|
|
211
|
-
date.setDate(date.getDate() - nbJoursMoins);
|
|
212
|
-
selectFormDate(lien, date.getDate(), (date.getMonth()+1), date.getFullYear());
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function selectFormDateCurrentMonth(lien) {
|
|
216
|
-
date = new Date();
|
|
217
|
-
selectFormDate(lien, -1, (date.getMonth()+1), date.getFullYear());
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function selectFormDateMonthMoinsNb(lien, nbMoisMoins) {
|
|
221
|
-
date = new Date();
|
|
222
|
-
date.setDate(1);
|
|
223
|
-
date.setMonth(date.getMonth() - nbMoisMoins);
|
|
224
|
-
selectFormDate(lien, -1, (date.getMonth()+1), date.getFullYear());
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function selectFormDateCurrentYear(lien) {
|
|
228
|
-
today = new Date();
|
|
229
|
-
selectFormDate(lien, -1, -1, today.getFullYear());
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function selectFormDateYearMoinsNb(lien, nbAnneesMoins) {
|
|
233
|
-
today = new Date();
|
|
234
|
-
selectFormDate(lien, -1, -1, today.getFullYear()-nbAnneesMoins);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function selectFormDateAddDayFromSelectedDay(lien, nbDaysAdded) {
|
|
238
|
-
date = getDateObjectSelected(lien);
|
|
239
|
-
date.setDate(date.getDate() + nbDaysAdded);
|
|
240
|
-
selectFormDate(lien, date.getDate(), (date.getMonth()+1), date.getFullYear());
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function getDateObjectSelected(lien) {
|
|
244
|
-
selectorDay = '#'+(lien.parent().prev().prev().prev().prev().attr('id'))+' option:selected';
|
|
245
|
-
selectorMonth = '#'+(lien.parent().prev().prev().prev().attr('id'))+' option:selected';
|
|
246
|
-
selectorYear = '#'+(lien.parent().prev().prev().attr('id'))+' option:selected';
|
|
247
|
-
if ($(selectorDay).length > 0 && $(selectorMonth).length > 0 && $(selectorYear).length > 0) {
|
|
248
|
-
return new Date($(selectorYear).attr('value'), $(selectorMonth).attr('value')-1, $(selectorDay).attr('value'));
|
|
249
|
-
}
|
|
250
|
-
return new Date();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function selectFormDate(lien, day, month, year) {
|
|
254
|
-
selectorDay = '#'+(lien.parent().prev().prev().prev().prev().attr('id'))+' option[value='+day+']';
|
|
255
|
-
selectorMonth = '#'+(lien.parent().prev().prev().prev().attr('id'))+' option[value='+month+']';
|
|
256
|
-
selectorYear = '#'+(lien.parent().prev().prev().attr('id'))+' option[value='+year+']';
|
|
257
|
-
if ($(selectorDay).length > 0) $(selectorDay).prop('selected', 'selected');
|
|
258
|
-
if ($(selectorMonth).length > 0) $(selectorMonth).prop('selected', 'selected');
|
|
259
|
-
if ($(selectorYear).length > 0) $(selectorYear).prop('selected', 'selected');
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
});
|
package/todos/graphiques.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// --------------------------------------------------------------------------------
|
|
3
|
-
// Graphiques (new)
|
|
4
|
-
// --------------------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
google.load("visualization", "1", {packages:["corechart"]});
|
|
7
|
-
|
|
8
|
-
$(function() {
|
|
9
|
-
if (typeof(listeAllGraphiqueStats) != 'undefined' && listeAllGraphiqueStats.length > 0) {
|
|
10
|
-
loadListAllGraphStats(listeAllGraphiqueStats);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
function loadListAllGraphStats(listeAllGraphiqueStats) {
|
|
15
|
-
$.each(listeAllGraphiqueStats, function(idx, listGraphStats) {
|
|
16
|
-
loadAllGraphStats(listGraphStats);
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function loadAllGraphStats(listGraphStats) {
|
|
21
|
-
if (typeof(initWidth) == 'undefined' || initWidth) {
|
|
22
|
-
console.log('ok');
|
|
23
|
-
var width = 0;
|
|
24
|
-
$.each(listGraphStats, function(idx, tabGraph) {
|
|
25
|
-
if ($('#'+tabGraph.id).length) {
|
|
26
|
-
if ($('#'+tabGraph.id).width() > 0) {
|
|
27
|
-
width = $('#'+tabGraph.id).width();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
$.each(listGraphStats, function(idx, tabGraph) {
|
|
34
|
-
// console.log(width + ' ' + height);
|
|
35
|
-
drawGraphiqueStat(tabGraph.type_graph, tabGraph.id, tabGraph.title, tabGraph.libelle_abs, tabGraph.tab_data_abs, tabGraph.liste_libelle_ord, tabGraph.liste_tab_data_ord, tabGraph.list_color, tabGraph.format_ord, tabGraph.height, width);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function drawGraphiqueStat(typeGraph, idDiv, titre, libelleAbs, tabDataAbsParam, listeLibelleOrd, listeTabDataOrd, tabColor, formatData, height, width) {
|
|
40
|
-
if ($('#'+idDiv).length == 0) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var afficherLibelleOrd = false;
|
|
45
|
-
|
|
46
|
-
isStacked = false;
|
|
47
|
-
if (typeGraph == 'stacked_bar_chart') {
|
|
48
|
-
typeGraph = 'bar_chart';
|
|
49
|
-
isStacked = true;
|
|
50
|
-
}
|
|
51
|
-
if (typeGraph == 'stacked_column_chart') {
|
|
52
|
-
typeGraph = 'column_chart';
|
|
53
|
-
isStacked = true;
|
|
54
|
-
}
|
|
55
|
-
if (typeGraph == 'stacked_combo_chart') {
|
|
56
|
-
typeGraph = 'combo_chart';
|
|
57
|
-
isStacked = true;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
isDualChart = false;
|
|
61
|
-
if (typeGraph == 'dual_column_chart') {
|
|
62
|
-
typeGraph = 'column_chart';
|
|
63
|
-
isDualChart = true;
|
|
64
|
-
}
|
|
65
|
-
if (typeGraph == 'dual_bar_chart') {
|
|
66
|
-
typeGraph = 'bar_chart';
|
|
67
|
-
isDualChart = true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Déclaration du tableau de données
|
|
71
|
-
var data = new google.visualization.DataTable();
|
|
72
|
-
data.addColumn('string', libelleAbs);
|
|
73
|
-
$.each(listeLibelleOrd, function(idx, libelleOrd) {
|
|
74
|
-
data.addColumn('number', libelleOrd);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Remplissage des données
|
|
78
|
-
var nbCells = 0;
|
|
79
|
-
var numRow = 0;
|
|
80
|
-
$.each(tabDataAbsParam, function(idx, dataAbs) {
|
|
81
|
-
// dataOrd = tabDataOrd[idx];
|
|
82
|
-
// data.addRow([dataAbs, dataOrd]);
|
|
83
|
-
data.addRows(1);
|
|
84
|
-
|
|
85
|
-
data.setCell(numRow, 0, dataAbs);
|
|
86
|
-
|
|
87
|
-
var numCell = 1;
|
|
88
|
-
$.each(listeTabDataOrd, function(idx2, tabDataOrd) {
|
|
89
|
-
data.setCell(numRow, numCell, tabDataOrd[idx]);
|
|
90
|
-
numCell++;
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
nbCells = numCell;
|
|
94
|
-
numRow++;
|
|
95
|
-
});
|
|
96
|
-
nbCells -= 2;
|
|
97
|
-
|
|
98
|
-
// console.log(data);
|
|
99
|
-
// console.log('drawGraph : '+idDiv+' ; type : '+typeGraph);
|
|
100
|
-
|
|
101
|
-
// Options générales
|
|
102
|
-
var options = {
|
|
103
|
-
colors: tabColor,
|
|
104
|
-
fontName: 'Trebuchet MS',
|
|
105
|
-
fontSize: 12,
|
|
106
|
-
hAxis: {maxAlternation: 1},
|
|
107
|
-
vAxis: {minValue: 0, textPosition: 'out'},
|
|
108
|
-
//gridlines: {color: '#333', count: 1}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
if (formatData != null) {
|
|
112
|
-
options.vAxis.format = formatData;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Options sur le titre du graphique
|
|
116
|
-
options.title = titre;
|
|
117
|
-
if (typeGraph == 'pie_chart') {
|
|
118
|
-
// options.titlePosition = 'none';
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
options.titlePosition = 'none';
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Options sur la taille du graphique
|
|
125
|
-
if (typeGraph == 'bar_chart') {
|
|
126
|
-
options.chartArea = {left:120, top:30};
|
|
127
|
-
options.chartArea.height = (height-60);
|
|
128
|
-
options.chartArea.width = "85%";
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
options.chartArea = {left:"auto", top:"auto"};
|
|
132
|
-
if (height != null) {
|
|
133
|
-
options.chartArea.height = height+"%";
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
options.chartArea.height = "80%";
|
|
137
|
-
}
|
|
138
|
-
options.chartArea.width = "85%";
|
|
139
|
-
}
|
|
140
|
-
// options.chartArea = {};
|
|
141
|
-
// options.chartArea.height = "100%";
|
|
142
|
-
// options.chartArea.width = "100%";
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// console.log($('#'+idDiv).width());
|
|
146
|
-
// options.height = $('#'+idDiv).height();
|
|
147
|
-
// options.width = $('#'+idDiv).width();
|
|
148
|
-
// options.height = height;
|
|
149
|
-
// console.log(height);
|
|
150
|
-
options.width = width;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
// Options sur la légende
|
|
155
|
-
options.legend = {};
|
|
156
|
-
if (typeGraph == 'pie_chart') {
|
|
157
|
-
options.legend.position = 'right';
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
options.legend.position = 'top';
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// Options sur l'affichage des labels en absisse / ordonnée
|
|
164
|
-
if (typeGraph == 'bar_chart') {
|
|
165
|
-
// options.hAxis.title = libelleOrd;
|
|
166
|
-
options.vAxis.title = libelleAbs;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
options.hAxis.title = libelleAbs;
|
|
170
|
-
// options.vAxis.title = libelleOrd;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Options sur les graphiques "dual bar chart / dual column chart"
|
|
174
|
-
if (isDualChart) {
|
|
175
|
-
options.series = {};
|
|
176
|
-
options.axes = {};
|
|
177
|
-
if (typeGraph == 'column_chart') {
|
|
178
|
-
options.axes.y = {};
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
options.axes.x = {};
|
|
182
|
-
}
|
|
183
|
-
$.each(listeLibelleOrd, function(idx, libelleOrd) {
|
|
184
|
-
console.log(idx);
|
|
185
|
-
if (idx <= 1) {
|
|
186
|
-
key = 'series_'+idx;
|
|
187
|
-
options.series[idx] = {axis: key};
|
|
188
|
-
if (typeGraph == 'column_chart') {
|
|
189
|
-
options.axes.y[key] = {label: libelleOrd};
|
|
190
|
-
if (idx == 1) {
|
|
191
|
-
options.axes.y[key].side = 'right';
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
options.axes.x[key] = {label: libelleOrd};
|
|
196
|
-
if (idx == 1) {
|
|
197
|
-
options.axes.x[key].side = 'top';
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
console.log(options.series);
|
|
203
|
-
console.log(options.axes.y);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Options sur les graphiques "combo chart"
|
|
207
|
-
if (typeGraph == 'combo_chart') {
|
|
208
|
-
options.seriesType = "bars";
|
|
209
|
-
options.series = {};
|
|
210
|
-
options.series[nbCells] = {type: "line"};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Options sur le style des lignes pour les "line chart"
|
|
214
|
-
if (typeGraph == 'line_chart') {
|
|
215
|
-
options.series = [{lineWidth: 3}, {lineWidth: 1.5}];
|
|
216
|
-
options.curveType = 'function';
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Options sur le style pour les "pie chart"
|
|
220
|
-
if (typeGraph == 'pie_chart') {
|
|
221
|
-
options.is3D = false;
|
|
222
|
-
options.pieResidueSliceLabel = 'Autre';
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (isStacked) {
|
|
226
|
-
options.isStacked = true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// console.log(options);
|
|
230
|
-
|
|
231
|
-
// Création du graphique
|
|
232
|
-
var errorChart = false;
|
|
233
|
-
if (typeGraph == 'column_chart') {
|
|
234
|
-
var chart = new google.visualization.ColumnChart(document.getElementById(idDiv));
|
|
235
|
-
}
|
|
236
|
-
else if (typeGraph == 'bar_chart') {
|
|
237
|
-
var chart = new google.visualization.BarChart(document.getElementById(idDiv));
|
|
238
|
-
}
|
|
239
|
-
else if (typeGraph == 'line_chart') {
|
|
240
|
-
var chart = new google.visualization.LineChart(document.getElementById(idDiv));
|
|
241
|
-
}
|
|
242
|
-
else if (typeGraph == 'combo_chart') {
|
|
243
|
-
var chart = new google.visualization.ComboChart(document.getElementById(idDiv));
|
|
244
|
-
}
|
|
245
|
-
else if (typeGraph == 'pie_chart') {
|
|
246
|
-
var chart = new google.visualization.PieChart(document.getElementById(idDiv));
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
errorChart = true;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
$('#'+idDiv).removeClass('ajaxLoader');
|
|
253
|
-
$('#'+idDiv).removeClass('graphique_load');
|
|
254
|
-
|
|
255
|
-
if (errorChart) {
|
|
256
|
-
console.log('erreur graphique');
|
|
257
|
-
$('#'+idDiv).addClass('graphique_error');
|
|
258
|
-
document.getElementById(idDiv).innerHTML = 'Une erreur s\'est produite lors du chargement du graphique.';
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
$('#'+idDiv).addClass('graphique');
|
|
262
|
-
document.getElementById(idDiv).innerHTML = '';
|
|
263
|
-
|
|
264
|
-
// $('#'+idDiv).
|
|
265
|
-
// document.getElementById(idDiv).style.display = 'block';
|
|
266
|
-
var hasClassActive = $('#'+idDiv).hasClass('active');
|
|
267
|
-
if (!hasClassActive) {
|
|
268
|
-
$('#'+idDiv).addClass('active');
|
|
269
|
-
}
|
|
270
|
-
google.visualization.events.addListener(chart, 'ready', function () {
|
|
271
|
-
// document.getElementById(idDiv).style.display = 'none';
|
|
272
|
-
// $('#'+idDiv).hide();
|
|
273
|
-
if (!hasClassActive) {
|
|
274
|
-
$('#'+idDiv).removeClass('active');
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
// console.log($("ul li.ui-state-active").index()
|
|
278
|
-
|
|
279
|
-
chart.draw(data, options);
|
|
280
|
-
}
|
|
281
|
-
}
|
package/todos/jquery.js
DELETED
package/todos/tree.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
* SIDEBAR MENU
|
|
4
|
-
* ------------
|
|
5
|
-
* This is a custom plugin for the sidebar menu. It provides a tree view.
|
|
6
|
-
*
|
|
7
|
-
* Usage:
|
|
8
|
-
* $(".sidebar).tree();
|
|
9
|
-
*
|
|
10
|
-
* Note: This plugin does not accept any options. Instead, it only requires a class added to the element that contains a sub-menu.
|
|
11
|
-
*
|
|
12
|
-
* When used with the sidebar, for example, it would look something like this:
|
|
13
|
-
* <ul class='sidebar-menu'>
|
|
14
|
-
* <li class="treeview active">
|
|
15
|
-
* <a href="#>Menu</a>
|
|
16
|
-
* <ul class='treeview-menu'>
|
|
17
|
-
* <li class='active'><a href=#>Level 1</a></li>
|
|
18
|
-
* </ul>
|
|
19
|
-
* </li>
|
|
20
|
-
* </ul>
|
|
21
|
-
*
|
|
22
|
-
* Add .active class to <li> elements if you want the menu to be open automatically
|
|
23
|
-
* on page load. See above for an example.
|
|
24
|
-
*/
|
|
25
|
-
(function($) {
|
|
26
|
-
"use strict";
|
|
27
|
-
|
|
28
|
-
$.fn.tree = function() {
|
|
29
|
-
return this.each(function() {
|
|
30
|
-
var btn = $(this).children("a").first();
|
|
31
|
-
// var btn = $('a.sidebar-toggle');
|
|
32
|
-
var menu = $(this).children(".treeview-menu").first();
|
|
33
|
-
var isActive = $(this).hasClass('active');
|
|
34
|
-
// isActive = true;
|
|
35
|
-
|
|
36
|
-
//initialize already active menus
|
|
37
|
-
// if (isActive) {
|
|
38
|
-
menu.show();
|
|
39
|
-
btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
|
|
40
|
-
// }
|
|
41
|
-
// else {
|
|
42
|
-
// menu.show();
|
|
43
|
-
// }
|
|
44
|
-
//Slide open or close the menu on link click
|
|
45
|
-
btn.click(function(e) {
|
|
46
|
-
e.preventDefault();
|
|
47
|
-
if (isActive) {
|
|
48
|
-
// Slide up to close menu
|
|
49
|
-
menu.slideUp();
|
|
50
|
-
isActive = false;
|
|
51
|
-
btn.children(".fa-angle-down").first().removeClass("fa-angle-down").addClass("fa-angle-left");
|
|
52
|
-
btn.parent("li").removeClass("active");
|
|
53
|
-
} else {
|
|
54
|
-
// Slide down to open menu
|
|
55
|
-
menu.slideDown();
|
|
56
|
-
isActive = true;
|
|
57
|
-
btn.children(".fa-angle-left").first().removeClass("fa-angle-left").addClass("fa-angle-down");
|
|
58
|
-
btn.parent("li").addClass("active");
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
/* Add margins to submenu elements to give it a tree look */
|
|
63
|
-
menu.find("li > a").each(function() {
|
|
64
|
-
var pad = parseInt($(this).css("margin-left")) + 10;
|
|
65
|
-
|
|
66
|
-
$(this).css({"margin-left": pad + "px"});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
}(jQuery));
|