eventsmanager

custom attendee form

Jun 28th, 2013
274
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var em_setup_attendee_forms = function( spaces, fieldset, fieldset_container, fields_template){
  2. fieldset_container.find('input.em-date-input-loc').datepicker('destroy').attr('id', ''); //clear all datepickers
  3. fieldset_container.find('.em-time-range input.em-time-end, .em-time-range input.em-time-start').unbind(['click','focus','change']); //clear all timepickers - consequently, also other click/blur/change events, recreate the further down
  4. //get the attendee form template and clone it
  5. var form = fields_template.clone().removeClass('em-attendee-fields-template').addClass('em-attendee-fields');
  6. //add or subtract fields according to spaces
  7. var current_forms = fieldset_container.find('.em-attendee-fields');
  8. if( current_forms.length < spaces ){
  9. for( var i= current_forms.length ; i < spaces; i++ ){
  10. new_form = form.clone().appendTo(fieldset).show();
  11. new_form.html(new_form.html().replace('#NUM#',i+1));
  12. new_form.find('*[name]').each( function(it, el){
  13. el = $(el);
  14. el.attr('name', el.attr('name').replace('[%n]','['+i+']'));
  15. });
  16. }
  17. }else if( current_forms.length > spaces ){
  18. var current_forms_length = current_forms.length;
  19. for( var i= spaces; i < current_forms_length; i++ ){
  20. current_forms.last().remove();
  21. current_forms.splice(current_forms.length-1,1);
  22. }
  23. }
  24. //clean up
  25. em_setup_datepicker(fieldset_container);
  26. em_setup_timepicker(fieldset_container);
  27. form.remove();
  28. //form tooltips - delete all and recreate events
  29. var tooltip_vars = { position: { my: 'left center', at: 'right center' } };
  30. $(document).trigger('emp-qtip',[tooltip_vars]);
  31. $('.em-attendee-fields span.form-tip').each( function(it, el){
  32. el = $(el);
  33. if( el.attr('oldtitle') != '' ){
  34. el.attr('title', el.attr('oldtitle'));
  35. }
  36. el.qtip(tooltip_vars);
  37. });
  38. return true;
  39. };
  40. $('.em-booking-form p.em-tickets-spaces select.em-ticket-select').change( function(e){
  41. var el = $(this);
  42. var spaces = el.children('option:selected').val();
  43. if (spaces > 1) {
  44. var fieldset = el.closest('.em-booking-form').find('.em-attendee-fieldset');
  45. var fieldset_container = fieldset.parent();
  46. var fields_template = el.closest('.em-booking-form').find('.em-attendee-fields-template');
  47. em_setup_attendee_forms(spaces, fieldset, fieldset_container, fields_template);
  48. }
  49. });
  50. $('.em-booking-form table.em-tickets select.em-ticket-select').change( function(e){
  51. var el = $(this);
  52. var spaces = el.children('option:selected').val();
  53. var row = el.closest('tr').next();
  54. if (spaces > 1) {
  55. var fieldset = row.find('.em-attendee-fieldset');
  56. var fieldset_container = row.find('.em-attendee-fieldset').parent();
  57. var fields_template = row.find('.em-attendee-fields-template');
  58. if (spaces > 1)em_setup_attendee_forms(spaces, fieldset, fieldset_container, fields_template);
  59. }
  60. if( spaces > 0 ){
  61. row.show();
  62. }else{
  63. row.hide();
  64. }
  65. });
  66. $('.em-booking-form .em-tickets-bookings-table .em-ticket-select').change( function(e){
  67. var el = $(this);
  68. var spaces = el.val();
  69. var row = el.closest('tr').next();
  70. if (spaces > 1) {
  71. var fieldset = row.find('.em-attendee-fieldset');
  72. var fieldset_container = row.find('.em-attendee-fieldset').parent();
  73. var fields_template = row.find('.em-attendee-fields-template');
  74. em_setup_attendee_forms(spaces, fieldset, fieldset_container, fields_template);
  75. }
  76. if( spaces > 0 ){
  77. row.show();
  78. }else{
  79. row.hide();
  80. }
  81. });
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×