Revision 3182:adf3c934173f,
1.3 KB
checked in by franck <carnet.franck.paul@…>, 10 years ago
(diff) |
Disable submit button unless at least one item selected whenever is possible, closes #1600
|
Rev | Line | |
---|
[0] | 1 | $(function() { |
---|
| 2 | $('.checkboxes-helpers').each(function() { |
---|
[3182] | 3 | dotclear.checkboxesHelpers(this,undefined,'#form-users input[type="checkbox"]','#form-users #do-action'); |
---|
[0] | 4 | }); |
---|
[3182] | 5 | dotclear.condSubmit('#form-users input[type="checkbox"]','#form-users #do-action'); |
---|
[0] | 6 | $('#form-users').submit(function() { |
---|
[860] | 7 | var action = $(this).find('select[name="action"]').val(); |
---|
[0] | 8 | var user_ids = new Array(); |
---|
| 9 | var nb_posts = new Array(); |
---|
| 10 | var i; |
---|
| 11 | var msg_cannot_delete = false; |
---|
[2566] | 12 | |
---|
[860] | 13 | $(this).find('input[name="users[]"]').each(function() { |
---|
[0] | 14 | user_ids.push(this); |
---|
| 15 | }); |
---|
| 16 | $(this).find('input[name="nb_post[]"]').each(function() { |
---|
| 17 | nb_posts.push(this.value); |
---|
| 18 | }); |
---|
[2566] | 19 | |
---|
[0] | 20 | if (action == 'deleteuser') { |
---|
| 21 | for (i=0; i<user_ids.length; i++) { |
---|
| 22 | if (nb_posts[i] > 0) { |
---|
[548] | 23 | if (user_ids[i].checked == true) { |
---|
| 24 | msg_cannot_delete = true; |
---|
| 25 | user_ids[i].checked = false; |
---|
| 26 | } |
---|
[0] | 27 | } |
---|
| 28 | } |
---|
| 29 | if (msg_cannot_delete == true) { |
---|
| 30 | alert(dotclear.msg.cannot_delete_users); |
---|
| 31 | } |
---|
| 32 | } |
---|
[2566] | 33 | |
---|
[0] | 34 | var selectfields = 0; |
---|
| 35 | for (i=0; i<user_ids.length; i++) { |
---|
| 36 | selectfields += user_ids[i].checked; |
---|
| 37 | } |
---|
[2566] | 38 | |
---|
[0] | 39 | if (selectfields == 0) { |
---|
| 40 | return false; |
---|
| 41 | } |
---|
[2566] | 42 | |
---|
[0] | 43 | if (action == 'deleteuser') { |
---|
[860] | 44 | return window.confirm(dotclear.msg.confirm_delete_user.replace('%s',$('input[name="users[]"]:checked').size())); |
---|
[0] | 45 | } |
---|
[2566] | 46 | |
---|
[0] | 47 | return true; |
---|
| 48 | }); |
---|
[2566] | 49 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.