@osimatic/helpers-js 1.0.2
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/array.js +84 -0
- package/bank.js +7 -0
- package/button_loader.js +50 -0
- package/contact_details.js +172 -0
- package/count_down.js +103 -0
- package/data_table.js +419 -0
- package/date_time.js +551 -0
- package/details_sub_array.js +126 -0
- package/duration.js +177 -0
- package/file.js +128 -0
- package/flash_message.js +38 -0
- package/form_date.js +262 -0
- package/form_helper.js +237 -0
- package/google_charts.js +344 -0
- package/google_charts_mytime.js +295 -0
- package/google_maps.js +169 -0
- package/google_recaptcha.js +15 -0
- package/graphiques.js +281 -0
- package/import_from_csv.js +274 -0
- package/index.js +69 -0
- package/jquery.js +5 -0
- package/jwt.js +97 -0
- package/list_box.js +113 -0
- package/location.js +391 -0
- package/media.js +82 -0
- package/multiple_action_in_table.js +229 -0
- package/network.js +554 -0
- package/number.js +90 -0
- package/package.json +12 -0
- package/paging.js +237 -0
- package/php.min.js +4 -0
- package/select_all.js +132 -0
- package/social_network.js +110 -0
- package/string.js +118 -0
- package/tree.js +71 -0
- package/util.js +23 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
|
|
2
|
+
class MultipleActionInTable {
|
|
3
|
+
// init checkbox
|
|
4
|
+
static init(table) {
|
|
5
|
+
if (!table.hasClass('table-action_multiple')) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
var divBtn = MultipleActionInTable.getDivBtn(table);
|
|
10
|
+
if (divBtn == null) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!divBtn.hasClass('action_multiple_buttons_initialized')) {
|
|
15
|
+
divBtn.prepend($('<img src="'+ROOT_PATH+DOSSIER_IMAGES+'arrow_ltr.png" alt="" /> '));
|
|
16
|
+
divBtn.append($('<br/><br/>'));
|
|
17
|
+
divBtn.addClass('action_multiple_buttons_initialized');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (table.find('thead tr th[data-key="select"]').length === 0) {
|
|
21
|
+
table.find('thead tr').prepend($('<th class="select no-sort" data-key="select"></th>'));
|
|
22
|
+
}
|
|
23
|
+
table.find('tbody tr:not(.no_items)').each(function(idx, tr) {
|
|
24
|
+
if ($(tr).find('td.select').length === 0) {
|
|
25
|
+
$(tr).prepend($('<td class="select"><input type="checkbox" class="action_multiple_checkbox" name="'+$(tr).data('action_multiple_input_name')+'" value="'+$(tr).data('action_multiple_item_id')+'"></td>'));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
table.find('input.action_multiple_checkbox').each(function(idx, el) {
|
|
30
|
+
var th = $(el).closest('table').find('thead tr th').first();
|
|
31
|
+
if (th.find('input').length === 0) {
|
|
32
|
+
// console.log(th);
|
|
33
|
+
th.html('<input type="checkbox" class="action_multiple_check_all" />');
|
|
34
|
+
// th.html('Coucou');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
table.find('input.action_multiple_checkbox').change(function() {
|
|
39
|
+
MultipleActionInTable.updateCheckbox(table);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
table.find('input.action_multiple_check_all').off('click').click(function() {
|
|
43
|
+
var table = $(this).closest('table');
|
|
44
|
+
var checkbox = table.find('input.action_multiple_checkbox');
|
|
45
|
+
var checkboxChecked = table.find('input.action_multiple_checkbox:checked');
|
|
46
|
+
if (checkbox.length === checkboxChecked.length) {
|
|
47
|
+
checkbox.prop('checked', false);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
checkbox.prop('checked', true);
|
|
51
|
+
}
|
|
52
|
+
MultipleActionInTable.updateCheckbox(table);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
MultipleActionInTable.updateCheckbox(table);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static updateCheckbox(table) {
|
|
59
|
+
MultipleActionInTable.showButtonsAction(table);
|
|
60
|
+
|
|
61
|
+
var allCheckbox = table.find('input.action_multiple_checkbox');
|
|
62
|
+
var allCheckboxChecked = table.find('input.action_multiple_checkbox:checked');
|
|
63
|
+
var checkboxSelectAll = table.find('thead tr th input.action_multiple_check_all');
|
|
64
|
+
if (allCheckbox.length === allCheckboxChecked.length) {
|
|
65
|
+
checkboxSelectAll.prop('checked', true);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
checkboxSelectAll.prop('checked', false);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static getDivBtn(table) {
|
|
73
|
+
var divTableResponsive = table.parent();
|
|
74
|
+
var divBtn = divTableResponsive.next();
|
|
75
|
+
if (divBtn.hasClass('action_multiple_buttons')) {
|
|
76
|
+
return divBtn;
|
|
77
|
+
}
|
|
78
|
+
divBtn = divTableResponsive.parent().parent().parent().next();
|
|
79
|
+
if (divBtn.hasClass('action_multiple_buttons')) {
|
|
80
|
+
return divBtn;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static showButtonsAction(table) {
|
|
86
|
+
let divBtn = MultipleActionInTable.getDivBtn(table);
|
|
87
|
+
if (divBtn == null) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// console.log(divBtn);
|
|
92
|
+
//var nbItems = $('input[name="' + checkbox.attr('name') + '"]:checked').length;
|
|
93
|
+
let nbItems = table.find('input.action_multiple_checkbox:checked').length;
|
|
94
|
+
|
|
95
|
+
if (nbItems > 0 && divBtn.is(':hidden')) {
|
|
96
|
+
divBtn.removeClass('hide');
|
|
97
|
+
}
|
|
98
|
+
// 13/04/2021 : si le tableau est caché cela veut dire qu'il est en train de s'initialiser (après avoir chargé les données) et donc s'il n'y a pas de ligne sélectionnées, on cache la div buttons
|
|
99
|
+
else if ((nbItems === 0 && divBtn.is(':visible')) || (nbItems === 0 && table.is(':hidden'))) {
|
|
100
|
+
divBtn.addClass('hide');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// affichage aucune action possible si aucun bouton n'est visible
|
|
104
|
+
if (divBtn.is(':visible')) {
|
|
105
|
+
divBtn.find('span.no_button').remove();
|
|
106
|
+
if (divBtn.find('button:visible, a:visible').length === 0) {
|
|
107
|
+
divBtn.find('img').after('<span class="no_button"><em>aucune action possible</em></span>');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
$(function() {
|
|
115
|
+
$('table.table-action_multiple').each(function(idx, table) {
|
|
116
|
+
MultipleActionInTable.init($(table));
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
/*
|
|
121
|
+
// init checkbox
|
|
122
|
+
function initTableActionMultiple(table) {
|
|
123
|
+
if (!table.hasClass('table-action_multiple')) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
var divBtn = tableActionMultipleGetDivBtn(table);
|
|
128
|
+
if (divBtn == null) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (table.find('thead tr th[data-key="select"]').length === 0) {
|
|
133
|
+
table.find('thead tr').prepend($('<th class="select no-sort" data-key="select"></th>'));
|
|
134
|
+
}
|
|
135
|
+
table.find('tbody tr:not(.no_items)').each(function(idx, tr) {
|
|
136
|
+
if ($(tr).find('td.select').length === 0) {
|
|
137
|
+
$(tr).prepend($('<td class="select"><input type="checkbox" class="action_multiple_checkbox" name="'+$(tr).data('action_multiple_input_name')+'" value="'+$(tr).data('action_multiple_item_id')+'"></td>'));
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
table.find('input.action_multiple_checkbox').each(function(idx, el) {
|
|
142
|
+
var th = $(el).closest('table').find('thead tr th').first();
|
|
143
|
+
if (th.find('input').length === 0) {
|
|
144
|
+
// console.log(th);
|
|
145
|
+
th.html('<input type="checkbox" class="action_multiple_check_all" />');
|
|
146
|
+
// th.html('Coucou');
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
table.find('input.action_multiple_checkbox').change(function() {
|
|
151
|
+
majCheckbox(table);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
table.find('input.action_multiple_check_all').off('click').click(function() {
|
|
155
|
+
var table = $(this).closest('table');
|
|
156
|
+
var checkbox = table.find('input.action_multiple_checkbox');
|
|
157
|
+
var checkboxChecked = table.find('input.action_multiple_checkbox:checked');
|
|
158
|
+
if (checkbox.length === checkboxChecked.length) {
|
|
159
|
+
checkbox.prop('checked', false);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
checkbox.prop('checked', true);
|
|
163
|
+
}
|
|
164
|
+
majCheckbox(table);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function majCheckbox(table) {
|
|
169
|
+
showButtonsAction(table);
|
|
170
|
+
|
|
171
|
+
var allCheckbox = table.find('input.action_multiple_checkbox');
|
|
172
|
+
var allCheckboxChecked = table.find('input.action_multiple_checkbox:checked');
|
|
173
|
+
var checkboxSelectAll = table.find('thead tr th input.action_multiple_check_all');
|
|
174
|
+
if (allCheckbox.length === allCheckboxChecked.length) {
|
|
175
|
+
checkboxSelectAll.prop('checked', true);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
checkboxSelectAll.prop('checked', false);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function tableActionMultipleGetDivBtn(table) {
|
|
183
|
+
var divTableResponsive = table.parent();
|
|
184
|
+
var divBtn = divTableResponsive.next();
|
|
185
|
+
if (divBtn.hasClass('action_multiple_buttons')) {
|
|
186
|
+
return divBtn;
|
|
187
|
+
}
|
|
188
|
+
divBtn = divTableResponsive.parent().parent().parent().next();
|
|
189
|
+
if (divBtn.hasClass('action_multiple_buttons')) {
|
|
190
|
+
return divBtn;
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function showButtonsAction(table) {
|
|
196
|
+
var divBtn = tableActionMultipleGetDivBtn(table);
|
|
197
|
+
if (divBtn == null) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// console.log(divBtn);
|
|
202
|
+
//var nbItems = $('input[name="' + checkbox.attr('name') + '"]:checked').length;
|
|
203
|
+
var nbItems = table.find('input.action_multiple_checkbox:checked').length;
|
|
204
|
+
|
|
205
|
+
if (nbItems > 0 && divBtn.is(':hidden')) {
|
|
206
|
+
divBtn.removeClass('hide');
|
|
207
|
+
}
|
|
208
|
+
else if (nbItems === 0 && divBtn.is(':visible')) {
|
|
209
|
+
divBtn.addClass('hide');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// affichage aucune action possible si aucun bouton n'est visible
|
|
213
|
+
if (divBtn.is(':visible')) {
|
|
214
|
+
divBtn.find('span.no_button').remove();
|
|
215
|
+
if (divBtn.find('button:visible, a:visible').length === 0) {
|
|
216
|
+
divBtn.find('img').after('<span class="no_button"><em>aucune action possible</em></span>');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
$(function() {
|
|
222
|
+
$('.action_multiple_buttons').prepend($('<img src="'+ROOT_PATH+DOSSIER_IMAGES+'arrow_ltr.png" alt="" /> '));
|
|
223
|
+
$('.action_multiple_buttons').append($('<br/><br/>'));
|
|
224
|
+
|
|
225
|
+
$('table.table-action_multiple').each(function(idx, table) {
|
|
226
|
+
initTableActionMultiple($(table));
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
*/
|