1(function ($, Drupal, once) { 2 $(document).ready(function() { 3 //Variables 4 var lastScrollTop = 0; 5 var titlePosition = 0; 6 var cod; 7 var modContinua = 0; 8 9 var customEvent = new CustomEvent( 10 '@ue-content-updated', 11 { detail: { location: document.location }} 12 ); 13 14 $( "#edit-wizard-next" ).click(function() { 15 //alert( "Handler for .click() called." ); 16 window.ueDataLayer.sendAnalyticsPage(); 17 }); 18 $( "#edit-wizard-prev" ).click(function() { 19 //alert( "Handler for .click() called." ); 20 window.ueDataLayer.sendAnalyticsPage(); 21 }); 22 23 24 //Llamadas a funciones iniciales 25 obtTitle(); 26 function obtTitle(){ 27 if($('.main .page-title').length > 0){ 28 var pageTitle = $('.mod-nav-continua.active .page-title').text();//añadir .main.active para que coja el titulo de la pagina activa 29 window.titlePosition = $('.mod-nav-continua.active .page-title').offset().top; 30 changetitle(pageTitle); 31 } 32 } 33 //Titulo de la pagina en la miga 34 function changetitle(pageTitle){ 35 if($('.noticia').length > 0 || $('.noticia-especial').length > 0){ 36 $('.nav-title').text(pageTitle); 37 } 38 } 39 //Funciones según scroll 40 var scrollTicking = false; 41 $(window).scroll(function(event){ 42 if (!scrollTicking) { 43 var scrollTop = $(this).scrollTop(); 44 window.requestAnimationFrame(function() { 45 esVisible(".mod-nav-continua"); 46 var st = scrollTop; 47 if (st > lastScrollTop && st > 60){ 48 window.dirScroll = "down"; 49 $('body').addClass('up'); 50 $('body').removeClass('down'); 51 if(lastScrollTop > titlePosition) { 52 $('.sub-nav').addClass('addTitle'); 53 } 54 }else if(st < lastScrollTop && st > 60) { 55 window.dirScroll = "up"; 56 $('body').addClass('down'); 57 $('body').removeClass('up'); 58 $('.sub-nav').removeClass('up'); 59 if(lastScrollTop < titlePosition) { 60 $('.sub-nav').removeClass('addTitle'); 61 } 62 } 63 else { 64 $('body').removeClass('down'); 65 $('body').removeClass('up'); 66 } 67 lastScrollTop = st; 68 scrollTicking = false; 69 }); 70 scrollTicking = true; 71 } 72 }); 73 //Detectamos si el elemento está visible en pantalla 74 function esVisible(elemVisible){ 75 if(modContinua!=0){ 76 if(elemVisible.length > 1){ 77 var posTopView = $(window).scrollTop(); 78 var posButView = posTopView + $(window).height(); 79 $(elemVisible).each(function(){ 80 var elemTop = $(this).offset().top; 81 var elemBottom = elemTop + $(this).height(); 82 if ((elemTop > posTopView && elemTop < posButView)||((elemBottom > posButView) && (elemTop < posTopView))){ 83 barraScroll(elemBottom, elemTop); 84 if($(this).hasClass("active")){ 85 // si tiene clase active no hace nada 86 } else { 87 $(this).addClass("active"); 88 obtTitle(); 89 //cd_satellite.track('continua'); 90 var newDirec = $(this).attr('url'); 91 history.pushState(null, "", newDirec); 92 newCod = $(this).attr('cod'); 93 94 if(newCod){ 95 var nameCod = window['ueDataLayer_'+newCod]; 96 //var nameCod_om = window['ueDataLayer_om_'+newCod]; 97 98 if (nameCod){ 99 100 nameCod.be_scroll_type=dirScroll; 101 nameCod.be_navigation_type='continua'; 102 103 delete nameCod.userProfesion; 104 delete nameCod.userCategory; 105 delete nameCod.userPrescriptor; 106 delete nameCod.userID; 107 // Update the object with the data from userDatalayer object. 108 if (typeof window.userDatalayer === "object") { 109 window.userDatalayer.injectUserData(nameCod); 110 } 111 112 } 113 //console.log(nameCod); 114 if (typeof refreshSticky !== 'undefined' && typeof(refreshSticky) === "function") { 115 funcion_re(newCod); 116 var funcion_refresh = window['refreshAllSlots_' + newCod]; 117 if (typeof funcion_refresh === 'function') { 118 funcion_refresh(); 119 } 120 } 121 122 //console.log('Fin'); 123 124 125 window.update = function (obj) { 126 for (var i = 1; i < arguments.length; i++) { 127 for (var prop in arguments[i]) { 128 var val = arguments[i][prop]; 129 130 if (typeof val == "object") update(obj[prop], val); 131 else obj[prop] = val; 132 } 133 } 134 return obj; 135 }; 136 update(ueDataLayer, nameCod); 137 138 //ueDataLayer=nameCod; 139 //ueDataLayer_om=nameCod_om; 140 141// console.log(ueDataLayer); 142// console.log(ueDataLayer_om); 143 144 document.title =ueDataLayer.be_page_article_title; 145 ueDataLayer.sendAnalyticsPage(); 146 document.dispatchEvent(customEvent); 147 } 148 // console.log(ueDataLayer.pageName); lo coge de un script que trae cada noticia por defecto 149 } 150 } else { 151 if($(this).hasClass("active")){ 152 $(this).removeClass("active"); 153 } 154 } 155 }) 156 } 157 }else { 158 modContinua = 1; 159 } 160 } 161 162 function funcion_re(newCod){ 163 window['refreshAllSlots_' + newCod]; 164 } 165 166 //barra scroll 167 function barraScroll(bottom, top) { 168 var $activeElement = $(".mod-nav-continua.active"); 169 var winScroll = document.body.scrollTop || document.documentElement.scrollTop; 170 var height = $activeElement.height() - document.documentElement.clientHeight; 171 var scrolled = ((winScroll - top) / height) * 100; 172 $(".percentage-bar").css({ width: scrolled + "%" }); 173 174 // Launch custom event earlier (40% instead of 75%) so the AJAX 175 // request for the next article has more time to finish rendering 176 // before the reader actually reaches the end of the page. 177 if (scrolled > 40 && window.dirScroll == 'down' 178 && $('body').find('.nc-container') 179 ) { 180 document.dispatchEvent(new Event('activeContentScrolled')); 181 } 182 183 } 184 //Para desplegar la navegacion lateral 185 //$('.hamburguer').click(function(){ togglenav() }); 186 //$('.close-nav-layer').click(function(){togglenav() }); 187 function togglenav(){ 188 //$('.hamburguer').toggleClass('active'); 189 $('.region-nav').toggleClass('active'); 190 $('.close-nav-layer').toggleClass('active'); 191 $('.open-menu').removeClass("open"); 192 $('.open-menu').siblings('.menu-dropdown').removeClass("open"); 193 } 194 //Dentro de la navegacion lateral despliega los submenús 195 $('.menu-level-0 > .menu-item > .open-menu').click(function(){ 196 $('.open-menu').not(this).removeClass("open"); 197 $('.open-menu').not(this).siblings('.menu-dropdown').removeClass("open"); 198 $(this).toggleClass("open"); 199 $(this).siblings('.menu-dropdown').toggleClass("open"); 200 }); 201 $('.menu-level-1 > .menu-item > .open-menu').click(function(){ 202 $(this).toggleClass("open"); 203 $(this).siblings('.menu-dropdown').toggleClass("open"); 204 }); 205 //OCULTAR MAS DE 5 ELEMENTOS EN EL MENU GENERAL 206 var numEmenu = $('#block-menugeneral > .menu-primario > li').length; 207 var liMenu = $('#block-menugeneral > .menu-primario > li'); 208/* 209 if(numEmenu > 6){ 210 $('#block-menugeneral > .menu-primario > li:nth-child(n+11)').addClass("ver-mas-elements"); 211 $('#block-menugeneral > .menu-primario > .ver-mas-elements').wrapAll('<li class="menu-item menu-ver-mas submenu"><ul class="ver-mas-open menu"></ul></li>'); 212 $('.ver-mas-open').before('<a href="#">Ver más</a>'); 213 $('.ver-mas-open').after("<span class='open-menu-header'>
213<svg class='svg-icon right-icon' viewBox='0 0 20 20'> <path fill='none' d='M11.611,10.049l-4.76-4.873c-0.303-0.31-0.297-0.804,0.012-1.105c0.309-0.304,0.803-0.293,1.105,0.012l5.306,5.433c0.304,0.31,0.296,0.805-0.012,1.105L7.83,15.928c-0.152,0.148-0.35,0.223-0.547,0.223c-0.203,0-0.406-0.08-0.559-0.236c-0.303-0.309-0.295-0.803,0.012-1.104L11.611,10.049z'></path></svg></span>"); 214 } 215*/ 216 217 //OCULTAR MAS DE 5 ELEMENTOS EN EL MENU OTROS PROFESIONALES 218 var numEmenu = $('#block-menuotrosprofesionales > .menu-primario > li').length; 219 var liMenu = $('#block-menuotrosprofesionales > .menu-primario > li'); 220 221 /* 222 if(numEmenu > 6){ 223 $('#block-menuotrosprofesionales > .menu-primario > li:nth-child(n+11)').addClass("ver-mas-elements"); 224 $('#block-menuotrosprofesionales > .menu-primario > .ver-mas-elements').wrapAll('<li class="menu-item menu-ver-mas submenu"><ul class="ver-mas-open menu"></ul></li>'); 225 $('.ver-mas-open').before('<a href="#">Ver más</a>'); 226 $('.ver-mas-open').after("<span class='open-menu-header'><svg class='svg-icon right-icon' viewBox='0 0 20 20'> <path fill='none' d='M11.611,10.049l-4.76-4.873c-0.303-0.31-0.297-0.804,0.012-1.105c0.309-0.304,0.803-0.293,1.105,0.012l5.306,5.433c0.304,0.31,0.296,0.805-0.012,1.105L7.83,15.928c-0.152,0.148-0.35,0.223-0.547,0.223c-0.203,0-0.406-0.08-0.559-0.236c-0.303-0.309-0.295-0.803,0.012-1.104L11.611,10.049z'></path></svg></span>"); 227 } 228*/ 229 //En el menu de la barra header despliega los submenús 230 $('.open-menu-header').click(function(){ 231 $(this).parent('.submenu').toggleClass("open"); 232 $(this).siblings('.menu').toggleClass("open"); 233 $(this).toggleClass("open"); 234 }); 235 //Despliega el buscador del header 236 $('.open-search').click(function(){ 237 $(this).parent().find('*[id^="edit-keys"]').toggleClass("open"); 238 $('.account').toggleClass('hidden'); 239 $(this).toggleClass("open"); 240 $('#block-dmedico-branding').toggleClass("search-open"); 241 }); 242 //Cerramos el Sticky 243 $('.close-sticky').click(function(){ 244 $('.publicidad-sticky').removeClass('ready'); 245 }); 246 // Si hay sticky y tiene contenido mostramos la opción de cerrar el módulo a los 3 segundos 247 if($('.publicidad-sticky').length > 0){ 248 setTimeout(function(){ 249 if($('.publicidad-sticky .cont-publicidad').length > 0){ 250 $('.close-sticky').addClass('visible'); 251 } 252 }, 3000); 253 } 254 // si hay cover coge la altura de su main padre 255 if($('.cover-version').length > 0){ 256 var altoMain = $('.cover-version').parent( ".main" ).height(); 257 $('.grid-sky').css("height" , altoMain); 258 } 259 //BOTONES DE CARRUSEL QUE LANZAN LA LLAMADA A LA PUBLI 260 /*$(".slick-arrow").click(satellitegaleria()); 261 function satellitegaleria(){ 262 googletag.cmd.push(function() { 263 googletag.pubads().refresh(); 264 }); 265 //googletag.cmd.push(googletag.pubads().refresh()); 266 if(typeof _satellite != "undefined")_satellite.track('paginaVista'); 267 }*/ 268 269 //CAPAS DE LA PAGINA DE USUARIO PARA MOSTRAR EDITAR O PAGINA DE USUARIO 270 $(".edit-profile").click(function(){ 271 $('.user-page').toggleClass('visible'); 272 }); 273 274 //////////////////////////////////////////////// SECTORES ///////////////////////////////////////// 275 $('.open-sectores.grpd').click(function(){ 276 $('.sectores.grpd').toggleClass("hidden"); 277 }) 278 279 $('.open-sectores.secnews').click(function(){ 280 $('.sectores.secnews').toggleClass("hidden"); 281 }) 282 283 });//cierre document ready 284 285 Drupal.behaviors.dmMain = { 286 attach(context) { 287 288 once("dm-news-headline-focus", "body", context).forEach(() => { 289 if ($('body').hasClass('user-logged-in')) { 290 return; 291 } 292 293 var headline = document.querySelector('.cont-noticia .headline.page-title'); 294 var loginForm = document.querySelector('.cont-noticia .user-login-form'); 295 296 if (!headline || !loginForm) { 297 return; 298 } 299 300 if (!headline.hasAttribute('tabindex')) { 301 headline.setAttribute('tabindex', '-1'); 302 } 303 304 setTimeout(function() { 305 headline.focus(); 306 }, 0); 307 }); 308
309 //////////////////////////////////////////////// FORMULARIOS ///////////////////////////////////////// 310 once("dm-forms", "form", context).forEach((form) => { 311 312 $(form).find( ".text-field input, .select-field select" ).each(function (){ 313 var activeElement = document.activeElement; 314 if (activeElement.tagName === 'INPUT' || activeElement.tagName === "SELECT") { 315 activeElement.closest('.select-field, .text-field').classList.add("focused"); 316 } 317 318 if (($(this).val() != "" && $(this).prop("tagName") == 'INPUT') 319 || ($(this).find('option:selected').text() != '' && $(this).prop("tagName") == 'SELECT') 320 || $(this).attr('type') == 'date') { 321 $(this).closest('.select-field, .text-field').addClass("focused"); 322 } 323 }); 324 325 $(form).find( ".text-field input" ).on( "focus blur input change", function(e){ 326 327 var elem = $( this ).closest('.text-field'); 328 if ($(this).val()=="" && $(this).attr('type') != 'date') { 329 elem.removeClass("focused"); 330 } 331 else { 332 elem.addClass("focused"); 333 } 334 335 if($(this).is(":focus")) { 336 elem.addClass("focused"); 337 } 338 339 }); 340 341 $(form).on("focus blur change", ".select-field select", function(){ 342 var elem = $( this ).closest('.select-field'); 343 var hasValue = ($(this).val() || '') !== '' && ($(this).val() || '') !== '_none'; 344 elem.toggleClass("focused", hasValue || $(this).is(":focus")); 345 elem.toggleClass("wcont", hasValue); 346 }); 347 348 $(form).find(".view-pass").on("click", function(){ 349 var elem = $( this ).closest('.text-field'); 350 var input = elem.find('input'); 351 if (input.attr("type") === 'password') { 352 input.attr("type", "text"); 353 $(this).text("Ocultar"); 354 } 355 else { 356 input.attr("type", "password"); 357 $(this).text("Mostrar"); 358 } 359 }); 360
361 //////////////////////////////////////////////// FORMULARIO DE LOGIN ///////////////////////////////////////// 362 363 $(form).find(".user-login-form #edit-name").on("blur", function(){ 364 var nameValue = $( this ).val(); 365 var link = $('#edit-recover-pass a'); 366 367 if (!link.attr("data-href")) { 368 link.attr("data-href", link.attr('href')); 369 } 370 371 if (nameValue.length > 0) { 372 link.attr('href', link.attr("data-href") + "?name=" + nameValue); 373 } 374 else { 375 link.attr('href', link.attr("data-href")); 376 } 377 }); 378 }); 379 380 } 381 }; 382})(jQuery, Drupal, once,);
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.