| 1 |
|
// $Id$ |
| 2 |
|
if (Drupal.jsEnabled) { |
| 3 |
|
// Define the selectors of the fields that needs hiding/showing |
| 4 |
|
var reply_start_date = new Array("#edit-reply-startdate-wrapper"); |
| 5 |
|
var reply_end_date = new Array("#edit-reply-enddate-wrapper"); |
| 6 |
|
$(document).ready(function () { |
| 7 |
|
|
| 8 |
|
// Show/hide those fields after page load |
| 9 |
|
rsvp_switch(reply_start_date, $("#edit-reply-startdate-option").attr("checked") ? 'show' : 'hide'); |
| 10 |
|
rsvp_switch(reply_end_date, $("#edit-reply-enddate-option").attr("checked") ? 'show' : 'hide'); |
| 11 |
|
|
| 12 |
|
// Attaching action for the "click" event |
| 13 |
|
$("#edit-reply-startdate-option").click(function () { |
| 14 |
|
rsvp_switch(reply_start_date, 'toggle'); |
| 15 |
|
}); |
| 16 |
|
$("#edit-reply-enddate-option").click(function () { |
| 17 |
|
rsvp_switch(reply_end_date, 'toggle'); |
| 18 |
|
}); |
| 19 |
|
}); |
| 20 |
|
} |
| 21 |
|
|
| 22 |
|
/** |
| 23 |
|
* Helper function needed for showing/hiding fields |
| 24 |
|
*/ |
| 25 |
|
function rsvp_switch(selectors, effect) { |
| 26 |
|
$.each(selectors, function() { |
| 27 |
|
var code = '$("' + this + '").' + effect + '();'; |
| 28 |
|
eval(code); |
| 29 |
|
}); |
| 30 |
|
} |