Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 122.72 KB | None | 0 0
  1. (function (a) {
  2. var c = p3.module("shared/base"),
  3. e = p3.module("shared/datepicker"),
  4. k = p3.module("shared/timepicker"),
  5. m = p3.module("utilities/validate"),
  6. b = p3.module("admissions/applicationformsedit"),
  7. i = p3.module("shared/mainbulletin"),
  8. j = p3.module("utilities/smodal"),
  9. d = p3.Us.Culture,
  10. f = p3.Us.Enum,
  11. h = p3.Us.InfoMessageLibrary,
  12. g = p3.module("shared/filesreview"),
  13. l = p3.Us.Tools;
  14. a.Ms.FormAuthModel = Bbm.extend({
  15. initialize: function () {
  16. a.Us.SetFormAuthSync(this)
  17. }
  18. });
  19. a.Ms.ApplicationForm = Bbm.extend({
  20. sync: c.DataParamSync,
  21. idAttribute: "ApplicationFormId",
  22. url: function () {
  23. return this.id ? aP + "OnlineApplication/ApplicationForm/" + this.id + "/" : aP + "OnlineApplication/ApplicationForm/"
  24. },
  25. isMigrationPending: function () {
  26. return (this.get("FormType") == f.FormType.INQUIRY.Value) && (this.get("InquiryMigrateStatus") < f.InquiryImport.MIGRATIONCOMPLETE)
  27. },
  28. isSchoolForm: function () {
  29. return this.get("FormType") & 248
  30. },
  31. isRecommendationForm: function () {
  32. return this.get("FormType") === f.FormType.RECOMMENDATION.Value
  33. }
  34. });
  35. a.Ms.Section = a.Ms.FormAuthModel.extend({
  36. sync: c.DataParamSync,
  37. idAttribute: "ApplicationSectionId",
  38. validation: {
  39. Name: [{
  40. required: true,
  41. msg: h.P3.RequiredInfoNotEntered
  42. }]
  43. },
  44. url: function () {
  45. return this.id ? aP + "OnlineApplication/ApplicationSection/" + this.id + "/" : aP + "OnlineApplication/ApplicationSection/"
  46. }
  47. });
  48. a.Ms.SectionItem = a.Ms.FormAuthModel.extend({});
  49. a.Ms.SectionItemDuplicate = a.Ms.FormAuthModel.extend({
  50. sync: c.DataParamSync,
  51. url: function () {
  52. return this.id ? aP + "OnlineApplication/FieldData/" + this.id + "/" : aP + "OnlineApplication/FieldData/"
  53. }
  54. });
  55. a.Ms.SectionValidUpdate = a.Ms.FormAuthModel.extend({
  56. sync: c.DataParamSync,
  57. url: function () {
  58. return this.id ? aP + "OnlineApplication/FieldData/" + this.id + "/" : aP + "OnlineApplication/FieldData/"
  59. }
  60. });
  61. a.Ms.ElementField = a.Ms.FormAuthModel.extend({});
  62. a.Ms.BlockField = a.Ms.FormAuthModel.extend({
  63. sync: c.DataParamSync,
  64. idAttribute: "FieldElementItemId",
  65. validation: {
  66. "FieldItem.FieldData.Data": [{
  67. required: false,
  68. fn: function (r, n, o) {
  69. var p, q;
  70. if ((o.FieldItem.DataLength) && r && (r.length > o.FieldItem.DataLength)) {
  71. return h.P3.MaxLengthExceeded
  72. }
  73. if (o.FieldItem.DataType === "I") {
  74. p = /^\d+$/g;
  75. if (!p.test(r)) {
  76. return h.P3.NotNumeric
  77. }
  78. }
  79. if (o.FieldItem.DataType === "EM") {
  80. q = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
  81. if (!q.test(r)) {
  82. return h.P3.EmailError
  83. }
  84. }
  85. if (o.FieldItem.DataType === "D") {
  86. if (!m.isEmptier(r)) {
  87. if (!m.isDate(r)) {
  88. return h.P3.DateError.fixDateFormat()
  89. }
  90. }
  91. }
  92. }
  93. }]
  94. },
  95. url: function () {
  96. return aP + "OnlineApplication/FieldElementItem/" + this.id + "/"
  97. },
  98. getData: function () {
  99. var o = this.get("FieldItem"),
  100. n;
  101. if (o && o.FieldData) {
  102. n = o.FieldData.Data
  103. }
  104. return n
  105. }
  106. }, {
  107. type: "Application.Ms.BlockField"
  108. });
  109. a.Ms.BlockFieldNull = a.Ms.FormAuthModel.extend({
  110. sync: c.DataParamSync,
  111. idAttribute: "FieldElementItemId",
  112. validation: {
  113. "FieldItem.FieldData.Data": [{
  114. fn: function (w, p, q) {
  115. if ((q.FieldItem.DataLength) && w && (w.length > q.FieldItem.DataLength)) {
  116. return h.P3.MaxLengthExceeded
  117. }
  118. if (q.FieldItem.MutexGroup) {
  119. var u = $('.sectionitems [data-mutexgroupid="' + q.FieldItem.MutexGroup + '"][data-ordinalid="' + q.FieldItem.FieldData.Ordinal + '"]:visible'),
  120. x = [],
  121. t = [],
  122. v = false,
  123. n, o, r, s;
  124. if (u.length > 1) {
  125. _.each(u, function (z) {
  126. var y = $(z),
  127. B = y.parent().siblings("label"),
  128. A = B.html();
  129. t.push(l.trim(A.replace('<span class="required-indicator" rel="tooltip" data-content="" data-original-title="Required">*</span>', "")));
  130. if (B.hasClass("required")) {
  131. v = true
  132. }
  133. if (y.is("select")) {
  134. n = y.find("option:selected");
  135. if (y.data("fieldid") != 143) {
  136. x.push(n.val())
  137. } else {
  138. if (n.text().toLowerCase() !== "* other" && n.text().toLowerCase() !== "*other" && n.text().toLowerCase() !== "other") {
  139. x.push(n.val())
  140. }
  141. }
  142. } else {
  143. x.push(y.val())
  144. }
  145. });
  146. if ((_.compact(x).length > 1) || (v && _.compact(x).length === 0)) {
  147. r = "Please choose either";
  148. for (s = 0; s < t.length - 1; s++) {
  149. r += " " + t[s] + " or"
  150. }
  151. r += " " + _.last(t) + ".";
  152. _.each(u, function (y) {
  153. $(y).parents(".field").trigger("fieldinvalid", [r])
  154. });
  155. return r
  156. }
  157. _.each(u, function (y) {
  158. $(y).parents(".field").trigger("fieldvalid")
  159. })
  160. } else {
  161. o = $(u[0]);
  162. if (q.FieldItem.Required) {
  163. if (m.isEmptier(w)) {
  164. if (o.hasClass("input-province-other")) {
  165. o.parents(".field").trigger("fieldinvalidprovinceother", h.P3.RequiredInfoNotEntered)
  166. } else {
  167. return h.P3.RequiredInfoNotEntered
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. }]
  175. },
  176. url: function () {
  177. return aP + "OnlineApplication/FieldElementItem/" + this.id + "/"
  178. },
  179. getData: function () {
  180. var o = this.get("FieldItem"),
  181. n;
  182. if (o && o.FieldData) {
  183. n = o.FieldData.Data
  184. }
  185. return n
  186. }
  187. }, {
  188. type: "Application.Ms.BlockFieldNull"
  189. });
  190. a.Ms.BlockFieldRequired = a.Ms.FormAuthModel.extend({
  191. sync: c.DataParamSync,
  192. idAttribute: "FieldElementItemId",
  193. validation: {
  194. "FieldItem.FieldData.Data": [{
  195. required: function () {
  196. var n = this,
  197. o = true;
  198. if (n.isEmergencyContactField()) {
  199. o = n.isBlockEnabled()
  200. }
  201. return o
  202. },
  203. msg: h.P3.RequiredInfoNotEntered
  204. }, {
  205. fn: function (C, n, o) {
  206. var p, q, w, s, u = false,
  207. r = false,
  208. v, B = this,
  209. y = false,
  210. t = false,
  211. x = "",
  212. A, z;
  213. if (o.FieldItem.DataLength && C && (C.length > o.FieldItem.DataLength)) {
  214. return h.P3.MaxLengthExceeded
  215. }
  216. if (o.FieldItem.DataType === "I") {
  217. p = /^\d+$/g;
  218. if (!p.test(C)) {
  219. return h.P3.NotNumeric
  220. }
  221. }
  222. if (o.FieldItem.DataType === "EM") {
  223. q = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
  224. if (!q.test(C)) {
  225. return h.P3.EmailError
  226. }
  227. }
  228. if (o.FieldItem.DataType === "D") {
  229. if (!m.isEmptier(C)) {
  230. if (!m.isDate(C)) {
  231. return h.P3.DateError.fixDateFormat()
  232. }
  233. }
  234. }
  235. y = B.isEmergencyContactField();
  236. if (y) {
  237. t = B.isBlockEnabled()
  238. }
  239. if (y && t) {
  240. if (o.FieldBlockId === 695) {
  241. w = $('.sectionitems [data-fieldblockid="695"]:visible').map(function () {
  242. return $(this).val()
  243. }).toArray();
  244. w = _.countBy(w);
  245. _.each(w, function (D, E) {
  246. if (D > 1 && E === C) {
  247. u = true
  248. }
  249. });
  250. if (u) {
  251. return "You can not have duplicate call orders."
  252. }
  253. if (l.stringToInt(C) === 0) {
  254. return h.P3.RequiredInfoNotEntered
  255. }
  256. }
  257. if (o.FieldBlockId === 688) {
  258. v = $('.sectionitems [data-fieldblockid="688"]:visible').filter(function () {
  259. return parseInt($(this).val(), 10) === 1
  260. }).toArray();
  261. if (v.length > 2 && parseInt(C, 10) === 1) {
  262. return "You may only set 2 automated calls to everytime."
  263. }
  264. }
  265. if (o.FieldBlockId === 694) {
  266. s = $('.sectionitems [data-fieldblockid="694"]:visible').map(function () {
  267. return $(this).val()
  268. }).toArray();
  269. s = _.countBy(s);
  270. _.each(s, function (D, E) {
  271. if (D > 1 && E === C) {
  272. r = true
  273. }
  274. });
  275. if (r) {
  276. return "You can not have duplicate email orders."
  277. }
  278. if (l.stringToInt(C) === 0) {
  279. return h.P3.RequiredInfoNotEntered
  280. }
  281. }
  282. if (o.FieldBlockId === 693) {
  283. v = $('.sectionitems [data-fieldblockid="693"]:visible').filter(function () {
  284. return parseInt($(this).val(), 10) === 1
  285. }).toArray();
  286. if (v.length > 2 && parseInt(C, 10) === 1) {
  287. return "You may only set 2 automated emails to everytime."
  288. }
  289. }
  290. }
  291. if (o.FieldBlockId === 749 || o.FieldBlockId === 761) {
  292. if (o.FieldBlockId === 749) {
  293. x = "Medication cannot be added more than once for the same allergy"
  294. } else {
  295. if (o.FieldBlockId === 761) {
  296. x = "Medication cannot be added more than once for the same condition"
  297. }
  298. }
  299. A = $('.sectionitems [data-fieldblockid="' + o.FieldBlockId + '"][data-ordinalid="' + o.FieldItem.FieldData.Ordinal + '"]:visible');
  300. z = _.chain(A).groupBy(function (D) {
  301. return $(D).val()
  302. }).map(function (D, E) {
  303. if (D.length > 1) {
  304. return E
  305. }
  306. }).compact().value();
  307. _.each(A, function (E) {
  308. var D = $(E);
  309. if (!m.isEmptier(D.val())) {
  310. D.parents(".field").trigger("fieldvalid")
  311. }
  312. });
  313. if (z.length) {
  314. _.each(z, function (D) {
  315. _.each($('.sectionitems [data-fieldblockid="' + o.FieldBlockId + '"][data-ordinalid="' + o.FieldItem.FieldData.Ordinal + '"]:visible option[value="' + D + '"]:selected'), function (E) {
  316. $(E).parents(".field").trigger("fieldinvalid", x)
  317. })
  318. });
  319. if (_.contains(z, C)) {
  320. return x
  321. }
  322. }
  323. }
  324. }
  325. }],
  326. "FieldItem.FieldData.OtherDescription": {
  327. required: function (s, n, o) {
  328. var q = o.FieldItem,
  329. p = q.FieldData.Data,
  330. r = /,-1$/;
  331. return q.Required && q.OtherInd && (p === "-1" || r.test(p))
  332. },
  333. msg: h.P3.RequiredInfoNotEntered
  334. }
  335. },
  336. url: function () {
  337. return aP + "OnlineApplication/FieldElementItem/" + this.id + "/"
  338. },
  339. isEmergencyContactField: function () {
  340. var n = j.Us.getPropByString(this.attributes, "FieldItem.BlockId");
  341. return _.contains([47, 48], n)
  342. },
  343. isBlockEnabled: function () {
  344. return j.Us.getPropByString(this.attributes, "FieldItem.FieldData.IsBlockEnabled")
  345. },
  346. getData: function () {
  347. var o = this.get("FieldItem"),
  348. n;
  349. if (o && o.FieldData) {
  350. n = o.FieldData.Data
  351. }
  352. return n
  353. }
  354. }, {
  355. type: "Application.Ms.BlockFieldRequired"
  356. });
  357. a.Ms.ApplicationSubmit = Bbm.extend({
  358. sync: c.DataParamSync,
  359. url: function () {
  360. return aP + "OnlineApplication/ApplicationSubmit/"
  361. }
  362. });
  363. a.Ms.SchoolFormSubmit = Bbm.extend({
  364. sync: c.DataParamSync,
  365. url: function () {
  366. return aP + "SchoolForm/FormSubmit/"
  367. }
  368. });
  369. a.Ms.RecommendationFormSubmit = a.Ms.FormAuthModel.extend({
  370. sync: c.DataParamSync,
  371. url: function () {
  372. return aP + "/RecommendationForm/FormSubmit/"
  373. }
  374. });
  375. a.Ms.SubmitPayment = Bbm.extend({
  376. sync: c.DataParamSync,
  377. url: function () {
  378. return aP + "OnlineApplication/SubmitPayment/"
  379. }
  380. });
  381. a.Ms.PaymentCheck = Bbm.extend({
  382. sync: c.DataParamSync,
  383. url: function () {
  384. return aP + "DataDirect/ApplicationPaymentRender/"
  385. }
  386. });
  387. a.Ms.ESignatureRender = Bbm.extend({
  388. sync: c.DataParamSync,
  389. validation: {
  390. SignedText: [{
  391. fn: function (p, n, o) {
  392. if (m.isEmptier(p) && (o.UserId == p3.Data.Context.attributes.UserInfo.UserId)) {
  393. return h.P3.RequiredInfoNotEntered
  394. }
  395. }
  396. }]
  397. },
  398. url: function () {
  399. return aP + "SchoolForm/FormSignature/"
  400. }
  401. });
  402. a.Ms.SignatureLabels = Bbm.extend({
  403. sync: c.DataParamSync,
  404. url: function () {
  405. return aP + "DataDirect/FormSignatureLabels/"
  406. }
  407. });
  408. a.Ms.EmergencyContact = Bbm.extend({
  409. url: function () {
  410. return aP + "SchoolForm/EmergencyContact/"
  411. }
  412. });
  413. a.Ms.RatingMatrix = a.Ms.FormAuthModel.extend({
  414. url: function () {
  415. return aP + "Rating/FormSectionItemRating/"
  416. }
  417. });
  418. a.Ms.RatingMatrixSubmit = a.Ms.FormAuthModel.extend({
  419. url: function () {
  420. return aP + "Rating/FormRatingScore"
  421. }
  422. });
  423. a.Cs.FormAuthCollection = Bbc.extend({
  424. initialize: function () {
  425. a.Us.SetFormAuthSync(this)
  426. }
  427. });
  428. a.Cs.Sections = a.Cs.FormAuthCollection.extend({
  429. sync: c.DataParamSync,
  430. model: a.Ms.Section,
  431. url: function () {
  432. return aP + "OnlineApplication/ApplicationSectionList/"
  433. }
  434. });
  435. a.Cs.SectionItems = a.Cs.FormAuthCollection.extend({
  436. sync: c.DataParamSync,
  437. model: a.Ms.SectionItem,
  438. url: function () {
  439. return aP + "OnlineApplication/SectionItemList/"
  440. }
  441. });
  442. a.Cs.BlockFields = Bbc.extend({
  443. sync: c.DataParamSync,
  444. model: function (n, o) {
  445. if (n.ElementItem.Id) {
  446. return new a.Ms.ElementField(n, o)
  447. }
  448. if (n.FieldItem.Id) {
  449. if (n.FieldItem.MutexGroup) {
  450. return new a.Ms.BlockFieldNull(n, o)
  451. }
  452. if (n.FieldItem.Required) {
  453. return new a.Ms.BlockFieldRequired(n, o)
  454. }
  455. return new a.Ms.BlockField(n, o)
  456. }
  457. },
  458. url: function () {
  459. return aP + "OnlineApplication/FieldBlockItemList/"
  460. }
  461. });
  462. a.Cs.FormSubmit = Bbc.extend({
  463. sync: c.DataParamSync,
  464. url: function () {
  465. return aP + "OnlineApplication/FormSubmit/"
  466. }
  467. });
  468. a.Cs.ESignaturesRender = Bbc.extend({
  469. sync: c.DataParamSync,
  470. model: a.Ms.ESignatureRender,
  471. url: function () {
  472. return aP + "SchoolForm/FormSignature/"
  473. }
  474. });
  475. a.Cs.EmergencyContactPhones = Bbc.extend({
  476. model: a.Ms.EmergencyContact,
  477. url: function () {
  478. return aP + "SchoolForm/emergencycontactPhone/"
  479. }
  480. });
  481. a.Cs.EmergencyContactEmails = Bbc.extend({
  482. model: a.Ms.EmergencyContact,
  483. url: function () {
  484. return aP + "SchoolForm/EmergencyContactEmail/"
  485. }
  486. });
  487. a.Cs.ContractFiles = Bbc.extend({
  488. url: "DataDirect/GetMyFileContracts"
  489. });
  490. a.Cs.FormFiles = Bbc.extend({
  491. url: "DataDirect/GetMyFileForms"
  492. });
  493. a.Vs.Layout = Bb.View.extend({
  494. template: "form/form.layout.template.html",
  495. id: "form-main",
  496. className: function () {
  497. return "collapse"
  498. },
  499. initialize: function (n) {
  500. if (a.Data.Local) {
  501. a.Us.AutoSizeIframe()
  502. }
  503. },
  504. dispose: function () {
  505. b.Us.DeleteStyle()
  506. },
  507. render: function (n) {
  508. var o = this;
  509. p3.setTitle(a.Data.FormType);
  510. $(n).append(o.el);
  511. o.renderData()
  512. },
  513. renderData: function () {
  514. var n = this;
  515. p3.fT(n.template, function (o) {
  516. n.$el.html(o({
  517. formType: a.Data.FormType
  518. }));
  519. p3.rV(new a.Vs.Header({
  520. layoutView: n
  521. }), n.$(".application-header"), true);
  522. p3.rV(new a.Vs.Sections({
  523. layoutView: n
  524. }), n.$(".application-navigation"), true)
  525. })
  526. }
  527. });
  528. a.Vs.Header = Bb.View.extend({
  529. template: "form/form.header.template.html",
  530. initialize: function () {
  531. var n = this;
  532. n.model = new a.Ms.ApplicationForm({
  533. ApplicationFormId: a.Data.FormId
  534. });
  535. a.Data.ApplicationForm = n.model
  536. },
  537. events: {
  538. renderdata: "renderData"
  539. },
  540. render: function (n) {
  541. var o = this;
  542. $(n).append(o.el)
  543. },
  544. renderData: function () {
  545. var n = this;
  546. n.model.fetch({
  547. cache: false,
  548. success: function (o, p) {
  549. a.Data.SecurePaymentProcessingType = n.model.get("SecurePaymentProcessingType");
  550. a.Data.SecurePayment = a.Data.SecurePaymentProcessingType > 0 ? true : false;
  551. a.Data.FormSaveType = n.model.get("FormSaveType");
  552. p3.fT(n.template, function (q) {
  553. n.$el.html(q({
  554. DisplayName: n.model.get("DisplayName"),
  555. showTestBanner: n.model.isMigrationPending(),
  556. skyUX: true
  557. }))
  558. })
  559. },
  560. error: function () {
  561. p3.displayError("Error loading form")
  562. }
  563. })
  564. }
  565. });
  566. a.Vs.Sections = Bb.View.extend({
  567. tagName: "ul",
  568. className: function () {
  569. return "nav nav-tabs"
  570. },
  571. initialize: function () {
  572. var o = this,
  573. n;
  574. o.sections = new a.Cs.Sections();
  575. o.sections.bind("add", function (r) {
  576. if (!r.get("EmptySection")) {
  577. var p = false,
  578. q = null;
  579. _.each(o.sections.models, function (s) {
  580. if (!s.attributes.EmptySection && s.attributes.Locked === false) {
  581. q = s.id
  582. }
  583. });
  584. if (q == r.id) {
  585. p = true
  586. }
  587. n = new a.Vs.Section({
  588. model: r,
  589. layoutView: o.options.layoutView,
  590. sectionId: r.id,
  591. lastSection: p
  592. });
  593. p3.rV(n, o.el, false)
  594. }
  595. }, this)
  596. },
  597. render: function (n) {
  598. var o = this;
  599. $(n).append(o.el);
  600. o.renderData()
  601. },
  602. renderData: function () {
  603. var n = this;
  604. n.sections.fetch({
  605. update: true,
  606. remove: false,
  607. cache: false,
  608. data: {
  609. applicationFormId: a.Data.FormId,
  610. keyId: a.Data.KeyId
  611. },
  612. complete: function () {
  613. $("#form-main").show();
  614. $(".application-header div").trigger("renderdata");
  615. if (a.Data.SPResponse === "0") {
  616. n.$("li.payment").trigger("selectsection")
  617. } else {
  618. if (a.Data.SPResponse === "1") {
  619. n.$("li.confirmation").trigger("selectsection")
  620. } else {
  621. n.$("li:first").trigger("selectsection")
  622. }
  623. }
  624. },
  625. error: function (o, p) {
  626. if (p.responseText.indexOf("Unauthorized form access") > -1) {
  627. $("#form-main").html('<div class="alert alert-error">You do not have access to this information.</div>').show()
  628. } else {
  629. $("#form-main").html('<div class="alert alert-error">There was an error accessing the form.</div>').show()
  630. }
  631. }
  632. })
  633. }
  634. });
  635. a.Vs.Section = Bb.View.extend({
  636. template: "admissions/application.section.template.html",
  637. tagName: "li",
  638. className: function () {
  639. var o = this,
  640. n = "";
  641. n += "tab ";
  642. switch (o.model.get("LockedType")) {
  643. case 1:
  644. case 3:
  645. n += "payment";
  646. break;
  647. case 2:
  648. n += "confirmation";
  649. break
  650. }
  651. if (!m.isEmptier(n)) {
  652. return n
  653. }
  654. },
  655. initialize: function () {
  656. var n = this;
  657. n.validSection = null;
  658. n.validTest = null;
  659. a.Data.Id = n.model.get("applicationId")
  660. },
  661. events: {
  662. "click a.unlocked": "selectSection",
  663. "click a.locked": "lockedSection",
  664. selectsection: "selectSection",
  665. refreshsection: "refreshSection"
  666. },
  667. render: function (n) {
  668. $(n).append(this.el);
  669. this.renderData()
  670. },
  671. renderData: function () {
  672. var n = this;
  673. p3.fT(n.template, function (o) {
  674. n.$el.html(o({
  675. model: n.model.toJSON(),
  676. userId: a.Data.KeyId,
  677. preview: a.Data.Preview
  678. }));
  679. if (n.model.get("Valid") == true) {
  680. $(n.el).find(".p3icon-ok").show()
  681. } else {
  682. if (n.model.get("Valid") == false) {
  683. $(n.el).find(".p3icon-notification").show()
  684. }
  685. }
  686. })
  687. },
  688. lockedSection: function (n) {
  689. n.preventDefault();
  690. n.stopPropagation()
  691. },
  692. selectSection: function (p, o) {
  693. p.preventDefault();
  694. p.stopPropagation();
  695. var s = this,
  696. r, n = $("#form-main .application-section"),
  697. q = p3.Data.SchoolContext.getLibrariesUrl();
  698. s.$el.parent().find("li").removeClass("active").find("a").removeClass("unlocked");
  699. s.$el.addClass("active");
  700. n.html('<div class="textcenter"><img src="' + q + '/p3-cache/img/spinner.gif"> Loading...</div>');
  701. r = new a.Cs.SectionItems();
  702. r.fetch({
  703. cache: false,
  704. data: {
  705. applicationFormId: a.Data.FormId,
  706. keyId: a.Data.KeyId,
  707. sectionId: s.model.id,
  708. preview: a.Data.Preview
  709. },
  710. success: function () {
  711. if (a.Data.FormType === "Inquiry") {
  712. a.Data.FormDefaults = $.extend(true, [], r.toJSON())
  713. }
  714. s.$el.siblings("li").find("a:not(.locked)").addClass("unlocked");
  715. s.model.set({
  716. SectionItems: r.toJSON()
  717. });
  718. $("body,html").scrollTop(0);
  719. var t = new a.Cs.SectionItems(s.model.get("SectionItems"));
  720. p3.rV(new a.Vs.SectionItems({
  721. sectionId: s.model.id,
  722. collection: t,
  723. layoutView: s.options.layoutView,
  724. sectionName: s.model.get("Name"),
  725. lastSection: s.options.lastSection,
  726. lockedSection: s.model.get("Locked"),
  727. lockedSectionType: s.model.get("LockedType"),
  728. applicationId: s.model.get("applicationId"),
  729. scrollTop: o ? o.scrollTop : null
  730. }), $(".application-section"), true)
  731. },
  732. error: function (t, u) {
  733. if (u.responseText.indexOf("Cannot edit previously submitted form") > -1) {
  734. n.html('<div class="alert alert-error">Previously submitted forms cannot be edited.</div>').show()
  735. } else {
  736. n.html('<div class="alert alert-error">There was an error accessing the form section.</div>').show()
  737. }
  738. }
  739. })
  740. },
  741. refreshSection: function (o, n) {
  742. o.preventDefault();
  743. o.stopPropagation();
  744. var r = this,
  745. q = new a.Cs.SectionItems(),
  746. p = p3.Data.SchoolContext.getLibrariesUrl();
  747. r.$el.parent().find("li").find("a").removeClass("unlocked");
  748. $("#form-main .application-section").html('<div class="textcenter"><img src="' + p + '/p3-cache/img/spinner.gif"> Loading...</div>');
  749. q.fetch({
  750. cache: false,
  751. data: {
  752. applicationFormId: a.Data.FormId,
  753. keyId: a.Data.KeyId,
  754. sectionId: r.model.id,
  755. preview: a.Data.Preview
  756. },
  757. success: function () {
  758. r.model.set({
  759. SectionItems: q.toJSON()
  760. });
  761. r.$el.trigger("selectsection", n)
  762. }
  763. })
  764. }
  765. });
  766. a.Vs.SectionItems = g.Vs.ClickButton.extend({
  767. template: "admissions/application.section.items.template.html",
  768. initialize: function () {
  769. var n = this;
  770. if (a.Data.FormType !== f.FormType.RECOMMENDATION.Name) {
  771. n.contractFiles = new a.Cs.ContractFiles();
  772. n.formFiles = new a.Cs.FormFiles()
  773. }
  774. },
  775. className: "sectionitems",
  776. events: {
  777. renderdata: "renderData",
  778. "click .prev": "prevSection",
  779. "click .next": "nextSection",
  780. "click .submitform:not(:disabled)": "submitForm",
  781. "click .submitpayment:not(:disabled)": "submitPayment",
  782. "click .submitconfirmation:not(:disabled)": "submitConfirmation",
  783. "click .proceed": "proceedNext"
  784. },
  785. render: function (n) {
  786. var o = this;
  787. $(n).append(o.el);
  788. if (o.options.lockedSectionType === 1) {
  789. o.paymentCheck = new a.Ms.PaymentCheck();
  790. o.paymentCheck.fetch({
  791. cache: false,
  792. data: {
  793. applicationFormId: a.Data.FormId,
  794. keyId: a.Data.KeyId
  795. },
  796. success: function () {
  797. o.renderData()
  798. }
  799. })
  800. } else {
  801. o.renderData()
  802. }
  803. },
  804. renderData: function () {
  805. var n = this;
  806. if ((a.Data.FormType === "Inquiry") || (a.Data.FormType === "Application") || (a.Data.FormType === f.FormType.RECOMMENDATION.Name)) {
  807. n.renderForms()
  808. } else {
  809. n.fetchAllContractsAndForms()
  810. }
  811. },
  812. renderForms: function () {
  813. var r = this,
  814. q, n, o, p;
  815. if (r.allForms !== undefined) {
  816. o = $.map(r.allForms, function (t, s) {
  817. if (t.DownloadLink === Bb.history.getFragment()) {
  818. return s
  819. }
  820. })[0];
  821. if (o !== undefined) {
  822. r.currentElement = r.allForms[o];
  823. if (r.currentElement.ProcessNextForm === true) {
  824. p = r.allForms.filter(function (s, t) {
  825. return s.ProcessNextForm === true && s.ReviewInd !== 2 && t > o
  826. })[0];
  827. r.currentElement.NextElement = p
  828. }
  829. }
  830. }
  831. p3.fT(r.template, function (v) {
  832. var s = (a.Data.FormType === "Inquiry") ? null : r.options.sectionName,
  833. t = (r.currentElement !== undefined && r.currentElement.ProcessNextForm && r.currentElement.NextElement !== undefined),
  834. u = (r.options.lockedSectionType === 2 && a.Data.FormType !== "Inquiry" && a.Data.FormType !== "Recommendation");
  835. r.$el.html(v({
  836. sectionName: s,
  837. showNextButton: t,
  838. showThankYouButton: u
  839. }));
  840. n = $("#form-formbuttons");
  841. _.each(r.collection.models, function (w) {
  842. if (w.get("ElementItem").Id) {
  843. q = new a.Vs.SectionItemElement({
  844. model: w,
  845. layoutView: r.options.layoutView,
  846. sectionId: w.id
  847. })
  848. } else {
  849. if (w.get("FieldBlockItem").Id) {
  850. switch (w.get("FieldBlockItem").Id) {
  851. case 20:
  852. if (!r.paymentCheck.get("PaymentComplete")) {
  853. q = new a.Vs.SectionItemBlock({
  854. model: w,
  855. layoutView: r.options.layoutView,
  856. sectionId: w.id,
  857. lockedSectionType: r.options.lockedSectionType,
  858. applicationId: r.options.applicationId,
  859. ordinal: w.attributes.FieldElementItems[w.attributes.FieldElementItems.length - 1].FieldItem.FieldData.Ordinal
  860. })
  861. } else {
  862. q = new a.Vs.SectionItemBlock_Payment({
  863. model: w,
  864. paymentCheck: r.paymentCheck,
  865. layoutView: r.options.layoutView,
  866. sectionId: w.id,
  867. lockedSectionType: r.options.lockedSectionType,
  868. applicationId: r.options.applicationId,
  869. ordinal: 1
  870. })
  871. }
  872. break;
  873. case 39:
  874. case 40:
  875. q = new a.Vs.SectionItemBlock_ESignatures({
  876. model: w,
  877. layoutView: r.options.layoutView,
  878. sectionId: w.id,
  879. lockedSectionType: r.options.lockedSectionType,
  880. applicationId: r.options.applicationId,
  881. ordinal: w.attributes.FieldElementItems[w.attributes.FieldElementItems.length - 1].FieldItem.FieldData.Ordinal
  882. });
  883. break;
  884. case 72:
  885. q = new a.Vs.SectionItemBlock_RatingMatrix({
  886. applicationId: r.options.applicationId,
  887. sectionItemId: w.get("SectionItemId")
  888. });
  889. break;
  890. default:
  891. q = new a.Vs.SectionItemBlock({
  892. model: w,
  893. layoutView: r.options.layoutView,
  894. sectionId: w.id,
  895. applicationId: r.options.applicationId,
  896. ordinal: w.attributes.FieldElementItems[w.attributes.FieldElementItems.length - 1].FieldItem.FieldData.Ordinal,
  897. scrollTop: r.options.scrollTop
  898. })
  899. }
  900. }
  901. }
  902. p3.rV(q, r.$("#form-items"), false)
  903. });
  904. if (!r.options.lockedSection) {
  905. if (!$(".application-navigation li.active").is(":first-child")) {
  906. n.append('<button class="btn btn-default btn-sm mr-5 pull-left prev">Previous</button>')
  907. }
  908. if (!r.options.lastSection) {
  909. n.append('<button class="btn btn-approve active btn-sm pull-left next">Next</button>')
  910. } else {
  911. n.append('<button class="btn btn-approve active btn-sm pull-left submitform">Submit</button>')
  912. }
  913. } else {
  914. if (r.options.lockedSectionType === 1) {
  915. if (!r.paymentCheck.get("PaymentComplete")) {
  916. if (a.Data.SecurePayment) {
  917. n.append('<button class="btn btn-approve active btn-sm mr-5 pull-left submitpayment">Pay & Submit</button>')
  918. }
  919. } else {
  920. n.append('<button class="btn btn-approve active btn-sm pull-left next">Next</button>')
  921. }
  922. } else {
  923. if (r.options.lockedSectionType === 2 && a.Data.FormType !== "Inquiry") {
  924. if (!a.Data.Preview) {
  925. $(".application-navigation a").removeClass("unlocked").addClass("disabled")
  926. }
  927. }
  928. }
  929. }
  930. n.append('<div class="clear"></div>')
  931. })
  932. },
  933. prevSection: function (n) {
  934. $(".application-navigation .active").prev("li").trigger("selectsection")
  935. },
  936. nextSection: function (n) {
  937. $(".application-navigation .active").next("li").trigger("selectsection")
  938. },
  939. submitForm: function (p) {
  940. p.stopPropagation();
  941. p.preventDefault();
  942. var s = this,
  943. q, o, r, n = $("#form-error");
  944. if (a.Data.Preview) {
  945. p3.displayError("Preview mode does not allow submit")
  946. } else {
  947. if (a.Data.ApplicationForm.isMigrationPending()) {
  948. p3.displayError("A problem has occurred. Please contact the school for more information.")
  949. } else {
  950. s.$(".submitform").button("loading");
  951. s.$(".submitform").prop("disabled", true);
  952. if (a.Data.FormSaveType === 1) {
  953. if (a.Data.ApplicationForm.isSchoolForm()) {
  954. q = new a.Ms.SchoolFormSubmit()
  955. } else {
  956. if (a.Data.ApplicationForm.isRecommendationForm()) {
  957. q = new a.Ms.RecommendationFormSubmit()
  958. } else {
  959. q = new a.Ms.ApplicationSubmit()
  960. }
  961. }
  962. o = {
  963. id: s.options.applicationId,
  964. submit: true,
  965. applicationFormId: a.Data.FormId
  966. };
  967. q.save({}, {
  968. dataParam: o,
  969. success: function (t, u) {
  970. a.Data.Submitted = true;
  971. _.each($(".application-navigation a:not(.locked)"), function (w) {
  972. var v = $(w);
  973. v.find(".p3icon-ok").show();
  974. v.find(".p3icon-notification").hide();
  975. _.each(u, function (x) {
  976. if (x.ApplicationSectionId == v.data("id")) {
  977. v.find(".p3icon-ok").hide();
  978. v.find(".p3icon-notification").show()
  979. }
  980. })
  981. });
  982. _.each($("#form-items .field"), function (v) {
  983. $(v).trigger("fieldvalidate")
  984. });
  985. n.empty();
  986. if (u.length === 0) {
  987. i.Us.ShowMainBulletin();
  988. if (($(".application-navigation li.active").index() + 1) < $(".application-navigation li").length) {
  989. $(".application-navigation .active").next("li").trigger("selectsection")
  990. } else {
  991. p3.router().navigate("#candidateview/" + s.collection.models[0].attributes.userId + "/progress", true)
  992. }
  993. } else {
  994. s.$(".submitform").button("reset");
  995. s.$(".submitform").prop("disabled", false);
  996. if (u.length === 1) {
  997. if (_.chain(u).pluck("ApplicationSectionId").contains(-999).value()) {
  998. p3.rV(new a.Vs.Error({
  999. errorMsg: "You have used the same medication for multiple allergies and/or conditions. The last set of medication details (ie frequency, etc) will be saved to all attached allergies and/or conditions.<br /><br />To continue, click OK and then Submit.",
  1000. medical: true
  1001. }), n, false)
  1002. } else {
  1003. p3.rV(new a.Vs.Error({
  1004. errorMsg: "Please review the fields marked in red on your form. Updates are necessary in order to submit."
  1005. }), n, false)
  1006. }
  1007. } else {
  1008. p3.rV(new a.Vs.Error({
  1009. errorMsg: "Please review the fields marked in red on your form. Updates are necessary in order to submit."
  1010. }), n, false);
  1011. if (_.chain(u).pluck("ApplicationSectionId").contains(-999).value()) {
  1012. p3.rV(new a.Vs.Error({
  1013. errorMsg: "You have used the same medication for multiple allergies and/or conditions. The last set of medication details (ie frequency, etc) will be saved to all attached allergies and/or conditions.<br /><br />To continue, click OK and then Submit.",
  1014. medical: true
  1015. }), n, false)
  1016. }
  1017. }
  1018. if (_.chain(u).pluck("BlockId").contains(72).value()) {
  1019. a.Data.InvalidSectionItemIds = [];
  1020. _.each(u, function (v) {
  1021. $('.ratings-matrix > .ratings-matrix-validation-error[data-section-item-id="' + v.ApplicationSectionItemId + '"]').show();
  1022. a.Data.InvalidSectionItemIds.push(v.ApplicationSectionItemId)
  1023. })
  1024. }
  1025. }
  1026. $("body,html").scrollTop(0)
  1027. },
  1028. error: function (u, t) {
  1029. s.$(".submitform").button("reset");
  1030. s.$(".submitform").prop("disabled", false);
  1031. p3.displayError("Error form validation")
  1032. }
  1033. })
  1034. } else {
  1035. if (a.Data.FormSaveType === 2) {
  1036. n.empty();
  1037. r = true;
  1038. _.each($("#form-items .field"), function (t) {
  1039. if ($(t).triggerHandler("fieldvalidate") === false) {
  1040. r = false
  1041. }
  1042. });
  1043. if (r) {
  1044. q = new a.Cs.FormSubmit(a.Data.FormData);
  1045. o = {
  1046. formId: a.Data.FormId
  1047. };
  1048. if (a.Data.Source) {
  1049. o.source = a.Data.Source
  1050. }
  1051. if (a.Data.Admin) {
  1052. o.origin = f.ProspectOrigin.ADMININQUIRY
  1053. } else {
  1054. if (a.Data.Local) {
  1055. o.origin = f.ProspectOrigin.INQUIRY
  1056. }
  1057. }
  1058. q.save({
  1059. dataParam: o,
  1060. success: function (t, u) {
  1061. if (a.Data.Admin) {
  1062. p3.router().navigate("#process/inquiries", true)
  1063. } else {
  1064. if (($(".application-navigation li.active").index() + 1) < $(".application-navigation li").length) {
  1065. $(".application-navigation .active").next("li").trigger("selectsection")
  1066. } else {
  1067. $("#form-items").html("<h2>Thank you for your submission!</h2>")
  1068. }
  1069. $("#form-formbuttons").empty()
  1070. }
  1071. },
  1072. error: function (u, t) {
  1073. p3.displayError("Error on form save")
  1074. }
  1075. })
  1076. } else {
  1077. s.$(".submitform").button("reset");
  1078. s.$(".submitform").prop("disabled", false);
  1079. p3.rV(new a.Vs.Error({
  1080. errorMsg: "Please review the fields marked in red on your form. Updates are necessary in order to submit."
  1081. }), n, false);
  1082. $("body,html").scrollTop(0)
  1083. }
  1084. }
  1085. }
  1086. }
  1087. }
  1088. },
  1089. submitPayment: function (o) {
  1090. o.stopPropagation();
  1091. o.preventDefault();
  1092. var q = this,
  1093. p, n = $("#form-error");
  1094. if (a.Data.Preview) {
  1095. p3.displayError("Preview mode does not allow payment")
  1096. } else {
  1097. q.$(".submitpayment").button("loading");
  1098. q.$(".submitpayment").prop("disabled", true);
  1099. n.empty();
  1100. _.each(q.collection.models, function (r) {
  1101. if (r.attributes.FieldBlockItem.Id === 20) {
  1102. p = new a.Ms.SubmitPayment(r.toJSON())
  1103. }
  1104. });
  1105. p.save({}, {
  1106. dataParam: {
  1107. encodedUri: encodeURIComponent(window.location.href)
  1108. },
  1109. success: function (r, s) {
  1110. if (s.url) {
  1111. window.location = s.url
  1112. } else {
  1113. if (($(".application-navigation li.active").index() + 1) < $(".application-navigation li").length) {
  1114. $(".application-navigation .active").next("li").trigger("selectsection")
  1115. } else {
  1116. a.Data.PaymentSubmitted = true;
  1117. p3.router().navigate("#candidateview/" + q.collection.models[0].attributes.userId + "/progress", true)
  1118. }
  1119. }
  1120. },
  1121. error: function (t, r) {
  1122. var s = "";
  1123. if (r.responseText.indexOf("Invalid Waiver Code.") > -1) {
  1124. $(".sectionitems input[data-fieldid=201]").parents(".field").trigger("fieldinvalid", ["Invalid waiver code."]);
  1125. s = "Invalid Waiver Code."
  1126. } else {
  1127. if (r.responseText.indexOf("Your credit card cannot be processed at this time") > -1) {
  1128. _.each($("#form-items .field"), function (u) {
  1129. $(u).trigger("fieldvalidate")
  1130. });
  1131. s = "Your credit card cannot be processed at this time. Please try again or contact the school for further information."
  1132. } else {
  1133. if (r.responseText.indexOf("Your transaction cannot be processed at this time") > -1) {
  1134. _.each($("#form-items .field"), function (u) {
  1135. $(u).trigger("fieldvalidate")
  1136. });
  1137. s = "Your transaction cannot be processed at this time. Please try again or contact the school for further information."
  1138. } else {
  1139. if (r.responseText.indexOf("gateway does not support EFT") > -1) {
  1140. s = "Your payment cannot be processed at this time. Currently selected payment gateway does not support EFT transactions."
  1141. } else {
  1142. _.each($("#form-items .field"), function (u) {
  1143. $(u).trigger("fieldvalidate")
  1144. });
  1145. s = "Your payment cannot be processed at this time. Please try again or contact the school for further information."
  1146. }
  1147. }
  1148. }
  1149. }
  1150. if (s) {
  1151. p3.rV(new a.Vs.Error({
  1152. errorMsg: s
  1153. }), n, false)
  1154. }
  1155. q.$(".submitpayment").button("reset");
  1156. q.$(".submitpayment").prop("disabled", false)
  1157. }
  1158. })
  1159. }
  1160. },
  1161. submitConfirmation: function (n) {
  1162. var o = this;
  1163. n.stopPropagation();
  1164. n.preventDefault();
  1165. if (a.Data.Preview) {
  1166. p3.displayError("Preview mode does not allow confirm")
  1167. } else {
  1168. o.$(".submitconfirmation").button("loading");
  1169. o.$(".submitconfirmation").prop("disabled", true);
  1170. if (a.Data.ApplicationForm.isSchoolForm()) {
  1171. p3.router().navigate("#myfiles", true)
  1172. } else {
  1173. if (a.Data.FormType === f.FormType.RECOMMENDATION.Name) {
  1174. o.$(".submitconfirmation").prop("disabled", true)
  1175. } else {
  1176. p3.router().navigate("#candidateview/" + o.collection.models[0].attributes.userId + "/progress", true)
  1177. }
  1178. }
  1179. }
  1180. }
  1181. });
  1182. a.Vs.SectionItemElement = Bb.View.extend({
  1183. template: "admissions/application.section.item.element.template.html",
  1184. className: "form-section-item",
  1185. render: function (n) {
  1186. var o = this;
  1187. $(n).append(o.el);
  1188. o.renderData()
  1189. },
  1190. renderData: function () {
  1191. var n = this;
  1192. p3.fT(n.template, function (o) {
  1193. n.$el.html(o({
  1194. model: n.model.toJSON()
  1195. }))
  1196. })
  1197. }
  1198. });
  1199. a.Vs.SectionItemBlock = Bb.View.extend({
  1200. template: "admissions/application.section.item.block.template.html",
  1201. className: function () {
  1202. return "form-section-item form-fix"
  1203. },
  1204. initialize: function () {
  1205. var r = this,
  1206. p, q, o, n;
  1207. r.collection = new a.Cs.BlockFields();
  1208. r.ordinal = 0;
  1209. if (!a.Data.Preview) {
  1210. if ((r.model.get("FieldBlockItem").Id === 26 || r.model.get("FieldBlockItem").Id === 20) && !a.Data.SecurePayment) {
  1211. p3.rV(new a.Vs.Error({
  1212. errorMsg: "Payments can not be submitted at this time. Please contact the school for assistance."
  1213. }), $("#form-error"), false)
  1214. }
  1215. if (r.model.get("FieldBlockItem").Id === 47) {
  1216. r.addBlockCollection = new a.Cs.EmergencyContactPhones();
  1217. r.addBlockCollection.fetch({
  1218. data: {
  1219. userId: a.Data.KeyId,
  1220. appId: r.options.applicationId
  1221. },
  1222. success: function (s, u) {
  1223. var t = "";
  1224. r.addBlockCollection = _.filter(s.models, function (w, v) {
  1225. w.set({
  1226. id: t + w.get("UserContactId") + w.get("PhoneIndexId") + w.get("ContactPhoneId"),
  1227. description: w.get("FirstName") + " " + w.get("LastName") + " - " + w.get("PhoneType") + " - " + w.get("PhoneNumber")
  1228. });
  1229. return w.get("SortOrder") === 0 && w.get("RelationshipId") !== -2
  1230. });
  1231. r.addBlockCollection = new a.Cs.EmergencyContactPhones(r.addBlockCollection)
  1232. },
  1233. error: function (t, s) {
  1234. p3.displayError("Error getting emergency phone contacts")
  1235. }
  1236. })
  1237. }
  1238. if (r.model.get("FieldBlockItem").Id === 48) {
  1239. r.addBlockCollection = new a.Cs.EmergencyContactEmails();
  1240. r.addBlockCollection.fetch({
  1241. data: {
  1242. userId: a.Data.KeyId,
  1243. appId: r.options.applicationId
  1244. },
  1245. success: function (s, u) {
  1246. var t = "";
  1247. r.addBlockCollection = _.filter(s.models, function (w, v) {
  1248. w.set({
  1249. id: t + w.get("RelationshipUserId") + w.get("UserContactId") + w.get("ContactEmailId"),
  1250. description: w.get("FirstName") + " " + w.get("LastName") + " - " + w.get("Email")
  1251. });
  1252. return w.get("SortOrder") === 0 && w.get("RelationshipId") !== -2
  1253. });
  1254. r.addBlockCollection = new a.Cs.EmergencyContactEmails(r.addBlockCollection)
  1255. },
  1256. error: function (t, s) {
  1257. p3.displayError("Error getting emergency email contacts")
  1258. }
  1259. })
  1260. }
  1261. }
  1262. r.collection.bind("add", function (s) {
  1263. if (r.model.get("MultipleBlockInd") && s.get("FieldItem").FieldData.CanRemove) {
  1264. if (r.ordinal != s.get("FieldItem").FieldData.Ordinal) {
  1265. r.ordinal = s.get("FieldItem").FieldData.Ordinal;
  1266. n = r.$(".fields");
  1267. n.append('<button class="btn btn-default btn-sm mt-10 mb-10 delete" data-ordinalid="' + r.ordinal + '"><i class="fa fa-times"></i> Remove ' + r.model.get("AppendBlockName") + "</button>")
  1268. }
  1269. }
  1270. s.get("FieldItem").FieldData.lastSubOrdinal = r.lastSubOrdinal[s.get("FieldItem").FieldData.Ordinal];
  1271. s.get("FieldItem").FieldData.firstSubOrdinal = r.firstSubOrdinal[s.get("FieldItem").FieldData.Ordinal];
  1272. if (s.get("ElementItem").Id) {
  1273. o = new a.Vs.ElementField({
  1274. model: s,
  1275. elementName: r.model.get("ElementItem").Name,
  1276. showMultiChild1: r.showMultiChild1,
  1277. showMultiChild2: r.showMultiChild2
  1278. })
  1279. } else {
  1280. if (s.get("FieldItem").Id) {
  1281. p = false;
  1282. q = _.chain(r.model.get("FieldElementItems")).filter(function (t) {
  1283. return t.FieldBlockId
  1284. }).last().value().FieldElementItemId;
  1285. if (q == s.get("FieldElementItemId")) {
  1286. p = true
  1287. }
  1288. o = new a.Vs.BlockField({
  1289. model: s,
  1290. layoutView: r.options.layoutView,
  1291. country: r.country,
  1292. country_1: r.country_1,
  1293. country_2: r.country_2,
  1294. country_3: r.country_3,
  1295. lockedSection: Boolean(r.model.get("Locked")),
  1296. parents: r.parents,
  1297. showChild: r.showChild,
  1298. showMultiChild1: r.showMultiChild1,
  1299. showMultiChild2: r.showMultiChild2,
  1300. emPhone: r.emPhone,
  1301. emEmail: r.emEmail,
  1302. householdAddress: r.householdAddress,
  1303. spouseHouseholdAddress: r.spouseHouseholdAddress,
  1304. lastField: p,
  1305. showSpouse: r.showSpouse
  1306. })
  1307. }
  1308. }
  1309. p3.rV(o, r.$(".fields"), false)
  1310. }, this)
  1311. },
  1312. events: {
  1313. "click .add": "addBlock",
  1314. "click .delete": "deleteBlock",
  1315. "click .show-blockselect": "showBlockSelect",
  1316. "click .cancel-blockselect": "cancelBlockSelect",
  1317. "click .add-blockselect": "addBlockSelect"
  1318. },
  1319. render: function (n) {
  1320. var o = this;
  1321. $(n).append(o.el);
  1322. o.renderData()
  1323. },
  1324. renderData: function () {
  1325. var r = this,
  1326. q = 0,
  1327. p = 0,
  1328. o = 0,
  1329. n;
  1330. p3.fT(r.template, function (s) {
  1331. r.$el.html(s({
  1332. model: r.model.toJSON()
  1333. }));
  1334. r.country_1 = null;
  1335. r.country_2 = null;
  1336. r.country_3 = null;
  1337. r.parents = null;
  1338. r.showChild = [];
  1339. r.showMultiChild1 = {};
  1340. r.showMultiChild2 = {};
  1341. r.header = null;
  1342. r.emPhone = [];
  1343. r.emEmail = [];
  1344. r.householdAddress = [];
  1345. r.spouseHouseholdAddress = [];
  1346. r.lastSubOrdinal = {};
  1347. r.firstSubOrdinal = {};
  1348. r.showSpouse = [];
  1349. _.each(r.model.get("FieldElementItems"), function (t) {
  1350. if (t.FieldItem.FieldData.Ordinal > o) {
  1351. r.firstSubOrdinal[t.FieldItem.FieldData.Ordinal] = 0;
  1352. r.lastSubOrdinal[t.FieldItem.FieldData.Ordinal] = 0;
  1353. o = t.FieldItem.FieldData.Ordinal
  1354. }
  1355. if (t.FieldItem.Id == 15) {
  1356. if (t.FieldItem.BlockGroup == null) {
  1357. r.country = t.FieldItem.FieldData.Data
  1358. }
  1359. if (t.FieldItem.BlockGroup == 1) {
  1360. r.country_1 = t.FieldItem.FieldData.Data
  1361. }
  1362. if (t.FieldItem.BlockGroup == 2) {
  1363. r.country_2 = t.FieldItem.FieldData.Data
  1364. }
  1365. if (t.FieldItem.BlockGroup == 3) {
  1366. r.country_3 = t.FieldItem.FieldData.Data
  1367. }
  1368. }
  1369. if (t.FieldItem.Id === 180 || t.FieldItem.Id === 250) {
  1370. var u = _.findWhere(t.FieldItem.LookUpList, {
  1371. dd_id: t.FieldItem.FieldData.Interest
  1372. });
  1373. if (u) {
  1374. if (r.header == u.category) {
  1375. t.FieldItem.FieldData._header = null
  1376. } else {
  1377. t.FieldItem.FieldData._header = u.category;
  1378. r.header = u.category
  1379. }
  1380. }
  1381. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1382. r.showChild.push(t.FieldItem.FieldData.Interest)
  1383. }
  1384. }
  1385. if (t.FieldBlockId === 682) {
  1386. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1387. q++;
  1388. r.emPhone.push(t.FieldItem.FieldData.Ordinal)
  1389. }
  1390. }
  1391. if (t.FieldBlockId === 696) {
  1392. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1393. p++;
  1394. r.emEmail.push(t.FieldItem.FieldData.Ordinal)
  1395. }
  1396. }
  1397. if (t.FieldItem.Id === 160) {
  1398. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1399. r.showChild.push(161)
  1400. }
  1401. }
  1402. if (t.FieldItem.Id === 161) {
  1403. r.showChild.push(161);
  1404. _.each(r.model.get("FieldElementItems"), function (v) {
  1405. if (v.FieldItem.Id === 160) {
  1406. if (v.FieldItem.Visible === true && v.FieldItem.FieldData.Data != "true") {
  1407. r.showChild.splice(r.showChild.indexOf(161), 1)
  1408. }
  1409. }
  1410. })
  1411. }
  1412. if (t.FieldItem.Id === 162) {
  1413. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1414. r.showChild.push(163)
  1415. }
  1416. }
  1417. if (t.FieldItem.Id === 163) {
  1418. r.showChild.push(163);
  1419. _.each(r.model.get("FieldElementItems"), function (v) {
  1420. if (v.FieldItem.Id === 162) {
  1421. if (v.FieldItem.Visible === true && v.FieldItem.FieldData.Data != "true") {
  1422. r.showChild.splice(r.showChild.indexOf(163), 1)
  1423. }
  1424. }
  1425. })
  1426. }
  1427. if (t.FieldItem.Id === 164) {
  1428. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1429. r.showChild.push(165)
  1430. }
  1431. }
  1432. if (t.FieldItem.Id === 165) {
  1433. r.showChild.push(165);
  1434. _.each(r.model.get("FieldElementItems"), function (v) {
  1435. if (v.FieldItem.Id === 164) {
  1436. if (v.FieldItem.Visible === true && v.FieldItem.FieldData.Data != "true") {
  1437. r.showChild.splice(r.showChild.indexOf(165), 1)
  1438. }
  1439. }
  1440. })
  1441. }
  1442. if (t.FieldItem.Id === 166) {
  1443. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1444. r.showChild.push(167)
  1445. }
  1446. }
  1447. if (t.FieldItem.Id === 167) {
  1448. r.showChild.push(167);
  1449. _.each(r.model.get("FieldElementItems"), function (v) {
  1450. if (v.FieldItem.Id === 166) {
  1451. if (v.FieldItem.Visible === true && v.FieldItem.FieldData.Data != "true") {
  1452. r.showChild.splice(r.showChild.indexOf(167), 1)
  1453. }
  1454. }
  1455. })
  1456. }
  1457. if (t.FieldItem.Id === 169) {
  1458. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1459. r.showChild.push(171)
  1460. }
  1461. }
  1462. if (t.FieldItem.Id === 171) {
  1463. r.showChild.push(171);
  1464. _.each(r.model.get("FieldElementItems"), function (v) {
  1465. if (v.FieldItem.Id === 169) {
  1466. if (v.FieldItem.Visible === true && v.FieldItem.FieldData.Data != "true") {
  1467. r.showChild.splice(r.showChild.indexOf(171), 1)
  1468. }
  1469. }
  1470. })
  1471. }
  1472. if (t.FieldBlockId === 700) {
  1473. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1474. r.showChild.push(700)
  1475. }
  1476. }
  1477. if (t.FieldBlockId === 740) {
  1478. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1479. j.Us.setPropByString(r.showMultiChild1, t.FieldBlockId + "." + t.FieldItem.FieldData.Ordinal, true)
  1480. }
  1481. }
  1482. if (t.FieldBlockId === 748) {
  1483. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1484. j.Us.setPropByString(r.showMultiChild1, t.FieldBlockId + "." + t.FieldItem.FieldData.Ordinal, true)
  1485. }
  1486. }
  1487. if (t.FieldBlockId === 780) {
  1488. if (r.firstSubOrdinal[t.FieldItem.FieldData.Ordinal] === 0) {
  1489. r.firstSubOrdinal[t.FieldItem.FieldData.Ordinal] = t.FieldItem.FieldData.SubBlockOrdinal
  1490. }
  1491. }
  1492. if (t.FieldBlockId === 781) {
  1493. if (t.FieldItem.FieldData.SubBlockOrdinal > r.lastSubOrdinal[t.FieldItem.FieldData.Ordinal]) {
  1494. r.lastSubOrdinal[t.FieldItem.FieldData.Ordinal] = t.FieldItem.FieldData.SubBlockOrdinal
  1495. }
  1496. }
  1497. if (t.FieldBlockId === 753) {
  1498. if (l.stringToInt(t.FieldItem.FieldData.Data) === 2) {
  1499. j.Us.setPropByString(r.showMultiChild2, t.FieldBlockId + "." + t.FieldItem.FieldData.Ordinal + "." + t.FieldItem.FieldData.SubBlockOrdinal, true)
  1500. }
  1501. }
  1502. if (t.FieldBlockId === 755) {
  1503. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1504. j.Us.setPropByString(r.showMultiChild1, t.FieldBlockId + "." + t.FieldItem.FieldData.Ordinal, true)
  1505. }
  1506. }
  1507. if (t.FieldBlockId === 760) {
  1508. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1509. j.Us.setPropByString(r.showMultiChild1, t.FieldBlockId + "." + t.FieldItem.FieldData.Ordinal, true)
  1510. }
  1511. }
  1512. if (t.FieldBlockId === 782) {
  1513. if (r.firstSubOrdinal[t.FieldItem.FieldData.Ordinal] === 0) {
  1514. r.firstSubOrdinal[t.FieldItem.FieldData.Ordinal] = t.FieldItem.FieldData.SubBlockOrdinal
  1515. }
  1516. }
  1517. if (t.FieldBlockId === 783) {
  1518. if (t.FieldItem.FieldData.SubBlockOrdinal > r.lastSubOrdinal[t.FieldItem.FieldData.Ordinal]) {
  1519. r.lastSubOrdinal[t.FieldItem.FieldData.Ordinal] = t.FieldItem.FieldData.SubBlockOrdinal
  1520. }
  1521. }
  1522. if (t.FieldBlockId === 765) {
  1523. if (l.stringToInt(t.FieldItem.FieldData.Data) === 2) {
  1524. j.Us.setPropByString(r.showMultiChild2, t.FieldBlockId + "." + t.FieldItem.FieldData.Ordinal + "." + t.FieldItem.FieldData.SubBlockOrdinal, true)
  1525. }
  1526. }
  1527. if (t.FieldBlockId === 29 || t.FieldBlockId === 361) {
  1528. if (l.stringToBoolean(t.FieldItem.FieldData.Data) !== true) {
  1529. r.householdAddress.push(t.FieldItem.FieldData.Ordinal)
  1530. }
  1531. }
  1532. if (t.FieldBlockId === 905) {
  1533. if (l.stringToBoolean(t.FieldItem.FieldData.Data) !== true) {
  1534. r.spouseHouseholdAddress.push(t.FieldItem.FieldData.Ordinal)
  1535. }
  1536. }
  1537. if (t.FieldBlockId === 939) {
  1538. if (l.stringToBoolean(t.FieldItem.FieldData.Data) === true) {
  1539. r.showSpouse.push(t.FieldItem.FieldData.Ordinal)
  1540. }
  1541. }
  1542. });
  1543. if (q > 10) {
  1544. r.$(".form-block-alert").append('<div class="alert alert-error">There are too many emergency phone numbers. Please enter no more than 10.</div>')
  1545. }
  1546. if (p > 10) {
  1547. r.$(".form-block-alert").append('<div class="alert alert-error">There are too many emergency emails. Please enter no more than 10.</div>')
  1548. }
  1549. r.parents = _.chain(r.model.get("FieldElementItems")).map(function (t) {
  1550. return t.FieldItem.Parent
  1551. }).uniq().compact().value();
  1552. _.each(r.model.get("FieldElementItems"), function (t) {
  1553. r.collection.add(t)
  1554. });
  1555. if (r.model.get("AllowAddAnother") && r.model.get("MultipleBlockInd")) {
  1556. n = r.$(".addAnother");
  1557. if (r.model.get("FieldBlockItem").Id === 47 || r.model.get("FieldBlockItem").Id === 48) {
  1558. n.append('<button class="btn btn-link btn-sm mt-10 mb-10 show-blockselect"><i class="fa fa-plus-circle"></i> Add Another ' + r.model.get("AppendBlockName") + "</button>")
  1559. } else {
  1560. n.append('<button class="btn btn-link btn-sm mt-10 mb-10 add"><i class="fa fa-plus-circle"></i> Add Another ' + r.model.get("AppendBlockName") + "</button>")
  1561. }
  1562. r.$("button.add").hover(function () {
  1563. r.$(".fields").css("background-color", "#fdffcf")
  1564. }, function () {
  1565. r.$(".fields").css("background-color", "")
  1566. });
  1567. r.$("button.delete").hover(function (t) {
  1568. r.$('[data-ordinalid="' + $(t.currentTarget).data("ordinalid") + '"]').parents(".field").css("background-color", "#fdffcf")
  1569. }, function (t) {
  1570. r.$('[data-ordinalid="' + $(t.currentTarget).data("ordinalid") + '"]').parents(".field").css("background-color", "")
  1571. })
  1572. }
  1573. if (r.options.scrollTop > 0) {
  1574. $(document).scrollTop(r.options.scrollTop)
  1575. }
  1576. })
  1577. },
  1578. showBlockSelect: function (n) {
  1579. n.stopPropagation();
  1580. n.preventDefault();
  1581. var o = this;
  1582. if (a.Data.Preview) {
  1583. p3.displayError("This feature is not available in Preview mode")
  1584. } else {
  1585. if (o.addBlockCollection.length > 0) {
  1586. p3.rV(new a.Vs.AddBlockSelect({
  1587. collection: o.addBlockCollection
  1588. }), o.$(".addAnother"), true)
  1589. } else {
  1590. o.addBlock(n)
  1591. }
  1592. }
  1593. },
  1594. cancelBlockSelect: function (o) {
  1595. o.stopPropagation();
  1596. o.preventDefault();
  1597. var p = this,
  1598. n = p.$(".addAnother");
  1599. n.empty().append('<button class="btn btn-link btn-sm mt-10 show-blockselect"><i class="fa fa-plus-circle"></i> Add Another ' + p.model.get("AppendBlockName") + "</button>")
  1600. },
  1601. addBlockSelect: function (n) {
  1602. var p = this,
  1603. o;
  1604. p.$(n.currentTarget).button("loading");
  1605. p.$(n.currentTarget).prop("disabled", true);
  1606. o = p.addBlockCollection.get(p.$(".blockselect").val());
  1607. o.set({
  1608. FormDataId: p.options.applicationId,
  1609. SectionItemId: p.model.get("SectionItemId"),
  1610. Ordinal: p.options.ordinal + 1,
  1611. BlockId: p.model.get("FieldBlockItem").Id
  1612. });
  1613. o.save({}, {
  1614. success: function (q, r) {
  1615. $(".application-navigation li.active").trigger("refreshsection")
  1616. },
  1617. error: function (r, q) {
  1618. p3.displayError("Error adding emergency contact");
  1619. p.$(n.currentTarget).button("reset");
  1620. p.$(n.currentTarget).prop("disabled", false)
  1621. }
  1622. })
  1623. },
  1624. addBlock: function (o) {
  1625. o.stopPropagation();
  1626. o.preventDefault();
  1627. var s = this,
  1628. q, p, r, n;
  1629. if (a.Data.Preview) {
  1630. p3.displayError("This feature is not available in Preview mode")
  1631. } else {
  1632. s.$(o.currentTarget).button("loading");
  1633. s.$(o.currentTarget).prop("disabled", true);
  1634. q = s.options.ordinal + 1;
  1635. p = s.collection.last().toJSON().FieldItem.FieldData.Ordinal;
  1636. if (a.Data.FormSaveType === 1) {
  1637. r = new a.Ms.SectionItemDuplicate({
  1638. ApplicantDataId: s.options.applicationId,
  1639. ApplicationFormId: a.Data.FormId,
  1640. KeyId: a.Data.KeyId,
  1641. Data: null,
  1642. Ordinal: q,
  1643. SectionItemId: s.model.get("SectionItemId"),
  1644. XMLElement: "addAnother"
  1645. });
  1646. r.save({}, {
  1647. dataParam: {
  1648. sectionId: s.model.get("ApplicationSectionId"),
  1649. returnModel: true
  1650. },
  1651. success: function (t, u) {
  1652. $(".application-navigation li.active").trigger("refreshsection")
  1653. },
  1654. error: function (u, t) {
  1655. p3.displayError("Error adding section item");
  1656. s.$(o.currentTarget).button("reset");
  1657. s.$(o.currentTarget).prop("disabled", false)
  1658. }
  1659. })
  1660. } else {
  1661. if (a.Data.FormSaveType === 2) {
  1662. s.$(o.currentTarget).button("reset");
  1663. s.$(o.currentTarget).prop("disabled", false);
  1664. if (a.Data.FormDefaults.length) {
  1665. n = _.findWhere(a.Data.FormDefaults, {
  1666. SectionItemId: s.model.get("SectionItemId")
  1667. })
  1668. }
  1669. n = _.filter(n.FieldElementItems, function (t) {
  1670. return t.FieldItem.FieldData.Ordinal === 1
  1671. });
  1672. n = $.extend(true, [], n);
  1673. _.each(n, function (t) {
  1674. t.FieldItem.FieldData.CanRemove = 1;
  1675. t.FieldItem.FieldData.Ordinal = p + 1
  1676. });
  1677. s.collection.add(n)
  1678. }
  1679. }
  1680. }
  1681. },
  1682. deleteBlock: function (n) {
  1683. n.stopPropagation();
  1684. n.preventDefault();
  1685. var r = this,
  1686. o, p = [],
  1687. q;
  1688. if (a.Data.Preview) {
  1689. p3.displayError("This feature is not available in Preview mode")
  1690. } else {
  1691. o = $(n.currentTarget).data("ordinalid");
  1692. if (a.Data.FormSaveType === 1) {
  1693. q = new a.Ms.SectionItemDuplicate({
  1694. ApplicantDataId: r.options.applicationId,
  1695. ApplicationFormId: a.Data.FormId,
  1696. KeyId: a.Data.KeyId,
  1697. Data: null,
  1698. Ordinal: $(n.currentTarget).data("ordinalid"),
  1699. SectionItemId: r.model.get("SectionItemId"),
  1700. XMLElement: "remove"
  1701. });
  1702. q.save({}, {
  1703. dataParam: {
  1704. sectionId: r.model.get("ApplicationSectionId"),
  1705. returnModel: true
  1706. },
  1707. success: function (s, t) {
  1708. $(".application-navigation li.active").trigger("refreshsection")
  1709. },
  1710. error: function (t, s) {
  1711. if (a.Data.Preview) {
  1712. p3.displayError("This feature is not available in Preview mode")
  1713. } else {
  1714. p3.displayError("Error adding section item")
  1715. }
  1716. }
  1717. })
  1718. } else {
  1719. if (a.Data.FormSaveType === 2) {
  1720. r.$(n.currentTarget).button("reset");
  1721. r.$(n.currentTarget).prop("disabled", false);
  1722. _.each(r.collection.models, function (s) {
  1723. if (s.get("FieldItem").FieldData.Ordinal == o) {
  1724. p.push(s)
  1725. }
  1726. });
  1727. r.collection.remove(p);
  1728. $(n.currentTarget).remove()
  1729. }
  1730. }
  1731. }
  1732. }
  1733. });
  1734. a.Vs.ElementField = Bb.View.extend({
  1735. template: "admissions/application.section.item.element.template.html",
  1736. initialize: function () {
  1737. var n = this;
  1738. n.model.bind("remove", this.deleteElement, this)
  1739. },
  1740. events: {
  1741. "click button": "clickButton"
  1742. },
  1743. render: function (n) {
  1744. var o = this;
  1745. $(n).append(o.el);
  1746. o.renderData()
  1747. },
  1748. renderData: function () {
  1749. var p = this,
  1750. n = false,
  1751. o = false;
  1752. switch (p.model.get("FieldBlockId")) {
  1753. case 781:
  1754. case 783:
  1755. if (p.model.get("FieldItem").FieldData.lastSubOrdinal !== p.model.get("FieldItem").FieldData.SubBlockOrdinal) {
  1756. o = true
  1757. }
  1758. if (!j.Us.getPropByString(p.options.showMultiChild1, p.model.get("FieldItem").Parent + "." + p.model.get("FieldItem").FieldData.Ordinal)) {
  1759. n = true
  1760. }
  1761. break;
  1762. case 780:
  1763. case 782:
  1764. if (p.model.get("FieldItem").FieldData.firstSubOrdinal === p.model.get("FieldItem").FieldData.SubBlockOrdinal) {
  1765. o = true
  1766. }
  1767. if (!j.Us.getPropByString(p.options.showMultiChild1, p.model.get("FieldItem").Parent + "." + p.model.get("FieldItem").FieldData.Ordinal)) {
  1768. n = true
  1769. }
  1770. break
  1771. }
  1772. if (!o) {
  1773. p3.fT(p.template, function (q) {
  1774. p.$el.html(q({
  1775. model: p.model.toJSON(),
  1776. hide: n,
  1777. remove: o
  1778. }));
  1779. if (p.model.get("FieldBlockId") === 780 || p.model.get("FieldBlockId") === 782) {
  1780. p.$("button.meds").hover(function (r) {
  1781. $(r.currentTarget).parents(".fields").find('[data-ordinalid="' + $(r.currentTarget).data("ordinalid") + '"][data-subordinalid="' + $(r.currentTarget).data("subordinalid") + '"]').parents(".field").css("background-color", "#fdffcf")
  1782. }, function (r) {
  1783. $(r.currentTarget).parents(".fields").find('[data-ordinalid="' + $(r.currentTarget).data("ordinalid") + '"][data-subordinalid="' + $(r.currentTarget).data("subordinalid") + '"]').parents(".field").css("background-color", "")
  1784. })
  1785. }
  1786. if (p.model.get("FieldBlockId") === 781 || p.model.get("FieldBlockId") === 783) {
  1787. p.$("button.meds").hover(function (r) {
  1788. $(r.currentTarget).parents(".fields").find('[data-ordinalid="' + $(r.currentTarget).data("ordinalid") + '"]').parents(".field").css("background-color", "#fdffcf")
  1789. }, function (r) {
  1790. $(r.currentTarget).parents(".fields").find('[data-ordinalid="' + $(r.currentTarget).data("ordinalid") + '"]').parents(".field").css("background-color", "")
  1791. })
  1792. }
  1793. })
  1794. }
  1795. },
  1796. clickButton: function (n) {
  1797. var p = this,
  1798. o;
  1799. if (a.Data.Preview) {
  1800. p3.displayError("This feature is not available in Preview mode")
  1801. } else {
  1802. switch (p.model.get("FieldBlockId")) {
  1803. case 780:
  1804. case 782:
  1805. o = new a.Ms.SectionItemDuplicate({
  1806. ApplicantDataId: a.Data.Id,
  1807. ApplicationFormId: a.Data.FormId,
  1808. Data: null,
  1809. KeyId: a.Data.KeyId,
  1810. Ordinal: $(n.currentTarget).data("ordinalid"),
  1811. SectionItemId: p.model.get("SectionItemId"),
  1812. SubBlock: p.model.get("FieldItem").FieldData.SubBlock,
  1813. SubBlockOrdinal: p.model.get("FieldItem").FieldData.SubBlockOrdinal,
  1814. XMLElement: "removeSub"
  1815. });
  1816. o.save({}, {
  1817. dataParam: {
  1818. sectionId: p.model.get("ApplicationSectionId"),
  1819. returnModel: true
  1820. },
  1821. success: function (q, r) {
  1822. $(".application-navigation li.active").trigger("refreshsection")
  1823. },
  1824. error: function (r, q) {
  1825. p3.displayError("Error removing section item")
  1826. }
  1827. });
  1828. break;
  1829. case 781:
  1830. case 783:
  1831. o = new a.Ms.SectionItemDuplicate({
  1832. ApplicantDataId: a.Data.Id,
  1833. ApplicationFormId: a.Data.FormId,
  1834. Data: null,
  1835. KeyId: a.Data.KeyId,
  1836. Ordinal: $(n.currentTarget).data("ordinalid"),
  1837. SectionItemId: p.model.get("SectionItemId"),
  1838. SubBlock: p.model.get("FieldItem").FieldData.SubBlock,
  1839. SubBlockOrdinal: p.model.get("FieldItem").FieldData.SubBlockOrdinal + 1,
  1840. XMLElement: "addSub"
  1841. });
  1842. o.save({}, {
  1843. dataParam: {
  1844. sectionId: p.model.get("ApplicationSectionId"),
  1845. returnModel: true
  1846. },
  1847. success: function (q, r) {
  1848. $(".application-navigation li.active").trigger("refreshsection")
  1849. },
  1850. error: function (r, q) {
  1851. p3.displayError("Error adding section item")
  1852. }
  1853. });
  1854. break
  1855. }
  1856. }
  1857. },
  1858. deleteElement: function () {
  1859. $(this.el).remove()
  1860. }
  1861. });
  1862. a.Vs.BlockField = Bb.View.extend({
  1863. className: "field",
  1864. initialize: function () {
  1865. var n = this;
  1866. switch (n.model.get("FieldItem").UIType) {
  1867. case "T":
  1868. n.template = "form/form.field.text.template.html";
  1869. break;
  1870. case "TA":
  1871. n.template = "form/form.field.textarea.template.html";
  1872. break;
  1873. case "Date":
  1874. n.template = "form/form.field.date.template.html";
  1875. break;
  1876. case "Time":
  1877. n.template = "form/form.field.time.template.html";
  1878. break;
  1879. case "RB":
  1880. n.template = "form/form.field.yesno.template.html";
  1881. break;
  1882. case "DD":
  1883. n.template = "form/form.field.dropdown.template.html";
  1884. n.addDDOptGroups(n.model.get("FieldItem").LookUpList);
  1885. break;
  1886. case "CheckBoxSingleSelect":
  1887. n.template = "form/form.field.checkboxsingle.template.html";
  1888. break;
  1889. case "CheckBoxMultiSelect":
  1890. n.template = "form/form.field.checkboxmulti.template.html";
  1891. break;
  1892. case "CB":
  1893. n.template = "form/form.field.checkbox.template.html";
  1894. break;
  1895. case "Display":
  1896. n.template = "form/form.field.display.template.html";
  1897. break;
  1898. case "IMG":
  1899. n.template = "form/form.field.image.template.html";
  1900. break;
  1901. case "DOC":
  1902. n.template = "form/form.field.document.template.html";
  1903. break;
  1904. case "ExpDate":
  1905. n.template = "form/form.field.expirationdate.template.html";
  1906. break;
  1907. case "Button":
  1908. n.template = "form/form.field.button.template.html";
  1909. break
  1910. }
  1911. n.model.bind("remove", this.deleteElement, this);
  1912. _.bindAll(n, "parent", "renderData", "filterLookupList");
  1913. Bb.Validation.bind(n, {
  1914. forceUpdate: true,
  1915. selector: "name"
  1916. });
  1917. n.model.view = n
  1918. },
  1919. events: {
  1920. updatemodel: "updateModel",
  1921. 'change input[type="text"]': "updateModel",
  1922. "change select": "updateModel",
  1923. "click .radio-input": "updateModel",
  1924. "click .checkbox-input": "updateModel",
  1925. "click .checkbox-multi-input": "updateModel",
  1926. "blur input.time-input": "updateModel",
  1927. "change textarea": "updateModel",
  1928. "keyup textarea": "updateCharacterCounter",
  1929. "click button.delete-attachment-file": "deleteAttachmentFile",
  1930. fieldvalidate: "fieldValidate",
  1931. fieldvalid: "fieldValid",
  1932. fieldinvalid: "fieldInvalid",
  1933. fieldinvalidprovinceother: "fieldInvalidProvinceOther",
  1934. "change .parent": "parent",
  1935. "click .parent.radio-input": "parent",
  1936. "click .parent.checkbox-input": "parent",
  1937. filterprovince: "filterProvince"
  1938. },
  1939. render: function (n) {
  1940. var o = this;
  1941. $(n).append(o.el);
  1942. o.renderData()
  1943. },
  1944. renderData: function (n) {
  1945. var v = this,
  1946. p = false,
  1947. q = false,
  1948. s, r, t, u, o;
  1949. p3.fT(v.template, function (w) {
  1950. if (v.model.get("FieldItem").Id === 229) {
  1951. if (v.model.get("FieldItem").BlockGroup == null) {
  1952. if (v.options.country === "United States") {
  1953. p = true;
  1954. q = true
  1955. } else {
  1956. if (v.options.country === "Canada" || v.options.country === "United Kingdom" || v.options.country === "Australia") {
  1957. q = true
  1958. } else {
  1959. if (v.options.country == null) {
  1960. p = true;
  1961. q = true
  1962. } else {
  1963. p = true
  1964. }
  1965. }
  1966. }
  1967. } else {
  1968. if (v.model.get("FieldItem").BlockGroup === 1) {
  1969. if (v.options.country_1 === "United States") {
  1970. p = true;
  1971. q = true
  1972. } else {
  1973. if (v.options.country_1 === "Canada" || v.options.country_1 === "United Kingdom" || v.options.country_1 === "Australia") {
  1974. q = true
  1975. } else {
  1976. if (v.options.country_1 == null) {
  1977. p = true;
  1978. q = true
  1979. } else {
  1980. p = true
  1981. }
  1982. }
  1983. }
  1984. } else {
  1985. if (v.model.get("FieldItem").BlockGroup === 2) {
  1986. if (v.options.country_2 === "United States") {
  1987. p = true;
  1988. q = true
  1989. } else {
  1990. if (v.options.country_2 === "Canada" || v.options.country_2 === "United Kingdom" || v.options.country_2 === "Australia") {
  1991. q = true
  1992. } else {
  1993. if (v.options.country_2 == null) {
  1994. p = true;
  1995. q = true
  1996. } else {
  1997. p = true
  1998. }
  1999. }
  2000. }
  2001. } else {
  2002. if (v.model.get("FieldItem").BlockGroup === 3) {
  2003. if (v.options.country_3 === "United States") {
  2004. p = true;
  2005. q = true
  2006. } else {
  2007. if (v.options.country_3 === "Canada" || v.options.country_3 === "United Kingdom" || v.options.country_3 === "Australia") {
  2008. q = true
  2009. } else {
  2010. if (v.options.country_3 == null) {
  2011. p = true;
  2012. q = true
  2013. } else {
  2014. p = true
  2015. }
  2016. }
  2017. }
  2018. }
  2019. }
  2020. }
  2021. }
  2022. }
  2023. if (v.model.get("FieldItem").Id === 13) {
  2024. if (v.model.get("FieldItem").BlockGroup == null) {
  2025. if (v.options.country === "United States") {
  2026. p = false
  2027. } else {
  2028. if (v.options.country === "Canada" || v.options.country === "United Kingdom" || v.options.country === "Australia") {
  2029. p = true
  2030. } else {
  2031. p = true
  2032. }
  2033. }
  2034. } else {
  2035. if (v.model.get("FieldItem").BlockGroup === 1) {
  2036. if (v.options.country_1 === "United States" || v.options.country_1 == null) {
  2037. p = false
  2038. } else {
  2039. if (v.options.country_1 === "Canada" || v.options.country_1 === "United Kingdom" || v.options.country_1 === "Australia") {
  2040. p = true
  2041. } else {
  2042. p = true
  2043. }
  2044. }
  2045. } else {
  2046. if (v.model.get("FieldItem").BlockGroup === 2) {
  2047. if (v.options.country_2 === "United States" || v.options.country_2 == null) {
  2048. p = false
  2049. } else {
  2050. if (v.options.country_2 === "Canada" || v.options.country_2 === "United Kingdom" || v.options.country_2 === "Australia") {
  2051. p = true
  2052. } else {
  2053. p = true
  2054. }
  2055. }
  2056. } else {
  2057. if (v.model.get("FieldItem").BlockGroup === 3) {
  2058. if (v.options.country_3 === "United States" || v.options.country_3 == null) {
  2059. p = false
  2060. } else {
  2061. if (v.options.country_3 === "Canada" || v.options.country_3 === "United Kingdom" || v.options.country_3 === "Australia") {
  2062. p = true
  2063. } else {
  2064. p = true
  2065. }
  2066. }
  2067. }
  2068. }
  2069. }
  2070. }
  2071. }
  2072. switch (v.model.get("FieldBlockId")) {
  2073. case 215:
  2074. case 216:
  2075. case 217:
  2076. case 218:
  2077. case 219:
  2078. case 220:
  2079. case 221:
  2080. case 222:
  2081. case 224:
  2082. if (!_.contains(v.options.householdAddress, v.model.get("FieldItem").FieldData.Ordinal)) {
  2083. p = true
  2084. }
  2085. break;
  2086. case 362:
  2087. case 363:
  2088. case 364:
  2089. case 365:
  2090. case 366:
  2091. case 367:
  2092. case 368:
  2093. case 369:
  2094. case 467:
  2095. if (!_.contains(v.options.householdAddress, v.model.get("FieldItem").FieldData.Ordinal)) {
  2096. p = true
  2097. }
  2098. break;
  2099. case 161:
  2100. case 163:
  2101. case 165:
  2102. case 167:
  2103. case 171:
  2104. if (!_.contains(v.options.showChild, v.model.get("FieldBlockId"))) {
  2105. p = true
  2106. }
  2107. break;
  2108. case 181:
  2109. case 182:
  2110. case 183:
  2111. case 184:
  2112. case 453:
  2113. case 454:
  2114. case 455:
  2115. case 456:
  2116. if (!_.contains(v.options.showChild, v.model.get("FieldItem").FieldData.Interest)) {
  2117. p = true
  2118. }
  2119. break;
  2120. case 203:
  2121. case 204:
  2122. case 205:
  2123. case 206:
  2124. case 207:
  2125. case 228:
  2126. case 229:
  2127. case 230:
  2128. case 231:
  2129. case 232:
  2130. case 233:
  2131. case 234:
  2132. case 235:
  2133. case 236:
  2134. case 237:
  2135. case 238:
  2136. case 239:
  2137. p = true;
  2138. break;
  2139. case 686:
  2140. case 687:
  2141. case 688:
  2142. case 695:
  2143. if (!_.contains(v.options.emPhone, v.model.get("FieldItem").FieldData.Ordinal)) {
  2144. p = true
  2145. }
  2146. break;
  2147. case 692:
  2148. case 693:
  2149. case 694:
  2150. if (!_.contains(v.options.emEmail, v.model.get("FieldItem").FieldData.Ordinal)) {
  2151. p = true
  2152. }
  2153. break;
  2154. case 701:
  2155. case 702:
  2156. case 703:
  2157. if (!_.contains(v.options.showChild, v.model.get("FieldItem").Parent)) {
  2158. p = true
  2159. }
  2160. break;
  2161. case 741:
  2162. case 742:
  2163. case 743:
  2164. case 744:
  2165. case 745:
  2166. case 746:
  2167. case 747:
  2168. case 748:
  2169. case 756:
  2170. case 757:
  2171. case 758:
  2172. case 759:
  2173. case 760:
  2174. case 749:
  2175. case 750:
  2176. case 751:
  2177. case 752:
  2178. case 753:
  2179. case 761:
  2180. case 762:
  2181. case 763:
  2182. case 764:
  2183. case 765:
  2184. if (!j.Us.getPropByString(v.options.showMultiChild1, v.model.get("FieldItem").Parent + "." + v.model.get("FieldItem").FieldData.Ordinal)) {
  2185. p = true
  2186. }
  2187. break;
  2188. case 754:
  2189. case 766:
  2190. if (!j.Us.getPropByString(v.options.showMultiChild2, v.model.get("FieldItem").Parent + "." + v.model.get("FieldItem").FieldData.Ordinal + "." + v.model.get("FieldItem").FieldData.SubBlockOrdinal)) {
  2191. p = true
  2192. }
  2193. break;
  2194. case 426:
  2195. r = v.model.get("FieldItem").Parent;
  2196. if (r) {
  2197. t = v.model.collection.find(function (x) {
  2198. return x.get("FieldBlockId") === r
  2199. });
  2200. if (t) {
  2201. v.filterLookupList(426, t.getData())
  2202. }
  2203. }
  2204. break;
  2205. case 905:
  2206. case 916:
  2207. case 917:
  2208. case 918:
  2209. case 919:
  2210. case 920:
  2211. case 921:
  2212. case 922:
  2213. case 923:
  2214. case 924:
  2215. case 925:
  2216. case 926:
  2217. case 927:
  2218. case 928:
  2219. case 929:
  2220. case 930:
  2221. case 931:
  2222. case 932:
  2223. case 933:
  2224. case 934:
  2225. case 935:
  2226. case 936:
  2227. case 937:
  2228. case 938:
  2229. if (!_.contains(v.options.showSpouse, v.model.get("FieldItem").FieldData.Ordinal)) {
  2230. p = true
  2231. }
  2232. break;
  2233. case 906:
  2234. case 907:
  2235. case 908:
  2236. case 909:
  2237. case 910:
  2238. case 911:
  2239. case 912:
  2240. case 913:
  2241. case 914:
  2242. if (!_.contains(v.options.showSpouse, v.model.get("FieldItem").FieldData.Ordinal)) {
  2243. p = true
  2244. }
  2245. if (!_.contains(v.options.spouseHouseholdAddress, v.model.get("FieldItem").FieldData.Ordinal)) {
  2246. p = true
  2247. }
  2248. break
  2249. }
  2250. s = v.model.get("FieldBlockId") === 200 ? "200" : v.options.parents.join(",");
  2251. v.$el.html(w({
  2252. model: v.model.toJSON(),
  2253. parents: s,
  2254. hide: p,
  2255. hideOther: q
  2256. }));
  2257. if (v.model.get("FieldItem").Id == 198) {
  2258. u = d.getDateString();
  2259. $('[data-fieldblockid="' + v.model.get("FieldItem").FieldData.FieldBlockId + '"]').val(u);
  2260. $('[data-fieldblockid="' + v.model.get("FieldItem").FieldData.FieldBlockId + '"]').trigger("change")
  2261. }
  2262. if (v.model.get("FieldItem").Id == 338) {
  2263. u = d.getDateString();
  2264. $('[data-fieldblockid="338"]').val(u);
  2265. $('[data-fieldblockid="338"]').trigger("change")
  2266. }
  2267. e.Us.initialize(".date-input", {
  2268. yearRange: "-30:+20"
  2269. });
  2270. k.Us.initialize(".time-input");
  2271. $(".required-indicator").tooltip();
  2272. v.$("textarea").trigger(jQuery.Event("keyup"));
  2273. p3.Us.PluginManager.Load(p3.Us.PluginManager.Plugins.AutoSize, function () {
  2274. v.$("textarea").autosize()
  2275. });
  2276. v.$("select.input-country").on("change", v.changeCountry);
  2277. v.$("select.input-country").on("changecountry", v.changeCountry);
  2278. p3.Us.PluginManager.Load(p3.Us.PluginManager.Plugins.jQueryUI, function () {
  2279. p3.Us.PluginManager.Load(p3.Us.PluginManager.Plugins.FileUpload, function () {
  2280. v.initializeFileUpload_File(v)
  2281. })
  2282. });
  2283. if ((a.Data.Submitted) && (v.options.lockedSection == false)) {
  2284. v.fieldValidate()
  2285. }
  2286. if ((a.Data.PaymentSubmitted) && (v.options.lockedSection == true)) {
  2287. v.fieldValidate()
  2288. }
  2289. if (a.Data.FormSaveType === 2) {
  2290. o = v.model.get("FieldItem");
  2291. if (o.FieldData.Data) {
  2292. v.storeFormData(o.FieldData, o.FieldData.Data)
  2293. }
  2294. }
  2295. if (v.options.lastField) {
  2296. _.defer(function () {
  2297. $("select.input-country").trigger("changecountry")
  2298. })
  2299. }
  2300. if (_.isFunction(n)) {
  2301. n()
  2302. }
  2303. })
  2304. },
  2305. fieldValidate: function (n) {
  2306. var o = this;
  2307. if (o.$(".applicationrender-field").is(":visible")) {
  2308. return o.model.isValid(true)
  2309. }
  2310. },
  2311. fieldValid: function (n) {
  2312. var o = this;
  2313. Bb.Validation.callbacks.valid(o, "FieldItem.FieldData.Data", "name")
  2314. },
  2315. fieldInvalid: function (n, o) {
  2316. var p = this;
  2317. Bb.Validation.callbacks.invalid(p, "FieldItem.FieldData.Data", o, "name")
  2318. },
  2319. fieldInvalidProvinceOther: function (n, o) {
  2320. var p = this;
  2321. Bb.Validation.callbacks.invalid(p, "input-province-other", o, "class")
  2322. },
  2323. changeCountry: function () {
  2324. var s = this,
  2325. r = $(s).data("sectionitem"),
  2326. n = $("select[data-sectionitem=" + r + "].input-country"),
  2327. q = $("select[data-sectionitem=" + r + "].input-state"),
  2328. o = $("select[data-sectionitem=" + r + "].input-province"),
  2329. p = $("input[data-sectionitem=" + r + "].input-province-other");
  2330. if (n.is(":visible")) {
  2331. if ((n.length) && (n.val() === "United States")) {
  2332. q.parents(".applicationrender-field").show();
  2333. o.parents(".applicationrender-field").hide();
  2334. o.val("");
  2335. p.parents(".applicationrender-field").hide();
  2336. p.val("")
  2337. } else {
  2338. if ((n.length) && (n.val() === "Canada" || n.val() === "United Kingdom" || n.val() === "Australia")) {
  2339. q.parents(".applicationrender-field").hide();
  2340. q.val("");
  2341. o.trigger("filterprovince", [n.val(), o.val()]);
  2342. o.parents(".applicationrender-field").show();
  2343. p.parents(".applicationrender-field").hide();
  2344. p.val("")
  2345. } else {
  2346. q.parents(".applicationrender-field").hide();
  2347. q.val("");
  2348. o.parents(".applicationrender-field").hide();
  2349. o.val("");
  2350. p.parents(".applicationrender-field").show()
  2351. }
  2352. }
  2353. } else {
  2354. q.parents(".applicationrender-field").hide();
  2355. o.parents(".applicationrender-field").hide();
  2356. p.parents(".applicationrender-field").hide()
  2357. }
  2358. },
  2359. filterProvince: function (o, n, q) {
  2360. var r = this,
  2361. p = [];
  2362. r.$el.find("option").remove();
  2363. p.push('<option value="">-- Select an Option --</option>');
  2364. _.each(_.where(r.model.get("FieldItem").LookUpList, {
  2365. dd_data: n
  2366. }), function (s) {
  2367. p.push('<option value="' + s.dd_id + '">' + s.dd_description + "</option>")
  2368. });
  2369. r.$el.find("select").html(p.join(""));
  2370. r.$el.find("select").val(q)
  2371. },
  2372. initializeFileUpload_File: function (p) {
  2373. var n = p.model.get("FieldItem").UIType,
  2374. o = (n === "IMG") ? p3.Us.Enum.UploadType.IMAGE : p3.Us.Enum.UploadType.DOCIMAGE;
  2375. p.$("#fileUpload").fileupload({
  2376. url: p3.Config.RootPath + "utilities/FileTransferHandler.ashx",
  2377. autoUpload: true,
  2378. acceptFileTypes: o.ValidExtensions,
  2379. formData: {
  2380. safeName: true
  2381. },
  2382. add: function (r, q) {
  2383. var s = p3.Us.FileTools.isValidFile(o, q.files[0].name);
  2384. if (s) {
  2385. q.submit()
  2386. } else {
  2387. p.$("#attachment-file").empty();
  2388. p.$("#attachment-file").append(p3.Us.FileTools.validateFiles(o, q))
  2389. }
  2390. }
  2391. }).bind("fileuploaddone", function (r, q) {
  2392. p.$("#attachment-file").html(q.result[0].original_name);
  2393. p.model.get("FieldItem").FieldData.AttachmentFile.Attachment = q.result[0].original_name;
  2394. p.model.get("FieldItem").FieldData.AttachmentFile.AttachmentTemp = q.result[0].name;
  2395. p.model.get("FieldItem").FieldData.Data = q.result[0].original_name;
  2396. _.each($(".tooltip"), function (s) {
  2397. $(s).hide()
  2398. });
  2399. p.$("#fileUpload").hide();
  2400. p.$(".delete-attachment-file").show();
  2401. p.$el.trigger("updatemodel")
  2402. })
  2403. },
  2404. deleteAttachmentFile: function (n) {
  2405. var o = this;
  2406. n.stopPropagation();
  2407. n.preventDefault();
  2408. o.model.get("FieldItem").FieldData.AttachmentFile.AttachmentRemove = o.model.get("FieldItem").FieldData.AttachmentFile.Attachment;
  2409. o.model.get("FieldItem").FieldData.AttachmentFile.Attachment = null;
  2410. o.model.get("FieldItem").FieldData.Data = null;
  2411. o.$("#attachment-file").empty();
  2412. o.$("#fileUpload").show();
  2413. o.$(".delete-attachment-file").hide();
  2414. o.$el.trigger("updatemodel")
  2415. },
  2416. updateCharacterCounter: function (n) {
  2417. var o = this;
  2418. n.stopPropagation();
  2419. n.preventDefault();
  2420. o.$(".characterCounter").html($(n.currentTarget).val().length)
  2421. },
  2422. parent: function (n) {
  2423. var o = this;
  2424. a.Vs.ParentEvent(n, o)
  2425. },
  2426. updateModel: function (p, n) {
  2427. var x = this,
  2428. v = $(p.currentTarget),
  2429. u = v.attr("name"),
  2430. w, o = {},
  2431. t, s, r, q;
  2432. n = !m.isEmptier(n) ? n : true;
  2433. if (x.model.get("FieldBlockId") === 740 || x.model.get("FieldBlockId") === 755) {
  2434. n = false
  2435. }
  2436. _.defer(function () {
  2437. if (x.model.get("FieldItem").OtherInd) {
  2438. w = v.prop("value");
  2439. if (x.model.get("FieldItem").UIType === "CheckBoxSingleSelect") {
  2440. if (v.hasClass("radio-input")) {
  2441. w = v.find("input").prop("value");
  2442. u = v.parent().attr("name");
  2443. if (l.stringToInt(w) === -1) {
  2444. if (!m.isEmptier(v.siblings(".other-text").val())) {
  2445. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.OtherDescription", v.siblings(".other-text").val())
  2446. }
  2447. } else {
  2448. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.OtherDescription", "");
  2449. v.parent().find(".other-text").val("")
  2450. }
  2451. } else {
  2452. if (v.hasClass("other-text")) {
  2453. if (!m.isEmptier(v.val())) {
  2454. v.siblings(".radio-input").removeClass("active");
  2455. v.siblings(".other-input").addClass("active");
  2456. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.Data", "-1")
  2457. } else {
  2458. v.siblings(".other-input").removeClass("active");
  2459. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.Data", "")
  2460. }
  2461. }
  2462. }
  2463. } else {
  2464. if (x.model.get("FieldItem").UIType === "CheckBoxMultiSelect") {
  2465. if (v.hasClass("checkbox-multi-input")) {
  2466. u = v.parent().attr("name");
  2467. w = v.siblings("label.active").andSelf().map(function () {
  2468. var y = $(this);
  2469. if (y.hasClass("active")) {
  2470. return y.find("input").val()
  2471. }
  2472. }).get();
  2473. w = w.join();
  2474. if (!_.contains(w.split(","), "-1")) {
  2475. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.OtherDescription", "");
  2476. v.parent().find(".other-text").prop("value", "")
  2477. }
  2478. } else {
  2479. if (v.hasClass("other-text")) {
  2480. if (!m.isEmptier(v.val())) {
  2481. v.siblings(".other-input").addClass("active");
  2482. t = v.siblings("label.active").andSelf().map(function () {
  2483. var y = $(this);
  2484. if (y.hasClass("active")) {
  2485. return y.find("input").val()
  2486. }
  2487. }).get();
  2488. t = t.join();
  2489. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.Data", t)
  2490. } else {
  2491. v.siblings(".other-input").removeClass("active");
  2492. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.Data", "")
  2493. }
  2494. }
  2495. }
  2496. } else {
  2497. if (x.model.get("FieldItem").UIType === "DD") {
  2498. if (v.hasClass("other-input")) {
  2499. if (l.stringToInt(w) === -1) {
  2500. v.siblings(".other-text-holder").show()
  2501. } else {
  2502. v.siblings(".other-text-holder").hide();
  2503. v.siblings(".other-text-holder").children(".other-text").prop("value", "");
  2504. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.OtherDescription", "")
  2505. }
  2506. } else {
  2507. if (v.hasClass("other-text")) {
  2508. if (m.isEmptier(v.prop("value"))) {
  2509. v.parent().hide();
  2510. v.parent().siblings(".other-input").prop("value", "");
  2511. j.Us.setPropByString(x.model.toJSON(), "FieldItem.FieldData.Data", "")
  2512. }
  2513. }
  2514. }
  2515. }
  2516. }
  2517. }
  2518. } else {
  2519. if (v.hasClass("radio-input")) {
  2520. w = v.children("input").prop("value");
  2521. u = v.parent().attr("name")
  2522. } else {
  2523. if (v.hasClass("checkbox-input")) {
  2524. w = (v.hasClass("btn-approve") && v.hasClass("active")).toString();
  2525. u = v.parent().attr("name")
  2526. } else {
  2527. if (v.hasClass("checkbox-multi-input")) {
  2528. w = v.siblings("label.active").map(function () {
  2529. return $(this).find("input").val()
  2530. }).get();
  2531. if (v.hasClass("active")) {
  2532. w.push(v.find("input").val())
  2533. }
  2534. w = w.join();
  2535. u = v.parent().attr("name")
  2536. } else {
  2537. if (v.hasClass("dateexp-input")) {
  2538. if (v.hasClass("month")) {
  2539. w = v.prop("value") + "/" + v.siblings(".year").prop("value")
  2540. } else {
  2541. if (v.hasClass("year")) {
  2542. w = v.siblings(".month").prop("value") + "/" + v.prop("value")
  2543. }
  2544. }
  2545. } else {
  2546. w = v.prop("value")
  2547. }
  2548. }
  2549. }
  2550. }
  2551. }
  2552. if (a.Data.FormSaveType === 1) {
  2553. if (!_.contains(u, ".")) {
  2554. o[u] = w;
  2555. x.model.set(o)
  2556. } else {
  2557. j.Us.setPropByString(x.model.toJSON(), u, w)
  2558. }
  2559. x.saveModel(n);
  2560. if (x.model.collection && _.contains([682, 696], x.model.get("FieldBlockId"))) {
  2561. s = x.model.get("SectionItemId");
  2562. r = j.Us.getPropByString(x.model.attributes, "FieldItem.FieldData.Ordinal");
  2563. q = _.filter(x.model.collection.models, function (y) {
  2564. return (y.get("SectionItemId") === s) && j.Us.getPropByString(y.attributes, "FieldItem.FieldData.FieldId") && (j.Us.getPropByString(y.attributes, "FieldItem.FieldData.Ordinal") === r)
  2565. });
  2566. _.each(q, function (y) {
  2567. j.Us.setPropByString(y.toJSON(), "FieldItem.FieldData.IsBlockEnabled", l.stringToBoolean(w))
  2568. })
  2569. }
  2570. } else {
  2571. if (a.Data.FormSaveType === 2) {
  2572. j.Us.setPropByString(x.model.toJSON(), u, w);
  2573. x.storeFormData(x.model.get("FieldItem").FieldData, w)
  2574. }
  2575. }
  2576. })
  2577. },
  2578. storeFormData: function (o, r) {
  2579. var s = this,
  2580. n = s.model.get("FieldElementItemId"),
  2581. p = m.isEmptier(o.Interest),
  2582. q = _.find(a.Data.FormData, function (t) {
  2583. return t.FieldElementItemId === n && t.Ordinal === o.Ordinal && (t.Interest === o.Interest || p)
  2584. });
  2585. if (q) {
  2586. q.data = r
  2587. } else {
  2588. a.Data.FormData.push({
  2589. data: r,
  2590. Ordinal: o.Ordinal,
  2591. FieldElementItemId: n,
  2592. Interest: o.Interest,
  2593. DataType: o.DataType
  2594. })
  2595. }
  2596. },
  2597. saveModel: function (n) {
  2598. var o = this;
  2599. o.model.defaults = $.extend(true, {}, o.model.attributes);
  2600. if (o.model.isValid(true)) {
  2601. o.model.get("FieldItem").FieldData.IsDirty = false
  2602. } else {
  2603. if ((o.model.get("FieldBlockId") == 143) || (o.model.get("FieldBlockId") == 208)) {
  2604. o.model.get("FieldItem").FieldData.IsDirty = false
  2605. } else {
  2606. o.model.get("FieldItem").FieldData.IsDirty = true
  2607. }
  2608. }
  2609. o.model.set({
  2610. FieldsToNull: []
  2611. });
  2612. _.each(o.model.attributes, function (r, p, q) {
  2613. j.Us.setFieldsToNull(o.model, r, p, q, "")
  2614. });
  2615. if ((!a.Data.Preview) && (o.options.lockedSection == false)) {
  2616. o.model.save({}, {
  2617. dataParam: {
  2618. returnFieldData: true
  2619. },
  2620. async: n,
  2621. success: function (p, q) {
  2622. if (q.FieldItem.DataTypeId === 2) {
  2623. o.model.set(q);
  2624. if (o.model.get("FieldItem").Id != 198) {
  2625. o.$(".date-input").val(o.model.get("FieldItem").FieldData.Data)
  2626. }
  2627. }
  2628. if (o.model.get("FieldBlockId") == 180 && o.model.get("FieldItem").FieldData.Data == "false") {
  2629. var s = o.model.get("FieldItem").FieldData.Interest,
  2630. r = o.model.get("FieldBlockId");
  2631. $("[data-parentid=" + r + "][data-interestid=" + s + "]").val("");
  2632. $("[data-fieldblockid=183][data-interestid=" + s + "]").removeClass("active")
  2633. }
  2634. if (o.model.get("FieldItem").Id === 29 || o.model.get("FieldItem").Id === 279) {
  2635. $(".application-navigation li.active").trigger("refreshsection", {
  2636. scrollTop: $(document).scrollTop()
  2637. })
  2638. }
  2639. },
  2640. error: function (q, p) {
  2641. if (p.responseText.indexOf("Invalid Date.") > -1) {
  2642. $(o.el).trigger("fieldinvalid", ["Invalid Date."])
  2643. } else {
  2644. if (p.responseText.indexOf("Invalid Future Birth Date.") > 0) {
  2645. $(o.el).trigger("fieldinvalid", [h.Login.MaxDateOfBirth])
  2646. }
  2647. }
  2648. p3.displayError("Error saving field data")
  2649. }
  2650. })
  2651. }
  2652. },
  2653. deleteElement: function () {
  2654. $(this.el).remove()
  2655. },
  2656. addDDOptGroups: function (n) {
  2657. var o = "";
  2658. if (n && n.length && n[0].hasOwnProperty("opt_group")) {
  2659. _.each(n, function (q, p) {
  2660. if (q.opt_group !== o) {
  2661. o = q.opt_group;
  2662. if (p > 0) {
  2663. n[p - 1].OptGroupEnd = true
  2664. }
  2665. q.OptGroup = o
  2666. }
  2667. });
  2668. _.last(n).OptGroupEnd = true
  2669. }
  2670. },
  2671. filterLookupList: function (n, p) {
  2672. var q = this,
  2673. o = q.model.get("FieldItem");
  2674. if (q.model.LookUpListBak) {
  2675. o.LookUpList = _.clone(q.model.LookUpListBak)
  2676. } else {
  2677. q.model.LookUpListBak = _.clone(o.LookUpList)
  2678. }
  2679. if (p) {
  2680. switch (n) {
  2681. case 426:
  2682. o.LookUpList = _.where(o.LookUpList, {
  2683. level_num: l.stringToInt(p)
  2684. });
  2685. break
  2686. }
  2687. }
  2688. }
  2689. });
  2690. a.Vs.ParentEvent = function (u, D) {
  2691. var o = $(u.currentTarget),
  2692. B = o.val(),
  2693. y = o.data("fieldblockid"),
  2694. z = o.data("ordinalid"),
  2695. A = o.data("subordinalid"),
  2696. p = [205, 206, 207, 311, 313, 314],
  2697. t = [236, 237, 238, 239, 312, 315, 316, 317],
  2698. v = [203, 204, 228, 229, 230, 231, 232, 233, 234, 235, 300, 301, 302, 303, 304, 305, 306, 307, 308, 320],
  2699. w = [228, 231, 232, 233, 234, 235, 302, 305, 306, 307, 308, 320],
  2700. q = o.parents(".fields"),
  2701. C, r, s, n = $("[data-fieldblockid=913]"),
  2702. x = $(".active[data-fieldblockid=905] > input").val();
  2703. if (o.hasClass("radio-input")) {
  2704. B = o.children("input").prop("value")
  2705. }
  2706. switch (y) {
  2707. case 200:
  2708. if (l.stringToBoolean(B)) {
  2709. $(q).find("[data-fieldblockid=201]").parents(".applicationrender-field").show();
  2710. $(q).find("[data-fieldblockid=202]").parents(".applicationrender-field").hide();
  2711. a.Us.FieldBlockVisibility(q, t, false);
  2712. a.Us.FieldBlockVisibility(q, p, false);
  2713. a.Us.FieldBlockVisibility(q, v, false)
  2714. } else {
  2715. $(q).find("[data-fieldblockid=201]").parents(".applicationrender-field").hide().find("input").val("");
  2716. $(q).find("[data-fieldblockid=202]").parents(".applicationrender-field").show().find("select").val("")
  2717. }
  2718. break;
  2719. case 310:
  2720. case 202:
  2721. B = l.stringToInt(B);
  2722. if (_.contains([1, 2, 3, 4], B)) {
  2723. a.Us.FieldBlockVisibility(q, t, false);
  2724. a.Us.FieldBlockVisibility(q, p, true);
  2725. a.Us.FieldBlockVisibility(q, v, true);
  2726. $(q).find("select.input-country").trigger("changecountry")
  2727. } else {
  2728. if (B === 5) {
  2729. a.Us.FieldBlockVisibility(q, t, true);
  2730. a.Us.FieldBlockVisibility(q, p, false);
  2731. a.Us.FieldBlockVisibility(q, v, true);
  2732. if ($(q).find("[data-fieldblockid=238]").children().length < 2) {
  2733. $(q).find("[data-fieldblockid=238]").parents(".applicationrender-field").hide().find("select").val("")
  2734. }
  2735. $(q).find("select.input-country").trigger("changecountry")
  2736. } else {
  2737. if (B === -1) {
  2738. a.Us.FieldBlockVisibility(q, t, false);
  2739. a.Us.FieldBlockVisibility(q, p, false);
  2740. a.Us.FieldBlockVisibility(q, v, false);
  2741. if (a.Data.SecurePaymentProcessingType === 2) {
  2742. a.Us.FieldBlockVisibility(q, w, true);
  2743. $(q).find("select.input-country").trigger("changecountry")
  2744. }
  2745. } else {
  2746. if (B === "") {
  2747. a.Us.FieldBlockVisibility(q, t, false);
  2748. a.Us.FieldBlockVisibility(q, p, false);
  2749. a.Us.FieldBlockVisibility(q, v, false)
  2750. }
  2751. }
  2752. }
  2753. }
  2754. break;
  2755. case 180:
  2756. case 452:
  2757. _.defer(function () {
  2758. var E = o.data("interestid");
  2759. if (l.stringToBoolean(B) === true || (o.hasClass("btn-approve") && o.hasClass("active"))) {
  2760. $("[data-parentid=" + y + "][data-interestid=" + E + "]").parents(".applicationrender-field").show()
  2761. } else {
  2762. $("[data-parentid=" + y + "][data-interestid=" + E + "]").parents(".applicationrender-field").hide()
  2763. }
  2764. });
  2765. break;
  2766. case 160:
  2767. case 162:
  2768. case 164:
  2769. case 166:
  2770. case 169:
  2771. if (l.stringToBoolean(B) === true) {
  2772. $("[data-parentid=" + y + "]").parents(".applicationrender-field").show()
  2773. } else {
  2774. $("[data-parentid=" + y + "]").val("");
  2775. $("[data-parentid=" + y + "]").parents(".applicationrender-field").hide()
  2776. }
  2777. break;
  2778. case 682:
  2779. case 696:
  2780. case 700:
  2781. case 740:
  2782. case 748:
  2783. case 755:
  2784. case 760:
  2785. if (l.stringToBoolean(B) === true) {
  2786. $("[data-parentid=" + y + "][data-ordinalid=" + z + "]").parents(".applicationrender-field").show()
  2787. } else {
  2788. $("[data-parentid=" + y + "][data-ordinalid=" + z + "]").parents(".applicationrender-field").hide();
  2789. a.Us.ParentsHide(y, z)
  2790. }
  2791. break;
  2792. case 753:
  2793. case 765:
  2794. if (l.stringToInt(B) === 2) {
  2795. $("[data-parentid=" + y + "][data-ordinalid=" + z + "][data-subordinalid=" + A + "]").parents(".applicationrender-field").show()
  2796. } else {
  2797. $("[data-parentid=" + y + "][data-ordinalid=" + z + "][data-subordinalid=" + A + "]").parents(".applicationrender-field").hide()
  2798. }
  2799. break;
  2800. case 361:
  2801. if (l.stringToBoolean(B) === true) {
  2802. $("[data-parentid=" + y + "][data-ordinalid=" + z + "]").val("");
  2803. $("[data-parentid=" + y + "][data-ordinalid=" + z + "]").trigger("change");
  2804. $("[data-parentid=" + y + "][data-ordinalid=" + z + "]").parents(".applicationrender-field").hide()
  2805. } else {
  2806. $("[data-parentid=" + y + "][data-ordinalid=" + z + "]").parents(".applicationrender-field").show();
  2807. if ($("[data-parentid=" + y + "][data-ordinalid=" + z + "][data-fieldblockid=369]")) {
  2808. r = D.model.collection.find(function (E) {
  2809. return E.get("FieldBlockId") === 369
  2810. });
  2811. s = r.attributes.FieldItem.LookUpList.filter(function (E) {
  2812. return E.dd_default === 1
  2813. })[0];
  2814. $("[data-parentid=" + y + "][data-ordinalid=" + z + "][data-fieldblockid=369]")[0].value = s.dd_description;
  2815. $("[data-parentid=" + y + "][data-ordinalid=" + z + "][data-fieldblockid=369]").trigger("change")
  2816. }
  2817. }
  2818. break;
  2819. case 866:
  2820. if (D && D.model.collection) {
  2821. C = D.model.collection.find(function (E) {
  2822. return E.get("FieldBlockId") === 426
  2823. });
  2824. if (C) {
  2825. j.Us.setPropByString(D.model.toJSON(), "FieldItem.FieldData.Data", B);
  2826. j.Us.setPropByString(C.toJSON(), "FieldItem.FieldData.Data", "");
  2827. _.defer(function () {
  2828. C.view.renderData(function () {
  2829. q.find("[data-fieldblockid=426]").trigger("change")
  2830. })
  2831. })
  2832. }
  2833. }
  2834. break;
  2835. case 939:
  2836. if (l.stringToBoolean(B) === true) {
  2837. $("[data-parentid=" + y + "][data-ordinalid=" + z + "]").parents(".applicationrender-field").show();
  2838. if (x === "false" || x === undefined) {
  2839. a.Us.FieldBlockVisibility(q, [906, 907, 908, 909, 912, 913, 914], true);
  2840. if (n.val() !== "") {
  2841. n.val(n.val()).trigger("change")
  2842. }
  2843. }
  2844. } else {
  2845. $("[data-parentid=" + y + "][data-ordinalid=" + z + "]").parents(".applicationrender-field").hide();
  2846. a.Us.FieldBlockVisibility(q, [906, 907, 908, 909, 910, 911, 912, 913, 914], false)
  2847. }
  2848. break
  2849. }
  2850. };
  2851. a.Vs.Error = Bb.View.extend({
  2852. template: "form/form.error.template.html",
  2853. className: "alert",
  2854. initialize: function (n) {
  2855. var o = this;
  2856. o.errorMsg = n.errorMsg || false;
  2857. o.medical = n.medical || false
  2858. },
  2859. events: {
  2860. "click .allow": "allowMedical"
  2861. },
  2862. render: function (n) {
  2863. var o = this;
  2864. $(n).append(o.el);
  2865. if (o.medical) {
  2866. $(o.el).addClass("alert-info")
  2867. } else {
  2868. $(o.el).addClass("alert-danger")
  2869. }
  2870. o.renderData()
  2871. },
  2872. renderData: function () {
  2873. var n = this;
  2874. if (n.errorMsg) {
  2875. p3.fT(n.template, function (o) {
  2876. n.$el.html(o({
  2877. errorMsg: n.errorMsg,
  2878. medical: n.medical
  2879. }))
  2880. })
  2881. }
  2882. },
  2883. allowMedical: function (n) {
  2884. n.preventDefault();
  2885. var o = this;
  2886. $.ajax({
  2887. async: true,
  2888. method: "PUT",
  2889. url: aP + "SchoolForm/MedicalOverride",
  2890. dataType: "json",
  2891. data: {
  2892. id: a.Data.Id
  2893. },
  2894. success: function (p) {
  2895. o.$el.remove()
  2896. },
  2897. error: function () {
  2898. p3.displayError("Setting could not be saved.")
  2899. }
  2900. });
  2901. o.$el.remove()
  2902. }
  2903. });
  2904. a.Vs.AddBlockSelect = Bb.View.extend({
  2905. template: "form/form.block.blockselect.template.html",
  2906. render: function (n) {
  2907. var o = this;
  2908. $(n).append(o.el);
  2909. o.renderData()
  2910. },
  2911. renderData: function () {
  2912. var n = this;
  2913. p3.fT(n.template, function (o) {
  2914. n.$el.html(o({
  2915. collection: n.collection.toJSON()
  2916. }))
  2917. })
  2918. }
  2919. });
  2920. a.Vs.SectionItemBlock_Payment = Bb.View.extend({
  2921. template: "form/form.section.item.block.payment.template.html",
  2922. className: "form-section-item form-horizontal",
  2923. render: function (n) {
  2924. var o = this;
  2925. $(n).append(o.el);
  2926. o.renderData()
  2927. },
  2928. renderData: function () {
  2929. var n = this;
  2930. p3.fT(n.template, function (o) {
  2931. n.$el.html(o({
  2932. lockedSectionType: n.options.lockedSectionType,
  2933. payment: n.options.paymentCheck.toJSON()
  2934. }))
  2935. })
  2936. }
  2937. });
  2938. a.Vs.SectionItemBlock_ESignatures = Bb.View.extend({
  2939. template: "form/form.block.esignatures.template.html",
  2940. className: "form-section-item form-horizontal",
  2941. initialize: function () {
  2942. var n = this;
  2943. n.collection = new a.Cs.ESignaturesRender()
  2944. },
  2945. render: function (n) {
  2946. var o = this;
  2947. $(n).append(o.el);
  2948. o.renderData()
  2949. },
  2950. renderData: function () {
  2951. var q = this,
  2952. n = q.model.get("FieldBlockItem").Id,
  2953. p, o;
  2954. p3.fT(q.template, function (r) {
  2955. if (a.Data.Preview) {
  2956. p = new a.Ms.SignatureLabels();
  2957. p.fetch({
  2958. data: {
  2959. applicationFormId: a.Data.FormId,
  2960. blockId: n
  2961. },
  2962. success: function () {
  2963. q.$el.html(r({
  2964. model: p.toJSON()
  2965. }));
  2966. if (n === 39) {
  2967. q.collection.add([{
  2968. FirstName: "Jonathan",
  2969. LastName: "Whipple"
  2970. }])
  2971. } else {
  2972. q.collection.add([{
  2973. FirstName: "Pat",
  2974. LastName: "Whipple"
  2975. }, {
  2976. FirstName: "Sue",
  2977. LastName: "Whipple"
  2978. }])
  2979. }
  2980. q.renderUsers(q.collection.models)
  2981. }
  2982. })
  2983. } else {
  2984. q.collection.fetch({
  2985. update: true,
  2986. cache: false,
  2987. data: {
  2988. formId: a.Data.FormId,
  2989. keyId: a.Data.KeyId
  2990. },
  2991. success: function () {
  2992. o = q.collection.filter(function (s) {
  2993. return s.get("BlockId") === n
  2994. });
  2995. if (o.length) {
  2996. q.$el.html(r({
  2997. model: {
  2998. DateFieldLabel: o[0].get("DateLabel"),
  2999. SignatureFieldLabel: o[0].get("SignatureLabel")
  3000. }
  3001. }))
  3002. }
  3003. q.renderUsers(o)
  3004. }
  3005. })
  3006. }
  3007. })
  3008. },
  3009. renderUsers: function (n) {
  3010. var o = this;
  3011. _(n).each(function (q) {
  3012. var p = new a.Vs.SectionItemBlock_ESignature({
  3013. model: q,
  3014. layoutView: o.options.layoutView,
  3015. lockedSectionType: o.options.lockedSectionType
  3016. });
  3017. p3.rV(p, o.$("#esignature"), false)
  3018. })
  3019. }
  3020. });
  3021. a.Vs.SectionItemBlock_ESignature = Bb.View.extend({
  3022. template: "form/form.block.esignature.template.html",
  3023. className: "row-fluid",
  3024. initialize: function () {
  3025. var n = this;
  3026. Bb.Validation.bind(n, {
  3027. forceUpdate: true,
  3028. selector: "name"
  3029. })
  3030. },
  3031. events: {
  3032. 'change input[type="text"]': "saveSignature",
  3033. fieldvalidate: "fieldValidate"
  3034. },
  3035. render: function (n) {
  3036. var o = this;
  3037. $(n).append(o.el);
  3038. o.renderData()
  3039. },
  3040. renderData: function () {
  3041. var o = this,
  3042. n = false;
  3043. p3.fT(o.template, function (p) {
  3044. if (o.options.lockedSectionType === 4 || o.model.get("IsAccepted") == true || o.model.get("UserId") != p3.Data.Context.attributes.UserInfo.UserId) {
  3045. n = true
  3046. }
  3047. o.$el.html(p({
  3048. model: o.model.toJSON(),
  3049. sectionItemLocked: n
  3050. }));
  3051. if ((a.Data.Submitted) && (m.isEmptier(o.options.lockedSectionType))) {
  3052. o.fieldValidate()
  3053. }
  3054. })
  3055. },
  3056. saveSignature: function (o) {
  3057. o.preventDefault();
  3058. var s = this,
  3059. q = $(o.currentTarget),
  3060. p = q.attr("name"),
  3061. r, n = {};
  3062. r = q.prop("value");
  3063. n[p] = r;
  3064. s.model.set(n);
  3065. if (!a.Data.Preview && !m.isEmptier(r)) {
  3066. s.model.save({}, {
  3067. success: function (t, u) {
  3068. s.model.set({
  3069. ContractSignatureId: parseInt(u.Message, 10)
  3070. })
  3071. }
  3072. })
  3073. }
  3074. },
  3075. fieldValidate: function (n) {
  3076. var o = this;
  3077. return o.model.isValid(true)
  3078. }
  3079. });
  3080. a.Vs.SectionItemBlock_RatingMatrix = Bb.View.extend({
  3081. template: "form/form.block.rating.matrix.template.html",
  3082. className: "ratings-matrix",
  3083. events: {
  3084. "click .rating-level-radio": "selectRatingLevel",
  3085. "change .rating-level-dropdown": "selectRatingLevel",
  3086. "keyup .rating-comment": "copyComment",
  3087. "blur .rating-comment": "saveComment"
  3088. },
  3089. render: function (n) {
  3090. var o = this;
  3091. $(n).append(o.el);
  3092. o.renderData()
  3093. },
  3094. renderData: function () {
  3095. var o = this,
  3096. n;
  3097. if (o.options.sectionItemId) {
  3098. n = new a.Ms.RatingMatrix();
  3099. n.fetch({
  3100. data: {
  3101. formDataId: a.Data.Preview ? undefined : o.options.applicationId,
  3102. sectionItemId: o.options.sectionItemId
  3103. },
  3104. success: function (p) {
  3105. o.model = p;
  3106. p3.fT(o.template, function (q) {
  3107. o.$el.html(q({
  3108. model: o.model.toJSON(),
  3109. variables: {
  3110. SectionItemId: o.options.sectionItemId
  3111. }
  3112. }));
  3113. if (!a.Data.Preview && o.options.applicationId) {
  3114. o.preSelectRatingLevels();
  3115. if (_.contains(a.Data.InvalidSectionItemIds, o.options.sectionItemId)) {
  3116. $('.ratings-matrix > .ratings-matrix-validation-error[data-section-item-id="' + o.options.sectionItemId + '"]').show()
  3117. }
  3118. }
  3119. })
  3120. }
  3121. })
  3122. }
  3123. },
  3124. preSelectRatingLevels: function () {
  3125. var s = this,
  3126. r, p, q, o, n;
  3127. _.each(s.model.attributes.Rating.Scores, function (t) {
  3128. if (t.RatingLevelId) {
  3129. r = s.$('.rating-level-radio[data-rating-attribute-id="' + t.RatingAttributeId + '"][data-rating-level-id="' + t.RatingLevelId + '"]').first();
  3130. r[0].checked = true;
  3131. p = s.$('.rating-level-radio[data-rating-attribute-id="' + t.RatingAttributeId + '"]');
  3132. _.each(p, function (u) {
  3133. $(u).attr("data-rating-score-id", t.RatingScoreId)
  3134. });
  3135. q = s.$('.rating-level-dropdown-option[data-rating-attribute-id="' + t.RatingAttributeId + '"][data-rating-level-id="' + t.RatingLevelId + '"]');
  3136. q[0].selected = true;
  3137. o = s.$('.rating-level-dropdown[data-rating-attribute-id="' + t.RatingAttributeId + '"]');
  3138. $(o[0]).attr("data-rating-score-id", t.RatingScoreId);
  3139. n = s.$('.rating-comment[data-rating-attribute-id="' + t.RatingAttributeId + '"]');
  3140. _.each(n, function (u) {
  3141. $(u).attr("data-rating-score-id", t.RatingScoreId);
  3142. u.disabled = false
  3143. })
  3144. }
  3145. })
  3146. },
  3147. selectRatingLevel: function (o) {
  3148. var v = this,
  3149. n = $(o.target),
  3150. p = n.attr("data-rating-attribute-id"),
  3151. s, u = n.attr("data-rating-score-id"),
  3152. t = v.$('.rating-level-radio[data-rating-attribute-id="' + p + '"]'),
  3153. r, q = v.$('.rating-comment[data-rating-attribute-id="' + p + '"]');
  3154. _.each(t, function (w) {
  3155. w.checked = false
  3156. });
  3157. if (n.hasClass("rating-level-radio")) {
  3158. s = n.attr("data-rating-level-id");
  3159. r = v.$('.rating-level-dropdown-option[data-rating-attribute-id="' + p + '"][data-rating-level-id="' + s + '"]');
  3160. r[0].selected = true;
  3161. n.prop("checked", true)
  3162. }
  3163. if (n.hasClass("rating-level-dropdown")) {
  3164. s = n.children(":selected")[0].getAttribute("data-rating-level-id");
  3165. t = v.$('.rating-level-radio[data-rating-attribute-id="' + p + '"][data-rating-level-id="' + s + '"]');
  3166. if (t.length) {
  3167. t[0].checked = true
  3168. }
  3169. }
  3170. _.each(q, function (w) {
  3171. w.disabled = false
  3172. });
  3173. v.saveRatingMatrix(p, s, u)
  3174. },
  3175. copyComment: function (o) {
  3176. var q = this,
  3177. n = $(o.target),
  3178. p = n.attr("data-rating-attribute-id");
  3179. q.$('.rating-comment[data-rating-attribute-id="' + p + '"]').val(n.val())
  3180. },
  3181. saveComment: function () {
  3182. var u = this,
  3183. n = $(event.target),
  3184. p = n.attr("data-rating-attribute-id"),
  3185. q, t = n.attr("data-rating-score-id"),
  3186. o = n.val(),
  3187. r, s;
  3188. r = u.$('.rating-level-radio[data-rating-attribute-id="' + p + '"]');
  3189. s = _.filter(r, function (v) {
  3190. return v.checked === true
  3191. });
  3192. q = $(s).attr("data-rating-level-id");
  3193. u.saveRatingMatrix(p, q, t, o)
  3194. },
  3195. saveRatingMatrix: function (p, s, x, n) {
  3196. if (a.Data.Preview) {
  3197. return
  3198. }
  3199. var y = this,
  3200. u = y.model.get("RatingMatrix").RatingMatrixId,
  3201. v = new a.Ms.RatingMatrixSubmit(),
  3202. w, t, r, q, o;
  3203. if (!n) {
  3204. o = y.$('.rating-comment[data-rating-attribute-id="' + p + '"][data-rating-score-id="' + x + '"]').first();
  3205. n = o.val()
  3206. }
  3207. v.set({
  3208. ratingScore: {
  3209. FormDataId: y.model.get("FormDataId"),
  3210. SectionItemId: y.model.get("SectionItemId"),
  3211. RatingAttributeId: p,
  3212. RatingMatrixId: u,
  3213. RatingLevelId: s,
  3214. RatingScoreId: x,
  3215. Comment: n
  3216. }
  3217. });
  3218. v.save({}, {
  3219. success: function (z, A) {
  3220. w = _.filter(y.model.get("Rating").Scores, function (B) {
  3221. return B.RatingMatrixId === l.stringToInt(u) && B.RatingAttributeId === l.stringToInt(p)
  3222. });
  3223. w[0].RatingScoreId = A.RatingScoreId;
  3224. w[0].RatingLevelId = s;
  3225. t = y.$('.rating-level-radio[data-rating-attribute-id="' + p + '"]');
  3226. _.each(t, function (B) {
  3227. $(B).attr("data-rating-score-id", A.RatingScoreId)
  3228. });
  3229. r = y.$('.rating-level-dropdown-option[data-rating-attribute-id="' + p + '"]');
  3230. _.each(r, function (B) {
  3231. $(B).attr("data-rating-score-id", A.RatingScoreId)
  3232. });
  3233. q = y.$('.rating-comment[data-rating-attribute-id="' + p + '"]');
  3234. _.each(q, function (B) {
  3235. $(B).attr("data-rating-score-id", A.RatingScoreId)
  3236. })
  3237. },
  3238. error: function (A, z) {
  3239. p3.displayError("An error occurred saving your selection. Please try again.")
  3240. }
  3241. })
  3242. }
  3243. });
  3244. a.Us.FieldBlockVisibility = function (o, p, q) {
  3245. var n = $(o).find(".applicationrender-field");
  3246. if (q) {
  3247. _.each(n, function (t) {
  3248. var s = $(t),
  3249. r = s.find("input, select");
  3250. if (_.contains(p, r.data("fieldblockid"))) {
  3251. s.show()
  3252. }
  3253. })
  3254. } else {
  3255. _.each(n, function (t) {
  3256. var s = $(t),
  3257. r = s.find("input, select");
  3258. if (_.contains(p, r.data("fieldblockid"))) {
  3259. s.hide()
  3260. }
  3261. })
  3262. }
  3263. };
  3264. a.Us.AutoSizeIframe = function () {
  3265. if (parent && a.Data.IFrameSelector) {
  3266. $("body").addClass("h-auto-important");
  3267. setInterval(function () {
  3268. var n = {
  3269. eventName: "OnBoard.InquiryForm.Resize",
  3270. selector: a.Data.IFrameSelector,
  3271. newHeight: $("body").outerHeight() + "px"
  3272. };
  3273. parent.postMessage(n, "*")
  3274. }, 2000)
  3275. }
  3276. };
  3277. a.Us.ParentsHide = function (n, o) {
  3278. var p = $(".parent[data-parentid=" + n + "][data-ordinalid=" + o + "]").data("fieldblockid");
  3279. if (p) {
  3280. $("[data-parentid=" + p + "][data-ordinalid=" + o + "]").parents(".applicationrender-field").hide();
  3281. if ($("button.parent[data-parentid=" + n + "][data-ordinalid=" + o + "]").length > 0) {
  3282. $("button.parent[data-parentid=" + n + "][data-ordinalid=" + o + "][value=false]").trigger("click", [false])
  3283. } else {
  3284. if ($("select.parent[data-parentid=" + n + "][data-ordinalid=" + o + "]").length > 0) {
  3285. $("select.parent[data-parentid=" + n + "][data-ordinalid=" + o + "]").val("");
  3286. $(".parent[data-parentid=" + n + "][data-ordinalid=" + o + "]").trigger("change", [false])
  3287. }
  3288. }
  3289. }
  3290. };
  3291. a.Us.SetFormRequestHeaders = function (p, o) {
  3292. var n = o || a.Data.AuthToken;
  3293. if (n && p3.Config.AppMode.Name === "Embed") {
  3294. p.setRequestHeader("Form-Auth-Token", n)
  3295. }
  3296. };
  3297. a.Us.SetFormAuthSync = function (o) {
  3298. var n;
  3299. if (o && !o._isFormAuthSync) {
  3300. o._sync = o.sync;
  3301. o.sync = function (p, q, r) {
  3302. n = r.beforeSend;
  3303. r.beforeSend = function (t, s) {
  3304. a.Us.SetFormRequestHeaders(t);
  3305. if (n) {
  3306. n(t, s)
  3307. }
  3308. };
  3309. return o._sync(p, q, r)
  3310. };
  3311. o._isFormAuthSync = true
  3312. }
  3313. };
  3314. Hb.registerHelper("formSectionItemId", function (n) {
  3315. return new Hb.SafeString(!m.isEmptier(n) ? ' data-sectionitem="' + n + '"' : "")
  3316. });
  3317. Hb.registerHelper("formFieldId", function (n) {
  3318. return new Hb.SafeString(!m.isEmptier(n) ? ' data-fieldid="' + n + '"' : "")
  3319. });
  3320. Hb.registerHelper("formFieldBlockId", function (n) {
  3321. return new Hb.SafeString(!m.isEmptier(n) ? ' data-fieldblockid="' + n + '"' : "")
  3322. });
  3323. Hb.registerHelper("formOrdinalId", function (n) {
  3324. return new Hb.SafeString(!m.isEmptier(n) ? ' data-ordinalid="' + n + '"' : "")
  3325. });
  3326. Hb.registerHelper("formSubOrdinalId", function (n) {
  3327. return new Hb.SafeString(!m.isEmptier(n) ? ' data-subordinalid="' + n + '"' : "")
  3328. });
  3329. Hb.registerHelper("formParentId", function (n) {
  3330. return new Hb.SafeString(!m.isEmptier(n) ? ' data-parentid="' + n + '"' : "")
  3331. });
  3332. Hb.registerHelper("formMutexGroupId", function (n) {
  3333. return new Hb.SafeString(!m.isEmptier(n) ? ' data-mutexgroupid="' + n + '"' : "")
  3334. });
  3335. Hb.registerHelper("formInterestId", function (n) {
  3336. return new Hb.SafeString(!m.isEmptier(n) ? ' data-interestid="' + n + '"' : "")
  3337. });
  3338. Hb.registerHelper("formMaxLength", function (n) {
  3339. return new Hb.SafeString(!m.isEmptier(n) ? ' maxlength="' + n + '"' : "")
  3340. });
  3341. p3.router().route("application/:formid(/keyid=:keyid)(/r=:r)", "application", function (n, o, t) {
  3342. var q = false,
  3343. p = false,
  3344. s = null,
  3345. u;
  3346. if (o.match(/(r1|r0)/g)) {
  3347. u = o.split("r");
  3348. s = u[0];
  3349. t = u[1];
  3350. p3.router().navigate("#" + Bb.history.getFragment().slice(0, -2), false)
  3351. } else {
  3352. if (o === "preview") {
  3353. q = true
  3354. } else {
  3355. if (o === "local") {
  3356. p = true
  3357. } else {
  3358. s = o
  3359. }
  3360. }
  3361. }
  3362. a.Data.FormId = n;
  3363. a.Data.KeyId = s;
  3364. a.Data.Preview = q;
  3365. a.Data.Local = p;
  3366. a.Data.FormType = "Application";
  3367. a.Data.Submitted = false;
  3368. a.Data.PaymentSubmitted = false;
  3369. a.Data.FormSaveType = null;
  3370. a.Data.SecurePayment = false;
  3371. a.Data.SPResponse = t;
  3372. b.Us.GetStyle(a.Data.FormId, function (r) {
  3373. b.Us.SetStyle(r.StyleElements);
  3374. p3.renderMainPage(new a.Vs.Layout({}))
  3375. })
  3376. });
  3377. p3.router().route("inquiry/:formid(/keyid=:keyid)(/source=:source)(/selector=:selector)", "inquiry", function (o, p, t, s) {
  3378. var r = (p === "preview"),
  3379. q = (p === "local"),
  3380. n = (p === "admin");
  3381. t = t || null;
  3382. a.Data.FormId = o;
  3383. a.Data.KeyId = null;
  3384. a.Data.Preview = r;
  3385. a.Data.Local = q;
  3386. a.Data.Admin = n;
  3387. a.Data.Source = t;
  3388. a.Data.IFrameSelector = s + " > iframe";
  3389. a.Data.FormType = "Inquiry";
  3390. a.Data.Submitted = false;
  3391. a.Data.PaymentSubmitted = false;
  3392. a.Data.FormSaveType = null;
  3393. a.Data.FormData = [];
  3394. b.Us.GetStyle(a.Data.FormId, function (u) {
  3395. b.Us.SetStyle(u.StyleElements);
  3396. p3.renderMainPage(new a.Vs.Layout({}))
  3397. })
  3398. });
  3399. p3.router().route("schoolform/:formid(/keyid=:keyid)(/r=:r)", "schoolform", function (n, o, q) {
  3400. var p = false,
  3401. t = null,
  3402. s;
  3403. if (o.match(/(r1|r0)/g)) {
  3404. s = o.split("r");
  3405. t = s[0];
  3406. q = s[1];
  3407. p3.router().navigate("#" + Bb.history.getFragment().slice(0, -2), false)
  3408. } else {
  3409. if (o === "preview") {
  3410. p = true
  3411. } else {
  3412. t = o
  3413. }
  3414. }
  3415. a.Data.FormId = n;
  3416. a.Data.KeyId = t;
  3417. a.Data.Preview = p;
  3418. a.Data.FormType = "School Form";
  3419. a.Data.Submitted = false;
  3420. a.Data.PaymentSubmitted = false;
  3421. a.Data.FormSaveType = null;
  3422. a.Data.SecurePayment = false;
  3423. a.Data.SPResponse = q;
  3424. p3.renderMainPage(new a.Vs.Layout({}))
  3425. })
  3426. }(p3.module("admissions/formrender/application")));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement