1/** 2 * @file 3 * Global utilities. 4 * 5 */ 6(function ($, Drupal) { 7 8 'use strict'; 9 10 Drupal.behaviors.barrio_custom = { 11 attach: function (context, settings) { 12 13 $('.traductor').each(function(){ 14 $(this).find('.notraslate').addClass('btn','btn-primary'); 15 $(this).find('.google-translator-switch').html('ES'); 16 }) 17 18 $(document).ready(function () { 19 20 // $('main', context).once('barrio_custom').each(function () { 21 // moveFiltersSearch(); 22 // clickFilter(); 23 // }); 24 25 26 resouercesInterchange(); 27 blockaliados(); 28 blockContentMoreSm(); 29 change_http(); 30 eduutubersCarousel(); 31 edutubersforo(); 32 //Acciones buscador 33 $("#views-exposed-form-buscador-page-1 #edit-label").focus(function () { 34 $("#views-exposed-form-buscador-page-1 .btn-clear").removeClass('d-none'); 35 }); 36 37 // $( "#views-exposed-form-buscador-page-1 #edit-label" ).focusout(function() { 38 // }); 39 40 $("#views-exposed-form-buscador-page-1 .btn-clear").click(function () { 41 $("#views-exposed-form-buscador-page-1 #edit-label").val(""); 42 $("#views-exposed-form-buscador-page-1 .btn-clear").addClass('d-none'); 43 }); 44 45 //Funcionalidad barra de accesibilidad 46 var letterMin = $('.icon-a-less'); 47 var letterMax = $('.icon-a-more'); 48 var letterReset = $('.icon-a-reset'); 49 var mood = 1; 50 var size = parseInt(getComputedStyle(document.documentElement).fontSize); 51 52 //Contraste 53 $('.icon-contrast').click(function () { 54 if (mood == 1) { 55 $('html').addClass('set_contrast'); 56 mood++; 57 } else { 58 $('html').removeClass('set_contrast'); 59 mood--; 60 } 61 }); 62 63 //reducir letra 64 letterMin.click(function () { 65 if (size > 8) { 66 size--; 67 $("div").css({ 68 fontSize: size 69 }); 70 71 } 72 }); 73 74 //Aumentar Letra 75 letterMax.click(function () { 76 console.log(size); 77 if (size < 30) { 78 size++; 79 $("div").css({ 80 fontSize: size 81 }); 82 } 83 }); 84 85 //Restaurar Letra 86 letterReset.click(function () { 87 $("div").css({ 88 fontSize: '' 89 }); 90 }); 91 92 93 }); 94 95 function change_http() { 96 const listItemFile = document.querySelectorAll(".field__item .file a"); 97 98 // console.debug(listItemFile); 99 100 for (var b = 0; b < listItemFile.length; b++) { 101 listItemFile[b].href = listItemFile[b].href.replace("http://", "https://"); 102 } 103 104 } 105 106 function blockContentMoreSm() { 107 var owl3 = $('.block-content-more-small .items'); 108 109 if (owl3.length > 0) { 110 owl3.addClass('owl-carousel'); 111 owl3.owlCarousel({ 112 loop: false, 113 items: 1, 114 nav: true, 115 dots: false, 116 margin: 20, 117 center: true, 118 // autoplay:true, 119 // autoplayTimeout:5000, 120 responsive: { 121 0: { 122 mouseDrag: true, 123 touchDrag: true, 124 items: 2 125 }, 126 768: { 127 mouseDrag: true, 128 touchDrag: true, 129 items: 2 130 }, 131 992: { 132 mouseDrag: true, 133 touchDrag: false, 134 items: 2 135 } 136 } 137 }); 138 } 139 } 140 141 142 //Edutubers carousel 143 function eduutubersCarousel() { 144 var owl_edutubers = $('.view-foro-edutubers .view-content'); 145 146 owl_edutubers.each(function (index) { 147 var owl_edutubers_items = $(this).children('.views-row'); 148 if (owl_edutubers_items.length > 3) { 149 $(this).addClass('owl-carousel col-md-8 m-auto'); 150 $(this).owlCarousel({ 151 loop: true, 152 items: 3, 153 slideBy: 3, 154 nav: true, 155 dots: true, 156 responsive: { 157 0: { 158 mouseDrag: false, 159 touchDrag: true, 160 items: 1, 161 dots: true, 162 }, 163 768: { 164 mouseDrag: false, 165 touchDrag: true, 166 items: 2, 167 dots: true, 168 slideBy: 2, 169 }, 170 1460: { 171 mouseDrag: false, 172 touchDrag: true, 173 items: 3, 174 dots: true, 175 slideBy: 3, 176 }, 177 } 178 }); 179 180 owl_edutubers.each(function () { 181 $(this).find('.owl-nav').addClass('nav_edutubers'); 182 $(this).find('.owl-dots').addClass('dots_edutubers'); 183 184 }); 185 owl_edutubers.find('.owl-dots ').each(function () { 186 $(this).find('button span').each(function (index) { 187 $(this).html(index + 1);
188 $(this).addClass('fs-light'); 189 }); 190 }); 191 192 } 193 }); 194 195 } 196 function edutubersforo() { 197 198 199 200 201 202 203 $('.comment-comentarios-edutubers-form #edit-submit').html('Participa >'); 204 $('.comment-comentarios-edutubers-form .form-item-name input').attr('type', 'email'); 205 $('.comment-comentarios-edutubers-form .form-item-name input').attr('required', 'true'); 206 $('.node--type-foro-edutubers .comment .comment__content ').each(function () { 207 $(this).removeClass('col-10'); 208 $(this).addClass('col-12'); 209 }); 210 $('.comment-comentarios-edutubers-form .form-item-field-rol').once('admin_select').each(function () { 211 var origin = window.location.origin + "/user-edutuber"; 212 $.get(origin, function (data) { 213 if (data.length > 0) { 214 var rol = data[0]['roles_target_id'].split(','); 215 var admin = false; 216 $.each(rol, function (element) { 217 if (rol && rol[element] == 'Administrator' || rol[element] == 'Administrador foro') { 218 $('.comment-comentarios-edutubers-form .form-item-field-rol select').val('Administrador foro'); 219 $('.comment-comentarios-edutubers-form .form-item-field-rol ').css("display", "none"); 220 admin = true; 221 } if (admin == false) { 222 $('.comment-comentarios-edutubers-form .form-item-field-rol select option[value="Administrador foro"]').remove(); 223 } 224 }); 225 } else { 226 $('.comment-comentarios-edutubers-form .form-item-field-rol select option[value="Administrador foro"]').remove(); 227 } 228 229 }); 230 }); 231 $('.node--type-foro-edutubers .comment__author span ').once('edutubers-correo').each(function () { 232 var correo = $(this).html().split("@").slice(0, -1); 233 if (correo[0]) { 234 $(this).text(correo); 235 } 236 }); 237 var comentarioRespuesta = $('.comment-comentarios-edutubers-form') 238 if (comentarioRespuesta) { 239 comentarioRespuesta.find('.form-item-name label').html('Firme su comentario con su correo'); 240 var respuesta = $('.path-comment') 241 if (respuesta) { 242 respuesta.addClass('respuesta_edutuber'); 243 } 244 } 245 246 247 } 248 //CAROUSEL INICIO 2 249 250 251 //FIN CAROUSEL INICIO 2 252 253 function blockaliados() { 254 var owl4 = $('.view-aliados .view-content'); 255 owl4.addClass('owl-carousel'); 256 257 if (owl4.length > 0) { 258 owl4.owlCarousel({ 259 loop: true, 260 items: 3, 261 nav: true, 262 dots: false, 263 // autoplay:true, 264 // autoplayTimeout:5000, 265 responsive: { 266 0: { 267 mouseDrag: false, 268 touchDrag: true, 269 items: 1 270 }, 271 768: { 272 mouseDrag: false, 273 touchDrag: true, 274 items: 2 275 }, 276 992: { 277 mouseDrag: true, 278 touchDrag: false, 279 items: 4 280 } 281 } 282 }); 283 284 owl4.each(function () { 285 $(this).find('.owl-prev span').each(function (index) { 286 $(this).attr('aria-label', 'Anterior'); 287 }); 288 289 $(this).find('.owl-next span').each(function (index) { 290 $(this).attr('aria-label', 'Siguiente'); 291 }); 292 }); 293 } 294 } 295 296 $(".owl-nav").each(function() { 297 $(this).find('.owl-prev').each(function(index) { 298 $(this).attr('aria-label', 'Anterior'); 299 $(this).attr('title','Carousel atrás'); 300 $(this).attr('alt','Carousel atrás'); 301 }); 302 303 $(this).find('.owl-next').each(function(index) { 304 $(this).attr('aria-label', 'Siguiente'); 305 $(this).attr('title','Carousel siguiente'); 306 $(this).attr('alt','Carousel siguiente'); 307 308 }); 309 }); 310 311 function clickFilter() { 312 var clicked = false;
313 $('.filter-head-facet').click(() => { 314 clicked = !clicked; 315 if (clicked) { 316 $('.block-category-content-list').hide(); 317 $('.block-public-content-facet').hide(); 318 $('.block-type-content-facet').hide(); 319 } else { 320 $('.block-category-content-list').show(); 321 $('.block-public-content-facet').show(); 322 $('.block-type-content-facet').show(); 323 } 324 }); 325 } 326 327 function moveFiltersSearch() { 328 var formfilter = $('#views-exposed-form-contenidos-new-page-1'); 329 var results = $('.view-header'); 330 var form = $('#views-exposed-form-contenidos-new-page-1'); 331 332 var div = $("<div id='search-input'></div>"); 333 var button = $('#edit-submit-contenidos-new'); 334 var input = $('#edit-aggregated-field-content'); 335 336 var flag = $('.button-bookmark'); 337 338 339 $('.featured-top').prepend(form); 340 $('.featured-top').prepend(flag); 341 $('.featured-top').prepend(results); 342 343 div.prepend(input); 344 div.prepend(button); 345 formfilter.find('.js-form-type-textfield').prepend(div); 346 347 //$('.featured-top').find('a').not('.is-active)').remove(); 348 349 //funciones responsive 350 if ($(window).width() <= 768) { 351 var morecontent = $("#block-mascontenidos-2"); 352 var title = $('#block-titulodecontenidos'); 353 354 $('.featured-top').prepend(title); 355 $('.featured-top').prepend(morecontent); 356 357 var facetcat = $('.block-category-content-clicked'); 358 var facetype = $('.block-type-content-clicked'); 359 var facepublic = $('.block-public-content-clicked'); 360 361 $('.featured-top').append(facetcat); 362 $('.featured-top').append(facetype); 363 $('.featured-top').append(facepublic); 364 365 var urlf = flag.find('a').attr('href'); 366 flag.click(() => { 367 window.location = urlf; 368 }); 369 370 } 371 372 $('#edit-sort-by').change(() => { 373 formfilter.submit(); 374 }) 375 376 $('#edit-items-per-page').change(() => { 377 formfilter.submit(); 378 }) 379 }; 380 381 function metaTagImg() { 382 var images = $('.data-image'); 383 $.each(images, function (key, value) { 384 var image = $(this).attr('data-image');
385 $(this).css('background-image', "url('" + image + "')"); 386 }); 387 388 } 389 //Para recursos permite cambiar el titulo por un contaniedo que solicitaron 390 function resouercesInterchange() { 391 var field = $('.field--name-field-coleccion'); 392 393 if (field.length > 0) { 394 395 var title_text = $('h1.title').text(); 396 var filed_html = field.html(); 397 $('h1.title').html(filed_html); 398 field.html(title_text); 399 } 400 401 } 402 403 } 404 }; 405 406})(jQuery, Drupal); 407 408 409 410// Adds the first empty card on Experiencias content type node' 411(function ($, Drupal, window, document, undefined) { 412 const nodeTitleOnFirtsCard = ` 413 <div class="empty-card"> 414 <a href="/">< Volver al menú anterior</a> 415 </div> 416 `; 417 $(".field--name-field-tarjeta").prepend(nodeTitleOnFirtsCard); 418 $(".field--name-field-grupo-recursos").append(nodeTitleOnFirtsCard); 419 420})(jQuery, Drupal, this, this.document);
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.