{"version":3,"sources":["fbc-certificate.js"],"names":["$","Drupal","behaviors","fbcCertificate","attach","context","settings","hideRequestForm","removeClass","addClass","css","blockVideo","unblockVideo","showCertificateFormIntro","hideCertificateFormIntro","hideCertificateForm","showCertificateForm","formFilled","getCookie","length","html","indexOf","setCookie","error","webinarTitle","text","val","userFirst","userLast","webinarBrand","webinarGUID","today","Date","dd","getDate","mm","getMonth","yyyy","getFullYear","webinarDate","certificateNode","certificateLink","window","location","replace","certificateButton","once","after","jQuery"],"mappings":"CAAA,SAAWA,GACT,YAKAC,QAAOC,UAAUC,gBACfC,OAAQ,SAAUC,EAASC,GAGzB,QAASC,KACPP,EAAE,iBAAiBQ,YAAY,WAAWC,SAAS,UACnDT,EAAE,2CAA2CU,IAAI,UAAW,QAC5DV,EAAE,eAAeQ,YAAY,WAAWC,SAAS,UACjDT,EAAE,yCAAyCU,IAAI,UAAW,QAG5D,QAASC,KACPX,EAAE,oBAAoBS,SAAS,2BAGjC,QAASG,KACPZ,EAAE,oBAAoBQ,YAAY,2BAGpC,QAASK,KACPb,EAAE,2BAA2BQ,YAAY,UAAUC,SAAS,WAG9D,QAASK,KACPd,EAAE,2BAA2BQ,YAAY,WAAWC,SAAS,UAG/D,QAASM,KACPf,EAAE,qBAAqBQ,YAAY,WAAWC,SAAS,UAGzD,QAASO,KACPhB,EAAE,qBAAqBQ,YAAY,UAAUC,SAAS,WA9BxD,GAAIQ,GAAaC,UAAU,SAkC3B,IAAIlB,EAAE,eAAemB,OAAS,EAAG,CAC/BR,IACAG,IACAC,IAImB,WAAfE,IAEFV,IACAK,IACAC,IAKF,KACMR,EAAQe,OAAOC,QAAQ,0BACzBC,UAAU,SAAU,SAAU,GAC9Bf,IACAK,IACAC,KAEF,MAAOU,GACPZ,IACAG,IACAC,IAKAf,EAAE,2BAA2BmB,OAAS,GACvB,WAAfF,IAGAV,IACAK,KA2BJ,GAvBIZ,EAAE,eAAemB,OAAS,IAKxBnB,EAAE,2BAA2BmB,OAAS,IACxC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,aAKbG","file":"../fbc-certificate.js","sourcesContent":["(function ($) {\n \"use strict\";\n\n // This is for the certificate functionality only.\n // Functionality relating to Eloqua is in the fbc-eloqua.js File.\n\n Drupal.behaviors.fbcCertificate = {\n attach: function (context, settings) {\n var formFilled = getCookie(\"fbc-wf\");\n\n function hideRequestForm() {\n $(\".ungated-form\").removeClass(\"visible\").addClass(\"hidden\");\n $(\".ungated-form .form-wrapper .row .links\").css(\"display\", \"none\");\n $(\".gated-form\").removeClass(\"visible\").addClass(\"hidden\");\n $(\".gated-form .form-wrapper .row .links\").css(\"display\", \"none\");\n }\n\n function blockVideo() {\n $(\".video-container\").addClass(\"video-container-blocked\");\n }\n\n function unblockVideo() {\n $(\".video-container\").removeClass(\"video-container-blocked\");\n }\n\n function showCertificateFormIntro() {\n $(\".certificate-form-intro\").removeClass(\"hidden\").addClass(\"visible\");\n }\n\n function hideCertificateFormIntro() {\n $(\".certificate-form-intro\").removeClass(\"visible\").addClass(\"hidden\");\n }\n\n function hideCertificateForm() {\n $(\".certificate-form\").removeClass(\"visible\").addClass(\"hidden\");\n }\n\n function showCertificateForm() {\n $(\".certificate-form\").removeClass(\"hidden\").addClass(\"visible\");\n }\n\n // Check page if a form is required.\n if ($(\".gated-form\").length > 0) {\n blockVideo();\n hideCertificateFormIntro();\n hideCertificateForm();\n\n // If a form is in markup on the page, check page if the form has been \n // filled.\n if (formFilled === \"filled\") {\n // If the cookie says the form has been filled, don't show the form.\n hideRequestForm();\n unblockVideo();\n showCertificateFormIntro();\n }\n\n // If a form is NOT in markup on the page, show the form and set a \n // cookie.\n try {\n if (context.html().indexOf(\"webform-confirmation\")) {\n setCookie(\"fbc-wf\", \"filled\", 7);\n hideRequestForm();\n unblockVideo();\n showCertificateFormIntro();\n }\n } catch (error) {\n blockVideo();\n hideCertificateFormIntro();\n hideCertificateForm();\n }\n\n // Check page if video is supposed to be displayed when there is a form.\n if (\n $(\".field-name-field-video\").length > 0 &&\n formFilled === \"filled\"\n ) {\n // If the video is displayed on the page and the form has been filled, unblock video.\n hideRequestForm();\n unblockVideo();\n }\n }\n\n if ($(\".gated-form\").length < 1) {\n // There is no form on the page, but there may or may not be a video.\n\n // If there is a video on the page, show the form.\n // Let the video player change the JS on if the form is displayed.\n if ($(\".field-name-field-video\").length > 0) {\n showCertificateFormIntro();\n hideCertificateForm();\n }\n\n // If there is NOT a video on the page, just show the form.\n if ($(\".field-name-field-video\").length < 1) {\n hideCertificateFormIntro();\n showCertificateForm();\n }\n }\n\n /**\n * This section is for handling the certificate, copying fields and actions\n * after the user has submitted the certificate form.\n */\n\n // Get the title of the event for the certificate.\n if ($(\"#certificate-node-form\").length) {\n var webinarTitle = $(\".field-name-field-h1-title h1\").text();\n\n if ($(\".field-name-field-event\").length) {\n $('input[name=\"field_event[und][0][value]\"]').val(webinarTitle);\n }\n\n var userFirst = $(\n 'input[name=\"field_first_name[und][0][value]\"]'\n ).val();\n\n var userLast = $('input[name=\"field_last_name[und][0][value]\"]').val();\n\n $('input[name=\"title_field[und][0][value]\"]').val(\n webinarTitle + \"-\" + userFirst + \"-\" + userLast\n );\n }\n\n // Gather fields from the video node to enter on the certificate form.\n if ($(\".node-type-video\").length) {\n if ($(\".node-certificate-form\").length) {\n var webinarTitle = $(\".field-name-field-h1-title h1\").text();\n var webinarBrand = $(\n \".field-name-field-manufacturer .field-item\"\n ).text();\n var webinarGUID = $(\n \".field-name-field-eloqua-campaign-id .field-item\"\n ).text();\n\n var today = new Date();\n var dd = today.getDate();\n var mm = today.getMonth() + 1;\n var yyyy = today.getFullYear();\n if (dd < 10) {\n dd = \"0\" + dd;\n }\n if (mm < 10) {\n mm = \"0\" + mm;\n }\n\n today = yyyy + \"-\" + mm + \"-\" + dd;\n\n if ($(\".field-name-field-webinar-date\").length) {\n var webinarDate = $(\n \".field-name-field-webinar-date .date-display-single\"\n ).text();\n } else {\n var webinarDate = today;\n }\n\n $('input[name=\"field_event[und][0][value]\"]').val(webinarTitle);\n $('input[name=\"title_field[und][0][value]\"]').val(webinarTitle);\n $('input[name=\"field_certificate_date[und][0][value][date]\"]').val(\n webinarDate\n );\n $('input[name=\"field_webinar_brand[und][0][value]\"]').val(\n webinarBrand\n );\n $('input[name=\"field_crm_guid[und][0][value]\"]').val(webinarGUID);\n }\n }\n\n // Hide the certificate create form if it has been created.\n if ($(\".node-type-certificate\").length) {\n if ($(\".node-certificate-form .messages.status\").length) {\n $(\".node-certificate-form .messages\").css(\"display\", \"none\");\n\n // Get the url from the status message.\n var certificateNode = $(\"#certificate-node\").text();\n\n var certificateLink = \"/printpdf/node/\" + certificateNode;\n window.location.replace(certificateLink);\n\n var certificateButton =\n 'Download Certificate';\n\n $(\".field-name-receive-your-certificate form\").css(\"display\", \"none\");\n $(\".field-name-receive-your-certificate\")\n .once()\n .after(\n '

Congratulations

' +\n \"

If you are not automatically redirected to your certificate, please click here:

\" +\n certificateButton\n ) + \"
\";\n }\n }\n },\n };\n})(jQuery);\n"]}