Revision 3880:e6d1f6d9d7df,
1.4 KB
checked in by franck <carnet.franck.paul@…>, 7 years ago
(diff) |
Use let and const rather than var (ES2015/ES6), use template string where is more efficient
|
Line | |
---|
1 | /*global $, dotclear */ |
---|
2 | 'use strict'; |
---|
3 | |
---|
4 | $(function() { |
---|
5 | $('.checkboxes-helpers').each(function() { |
---|
6 | dotclear.checkboxesHelpers(this, undefined, '#form-users input[type="checkbox"]', '#form-users #do-action'); |
---|
7 | }); |
---|
8 | dotclear.condSubmit('#form-users input[type="checkbox"]', '#form-users #do-action'); |
---|
9 | $('#form-users').submit(function() { |
---|
10 | const action = $(this).find('select[name="action"]').val(); |
---|
11 | let user_ids = []; |
---|
12 | let nb_posts = []; |
---|
13 | let i; |
---|
14 | let msg_cannot_delete = false; |
---|
15 | |
---|
16 | $(this).find('input[name="users[]"]').each(function() { |
---|
17 | user_ids.push(this); |
---|
18 | }); |
---|
19 | $(this).find('input[name="nb_post[]"]').each(function() { |
---|
20 | nb_posts.push(this.value); |
---|
21 | }); |
---|
22 | |
---|
23 | if (action == 'deleteuser') { |
---|
24 | for (i = 0; i < user_ids.length; i++) { |
---|
25 | if (nb_posts[i] > 0) { |
---|
26 | if (user_ids[i].checked == true) { |
---|
27 | msg_cannot_delete = true; |
---|
28 | user_ids[i].checked = false; |
---|
29 | } |
---|
30 | } |
---|
31 | } |
---|
32 | if (msg_cannot_delete == true) { |
---|
33 | window.alert(dotclear.msg.cannot_delete_users); |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | let selectfields = 0; |
---|
38 | for (i = 0; i < user_ids.length; i++) { |
---|
39 | selectfields += user_ids[i].checked; |
---|
40 | } |
---|
41 | |
---|
42 | if (selectfields == 0) { |
---|
43 | return false; |
---|
44 | } |
---|
45 | |
---|
46 | if (action == 'deleteuser') { |
---|
47 | return window.confirm(dotclear.msg.confirm_delete_user.replace('%s', $('input[name="users[]"]:checked').size())); |
---|
48 | } |
---|
49 | |
---|
50 | return true; |
---|
51 | }); |
---|
52 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.