1var RWD = RWD || {}; 2 3RWD.configuracion_enlaces_en_ventana_nueva = { 4 mensaje: 'Se abrirá en ventana nueva', 5 carpetas_descargas: [], 6 class_excluidos: [], 7 extensiones_documentos_descargables: ["pdf", "doc", "docx", "zip", "odt", "xls", "xlsx"] 8}; 9 10RWD.configuracion_registrar_en_analytics = { 11 registrar: false, 12 registrar_mails: false, 13 registrar_telefonos: false 14}; 15 16RWD.tools = RWD.tools || {}; 17 18RWD.tools.enlaces_en_ventana_nueva = function() { 19 "use strict"; 20 21 var todosLosEnlacesConHref = jQuery("a[href]"); 22 23 todosLosEnlacesConHref.each(function () { 24 "use strict"; 25 26 var enlace = jQuery(this); 27 RWD.tools.enlaces_en_ventana_nueva.manipula_enlace(enlace); 28 }); 29}; 30 31RWD.tools.enlaces_en_ventana_nueva.manipula_enlace = function (enlace) { 32 "use strict"; 33 34 var url, 35 elEnlaceEsExterno, 36 laUrlContieneUnaCarpetaDeDescarga, 37 larUrlContieneUnaExtensionDeArchivoCuyaDescargaQueremosRegistrar, 38 elEnlaceTieneRelExternal, 39 parametrosRegistroClick; 40 41 elEnlaceEsExterno = RWD.tools.enlaces_en_ventana_nueva.enlace_es_externo(enlace); 42 43 if (elEnlaceEsExterno) { 44 45 parametrosRegistroClick = { 46 enlace: enlace, 47 tipo: "Enlace externo", 48 evento: "click" 49 }; 50 51 RWD.tools.enlaces_en_ventana_nueva.abrir_en_ventana_nueva_y_registrar_click_en_analytics(parametrosRegistroClick); 52 } 53 54 url = enlace.attr("href"); 55 laUrlContieneUnaCarpetaDeDescarga = RWD.tools.enlaces_en_ventana_nueva.la_url_contiene_una_carpeta_de_descarga(url); 56 57 if (laUrlContieneUnaCarpetaDeDescarga) { 58 59 parametrosRegistroClick = { 60 enlace: enlace, 61 tipo: "Documento", 62 evento: "descarga" 63 }; 64 65 RWD.tools.enlaces_en_ventana_nueva.abrir_en_ventana_nueva_y_registrar_click_en_analytics(parametrosRegistroClick); 66 } else { 67 larUrlContieneUnaExtensionDeArchivoCuyaDescargaQueremosRegistrar = RWD.tools.enlaces_en_ventana_nueva.la_url_contiene_una_extension_de_archivo_cuya_descarga_queremos_registrar(url); 68 69 if (larUrlContieneUnaExtensionDeArchivoCuyaDescargaQueremosRegistrar) { 70 71 parametrosRegistroClick = { 72 enlace: enlace, 73 tipo: "Documento", 74 evento: "descarga" 75 }; 76 77 RWD.tools.enlaces_en_ventana_nueva.abrir_en_ventana_nueva_y_registrar_click_en_analytics(parametrosRegistroClick); 78 } 79 } 80 81 elEnlaceTieneRelExternal = RWD.tools.enlaces_en_ventana_nueva.tiene_rel_external(enlace); 82 83 if (elEnlaceTieneRelExternal) { 84 RWD.tools.enlaces_en_ventana_nueva.anadir_title_y_target_blank (enlace); 85 } 86}; 87 88RWD.tools.enlaces_en_ventana_nueva.abrir_en_ventana_nueva_y_registrar_click_en_analytics = function (parametros) { 89 "use strict"; 90 91 RWD.tools.enlaces_en_ventana_nueva.anadir_rel_external(parametros.enlace); 92 93 if (typeof RWD.tools.registrar_en_analytics.otros_enlaces == 'function') { 94 RWD.tools.registrar_en_analytics.otros_enlaces(parametros.tipo, parametros.evento, parametros.enlace); 95 } 96}; 97 98RWD.tools.enlaces_en_ventana_nueva.enlace_es_externo = function(enlace) { 99 "use strict"; 100 101 var dominio = location.hostname, enlace_URL = enlace.attr('href'), resultado = false; 102 103 if (enlace_URL.indexOf("http") == 0 && enlace_URL.indexOf("http://" + dominio) == -1 && enlace_URL.indexOf("https://" + dominio) == -1) { 104 resultado = true; 105 } 106 107 return resultado; 108}; 109 110RWD.tools.enlaces_en_ventana_nueva.anadir_rel_external = function(elemento) { 111 "use strict"; 112 113 var relacion = elemento.attr("rel"), 114 tieneRelExternal; 115 116 if (relacion !== undefined) { 117 tieneRelExternal = RWD.tools.enlaces_en_ventana_nueva.tiene_rel_external(elemento); 118 119 if (tieneRelExternal === false) { 120 elemento.attr("rel", relacion + " external"); 121 } 122 } else { 123 elemento.attr("rel", "external"); 124 } 125}; 126 127RWD.tools.enlaces_en_ventana_nueva.tiene_rel_external = function(elemento) { 128 "use strict"; 129 130 var attrRel = elemento.attr("rel"); 131 var tieneRelExternal = false; 132 133 if (attrRel !== undefined && attrRel.indexOf("external") >= 0) { 134 tieneRelExternal = true; 135 } 136 137 return tieneRelExternal; 138}; 139 140RWD.tools.enlaces_en_ventana_nueva.la_url_contiene_una_carpeta_de_descarga = function (url) { 141 "use strict"; 142 143 var laUrlContieneUnaCarpetaDescarga = false, 144 directoriosDescargas, 145 expresion, 146 expresionRegular; 147 148 if (RWD.configuracion_enlaces_en_ventana_nueva.carpetas_descargas.length > 0) { 149 directoriosDescargas = RWD.configuracion_enlaces_en_ventana_nueva.carpetas_descargas.join("|").replace(/\//g, "\/"); 150 expresion = "(" + directoriosDescargas + ")"; 151 expresionRegular = new RegExp(expresion); 152 laUrlContieneUnaCarpetaDescarga = expresionRegular.test(url); 153 } 154 155 return laUrlContieneUnaCarpetaDescarga; 156}; 157 158RWD.tools.enlaces_en_ventana_nueva.la_url_contiene_una_extension_de_archivo_cuya_descarga_queremos_registrar = function (url) { 159 "use strict"; 160 161 var enlazaConUnDocumentoCuyaDescargaQueremosResgistrar = false, 162 extensionesDocumentos, 163 expresion, 164 expresionRegular; 165 166 if (RWD.configuracion_enlaces_en_ventana_nueva.extensiones_documentos_descargables.length > 0) { 167 extensionesDocumentos = RWD.configuracion_enlaces_en_ventana_nueva.extensiones_documentos_descargables.join("|").replace(/\./g, ""); 168 expresion = ".+\\.(" + extensionesDocumentos + ")(\\?.*)?$"; 169 expresionRegular = new RegExp(expresion, "i"); 170 enlazaConUnDocumentoCuyaDescargaQueremosResgistrar = expresionRegular.test(url); 171 } 172 173 return enlazaConUnDocumentoCuyaDescargaQueremosResgistrar; 174}; 175 176RWD.tools.enlaces_en_ventana_nueva.anadir_title_y_target_blank = function (enlace) { 177 "use strict"; 178 179 var title, 180 numero_enlaces_excluidos, 181 procesar = true; 182 183 title = enlace.attr("title"); 184 numero_enlaces_excluidos = RWD.configuracion_enlaces_en_ventana_nueva.class_excluidos.length; 185 186 for (var i = 0; i < numero_enlaces_excluidos; i++) { 187 if (enlace.hasClass(RWD.configuracion_enlaces_en_ventana_nueva.class_excluidos[i])) { 188 procesar = false;
189 break; 190 } 191 } 192 193 if (procesar) { 194 enlace.attr("target", "_blank"); 195 196 if (title === undefined) { 197 enlace.attr("title", RWD.configuracion_enlaces_en_ventana_nueva.mensaje); 198 } else { 199 enlace.attr("title", title + " [" + RWD.configuracion_enlaces_en_ventana_nueva.mensaje + "]"); 200 } 201 } 202}; 203 204RWD.tools.registrar_en_analytics = function() { 205 "use strict"; 206 207 if (typeof ga == 'function' && RWD.configuracion_registrar_en_analytics.registrar) { 208 209 if (RWD.configuracion_registrar_en_analytics.registrar_mails) { 210 jQuery("a[href^='mailto']").on('click', function() { 211 var enlace = jQuery(this), url_enlace = enlace.attr("href").toLowerCase().replace(/^mailto\:*/i, ""); 212 213 ga('send', 'event', 'Email', 'click', url_enlace); 214 }); 215 } 216 217 if (RWD.configuracion_registrar_en_analytics.registrar_telefonos) { 218 jQuery("a[href^='tel']").on('click', function() { 219 var enlace = jQuery(this), url_enlace = enlace.attr("href").toLowerCase().replace(/^tel\:*/i, ""); 220 221 ga('send', 'event', 'Teléfono', 'click', url_enlace); 222 }); 223 } 224 } 225}; 226 227RWD.tools.registrar_en_analytics.otros_enlaces = function(tipo, evento, enlace) { 228 "use strict"; 229 230 var url_enlace = enlace.attr("href").toLowerCase(); 231 232 if (typeof ga == 'function' && RWD.configuracion_registrar_en_analytics.registrar) { 233 enlace.on('click', function() { 234 ga('send', 'event', tipo, evento, url_enlace); 235 }); 236 } 237}; 238 239RWD.formuSolicitud = RWD.formuSolicitud || {}; 240 241RWD.formuSolicitud.cambioTipoUsuario = function() { 242 "use strict"; 243 244 $("#tipoUsuarioPersona").click(function() { 245 if (this.checked == true) { 246 $("#bloqueDatosPersonaSolicitante").show(); 247 $("#bloqueDatosEntidad").hide(); 248 } 249 }); 250 251 $("#tipoUsuarioEntidad").click(function() { 252 if (this.checked == true) { 253 $("#bloqueDatosPersonaSolicitante").hide(); 254 $("#bloqueDatosEntidad").show(); 255 } 256 }); 257}; 258 259 260window.onload = function() { 261 RWD.tools.enlaces_en_ventana_nueva(); 262 RWD.tools.registrar_en_analytics(); 263 RWD.formuSolicitud.cambioTipoUsuario(); 264 265};
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.