1/** 2 * V3.1.9 3 */ 4 5// IE FIX FOR startsWith METHOD 6if (!String.prototype.startsWith) { 7 String.prototype.startsWith = function(searchString, position) { 8 position = position || 0; 9 return this.indexOf(searchString, position) === position; 10 }; 11} 12 13jQuery(document).ready(function() { 14 /*** CHECK IF FORMS ON THE PAGE ***/ 15 var forms = jQuery('form'); 16 var formBuilder = cmHipaaScript.formBuilder; 17 18 var calderaEnabledForms; 19 if(cmHipaaScript.calderaEnabledForms) { 20 calderaEnabledForms = JSON.parse(cmHipaaScript.calderaEnabledForms); 21 } 22 23 var gravityEnabledForms; 24 if(cmHipaaScript.gravityEnabledForms) { 25 gravityEnabledForms = JSON.parse(cmHipaaScript.gravityEnabledForms); 26 } 27 28 var enabledFormsSettings; 29 if(cmHipaaScript.enabledFormsSettings) { 30 enabledFormsSettings = JSON.parse(cmHipaaScript.enabledFormsSettings); 31 } 32 33 formIds = []; 34 // LOOP ENABLED CALDERA FORMS AND PUSH IDS TO ARRAY - DEPRECATED 35 for(var i = 0; i < calderaEnabledForms.length; i++){ 36 if(calderaEnabledForms[i]) { 37 formIds.push(calderaEnabledForms[i]); 38 } 39 } 40 41 // LOOP ENABLED GRAVITY FORMS AND PUSH IDS TO ARRAY - DEPRECATED 42 for(var i = 0; i < gravityEnabledForms.length; i++){ 43 if(gravityEnabledForms[i]) { 44 formIds.push('gform_' + gravityEnabledForms[i]); 45 } 46 } 47 /*** LOOP FORMS ***/ 48 forms.each(function() { 49 var form = jQuery(this); 50 var formMainId = form.attr('id'); 51 var formId = form.attr('data-form-id'); 52 if(!formId) { 53 formId = formMainId; 54 } 55 56 // SET NEW SUBMIT BUTTON 57 var newSubmitButton; 58 if(formId && formId.startsWith('gform_')) { 59 newSubmitButton = '<div class="cm-hipaa-forms-submit gravity cm-hipaa-forms-button active" role="button" tabindex="0" ><i class="material-icons">lock</i> SUBMIT</div>'; 60 } else { 61 newSubmitButton = '<div class="cm-hipaa-forms-submit caldera cm-hipaa-forms-button active" role="button" tabindex="0" ><i class="material-icons">lock</i> SUBMIT</div>'; 62 } 63 64 var showSig; 65 if(!enabledFormsSettings) { 66 // IF NEW ENABLED FORMS SETTINGS DOESN'T EXIST SET SIGNATURE TO YES 67 showSig = 'yes'; 68 } 69 70 // CHECK IF FORM OBJECT EXISTS IN ARRAY - NEW FORMS SETTINGS JSON OBJECT ARRAY METHOD 71 var formFound; 72 if(cmHipaaScript.enabledFormsSettings) { 73 enabledFormsSettings.some(function (el) { 74 if (el.id === formId && el.enabled === 'yes' || el.form_builder === 'gravity' && 'gform_' + el.id === formId && el.enabled === 'yes') { 75 formFound = true; 76 77 // IF SIGNATURE OPTION HAS VALUE SET IT 78 if(el.show_signature) { 79 showSig = el.show_signature; 80 } 81 // SET SUBMIT BUTTON 82 if(el.submit_btn_text){ 83 if(el.form_builder === 'gravity' && 'gform_' + el.id === formId){ 84 newSubmitButton = '<div class="cm-hipaa-forms-submit gravity cm-hipaa-forms-button active" role="button" tabindex="0" >' + el.submit_btn_text + '</div>'; 85 } else { 86 newSubmitButton = '<div class="cm-hipaa-forms-submit caldera cm-hipaa-forms-button active" role="button" tabindex="0" >' + el.submit_btn_text + '</div>'; 87 } 88 } 89 } 90 }); 91 } 92 // IF FORM ID IN DEPRECATED METHOD OR FORM FOUND IN NEW JSON OBJECT ARRAY METHOD 93 if(jQuery.inArray(formId, formIds) !== -1 || formFound) { 94 // CHECK IF SSL ENABLED 95 var protocol = document.location.protocol; 96 97 // ADD CM-HIPAA-FORM-ENABLED CLASS TO FORM 98 jQuery(this).addClass('cm-hipaa-form-enabled'); 99 100 // SET INITIAL VALUES 101 var submitButton = jQuery(this).find('input[type="submit"]'); 102 var gravityFileUploadEle = jQuery(this).find('.ginput_container_fileupload'); 103 var calderaFileUploadEle = jQuery(this).find('.file-prevent-overflow').parent(); 104 var calderaMultiFileUploadEle = jQuery(this).find('.cf-uploader-trigger').parent(); 105 var calderaAdvancedFileUploadEle = jQuery(this).find('.cf2-field-wrapper'); // EXPERIMENTAL - WILL OTHER NON-FILE UPLOAD FIELDS USE THIS CLASS IN THE FUTURE? 106 107 if(calderaAdvancedFileUploadEle.length > 0) { 108 jQuery.each(calderaAdvancedFileUploadEle,function (){ 109 calderaMultiFileUploadEle.push(this); 110 }) 111 //calderaMultiFileUploadEle.push(calderaAdvancedFileUploadEle); // EXPERIMENTAL 112 } 113 114 var gravitySflEle = jQuery(this).find('.gform_save_link'); 115 var calderaFormPages; 116 var gravityFormPages; 117 var appendEle; 118 119 calderaFormPages = jQuery(this).find('[data-formpage]'); 120 gravityFormPages = jQuery(this).find('.gform_page'); 121 122 // CHECK IF MULTI-PAGE FORM 123 if(calderaFormPages.length) {
124 appendEle = calderaFormPages.last(); 125 } else if(gravityFormPages.length) { 126 appendEle = gravityFormPages.last(); 127 128 // STRIP PREVIOUS & NEXT ONCLICK & ONKEYPRESS METHODS (IE FIX SETS ATTRIBUTE BLANK AS REMOVEATTR DOESN'T PLAY WELL WITH THAT ANTIQUE PIECE OF JUNK) 129 jQuery(this).find('.gform_next_button, .gform_previous_button').prop('onclick', '').prop('onkeypress', '').removeAttr('onclick').removeAttr('onkeypress'); 130 131 // LOOP PAGES AND ADD PREVIOUS/NEXT BUTTONS 132 gravityFormPages.each(function(index) { 133 index = +index+1; 134 var pageFooter = jQuery(this).find('.gform_page_footer'); 135 var inputIndex = jQuery(this).find('.gform_page_fields input[tabindex]').last().attr('tabindex'); 136 var previousButtonIndex; 137 138 // PREPEND PREVIOUS BUTTON TO LAST PAGE (NOT SURE WHY ONLY THAT PAGE DOESN'T GET IT) 139 if(index > 1 && index === gravityFormPages.length) { 140 previousButtonIndex = +inputIndex+1; 141 142 pageFooter.prepend('<input type="button" id="gform_previous_button_12" class="gform_previous_button button" value="Previous" tabindex="' + previousButtonIndex + '">'); 143 } 144 }); 145 } else { 146 appendEle = form; 147 } 148 // REMOVE FORM ACTION TO ONLY SUBMIT THROUGH AJAX 149 jQuery(this).attr('action',''); 150 151 // STOP FORMS FROM USING GENERIC SUBMIT BUTTON 152 jQuery(document).on('click', '#'+ formMainId +' input[type="submit"], #'+ formMainId +' button[type="submit"], #'+ formMainId +' [id^=gform_submit_button], #'+ formMainId +' input[type="submit"], #'+ formMainId +' button[type="submit"] ', function(e) { 153 e.preventDefault(); 154 alert('ERROR: This form submission is being overridden be the HIPAA Forms Plugin and was not submitted!'); 155 }); 156 157 // SET LOADING ICON 158 appendEle.append('<div class="cm-hipaa-forms-loading"><img src="' + cmHipaaScript.pluginUrl + '/images/loading/loading16.gif" alt="Securing Form" /><br /><br />SECURING FORM</div>'); 159 160 // ENSURE SSL ENABLED IF FORM SELECTED AS HIPAA COMPLIANT (checks both Wordpress is_ssl AND document protocol for good measure) 161 if(protocol === 'https:' && cmHipaaScript.ssl === '1') { 162 /*** VALIDATE ACCOUNT ***/ 163 jQuery.ajax({ 164 method: 'POST', 165 type: 'POST', 166 url: cmHipaaScript.ajax_url, 167 data: { 168 'action': 'cm_hipaa_validate_account', 169 'nonce': cmHipaaScript.nonce 170 }, 171 success: function (data) { 172 // REMOVE LOADING ICON 173 jQuery('.cm-hipaa-forms-loading').remove(); 174 175 //var resultData = JSON.parse(data); 176 var resultData; 177 try { 178 resultData = JSON.parse(data); 179 } catch (e) { 180 console.log(data); 181 appendEle.append('<div class="cm-hipaa-field-error">There was an Ajax Error!</div>'); 182 return false; 183 } 184 185 if(resultData.success === 'success') { 186 // CHECK IF STAGING 187 var stagingMessage = ''; 188 if(resultData.staging) { 189 stagingMessage = resultData.staging; 190 } 191 192 /*** CHECK IF FILE UPLOAD ENABLED ***/ 193 var validatedAddOns = resultData.add_ons; 194 var validatedAddOnsArray = ''; 195 if(validatedAddOns && validatedAddOns !== null && validatedAddOns !== 'null' && validatedAddOns !== ''){
196 if(Array.isArray(validatedAddOns)){ 197 validatedAddOnsArray = validatedAddOns.split(','); 198 }else{ 199 validatedAddOnsArray = validatedAddOns; 200 } 201 202 } 203 var fileUploadEnabled = 'no'; 204 if(Array.isArray(validatedAddOnsArray) && validatedAddOnsArray.indexOf('fileupload') !== -1) { 205 fileUploadEnabled = 'yes'; 206 } else if(validatedAddOns === 'fileupload') { 207 fileUploadEnabled = 'yes'; 208 } 209 210 // SET BASIC PRODUCT BADGE 211 var basicBadge = ''; 212 if(resultData.product === 'basic' || resultData.license_status === 'expired') { 213 basicBadge = '<div class="cm-hipaa-powered-by-badge">POWERED BY <a href="https://www.hipaaforms.online" target="_blank">HIPAA FORMS</a> <i>for Wordpress</i></div>'; 214 } 215 216 // IF BASIC PRODUCT CHECK IF MAX SUBMISSIONS REACHED 217 var maxSubmissionsMessage; 218 if(resultData.product === 'basic' && resultData.this_months_submissions >= 25) { 219 // CHANGING THIS WILL ENABLE YOUR FORM BUT THE SUBMISSIONS WILL STILL BE BLOCKED BY THE API. UPGRADING IS ONLY $50/MO, CODE MONKEYS HAVE BILLS TO PAY TOO ;). 220 maxSubmissionsMessage = '<div class="cm-hipaa-field-error">The maximum number of forms have been submitted for this month, please try again next month.</div>' + basicBadge; 221 } 222 223 if(submitButton.length > 0) { 224 // DISABLE & REMOVE ORIGINAL SUBMIT BUTTON TO PREVENT ACCIDENTAL GENERAL SUBMISSION 225 submitButton.attr('disabled', 'disabled').remove(); 226 } 227 228 // CHECK IF GRAVITY FILE UPLOAD FIELD & FILE UPLOAD URL EXISTS & REPLACE WITH MESSAGE IF NO UPLOAD URL 229 if(gravityFileUploadEle && fileUploadEnabled !== 'yes') { 230 gravityFileUploadEle.html('<div class="cm-hipaa-field-error">Default file upload functionality is not HIPAA compliant & has been disabled, please upgrade HIPAA Forms for file upload capability.</div>'); 231 } else if(gravityFileUploadEle && fileUploadEnabled === 'yes') { 232 // DISABLE GFORM THEME ON FILE UPLOAD ELEMENT (NEEDED SINCE ORBITAL THEME) 233 gravityFileUploadEle.addClass('gform-theme__disable'); 234 235 // LOOP FILE INPUT FIELDS & REPLACE MULTI-FILE UPLOAD IF EXISTS 236 jQuery.each(gravityFileUploadEle, function() { 237 var gfMultiFile = jQuery(this).find('.gform_fileupload_multifile'); 238 var fieldId = jQuery(this).parent().attr('id'); 239 var fileInputId = fieldId.replace('field', 'input'); 240 var fileInputEnd = fieldId.split('_').pop(); 241 var fileInputName = 'input_' + fileInputEnd; 242 var fileInputDescribed = fieldId.replace('field', 'extensions_message'); 243 var tabIndex = jQuery(this).find('.gform_button_select_files').attr('tabindex'); 244 245 var gfAcceptAttr = jQuery(this).find('.gform_fileupload_multifile input[type="file"]').attr('accept'); 246 var gfMaxFileSize = 0; 247 var gfDisallowedExtensions = "php,asp,aspx,cmd,csh,bat,html,htm,hta,jar,exe,com,js,lnk,htaccess,phtml,ps1,ps2,php3,php4,php5,php6,py,rb,tmp"; 248 var gfFileMimeTypesExtensions = "*"; 249 var gfMaxFiles = 0; 250 251 var gfFileInputSettings = ""; 252 if(gfMultiFile && gfMultiFile.data('settings')){ 253 var gfFileDataSettings = gfMultiFile.data('settings'); 254 if(gfFileDataSettings.filters.max_file_size){ 255 gfMaxFileSize = gfFileDataSettings.filters.max_file_size 256 } 257 var gfFileMimeTypesTitle = ""; 258 if(gfFileDataSettings.filters.mime_types[0]){ 259 var gfFileMimeTypes = gfFileDataSettings.filters.mime_types[0]; 260 if(gfFileMimeTypes.title){ 261 gfFileMimeTypesTitle = gfFileMimeTypes.title 262 } 263 if(gfFileMimeTypes.extensions){ 264 gfFileMimeTypesExtensions = gfFileMimeTypes.extensions 265 } 266 } 267 if(gfFileDataSettings.gf_vars.disallowed_extensions){ 268 gfDisallowedExtensions = gfFileDataSettings.gf_vars.disallowed_extensions 269 } 270 if(gfFileDataSettings.gf_vars.max_files){ 271 gfMaxFiles = gfFileDataSettings.gf_vars.max_files 272 } 273 gfFileInputSettings = '{"maxfilesize":"'+gfMaxFileSize+'","allowedextensions":"'+gfFileMimeTypesExtensions+'","disallowedextensions":"'+gfDisallowedExtensions+'","maxfiles":"'+gfMaxFiles+'"}'; 274 }else if (gfMultiFile.length === 0){ 275 gfMaxFileSize = jQuery(this).find("input[type='hidden'][name='MAX_FILE_SIZE']").first().val(); 276 var uploadRulesTxt = jQuery(this).find(".gform_fileupload_rules").first().text(); 277 var start = uploadRulesTxt.indexOf("Accepted file types: "); 278 var end = uploadRulesTxt.lastIndexOf(','); 279 if(start > -1 && end > -1){ 280 gfFileMimeTypesExtensions = uploadRulesTxt.substring(21, end).replaceAll(' ','').split(','); 281 } 282 283 284 gfFileInputSettings = '{"maxfilesize":"'+gfMaxFileSize+'","allowedextensions":"'+gfFileMimeTypesExtensions+'","disallowedextensions":"'+gfDisallowedExtensions+'","maxfiles":"'+gfMaxFiles+'"}'; 285 } 286 287 isRequired = jQuery(this).parent().hasClass('gfield_contains_required'); 288 289 if(gfMultiFile.length > 0 && gfMaxFiles === "1") { 290 //maxfiles set to allow only 1 file 291 gfMultiFile.replaceWith('<input name="' + fileInputName + '" id="' + fileInputId + '" type="file" class="medium cm-hipaa-multifile-upload-input" aria-describedby="' + fileInputDescribed + '" aria-required="' + isRequired + '" data-settings=' + gfFileInputSettings + ' accept="'+gfAcceptAttr+'" tabindex="' + tabIndex + '">'); 292 }else if(gfMultiFile.length > 0 ){ 293 gfMultiFile.replaceWith('<input name="' + fileInputName + '" id="' + fileInputId + '" type="file" class="medium cm-hipaa-multifile-upload-input" aria-describedby="' + fileInputDescribed + '" aria-required="' + isRequired + '" data-settings=' + gfFileInputSettings + ' accept="'+gfAcceptAttr+'" tabindex="' + tabIndex + '"><div id="assocd_id_'+ fileInputId +'" class="cm-hipaa-gf-multifile-upload-button">Add Another File</div>'); 294 }else if(gfMultiFile.length === 0 && gfMaxFiles === 0){ 295 jQuery('#'+fileInputId).replaceWith('<input name="' + fileInputName + '" id="' + fileInputId + '" type="file" class="medium cm-hipaa-multifile-upload-input" aria-describedby="' + fileInputDescribed + '" aria-required="' + isRequired + '" data-settings=' + gfFileInputSettings + ' tabindex="' + tabIndex + '">'); 296 } 297 }); 298 } 299 300 // CHECK IF CALDERA FILE UPLOAD FIELD & FILE UPLOAD URL EXISTS & REPLACE WITH MESSAGE IF NO UPLOAD URL 301 if((calderaFileUploadEle || calderaMultiFileUploadEle) && fileUploadEnabled !== 'yes') { 302 calderaFileUploadEle.html('<div class="cm-hipaa-field-error">Default file upload functionality is not HIPAA compliant & has been disabled, please upgrade HIPAA Forms for file upload capability.</div>'); 303 } else if(calderaMultiFileUploadEle && fileUploadEnabled === 'yes') { 304 // LOOP FILE INPUT FIELDS & REPLACE MULTI-FILE UPLOAD IF EXISTS 305 jQuery.each(calderaMultiFileUploadEle, function() { 306 var fieldId = jQuery(this).parent().attr('data-field-wrapper'); 307 if(!fieldId){ 308 fieldId = jQuery(this).attr('data-field-id'); 309 } 310 var cfInputField = jQuery("#"+fieldId); 311 var cfAcceptAttr = cfInputField.attr('accept'); 312 var cfMaxFileSize = 0; 313 var cfDisallowedExtensions = "php,asp,aspx,cmd,csh,bat,html,htm,hta,jar,exe,com,js,lnk,htaccess,phtml,ps1,ps2,php3,php4,php5,php6,py,rb,tmp"; 314 var cfFileMimeTypesExtensions = "*"; 315 var cfMaxFiles = cfInputField.attr('multiple'); 316 317 var cfFileInputSettings = '{"maxfilesize":"'+cfMaxFileSize+'","allowedextensions":"'+cfFileMimeTypesExtensions+'","disallowedextensions":"'+cfDisallowedExtensions+'","maxfiles":"'+cfMaxFiles+'"}'; 318 319 if(cfMaxFiles === 'multiple'){ 320 jQuery(this).replaceWith('<div class="file-prevent-overflow"><div id="' + fieldId + '_1_file_list" class="cf-multi-uploader-list"></div><input type="file" data-settings=' + cfFileInputSettings + ' accept="'+cfAcceptAttr+'" name="' + fieldId + '" value="" data-field="' + fieldId + '" class="" id="' + fieldId + '_1" aria-labelledby="' + fieldId + 'Label"><input type="hidden" name="' + fieldId + '"></div><div id="assocd_id_'+ fieldId +'" class="cm-hipaa-cf-multifile-upload-button">Add Another File</div>'); 321 }else { 322 jQuery(this).replaceWith('<div class="file-prevent-overflow"><div id="' + fieldId + '_1_file_list" class="cf-multi-uploader-list"></div><input type="file" data-settings=' + cfFileInputSettings + ' accept="' + cfAcceptAttr + '" name="' + fieldId + '" value="" data-field="' + fieldId + '" class="" id="' + fieldId + '_1" aria-labelledby="' + fieldId + 'Label"><input type="hidden" name="' + fieldId + '">'); 323 } 324 }); 325 } 326 327 // CHECK IF GRAVITY FORMS "SAVE FOR LATER" LINK EXISTS AND REPLACE WITH NON-COMPLIANT MESSAGE 328 if(gravitySflEle) { 329 gravitySflEle.replaceWith('<div class="cm-hipaa-field-error">"Save For Later" has been disabled due to HIPAA non-compliance</div>'); 330 } 331 332 var sigField = ''; 333 if(showSig === 'yes') { 334 sigField = '<div class="cm-hipaa-form-signature-wrapper"><div class="cm-hipaa-form-signature-inner"><div class="cm-hipaa-form-signature" style="min-height:150px;"></div><div class="cm-hipaa-form-signature-label"><span class="cm-hipaa-form-signature-label-text">To sign left click and drag mouse or use your finger or stylus if touch screen</span> <span class="cm-hipaa-form-signature-reset cm-ghost-button" class="cm-hipaa-forms-button">RESET</span><span style="clear:both;"></span></div></div></div>'; 335 } 336 337 // SET HIPAA PRIVACY NOTICE 338 var cmPrivacyNoticeMethod = cmHipaaScript.privacyNoticeMethod; 339 var cmPrivacyNoticeLabel = cmHipaaScript.privacyNoticeLabel; 340 var cmPrivacyNoticeCopy = cmHipaaScript.privacyNoticeCopy; 341 var cmPrivacyNoticeLink = cmHipaaScript.privacyNoticeLink; 342 var privacyStatement; 343 344 if(!cmPrivacyNoticeLabel) { 345 cmPrivacyNoticeLabel = 'I agree to the HIPAA Privacy Statement'; 346 } 347 348 if(!cmPrivacyNoticeCopy) { 349 cmPrivacyNoticeCopy = '<p>\n' + 350 'This "Notice of Information/Privacy Practices" is used to inform website visitors regarding our policies with the collection, use, and disclosure of Personal Information if anyone decided to use our Service.\n' + 351 '</p>\n' + 352 '<p>\n' + 353 'If you choose to use our Service, then you agree to the collection and use of information in relation with this policy. The Personal Information that we collect are used for providing and improving the Service. We will not use or share your information with anyone except as de
353scribed in this Privacy Policy.\n' + 354 '</p>\n' + 355 '<p>\n' + 356 '<h3>Information Collection and Use</h3>\n' + 357 'For a better experience while using our Service, we may require you to provide us with certain personally identifiable information, including but not limited to your name, phone number, and postal address. The information that we collect will be used to contact or identify you.\n' + 358 '</p>\n' + 359 '<p>\n' + 360 '<h3>Log Data</h3>\n' + 361 'We want to inform you that whenever you visit our Service, we collect information that your browser sends to us that is called Log Data. This Log Data may include information such as your computerâs Internet Protocol ("IP") address, browser version, pages of our Service that you visit, the time and date of your visit, the time spent on those pages, and other statistics.\n' + 362 '</p>\n' + 363 '<p>\n' + 364 '<h3>Cookies</h3>\n' + 365 'Cookies are files with small amount of data that is commonly used an anonymous unique identifier. These are sent to your browser from the website that you visit and are stored on your computerâs hard drive.\n' + 366 '</p>\n' + 367 '<p>\n' + 368 'Our website uses these "cookies" to collection information and to improve our Service. You have the option to either accept or refuse these cookies, and know when a cookie is being sent to your computer. If you choose to refuse our cookies, you may not be able to use some portions of our Service.\n' + 369 '</p>\n' + 370 '<p>\n' + 371 '<h3>Service Providers</h3>\n' + 372 'We may employ third-party companies and individuals due to the following reasons:\n' + 373 '<ul>\n' + 374 '<li>To facilitate our Service;</li>\n' + 375 '<li>To provide the Service on our behalf;</li>\n' + 376 '<li>To perform Service-related services; or</li>\n' + 377 '<li>To assist us in analyzing how our Service is used.</li>\n' + 378 '<p>\n' + 379 'We want to inform our Service users that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.\n' + 380 '</p>\n' + 381 '</p>\n' + 382 '<p>\n' + 383 '<h3>Security</h3>\n' + 384 'We value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and we cannot guarantee its absolute security.\n' + 385 '</p>\n' + 386 '<p>\n' + 387 '<h3>Links to Other Sites</h3>\n' + 388 'Our Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by us. Therefore, we strongly advise you to review the Privacy Policy of these websites. We have no control over, and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.\n' + 389 '</p>\n' + 390 '<p>\n' + 391 '<h3>Changes to This Privacy Policy</h3>\n' + 392 'We may update our Privacy Policy from time to time. Thus, we advise you to review this page periodically for any changes. We will notify you of any changes by posting the new Privacy Policy on this page. These
392changes are effective immediately, after they are posted on this page.\n' + 393 '</p>'; 394 } 395 396 var modalHTML; 397 if(cmPrivacyNoticeLink && cmPrivacyNoticeMethod === 'link') { 398 privacyStatement = '<span class="cm-hipaa-privacy-statement-link"><a href="' + cmPrivacyNoticeLink + '" target="_blank" >' + cmPrivacyNoticeLabel + '</a></span>'; 399 modalHTML = ''; 400 } else { 401 modalHTML = '<div class="cmprivacy-modal closed"><div class="cmprivacy-modal-inner"><div class="cmprivacy-modal-inner-top"><h2 class="cmprivacy-title">Notice of Information/Privacy Practices</h2><i class="cmprivacy-close-btn material-icons">cancel</i></div><div class="cmprivacy-content">'+ cmPrivacyNoticeCopy + '</div></div></div>'; 402 403 privacyStatement = '<span class="cm-hipaa-privacy-statement"><a href="#" >' + cmPrivacyNoticeLabel + '</a></span>'; 404 } 405 406 // CREATE HONEYPOT INPUT 407 var honeyPot = '<input type="hidden" class="cm-hipaa-required-extra" value="" />'; 408 409 if(maxSubmissionsMessage) { 410 // PREPEND MAX FORM SUBMISSIONS MESSAGE 411 form.prepend('<div class="cm-hipaa-forms-prepend">'+ maxSubmissionsMessage +'</div>'); 412 413 // APPEND MAX FORM SUBMISSIONS MESSAGE 414 appendEle.append('<div class="cm-hipaa-forms-prepend">'+ maxSubmissionsMessage +'</div>'); 415 416 // DISABLE FORM INPUTS 417 form.find('input, textarea').attr('readonly', 'readonly'); 418 form.find('select').attr('disabled', 'disabled'); 419 form.find('input[type="checkbox"], input[type="radio"]').prop('disabled', true); 420 } else { 421 // APPEND ADDITIONAL FIELDS, SUBMIT BUTTON AND BADGE TO THE FORM 422 appendEle.append('<div class="cm-hipaa-forms-prepend gform-theme__disable">' + modalHTML + '<div class="cm-hipaa-forms-privacy-statement"><label for="cm-hipaa-forms-privacy-agree" class="sr-only"> ' + cmPrivacyNoticeLabel + '</label><input type="checkbox" id="cm-hipaa-forms-privacy-agree" class="cm-hipaa-forms-privacy-agree" name="cm-hipaa-forms-privacy-agree" aria-label="HIPAA Forms Privacy Statment" value="Yes" /> ' + privacyStatement + '</div><div class="cm-hipaa-forms-prepend-bottom gform-theme__disable"><div class="cm-hipaa-forms-ssl-notice"></div>' + sigField + '<div class="cm-hipaa-forms-submit-wrapper">' + honeyPot + newSubmitButton + '</div><div class="cm-hipaa-notice"></div>' + stagingMessage + '<div class="cm-hipaa-form-badge-wrapper"><img src="' + cmHipaaScript.pluginUrl + '/images/hipaa-compliant-badge.png" alt="HIPAA COMPLIANT FORM" /></div>' + basicBadge + '</div></div>').promise().done(function () { 423 if (showSig === 'yes') { 424 // INITIALIZE THE FORM SIGNATURE CANVAS FIELD IF VISIBLE 425 var signature = appendEle.find(".cm-hipaa-form-signature"); 426 if (signature.is(':visible')) { 427 signature.jSignature({'background-color':'transparent'}); 428 } 429 } 430 }); 431 } 432 } else { 433 // DISABLE & REMOVE ORIGINAL SUBMIT BUTTON TO PREVENT ACCIDENTAL GENERAL SUBMISSION 434 submitButton.attr('disabled', 'disabled').remove(); 435 436 appendEle.append(resultData.error); 437 } 438 }, 439 error: function (errorThrown) { 440 // REMOVE LOADING ICON
441 jQuery('.cm-hipaa-forms-loading').remove(); 442 443 console.log(errorThrown); 444 } 445 }); 446 } else { 447 // APPEND NOTICE THAT SSL IS NOT ENABLED 448 form.append('<div class="cm-hipaa-forms-ssl-notice">This form is designated as a HIPAA compliant form however SSL (https) is not enabled so the form has been disabled.<br />Please ask the website administrators to fix this issue.</div>'); 449 450 // DISABLE AND REMOVE SUBMIT BUTTON TO ENSURE FORM CAN'T BE SUBMITTED 451 submitButton.attr('disabled', 'disabled').remove(); 452 } 453 } 454 }); 455 456 /*** REINITIALIZE JSIGNATURE IF MULTI-PAGE FORM - JSIGNATURE DOESN'T INIT PROPERLY WHEN IN A HIDDEN ELEMENT ***/ 457 jQuery(document).on('click', '.cm-hipaa-form-enabled .cf-page-btn-next, .cm-hipaa-form-enabled .gform_next_button, .cm-hipaa-form-enabled .gf_step, .caldera_forms_form .breadcrumb a', function() { 458 var signature = jQuery(this).closest('form').find('.cm-hipaa-form-signature'); 459 460 // SET TIMEOUT TO WAIT FOR FADEIN 461 setTimeout(function() { 462 if(signature.is(':visible') && signature.find('canvas').length === 0) { 463 signature.jSignature({'background-color':'transparent'}); 464 } 465 },500); 466 }); 467 468 /*** ADD VALID CLASS TO SIGNATURE FIELD ON CLICK ***/ 469 jQuery(document).on('click', '.jSignature', function() { 470 if(!jQuery(this).hasClass('cm-valid-sig')) { 471 jQuery(this).addClass('cm-valid-sig'); 472 } 473 }); 474 475 /*** TOUCH EVENT VERSION ***/ 476 jQuery(document).on('touchstart', '.jSignature', function() { 477 if(!jQuery(this).hasClass('cm-valid-sig')) { 478 jQuery(this).addClass('cm-valid-sig'); 479 } 480 }); 481 482 /*** REMOVE VALID CLASS FROM SIGNATURE FIELD ON RESET ***/ 483 jQuery(document).on('click', '.cm-hipaa-form-signature-reset', function() { 484 jQuery(this).parent().parent().find('.jSignature').removeClass('cm-valid-sig'); 485 }); 486 487 /*** OVER-RIDE GRAVITY PREVIOUS/NEXT BUTTONS TO SHOW/HIDE INSTEAD OF RELOAD PAGE, DEFAULT FORM SUBMIT TO SELF ISN'T PROTECTED & NOT COMPLIANT! ***/ 488 jQuery(document).on('click', '.cm-hipaa-form-enabled .gform_previous_button, .cm-hipaa-form-enabled .gform_next_button', function(e) { 489 var form = jQuery(this).closest('form'); 490 var formId = form.attr('id'); 491 var thisPage = jQuery(this).parent().parent(); 492 var pages = form.find('.gform_page'); 493 var pbPercent = Math.floor(100/pages.length); 494 var progressBarTitle = form.find('.gf_progressbar_title'); 495 var progressBar = form.find('.gf_progressbar_percentage'); 496 var stepsWrapper = form.find('.gf_page_steps'); 497 var direction; 498 499 // CLEAR ERRORS 500 form.find('.gfield_error').removeClass('gfield_error'); 501 form.find('.validation_error, .validation_message').remove(); 502 503 if(jQuery(this).hasClass('gform_previous_button')) { 504 direction = 'previous'; 505 } else if(jQuery(this).hasClass('gform_next_button')) { 506 direction = 'next'; 507 } 508 509 // LOOP PAGES 510 pages.each(function(index) { 511 index = index+1; 512 513 if(jQuery(this).attr('id') === thisPage.attr('id') && direction === 'next') { 514 // VALIDATE REQUIRED FIELDS ON PAGE 515 var inputs = thisPage.find('input, select, textarea'); 516 var errors = []; 517 518 // LOOP INPUTS 519 inputs.each(function() { 520 var fieldWrapper = jQuery(this).closest('.gfield'); 521 var fieldType = jQuery(this).attr('type'); 522 var value = jQuery(this).val(); 523 var visibleSelect; 524 var optionText; 525 var fieldId = jQuery(this).attr('id'); 526 527 if (!fieldType) { 528 if (jQuery(this).is('select')) { 529 fieldType = 'select'; 530 visibleSelect = form.find('#' + fieldId); 531 optionText = visibleSelect.find('option:selected').text(); 532 value = visibleSelect.val(); 533 } else if (jQuery(this).is('textarea')) { 534 fieldType = 'textarea'; 535 var visibleTextArea = form.find('#' + fieldId); 536 value = visibleTextArea.attr('value'); 537 // TRY THE VALUE ATTR FIRST AND IF NO VALUE TRY NORMAL JQUERY VAL(), NOT SURE WHY ONE WORKS OVER THE OTHER
537SOMETIMES 538 if (!value || value === 'undefined') { 539 value = visibleTextArea.val(); 540 } 541 } 542 } 543 // IF CHECKBOX OR RADIO SET OPTIONS 544 var checkOrRadio = false; 545 var cbOptionChecked; 546 if(fieldType === 'checkbox' || fieldType === 'radio') { 547 checkOrRadio = true; 548 cbOptionChecked = jQuery(this).prop('checked'); 549 } 550 551 // SET IF FIELD IS HIDDEN OR DISABLED 552 var isVisible = jQuery(this).is(':visible'); 553 var isDisabled = jQuery(this).prop('disabled'); 554 555 // CHECK IF FIELD IS A NUMBER FIELD WITH MIN AND/OR MAX 556 if (fieldType === 'number') { 557 var val = jQuery(this).val(); 558 var num = parseFloat(val); 559 if (val !== '') { 560 if (jQuery.isNumeric(num)) { 561 var min = parseFloat(jQuery(this).attr('min')); 562 var max = parseFloat(jQuery(this).attr('max')); 563 if (jQuery.isNumeric(min) && jQuery.isNumeric(max)) { 564 if ((Math.round(num * 100000) < Math.round(min * 100000)) || (Math.round(max * 100000) < Math.round(num * 100000))) { 565 errors.push(jQuery(this).attr('id')); 566 } 567 } else if (jQuery.isNumeric(max)) { 568 if (Math.round(max * 100000) < Math.round(num * 100000)) { 569 errors.push(jQuery(this).attr('id')); 570 } 571 } else if (jQuery.isNumeric(min)) { 572 if (Math.round(num * 100000) < Math.round(min * 100000)) { 573 errors.push(jQuery(this).attr('id')); 574 } 575 } 576 } else { 577 errors.push(jQuery(this).attr('id')); 578 } 579 } 580 581 } 582 583 // CHECK IF FIELD IS AN EMAIL AND FORMATTED CORRECTLY 584 if (fieldType === 'email'){ 585 var emailVal = jQuery(this).val(); 586 // pattern taken form https://emailregex.com/ 587 var emailReg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 588 if ( emailVal !== '' ) { 589 if(!emailReg.test( emailVal ) ){ 590 errors.push(jQuery(this).attr('id')); 591 } 592 } 593 } 594 595 // SET IF FIELD IS REQUIRED 596 var required = false; 597 if(isDisabled !== true && isVisible === true && !jQuery(this).parent().hasClass('name_prefix_select') && !jQuery(this).parent().hasClass('name_suffix') && !jQuery(this).parent().hasClass('ginput_address_line_2') && (jQuery(this).attr('required') === 'true' || jQuery(this).attr('aria-required') === 'true' || fieldWrapper.hasClass('gfield_contains_required') && checkOrRadio !== true && !jQuery(this).parent().hasClass('address_line_2'))) { 598 required = true; 599 } 600 601 // IF REQUIRED FIELD WITH NO VALUE PUSH FIELD TO ERRORS ARRAY 602 if (required && (!value || value == "") || isDisabled !== true && isVisible === true && checkOrRadio === true && fieldWrapper.hasClass('gfield_contains_required') && cbOptionChecked === false) { 603 var invalidInputId; 604 605 // IF CHECKBOX OR RADIO INPUT 606 if(checkOrRadio === true) { 607 var cbIsValid = false; 608 609 // GROUP OPTION INPUTS 610 var cbInputs = fieldWrapper.find('input'); 611 612 // LOOP OPTIONS 613 cbInputs.each(function() { 614 if(jQuery(this).prop('checked') === true) { 615 cbIsValid = true; 616 } 617 }); 618 619 // PUSH ID TO ERROR ARRAY IF INVALID 620 if(cbIsValid !== true) { 621 invalidInputId = fieldWrapper.attr('id'); 622 } 623 } else if (jQuery(this).attr('id') === undefined){ 624 invalidInputId = fieldWrapper.attr('id'); 625 } else if (fieldType === 'select'){ 626 invalidInputId = fieldWrapper.attr('id'); 627 }else { 628 invalidInputId = jQuery(this).attr('id'); 629 } 630 631 if(invalidInputId && errors.indexOf(invalidInputId) === -1) { 632 errors.push(invalidInputId); 633 } 634 } 635 }); 636 637 if(errors.length > 0) { 638 // SET FIRST INVALID FIELD 639 var firstErrorId = errors[0]; 640 var firstInvalidInput = jQuery('#' + firstErrorId); 641 var firstInvalidInputWrapper = firstInvalidInput.closest('.gfield'); 642 643 // ADD ERROR MESSAGE TO TOP OF FORM 644 form.find('.gform_body').before('<div class="validation_error">There was a problem with your submission. Errors have been highlighted below.</div>'); 645 646 // LOOP INVALID INPUT ID'S 647 for(i=0; i<errors.length; i++) { 648 var invalidInput = jQuery('#' + errors[i]); 649 var invalidFieldType = invalidInput.attr('type'); 650 651 // ADD ERROR CLASS & NOTICE MESSAGE 652 var invalidInputWrapper; 653 if(invalidFieldType === 'checkbox' || invalidFieldType === 'radio') { 654 invalidInputWrapper = invalidInput.parent().parent().parent().parent(); 655 invalidInputWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">This field is required.</div>'); 656 } else { 657 invalidInputWrapper = invalidInput.closest('.gfield'); 658 invalidInputWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">This field is required.</div>'); 659 } 660 } 661 662 // SCROLL TO FIRST INVALID FIELD 663 jQuery('html, body').animate({ 664 scrollTop: firstInvalidInputWrapper.offset().top 665 }, 500, 'linear'); 666 } else { 667 // FADE OUT THIS PAGE 668 jQuery(this).fadeOut().promise().done(function () { 669 // FADE IN NEXT PAGE 670 var nextPageEle = jQuery(this).next('.gform_page'); 671 nextPageEle.fadeIn(); 672 673 var nextIndex = index + 1; 674 675 // UPDATE PROGRESS BAR IF SET 676 if(progressBar) { 677 var nextPercent; 678 if (index + 1 === pages.length) { 679 nextPercent = 100; 680 } else { 681 nextPercent = (pbPercent * index) + pbPercent; 682 } 683 progressBar.css('width', nextPercent + '%').find('span').html(nextPercent + '%'); 684 progressBarTitle.html('Step ' + nextIndex + ' of ' + pages.length); 685 } 686 687 // UPDATE STEPS IF SET 688 if(stepsWrapper) { 689 var stepLinks = stepsWrapper.find('.gf_step'); 690 var pageId = nextPageEle.attr('id'); 691 var pageIdArr = pageId.split('_'); 692 693 var stepLinkId = 'gf_step_' + pageIdArr[2] + '_' + pageIdArr[3]; 694 695 // LOOP STEP LINK AND SET NEXT STEP ACTIVE 696 jQuery.each(stepLinks, function() { 697 if(jQuery(this).attr('id') === stepLinkId) { 698 jQuery(this).addClass('gf_step_active gpmpn-step-current'); 699 } else { 700 jQuery(this).removeClass('gf_step_active gpmpn-step-current'); 701 } 702 }); 703 } 704 705 // SCROLL TO FIRST INVALID FIELD 706 jQuery('html, body').animate({ 707 scrollTop: form.offset().top 708 }, 300, 'linear'); 709 }); 710 } 711 } else if(jQuery(this).attr('id') === thisPage.attr('id') && direction === 'previous') { 712 // FADE OUT THIS PAGE 713 jQuery(this).fadeOut().promise().done(function() { 714 // FADE IN PREVIOUS PAGE 715 var prevPageEle = jQuery(this).prev('.gform_page'); 716 prevPageEle.fadeIn(); 717 718 var previousIndex = index - 1; 719 720 // UPDATE PROGRESS BAR 721 if(progressBar) { 722 prevPercent = (pbPercent * index) - pbPercent; 723 progressBar.css('width', prevPercent + '%').find('span').html(prevPercent + '%'); 724 progressBarTitle.html('Step ' + previousIndex + ' of ' + pages.length); 725 } 726 727 // UPDATE STEPS IF SET 728 if(stepsWrapper) { 729 var stepLinks = stepsWrapper.find('.gf_step'); 730 var pageId = prevPageEle.attr('id'); 731 var pageIdArr = pageId.split('_'); 732 733 var stepLinkId = 'gf_step_' + pageIdArr[2] + '_' + pageIdArr[3]; 734 735 // LOOP STEP LINK AND SET NEXT STEP ACTIVE 736 jQuery.each(stepLinks, function() { 737 if(jQuery(this).attr('id') === stepLinkId) { 738 jQuery(this).addClass('gf_step_active gpmpn-step-current'); 739 } else { 740 jQuery(this).removeClass('gf_step_active gpmpn-step-current'); 741 } 742 }); 743 } 744 745 // SCROLL TO FIRST INVALID FIELD 746 jQuery('html, body').animate({ 747 scrollTop: form.offset().top 748 }, 300, 'linear'); 749 }); 750 } 751 }); 752 });
753 754 /*** ADD GRAVITY STEP LINK ACTION ***/ 755 jQuery(document).on('click', '.cm-hipaa-form-enabled .gf_step', function() { 756 var form = jQuery(this).closest('form'); 757 var stepsWrapper = form.find('.gf_page_steps'); 758 var stepLinks = stepsWrapper.find('.gf_step'); 759 var stepId = jQuery(this).attr('id'); 760 var stepIdArr = stepId.split('_'); 761 var pageId = 'gform_page_' + stepIdArr[2] + '_' + stepIdArr[3]; 762 var curPage = form.find('.gform_page:visible'); 763 var curPageIdArr = curPage.attr('id').split('_'); 764 765 if(curPage.attr('id') !== pageId) { 766 if(stepIdArr[3] > curPageIdArr[3]) { 767 // CLEAR ERRORS 768 form.find('.gfield_error').removeClass('gfield_error'); 769 form.find('.validation_error, .validation_message').remove(); 770 771 // VALIDATE REQUIRED FIELDS ON PREVIOUS PAGES 772 var inputs = []; 773 jQuery.each(form.find('.gform_page'), function() { 774 if(jQuery(this).attr('id').split('_')[3] < stepIdArr[3]) { 775 var pageInputs = jQuery(this).find('input'); 776 777 pageInputs.each(function() { 778 inputs.push(jQuery(this).attr('id')); 779 }); 780 } else { 781 return false; 782 } 783 }); 784 785 var errors = []; 786 // LOOP INPUTS 787 for(i=0; i<inputs.length; i++) { 788 var curInput = jQuery('#' + inputs[i]); 789 var fieldWrapper = curInput.closest('.gfield'); 790 var fieldType = curInput.attr('type'); 791 var value = curInput.val(); 792 793 // IF CHECKBOX OR RADIO SET OPTIONS 794 var checkOrRadio = false; 795 var cbOptionChecked; 796 if(fieldType === 'checkbox' || fieldType === 'radio') { 797 checkOrRadio = true; 798 cbOptionChecked = curInput.prop('checked'); 799 } 800 801 // SET IF FIELD IS HIDDEN OR DISABLED 802 var isVisible = curInput.is(':visible'); 803 var isDisabled = curInput.prop('disabled'); 804 805 // CHECK IF FIELD IS A NUMBER FIELD WITH MIN AND/OR MAX 806 if (fieldType === 'number') { 807 var val = jQuery(this).val(); 808 var num = parseFloat(val); 809 if (val !== '') { 810 if (jQuery.isNumeric(num)) { 811 var min = parseFloat(jQuery(this).attr('min')); 812 var max = parseFloat(jQuery(this).attr('max')); 813 if (jQuery.isNumeric(min) && jQuery.isNumeric(max)) { 814 if ((Math.round(num * 100000) < Math.round(min * 100000)) || (Math.round(max * 100000) < Math.round(num * 100000))) { 815 errors.push(jQuery(this).attr('id')); 816 } 817 } else if (jQuery.isNumeric(max)) { 818 if (Math.round(max * 100000) < Math.round(num * 100000)) { 819 errors.push(jQuery(this).attr('id')); 820 } 821 } else if (jQuery.isNumeric(min)) { 822 if (Math.round(num * 100000) < Math.round(min * 100000)) { 823 errors.push(jQuery(this).attr('id')); 824 } 825 } 826 } else { 827 errors.push(jQuery(this).attr('id')); 828 } 829 } 830 } 831 832 // CHECK IF FIELD IS AN EMAIL AND FORMATTED CORRECTLY 833 if (fieldType === 'email'){ 834 var emailVal = jQuery(this).val(); 835 // pattern taken form https://emailregex.com/ 836 var emailReg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 837 if ( emailVal !== '' ) { 838 if(!emailReg.test( emailVal ) ){ 839 errors.push(jQuery(this).attr('id')); 840 } 841 } 842 } 843 844 // SET IF FIELD IS REQUIRED 845 var required = false; 846 if(isDisabled !== true && isVisible === true && (curInput.attr('required') || curInput.attr('aria-required') || fieldWrapper.hasClass('gfield_contains_required') && checkOrRadio !== true && !curInput.parent().hasClass('address_line_2'))) { 847 required = true; 848 } 849 850 if (required === true && !value || isDisabled !== true && isVisible === true && checkOrRadio === true && fieldWrapper.hasClass('gfield_contains_required') && cbOptionChecked === false) { 851 var invalidInputId; 852 853 // IF CHECKBOX OR RADIO INPUT 854 if (fieldType === 'checkbox' || fieldType === 'radio') { 855 var cbIsValid; 856 857 // SET INPUT GROUP WRAPPER 858 var cbInputWrapper = curInput.parent().parent().parent().parent(); 859 860 // GROUP OPTION INPUTS 861 var cbInputs = cbInputWrapper.find('input'); 862 863 // LOOP OPTIONS 864 cbInputs.each(function () { 865 cbIsValid = false; 866 867 if (jQuery(this).prop('checked') === true) { 868 cbIsValid = true; 869 870 return false; 871 } 872 }); 873 874 // PUSH ID TO ERROR ARRAY IF INVALID 875 if (cbIsValid !== true) { 876 invalidInputId = cbInputWrapper.attr('id'); 877 } 878 } else { 879 invalidInputId = curInput.attr('id'); 880 } 881 if (invalidInputId && errors.indexOf(invalidInputId) === -1) { 882 errors.push(invalidInputId); 883 } 884 } 885 } 886 887 if (errors.length > 0) { 888 // SET FIRST INVALID FIELD 889 var firstErrorId = errors[0]; 890 var firstInvalidInput = jQuery('#' + firstErrorId); 891 var errorPage = firstInvalidInput.closest('.gform_page'); 892 var errorPageIdArr = errorPage.attr('id').split('_'); 893 var firstInvalidInputWrapper = firstInvalidInput.closest('.gfield'); 894 895 // ADD ERROR MESSAGE TO TOP OF FORM 896 form.find('.gform_body').before('<div class="validation_error">There was a problem with your submission. Errors have been highlighted below.</div>'); 897 898 // LOOP INVALID INPUT ID'S 899 for (i = 0; i < errors.length; i++) { 900 var invalidInput = jQuery('#' + errors[i]); 901 var invalidFieldType = invalidInput.attr('type'); 902 903 // ADD ERROR CLASS & NOTICE MESSAGE 904 var invalidInputWrapper; 905 if (invalidFieldType === 'checkbox' || invalidFieldType === 'radio') { 906 invalidInputWrapper = invalidInput.parent().parent().parent().parent(); 907 invalidInputWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">This field is required.</div>'); 908 } else { 909 invalidInputWrapper = invalidInput.closest('li'); 910 invalidInputWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">This field is required.</div>'); 911 } 912 } 913 914 if(errorPage.attr('id') !== curPage.attr('id')) { 915 curPage.fadeOut().promise().done(function() { 916 errorPage.fadeIn(); 917 918 // UPDATE LINKS 919 jQuery.each(stepLinks, function () { 920 if (jQuery(this).attr('id') === 'gf_step_' + errorPageIdArr[2] + '_' + errorPageIdArr[3]) { 921 jQuery(this).addClass('gf_step_active gpmpn-step-current'); 922 } else { 923 jQuery(this).removeClass('gf_step_active gpmpn-step-current'); 924 } 925 }); 926 }); 927 } 928 929 // SCROLL TO FIRST INVALID FIELD 930 jQuery('html, body').animate({ 931 scrollTop: firstInvalidInputWrapper.offset().top 932 }, 500, 'linear'); 933 } else { 934 // FADE OUT CURRENT PAGE 935 curPage.fadeOut().promise().done(function () { 936 // FADE IN SELECTED PAGE 937 jQuery('#' + pageId).fadeIn(); 938 939 // UPDATE LINKS 940 jQuery.each(stepLinks, function () { 941 if (jQuery(this).attr('id') === stepId) { 942 jQuery(this).addClass('gf_step_active gpmpn-step-current'); 943 } else { 944 jQuery(this).removeClass('gf_step_active gpmpn-step-current'); 945 } 946 }); 947 }); 948 } 949 } else { 950 // FADE OUT CURRENT PAGE 951 curPage.fadeOut().promise().done(function () { 952 // FADE IN SELECTED PAGE 953 jQuery('#' + pageId).fadeIn(); 954 // UPDATE LINKS 955 jQuery.each(stepLinks, function () { 956 if (jQuery(this).attr('id') === stepId) { 957 jQuery(this).addClass('gf_step_active gpmpn-step-current'); 958 } else { 959 jQuery(this).removeClass('gf_step_active gpmpn-step-current'); 960 } 961 }); 962 }); 963 } 964 } 965 });
966 967 /*** MULTI-FILE UPLOAD ***/ 968 jQuery(document).on('change', '.cm-hipaa-multifile-upload-input',function (){ 969 jQuery('body .cm-hipaa-multifile-errors').remove(); 970 var settings = jQuery(this).data('settings'); 971 var uploadPath = jQuery(this).val(); 972 var uploadExtension = uploadPath.substring(uploadPath.lastIndexOf(".")+1, uploadPath.length).toLowerCase(); // ADDED TOLOWERCASE 973 //Default values 974 var uploadValidationErrors = []; 975 var maxFileSize = ""; 976 var isMaxFileSize = true; 977 var isAllowedExtention = null; 978 var isDisallowedExtention = null; 979 980 if(settings.maxfilesize){ 981 maxFileSize = settings.maxfilesize; 982 var fileSize = jQuery(this).prop('files')[0].size; 983 //maxFileSize = maxFileSize.substring(0,maxFileSize.length - 1); //No Longer needed 984 if(fileSize > parseInt(maxFileSize)){ 985 uploadValidationErrors.push("<div class='cm-hipaa-field-error cm-hipaa-multifile-errors'>This file is too large.</div>"); 986 } 987 } 988 989 var allowedExtentions = ""; 990 if(settings.allowedextensions){ 991 allowedExtentions = settings.allowedextensions; 992 } 993 994 var disallowedExtentions = ""; 995 if(settings.disallowedextentions){ 996 disallowedExtentions = settings.disallowedextentions; 997 } 998 999 if(allowedExtentions !== "*"){ 1000 var allowedExtentionsArray = allowedExtentions.split(','); 1001 //if extention not found in array then error is given 1002 if(!allowedExtentionsArray.includes(uploadExtension)){ 1003 uploadValidationErrors.push("<div class='cm-hipaa-field-error cm-hipaa-multifile-errors'>This file type is not allowed.</div>") 1004 } 1005 }else{ 1006 var disallowedExtentionsArray = disallowedExtentions.split(','); 1007 //if extention is found in array then error is given 1008 if(disallowedExtentionsArray.includes(uploadExtension)){ 1009 uploadValidationErrors.push("<div class='cm-hipaa-field-error cm-hipaa-multifile-errors'>This file type is not allowed.</div>") 1010 } 1011 } 1012 1013 var maxFiles = 0; 1014 if(settings.maxfiles){ 1015 maxFiles = settings.maxfiles; 1016 } 1017 1018 if(uploadValidationErrors.length){ 1019 jQuery(this).val(""); 1020 for (i = 0; i < uploadValidationErrors.length; i++) { 1021 jQuery(this).before(uploadValidationErrors[i]); 1022 } 1023 } 1024 }) 1025 1026 /*** GRAVITY MULTI-FILE UPLOAD ADD NEW FIELD ***/ 1027 jQuery(document).on('click', '.cm-hipaa-gf-multifile-upload-button', function() { 1028 var fileUploadInputCount = jQuery(this).parent().find('input[type="file"]').length+1; 1029 var fieldId = jQuery(this).parent().parent().attr('id'); 1030 var fileInputId = fieldId.replace('field', 'input'); 1031 var fileInputEnd = fieldId.split('_').pop(); 1032 var fileInputName = 'input_' + fileInputEnd; 1033 var fileInputDescribed = fieldId.replace('field', 'extensions_message'); 1034 var gfFileInputSettings = JSON.stringify(jQuery('#'+fileInputId).data('settings')); 1035 var gfAcceptAttr = jQuery('#'+fileInputId).attr('accept'); 1036 jQuery(this).before('<div class="multi-file-input-spacer"></div><input name="' + fileInputName + '_' + fileUploadInputCount + '" id="' + fileInputId + '_' + fileUploadInputCount + '" type="file" class="medium cm-hipaa-multifile-upload-input" data-settings=' + gfFileInputSettings + ' accept="'+gfAcceptAttr+'" aria-describedby="' + fileInputDescribed + '"><div class="cm-hipaa-gf-delete-file"><i class="material-icons">delete_forever</i></div>'); 1037 gfAddAnotherFileBtn(fileInputId); 1038 }); 1039 1040 /*** GRAVITY HANDLE MULTI-FILE ADD ANOTHER FILE BUTTON ***/ 1041 function gfAddAnotherFileBtn(assocdInputId){ 1042 var fileInputId = jQuery('#'+assocdInputId); 1043 var count = 0; 1044 count = fileInputId.parent().find('input[type="file"]').length; 1045 var fileInputSetting = fileInputId.data('settings'); 1046 var max = parseInt(fileInputSetting.maxfiles); 1047 var addAnotherBtn = jQuery('#assocd_id_'+assocdInputId); 1048 var btnFound = false; 1049 if(addAnotherBtn.length > 0){ 1050 btnFound = true; 1051 } 1052 if((!btnFound && max === 0) || (!btnFound && max > count)){ 1053 fileInputId.parent().find('span.gform_fileupload_rules').before('<div id="assocd_id_'+ assocd
1053InputId +'" class="cm-hipaa-gf-multifile-upload-button">Add Another File</div>') 1054 }else if(btnFound && max <= count && max !== 0){ 1055 addAnotherBtn.remove(); 1056 } 1057 } 1058 1059 /*** CALDERA MULTI-FILE UPLOAD ADD NEW FIELD ***/ 1060 jQuery(document).on('click', '.cm-hipaa-cf-multifile-upload-button', function() { 1061 var fileUploadInputCount = 0; 1062 fileUploadInputCount = jQuery(this).parent().find('input[type="file"]').length+1; 1063 1064 //var fieldId = jQuery(this).parent().attr('data-field-wrapper'); 1065 var fieldId = jQuery(this).attr('id').replace('assocd_id_',''); 1066 var firstFileUploadInput = jQuery('#'+fieldId+'_1'); 1067 var cfFileInputSettings = firstFileUploadInput.data('settings'); 1068 var cfAcceptAttr = firstFileUploadInput.attr('accept'); 1069 1070 jQuery(this).before('<div class="multi-file-input-spacer"></div><div class="file-prevent-overflow"><div id="' + fieldId + '_' + fileUploadInputCount + '_file_list" class="cf-multi-uploader-list"></div><input type="file" data-settings=' + cfFileInputSettings + ' accept="'+cfAcceptAttr+'" name="' + fieldId + '_' + fileUploadInputCount + '" value="" data-field="' + fieldId + '" class="" id="' + fieldId + '_' + fileUploadInputCount + '" aria-labelledby="' + fieldId + 'Label"><input type="hidden" name="' + fieldId + '"></div><div class="cm-hipaa-cf-delete-file"><i class="material-icons">delete_forever</i></div>'); 1071 }); 1072 1073 /*** GRAVITY MULTI-FILE DELETE ***/ 1074 jQuery(document).on('click', '.cm-hipaa-gf-delete-file', function() { 1075 var fileInputId = jQuery(this).parent().find('input[type="file"]').first().attr('id') 1076 jQuery(this).prev().prev().remove(); 1077 jQuery(this).prev().remove(); 1078 jQuery(this).remove(); 1079 gfAddAnotherFileBtn(fileInputId); 1080 }); 1081 1082 /*** CALDERA MULTI-FILE DELETE ***/ 1083 jQuery(document).on('click', '.cm-hipaa-cf-delete-file', function() { 1084 jQuery(this).prev().prev().remove(); 1085 jQuery(this).prev().remove(); 1086 jQuery(this).remove(); 1087 }); 1088 1089 /*** TRIGGER CLICK EVENT ON ENTER/RETURN KEY CALDERA***/ 1090 jQuery(document).on('keydown', 'form .cm-hipaa-forms-submit.caldera.active', function(e){ 1091 if(e.keyCode===13){ 1092 jQuery('form .cm-hipaa-forms-submit.caldera.active').trigger('click'); 1093 } 1094 }); 1095 1096 /*** SUBMIT HIPAA ENABLED CALDERA FORM ***/ 1097 jQuery(document).on('click', 'form .cm-hipaa-forms-submit.caldera.active', function(e){ 1098 var submitButton = jQuery(this); 1099 var form = jQuery(this).parents('form:first'); 1100 var formHtml = form.html(); 1101 var noticeEle = form.find('.cm-hipaa-notice'); 1102 var formMainId = form.attr('id'); 1103 var formId = form.attr('data-form-id'); 1104 if(!formId) { 1105 formId = formMainId; 1106 } 1107 1108 // REMOVE ACTIVE CLASS FROM SUBMIT BUTTON TO PREVENT RE-SUBMITTING 1109 submitButton.removeClass('active').addClass('inactive'); 1110 1111 var calderaEnabledForms = JSON.parse(cmHipaaScript.calderaEnabledForms); // DEPRECATED 1112 formIds = []; 1113 1114 // LOOP CALDERA FORMS AND PUSH IDS TO ARRAY - DEPRECATED 1115 for(var i = 0; i < calderaEnabledForms.length; i++){ 1116 if(calderaEnabledForms[i]) { 1117 formIds.push(calderaEnabledForms[i]); 1118 } 1119 } 1120 1121 var enabledFormsSettings; 1122 if(cmHipaaScript.enabledFormsSettings) { 1123 enabledFormsSettings = JSON.parse(cmHipaaScript.enabledFormsSettings); // NEW JSON OBJECT ARRAY 1124 } 1125 1126 1127 // CHECK IF FORM OBJECT EXISTS IN ARRAY - NEW FORMS SETTINGS JSON OBJECT ARRAY METHOD 1128 var formFound = false; 1129 var successHandler; 1130 var successMessage; 1131 var successHideForm; 1132 var successRedirect; 1133 var successCallback; 1134 var successCallbackParams; 1135 var selectedUserSlug = ''; 1136 var showSignature; 1137 var notificationOption = ''; 1138 //var notificationFromName = ''; 1139 //var notificationFromEmail = ''; 1140 //var notificationSendTo = ''; 1141 //var notificationSubject = ''; 1142 //var notificationMessage = ''; 1143 1144 if(cmHipaaScript.enabledFormsSettings) { 1145 enabledFormsSettings.some(function (el) { 1146 if (el.id === formId && el.enabled === 'yes') { 1147 formFound = true; 1148 successHandler = el.success_handler; 1149 successMessage = el.success_message; 1150 successHideForm = el.success_hide_form; 1151 successRedirect = el.success_redirect; 1152 successCallback = el.success_callback; 1153 successCallbackParams = el.success_callback_params; 1154 selectedUserSlug = el.selected_user_slug; 1155 showSignature = el.show_signature; 1156 notificationOption = el.notification_option; 1157 //notificationFromName = el.notification_from_name; 1158 //notificationFromEmail = el.notification_from_email; 1159 //notificationSendTo = el.notification_sendto; 1160 //notificationSubject = el.notification_subject; 1161 //notificationMessage = el.notification_message; 1162 } 1163 }); 1164 } 1165 1166 // SET SUCCESS MESSAGE IF NOT SET 1167 if(!successMessage) { 1168 successMessage = 'Thank you, your form has been encrypted to protect your privacy and submitted successfully!'; 1169 } 1170 1171 // IF FORM ID IS IN ENABLED FORMS PREVENT DEFAULT SUBMIT AND SEND TO CODE MONKEYS 1172 if(jQuery.inArray(formId, formIds) !== -1 || formFound) { 1173 e.preventDefault(); //Prevent the normal submission action 1174 var defaultBorder; 1175 1176 // GET FILE INPUTS 1177 var fileInputs = form.find('input[type=file]'); 1178 1179 // CLONE THE FORM AS A HIDDEN VERSION IN ORDER TO REPLACE INPUTS WITH VALUES AND FORMAT TO SAVE 1180 form.after('<div class="cm-hipaa-forms-hidden-form" style="display:none;"></div>'); 1181 form.clone().appendTo('.cm-hipaa-forms-hidden-form');
1182 var hiddenForm = jQuery('.cm-hipaa-forms-hidden-form form'); 1183 var hiddenFormInputs = jQuery('.cm-hipaa-forms-hidden-form form :input'); 1184 1185 // REMOVE THE UNWANTED APPENDED ITEMS AT BOTTOM OF FORM 1186 hiddenForm.find('.cm-hipaa-forms-prepend-bottom, .cmprivacy-modal, .cmprivacy-modal-overlay').remove(); 1187 1188 // REMOVE STEP LINK BREADCRUMBS IF EXIST 1189 hiddenForm.find('.breadcrumb').remove(); 1190 1191 // LOOP CLONED HIDDEN FORM INPUTS AND GET LABELS => VALUES & FULL HTML VERSION OF FORM 1192 var formFields = []; 1193 var validationErrors = []; 1194 1195 var inputs = jQuery('#' + formMainId + ' :input'); 1196 hiddenFormInputs.each(function() { 1197 var label = form.find('label[for="' + jQuery(this).attr('id') + '"]').text().trim(); 1198 var value = jQuery(this).val(); 1199 var dataField = jQuery(this).attr('data-field'); 1200 var fieldId = jQuery(this).attr('id'); 1201 var fieldName = jQuery(this).attr('name'); 1202 var fieldType = jQuery(this).attr('type'); 1203 defaultBorder = jQuery(this).css('border'); 1204 var required = jQuery(this).attr('required'); 1205 var formGroup = jQuery(this).closest('.form-group'); 1206 var checkboxParentLabel = ''; 1207 var checkboxLabel = ''; 1208 var radioValue = ''; 1209 var checkboxValue = ''; 1210 var fieldValue = ''; 1211 var optionLabel = ''; 1212 var optionValue = ''; 1213 1214 // IGNORE INITIAL HIDDEN CALDERA FIELDS & NEXT/PREVIOUS BUTTONS 1215 if(fieldName !== '_cf_verify' && fieldName !== '_wp_http_referer' && fieldName !== '_cf_frm_id' && fieldName !== '_cf_frm_ct' && fieldName !== 'cfajax' && fieldName !== '_cf_cr_pst' && fieldType !== 'button' && !jQuery(this).hasClass('button_trigger_1') && !jQuery(this).hasClass('button_trigger_2') && fieldName !== 'pum_form_popup_id') { 1216 if (!fieldType) { 1217 if (jQuery(this).is('select')) { 1218 fieldType = 'select'; 1219 var visibleSelect = form.find('#' + fieldId); 1220 var optionText = visibleSelect.find('option:selected').text(); 1221 value = visibleSelect.val(); 1222 fieldValue = value; 1223 } else if (jQuery(this).is('textarea')) { 1224 fieldType = 'textarea'; 1225 var visibleTextArea = form.find('#' + fieldId); 1226 value = visibleTextArea.attr('value'); 1227 fieldValue = value; 1228 // TRY THE VALUE ATTR FIRST AND IF NO VALUE TRY NORMAL JQUERY VAL(), NOT SURE WHY ONE WORKS OVER THE OTHER SOMETIMES 1229 if(!value || value === 'undefined') { 1230 value = visibleTextArea.val(); 1231 fieldValue = value; 1232 } 1233 } 1234 } 1235 1236 // GET REQUIRED FIELDS THAT DO NOT HAVE A VALUE 1237 if (required && !value && form.find('#' + fieldId).is(':visible') || (fieldType === 'checkbox' || fieldType === 'radio') && (required || jQuery(this).attr('data-parsley-required') === 'true') && jQuery(this).prop('checked') === false && form.find('#' + fieldId).is(':visible')) { 1238 var errorExists; 1239 1240 if(fieldType === 'checkbox' || fieldType === 'radio') { 1241 var optionsGroup; 1242 var visibleOptionsGroup; 1243 if(fieldType === 'checkbox') { 1244 optionsGroup = jQuery(this).data('parsley-group'); 1245 visibleOptionsGroup = form.find('input[data-parsley-group="' + optionsGroup + '"]'); 1246 } else if(fieldType === 'radio') { 1247 optionsGroup = jQuery(this).data('radio-field'); 1248 visibleOptionsGroup = form.find('input[data-radio-field="' + optionsGroup + '"]'); 1249 } 1250 var cbIgnore; 1251 1252 visibleOptionsGroup.each(function() { 1253 if(jQuery(this).prop('checked') === true) { 1254 cbIgnore = true; 1255 1256 return false; 1257 } 1258 }); 1259 1260 if(validationErrors.length > 0) { 1261 validationErrors.some(function(el) { 1262 if(el.fieldId === fieldId || el.fieldGroup === optionsGroup) { 1263 errorExists = true; 1264 } 1265 }); 1266 } 1267 1268 if(!errorExists && !cbIgnore) { 1269 validationErrors.push({ 1270 'fieldId': fieldId, 1271 'label': form.find('label[for="' + optionsGroup + '"]').text(), 1272 'fieldType': fieldType, 1273 'fieldGroup': optionsGroup 1274 }); 1275 } 1276 } else { 1277 validationErrors.push({ 1278 'fieldId': fieldId, 1279 'label': form.find('label[for="' + jQuery(this).attr('id') + '"]').text(), 1280 'fieldType': fieldType, 1281 'fieldGroup': '' 1282 }); 1283 } 1284 } 1285 1286 // SET CHECKBOX OR RADIO FIELD LABEL AND INPUT LABEL 1287 if (fieldType === 'checkbox' || fieldType === 'radio') { 1288 if (jQuery(this).prop('checked') === true) { 1289 checkboxLabel = jQuery(this).parent().text().trim(); 1290 1291 if(jQuery(this).hasClass('cm-hipaa-forms-privacy-agree')) { 1292 label = 'Privacy Agreement'; 1293 } else { 1294 label = jQuery(this).parent().parent().parent().find('.control-label').text().trim(); 1295 1296 if(!label) { 1297 label = jQuery(this).parent().parent().parent().parent().find('.control-label').text().trim(); 1298 1299 if(!label) { 1300 label = checkboxLabel; 1301 } 1302 } 1303 } 1304 1305 checkboxParentLabel = label; 1306 optionLabel = checkboxLabel; 1307 optionValue = value; 1308 } 1309 } 1310 1311 // REPLACE HIDDEN HTML VERSION INPUTS WITH VALUES 1312 if (fieldType === 'select') { 1313 jQuery(this).replaceWith(optionText); 1314 } else if (fieldType === 'checkbox') { 1315 // SET CHECKBOX VALUE IF DIFFERENT THAN LABEL 1316 if(value !== checkboxLabel) { 1317 checkboxValue = value; 1318 } 1319 1320 if (jQuery(this).prop('checked') === true) { 1321 // SET CHECKED CHECKBOX IMAGE AND VALUE 1322 value = '<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/checkbox.png" alt="Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" />' + checkboxValue + '</span>'; 1323 jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-checked-wrapper'); 1324 if(checkboxParentLabel) { 1325 fieldValue = 'checked'; 1326 } 1327 } else { 1328 // SET UNCHECKED CHECKBOX IMAGE AND VALUE 1329 value = '<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-not-checked"><img src="https://www.hipaaforms.online/api-assets/checkbox-unchecked.png" alt="Not Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>'; 1330 jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-not-checked-wrapper'); 1331 } 1332 jQuery(this).replaceWith(value); 1333 } else if (fieldType === 'radio') { 1334 // SET RADIO VALUE IF DIFFERENT THAN LABEL 1335 if (value !== checkboxLabel) { 1336 radioValue = value; 1337 } 1338 if (jQuery(this).prop('checked') === true) { 1339 // SET CHECKED RADIO BUTTON IMAGE AND VALUE 1340 value = '<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/radio-checked.png" alt="Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" />' + radioValue + '</span>'; 1341 jQuery(this).parent().addClass('cm-hipaa-forms-radio-checked-wrapper'); 1342 if (checkboxParentLabel) { 1343 fieldValue = 'checked'; 1344 } 1345 } else { 1346 // SET UNCHECKED RADIO BUTTON IMAGE AND VALUE 1347 value = '<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-not-checked"><img src="https://www.hipaaforms.online/api-assets/radio-unchecked.png" alt="Not Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>'; 1348 jQuery(this).parent().addClass('cm-hipaa-forms-radio-not-checked-wrapper'); 1349 } 1350 jQuery(this).replaceWith(value); 1351 } else if(fieldType === 'hidden') { 1352 // NEED TO CREATE A WRAPPING ELEMENT AND PASS ATTRIBUTES FROM INPUT TO WRAPPER ELE 1353 jQuery(this).replaceWith('<div data-field="' + jQuery(this).attr('data-field') + '" class="form-group ' + jQuery(this).attr('class') + '" id="' + jQuery(this).attr('id') + '">' + value + '</div>'); 1354 } else { 1355 fieldValue = value; 1356 jQuery(this).replaceWith(value); 1357 } 1358 1359 // ADD CUSTOM CLASS TO IDENTIFY IF FIELD VALUE IS EMPTY OR NOT 1360 if(formGroup.hasClass('cm_hipaa_forms_field_not_empty') === false && (!fieldValue || fieldValue.length === 0)) { 1361 formGroup.addClass('cm_hipaa_forms_field_empty'); 1362 } else { 1363 formGroup.removeClass('cm_hipaa_forms_field_empty'); 1364 formGroup.addClass('cm_hipaa_forms_field_not_empty'); 1365 } 1366 1367 1368 if (label && fieldValue) { 1369 // IF LABEL EXISTS PUSH TO FIELDS ARRAY 1370 formFields.push({ 1371 'label': label, 1372 'option_label': optionLabel, 1373 'option_value': optionValue, 1374 'value': fieldValue, 1375 'data_field': dataField, 1376 'field_id': fieldId, 1377 'field_type': fieldType, 1378 'option_text': optionText 1379 }); 1380 } 1381 } 1382 }); 1383 1384 // GET SIGNATURE SVG BASE64 DATA 1385 var signatureEle = form.find('.cm-hipaa-form-signature');
1386 var datapair = signatureEle.jSignature("getData", "svgbase64"); 1387 var signature; 1388 if(datapair) { 1389 signature = "data:" + datapair[0] + "," + datapair[1]; 1390 1391 formFields.push({ 1392 'label': 'Signature', 1393 'option_label': 'data:', 1394 'option_value': datapair[0], 1395 'value': datapair[1], 1396 'data_field': '', 1397 'field_id': '', 1398 'field_type': 'signature', 1399 'option_text': '' 1400 }); 1401 } 1402 1403 // SET PRIVACY AGREEMENT ELEMENT 1404 var privacyAgreementEle = form.find('.cm-hipaa-forms-privacy-agree'); 1405 1406 // RESET ERRORS 1407 //inputs.css('border', defaultBorder); 1408 jQuery('.form-group').removeClass('has-error'); 1409 jQuery('input, select, textarea').removeAttr('aria-invalid').removeClass('parsley-error'); 1410 jQuery('.caldera_ajax_error_block').remove(); 1411 privacyAgreementEle.parent().css('border', '0'); 1412 if(signatureEle) { 1413 signatureEle.find('.jSignature').css('border', '0'); 1414 } 1415 noticeEle.html(''); 1416 1417 // MULTI-PAGE FORM RENDERING 1418 var calderaFormPages = hiddenForm.find('[data-formpage]'); 1419 calderaFormPages.each(function(index) { 1420 // MAKE PAGE ELEMENT VISIBLE 1421 jQuery(this).css({ 1422 'visibility': 'visible', 1423 'display': 'block' 1424 }); 1425 1426 // REMOVE BUTTONS 1427 jQuery(this).find('input[type="button"]').closest('.form-group').remove(); 1428 jQuery(this).find('button').remove(); 1429 1430 // APPEND PAGE BREAK TO END OF PAGE FOR MPDF IF NOT LAST ELEMENT 1431 if(index !== (calderaFormPages.length - 1)) { 1432 jQuery(this).append('<pagebreak />'); 1433 } 1434 }); 1435 1436 var nonce = cmHipaaScript.nonce; 1437 1438 if(!jQuery.isEmptyObject(validationErrors) && validationErrors.length > 0) { // ADDED .LENGTH CHECK TO OBJECT TO PREVENT POTENTIAL UNDEFINED OBJ ISSUES 1439 // VALIDATE FIELDS 1440 jQuery.each(validationErrors, function(key, val) { 1441 var invalidFieldId = val.fieldId; 1442 var invalidFieldType = val.fieldType; 1443 var invalidFieldGroup = val.fieldGroup; 1444 var invalidInput = jQuery('#' + invalidFieldId); 1445 var invalidFieldWrapper; 1446 1447 if(invalidFieldGroup) { 1448 invalidFieldWrapper = jQuery('#' + invalidFieldGroup + '-wrap'); 1449 } else { 1450 invalidFieldWrapper = jQuery('#' + invalidFieldId + '-wrap'); 1451 } 1452 1453 // ADD ERROR CLASS TO FIELD GROUP ELEMENT & INPUT 1454 invalidFieldWrapper.addClass('has-error'); 1455 invalidInput.attr('aria-invalid', 'true').addClass('parsley-error'); 1456 jQuery('label[for="' + invalidFieldId + '"]').addClass('parsley-error'); 1457 1458 // APPEND NOTICE 1459 invalidFieldWrapper.append('<span class="help-block caldera_ajax_error_block filled" aria-live="polite"><span class="parsley-required">This value is required.</span></span>'); 1460 1461 // UPDATE NOTICE ELEMENT 1462 noticeEle.append('<p>' + val.label + ' is a required field!</p>'); 1463 }); 1464 1465 // REMOVE HIDDEN FORM 1466 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1467 1468 // SET FIRST INVALID FIELD DEPENDING ON IF CHECKBOX/FIELDGROUP 1469 var scrollTopEle; 1470 if(validationErrors[0].fieldGroup) { 1471 //if(validationErrors[0].hasOwnProperty('fieldGroup')) { // CHANGED TO PREVENT POTENTIAL UNDEFINED ISSUES 1472 scrollTopEle = '#' + validationErrors[0].fieldGroup + '-wrap'; 1473 } else { 1474 scrollTopEle = '#' + validationErrors[0].fieldId + '-wrap'; 1475 } 1476 1477 // SCROLL TO FIRST INVALID FIELD 1478 jQuery('html, body').animate({ 1479 scrollTop: jQuery(scrollTopEle).offset().top 1480 }, 500, 'linear'); 1481
1482 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1483 submitButton.removeClass('inactive').addClass('active'); 1484 } else if(privacyAgreementEle.prop('checked') !== true) { 1485 // ENSURE THE HIPAA PRIVACY CHECKBOX IS CHECKED 1486 privacyAgreementEle.parent().css('border', '1px solid red'); 1487 noticeEle.html('You must agree to the HIPAA Privacy Agreement'); 1488 1489 // REMOVE HIDDEN FORM 1490 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1491 1492 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1493 submitButton.removeClass('inactive').addClass('active'); 1494 } else if(showSignature === 'yes' && !signatureEle.find('.jSignature').hasClass('cm-valid-sig')) { 1495 // ADD RED BORDER TO SIGNATURE FIELD 1496 signatureEle.find('.jSignature').css('border', '1px solid red'); 1497 1498 // UPDATE NOTICE ELEMENT 1499 noticeEle.html('You must sign the form'); 1500 1501 // REMOVE HIDDEN FORM 1502 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1503 1504 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1505 submitButton.removeClass('inactive').addClass('active'); 1506 } else { 1507 // VALIDATE ACCOUNT TO GET ENABLED ADD-ONS 1508 jQuery.ajax({ 1509 method: 'POST', 1510 type: 'POST', 1511 url: cmHipaaScript.ajax_url, 1512 data: { 1513 'action': 'cm_hipaa_validate_account', 1514 'nonce': cmHipaaScript.nonce 1515 }, 1516 success: function (data) { 1517 // REMOVE LOADING ICON 1518 jQuery('.cm-hipaa-forms-loading').remove(); 1519 //var resultData = JSON.parse(data); 1520 var resultData; 1521 try { 1522 resultData = JSON.parse(data); 1523 } catch (e) { 1524 console.log(data); 1525 noticeEle.append(data); 1526 return false; 1527 } 1528 1529 if (resultData.success === 'success') { 1530 // CHECK IF FILE UPLOAD ENABLED 1531 var validatedAddOns = resultData.add_ons; 1532 var validatedAddOnsArray; 1533 if(validatedAddOns) { 1534 validatedAddOnsArray = validatedAddOns.split(','); 1535 } 1536 var fileUploadEnabled = 'no'; 1537 if(Array.isArray(validatedAddOnsArray) && validatedAddOnsArray.indexOf('fileupload') !== -1) { 1538 fileUploadEnabled = 'yes'; 1539 } else if(validatedAddOns === 'fileupload') { 1540 fileUploadEnabled = 'yes'; 1541 } 1542 1543 // IF FILE INPUTS EXIST & FILE UPLOAD ENABLED 1544 if (fileInputs.length > 0 && fileUploadEnabled === 'yes') { 1545 // SHOW LOADING BAR 1546 noticeEle.html('<div class="cm-hipaa-forms-file-upload-status">Uploading Files...</div><div class="cm-hipaa-forms-progress-wrapper"><div class="cm-hipaa-forms-progress"><div class="cm-hipaa-forms-progress-bar"><!-- <div class="cm-hipaa-forms-progress-label">10%</div>--></div></div></div>'); 1547 cmHipaaFormsProgress(); 1548 var fileInputsLength = fileInputs.length; 1549 var iterations = 0; 1550 var fileKeys = []; 1551 fileInputs.each(function (index) { 1552 var fileInputParentId = jQuery(this).parent().parent().attr('id'); 1553 var fileLabel = jQuery(this).parent().parent().find('label').text(); 1554 fileLabel = fileLabel.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '-'); 1555 // GET FILE 1556 var theFormFile = jQuery(this).get()[0].files[0]; 1557 if (theFormFile) { 1558 var fileType = theFormFile.type; 1559 var fileName = theFormFile.name; 1560 // GET PRESIGNED FILE UPLOAD URL 1561 jQuery.ajax({ 1562 method: 'POST', 1563 type: 'POST', 1564 url: cmHipaaScript.ajax_url, 1565 data: { 1566 'action': 'cm_hipaa_get_file_upload_url', 1567 'file_name': fileName, 1568 'nonce': cmHipaaScript.
1568nonce 1569 }, 1570 success: function (data) { 1571 //var resultData = JSON.parse(data); 1572 var resultData; 1573 try { 1574 resultData = JSON.parse(data); 1575 } catch (e) { 1576 console.log(data); 1577 noticeEle.append(data); 1578 return false; 1579 } 1580 1581 var fileUploadUrl = resultData.file_upload_url; 1582 var fileKey = resultData.file_key; 1583 // PUSH FILE KEYS TO ARRAY 1584 fileKeys.push(fileKey); 1585 // UPLOAD THE FILE 1586 jQuery.ajax({ 1587 url: fileUploadUrl, // the presigned URL 1588 type: 'PUT', 1589 processData: false, 1590 contentType: fileType, 1591 //headers: {'x-amz-tagging': 'label=' + fileLabel}, 1592 data: theFormFile, 1593 success: function () { 1594 var hiddenFileUploadContainer = hiddenForm.find('#' + fileInputParentId); 1595 var existingFiles = hiddenFileUploadContainer.find('.cm_hipaa_file_input'); // GET EXISTING FILES ALREADY UPLOADED IN HIDDEN FORM 1596 hiddenFileUploadContainer.html(''); // CLEAR THE CONTAINER ELEMENT 1597 // PREPEND LABEL TO FILE CONTAINER ELEMENT 1598 hiddenFileUploadContainer.prepend('<label>' + fileLabel + '</label>'); 1599 jQuery.each(existingFiles, function () { 1600 // APPEND EXISTING FILES ALREADY UPLOADED BACK INTO CONTAINER ELEMENT 1601 hiddenFileUploadContainer.append(jQuery(this)); 1602 }); 1603 // APPEND NEW UPLOADED FILE TO CONTAINER ELEMENT 1604 hiddenFileUploadContainer.append('<div class="cm_hipaa_file_input" data-file-key="' + fileKey + '">' + fileKey + '</div>'); 1605 iterations = iterations + 1; 1606 if (iterations === fileInputsLength) { 1607 // UPDATE FILE UPLOAD STATUS 1608 jQuery('.cm-hipaa-forms-file-upload-status').html('Submitting Form...'); 1609 // SET TIMEOUT TO ENSURE INPUTS OVERWRITTEN 1610 setTimeout(function () { 1611 // SUBMIT FORM 1612 jQuery.ajax({ 1613 method: 'POST', 1614 type: 'POST', 1615 url: cmHipaaScript.ajax_url, 1616 data: { 1617 'action': 'cm_hipaa_submit_caldera_form', 1618 'formId': formId, 1619 'formFields': formFields, 1620 'formHtml': hiddenForm.html(), 1621 'signature': signature, 1622 'nonce': nonce, 1623 'selectedUserSlug': selectedUserSlug, 1624 'notification_option': notificationOption, 1625 //'notification_from_name': notificationFromName, 1626 //'notification_from_email': notificationFromEmail, 1627 //'notification_sendto': notificationSendTo, 1628 //'notification_subject': notificationSubject, 1629 //'notification_message': notificationMessage, 1630 'files': fileKeys.join(','), 1631 'formFound': formFound 1632 }, 1633 success: function (data) { 1634 //var resultData = JSON.parse(data); 1635 var resultData; 1636 try { 1637 resultData = JSON.parse(data); 1638 } catch (e) { 1639 console.log(data); 1640 noticeEle.append(data); 1641 return false; 1642 } 1643 1644 var formError = ''; 1645 if (resultData.error) { 1646 formError = resultData.error; 1647 } 1648 1649 if (resultData.success === 'success') { 1650 if (successHandler === 'message') { 1651 if(successHideForm === 'hide') { 1652 // HIDE FORM THEN ADD SUCCESS MESSAGE 1653 form.fadeOut().promise().done(function() { 1654 form.after('<div class="cm-hipaa-notice cm-hidden-form-message">' + successMessage + ' ' + formError + '</div>'); 1655 jQuery('.cm
1655-hidden-form-message').fadeIn(); 1656 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1657 submitButton.removeClass('inactive').addClass('active'); 1658 }); 1659 } else { 1660 // DISPLAY THE SUCCESS NOTICE 1661 noticeEle.html(successMessage + ' ' + formError); 1662 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1663 submitButton.removeClass('inactive').addClass('active'); 1664 } 1665 } else if (successHandler === 'redirect') { 1666 // REDIRECT TO SUCCESS PAGE 1667 window.location = successRedirect; 1668 } else if (successHandler === 'callback') { 1669 // MAKE SURE CALLBACK IS AN EXISTING FUNCTION 1670 fnExists = typeof window[successCallback] === 'function'; 1671 if (fnExists) { 1672 if (successCallbackParams) { 1673 window[successCallback].apply(null, successCallbackParams.split(',')); 1674 } else { 1675 window[successCallback](); 1676 } 1677 } else { 1678 console.log(successCallback + ' is not an existing function!'); 1679 } 1680 if (successMessage) { 1681 noticeEle.html(successMessage + ' ' + formError); 1682 } else { 1683 // DISPLAY THE SUCCESS NOTICE 1684 noticeEle.html('Thank y
1684ou, your form has been encrypted to protect your privacy and submitted successfully!'); 1685 } 1686 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1687 submitButton.removeClass('inactive').addClass('active'); 1688 } else { 1689 // DISPLAY THE SUCCESS NOTICE 1690 noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!'); 1691 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1692 submitButton.removeClass('inactive').addClass('active'); 1693 } 1694 // RESET THE FORM 1695 form[0].reset(); 1696 if (signature) { 1697 signatureEle.jSignature("reset"); 1698 } 1699 } else { 1700 // JUST A FAIL-SAFE JUST IN CASE WE DON'T ACTUALLY GET A SUCCESS MESSAGE 1701 noticeEle.html(formError); 1702 } 1703 hiddenForm.remove(); 1704 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1705 }, 1706 error: function (errorThrown) { 1707 console.log(errorThrown); 1708 noticeEle.html(errorThrown); 1709 hiddenForm.remove(); 1710 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1711 } 1712 }); 1713 }, 1000); 1714 } 1715 } 1716 }); 1717 }, 1718 error: function (errorThrown) { 1719 console.log(errorThrown); 1720 } 1721 }); 1722 } else { 1723 hiddenForm.find('#' + fileInputParentId).find('.file-prevent-overflow').html('<div class="cm_hipaa_file_input" data-file-key="">No File Attached</div>'); 1724 iterations = iterations + 1; 1725 if (iterations === fileInputsLength) { 1726 // UPDATE FILE UPLOAD STATUS 1727 jQuery('.cm-hipaa-forms-file-upload-status').html('Submitting Form...'); 1728 // SET TIMEOUT TO ENSURE INPUTS OVERWRITTEN 1729 setTimeout(function () { 1730 // SUBMIT FORM 1731 jQuery.ajax({ 1732 method: 'POST', 1733 type: 'POST', 1734 url: cmHipaaScript.ajax_url, 1735 data: { 1736 'action': 'cm_hipaa_submit_caldera_form', 1737 'formId': formId, 1738 'formFields': formFields, 1739 'formHtml': hiddenForm.html(), 1740 'signature': signature, 1741 'nonce': nonce, 1742 'selectedUserSlug': selectedUserSlug, 1743 'notification_option': notificationOption, 1744 //'notification_from_name': notificationFromName, 1745 //'notification_from_email': notificationFromEmail, 1746 //'notification_sendto': notificationSendTo, 1747 //'notification_subject': notificationSubject, 1748 //'notification_message': notificationMessage, 1749 'files': fileKeys.join(','), 1750 'formFound': formFound 1751 }, 1752 success: function (data) { 1753 //var resultData = JSON.parse(data); 1754 var resultData; 1755 try { 1756 resultData = JSON.parse(data); 1757 } catch (e) { 1758 console.log(data); 1759 noticeEle.append(data); 1760 return false; 1761 } 1762 1763 var formError = ''; 1764 if (resultData.error) { 1765 formError = resultData.error; 1766 } 1767 if (resultData.success === 'success') { 1768 if (successHandler === 'message') { 1769 if(successHideForm === 'hide') { 1770 // HIDE FORM THEN ADD SUCCESS MESSAGE 1771 form.fadeOut().promise().done(function() { 1772 form.after('<div class="cm-hipaa-notice cm-hidden-form-message">' + successMessage + ' ' + formError + '</div>'); 1773 jQuery('.cm
1773-hidden-form-message').fadeIn(); 1774 }); 1775 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1776 submitButton.removeClass('inactive').addClass('active'); 1777 } else { 1778 // DISPLAY THE SUCCESS NOTICE 1779 noticeEle.html(successMessage + ' ' + formError); 1780 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1781 submitButton.removeClass('inactive').addClass('active'); 1782 } 1783 } else if (successHandler === 'redirect') { 1784 // REDIRECT TO SUCCESS PAGE 1785 window.location = successRedirect; 1786 } else if (successHandler === 'callback') { 1787 // MAKE SURE CALLBACK IS AN EXISTING FUNCTION 1788 fnExists = typeof window[successCallback] === 'function'; 1789 if (fnExists) { 1790 if (successCallbackParams) { 1791 window[successCallback].apply(null, successCallbackParams.split(',')); 1792 } else { 1793 window[successCallback](); 1794 } 1795 } else { 1796 console.log(successCallback + ' is not an existing function!'); 1797 } 1798 if (successMessage) { 1799 noticeEle.html(successMessage + ' ' + formError); 1800 } else { 1801 // DISPLAY THE SUCCESS NOTICE 1802 noticeEle.html('Thank y
1802ou, your form has been encrypted to protect your privacy and submitted successfully!'); 1803 } 1804 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1805 submitButton.removeClass('inactive').addClass('active'); 1806 } else { 1807 // DISPLAY THE SUCCESS NOTICE 1808 noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!'); 1809 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1810 submitButton.removeClass('inactive').addClass('active'); 1811 } 1812 // RESET THE FORM 1813 form[0].reset(); 1814 if (signature) { 1815 signatureEle.jSignature("reset"); 1816 } 1817 } else { 1818 // JUST A FAIL-SAFE JUST IN CASE WE DON'T ACTUALLY GET A SUCCESS MESSAGE 1819 noticeEle.html(formError); 1820 } 1821 hiddenForm.remove(); 1822 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1823 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1824 submitButton.removeClass('inactive').addClass('active'); 1825 }, 1826 error: function (errorThrown) { 1827 console.log(errorThrown); 1828 noticeEle.html(errorThrown); 1829 hiddenForm.remove(); 1830 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1831 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1832 submitButton.removeClass('inactive').addClass('active'); 1833 } 1834 }); 1835 }, 1000); 1836 } 1837 } 1838 }); 1839 } else { 1840 // SHOW LOADING BAR 1841 noticeEle.html('<div class="cm-hipaa-forms-progress-wrapper"><div class="cm-hipaa-forms-progress"><div class="cm-hipaa-forms-progress-bar"><!-- <div class="cm-hipaa-forms-progress-label">10%</div>--></div></div></div>'); 1842 cmHipaaFormsProgress(); 1843 // SUBMIT FORM 1844 jQuery.ajax({ 1845 method: 'POST', 1846 type: 'POST', 1847 url: cmHipaaScript.ajax_url, 1848 data: { 1849 'action': 'cm_hipaa_submit_caldera_form', 1850 'formId': formId, 1851 'formFields': formFields, 1852 'formHtml': hiddenForm.html(), 1853 'signature': signature, 1854 'nonce': nonce, 1855 'selectedUserSlug': selectedUserSlug, 1856 'notification_option': notificationOption, 1857 //'notification_from_name': notificationFromName, 1858 //'notification_from_email': notificationFromEmail, 1859 //'notification_sendto': notificationSendTo, 1860 //'notification_subject': notificationSubject, 1861 //'notification_message': notificationMessage 1862 'formFound': formFound 1863 }, 1864 success: function (data) { 1865 //var resultData = JSON.parse(data); 1866 var resultData; 1867 try { 1868 resultData = JSON.parse(data); 1869 } catch (e) { 1870 console.log(data); 1871 noticeEle.append(data); 1872 return false; 1873 } 1874 1875 var formError = ''; 1876 if (resultData.error) { 1877 formError = resultData.error; 1878 } 1879 if (resultData.success === 'success') { 1880 if (successHandler === 'message') { 1881 if(successHideForm === 'hide') { 1882 // HIDE FORM THEN ADD SUCCESS MESSAGE 1883 form.fadeOut().promise().done(function() { 1884 form.after('<div class="cm-hipaa-notice cm-hidden-form-message">' + successMessage + ' ' + formError + '</div>'); 1885 jQuery('.cm
1885-hidden-form-message').fadeIn(); 1886 }); 1887 } else { 1888 // DISPLAY THE SUCCESS NOTICE 1889 noticeEle.html(successMessage + ' ' + formError); 1890 } 1891 } else if (successHandler === 'redirect') { 1892 // REDIRECT TO SUCCESS PAGE 1893 window.location = successRedirect; 1894 } else if (successHandler === 'callback') { 1895 // MAKE SURE CALLBACK IS AN EXISTING FUNCTION 1896 fnExists = typeof window[successCallback] === 'function'; 1897 if (fnExists) { 1898 if (successCallbackParams) { 1899 window[successCallback].apply(null, successCallbackParams.split(',')); 1900 } else { 1901 window[successCallback](); 1902 } 1903 } else { 1904 console.log(successCallback + ' is not an existing function!'); 1905 } 1906 if (successMessage) { 1907 noticeEle.html(successMessage + ' ' + formError); 1908 } else { 1909 // DISPLAY THE SUCCESS NOTICE 1910 noticeEle.html('Thank y
1910ou, your form has been encrypted to protect your privacy and submitted successfully!'); 1911 } 1912 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1913 submitButton.removeClass('inactive').addClass('active'); 1914 } else { 1915 // DISPLAY THE SUCCESS NOTICE 1916 noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!'); 1917 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1918 submitButton.removeClass('inactive').addClass('active'); 1919 } 1920 // RESET THE FORM 1921 form[0].reset(); 1922 if (signature) { 1923 signatureEle.jSignature("reset"); 1924 } 1925 } else { 1926 // JUST A FAIL-SAFE JUST IN CASE WE DON'T ACTUALLY GET A SUCCESS MESSAGE 1927 noticeEle.html(formError); 1928 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1929 submitButton.removeClass('inactive').addClass('active'); 1930 } 1931 hiddenForm.remove(); 1932 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1933 }, 1934 error: function (errorThrown) { 1935 console.log(errorThrown); 1936 noticeEle.html(errorThrown); 1937 hiddenForm.remove(); 1938 jQuery('.cm-hipaa-forms-hidden-form').remove(); 1939 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 1940 submitButton.removeClass('inactive').addClass('active'); 1941 } 1942 }); 1943 } 1944 } else { 1945 console.log('Error validating Account...'); 1946 } 1947 }, 1948 error: function (errorThrown) { 1949 console.log(errorThrown); 1950 } 1951 }); 1952 } 1953 } 1954 }); 1955 1956 /*** TRIGGER CLICK EVENT ON ENTER/RETURN KEY GRAVITY***/ 1957 jQuery(document).on('keyup', 'form .cm-hipaa-forms-submit.gravity.active', function(e){ 1958 if(e.keyCode===13){ 1959 jQuery('body form .cm-hipaa-forms-submit.gravity.active').trigger('click'); 1960 } 1961 }); 1962 1963 /*** SUBMIT HIPAA ENABLED GRAVITY FORM ***/ 1964 jQuery(document).on('click', 'form .cm-hipaa-forms-submit.gravity.active', function(e){ 1965 var gravityVersion = cmHipaaScript.gravityVersion; 1966 var submitButton = jQuery(this); 1967 var form = jQuery(this).parents('form:first'); 1968 var noticeEle = form.find('.cm-hipaa-notice'); 1969 var formMainId = form.attr('id'); 1970 var formId = form.attr('data-form-id'); 1971 var newFormat = false; 1972 var legacyMarkup = false; 1973 if(!formId) { 1974 formId = formMainId; 1975 } 1976 1977 // REMOVE ALL TAGS BEFORE CLONING FORM 1978 var rawInputs = form.find('textarea, ' + 1979 'input[type=text], ' + 1980 'input[type=textarea], ' + 1981 'input[type=email], ' + 1982 'input[type=hidden], ' + 1983 'input[type=password], ' + 1984 'input[type=search], ' + 1985 'input[type=url], ' + 1986 'input[type=month], ' + 1987 'input[type=day], ' + 1988 'input[type=year]'); 1989 jQuery.each(rawInputs, function(index) { 1990 var rawValue = jQuery(this).val(); 1991 if (rawValue) { 1992 var newValue = rawValue 1993 .replaceAll('onerror', '') 1994 .replaceAll('img', '') 1995 .replaceAll('onload','') 1996 .replaceAll('<','<') 1997 .replaceAll('>', '>'); 1998 //var sanitizedValue = removeTags(newValue); 1999 jQuery(this).val(newValue); 2000 } 2001 }); 2002 2003 // CHECK IF NEW FORMAT VERSION (2.5 OR HIGHER) 2004 if(gravityVersion >= 2.5) { 2005 // SET NEW FORMAT TO TRUE 2006 newFormat = true; 2007 2008 // CHECK IF LEGACY MARKUP FORM 2009 if(form.parent().hasClass('gform_legacy_markup_wrapper')) { 2010 legacyMarkup = true; 2011 } 2012 } 2013 2014 // REMOVE ACTIVE CLASS TO PREVENT RE-SUBMITTING 2015 submitButton.removeClass('active').addClass('inactive'); 2016 2017 // REMOVE REQUIRED FIELD NOTIFICATION ERROR IF EXISTS 2018 jQuery('.validation_error').remove(); 2019 2020 var gravityEnabledForms = JSON.parse(cmHipaaScript.gravityEnabledForms); // DEPRECATED 2021 formIds = []; 2022
2023 // LOOP GRAVITY FORMS AND PUSH IDS TO ARRAY - DEPRECATED 2024 for(var i = 0; i < gravityEnabledForms.length; i++){ 2025 if(gravityEnabledForms[i]) { 2026 formIds.push('gform_' + gravityEnabledForms[i]); 2027 } 2028 } 2029 2030 var enabledFormsSettings; 2031 if(cmHipaaScript.enabledFormsSettings) { 2032 enabledFormsSettings = JSON.parse(cmHipaaScript.enabledFormsSettings); // NEW JSON OBJECT ARRAY 2033 } 2034 2035 2036 // CHECK IF FORM OBJECT EXISTS IN ARRAY - NEW FORMS SETTINGS JSON OBJECT ARRAY METHOD 2037 var formFound; 2038 var successHandler; 2039 var successMessage; 2040 var successHideForm; 2041 var successRedirect; 2042 var successCallback; 2043 var successCallbackParams; 2044 var selectedUserSlug = ''; 2045 var showSignature; 2046 var notificationOption = ''; 2047 //var notificationFromName = ''; 2048 //var notificationFromEmail = ''; 2049 //var notificationSendTo = ''; 2050 //var notificationSubject = ''; 2051 //var notificationMessage = ''; 2052 2053 if(cmHipaaScript.enabledFormsSettings) { 2054 enabledFormsSettings.some(function (el) { 2055 if (el.form_builder === 'gravity' && 'gform_' + el.id === formId && el.enabled === 'yes') { 2056 formFound = true; 2057 successHandler = el.success_handler; 2058 successMessage = el.success_message; 2059 successHideForm = el.success_hide_form; 2060 successRedirect = el.success_redirect; 2061 successCallback = el.success_callback; 2062 successCallbackParams = el.success_callback_params; 2063 selectedUserSlug = el.selected_user_slug; 2064 showSignature = el.show_signature; 2065 notificationOption = el.notification_option; 2066 //notificationFromName = el.notification_from_name; 2067 //notificationFromEmail = el.notification_from_email; 2068 //notificationSendTo = el.notification_sendto; 2069 //notificationSubject = el.notification_subject; 2070 //notificationMessage = el.notification_message; 2071 } 2072 }); 2073 } 2074 2075 // SET SUCCESS MESSAGE IF NOT SET 2076 if(!successMessage) { 2077 successMessage = 'Thank you, your form has been encrypted to protect your privacy and submitted successfully!'; 2078 } 2079 2080 // IF FORM ID IS IN ENABLED FORMS PREVENT DEFAULT SUBMIT AND SEND TO CODE MONKEYS 2081 if(jQuery.inArray(formId, formIds) !== -1 || formFound) { 2082 e.preventDefault(); //Prevent the normal submission action 2083 2084 var location; 2085 var locationEmail; 2086 var firstName; 2087 var lastName; 2088 var email; 2089 var phone; 2090 var selectedUser; 2091 var defaultBorder; 2092 2093 // CHECK IF PAGINATED 2094 let isPaginated = false; 2095 if(jQuery('.gform_page')[0]) { 2096 isPaginated = true; 2097 } 2098 2099 // GET FILE INPUTS 2100 var fileInputs = form.find('input[type=file]'); 2101 2102 // CLONE THE FORM AS A HIDDEN VERSION IN ORDER TO REPLACE INPUTS WITH VALUES AND FORMAT TO SAVE 2103 form.after('<div class="cm-hipaa-forms-hidden-form" style="display:none;"></div>'); // ADD HIDDEN EMPTY DIV ELEMENT TO CLONE FORM TO 2104 form.clone().appendTo('.cm-hipaa-forms-hidden-form'); // CLONE FORM TO APPENDED HIDDEN EMPTY DIV ELEMENT 2105 var hiddenForm = jQuery('.cm-hipaa-forms-hidden-form form'); // SET HIDDEN FORM VARIABLE 2106 var hiddenFormInputs = jQuery('.cm-hipaa-forms-hidden-form form :input'); // SET INPUTS VARIABLE FROM HIDDEN FORM 2107 2108 // IF GRAVITY 2.5+ ADD GFORM_WRAPPER GRAVITY-THEME CLASS ELEMENT FOR COLUMN STYLES TO WORK 2109 if(newFormat === true && legacyMarkup === false) { 2110 hiddenForm.find('.gform_body').addClass('gform_wrapper gravity-theme'); 2111 } 2112 2113 // REMOVE THE UNWANTED APPENDED ITEMS AT BOTTOM OF FORM 2114 hiddenForm.find('.cm-hipaa-forms-prepend-bottom, .cmprivacy-modal, .cmprivacy-modal-overlay').remove(); 2115 hiddenForm.find('.gform_footer .gform_hidden').remove(); 2116 2117 //add css class by dividing by number of header items 2118 hiddenForm.find('.gfield_list_container').each(function () { 2119 var headerItems = jQuery(this).find('.gfield_header_item'); 2120 var headerCount = headerItems.length; 2121 //console.log(headerCount)
2122 if(headerItems.last().hasClass('gfield_header_item--icons')){ 2123 headerCount = headerCount - 1; 2124 } 2125 2126 var widthClass; 2127 switch (headerCount) { 2128 case 1 : 2129 widthClass = 'cm-hipaa-gfield--width-1-col'; 2130 break; 2131 case 2 : 2132 widthClass = 'cm-hipaa-gfield--width-2-col'; 2133 break; 2134 case 3 : 2135 widthClass = 'cm-hipaa-gfield--width-3-col'; 2136 break; 2137 case 4 : 2138 widthClass = 'cm-hipaa-gfield--width-4-col'; 2139 break; 2140 case 5 : 2141 widthClass = 'cm-hipaa-gfield--width-5-col'; 2142 break; 2143 case 6 : 2144 widthClass = 'cm-hipaa-gfield--width-6-col'; 2145 break; 2146 case 7 : 2147 widthClass = 'cm-hipaa-gfield--width-7-col'; 2148 break; 2149 case 8 : 2150 widthClass = 'cm-hipaa-gfield--width-8-col'; 2151 break; 2152 case 9 : 2153 widthClass = 'cm-hipaa-gfield--width-9-col' 2154 break; 2155 default: 2156 widthClass = ''; 2157 } 2158 headerItems.each(function () { 2159 jQuery(this).addClass(widthClass); 2160 }); 2161 jQuery(this).find('.gfield_list_group_item').each(function () { 2162 jQuery(this).removeAttr('data-label'); 2163 jQuery(this).addClass(widthClass); 2164 }) 2165 }) 2166 2167 2168 // FIND DATE FIELDS 2169 var dateContainers = hiddenForm.find('.ginput_container_date'); 2170 2171 // LOOP DATE FIELDS 2172 var dateInputId = ''; 2173 dateContainers.each(function() { 2174 // SET MAIN INPUT ID 2175 dateInputId = jQuery(this).find('.datepicker').attr('id'); 2176 2177 // REMOVE ICON 2178 jQuery(this).find('.ui-datepicker-trigger').remove(); 2179 2180 // REMOVE HIDDEN INPUT WITH ICON PATH 2181 jQuery(this).find('.gform_hidden').remove(); 2182 }); 2183 2184 // FIND AND REMOVE HIDDEN DATEPICKER ICON INPUT IF EXISTS 2185 hiddenForm.find('.ginput_container_date').next('.gform_hidden').remove(); 2186 2187 // REMOVE STEPS LINKS AT TOP OF FORM IF EXIST 2188 hiddenForm.find('.gf_page_steps').remove(); 2189 2190 // REMOVE HIDDEN PAGE PROGRESSION INPUT IF EXISTS 2191 hiddenForm.find( "input[name^='gpps_page_progression_']" ).remove(); 2192 2193 // REMOVE ADD/DELETE ROW ICONS IF EXIST 2194 hiddenForm.find('.add_list_item').remove(); 2195 hiddenForm.find('.delete_list_item').remove(); 2196 2197 // REMOVE MULTI-SELECT SELECT OPTIONS ELEMENT 2198 hiddenForm.find('.chosen-drop').remove(); 2199 2200 // LOOP CLONED HIDDEN FORM INPUTS AND GET LABELS => VALUES & FULL HTML VERSION OF FORM 2201 var formFields = []; 2202 var validationErrors = []; 2203 2204 var inputs = jQuery('#' + formMainId + ' :input'); 2205 hiddenFormInputs.each(function() { 2206 var label = form.find('label[for="' + jQuery(this).attr('id') + '"]').text().trim(); 2207 var value = jQuery(this).val(); 2208 var fieldId = jQuery(this).attr('id'); 2209 var fieldSetId; 2210 var fieldName = jQuery(this).attr('name'); 2211 var fieldType = jQuery(this).attr('type'); 2212 var gravityClassEle = jQuery(this).closest('.gfield'); 2213 var gravityClass = gravityClassEle.attr('class'); 2214 defaultBorder = jQuery(this).css('border'); 2215 2216 var locationSelect; 2217 var selectedUserSelect; 2218 var visibleSelect; 2219 var optionText = ''; 2220 var checkboxParentLabel = ''; 2221 var checkboxLabel; 2222 var radioValue = ''; 2223 var checkboxValue = ''; 2224 var fieldValue = ''; 2225 var optionLabel = ''; 2226 var optionValue = ''; 2227 var checkRadioEmpty = false; 2228 var required = false; 2229 2230 // ENSURE FIELD ID IS SET, SEEMS TO BE AN ISSUE FOR LIST FIELDS - ADDED 9/15/25 2231 if(!fieldId || fieldId === '') { 2232 const fieldIdFound = jQuery(this).closest('.gfield').attr('id'); 2233 2234 if(fieldIdFound) { 2235 fieldId = fieldIdFound; 2236 } 2237 } 2238 2239 // SET IF FIELD IS VISIBLE (TRUE/FALSE) 2240 var visibleFormField = form.find('#' + fieldId); 2241 var isVisible = visibleFormField.is(':visible'); 2242 // FOLLOWING IS NEEDED FOR NEW GRAVITY ORBITAL THEME USING CONDITIONAL LOGIC ATTRIBUTE 2243 if(visibleFormField.attr('data-conditional-logic') === 'hidden') { 2244 console.log('Original = ' + isVisible); 2245 isVisible = false; 2246 console.log('Conditional Logic = ' + isVisible); 2247 } 2248 2249 var isDisabled = jQuery(this).prop('disabled'); 2250 var message = ''; 2251 2252 // SET IF ADVANCED FIELD 2253 var isAdvancedField = false; 2254 var isAdvancedList = false; 2255 if(jQuery(this).closest('.ginput_container').hasClass('ginput_complex') || jQuery(this).closest('.ginput_container').hasClass('ginput_container_list')) { 2256 isAdvancedField = true; 2257 // SET FIELDSET ID IF NEW FORMAT & NOT LEGACY MARKUP 2258 if(newFormat === true && legacyMarkup === false) { 2259 fieldSetId = jQuery(this).closest('fieldset').attr('id'); 2260 2261 // SET FIELD ID OF EACH INPUT ELEMENT 2262 let currentItem = jQuery(this); 2263 jQuery('.gfield_list input').each(function(index) { 2264 if(jQuery(this).attr('aria-label') === currentItem.attr('aria-label')) { 2265 fieldId = fieldSetId + '_' + index; 2266 return false; 2267 } 2268 }); 2269 2270 // SET IF ADVANCED FIELD IS VISIBLE 2271 let visibleFormFieldSet = form.find('#' + fieldSetId); 2272 isVisible = visibleFormFieldSet.is(':visible'); 2273 // FOLLOWING IS NEEDED FOR NEW GRAVITY ORBITAL THEME USING CONDITIONAL LOGIC ATTRIBUTE 2274 if(visibleFormFieldSet.attr('data-conditional-logic') === 'hidden') { 2275 console.log('Original Field Set = ' + isVisible); 2276 isVisible = false; 2277 console.log('Field Set Conditional Logic = ' + isVisible); 2278 } 2279 } 2280 2281 // IF ADVANCED LIST ITEM 2282 if(jQuery(this).closest('.ginput_container').hasClass('ginput_container_list')) { 2283 isAdvancedList = true; 2284 2285 // TODO: SET FIELD ID OF EACH INPUT ELEMENT ON LEGACY MARKUP (MAYBE IMPOSSIBLE) 2286 } 2287 2288 2289 } 2290 2291 // IGNORE GRAVITY SPECIFIC HIDDEN FIELDS NOT NEEDED TO SHOW ON FORM 2292 if(fieldName !== 'is_submit_10' && fieldName !== 'gform_submit' && fieldName !== 'gform_unique_id' && fieldName !== 'state_10' && fieldName !== 'gform_target_page_number_10' && fieldName !== 'gform_source_page_number_10' && fieldName !== 'gform_field_values' && !jQuery(this).hasClass('gforms-pum') && !(jQuery(this).hasClass('gform_hidden') && jQuery(this).parent().hasClass('ginput_container_
2292consent'))) { 2293 // TODO: ADDING THIS TO THE END OF THE ABOVE IF STATEMENT BREAKS ADVANCED ADDRESS FIELDS ON >2.5 && !jQuery(this).hasClass('gform_hidden') 2294 // TODO: ABOVE WAS ADDED TO TRY AND REMOVE REDUNDANT LABEL/VALUE FOR "I AGREE" CHECKBOX FIELD, NEED TO TRY AND CHECK PARENT ELE FOR CLASS GINPUT_CONTAINER_CONSENT FIRST 2295 2296 // GET REQUIRED GRAVITY FIELDS 2297 if (gravityClassEle.hasClass('hipaa_forms_office_location')) { 2298 // SET LOCATION VALUES 2299 locationSelect = form.find('#' + fieldId); 2300 location = locationSelect.find('option:selected').text(); 2301 locationEmail = locationSelect.val(); 2302 } else if (gravityClassEle.hasClass('hipaa_forms_first_name') && jQuery(this).val()) { 2303 firstName = jQuery(this).val(); 2304 } else if (gravityClassEle.hasClass('hipaa_forms_last_name') && jQuery(this).val()) { 2305 lastName = jQuery(this).val(); 2306 } else if (gravityClassEle.hasClass('hipaa_forms_name')) { 2307 if (jQuery(this).parent().hasClass('name_first') && jQuery(this).val()) { 2308 firstName = jQuery(this).val(); 2309 } else if (jQuery(this).parent().hasClass('name_last') && jQuery(this).val()) { 2310 lastName = jQuery(this).val(); 2311 } 2312 } else if (gravityClassEle.hasClass('hipaa_forms_email')) { 2313 email = jQuery(this).val(); 2314 } else if (gravityClassEle.hasClass('hipaa_forms_phone')) { 2315 phone = jQuery(this).val(); 2316 } else if (selectedUserSlug && gravityClassEle.hasClass(selectedUserSlug)) { 2317 selectedUserSelect = form.find('#' + fieldId); 2318 selectedUser = selectedUserSelect.val(); 2319 } 2320 2321 if (!fieldType) { 2322 if (jQuery(this).is('select')) { 2323 fieldType = 'select'; 2324 visibleSelect = form.find('#' + fieldId); 2325 optionText = visibleSelect.find('option:selected').text(); 2326 value = visibleSelect.val(); 2327 fieldValue = value; 2328 } else if (jQuery(this).is('textarea')) { 2329 fieldType = 'textarea'; 2330 var visibleTextArea = form.find('#' + fieldId); 2331 value = visibleTextArea.attr('value'); 2332 fieldValue = value; 2333 // TRY THE VALUE ATTR FIRST AND IF NO VALUE TRY NORMAL JQUERY VAL(), NOT SURE WHY ONE WORKS OVER THE OTHER SOMETIMES 2334 if (!value || value === 'undefined') { 2335 value = visibleTextArea.val(); 2336 fieldValue = value; 2337 } 2338 } 2339 } 2340 // IF CHECKBOX OR RADIO SET OPTIONS 2341 var cbOptionsWrapper; 2342 var checkOrRadio = false; 2343 var cbOptionChecked; 2344 if (fieldType === 'checkbox' || fieldType === 'radio') { 2345 checkOrRadio = true; 2346 cbOptionsWrapperId = gravityClassEle.attr('id'); 2347 cbOptionsWrapper = form.find('#' + cbOptionsWrapperId); 2348 cbOptionChecked = form.find('#' + fieldId).prop('checked'); 2349 } 2350 2351 // CHECK IF FIELD IS FILE UPLOAD & SET AS HIDDEN INPUT VALUE (SAFARI REQUIRED FIELD FIX) 2352 if (fieldType === 'file') { 2353 value = form.find('#' + fieldId).val().replace(/C:\\fakepath\\/i, ''); 2354 if (!label) { 2355 label = 'File Upload'; 2356 } 2357 } 2358 2359 // CHECK IF FIELD IS A NUMBER FIELD WITH MIN AND/OR MAX 2360 if (fieldType === 'number') { 2361 var val = jQuery(this).val(); 2362 var num = parseFloat(val); 2363 if (val !== '') { 2364 if (jQuery.isNumeric(num)) { 2365 var min = parseFloat(jQuery(this).attr('min')); 2366 var max = parseFloat(jQuery(this).attr('max')); 2367 if (jQuery.isNumeric(min) && jQuery.isNumeric(max)) { 2368 if ((Math.round(num * 100000) < Math.round(min * 100000)) || (Math.round(max * 100000) < Math.round(num * 100000))) { 2369 validationErrors.push({ 2370 'fieldId': fieldId, 2371 'label': label, 2372 'name': fieldName, 2373 'visible': isVisible, 2374 'message': 'The number must be between ' + min + ' and ' + max 2375 }); 2376 } 2377 } else if (jQuery.isNumeric(max)) { 2378 if (Math.round(max * 100000) < Math.round(num * 100000)) { 2379 validationErrors.push({ 2380 'fieldId': fieldId, 2381 'label': label, 2382 'name': fieldName, 2383 'visible': isVisible, 2384 'message': 'The number must be less than or equal to ' + max 2385 }); 2386 } 2387 } else if (jQuery.isNumeric(min)) { 2388 if (Math.round(num * 100000) < Math.round(min * 100000)) { 2389 validationErrors.push({ 2390 'fieldId': fieldId, 2391 'label': label, 2392 'name': fieldName, 2393 'visible': isVisible, 2394 'message': 'The number must be greater than or equal to ' + min 2395 }); 2396 } 2397 } 2398 } else { 2399 validationErrors.push({ 2400 'fieldId': fieldId, 2401 'label': label, 2402 'name': fieldName, 2403 'visible': isVisible, 2404 'message': 'You must enter a number' 2405 }); 2406 } 2407 } 2408 2409 } 2410 2411 // CHECK IF FIELD IS AN EMAIL AND FORMATTED CORRECTLY 2412 if (fieldType === 'email'){ 2413 var emailVal = jQuery(this).val(); 2414 // pattern taken form https://emailregex.com/ 2415 var emailReg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 2416 if ( emailVal !== '' ) { 2417 if(!emailReg.test( emailVal ) ){ 2418 validationErrors.push({ 2419 'fieldId': fieldId, 2420 'label': label, 2421 'name': fieldName, 2422 'visible': isVisible, 2423 'message': 'The email address entered is invali
2423d, please check the formatting (e.g. [email protected])', 2424 }); 2425 } 2426 } 2427 } 2428 2429 // SET IF FIELD IS REQUIRED 2430 if (isDisabled !== true && isVisible === true && (jQuery(this).attr('required') === 'true' || jQuery(this).attr('aria-required') === 'true' || gravityClassEle.hasClass('gfield_contains_required') === 'true' && checkOrRadio !== true && !jQuery(this).parent().hasClass('address_line_2'))) { 2431 required = true; 2432 jQuery(this).attr('required'); 2433 } else if (isAdvancedField) { 2434 if (isAdvancedList && jQuery(this).attr('aria-required') === 'true' && isVisible === true) { 2435 required = true; 2436 jQuery(this).attr('required'); 2437 fieldId = (jQuery(this).closest('fieldset.gfield_contains_required').attr('id')); 2438 jQuery(this).attr('id', fieldId + '_' + jQuery(this).attr('aria-label')); 2439 } 2440 } 2441 2442 // GET REQUIRED FIELDS THAT DO NOT HAVE A VALUE 2443 if (required && (!value || value == "") || isDisabled !== true && isVisible === true && checkOrRadio === true && cbOptionsWrapper.hasClass('gfield_contains_required') && cbOptionChecked === false) { 2444 // MAKE SURE OBJECT DOES NOT ALREADY EXIST, CLEARING ARRAY ABOVE DOESN'T SEEM TO WORK HERE 2445 var errorFound; 2446 var cbIgnore; 2447 2448 // IF CHECKBOX SPLIT NAME AT PERIOD FOR CONSISTENCY 2449 if (fieldType === 'checkbox' && !jQuery(this).parent().hasClass('gchoice_select_all')) { 2450 fieldName = fieldName.split('.')[0]; 2451 } 2452 2453 // IF CHECKBOX OR RADIO, GROUP OPTIONS & ENSURE ONE IS CHECKED 2454 if (cbOptionsWrapper) { 2455 var cbOptions = cbOptionsWrapper.find('input'); 2456 cbOptions.each(function () { 2457 if (jQuery(this).prop('checked')) { 2458 cbIgnore = true; 2459 2460 return false; 2461 } 2462 }); 2463 } 2464 2465 if (validationErrors.length > 0) { 2466 validationErrors.some(function (el) { 2467 // CHECK IF ERROR ALREADY EXISTS IN VALIDATION ERRORS ARRAY 2468 if (el.fieldId === fieldId || el.name === fieldName) { 2469 errorFound = true; 2470 } 2471 }); 2472 } 2473 2474 if (!errorFound && !cbIgnore && !jQuery(this).parent().hasClass('name_prefix_select') && !jQuery(this).parent().hasClass('name_suffix') && !jQuery(this).parent().hasClass('ginput_address_line_2')) { 2475 validationErrors.push({ 2476 'fieldId': fieldId, 2477 'label': label, 2478 'name': fieldName, 2479 'visible': isVisible, 2480 'message': message 2481 }); 2482 } 2483 } 2484 2485 // SET CHECKBOX OR RADIO FIELD LABEL AND INPUT LABEL 2486 if (fieldType === 'checkbox' || fieldType === 'radio') { 2487 if (jQuery(this).prop('checked') === true) { 2488 checkboxLabel = jQuery(this).parent().find('label').text().trim(); 2489 2490 if (jQuery(this).hasClass('cm-hipaa-forms-privacy-agree')) { 2491 label = 'Privacy Agreement'; 2492 } else { 2493 label = cbOptionsWrapper.find('.gfield_label').text().trim(); 2494 } 2495 2496 checkboxParentLabel = label; 2497 optionLabel = checkboxLabel; 2498 optionValue = value; 2499 } 2500 2501 // GET CHECKBOXES OR RADIOS WITHIN GROUP 2502 //var advancedFields = gravityClassEle.find('input, select'); 2503 //var lastAdvancedFieldId = gravityClassEle.find('input
2503:last', 'select:last').attr('id'); 2504 } 2505 2506 // REPLACE HIDDEN HTML VERSION INPUTS WITH VALUES 2507 if (isAdvancedField === true) { 2508 if (newFormat === true && legacyMarkup === false) { 2509 /* NEW 2.5+ FORMAT STUFF HERE */ 2510 // GET INPUT AND SELECT ELEMENTS IN FIELD 2511 var advancedFields = gravityClassEle.find('input, select'); 2512 var lastAdvancedFieldId = ''; 2513 var lastAdvancedListField = ''; 2514 if (isAdvancedList === true) { 2515 lastAdvancedListField = advancedFields.filter(':last'); 2516 } else { 2517 lastAdvancedFieldId = advancedFields.filter(':last').attr('id'); 2518 } 2519 // LOOP FIELDS IF THIS IS THE LAST ADVANCED FIELD 2520 if (fieldId === lastAdvancedFieldId || isAdvancedList === true && jQuery(this).is(lastAdvancedListField)) { 2521 // LOOP FIELDS 2522 var advancedFieldValues = []; 2523 var advancedFieldHTML = []; 2524 advancedFields.each(function (index) { 2525 var advancedFieldClass = jQuery(this).parent().attr('class'); 2526 var listGroupsWrapper; 2527 var listRows; 2528 var listRow; 2529 var firstListRow; 2530 var lastListRow; 2531 var listRowFields; 2532 var listCell; 2533 var firstListCell; 2534 var lastListCell; 2535 var listCellLabel; 2536 2537 if (isAdvancedList === true) { 2538 listGroupsWrapper = jQuery(this).closest('.gfield_list_groups'); 2539 listRows = listGroupsWrapper.find('.gfield_list_group'); 2540 listRow = jQuery(this).closest('.gfield_list_group'); 2541 firstListRow = listRows.filter(':first'); 2542 lastListRow = listRows.filter(':last'); 2543 listRowFields = listRow.find('input, select'); 2544 listCell = jQuery(this).closest('.gfield_list_group_item'); 2545 firstListCell = listRowFields.filter(':first'); 2546 lastListCell = listRowFields.filter(':last'); 2547 //listCellLabel = jQuery(this).parent().attr('data-label'); 2548 listCellLabel = jQuery(this).attr('aria-label'); 2549 } 2550 2551 if (jQuery(this).is('select') && isAdvancedList !== true) { 2552 visibleSelect = form.find('#' + jQuery(this).attr('id')); 2553 optionText = visibleSelect.find('option:selected').text(); 2554 2555 advancedFieldHTML.push('<span class="' + advancedFieldClass + '">' + optionText + '</span> '); 2556 advancedFieldValues.push(optionText); 2557 } else { 2558 if (isAdvancedList === true && jQuery(this).is(firstListCell)) { 2559 // if (listRow.is(firstListRow)) { 2560 // //advancedFieldHTML.push('<table class="' + listTable.attr('class') + '">' + listTableHead.html()); 2561 // } 2562 advancedFieldHTML.push('<div class="' + listRow.attr('class') + '"><div class="' + listCell.attr('class') + '">'); 2563 } 2564 2565 if (isAdvancedList === true) { 2566 var listVal; 2567 if (jQuery(this).is('select')) { 2568 var thisListField = jQuery(this); 2569 var thisFieldName = thisListField.attr('name'); 2570 var thisFieldSelects = hiddenForm.find('select[name="' + thisFieldName + '"]'); 2571 var visibleFieldSelects = form.find('select[name="' + thisFieldName + '"]'); 2572 var listOptionValue; 2573 thisFieldSelects.each(function (index) { 2574 if (jQuery(this).is(thisListField)) { 2575 listOptionValue = visibleFieldSelects.eq(index).val(); 2576 } 2577 }); 2578 2579 if (listCell.attr('data-label')) { 2580 listCellLabel = listCell.attr('data-label'); 2581 } 2582 2583 listVal = listOptionValue; 2584 } else { 2585 listVal = jQuery(this).val(); 2586 } 2587 var inputAttributes = []; 2588 jQuery(this).each(function () { 2589 jQuery.each(this.attributes, function () { 2590 // this.attributes is not a plain object, but an array 2591 // of attribute nodes, which contain both the name and value 2592 if (this.specified) { 2593 inputAttributes.push(this.name + '="' + this.value + '"'); 2594 } 2595 }); 2596 }); 2597 jQuery(this).replaceWith('<span ' + inputAttributes.join(' ') + '>
2597' + listVal + '</span>'); 2598 advancedFieldValues.push(listCellLabel +': ' + listVal); 2599 } else { 2600 advancedFieldHTML.push('<span class="' + advancedFieldClass + '">' + jQuery(this).val() + '</span> '); 2601 advancedFieldValues.push(jQuery(this).val()); 2602 } 2603 2604 if (isAdvancedList === true && jQuery(this).is(lastListCell)) { 2605 advancedFieldHTML.push('</div>'); 2606 if (index !== advancedFields.length - 1) { 2607 advancedFieldValues.push('|'); 2608 } 2609 } else if (isAdvancedList === true) { 2610 advancedFieldValues.push(' - '); 2611 } 2612 } 2613 2614 if (isAdvancedList === true) { 2615 value = advancedFieldHTML.join(''); 2616 } else { 2617 value = '<div class="' + jQuery(this).closest('div.ginput_complex').attr('class') + '" id="' + jQuery(this).closest('div.ginput_complex').attr('id') + '">' + advancedFieldHTML.join('') + '</div>'; 2618 } 2619 2620 fieldValue = advancedFieldValues.join(' '); 2621 label = gravityClassEle.find('.gfield_label_before_complex').text(); 2622 // ADD FIX FOR ADVANCED LIST NOT GETTING LABEL 2623 if (!label) { 2624 label = gravityClassEle.find('.label').text(); 2625 } 2626 if (!label){ 2627 label = gravityClassEle.find('.gfield_label').text(); 2628 } 2629 }); 2630 } else { 2631 value = ''; 2632 fieldValue = ''; 2633 label = ''; 2634 } 2635 2636 if (value && isAdvancedList !== true) { 2637 gravityClassEle.html('<label class="gfield_label gfield_label_before_complex">' + label + '</label>' + value); 2638 fieldId = gravityClassEle.attr('id'); 2639 fieldType = 'advanced'; 2640 } 2641 } else { 2642 /* PRE-2.5 & LEGACY FORMS ADVANCED FIELDS */ 2643 // GET INPUT AND SELECT ELEMENTS IN FIELD 2644 var advancedFields = gravityClassEle.find('input, select'); 2645 var lastAdvancedFieldId = ''; 2646 var lastAdvancedListField = ''; 2647 2648 if (isAdvancedList === true) { 2649 lastAdvancedListField = advancedFields.filter(':last'); 2650 } else { 2651 lastAdvancedFieldId = advancedFields.filter(':last').attr('id'); 2652 } 2653 2654 // LOOP FIELDS IF THIS IS THE LAST ADVANCED FIELD 2655 if (fieldId === lastAdvancedFieldId || isAdvancedList === true && jQuery(this).is(lastAdvancedListField)) { 2656 var listTable; 2657 var listTableHead; 2658 if (isAdvancedList === true) { 2659 listTable = jQuery(this).closest('table'); 2660 listTableHead = listTable.find('thead'); 2661 } 2662 2663 // LOOP FIELDS 2664 var advancedFieldValues = []; 2665 var advancedFieldHTML = []; 2666 advancedFields.each(function (index) { 2667 var advancedFieldClass = jQuery(this).parent().attr('class'); 2668 var listRow; 2669 var firstListRow; 2670 var lastListRow; 2671 var listRowFields; 2672 var listCell; 2673 var firstListCell; 2674 var lastListCell; 2675 var listCellLabel; 2676 2677 if (isAdvancedList === true) { 2678 listRow = jQuery(this).closest('tr'); 2679 firstListRow = jQuery(this).closest('table').find('tr').filter(':first'); 2680 lastListRow = jQuery(this).closest('table').find('tr').filter(':last'); 2681 listRowFields = listRow.find('input, select'); 2682 listCell = jQuery(this).closest('td'); 2683 firstListCell = listRowFields.filter(':first'); 2684 lastListCell = listRowFields.filter(':last'); 2685 listCellLabel = jQuery(this).attr('aria-label'); 2686 } 2687 2688 if (jQuery(this).is('select') && isAdvancedList !== true) { 2689 visibleSelect = form.find('#' + jQuery(this).attr('id')); 2690 optionText = visibleSelect.find('option:selected').text(); 2691 2692 advancedFieldHTML.push('<span class="' + advancedFieldClass + '">
2692' + optionText + '</span> '); 2693 advancedFieldValues.push(optionText); 2694 } else { 2695 if (isAdvancedList === true && jQuery(this).is(firstListCell)) { 2696 if (listRow.is(firstListRow)) { 2697 //advancedFieldHTML.push('<table class="' + listTable.attr('class') + '">' + listTableHead.html()); 2698 } 2699 2700 advancedFieldHTML.push('<tr class="' + listRow.attr('class') + '">'); 2701 } 2702 2703 if (isAdvancedList === true) { 2704 var listVal; 2705 if (jQuery(this).is('select')) { 2706 var thisListField = jQuery(this); 2707 var thisFieldName = thisListField.attr('name'); 2708 var thisFieldSelects = hiddenForm.find('select[name="' + thisFieldName + '"]'); 2709 var visibleFieldSelects = form.find('select[name="' + thisFieldName + '"]'); 2710 var listOptionValue; 2711 thisFieldSelects.each(function (index) { 2712 if (jQuery(this).is(thisListField)) { 2713 listOptionValue = visibleFieldSelects.eq(index).val(); 2714 } 2715 }); 2716 2717 if (jQuery(this).closest('td').attr('data-label')) { 2718 listCellLabel = jQuery(this).closest('td').attr('data-label'); 2719 } 2720 2721 listVal = listOptionValue; 2722 } else { 2723 listVal = jQuery(this).val(); 2724 } 2725 2726 advancedFieldHTML.push('<td class="' + listCell.attr('class') + '">' + listVal + '</td>'); 2727 advancedFieldValues.push(listCellLabel + ': ' + listVal); 2728 } else { 2729 advancedFieldHTML.push('<span class="' + advancedFieldClass + '">' + jQuery(this).val() + '</span> '); 2730 advancedFieldValues.push(jQuery(this).val()); 2731 } 2732 2733 if (isAdvancedList === true && jQuery(this).is(lastListCell)) { 2734 advancedFieldHTML.push('</tr>'); 2735 2736 if (listRow.is(lastListRow)) { 2737 //advancedFieldHTML.push('</table>'); 2738 } 2739 2740 if (index !== advancedFields.length - 1) { 2741 advancedFieldValues.push('|'); 2742 } 2743 } else if (isAdvancedList === true) { 2744 advancedFieldValues.push(' - '); 2745 } 2746 } 2747 2748 if (isAdvancedList === true) { 2749 var listTableHeadHtml = ''; 2750 if (listTableHead.html()) { 2751 listTableHeadHtml = listTableHead.html(); 2752 } 2753 2754 value = '<table class="' + jQuery(this).closest('table').attr('class') + '"><thead>' + listTableHeadHtml + '</thead>' + advancedFieldHTML.join('') + '</table>'; 2755 } else { 2756 value = '<div class="' + jQuery(this).closest('div.ginput_complex').attr('class') + '" id="' + jQuery(this).closest('div.ginput_complex').attr('id') + '">' + advancedFieldHTML.join('') + '</div>'; 2757 } 2758 2759 fieldValue = advancedFieldValues.join(' '); 2760 label = gravityClassEle.find('.gfield_label_before_complex').text(); 2761 2762 // ADD FIX FOR ADVANCED LIST NOT GETTING LABEL 2763 if (!label) { 2764 label = gravityClassEle.find('label').text(); 2765 } 2766 if (!label){ 2767 label = gravityClassEle.find('.gfield_label').text(); 2768 } 2769 }); 2770 } else { 2771 value = ''; 2772 fieldValue = ''; 2773 label = ''; 2774 } 2775 2776 if (value) { 2777 gravityClassEle.html('<label class="gfield_label gfield_label_before_complex">' + label + '</label>' + value); 2778 fieldId = gravityClassEle.attr('id'); 2779 fieldType = 'advanced'; 2780 } 2781 } 2782 } else if (fieldType === 'select') { 2783 // IF VALUE IS OBJECT ARRAY LIKE FROM MULTISELECT, JOIN VALUES TO STRING 2784 if (Array.isArray(value)) { 2785 fieldValue = value.join(';'); 2786 value = value.join('<br />'); 2787 jQuery(this).replaceWith(value); 2788 } else if (jQuery(this).closest('.ginput_container_date').is('[class*="gfield_date_dropdown"]')){ 2789 var fieldsetElm; 2790 var parentElm; 2791 if (newFormat === true && legacyMarkup === false){ 2792 fieldsetElm = jQuery(this).closest('fieldset'); 2793 fieldSetId = fieldsetElm.attr('id'); 2794 parentElm = jQuery(this).parent(); 2795 }else{ 2796 fieldsetElm = jQuery(this).closest('li.gf
2796ield'); 2797 fieldSetId = fieldsetElm.attr('id'); 2798 parentElm = jQuery(this).parent().parent(); 2799 } 2800 2801 var dateSelect1 = form.find('#' + fieldSetId).find('select:eq(0)').attr('id'); 2802 var dateSelect2 = form.find('#' + fieldSetId).find('select:eq(1)').attr('id'); 2803 var dateSelect3 = form.find('#' + fieldSetId).find('select:eq(2)').attr('id'); 2804 var dateValue1 = form.find('#'+dateSelect1+' option:selected').text(); 2805 var dateValue2 = form.find('#'+dateSelect2+' option:selected').text(); 2806 var dateValue3 = form.find('#'+dateSelect3+' option:selected').text(); 2807 2808 if (jQuery(this).attr('id') === dateSelect1){ 2809 if (dateValue1 && dateValue1 !== '' && dateValue1 !== 'Month' && dateValue1 !== 'Day' && dateValue1 !== 'Year') { 2810 value = dateValue1 + '<span class="dateseparator">\/</span>' + dateValue2 + '<span class="dateseparator">\/</span>' + dateValue3; 2811 parentElm.replaceWith(value); 2812 fieldId = fieldSetId; 2813 fieldValue = dateValue1 + '/' + dateValue2 + '/' + dateValue3; 2814 optionText = ''; 2815 label = fieldsetElm.find('.gfield_label').text(); 2816 }else{ 2817 label = fieldsetElm.find('.gfield_label').text(); 2818 jQuery(this).replaceWith(''); 2819 } 2820 }else{ 2821 label = ''; 2822 jQuery(this).replaceWith(''); 2823 } 2824 } else { 2825 jQuery(this).replaceWith(optionText); 2826 } 2827 } else if (fieldType === 'checkbox') { 2828 // SET CHECKBOX VALUE IF DIFFERENT THAN LABEL 2829 if (value !== checkboxLabel && !jQuery(this).parent().hasClass('ginput_container_consent')) { 2830 checkboxValue = value; 2831 } 2832 2833 if (jQuery(this).prop('checked') === true) { 2834 // SET CHECKED CHECKBOX IMAGE AND VALUE 2835 value = '<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/checkbox.png" alt="Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" />' + checkboxValue + '</span>'; 2836 // ADD CHECKED WRAPPER CLASS TO PARENT ELEMENT 2837 jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-checked-wrapper'); 2838 if (checkboxParentLabel) { 2839 fieldValue = 'checked'; 2840 } 2841 } else { 2842 // SET UNCHECKED CHECKBOX IMAGE AND VALUE 2843 value = '<span class="cm-hipaa-forms-checkbox-value cm-hipaa-forms-checkbox-not-checked"><img src="https://www.hipaaforms.online/api-assets/checkbox-unchecked.png" alt="Not Checked" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>'; 2844 jQuery(this).parent().addClass('cm-hipaa-forms-checkbox-not-checked-wrapper'); 2845 } 2846 2847 // ADD VALUE 2848 jQuery(this).replaceWith(value); 2849 } else if (fieldType === 'radio') { 2850 // SET RADIO VALUE IF DIFFERENT THAN LABEL 2851 if (value !== checkboxLabel) { 2852 radioValue = value; 2853 } 2854 2855 if (jQuery(this).prop('checked') === true) { 2856 // SET CHECKED RADIO BUTTON IMAGE AND VALUE 2857 value = '<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-checked" style="background: #f7f5a091;"><img src="https://www.hipaaforms.online/api-assets/radio-checked.png" alt="Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" />' + radioValue + '</span>'; 2858 jQuery(this).parent().addClass('cm-hipaa-forms-radio-checked-wrapper'); 2859 2860 if (checkboxParentLabel) { 2861 fieldValue = 'checked'; 2862 } 2863 } else { 2864 // SET UNCHECKED RADIO BUTTON IMAGE AND VALUE 2865 value = '<span class="cm-hipaa-forms-radio-value cm-hipaa-forms-radio-not-checked"><img src="https://www.hipaaforms.online/api-assets/radio-unchecked.png" alt="Not Selected" style="height: 16px; padding-right: 5px; vertical-align: middle;" /></span>'; 2866 jQuery(this).parent().addClass('cm-hipaa-forms-radio-not-checked-wrapper'); 2867 } 2868 jQuery(this).replaceWith(value); 2869 } else if (fieldType === 'url') { 2870 var rawUrl = jQuery(this).val(); 2871 var formatedUrl = ''; 2872 2873 if (rawUrl.indexOf("http://") === 0){ 2874 formatedUrl = rawUrl.replace('http://','https://'); 2875 }else if(rawUrl.indexOf("https://") === 0){ 2876 formatedUrl = rawUrl; 2877 }else{ 2878 formatedUrl = 'https://'+rawUrl; 2879 } 2880 value = '<span class="cm-hipaa-forms-url-value"><a target="_blank" href="' + formatedUrl + '">' + formatedUrl + '</a></span>'; 2881 fieldValue = formatedUrl; 2882 jQuery(this).replaceWith(value); 2883 }else if(jQuery(this).parent().hasClass('ginput_container_time')) { 2884 if (jQuery(this).parent().hasClass('gfield_time_hour')) { 2885 var name = jQuery(this).attr('name'); 2886 var hours = jQuery(this).val(); 2887 var minutes = jQuery('.gfield_time_minute input[name="' + name + '"]').val(); 2888 var ampm = jQuery('.gfield_time_ampm select[name="' + name + '"]').val(); 2889 if(hours && hours !== '') { 2890 if (parseInt(minutes) < 10) { 2891 minutes = '0' + minutes; 2892 } 2893 if (ampm) { 2894 fieldValue = hours + ':' + minutes + ' ' + ampm; 2895 } else { 2896 fieldValue = hours + ':' + minutes; 2897 } 2898 }else{ 2899 fieldValue = ''; 2900 } 2901 label = jQuery(this).closest('fieldset').find('.gfield_label').text(); 2902 fieldId = jQuery(this).closest('.gfield_time_hour').attr('id'); 2903 jQuery(this).closest('.ginput_complex').replaceWith('<div class="ginput_container ginput_container_time" id="' + fieldId + '">' + fieldValue + '</div>'); 2904 } else { 2905 label = false; 2906 } 2907 }else if (jQuery(this).closest('.ginput_container_date').is('[class*="gfield_date"]')) { 2908 var dateFieldsetElm; 2909 var dateFieldsetId; 2910 var parentElm; 2911 if (newFormat === true && legacyMarkup === false) { 2912 dateFieldsetElm = jQuery(this).closest('fieldset'); 2913 dateFieldsetId = dateFieldsetElm.attr('id'); 2914 parentElm = jQuery(this).parent(); 2915 } else { 2916 dateFieldsetElm = jQuery(this).closest('li.gf
2916ield'); 2917 dateFieldsetId = dateFieldsetElm.attr('id'); 2918 parentElm = jQuery(this).parent().parent(); 2919 } 2920 var dateField1 = form.find('#' + dateFieldsetId).find('.ginput_container_date:eq(0) input'); 2921 var dateField2 = form.find('#' + dateFieldsetId).find('.ginput_container_date:eq(1) input'); 2922 var dateField3 = form.find('#' + dateFieldsetId).find('.ginput_container_date:eq(2) input'); 2923 var dateFieldValue1 = jQuery(dateField1).val(); 2924 var dateFieldValue2 = jQuery(dateField2).val(); 2925 var dateFieldValue3 = jQuery(dateField3).val(); 2926 2927 if (jQuery(this).attr('id') === jQuery(dateField1).attr('id')) { 2928 if (dateFieldValue1 && dateFieldValue1 !== '' && dateFieldValue1 !== 'Month' && dateFieldValue1 !== 'Day' && dateFieldValue1 !== 'Year') { 2929 value = dateFieldValue1 + '<span class="dateseparator">\/</span>' + dateFieldValue2 + '<span class="dateseparator">\/</span>' + dateFieldValue3; 2930 parentElm.replaceWith(value); 2931 fieldValue = dateFieldValue1 + '/' + dateFieldValue2 + '/' + dateFieldValue3; 2932 label = dateFieldsetElm.find('.gfield_label').text(); 2933 optionText = ''; 2934 }else { 2935 label = dateFieldsetElm.find('.gfield_label').text(); 2936 jQuery(this).replaceWith(''); 2937 } 2938 } else { 2939 label = ''; 2940 jQuery(this).replaceWith(''); 2941 } 2942 } else { 2943 jQuery(this).replaceWith(value); 2944 } 2945 // MAKE SURE VALUES ARE TRIMMED 2946 if(typeof value === 'string' || value instanceof String) { 2947 value = value.trim(); 2948 } 2949 if(typeof fieldValue === 'string' || fieldValue instanceof String) { 2950 fieldValue = fieldValue.trim(); 2951 } 2952 2953 if(!fieldValue && fieldType !== 'checkbox' && fieldType !== 'radio' && fieldType !== 'advanced' && fieldType !== 'url') { 2954 fieldValue = value; 2955 } 2956 2957 // ADD CUSTOM CLASS TO IDENTIFY IF FIELD VALUE IS EMPTY OR NOT 2958 if(gravityClassEle.hasClass('cm_hipaa_forms_field_not_empty') === false && (!fieldValue || fieldValue.length === 0)) { 2959 gravityClassEle.addClass('cm_hipaa_forms_field_empty'); 2960 } else { 2961 gravityClassEle.removeClass('cm_hipaa_forms_field_empty'); 2962 gravityClassEle.addClass('cm_hipaa_forms_field_not_empty'); 2963 } 2964 2965 // REMOVED "&& fieldValue" TO START STORING FIELDS WITH EMPTY VALUES 4/2/21 2966 if (label) { 2967 // IF LABEL EXISTS PUSH TO FIELDS ARRAY 2968 formFields.push({ 2969 'label': label, 2970 'option_label': optionLabel, 2971 'option_value': optionValue, 2972 'value': fieldValue, 2973 'field_id': fieldId, 2974 'field_type': fieldType, 2975 'option_text': optionText 2976 }); 2977 } 2978 } 2979 }); 2980 2981 // GET SIGNATURE SVG BASE64 DATA 2982 var signature; 2983 var signatureEle; 2984 var datapair; 2985 if(showSignature === 'yes') { 2986 signatureEle = form.find('.cm-hipaa-form-signature'); 2987 datapair = signatureEle.jSignature("getData", "svgbase64"); 2988 if(datapair) { 2989 signature = "data:" + datapair[0] + "," + datapair[1]; 2990 2991 formFields.push({ 2992 'label': 'Signature', 2993 'option_label': 'data', 2994 'option_value': datapair[0], 2995 'value': datapair[1], 2996 'field_id': '', 2997 'field_type': 'signature', 2998 'option_text': 'ELECTRONICALLY SIGNED ' + new Date().toLocaleStr
2998ing() 2999 }); 3000 } 3001 } 3002 3003 // SET PRIVACY AGREEMENT ELEMENT 3004 var privacyAgreementEle = form.find('.cm-hipaa-forms-privacy-agree'); 3005 3006 // RESET ERRORS 3007 jQuery('.gfield_error').removeClass('gfield_error'); 3008 privacyAgreementEle.parent().css('border', '0'); 3009 if(signatureEle) { 3010 signatureEle.find('.jSignature').css('border', '0'); 3011 } 3012 noticeEle.html(''); 3013 // CLEAR ERRORS 3014 form.find('.gfield_error').removeClass('gfield_error'); 3015 form.find('.validation_error, .validation_message').remove(); 3016 3017 // MULTI-PAGE FORM RENDERING 3018 var gravityFormPages = hiddenForm.find('.gform_page'); 3019 if(gravityFormPages && gravityFormPages.length > 0) { 3020 // REMOVE PROGRESS BAR 3021 hiddenForm.find('.gf_progressbar_wrapper').remove(); 3022 3023 gravityFormPages.each(function(index) { 3024 // MAKE PAGE ELEMENT VISIBLE 3025 jQuery(this).css({ 3026 'display': 'block' 3027 }); 3028 3029 // REMOVE BUTTONS 3030 jQuery(this).find('.gform_page_footer').remove(); 3031 3032 // APPEND PAGE BREAK TO END OF PAGE FOR MPDF IF NOT LAST ELEMENT 3033 if(index !== (gravityFormPages.length - 1)) { 3034 jQuery(this).append('<pagebreak />'); 3035 } 3036 }); 3037 } 3038 3039 var nonce = cmHipaaScript.nonce; 3040 var honeyPotInput = form.find('.cm-hipaa-required-extra'); 3041 var honeyPot; 3042 3043 if(honeyPotInput) { 3044 honeyPot = honeyPotInput.val(); 3045 } 3046 3047 if(honeyPot) { 3048 //console.log(honeyPot); 3049 // REMOVE HIDDEN FORM 3050 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3051 3052 // ADD NOTICE MESSAGE 3053 noticeEle.html('<div><img src="https://media1.tenor.com/images/4945d2cd26ab7d38a6dce346a9c866e7/tenor.gif?itemid=14825791" alt="Angry Robot Upset GIF - AngryRobot Upset Furious GIFs" style="max-width: 250px;"></div><div>Oops, this appears to be an automated bot submission! Please contact [email protected] if this is an error.</div>'); 3054 3055 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3056 submitButton.removeClass('inactive').addClass('active'); 3057 } else if(!jQuery.isEmptyObject(validationErrors) && validationErrors.length > 0) { 3058 // ADD ERROR MESSAGE TO TOP OF FORM 3059 form.find('.gform_body').before('<div class="validation_error">There was a problem with your submission. Errors have been highlighted below.</div>'); 3060 3061 // VALIDATE FIELDS 3062 jQuery.each(validationErrors, function(key, val) { 3063 let invalidFieldId = val.fieldId; 3064 let invalidFieldInputNumber; 3065 let invalidField = jQuery('#' + invalidFieldId); 3066 3067 // IF INVALID FIELD NOT FOUND IT'S PROBABLY A FIELD SET SO SLICE IT DOWN 3068 if(invalidField.length === 0) { 3069 invalidFieldId = invalidFieldId.slice(0, -2); 3070 3071 // FIND FIRST EMPTY INPUT IN FIELD SET 3072 const invalidFieldSetInputs = jQuery('#' + invalidFieldId + ' input'); 3073 jQuery.each(invalidFieldSetInputs, function(inputKey, inputVal) { 3074 const invalidValue = jQuery('#' + invalidFieldId + ' input').eq(inputKey).val(); 3075 if(!invalidValue || invalidValue === '') { 3076 invalidFieldInputNumber = inputKey; 3077 return false; // BREAK LOOP 3078 } 3079 }); 3080 3081 // SET INVALID FIELD 3082 invalidField = jQuery('#' + invalidFieldId + ' input:eq(' + invalidFieldInputNumber + ')'); 3083 } 3084 3085 var invalidFieldType = invalidField.attr('type'); 3086 var requiredMessage = val.message; 3087 3088 if(requiredMessage.length < 1){ 3089 if(invalidField.closest('li').hasClass('hipaa_forms_office_location') && !locationEmail) { 3090 requiredMessage = 'Location select options must have a value! This should be an email address for the person at the specific location that should receive the form submission notice.'; 3091 } else { 3092 requiredMessage = 'This field is required.'; 3093 } 3094 } 3095 3096 3097 // ADD ERROR CLASS & NOTICE MESSAGE 3098 let invalidFieldWrapper; 3099 if(newFormat === true && legacyMarkup === false) { 3100 /* NEW FORMAT VALIDATION */ 3101 // SET INVALID FIELD WRAPPER 3102 if(invalidFieldInputNumber) { 3103 invalidFieldWrapper = invalidField.parent(); 3104 } else { 3105 invalidFieldWrapper = invalidField.closest('.gfield'); 3106 } 3107 3108 // CHECK IF VALIDATION ERROR ALREADY EXISTS
3109 var existingValidationMessage = invalidFieldWrapper.find('.validation_message'); 3110 3111 if(existingValidationMessage.length === 0) { 3112 // IF NO VALIDATION MESSAGE EXISTS ADD THE MESSAGE 3113 invalidFieldWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">' + requiredMessage + '</div>'); 3114 } 3115 } else { 3116 /* PRE-2.5 & LEGACY FORMS */ 3117 if(invalidFieldType === 'checkbox' || invalidFieldType === 'radio') { 3118 invalidFieldWrapper = invalidField.parent().parent().parent().parent(); 3119 invalidFieldWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">' + requiredMessage + '</div>'); 3120 } else { 3121 invalidFieldWrapper = invalidField.closest('li'); 3122 invalidFieldWrapper.addClass('gfield_error').append('<div class="gfield_description validation_message">' + requiredMessage + '</div>'); 3123 } 3124 } 3125 }); 3126 3127 // REMOVE HIDDEN FORM 3128 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3129 // SCROLL TO FIRST INVALID FIELD 3130 if (jQuery('#' + validationErrors[0].fieldId).length){ 3131 jQuery('html, body').animate({ 3132 scrollTop: jQuery('#' + validationErrors[0].fieldId).offset().top-125 3133 }, 500, 'linear'); 3134 }else{ 3135 jQuery('html, body').animate({ 3136 scrollTop: jQuery('#' + formId).offset().top-125 3137 }, 500, 'linear'); 3138 } 3139 3140 3141 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3142 submitButton.removeClass('inactive').addClass('active'); 3143 } else if(privacyAgreementEle.prop('checked') !== true) { 3144 // ADD RED BORDER TO PRIVACY FIELD 3145 privacyAgreementEle.parent().css('border', '1px solid red'); 3146 3147 // UPDATE NOTICE ELEMENT 3148 noticeEle.html('You must agree to the HIPAA Privacy Agreement'); 3149 3150 // REMOVE HIDDEN FORM 3151 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3152 3153 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3154 submitButton.removeClass('inactive').addClass('active'); 3155 } else if(showSignature === 'yes' && !signatureEle.find('.jSignature').hasClass('cm-valid-sig')) { 3156 // ADD RED BORDER TO SIGNATURE FIELD 3157 signatureEle.find('.jSignature').css('border', '1px solid red'); 3158 3159 // UPDATE NOTICE ELEMENT 3160 noticeEle.html('You must sign the form'); 3161 3162 // REMOVE HIDDEN FORM 3163 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3164 3165 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3166 submitButton.removeClass('inactive').addClass('active'); 3167 } else { 3168 //console.log(formId); 3169 //console.log(formFields); 3170 //console.log(hiddenForm.html()); 3171 /*** VALIDATE ACCOUNT TO GET ENABLED ADD-ONS ***/ 3172 jQuery.ajax({ 3173 method: 'POST', 3174 type: 'POST', 3175 url: cmHipaaScript.ajax_url, 3176 data: { 3177 'action': 'cm_hipaa_validate_account', 3178 'nonce': cmHipaaScript.nonce 3179 }, 3180 success: function (data) { 3181 // REMOVE LOADING ICON 3182 jQuery('.cm-hipaa-forms-loading').remove(); 3183 //var resultData = JSON.parse(data); 3184 var resultData; 3185 try { 3186 resultData = JSON.parse(data); 3187 } catch (e) { 3188 console.log(data); 3189 noticeEle.append(data); 3190 return false; 3191 } 3192 3193 if (resultData.success === 'success') { 3194 // CHECK IF FILE UPLOAD ENABLED
3195 var validatedAddOns = resultData.add_ons; 3196 var validatedAddOnsArray; 3197 if(validatedAddOns) { 3198 validatedAddOnsArray = validatedAddOns.split(','); 3199 } 3200 var fileUploadEnabled = 'no'; 3201 if(Array.isArray(validatedAddOnsArray) && validatedAddOnsArray.indexOf('fileupload') !== -1) { 3202 fileUploadEnabled = 'yes'; 3203 } else if(validatedAddOns === 'fileupload') { 3204 fileUploadEnabled = 'yes'; 3205 } 3206 3207 // IF FILE INPUTS EXIST & FILE UPLOAD ENABLED 3208 if(fileInputs.length > 0 && fileUploadEnabled === 'yes') { 3209 // SHOW LOADING BAR 3210 noticeEle.html('<div class="cm-hipaa-forms-file-upload-status">Uploading Files...</div><div class="cm-hipaa-forms-progress-wrapper"><div class="cm-hipaa-forms-progress"><div class="cm-hipaa-forms-progress-bar"><!-- <div class="cm-hipaa-forms-progress-label">10%</div>--></div></div></div>'); 3211 cmHipaaFormsProgress(); 3212 3213 var fileInputsLength = fileInputs.length; 3214 var iterations = 0; 3215 var fileKeys = []; 3216 3217 fileInputs.each(function(index) { 3218 var fileInputParentId = jQuery(this).parent().parent().attr('id'); 3219 var fileLabel = jQuery(this).parent().parent().find('label').text(); 3220 fileLabel = fileLabel.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '-'); 3221 3222 // GET FILE 3223 var theFormFile = jQuery(this).get()[0].files[0]; 3224 3225 if(theFormFile) { 3226 var fileType = theFormFile.type; 3227 var fileName = index+'_'+theFormFile.name; 3228 3229 // GET PRESIGNED FILE UPLOAD URL 3230 jQuery.ajax({ 3231 method: 'POST', 3232 type: 'POST', 3233 url: cmHipaaScript.ajax_url, 3234 data: { 3235 'action': 'cm_hipaa_get_file_upload_url', 3236 'file_name': fileName, 3237 'nonce': cmHipaaScript.nonce 3238 }, 3239 success: function (data) { 3240 //var resultData = JSON.parse(data); 3241 var resultData; 3242 try { 3243 resultData = JSON.parse(data); 3244 } catch (e) { 3245 console.log(data); 3246 noticeEle.append(data); 3247 return false; 3248 } 3249 3250 var fileUploadUrl = resultData.file_upload_url; 3251 var fileKey = resultData.file_key; 3252 3253 // PUSH FILE KEYS TO ARRAY 3254 fileKeys.push(fileKey); 3255 3256 // UPLOAD THE FILE 3257 jQuery.ajax({ 3258 url: fileUploadUrl, // the presigned URL 3259 type: 'PUT', 3260 processData: false, 3261 contentType: fileType, 3262 //headers: {'x-amz-tagging': 'label=' + fileLabel}, //breaks on long text 3263 data: theFormFile, 3264 success: function () { 3265 var hiddenFileUploadContainer = hiddenForm.find('#' + fileInputParentId).find('.ginput_container_fileupload'); 3266 var existingFiles = hiddenForm.find('#' + fileInputParentId).find('.cm_hi
3266paa_file_input'); // GET EXISTING FILES ALREADY UPLOADED IN HIDDEN FORM 3267 hiddenFileUploadContainer.html(''); // CLEAR THE CONTAINER ELEMENT 3268 3269 jQuery.each(existingFiles, function() { 3270 // APPEND EXISTING FILES ALREADY UPLOADED BACK INTO CONTAINER ELEMENT 3271 hiddenFileUploadContainer.append(jQuery(this)); 3272 }); 3273 3274 // APPEND NEW UPLOADED FILE TO CONTAINER ELEMENT 3275 hiddenFileUploadContainer.append('<div class="cm_hipaa_file_input" data-file-key="' + fileKey + '">' + fileKey + '</div>'); 3276 3277 iterations = iterations + 1; 3278 if (iterations === fileInputsLength) { 3279 // UPDATE FILE UPLOAD STATUS 3280 jQuery('.cm-hipaa-forms-file-upload-status').html('Submitting Form...'); 3281 // SET TIMEOUT TO ENSURE INPUTS OVERWRITTEN 3282 setTimeout(function () { 3283 // SUBMIT FORM 3284 jQuery.ajax({ 3285 method: 'POST', 3286 type: 'POST', 3287 url: cmHipaaScript.ajax_url, 3288 data: { 3289 'action': 'cm_hipaa_submit_gravity_form', 3290 'formId': formId, 3291 'formFields': formFields, 3292 'formHtml': hiddenForm.html(), 3293 'signature': signature, 3294 'nonce': nonce, 3295 'selectedUser': selectedUser, 3296 'location': location, 3297 'locationEmail': locationEmail, 3298 'firstName': firstName, 3299 'lastName': lastName, 3300 'email': email, 3301 'phone': phone, 3302 'notification_option': notificationOption, 3303 //'notification_from_name': notificationFromName, 3304 //'notification_from_email': notificationFromEmail, 3305 //'notification_sendto': notificationSendTo, 3306 //'notification_subject': notificationSubject, 3307 //'notification_message': notificationMessage, 3308 'files': fileKeys.join(','), 3309 'formFound': formFound 3310 }, 3311 success: function (data) { 3312 var resultData = JSON.parse(data); 3313 var formError = ''; 3314 if(resultData.error) { 3315 formError = resultData.error; 3316 } 3317 3318 if (resultData.success === 'success') { 3319 if (successHandler === 'message') { 3320 if(successHideForm === 'hide') { 3321 // HIDE FORM THEN ADD SUCCESS MESSAGE 3322 form.fadeOut().promise().done(function() { 3323 form.after('<div class="cm-hipaa-notice cm-hidden-form-message">' + successMessage + ' ' + formError + '</div>'); 3324 jQuery('.cm
3324-hidden-form-message').fadeIn(); 3325 }); 3326 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3327 submitButton.removeClass('inactive').addClass('active'); 3328 } else { 3329 // DISPLAY THE SUCCESS NOTICE 3330 noticeEle.html(successMessage + ' ' + formError); 3331 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3332 submitButton.removeClass('inactive').addClass('active'); 3333 } 3334 } else if (successHandler === 'redirect') { 3335 // REDIRECT TO SUCCESS PAGE 3336 window.location = successRedirect; 3337 } else if (successHandler === 'callback') { 3338 // MAKE SURE CALLBACK IS AN EXISTING FUNCTION 3339 fnExists = typeof window[successCallback] === 'function'; 3340 if (fnExists) { 3341 if (successCallbackParams) { 3342 window[successCallback].apply(null, successCallbackParams.split(',')); 3343 } else { 3344 window[successCallback](); 3345 } 3346 } else { 3347 console.log(successCallback + ' is not an existing function!'); 3348 } 3349 if (successMessage) { 3350 noticeEle.html(successMessage + ' ' + formError); 3351 } else { 3352 // DISPLAY THE SUCCESS NOTICE 3353 noticeEle.html('Thank y
3353ou, your form has been encrypted to protect your privacy and submitted successfully!'); 3354 } 3355 } else { 3356 // DISPLAY THE SUCCESS NOTICE 3357 noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!'); 3358 } 3359 // RESET THE FORM 3360 form[0].reset(); 3361 if (signature) { 3362 signatureEle.jSignature("reset"); 3363 } 3364 3365 // SHOW PAGE 1 OF FORM IF PAGINATED/STEPPED & NO ERROR 3366 if(isPaginated === true && !formError) { 3367 // DEACTIVATE SUBMIT BUTTON AGAIN (DIRTY BUT EASIER) 3368 submitButton.removeClass('active').addClass('inactive'); 3369 3370 setTimeout(function() { 3371 jQuery('.gform_page').fadeOut().promise().done(function() { 3372 jQuery('.gform_page:first').fadeIn().promise().done(function() { 3373 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3374 submitButton.removeClass('inactive').addClass('active'); 3375 }); 3376 }); 3377 }, 5000); 3378 } else { 3379 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3380 submitButton.removeClass('inactive').addClass('active'); 3381 } 3382 } else { 3383 // JUST A FAIL-SAFE JUST IN CASE WE DON'T ACTUALLY GET A SUCCESS MESSAGE 3384 noticeEle.html(formError); 3385 3386 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3387 submitButton.removeClass('inactive').addClass('active'); 3388 } 3389 hiddenForm.remove(); 3390 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3391 }, 3392 error: function (errorThrown) { 3393 console.log(errorThrown); 3394 noticeEle.html(errorThrown); 3395 hiddenForm.remove(); 3396 jQuery('.cm
3396-hipaa-forms-hidden-form').remove(); 3397 3398 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3399 submitButton.removeClass('inactive').addClass('active'); 3400 } 3401 }); 3402 }, 500); 3403 } 3404 } 3405 }); 3406 }, 3407 error: function (errorThrown) { 3408 console.log(errorThrown); 3409 } 3410 }); 3411 } else { 3412 hiddenForm.find('#' + fileInputParentId).find('.ginput_container_fileupload').html('<div class="cm_hipaa_file_input" data-file-key="">No File Attached</div>'); 3413 3414 iterations = iterations + 1; 3415 if (iterations === fileInputsLength) { 3416 // UPDATE FILE UPLOAD STATUS 3417 jQuery('.cm-hipaa-forms-file-upload-status').html('Submitting Form...'); 3418 // SET TIMEOUT TO ENSURE INPUTS OVERWRITTEN 3419 setTimeout(function () { 3420 // SUBMIT FORM 3421 jQuery.ajax({ 3422 method: 'POST', 3423 type: 'POST', 3424 url: cmHipaaScript.ajax_url, 3425 data: { 3426 'action': 'cm_hipaa_submit_gravity_form', 3427 'formId': formId, 3428 'formFields': formFields, 3429 'formHtml': hiddenForm.html(), 3430 'signature': signature, 3431 'nonce': nonce, 3432 'selectedUser': selectedUser, 3433 'location': location, 3434 'locationEmail': locationEmail, 3435 'firstName': firstName, 3436 'lastName': lastName, 3437 'email': email, 3438 'phone': phone, 3439 'notification_option': notificationOption, 3440 'files': fileKeys.join(','), 3441 'formFound': formFound 3442 }, 3443 success: function (data) { 3444 //var resultData = JSON.parse(data); 3445 var resultData; 3446 try { 3447 resultData = JSON.parse(data); 3448 } catch (e) { 3449 console.log(data); 3450 noticeEle.append(data); 3451 return false; 3452 } 3453 3454 var formError = ''; 3455 if(resultData.error) { 3456 formError = resultData.error; 3457 } 3458 3459 if (resultData.success === 'success') { 3460 if (successHandler === 'message') { 3461 if(successHideForm === 'hide') { 3462 // HIDE FORM THEN ADD SUCCESS MESSAGE 3463 form.fadeOut().promise().done(function() { 3464 form.after('<div class="cm-hipaa-notice cm-hidden-form-message">' + successMessage + ' ' + formError + '</div>'); 3465 jQuery('.cm
3465-hidden-form-message').fadeIn(); 3466 }); 3467 3468 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3469 submitButton.removeClass('inactive').addClass('active'); 3470 } else { 3471 // DISPLAY THE SUCCESS NOTICE 3472 noticeEle.html(successMessage + ' ' + formError); 3473 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3474 submitButton.removeClass('inactive').addClass('active'); 3475 } 3476 } else if (successHandler === 'redirect') { 3477 // REDIRECT TO SUCCESS PAGE 3478 window.location = successRedirect; 3479 } else if (successHandler === 'callback') { 3480 // MAKE SURE CALLBACK IS AN EXISTING FUNCTION 3481 fnExists = typeof window[successCallback] === 'function'; 3482 if (fnExists) { 3483 if (successCallbackParams) { 3484 window[successCallback].apply(null, successCallbackParams.split(',')); 3485 } else { 3486 window[successCallback](); 3487 } 3488 } else { 3489 console.log(successCallback + ' is not an existing function!'); 3490 } 3491 if (successMessage) { 3492 noticeEle.html(successMessage + ' ' + formError); 3493 } else { 3494 // DISPLAY THE SUCCESS NOTICE 3495 noticeEle.html('Thank y
3495ou, your form has been encrypted to protect your privacy and submitted successfully!'); 3496 } 3497 } else { 3498 // DISPLAY THE SUCCESS NOTICE 3499 noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!'); 3500 } 3501 // RESET THE FORM 3502 form[0].reset(); 3503 if (signature) { 3504 signatureEle.jSignature("reset"); 3505 } 3506 3507 // SHOW PAGE 1 OF FORM IF PAGINATED/STEPPED & NO ERROR 3508 if(isPaginated === true && !formError) { 3509 // DEACTIVATE SUBMIT BUTTON AGAIN (DIRTY BUT EASIER) 3510 submitButton.removeClass('active').addClass('inactive'); 3511 3512 setTimeout(function() { 3513 jQuery('.gform_page').fadeOut().promise().done(function() { 3514 jQuery('.gform_page:first').fadeIn().promise().done(function() { 3515 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3516 submitButton.removeClass('inactive').addClass('active'); 3517 }); 3518 }); 3519 }, 5000); 3520 } else { 3521 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3522 submitButton.removeClass('inactive').addClass('active'); 3523 } 3524 } else { 3525 // JUST A FAIL-SAFE JUST IN CASE WE DON'T ACTUALLY GET A SUCCESS MESSAGE 3526 noticeEle.html(formError); 3527 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3528 submitButton.removeClass('inactive').addClass('active'); 3529 } 3530 hiddenForm.remove(); 3531 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3532 }, 3533 error: function (errorThrown) { 3534 console.log(errorThrown); 3535 noticeEle.html(errorThrown); 3536 hiddenForm.remove(); 3537 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3538 3539 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3540 submitButton.removeClass('inactive').addClass('active'); 3541 } 3542 }); 3543 }, 500); 3544 } 3545 } 3546 }); 3547 } else { 3548 // SHOW LOADING BAR 3549 noticeEle.html('<div class="cm-hipaa-forms-progress-wrapper"><div class="cm-hipaa-forms-progress"><div class="cm-hipaa-forms-progress-bar"><!-- <div class="cm-hipaa-forms-progress-label">10%</div>--></div></div></div>'); 3550 cmHipaaFormsProgress(); 3551 // SUBMIT FORM 3552 jQuery.ajax({ 3553 method: 'POST', 3554 type: 'POST', 3555 url: cmHipaaScript.ajax_url, 3556 data: { 3557 'action': 'cm_hipaa_submit_gravity_form', 3558 'formId': formId, 3559 'formFields': formFields, 3560 'formHtml': hiddenForm.html(), 3561 'signature': signature, 3562 'nonce': nonce, 3563 'selectedUser': selectedUser,
3564 'location': location, 3565 'locationEmail': locationEmail, 3566 'firstName': firstName, 3567 'lastName': lastName, 3568 'email': email, 3569 'phone': phone, 3570 'notification_option': notificationOption, 3571 'formFound': formFound 3572 }, 3573 success: function (data) { 3574 // var resultData = JSON.parse(data); 3575 var resultData; 3576 try { 3577 resultData = JSON.parse(data); 3578 } catch (e) { 3579 console.log(data); 3580 noticeEle.append(data); 3581 return false; 3582 } 3583 3584 var formError = ''; 3585 if (resultData.error) { 3586 formError = resultData.error; 3587 } 3588 3589 if (resultData.success === 'success') { 3590 if(successHandler === 'message') { 3591 if(successHideForm === 'hide') { 3592 // HIDE FORM THEN ADD SUCCESS MESSAGE 3593 form.fadeOut().promise().done(function() { 3594 form.after('<div class="cm-hipaa-notice cm-hidden-form-message">' + successMessage + ' ' + formError + '</div>'); 3595 jQuery('.cm-hidden-form-message').fadeIn(); 3596 }); 3597 } else { 3598 // DISPLAY THE SUCCESS NOTICE 3599 noticeEle.html(successMessage + ' ' + formError); 3600 } 3601 } else if(successHandler === 'redirect') { 3602 // REDIRECT TO SUCCESS PAGE 3603 window.location = successRedirect; 3604 } else if(successHandler === 'callback') { 3605 // MAKE SURE CALLBACK IS AN EXISTING FUNCTION 3606 fnExists = typeof window[successCallback] === 'function'; 3607 if(fnExists) { 3608 if(successCallbackParams) { 3609 window[successCallback].apply(null, successCallbackParams.split(',')); 3610 } else { 3611 window[successCallback](); 3612 } 3613 } else { 3614 console.log(successCallback + ' is not an existing function!'); 3615 } 3616 3617 if(successMessage) { 3618 noticeEle.html(successMessage + ' ' + formError); 3619 } else { 3620 // DISPLAY THE SUCCESS NOTICE 3621 noticeEle.html('Thank y
3621ou, your form has been encrypted to protect your privacy and submitted successfully!'); 3622 } 3623 } else { 3624 // DISPLAY THE SUCCESS NOTICE 3625 noticeEle.html('Thank you, your form has been encrypted to protect your privacy and submitted successfully!'); 3626 } 3627 3628 // RESET THE FORM 3629 form[0].reset(); 3630 3631 if(signature) { 3632 signatureEle.jSignature("reset"); 3633 } 3634 3635 // SHOW PAGE 1 OF FORM IF PAGINATED/STEPPED & NO ERROR 3636 if(isPaginated === true && !formError) { 3637 // DEACTIVATE SUBMIT BUTTON AGAIN (DIRTY BUT EASIER) 3638 submitButton.removeClass('active').addClass('inactive'); 3639 3640 setTimeout(function() { 3641 jQuery('.gform_page').fadeOut().promise().done(function() { 3642 jQuery('.gform_page:first').fadeIn().promise().done(function() { 3643 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3644 submitButton.removeClass('inactive').addClass('active'); 3645 }); 3646 }); 3647 }, 5000); 3648 } else { 3649 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3650 submitButton.removeClass('inactive').addClass('active'); 3651 } 3652 } else { 3653 // JUST A FAIL-SAFE JUST IN CASE WE DON'T ACTUALLY GET A SUCCESS MESSAGE 3654 noticeEle.html(formError); 3655 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3656 submitButton.removeClass('inactive').addClass('active'); 3657 } 3658 3659 hiddenForm.remove(); 3660 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3661 3662 }, 3663 error: function (errorThrown) { 3664 console.log(errorThrown); 3665 noticeEle.html(errorThrown); 3666 hiddenForm.remove(); 3667 jQuery('.cm-hipaa-forms-hidden-form').remove(); 3668 3669 // ADD ACTIVE CLASS BACK TO SUBMIT BUTTON 3670 submitButton.removeClass('inactive').addClass('active'); 3671 } 3672 }); 3673 } 3674 } else { 3675 console.log('Error validating Account...'); 3676 } 3677 }, 3678 error: function (errorThrown) { 3679 console.log(errorThrown); 3680 } 3681 }); 3682 3683 } 3684 } 3685 }); 3686 3687 /*** RESET SIGNATURE ***/ 3688 jQuery(document).on('click', '.cm-hipaa-form-signature-reset', function() { 3689 jQuery(this).parent().parent().find('.cm-hipaa-form-signature').jSignature("reset"); 3690 }); 3691 3692 /*** PRIVACY MODAL WINDOW ***/ 3693 jQuery(document).on('click', '.cmprivacy-modal .cmprivacy-close-btn', function() { 3694 jQuery('.cmprivacy-modal').toggle('closed'); 3695 jQuery('.cmprivacy-modal-overlay').toggle('closed'); 3696 });
3697 jQuery(document).on('click', '.cm-hipaa-privacy-statement a', function(e) { 3698 e.preventDefault(); 3699 jQuery('.cmprivacy-modal').toggle('closed'); 3700 jQuery('.cmprivacy-modal-overlay').toggle('closed'); 3701 }); 3702 3703 //console.log('CM script.js finished'); 3704}); 3705 3706//Custom progress bar 3707function cmHipaaFormsProgress() { 3708 var elem = jQuery(".cm-hipaa-forms-progress-bar"); 3709 var width = 10; 3710 var id = setInterval(frame, 25); 3711 function frame() { 3712 if (width >= 100) { 3713 width = 10; 3714 } else { 3715 width++; 3716 elem.css('width', width + '%'); 3717 jQuery(".cm-hipaa-forms-progress-label").html( width + '%'); 3718 } 3719 } 3720} 3721 3722//Custom Sanatize inputs 3723function removeTags(str) { 3724 if ((str===null) || (str==='')) 3725 return false; 3726 else 3727 str = str.toString(); 3728 3729 // Regular expression to identify HTML tags in 3730 // the input string. Replacing the identified 3731 // HTML tag with a null string. 3732 var sanitizedString = str.replace( /(<([^>]+)>)/ig, ''); 3733 var sanitizedString2 = sanitizedString.replace(/<img[^>]*?>/g,''); 3734 //console.log(sanitizedString2); 3735 3736 return sanitizedString2; 3737}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.