fe 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (402) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +4 -4
  3. data/app/assets/config/fe/manifest.js +3 -0
  4. data/app/assets/config/manifest.js +3 -0
  5. data/app/assets/javascripts/application.js.erb +1 -1
  6. data/app/assets/javascripts/fe/admin.js +0 -1
  7. data/app/assets/javascripts/fe/fe.admin.js +2 -6
  8. data/app/assets/javascripts/fe/{fe.common.js → fe.common.js.erb} +14 -7
  9. data/app/assets/javascripts/fe/fe.public.js +1 -2
  10. data/app/assets/javascripts/fe/{fe.public.nojquery.js → fe.public.nojquery.js.erb} +152 -76
  11. data/app/assets/javascripts/fe/jquery.html5_upload.js +258 -0
  12. data/app/assets/stylesheets/fe/fe.screen.css.scss.erb +22 -1
  13. data/app/assets/stylesheets/fe/validation.css +5 -1
  14. data/app/controllers/{fe/concerns → concerns/fe}/admin/question_sheets_controller_concern.rb +15 -16
  15. data/app/controllers/concerns/fe/answer_pages_controller_concern.rb +131 -0
  16. data/app/controllers/{fe/concerns → concerns/fe}/answer_sheets_controller_concern.rb +14 -6
  17. data/app/controllers/{fe/concerns → concerns/fe}/application_controller_concern.rb +3 -3
  18. data/app/controllers/fe/admin/elements_controller.rb +46 -24
  19. data/app/controllers/fe/admin/email_templates_controller.rb +5 -5
  20. data/app/controllers/fe/admin/question_pages_controller.rb +8 -8
  21. data/app/controllers/fe/reference_pages_controller.rb +11 -11
  22. data/app/controllers/fe/reference_sheets_controller.rb +4 -4
  23. data/app/controllers/fe/references_controller.rb +19 -19
  24. data/app/controllers/fe/submit_pages_controller.rb +5 -5
  25. data/app/helpers/fe/answer_pages_helper.rb +1 -1
  26. data/app/helpers/fe/application_helper.rb +3 -3
  27. data/app/jobs/fe/update_reference_sheet_visibility_job.rb +11 -0
  28. data/app/mailers/fe/notifier.rb +4 -4
  29. data/app/models/answer_sheet.rb +1 -1
  30. data/app/models/application_record.rb +3 -0
  31. data/app/models/{fe/concerns → concerns/fe}/answer_concern.rb +2 -2
  32. data/app/models/{fe/concerns → concerns/fe}/answer_pages_presenter_concern.rb +6 -5
  33. data/app/models/concerns/fe/answer_sheet_concern.rb +125 -0
  34. data/app/models/{fe/concerns → concerns/fe}/choice_field_concern.rb +41 -23
  35. data/app/models/fe/address.rb +2 -2
  36. data/app/models/fe/answer.rb +1 -1
  37. data/app/models/fe/answer_sheet.rb +1 -1
  38. data/app/models/fe/answer_sheet_question_sheet.rb +2 -2
  39. data/app/models/fe/application.rb +14 -10
  40. data/app/models/fe/condition.rb +4 -4
  41. data/app/models/fe/date_field.rb +1 -1
  42. data/app/models/fe/element.rb +126 -44
  43. data/app/models/fe/email_address.rb +2 -2
  44. data/app/models/fe/email_template.rb +1 -1
  45. data/app/models/fe/page.rb +94 -19
  46. data/app/models/fe/page_element.rb +2 -2
  47. data/app/models/fe/paragraph.rb +1 -1
  48. data/app/models/fe/person.rb +5 -5
  49. data/app/models/fe/phone_number.rb +1 -1
  50. data/app/models/fe/question.rb +62 -38
  51. data/app/models/fe/question_grid.rb +15 -3
  52. data/app/models/fe/question_set.rb +53 -13
  53. data/app/models/fe/question_sheet.rb +49 -16
  54. data/app/models/fe/reference_question.rb +9 -3
  55. data/app/models/fe/reference_sheet.rb +102 -47
  56. data/app/models/fe/state_chooser.rb +2 -2
  57. data/app/models/fe/text_field.rb +2 -2
  58. data/app/models/fe/user.rb +1 -1
  59. data/app/models/staff.rb +6 -6
  60. data/app/views/fe/admin/elements/create.js.erb +3 -3
  61. data/app/views/fe/admin/elements/destroy.js.erb +1 -1
  62. data/app/views/fe/admin/elements/drop.js.erb +1 -1
  63. data/app/views/fe/admin/elements/duplicate.js.erb +1 -1
  64. data/app/views/fe/admin/elements/edit.js.erb +1 -1
  65. data/app/views/fe/admin/elements/error.js.erb +1 -1
  66. data/app/views/fe/admin/elements/new.js.erb +13 -6
  67. data/app/views/fe/admin/elements/update.js.erb +1 -1
  68. data/app/views/fe/admin/email_templates/_form.html.erb +3 -3
  69. data/app/views/fe/admin/email_templates/edit.html.erb +3 -3
  70. data/app/views/fe/admin/email_templates/index.html.erb +3 -3
  71. data/app/views/fe/admin/email_templates/new.html.erb +3 -3
  72. data/app/views/fe/admin/panels/_advanced_options.html.erb +8 -8
  73. data/app/views/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
  74. data/app/views/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
  75. data/app/views/fe/admin/panels/_common_fields.html.erb +2 -17
  76. data/app/views/fe/admin/panels/_condition.html.erb +1 -1
  77. data/app/views/fe/admin/panels/_insert.html.erb +25 -25
  78. data/app/views/fe/admin/panels/_nav_controls.html.erb +4 -4
  79. data/app/views/fe/admin/panels/_page.html.erb +1 -1
  80. data/app/views/fe/admin/panels/_pages_list.html.erb +3 -3
  81. data/app/views/fe/admin/panels/_prop_attachment_field.html.erb +2 -2
  82. data/app/views/fe/admin/panels/_prop_choice_field.html.erb +36 -17
  83. data/app/views/fe/admin/panels/_prop_date_field.html.erb +1 -1
  84. data/app/views/fe/admin/panels/_prop_element.html.erb +5 -5
  85. data/app/views/fe/admin/panels/_prop_page.html.erb +3 -3
  86. data/app/views/fe/admin/panels/_prop_paragraph.html.erb +8 -8
  87. data/app/views/fe/admin/panels/_prop_question_grid.html.erb +7 -2
  88. data/app/views/fe/admin/panels/_prop_question_grid_with_total.html.erb +2 -2
  89. data/app/views/fe/admin/panels/_prop_reference_question.html.erb +3 -3
  90. data/app/views/fe/admin/panels/_prop_section.html.erb +1 -1
  91. data/app/views/fe/admin/panels/_prop_sheet.html.erb +3 -3
  92. data/app/views/fe/admin/panels/_prop_text_field.html.erb +12 -12
  93. data/app/views/fe/admin/question_pages/_element.html.erb +7 -7
  94. data/app/views/fe/admin/question_pages/_element_show.html.erb +2 -2
  95. data/app/views/fe/admin/question_pages/_question_page.html.erb +4 -4
  96. data/app/views/fe/admin/question_pages/create.js.erb +3 -3
  97. data/app/views/fe/admin/question_pages/destroy.js.erb +3 -3
  98. data/app/views/fe/admin/question_pages/edit.js.erb +1 -1
  99. data/app/views/fe/admin/question_pages/error.js.erb +1 -1
  100. data/app/views/fe/admin/question_pages/show.js.erb +2 -2
  101. data/app/views/fe/admin/question_pages/show_panel.js.erb +1 -1
  102. data/app/views/fe/admin/question_pages/update.js.erb +1 -1
  103. data/app/views/fe/admin/question_sheets/edit.js.erb +1 -1
  104. data/app/views/fe/admin/question_sheets/error.js.erb +1 -1
  105. data/app/views/fe/admin/question_sheets/index.html.erb +8 -8
  106. data/app/views/fe/admin/question_sheets/new.html.erb +3 -3
  107. data/app/views/fe/admin/question_sheets/show.html.erb +5 -5
  108. data/app/views/fe/admin/question_sheets/update.js.erb +1 -1
  109. data/app/views/fe/answer_pages/_answer_page.html.erb +13 -14
  110. data/app/views/fe/answer_pages/_element.html.erb +22 -2
  111. data/app/views/fe/answer_pages/_page_name.html.erb +1 -1
  112. data/app/views/fe/answer_pages/show.html.erb +39 -0
  113. data/app/views/fe/answer_pages/update.js.erb +10 -2
  114. data/app/views/fe/answer_sheets/_answer_sheet.html.erb +4 -4
  115. data/app/views/fe/answer_sheets/_element.html.erb +9 -7
  116. data/app/views/fe/answer_sheets/_incomplete.html.erb +1 -1
  117. data/app/views/fe/answer_sheets/_page_link.html.erb +9 -7
  118. data/app/views/fe/answer_sheets/_pages_list.html.erb +3 -3
  119. data/app/views/fe/answer_sheets/_submit_to.html.erb +1 -1
  120. data/app/views/fe/answer_sheets/_title.html.erb +1 -1
  121. data/app/views/fe/answer_sheets/edit.html.erb +18 -18
  122. data/app/views/fe/answer_sheets/incomplete.js.erb +7 -4
  123. data/app/views/fe/answer_sheets/index.html.erb +1 -1
  124. data/app/views/fe/answer_sheets/show.html.erb +1 -1
  125. data/app/views/fe/applications/_logout.html.erb +1 -1
  126. data/app/views/fe/questions/fe/_acceptance.html.erb +10 -9
  127. data/app/views/fe/questions/fe/_attachment_field.html.erb +129 -10
  128. data/app/views/fe/questions/fe/_checkbox_field.html.erb +18 -16
  129. data/app/views/fe/questions/fe/_country.html.erb +6 -6
  130. data/app/views/fe/questions/fe/_date_field.html.erb +5 -4
  131. data/app/views/fe/questions/fe/_date_field_mmyy.html.erb +8 -8
  132. data/app/views/fe/questions/fe/_drop_down_field.html.erb +5 -5
  133. data/app/views/fe/questions/fe/_question_grid.html.erb +10 -10
  134. data/app/views/fe/questions/fe/_question_grid_with_total.html.erb +8 -8
  135. data/app/views/fe/questions/fe/_questions.html.erb +11 -5
  136. data/app/views/fe/questions/fe/_radio_button_field.html.erb +35 -19
  137. data/app/views/fe/questions/fe/_rating.html.erb +56 -18
  138. data/app/views/fe/questions/fe/_reference_discipler.html.erb +1 -1
  139. data/app/views/fe/questions/fe/_reference_friend.html.erb +1 -1
  140. data/app/views/fe/questions/fe/_reference_parent.html.erb +1 -1
  141. data/app/views/fe/questions/fe/_reference_peer.html.erb +1 -1
  142. data/app/views/fe/questions/fe/_reference_question.html.erb +40 -24
  143. data/app/views/fe/questions/fe/_reference_roommate.html.erb +1 -1
  144. data/app/views/fe/questions/fe/_reference_spiritual.html.erb +1 -1
  145. data/app/views/fe/questions/fe/_reference_staff.html.erb +1 -1
  146. data/app/views/fe/questions/fe/_state_chooser.html.erb +6 -6
  147. data/app/views/fe/questions/fe/_text_area_field.html.erb +14 -10
  148. data/app/views/fe/questions/fe/_text_field.html.erb +7 -6
  149. data/app/views/fe/questions/fe/_yes_no.html.erb +8 -8
  150. data/app/views/fe/questions/fe/_yes_no_field.erb +11 -8
  151. data/app/views/fe/reference_pages/_reference.html.erb +12 -12
  152. data/app/views/fe/reference_pages/edit.html.erb +4 -4
  153. data/app/views/fe/reference_sheets/done.html.erb +2 -2
  154. data/app/views/fe/reference_sheets/not_found.html.erb +3 -3
  155. data/app/views/fe/references/edit.html.erb +5 -5
  156. data/app/views/fe/references/show.html.erb +3 -3
  157. data/app/views/fe/references/submit.js.erb +3 -3
  158. data/app/views/fe/submit_pages/_thankyou.html.erb +1 -1
  159. data/app/views/fe/submit_pages/edit.html.erb +9 -9
  160. data/app/views/fe/submit_pages/error.js.erb +1 -1
  161. data/app/views/fe/submit_pages/submit.js.erb +2 -2
  162. data/app/views/layouts/fe/_error_messages_for.html.erb +1 -1
  163. data/app/views/layouts/fe/application.html.erb +3 -4
  164. data/app/views/layouts/fe/fe_admin.html.erb +30 -0
  165. data/app/views.current/fe/admin/elements/_errors.html.erb +11 -0
  166. data/app/views.current/fe/admin/elements/create.js.erb +12 -0
  167. data/app/views.current/fe/admin/elements/destroy.js.erb +4 -0
  168. data/app/views.current/fe/admin/elements/drop.js.erb +3 -0
  169. data/app/views.current/fe/admin/elements/duplicate.js.erb +3 -0
  170. data/app/views.current/fe/admin/elements/edit.js.erb +4 -0
  171. data/app/views.current/fe/admin/elements/error.js.erb +4 -0
  172. data/app/views.current/fe/admin/elements/new.js.erb +17 -0
  173. data/app/views.current/fe/admin/elements/update.js.erb +9 -0
  174. data/app/views.current/fe/admin/email_templates/_form.html.erb +8 -0
  175. data/app/views.current/fe/admin/email_templates/edit.html.erb +13 -0
  176. data/app/views.current/fe/admin/email_templates/index.html.erb +20 -0
  177. data/app/views.current/fe/admin/email_templates/new.html.erb +11 -0
  178. data/app/views.current/fe/admin/panels/_advanced_options.html.erb +49 -0
  179. data/app/views.current/fe/admin/panels/_common_boolean_fields.html.erb +1 -0
  180. data/app/views.current/fe/admin/panels/_common_boolean_fields_default.html.erb +11 -0
  181. data/app/views.current/fe/admin/panels/_common_fields.html.erb +23 -0
  182. data/app/views.current/fe/admin/panels/_condition.html.erb +6 -0
  183. data/app/views.current/fe/admin/panels/_insert.html.erb +39 -0
  184. data/app/views.current/fe/admin/panels/_nav_controls.html.erb +6 -0
  185. data/app/views.current/fe/admin/panels/_page.html.erb +3 -0
  186. data/app/views.current/fe/admin/panels/_pages_list.html.erb +16 -0
  187. data/app/views.current/fe/admin/panels/_prop_attachment_field.html.erb +2 -0
  188. data/app/views.current/fe/admin/panels/_prop_choice_field.html.erb +74 -0
  189. data/app/views.current/fe/admin/panels/_prop_date_field.html.erb +7 -0
  190. data/app/views.current/fe/admin/panels/_prop_element.html.erb +23 -0
  191. data/app/views.current/fe/admin/panels/_prop_page.html.erb +26 -0
  192. data/app/views.current/fe/admin/panels/_prop_paragraph.html.erb +46 -0
  193. data/app/views.current/fe/admin/panels/_prop_question_grid.html.erb +28 -0
  194. data/app/views.current/fe/admin/panels/_prop_question_grid_with_total.html.erb +14 -0
  195. data/app/views.current/fe/admin/panels/_prop_reference_question.html.erb +12 -0
  196. data/app/views.current/fe/admin/panels/_prop_section.html.erb +8 -0
  197. data/app/views.current/fe/admin/panels/_prop_sheet.html.erb +20 -0
  198. data/app/views.current/fe/admin/panels/_prop_text_field.html.erb +20 -0
  199. data/app/views.current/fe/admin/question_pages/_element.html.erb +28 -0
  200. data/app/views.current/fe/admin/question_pages/_element_show.html.erb +10 -0
  201. data/app/views.current/fe/admin/question_pages/_errors.html.erb +10 -0
  202. data/app/views.current/fe/admin/question_pages/_question_page.html.erb +13 -0
  203. data/app/views.current/fe/admin/question_pages/create.js.erb +11 -0
  204. data/app/views.current/fe/admin/question_pages/destroy.js.erb +5 -0
  205. data/app/views.current/fe/admin/question_pages/edit.js.erb +3 -0
  206. data/app/views.current/fe/admin/question_pages/error.js.erb +4 -0
  207. data/app/views.current/fe/admin/question_pages/show.js.erb +9 -0
  208. data/app/views.current/fe/admin/question_pages/show_panel.js.erb +3 -0
  209. data/app/views.current/fe/admin/question_pages/update.js.erb +2 -0
  210. data/app/views.current/fe/admin/question_sheets/_errors.html.erb +11 -0
  211. data/app/views.current/fe/admin/question_sheets/edit.js.erb +3 -0
  212. data/app/views.current/fe/admin/question_sheets/error.js.erb +5 -0
  213. data/app/views.current/fe/admin/question_sheets/index.html.erb +41 -0
  214. data/app/views.current/fe/admin/question_sheets/new.html.erb +15 -0
  215. data/app/views.current/fe/admin/question_sheets/show.html.erb +27 -0
  216. data/app/views.current/fe/admin/question_sheets/update.js.erb +2 -0
  217. data/app/views.current/fe/answer_pages/_answer_page.html.erb +53 -0
  218. data/app/views.current/fe/answer_pages/_element.html.erb +32 -0
  219. data/app/views.current/fe/answer_pages/_page_name.html.erb +1 -0
  220. data/app/views.current/fe/answer_pages/show.html.erb +39 -0
  221. data/app/views.current/fe/answer_pages/update.js.erb +13 -0
  222. data/app/views.current/fe/answer_sheets/_answer_sheet.html.erb +26 -0
  223. data/app/views.current/fe/answer_sheets/_element.html.erb +74 -0
  224. data/app/views.current/fe/answer_sheets/_incomplete.html.erb +10 -0
  225. data/app/views.current/fe/answer_sheets/_page_link.html.erb +9 -0
  226. data/app/views.current/fe/answer_sheets/_pages_list.html.erb +11 -0
  227. data/app/views.current/fe/answer_sheets/_submit_to.html.erb +1 -0
  228. data/app/views.current/fe/answer_sheets/_title.html.erb +1 -0
  229. data/app/views.current/fe/answer_sheets/edit.html.erb +66 -0
  230. data/app/views.current/fe/answer_sheets/incomplete.js.erb +11 -0
  231. data/app/views.current/fe/answer_sheets/index.html.erb +18 -0
  232. data/app/views.current/fe/answer_sheets/send_reference_invite.js.erb +8 -0
  233. data/app/views.current/fe/answer_sheets/show.html.erb +13 -0
  234. data/app/views.current/fe/applications/_logout.html.erb +1 -0
  235. data/app/views.current/fe/applications/show.html.erb +1 -0
  236. data/app/views.current/fe/help/builder.html +33 -0
  237. data/app/views.current/fe/help/question_grid.html +18 -0
  238. data/app/views.current/fe/questions/fe/_acceptance.html.erb +14 -0
  239. data/app/views.current/fe/questions/fe/_attachment_field.html.erb +165 -0
  240. data/app/views.current/fe/questions/fe/_checkbox_field.html.erb +53 -0
  241. data/app/views.current/fe/questions/fe/_country.html.erb +7 -0
  242. data/app/views.current/fe/questions/fe/_date_field.html.erb +7 -0
  243. data/app/views.current/fe/questions/fe/_date_field_mmyy.html.erb +9 -0
  244. data/app/views.current/fe/questions/fe/_drop_down_field.html.erb +8 -0
  245. data/app/views.current/fe/questions/fe/_paragraph.html.erb +1 -0
  246. data/app/views.current/fe/questions/fe/_question_grid.html.erb +70 -0
  247. data/app/views.current/fe/questions/fe/_question_grid_with_total.html.erb +64 -0
  248. data/app/views.current/fe/questions/fe/_questions.html.erb +15 -0
  249. data/app/views.current/fe/questions/fe/_radio_button_field.html.erb +60 -0
  250. data/app/views.current/fe/questions/fe/_rating.html.erb +64 -0
  251. data/app/views.current/fe/questions/fe/_reference_discipler.html.erb +1 -0
  252. data/app/views.current/fe/questions/fe/_reference_friend.html.erb +1 -0
  253. data/app/views.current/fe/questions/fe/_reference_parent.html.erb +1 -0
  254. data/app/views.current/fe/questions/fe/_reference_peer.html.erb +1 -0
  255. data/app/views.current/fe/questions/fe/_reference_question.html.erb +61 -0
  256. data/app/views.current/fe/questions/fe/_reference_roommate.html.erb +1 -0
  257. data/app/views.current/fe/questions/fe/_reference_spiritual.html.erb +1 -0
  258. data/app/views.current/fe/questions/fe/_reference_staff.html.erb +1 -0
  259. data/app/views.current/fe/questions/fe/_section.html.erb +1 -0
  260. data/app/views.current/fe/questions/fe/_state_chooser.html.erb +7 -0
  261. data/app/views.current/fe/questions/fe/_text_area_field.html.erb +17 -0
  262. data/app/views.current/fe/questions/fe/_text_field.html.erb +9 -0
  263. data/app/views.current/fe/questions/fe/_yes_no.html.erb +17 -0
  264. data/app/views.current/fe/questions/fe/_yes_no_field.erb +20 -0
  265. data/app/views.current/fe/reference_pages/_reference.html.erb +31 -0
  266. data/app/views.current/fe/reference_pages/edit.html.erb +24 -0
  267. data/app/views.current/fe/reference_sheets/done.html.erb +2 -0
  268. data/app/views.current/fe/reference_sheets/not_found.html.erb +5 -0
  269. data/app/views.current/fe/reference_sheets/submitted.js.erb +1 -0
  270. data/app/views.current/fe/references/edit.html.erb +8 -0
  271. data/app/views.current/fe/references/send_invite.js.erb +7 -0
  272. data/app/views.current/fe/references/show.html.erb +18 -0
  273. data/app/views.current/fe/references/submit.js.erb +3 -0
  274. data/app/views.current/fe/submit_pages/_errors.html.erb +1 -0
  275. data/app/views.current/fe/submit_pages/_thankyou.html.erb +2 -0
  276. data/app/views.current/fe/submit_pages/edit.html.erb +36 -0
  277. data/app/views.current/fe/submit_pages/error.js.erb +1 -0
  278. data/app/views.current/fe/submit_pages/submit.js.erb +3 -0
  279. data/app/views.current/layouts/fe/_error_messages_for.html.erb +7 -0
  280. data/app/views.current/layouts/fe/application.html.erb +47 -0
  281. data/app/{views/layouts/fe/fe.admin.html.erb → views.current/layouts/fe/fe_admin.html.erb} +4 -4
  282. data/config/initializers/paper_trail.rb +3 -0
  283. data/config/routes.rb +3 -1
  284. data/db/migrate/20131003041856_core.rb +23 -23
  285. data/db/migrate/20131003044250_create_reference_sheets.rb +1 -1
  286. data/db/migrate/20131003044436_add_element_and_answer_fields.rb +3 -3
  287. data/db/migrate/20131003044518_create_email_templates.rb +2 -2
  288. data/db/migrate/20131003044621_add_max_lengths.rb +1 -1
  289. data/db/migrate/20131003044714_create_join_table.rb +1 -1
  290. data/db/migrate/20131016162128_remove_question_id_from_element.rb +1 -1
  291. data/db/migrate/20140623153424_create_fe_people.rb +1 -1
  292. data/db/migrate/20140624180246_create_fe_addresses.rb +1 -1
  293. data/db/migrate/20140624182216_create_fe_phone_numbers.rb +1 -1
  294. data/db/migrate/20140625160545_create_fe_users.rb +1 -1
  295. data/db/migrate/20140808202507_add_conditional_type_to_elements.rb +1 -1
  296. data/db/migrate/20140808203609_add_conditional_answer_to_elements.rb +1 -1
  297. data/db/migrate/20141103204704_remove_short_value_column.rb +1 -1
  298. data/db/migrate/20141109154522_move_conditional_ids_used_for_choice_field_to_their_own_column.rb +1 -1
  299. data/db/migrate/20150504221439_add_all_element_ids_to_pages.rb +1 -1
  300. data/db/migrate/20150713022326_add_locale_columns.rb +1 -1
  301. data/db/migrate/20150714220730_add_locale_to_answer_sheet.rb +1 -1
  302. data/db/migrate/20150925181652_add_share_to_elements.rb +5 -0
  303. data/db/migrate/20150928085325_change_pages_all_element_ids_to_text.rb +1 -1
  304. data/db/migrate/20150930191538_add_locale_to_reference_sheets.rb +1 -1
  305. data/db/migrate/20151021181928_switch_conditional_answer_separator_to_semicolon.rb +7 -0
  306. data/db/migrate/20151021184250_add_question_sheet_id_in_refs.rb +12 -0
  307. data/db/migrate/20160201185838_add_visible_and_visibility_cache_key_to_reference_sheets.rb +6 -0
  308. data/db/migrate/20160805221415_add_rating_extra_labels.rb +10 -0
  309. data/db/migrate/20181108201746_create_versions.rb +80 -0
  310. data/db/migrate/20181218201130_increase_slug_length.rb +5 -0
  311. data/lib/fe/engine.rb +10 -10
  312. data/lib/fe/version.rb +1 -1
  313. data/lib/fe.rb +7 -1
  314. data/spec/controllers/fe/admin/elements_controller_spec.rb +30 -20
  315. data/spec/controllers/fe/admin/email_templates_controller_spec.rb +2 -2
  316. data/spec/controllers/fe/admin/question_pages_controller_spec.rb +1 -1
  317. data/spec/controllers/fe/admin/question_sheets_controller_spec.rb +4 -4
  318. data/spec/controllers/fe/answer_pages_controller_spec.rb +86 -30
  319. data/spec/controllers/fe/answer_sheets_controller_spec.rb +65 -9
  320. data/spec/dummy/app/assets/config/manifest.js +0 -0
  321. data/spec/dummy/app/models/user.rb +1 -1
  322. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  323. data/spec/dummy/config/application.rb +1 -0
  324. data/spec/dummy/config/environments/test.rb +3 -3
  325. data/spec/dummy/config/initializers/assets.rb +5 -2
  326. data/spec/dummy/config/initializers/fast_gettext.rb +1 -1
  327. data/spec/dummy/config/initializers/to_unsafe_h.rb +5 -0
  328. data/spec/dummy/config/initializers/to_unsafe_h.rb.new +5 -0
  329. data/spec/dummy/db/migrate/20141203214017_core.fe_engine.rb +23 -23
  330. data/spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb +1 -1
  331. data/spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb +3 -3
  332. data/spec/dummy/db/migrate/20141203214020_create_email_templates.fe_engine.rb +2 -2
  333. data/spec/dummy/db/migrate/20141203214021_add_max_lengths.fe_engine.rb +1 -1
  334. data/spec/dummy/db/migrate/20141203214022_create_join_table.fe_engine.rb +1 -1
  335. data/spec/dummy/db/migrate/20141203214023_remove_question_id_from_element.fe_engine.rb +1 -1
  336. data/spec/dummy/db/migrate/20141203214024_create_fe_people.fe_engine.rb +1 -1
  337. data/spec/dummy/db/migrate/20141203214025_create_fe_addresses.fe_engine.rb +1 -1
  338. data/spec/dummy/db/migrate/20141203214027_create_fe_users.fe_engine.rb +1 -1
  339. data/spec/dummy/db/migrate/20141203214028_add_conditional_type_to_elements.fe_engine.rb +1 -1
  340. data/spec/dummy/db/migrate/20141203214029_add_conditional_answer_to_elements.fe_engine.rb +1 -1
  341. data/spec/dummy/db/migrate/20141203214030_remove_short_value_column.fe_engine.rb +1 -1
  342. data/spec/dummy/db/migrate/20141203214031_move_conditional_ids_used_for_choice_field_to_their_own_column.fe_engine.rb +1 -1
  343. data/spec/dummy/db/migrate/20150123215803_create_users.rb +1 -1
  344. data/spec/dummy/db/migrate/20150504222619_add_all_element_ids_to_pages.fe_engine.rb +1 -1
  345. data/spec/dummy/db/migrate/20150925192557_add_share_to_elements.fe_engine.rb +6 -0
  346. data/spec/dummy/db/migrate/20150930190001_create_fe_phone_numbers.fe_engine.rb +1 -1
  347. data/spec/dummy/db/migrate/20150930190002_add_locale_columns.fe_engine.rb +1 -1
  348. data/spec/dummy/db/migrate/20150930190003_add_locale_to_answer_sheet.fe_engine.rb +1 -1
  349. data/spec/dummy/db/migrate/20150930190004_change_pages_all_element_ids_to_text.fe_engine.rb +1 -1
  350. data/spec/dummy/db/migrate/20150930191756_add_locale_to_reference_sheets.fe_engine.rb +1 -1
  351. data/spec/dummy/db/migrate/20151021190027_add_question_sheet_id_in_refs.fe_engine.rb +13 -0
  352. data/spec/dummy/db/migrate/20160204164612_switch_conditional_answer_separator_to_semicolon.fe_engine.rb +8 -0
  353. data/spec/dummy/db/migrate/20160204164613_add_visible_and_visibility_cache_key_to_reference_sheets.fe_engine.rb +7 -0
  354. data/spec/dummy/db/migrate/20181108201746_create_versions.rb +80 -0
  355. data/spec/dummy/db/schema.rb +71 -79
  356. data/spec/dummy/log/test.log +101278 -419
  357. data/spec/factories/answer_sheet_question_sheets.rb +1 -1
  358. data/spec/factories/answer_sheets.rb +2 -2
  359. data/spec/factories/answers.rb +1 -1
  360. data/spec/factories/applications.rb +3 -3
  361. data/spec/factories/dummy_applications.rb +3 -3
  362. data/spec/factories/dummy_people.rb +3 -3
  363. data/spec/factories/dummy_users.rb +3 -3
  364. data/spec/factories/elements.rb +21 -21
  365. data/spec/factories/email_templates.rb +3 -3
  366. data/spec/factories/fe_addresses.rb +10 -10
  367. data/spec/factories/fe_email_addresses.rb +3 -3
  368. data/spec/factories/fe_email_templates.rb +4 -4
  369. data/spec/factories/fe_people.rb +5 -5
  370. data/spec/factories/fe_phone_numbers.rb +3 -3
  371. data/spec/factories/fe_user.rb +3 -3
  372. data/spec/factories/page.rb +1 -1
  373. data/spec/factories/page_elements.rb +1 -1
  374. data/spec/factories/paragraphs.rb +1 -1
  375. data/spec/factories/question_sheet.rb +2 -2
  376. data/spec/factories/reference_questions.rb +1 -1
  377. data/spec/factories/reference_sheets.rb +1 -1
  378. data/spec/jobs/fe/update_reference_sheet_visibility_job_spec.rb +40 -0
  379. data/spec/models/fe/answer_sheet_question_sheet_spec.rb +1 -1
  380. data/spec/models/fe/answer_spec.rb +2 -2
  381. data/spec/models/fe/application_spec.rb +94 -1
  382. data/spec/models/fe/choice_field_spec.rb +47 -1
  383. data/spec/models/fe/condition_spec.rb +2 -2
  384. data/spec/models/fe/element_spec.rb +252 -60
  385. data/spec/models/fe/email_template_spec.rb +1 -1
  386. data/spec/models/fe/page_element_spec.rb +1 -1
  387. data/spec/models/fe/page_spec.rb +57 -12
  388. data/spec/models/fe/person_spec.rb +1 -1
  389. data/spec/models/fe/question_set_spec.rb +91 -0
  390. data/spec/models/fe/question_sheet_spec.rb +11 -15
  391. data/spec/models/fe/question_spec.rb +73 -6
  392. data/spec/models/fe/reference_question_spec.rb +20 -0
  393. data/spec/models/fe/reference_sheet_spec.rb +287 -4
  394. data/spec/models/fe/text_field_spec.rb +22 -0
  395. data/spec/rails_helper.rb +79 -76
  396. metadata +195 -57
  397. data/app/assets/javascripts/fe/jquery.scrollTo-min.js +0 -7
  398. data/app/controllers/fe/concerns/answer_pages_controller_concern.rb +0 -84
  399. data/app/models/fe/concerns/answer_sheet_concern.rb +0 -85
  400. data/spec/dummy/db/migrate/20141203214026_create_create_fe_phone_numbers.fe_engine.rb +0 -17
  401. data/spec/dummy/log/development.log +0 -5
  402. /data/app/{assets/stylesheets/360front.css → views.current/fe/admin/elements/reorder.js.erb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7be29ca99d6897702864247f44659b07068b917d
4
- data.tar.gz: 3a4b5b1401e357ca9b4fdd5a9d65c49083fbda89
2
+ SHA256:
3
+ metadata.gz: ceba5cafab0cf4095c3db104e3a8ace2d7ff8630b2bd725ebb8c719f4a172136
4
+ data.tar.gz: 476961619c8eeda0570e596345f4383c2a21a22d54a819459969bf170c83c9a8
5
5
  SHA512:
6
- metadata.gz: f480268cc6bac72b46ff5e19debbd5114997f39cba51f48e57972b84fae257e3ad7289c6af4c890f7a159dedb97f88d1c98c6828e1286f1e23a83f7d289668ac
7
- data.tar.gz: ffa4819032a0495515a75d28e83bb2bc3e6d26615046b26fd4a6fd10bc90fb3e35c9984792d912e11c7e9a3a9e3e3639a86a9fa41f2686e1ee32d6b4a7d3694e
6
+ metadata.gz: 345b88e2ab3d74555c19adbf7256c1aa6f40bcfe76e9b99b64a02467e9633dbaceac84956193207336ed7cfce71cd67eeb3fb0f544be35841d2c221af3d49a62
7
+ data.tar.gz: 68e3f1a303ae918bdb3a82b4825f4231cab11a514e4db48b6c3b747485ba943fbcbee26ceb25bfe7771f5ce696fea50854b9b0f3b1c4101598ceb7d89dfc5906
data/README.md CHANGED
@@ -8,17 +8,17 @@ This project rocks and uses MIT-LICENSE.
8
8
 
9
9
  ### Testing
10
10
 
11
- Setup a testing environment that mimics the Travis CI setup:
11
+ Setup the testing db
12
12
 
13
- rake setup_dummy_app
13
+ bundle exec rake setup_db
14
14
 
15
15
  Run specs:
16
16
 
17
- rake spec
17
+ bundle exec rake spec
18
18
 
19
19
  Run a specific spec:
20
20
 
21
- ruby -I$GEM_HOME/gems/rspec-core-3.0.2/lib:$GEM_HOME/gems/rspec-support-3.0.2/lib -S -I fe/spec rspec spec/models/fe/element_spec.rb
21
+ bundle exec rspec spec/models/fe/element_spec.rb
22
22
 
23
23
  ### Example enclosing app
24
24
 
@@ -0,0 +1,3 @@
1
+ //= link_tree ../../images
2
+ //= link_directory ../../javascripts/fe .js
3
+ //= link_tree ../../stylesheets
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_tree ../javascripts
3
+ //= link_tree ../stylesheets
@@ -1 +1 @@
1
- //= require fe.public.js
1
+ //= require fe/fe.public.js
@@ -1,3 +1,2 @@
1
1
  //= require fe/fe.common.js
2
2
  //= require fe/fe.admin.js
3
- //= require fe/jquery.scrollTo-min.js
@@ -118,18 +118,14 @@ function snapElementProperties(el) {
118
118
  $('#panel-properties-element').css({'margin-top': propsTop});
119
119
  }
120
120
 
121
- function scrollToElement(id) {
122
- $(id).scrollTo();
123
- }
124
-
125
121
  function addError(id) {
126
122
  $('#' + id).addClassName('fieldWithErrors');
127
123
  }
128
124
 
129
125
  // convert label to slug
130
126
  function updateSlug(source, dest) {
131
- label = $F(source)
132
- slug = $F(dest)
127
+ label = $(source).val();
128
+ slug = $(dest).val();
133
129
  if( label == null || slug == null) return; // oh oh
134
130
 
135
131
  label = label.strip();
@@ -57,12 +57,12 @@ function setUpSortables() {
57
57
  }
58
58
 
59
59
  function setUpCalendars() {
60
- now = new Date();
61
- year = now.getFullYear() + 10;
62
- $('[data-calendar]').datepicker({
60
+ now = new Date();
61
+ year = now.getFullYear() + 10;
62
+ $('[data-calendar]').datepicker({
63
63
  changeYear:true,
64
- yearRange: '1950:' + year,
65
- dateFormat: 'yy-mm-dd'
64
+ yearRange: '1950:' + year,
65
+ dateFormat: '<%= Fe.date_format %>'
66
66
  })
67
67
  }
68
68
 
@@ -75,8 +75,8 @@ function setUpJsHelpers() {
75
75
  // ==================
76
76
  // Calendar
77
77
  setUpCalendars();
78
- // ==================
79
- $(".tip[title], a[title]").tooltip()
78
+ // ==================
79
+ <% unless Fe.bootstrap %>$(".tip[title], a[title]").tooltip()<% end %>
80
80
  }
81
81
 
82
82
  function fixGridColumnWidths() {
@@ -89,3 +89,10 @@ function fixGridColumnWidths() {
89
89
  }
90
90
  });
91
91
  };
92
+
93
+ function scrollTo(el) {
94
+ if ($(el).length == 0) { return; }
95
+ $('html, body').animate({
96
+ scrollTop: $(el).offset().top
97
+ }, 1000);
98
+ }
@@ -1,6 +1,5 @@
1
1
  //= require jquery
2
- //= require jquery_ujs
2
+ //= require rails-ujs
3
3
  //= require jquery-ui
4
- //= require fe/jquery.scrollTo-min.js
5
4
  //= require fe/jquery.validate.pack.js
6
5
  //= require fe/fe.public.nojquery.js
@@ -3,47 +3,66 @@
3
3
  // used by answer sheets
4
4
 
5
5
  (function($) {
6
- //debugger;
7
- $(function() {
6
+ <% if Fe.bootstrap %>
7
+ // http://stackoverflow.com/questions/18754020/bootstrap-3-with-jquery-validation-plugin
8
+ $.validator.setDefaults({
9
+ errorElement: "span",
10
+ errorClass: "help-block",
11
+ highlight: function (element, errorClass, validClass) {
12
+ $(element).closest('.form-group').addClass('has-error');
13
+ },
14
+ unhighlight: function (element, errorClass, validClass) {
15
+ $(element).closest('.form-group').removeClass('has-error');
16
+ },
17
+ errorPlacement: function (error, element) {
18
+ if (element.parent('.input-group').length || element.prop('type') === 'checkbox' || element.prop('type') === 'radio') {
19
+ error.appendTo(element.closest('div:not(.field'));
20
+ } else {
21
+ error.insertAfter(element);
22
+ }
23
+ }
24
+ });
25
+ <% end %>
8
26
 
9
- $(document).on('click', '.save_button', function() {
10
- $.fe.pageHandler.savePage($(this).closest('.answer-page'), true);
11
- });
27
+ $(document).on('click', '.save_button', function() {
28
+ fe.pageHandler.savePage($(this).closest('.answer-page'), true);
29
+ });
12
30
 
13
- $(document).on('click', '.reference_send_invite', function() {
14
- var el = this;
15
- var data = $(el).closest('form').serializeArray();
16
-
17
- data.push({name: 'answer_sheet_type', value: answer_sheet_type});
18
- $.ajax({url: $(el).attr('href'), data: data, dataType: 'script', type: 'POST',
19
- beforeSend: function (xhr) {
20
- $('body').trigger('ajax:loading', xhr);
21
- },
22
- complete: function (xhr) {
23
- $('body').trigger('ajax:complete', xhr);
24
- },
25
- error: function (xhr, status, error) {
26
- $('body').trigger('ajax:failure', [xhr, status, error]);
27
- }
28
- });
29
- return false;
30
- });
31
- $(document).on('focus', 'textarea[maxlength]', function() {
32
- var max = parseInt($(this).attr('maxlength'));
33
- $(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
34
- }).on('keyup', 'textarea[maxlength]', function(){
35
- var max = parseInt($(this).attr('maxlength'));
36
- if($(this).val().length > max){
37
- $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
38
- }
39
- $(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
40
- }).on('blur', 'textarea[maxlength]', function() {
41
- $(this).parent().find('.charsRemaining').html('');
31
+ $(document).on('click', '.reference_send_invite', function() {
32
+ var el = this;
33
+ var form_elements = $(el).closest('form').find('input:not(.dont_submit), textarea:not(.dont_submit), select:not(.dont_submit)');
34
+ var data = form_elements.serializeArray();
35
+
36
+ data.push({name: 'answer_sheet_type', value: answer_sheet_type});
37
+ $.ajax({url: $(el).attr('href'), data: data, dataType: 'script', type: 'POST',
38
+ beforeSend: function (xhr) {
39
+ $('body').trigger('ajax:loading', xhr);
40
+ },
41
+ complete: function (xhr) {
42
+ $('body').trigger('ajax:complete', xhr);
43
+ },
44
+ error: function (xhr, status, error) {
45
+ $('body').trigger('ajax:failure', [xhr, status, error]);
46
+ }
42
47
  });
48
+ return false;
49
+ });
50
+ $(document).on('focus', 'textarea[maxlength]', function() {
51
+ var max = parseInt($(this).attr('maxlength'));
52
+ $(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
53
+ }).on('keyup', 'textarea[maxlength]', function(){
54
+ var max = parseInt($(this).attr('maxlength'));
55
+ if($(this).val().length > max){
56
+ $(this).val($(this).val().substr(0, $(this).attr('maxlength')));
57
+ }
58
+ $(this).parent().find('.charsRemaining').html('You have ' + (max - $(this).val().length) + ' characters remaining');
59
+ }).on('blur', 'textarea[maxlength]', function() {
60
+ $(this).parent().find('.charsRemaining').html('');
43
61
  });
44
62
 
45
- $.fe = {};
46
- $.fe.pageHandler = {
63
+ window.fe = {};
64
+ fe.pageHandler = {
65
+
47
66
  initialize : function(page) {
48
67
  this.auto_save_frequency = 30; // seconds
49
68
  this.timer_id = null;
@@ -69,8 +88,8 @@
69
88
 
70
89
  // HACK: Need to clear the main error message when returning to the submit page
71
90
  // It is very confusing to users to be there when they revisit the page
72
- if ((page=='submit_page') && ($('#submit_message')[0] != null)) $('#submit_message').hide();
73
- if ((page=='submit_page') && ($('#application_errors')[0] != null)) $('#application_errors').html('');
91
+ $('#submit_message, .submit_message').hide();
92
+ $('#application_errors, .application_errors').html('');
74
93
 
75
94
  // show the new
76
95
  // $('#' + page + '-li').removeClass('incomplete');
@@ -86,7 +105,7 @@
86
105
  // callback onSuccess
87
106
  pageLoadedBackground : function(response, textStatus, jqXHR) {
88
107
  //this.pageLoaded(response, textStatus, jqXHR, true)
89
- $.fe.pageHandler.pageLoaded(response, textStatus, jqXHR, true)
108
+ fe.pageHandler.pageLoaded(response, textStatus, jqXHR, true)
90
109
  },
91
110
 
92
111
  // callback onSuccess
@@ -98,17 +117,20 @@
98
117
  if( match != null )
99
118
  {
100
119
  var page = match[1];
101
- if ($('#'+page).length > 0) {
120
+ if (response.match(/<html/)) {
121
+ alert("There was a problem loading that page. To work on other pages, please refresh the website.");
122
+ document.location = document.location;
123
+ } else if ($('#'+page).length > 0) {
102
124
  $('#'+page).replaceWith(response);
103
125
  } else {
104
126
  $('#preview').append(response);
105
127
  }
106
128
 
107
- if (!background_load) { $.fe.pageHandler.showPage(page); } // show after load, unless loading in background
129
+ if (!background_load) { fe.pageHandler.showPage(page); } // show after load, unless loading in background
108
130
  setUpJsHelpers();
109
- $.fe.pageHandler.enableValidation(page);
110
- if (background_load) { $.fe.pageHandler.validatePage(page, true); }
111
- $('#' + page).data('form_data', $.fe.pageHandler.captureForm($('#' + page)));
131
+ fe.pageHandler.enableValidation(page);
132
+ if (background_load) { fe.pageHandler.validatePage(page, true); }
133
+ $('#' + page).data('form_data', fe.pageHandler.captureForm($('#' + page)));
112
134
  }
113
135
  $('#page_ajax_spinner').hide();
114
136
  $('.reference_send_invite').button();
@@ -116,33 +138,51 @@
116
138
  $(document).trigger('fePageLoaded'); // allow other code to handle page load event by using $(document).on('fePageLoaded', function() { ... });
117
139
  },
118
140
 
119
- loadPage : function(page, url, background_load) {
141
+ loadPage : function(page, url, background_load, validate_current_page) {
120
142
  background_load = typeof background_load !== 'undefined' ? background_load : false;
143
+ validate_current_page = typeof validate_current_page !== 'undefined' ? validate_current_page : true;
144
+
145
+ if (validate_current_page) {
146
+ isValid = this.validatePage(this.current_page); // mark current page as valid (or not) as we're leaving
147
+ } else {
148
+ isValid = true
149
+ }
150
+
151
+ // Provide a way for enclosing apps to not go to the next page until the current page is valid
152
+ // They can do that with this:
153
+ //
154
+ // $(document).on 'fePageLoaded', (evt, page) ->
155
+ // $(".page > form").addClass('enforce-valid-before-next');
156
+ //
157
+ if (!isValid && $('#' + this.current_page + "-form").hasClass('enforce-valid-before-next')) {
158
+ // scroll up to where the error is
159
+ scrollTo($(".help-block:visible")[0].closest("li"));
160
+ return;
161
+ }
121
162
 
122
163
  this.unregisterAutoSave(); // don't auto-save while loading/saving
123
164
  // will register auto-save on new page once loaded/shown
124
165
 
125
- this.validatePage(this.current_page); // mark current page as valid (or not) as we're leaving
126
166
  this.savePage();
127
167
 
128
168
  if (!background_load) {
129
169
  if ($('a[name="main"]').length == 1) {
130
- $.scrollTo('a[name="main"]');
170
+ scrollTo('a[name="main"]');
131
171
  } else {
132
- $.scrollTo('#main');
172
+ scrollTo('#main');
133
173
  }
134
174
  }
135
175
 
136
- if ($.fe.pageHandler.isPageLoaded(page) && page.match('no_cache') == null) {
176
+ if (fe.pageHandler.isPageLoaded(page) && page.match('no_cache') == null) {
137
177
  // if already loaded (element exists) excluding pages that need reloading
138
- if (!background_load) { $.fe.pageHandler.showPage(page); }
178
+ if (!background_load) { fe.pageHandler.showPage(page); }
139
179
  $('#page_ajax_spinner').hide();
140
180
  } else {
141
181
  $.ajax({
142
182
  url: url,
143
183
  type: 'GET',
144
184
  data: {'answer_sheet_type':answer_sheet_type},
145
- success: background_load ? $.fe.pageHandler.pageLoadedBackground : $.fe.pageHandler.pageLoaded,
185
+ success: background_load ? fe.pageHandler.pageLoadedBackground : fe.pageHandler.pageLoaded,
146
186
  error: function (xhr, status, error) {
147
187
  alert("There was a problem loading that page. We've been notified and will fix it as soon as possible. To work on other pages, please refresh the website.");
148
188
  document.location = document.location;
@@ -158,8 +198,11 @@
158
198
  },
159
199
 
160
200
  // save form if any changes were made
161
- savePage : function(page, force) {
201
+ savePage : function(page, force, blocking) {
202
+
162
203
  if (page == null) page = $('#' + this.current_page);
204
+ if (typeof blocking == "undefined") blocking = false;
205
+
163
206
  // don't save more than once per second
164
207
  timeNow = new Date();
165
208
  if (typeof(lastSave) != "undefined" && lastSave && !force && (timeNow - lastSave < 1000)) {
@@ -180,6 +223,7 @@
180
223
  success: function (xhr) {
181
224
  page.data('save_fails', 0)
182
225
  },
226
+ async: !blocking,
183
227
  error: function() {
184
228
  save_fails = page.data('save_fails') == null ? 0 : page.data('save_fails');
185
229
  save_fails += 1;
@@ -201,7 +245,7 @@
201
245
  },
202
246
 
203
247
  savePages : function(force) {
204
- $('.answer-page').each(function() {$.fe.pageHandler.savePage(null, force)})
248
+ $('.answer-page').each(function() {fe.pageHandler.savePage(null, force)})
205
249
  },
206
250
 
207
251
  // setup a timer to auto-save (only one timer, for the page being viewed)
@@ -221,21 +265,36 @@
221
265
  captureForm : function(page) {
222
266
  form_el = $('#' + page.attr('id') + '-form');
223
267
  if( form_el[0] == null ) return null;
224
- return {url: form_el.attr('action'), data: form_el.serialize() + '&answer_sheet_type=' + answer_sheet_type};
268
+ form_all_el = form_el.find("input:not(.dont_submit), textarea:not(.dont_submit), select:not(.dont_submit)");
269
+ return {url: form_el.attr('action'), data: form_all_el.serialize() + '&answer_sheet_type=' + answer_sheet_type};
225
270
  },
226
271
 
227
272
 
228
273
  // enable form validation (when form is loaded)
229
274
  enableValidation : function(page) {
230
- $('#' + page + '-form').validate({onsubmit:false, focusInvalid:true, onfocusout: function(element) { this.element(element);}});
231
- $('#' + page + '-form :input').change(function() {
232
- $.fe.pageHandler.validatePage(page, true);
275
+ // Provide a way for enclosing apps to not have validation continually as people fill things out
276
+ // They can do that with this:
277
+ //
278
+ // $(document).on 'fePageLoaded', (evt, page) ->
279
+ // $(".page > form").addClass('no-ongoing-validation');
280
+ //
281
+ $('#' + page + '-form:not(.no-ongoing-validation)').validate({onsubmit:false, focusInvalid:true, onfocusout: function(element) { this.element(element);}});
282
+ $('#' + page + '-form:not(.no-ongoing-validation):input').change(function() {
283
+ fe.pageHandler.validatePage(page, true);
233
284
  });
234
285
  },
235
286
 
236
287
  validatePage : function(page, page_classes_only) {
237
288
  page_classes_only = typeof page_classes_only !== 'undefined' ? page_classes_only : false;
238
289
 
290
+ // Provide a way for enclosing apps to never validate a form
291
+ // They can do that with this:
292
+ //
293
+ // $(document).on 'fePageLoaded', (evt, page) ->
294
+ // $(".page > form").addClass('no-validation');
295
+ //
296
+ if ($('#' + this.current_page + "-form").hasClass('no-validation')) { return; }
297
+
239
298
  try {
240
299
  var li = $('#' + page + '-li');
241
300
  var form = $('#' + page + '-form');
@@ -273,12 +332,12 @@
273
332
  // callback when falls to 0 active Ajax requests
274
333
  completeAll : function()
275
334
  {
276
- $('#submit_button').attr('disabled', true)
277
- $('#submit_message').html('');
278
- $('#submit_message').hide();
335
+ $('.page:visible #submit_button').attr('disabled', true)
336
+ $('#submit_message, .submit_message').html('');
337
+ $('#submit_message, .submit_message').hide();
279
338
  // validate all the pages
280
339
  $('.page_link').each(function(index, page) {
281
- $.fe.pageHandler.validatePage($(page).attr('data-page-id'));
340
+ fe.pageHandler.validatePage($(page).attr('data-page-id'));
282
341
  });
283
342
  var all_valid = ($('#list-pages li.incomplete').length == 0);
284
343
 
@@ -288,7 +347,8 @@
288
347
 
289
348
  if( payments_made)
290
349
  {
291
- this.savePage($('#' + $.fe.pageHandler.current_page)); // in case any input fields on submit_page
350
+ // force an async save (so it finishes before submitting) in case any input fields on submit_page
351
+ this.savePage(null, true, true);
292
352
 
293
353
  // submit the application
294
354
  if($('#submit_to')[0] != null)
@@ -296,7 +356,7 @@
296
356
  url = $('#submit_to').val();
297
357
  // clear out pages array to force reload. This enables "frozen" apps
298
358
  // immediately after submission - :onSuccess (for USCM which stays in the application vs. redirecting to the dashboard)
299
- var curr = $.fe.pageHandler.current_page;
359
+ var curr = fe.pageHandler.current_page;
300
360
  $.ajax({url: url, dataType:'script',
301
361
  data: {answer_sheet_type: answer_sheet_type, a: $('input[type=hidden][name=a]').val()},
302
362
  type:'post',
@@ -319,8 +379,8 @@
319
379
  else
320
380
  {
321
381
  // some pages aren't valid
322
- $('#submit_message').html("Please make a payment");
323
- $('#submit_message').show();
382
+ $('#submit_message, .submit_message').html("Please make a payment");
383
+ $('#submit_message, .submit_message').show();
324
384
 
325
385
  var btn = $('#submit_button'); if (btn) { btn.attr('disabled', false); }
326
386
  }
@@ -333,8 +393,8 @@
333
393
  },
334
394
 
335
395
  checkConditional : function($element) {
336
- matchable_answers = String($element.data('conditional_answer')).split(',').map(function(s) { return s.trim(); })
337
- if ($element.hasClass('fe_choicefield') && $element.hasClass('style_yes-no')) {
396
+ matchable_answers = String($element.data('conditional_answer')).split(';').map(function(s) { return s.trim(); })
397
+ if ($element.hasClass('fe_choicefield') && ($element.hasClass('style_yes-no') || $element.hasClass('yes-no'))) {
338
398
  if ($(matchable_answers).filter([1, '1', true, 'true', 'yes', 'Yes']).length > 0) {
339
399
  matchable_answers = [1, '1', true, 'true', 'yes', 'Yes'];
340
400
  }
@@ -344,6 +404,8 @@
344
404
  vals = $([$element.find("input[type=radio]:checked").val()]);
345
405
  } else if ($element.hasClass('fe_choicefield') && $element.hasClass('checkbox')) {
346
406
  vals = $element.find("input[type=checkbox]:checked").map(function(i, el) { return $(el).val(); });
407
+ } else if ($element.hasClass('fe_choicefield') && $element.hasClass('radio')) {
408
+ vals = $([$element.find("input[type=radio]:checked").val()]);
347
409
  } else {
348
410
  vals = $([$element.find("input:visible, select:visible").val()]);
349
411
  }
@@ -361,6 +423,7 @@
361
423
  prefix = $element.data('answer_sheet_id_prefix');
362
424
  pg = prefix + '_' + $element.data('application_id') + '-fe_page_' + $element.data('conditional_id');
363
425
  li_id = 'li#'+pg+'-li';
426
+ li_id += ', li#'+pg+'-no_cache-li';
364
427
 
365
428
  if (match) {
366
429
  $(li_id).show();
@@ -373,9 +436,11 @@
373
436
  }
374
437
  },
375
438
 
376
- next : function() {
377
- curr_page_link = $('#'+$.fe.pageHandler.current_page+"-link");
378
- //$.fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
439
+ next : function(validate_current_page) {
440
+ validate_current_page = typeof validate_current_page !== 'undefined' ? validate_current_page : false;
441
+
442
+ curr_page_link = $('#'+fe.pageHandler.current_page+"-link");
443
+ //fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
379
444
  page_link = curr_page_link
380
445
  .parents('.application_section')
381
446
  .nextAll()
@@ -383,12 +448,12 @@
383
448
  .first()
384
449
  .find('a.page_link');
385
450
  $(".answer-page:visible div.buttons button").prop("disabled", true)
386
- $.fe.pageHandler.loadPage(page_link.data('page-id'), page_link.attr('href'));
451
+ fe.pageHandler.loadPage(page_link.data('page-id'), page_link.attr('href'), false, validate_current_page);
387
452
  },
388
453
 
389
454
  prev : function() {
390
- curr_page_link = $('#'+$.fe.pageHandler.current_page+"-link");
391
- //$.fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
455
+ curr_page_link = $('#'+fe.pageHandler.current_page+"-link");
456
+ //fe.pageHandler.loadPage('application_22544-fe_page_165-no_cache','/fe/answer_sheets/22544/page/165/edit'); return false;
392
457
  page_link = curr_page_link
393
458
  .parents('.application_section')
394
459
  .prevAll()
@@ -396,13 +461,13 @@
396
461
  .first()
397
462
  .find('a.page_link');
398
463
  $(".answer-page:visible div.buttons button").prop("disabled", true)
399
- $.fe.pageHandler.loadPage(page_link.data('page-id'), page_link.attr('href'));
464
+ fe.pageHandler.loadPage(page_link.data('page-id'), page_link.attr('href'));
400
465
  }
401
466
 
402
467
  };
403
468
 
404
469
  $(document).on('click', ".conditional input, .conditional select", function() {
405
- $.fe.pageHandler.checkConditional($(this).closest('.conditional'));
470
+ fe.pageHandler.checkConditional($(this).closest('.conditional'));
406
471
  });
407
472
  $(document).on('keyup', ".conditional input, .conditional select", function() { $(this).click(); });
408
473
  $(document).on('blug', ".conditional input, .conditional select", function() { $(this).click(); });
@@ -413,6 +478,10 @@
413
478
  remaining = maxlength - $(this).val().length;
414
479
  $('#'+$(this).attr('id')+'_count').val(remaining);
415
480
  });
481
+
482
+ $(document).on('click', 'a[disabled]', function(event) {
483
+ event.preventDefault();
484
+ });
416
485
  })(jQuery);
417
486
 
418
487
  $(function() {
@@ -425,7 +494,7 @@ function updateTotal(id) {
425
494
  try {
426
495
  total = 0;
427
496
  $(".col_" + id).each(function(index, el) {
428
- total += Number($(el).val());
497
+ total += Number($(el).val().replace(',',''));
429
498
  });
430
499
  $('#total_' + id).val(total).trigger('totalChanged');
431
500
  } catch(e) {
@@ -448,3 +517,10 @@ function submitToFrame(id, url) {
448
517
  form.submit();
449
518
  return false
450
519
  }
520
+
521
+ function scrollTo(el) {
522
+ if ($(el).length == 0) { return; }
523
+ $('html, body').animate({
524
+ scrollTop: $(el).offset().top
525
+ }, 1000);
526
+ }