/* --------------------------------------------------------------------------- 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

Student Life

Home Student Life

The perks of going back to school

@Student Life

Deciding to go back to school is never easy, but in today’s uncertain and ever-changing world, it is a crucial step in ensuring your professional advancement. At IE University, we offer our students the latest in teaching innovation...

Studying in Madrid: Discover a city of growth

@Student Life

Madrid is buzzing with a mix of traditional culture and multicultural excitement. With a prime location, excellent transport links and one of the world’s most spoken languages, people are flocking to the city. As of 2021, it has a metropolitan...

The 10 most delicious dishes in Spain

@Student Life

Spanish food has become one of the most popular and successful cuisines in the world. Its extraordinary and varied flavors set it apart, with heavy use of both olive oil and garlic as well as spices like oregano, thyme, parsley and rosemary...

The top seven places to visit in Spain

@Student Life

Whether you’re looking for a quick city break, a weekend on the beach or something that’s more off the beaten track, we’ve got you covered. We’ve compiled a list of the top seven places to visit in Spain so that you can start planning...