| 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
|
| Line | |
|---|
| 1 | $(function() { |
|---|
| 2 | $('.checkboxes-helpers').each(function() { |
|---|
| 3 | dotclear.checkboxesHelpers(this,undefined,'#form-users input[type="checkbox"]','#form-users #do-action'); |
|---|
| 4 | }); |
|---|
| 5 | dotclear.condSubmit('#form-users input[type="checkbox"]','#form-users #do-action'); |
|---|
| 6 | $('#form-users').submit(function() { |
|---|
| 7 | var action = $(this).find('select[name="action"]').val(); |
|---|
| 8 | var user_ids = new Array(); |
|---|
| 9 | var nb_posts = new Array(); |
|---|
| 10 | var i; |
|---|
| 11 | var msg_cannot_delete = false; |
|---|
| 12 | |
|---|
| 13 | $(this).find('input[name="users[]"]').each(function() { |
|---|
| 14 | user_ids.push(this); |
|---|
| 15 | }); |
|---|
| 16 | $(this).find('input[name="nb_post[]"]').each(function() { |
|---|
| 17 | nb_posts.push(this.value); |
|---|
| 18 | }); |
|---|
| 19 | |
|---|
| 20 | if (action == 'deleteuser') { |
|---|
| 21 | for (i=0; i<user_ids.length; i++) { |
|---|
| 22 | if (nb_posts[i] > 0) { |
|---|
| 23 | if (user_ids[i].checked == true) { |
|---|
| 24 | msg_cannot_delete = true; |
|---|
| 25 | user_ids[i].checked = false; |
|---|
| 26 | } |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
| 29 | if (msg_cannot_delete == true) { |
|---|
| 30 | alert(dotclear.msg.cannot_delete_users); |
|---|
| 31 | } |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | var selectfields = 0; |
|---|
| 35 | for (i=0; i<user_ids.length; i++) { |
|---|
| 36 | selectfields += user_ids[i].checked; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | if (selectfields == 0) { |
|---|
| 40 | return false; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | if (action == 'deleteuser') { |
|---|
| 44 | return window.confirm(dotclear.msg.confirm_delete_user.replace('%s',$('input[name="users[]"]:checked').size())); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | return true; |
|---|
| 48 | }); |
|---|
| 49 | }); |
|---|
Note: See
TracBrowser
for help on using the repository browser.