PageSourceSearch

https://nacionespanola.org/wp-content/themes/Avada-Child-Theme/js/enlacesExternos.js?ver=1.0

js nacionespanola.org collected 2026-10-02 11:05:31 UTC 3,960 bytes, 103 lines download raw bytes

1/*
2**  Plugin para abrir enlaces externos
3*/
4
5(function($) {
6    $.fn.extend({
7        enlacesExternos: function (options) {
8			var defaults = {
9				mostrarIcono: false,
10				modoImagen: false,
11				rutaIcono: "/img/interface/ico-enlaces-externos.png",
12				mostrarTitle: true,				
13				title: "Este enlace se abrirá en una ventana nueva",
14				abrirVentana: true,
15				clase: ''
16			};
17			var options = $.extend(defaults, options);
18            			
19			var prefijoUrl = String(document.location)
20                .replace(/^(https?:\/\/[^:\/]+).*$/, "$1")
21                .replace(/^((site)?file:\/\/.+\/)[^\/]+$/, "$1")
22                .replace(/(\\.)/g, "\\$1");
23            var nombreDominio = String(document.location)
24                .replace(/^/, "X")
25                .replace(/^X(https?|ftp):\/\/([^:\/]+).*$/, "$1")
26                .replace(/^X.*$/, "")
27				.replace(/(\\.)/g, "\\$1");
28
29			// 12/06/18 - Añadido para solventar problema con subdominios. 2 variables con las regexp para comprobar si es un enlace web o si contiene el dominio
30			var re = new RegExp(window.location.hostname.split('.').join('\\.'), 'i');
31			var re2 = /^http(s)?/i
32			/***********************************/
33
34			//$("a", this) //esto serviria para seleccionar los "a" dentro de this, la opción usada debe recibir directamente los "a"
35			$(this) //a partir de aqui filtramos los enlaces:
36				.filter(function (i) { //solo enlaces externos
37					var href = $(this).attr("href");
38					if( $(this).hasClass("enlaceExterno") ){ 
39						return true;
40					} else {
41						if (href == null)
42							return false;
43						// 12/06/18 - Si no es un enlace web, salimos del bucle						
44						if (!re2.test(this.href))
45							return false;
46						// 12/06/18 - Devolvemos true si es un enlace externo, true si es interno o subdominio
47						return (
48							!re.test(this.href)
49						);
50						/*********************************/
51						/*
52						return (
53							   href.match(RegExp(
54								   "^(" + prefijoUrl + ".*" +
55								   (nombreDominio != "" ? ("|" + "(https?|ftp)://" + nombreDominio + "([/:].*)?") : "") +
56								   "|" + "((https?|ftp):)?/[^/].*" +
57								   ")$"
58							   )) == null
59							&& href.match(RegExp("^(https?|ftp)://.+")) != null
60						);
61						*/
62					}
63				})
64				.not(".noExterno") //si el enlace posee la clase "noExterno", no se aplica el plugin
65				.each(function () { //recorremos los enlaces una vez filtrados
66					//PARAMETROS
67					if( $(this).not(":has(img)") ) { //si no tiene imagen dentro del enlace, habilitamos la opcion de mostrar icono
68						if(options.mostrarIcono == true) { //mostramos icono si/no?
69							if(options.modoImagen == false) { //mostramos icono como background del enlace
70								$(this)
71									.css("backgroundImage",    "url("+options.rutaIcono+")")
72									.css("backgroundRepeat",   "no-repeat")
73									.css("backgroundPosition", "right center")
74									.css("padding-right",      "11px");
75							} else if(options.modoImagen == true) { //añadimos el icono como etiqueta img detras del enlace, para evitar sobreescribir backgrounds
76								$(this).after('&nbsp;<img src="' + options.rutaIcono + '" alt="' + options.title + '" title="' + options.title + '">');
77							}
78						}
79					}
80					if(options.mostrarTitle == true) { //mostramos title en el enlace, si ya existe, se añade antes de lo existente
81						var titulo = $(this).attr("title");
82						if( titulo == undefined ){
83							$(this).attr("title", options.title);
84						} else {
85							$(this).attr("title", options.title+": "+titulo);
86						}
87					}
88					if(options.abrirVentana == true) {
89						$(this).attr('target', '_blank');
90						/*
91						$(this).on('click', function(){
92							window.open(this.href);
93							return false;
94						});
95						*/
96					}
97					if(options.clase != ''){
98						$(this).addClass(options.clase);
99					}
100				});
101        }
102    });
103})(jQuery);

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.