/* --------------------------------------------------------------------------- Ajuste en formulario Hubspot, que repara el selector de LISTA de PROVINCIAS, que es dependiente del país. En las opciones de "provincia" salía también el código de la provincia: ( A CORUÑA[9b4032be-a5f1-df11-af0a-02bf0a09015e] ) --------------------------------------------------------------------------- */ var hubspotFormFIX = new function () { var initHubspotForm = function($form) { var regionsList = []; var $country = $('select[name="countrylist"]', $form); var $region = $('select[name="stateprovincelist"]', $form); var pushIfNew = function (obj) { for (var i = 0; i < regionsList.length; i++) { if (regionsList[i].id === obj.id) { return; } } regionsList.push(obj); }; var setRegionsList = function () { var myRegexp = /([^\[]+)\[([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\]/g; $('option', $region).each(function () { var literal = $(this).html(); var match = myRegexp.exec(literal); if (match != null) { pushIfNew({ "id" : $(this).val(), "name" : match[1], "countryId": match[2], }); } else { pushIfNew({ "id" : $(this).val(), "name" : literal, "countryId": '', }); } }); }; var getRegions = function (countryId) { return $.grep(regionsList, function (item) { return item.countryId == countryId || item.id == ""; }); }; var repopulateSelect = function ($select, values) { $select.find("option").remove(); var output = []; $.each(values, function (key, value) { output.push(''); }); $select.html(output.join('')); }; var onCountryChange = function () { var selectedValue = $country.find("option:selected").val(); var filteredRegionList = []; if (selectedValue !== '') { filteredRegionList = getRegions(selectedValue); repopulateSelect($region, filteredRegionList); } if (filteredRegionList.length < 2) { $region.val(''); $region.parent().parent().css("display", "none"); $region.closest('.hs-form-field').removeClass('filtred'); } else { $region.parent().parent().css("display", "block"); $region.closest('.hs-form-field').addClass('filtred'); } $region.attr("required", (filteredRegionList.length > 1)); }; if (!regionsList.length) { setRegionsList(); } var selectedRegion = $region.val(); if (selectedRegion != "") { onCountryChange(); $region.val(selectedRegion).removeAttr("disabled"); } else { $region.attr("disabled", true); } $country.on('change', onCountryChange); }; return { init: function () { $(document).on('focus', 'form.hs-form', function(e) { var $form = $(this); if (!$form.hasClass('form-processed')) { e.preventDefault(); console.log("Init form"); $form.addClass('form-processed'); initHubspotForm($form); } }); if ($('form.hs-form').length) { $('.footer-content_footer_last .footer-content_footer_inner').append(''); } } }; }; module.exports = hubspotFormFIX

IE Core

Home IE Core

Staying in the loop with events at IE University

@IE Core

At IE University, we’re big believers in learning beyond the classroom. While earning that master’s degree may seem like the number-one goal of your academic journey, attending informative sessions and conferences will give you added insights...