1(function ($, Drupal) { 2 "use strict"; 3 4 jQuery(function () { 5 var excludeForms = 6 ":not(.view-general-search):not(.cern-view-display-resources):not(.cern-view-display-feature_events):not(.cern-view-display-past_events):not(.cern-view-display-all_news):not(.cern-view-display-faq_page):not(.cern-view-display-page_taxonomies):not(.resources-mosaic)"; 7 exposedForms(excludeForms); 8 }); 9 10 jQuery(window).resize(function () { 11 var excludeForms = 12 ":not(.view-general-search):not(.cern-view-display-resources):not(.cern-view-display-feature_events):not(.cern-view-display-past_events):not(.cern-view-display-all_news):not(.cern-view-display-faq_page):not(.cern-view-display-page_taxonomies):not(.resources-mosaic)"; 13 exposedForms(excludeForms); 14 }); 15 16 function exposedForms(excludeForms) { 17 var totalWidthForm = 0; 18 } 19 20 jQuery(window).resize(function () { 21 calculateWidthOfFormItems(); 22 }); 23 24 jQuery(function () { 25 calculateWidthOfFormItems(); 26 }); 27 28 /** 29 * Calculates the width of form items based on screen resolution 30 */ 31 function calculateWidthOfFormItems() { 32 if ($(window).width() > 1024) { 33 setWidthOfFormItems(1); 34 } else if ($(window).width() > 768) { 35 setWidthOfFormItems(2); 36 } else { 37 removeWidthOfFormItems(); 38 } 39 } 40 41 /** 42 * Removes the width of form items. Used in small resolutions in order to inherit the default values. 43 */ 44 function removeWidthOfFormItems() { 45 let form_elements = jQuery( 46 ".cern-view-display-page .views-exposed-form .form-inline .form-item" 47 ); 48 form_elements.each(function () { 49 jQuery(this).css("width", ""); 50 }); 51 } 52 53 /** 54 * Sets the width of form items based on how many rows the forms should expand. 55 * 56 * @param numberOfRows 57 */ 58 function setWidthOfFormItems(numberOfRows) { 59 let form_elements = jQuery( 60 ".cern-view-display-page .views-exposed-form .form-inline .form-item" 61 ); 62 let first_child = form_elements.first(); // the first child of the form elements 63 // if first exposed for is of type textfield 64 if (first_child.hasClass("form-type-textfield")) { 65 let rest_of_the_items = jQuery( 66 ".cern-view-display-page .views-exposed-form .form-inline .form-item:not(:first)" 67 ); 68 rest_of_the_items.each(function () { 69 let equal_width = (100 / rest_of_the_items.length) * numberOfRows; 70 jQuery(this) 71 .css("width", equal_width + "%") 72 .css("width", "-=23px"); 73 }); 74 } else { 75 form_elements.each(function () { 76 let equal_width = (100 / form_elements.length) * numberOfRows; 77 78 jQuery(this) 79 .css("width", equal_width + "%") 80 .css("width", "-=23px"); 81 }); 82 } 83 } 84 85 jQuery(function () { 86 carruselFillGaps(); 87 }); 88 89 jQuery(window).resize(function () { 90 clearFillGaps(); 91 carruselFillGaps(); 92 }); 93 94 function clearFillGaps() { 95 jQuery(":not(.ux-library) .cern-view-display-block").each(function () { 96 jQuery(this) 97 .find(".owl-carousel .owl-item") 98 .each(function () { 99 var itemWrapper = jQuery(this).find(".row"); 100 if (itemWrapper.find(".views-row").length < 3) { 101 itemWrapper.find(".views-row").each(function () { 102 jQuery(this).css("width", ""); 103 }); 104 } 105 }); 106 }); 107 } 108 109 function carruselFillGaps() { 110 if (jQuery(window).width() >= 992) { 111 var idCarrusel = 0; 112 jQuery( 113 ":not(.ux-library) .cern-view-display-block:not(.cern-view-display-story_resources):not(.resources-mosaic):not(.cern-view-display-upcoming_events):not(.events-collision)" 114 ).each(function () { 115 idCarrusel++; 116 jQuery(this) 117 .find(".owl-carousel .owl-item") 118 .each(function () { 119 var itemWrapper = jQuery(this).find(".row"); 120 121 if (itemWrapper.find(".views-row").length == 2) { 122 itemWrapper.find(".views-row").each(function () { 123 jQuery(this).css("width", "calc(50% - 16px)"); 124 }); 125 } 126 127 if (itemWrapper.find(".views-row").length == 1) { 128 itemWrapper.find(".views-row").each(function () { 129 jQuery(this).css("width", "calc(100% - 16px)"); 130 }); 131 } 132 }); 133 }); 134 } 135 } 136 137 //custom views : events collision 138 Drupal.behaviors.EventsCollision = { 139 attach: function (context, settings) { 140 /* Upcoming events carousel */ 141 142 jQuery(function () { 143 jQuery(".events-collision .view-content.owl-carousel").prepend( 144 '<button class="bubbly-button"></button>' 145 ); 146 }); 147 148 var bubblyTimeoutID = null; 149 var animateButton2 = function (item) { 150 //reset animation 151 if (bubblyTimeoutID) { 152 clearTimeout(bubblyTimeoutID); 153 } 154 item.removeClass("animate"); 155 156 setTimeout(function () { 157 item.addClass("animate"); 158 bubblyTimeoutID = setTimeout(function () { 159 item.removeClass("animate"); 160 }, 2000); 161 }, 100); 162 }; 163 164 $(".events-collision .view-content").each(function () { 165 if ($(this).find(".carousel-cern-item").length > 0) { 166 var owlCollision = $(this); 167 owlCollision.owlCarousel({ 168 loop: false, 169 nav: true, 170 navText: ["", ""], 171 dots: false, 172 merge: true, 173 mouseDrag: false, 174 items: 1, 175 itemElement: "carousel-cern-item", 176 autoHeight: false, 177 }); 178 // Apply the theme 179 owlCollision.addClass("owl-carousel").addClass("owl-theme"); 180 owlCollision.on("translate.owl.carousel", function (event) { 181 // var position = $('.owl-dot.active').position().left; 182 owlCollision.filter(".owl-dots .owl-dot:first-child span").animate( 183 { 184 // left: position - 5, 185 }, 186 200, 187 "linear" 188 ); 189 }); 190 191 // hidden the inactive slides on moves ending 192 owlCollision.on("translated.owl.carousel", function (event) { 193 jQuery(this) 194 .find(".owl-item:not(.active)") 195 .each(function () { 196 jQuery(this).css("opacity", "0"); 197 }); 198 }); 199 owlCollision.on("translate.owl.carousel", function (event) { 200 jQuery(this) 201 .find(".owl-item") 202 .each(function () { 203 jQuery(this).css("opacity", "1"); 204 }); 205 animateButton2( 206 jQuery(this).closest(".owl-carousel").find(".bubbly-button") 207 ); 208 }); 209 } 210 }); 211 }, 212 }; 213 214 // //custom views : resources mosaic 215 // Drupal.behaviors.ResourcesMosaic = { 216 // attach: function (context, settings) { 217 // jQuery(function () { 218 // jQuery(".resources-mosaic form.views-exposed-form .form-item:first-child").each(function () { 219 // var item = jQuery(this); 220 // var placeholder = item.find('label').text(); 221 // item.find('label').hide(); 222 // item.find('input').attr('placeholder', placeholder.toUpperCase()); 223 // }); 224 // }); 225 // } 226 // }; 227 228 //custom views : horizontal boxes 229 Drupal.behaviors.HorizontalBoxes = { 230 attach: function (context, settings) { 231 $(".horizontal-boxes .view-content").each(function () { 232 if ($(this).find(".carousel-cern-item").length > 0) { 233 var owlHorizontal = $(this); 234 owlHorizontal.owlCarousel({ 235 loop: false, 236 nav: false, 237 navText: ["", ""], 238 dots: true, 239 merge: true, 240 mouseDrag: false, 241 items: 1, 242 itemElement: "carousel-cern-item", 243 autoHeight: false, 244 }); 245 // extend elements on the last slide 246 owlHorizontal.on("initialized.owl.carousel", function (e) {}); 247 // Apply the theme 248 owlHorizontal.addClass("owl-carousel").addClass("owl-theme"); 249 owlHorizontal.on("translate.owl.carousel", function (event) { 250 // var position = $('.owl-dot.active').position().left; 251 owlHorizontal.filter(".owl-dots .owl-dot:first-child span").animate( 252 { 253 // left: position - 5, 254 }, 255 200, 256 "linear" 257 ); 258 if ($(window).width() >= 992) { 259 var idCarrusel = 0; 260 $(".horizontal-boxes .view-content").each(function () { 261 idCarrusel++; 262 $(this) 263 .find(".owl-item") 264 .each(function () { 265 var itemWrapper = $(this).find(".row"); 266 267 if (itemWrapper.find(".views-row").length == 2) { 268 itemWrapper.find(".views-row").each(function () { 269 $(this).css("width", "calc(50% - 16px)"); 270 }); 271 } 272 273 if (itemWrapper.find(".views-row").length == 1) { 274 itemWrapper.find(".views-row").each(function () { 275 $(this).css("width", "calc(100% - 16px)"); 276 }); 277 } 278 }); 279 }); 280 } 281 if ($(window).width() < 992) { 282 var idCarrusel = 0; 283 $(".horizontal-boxes .view-content").each(function () { 284 idCarrusel++; 285 $(this) 286 .find(".owl-item") 287 .each(function () { 288 var itemWrapper = $(this).find(".row"); 289 290 if (itemWrapper.find(".views-row").length == 2) { 291 itemWrapper.addClass("last-2"); 292 itemWrapper.find(".views-row").each(function () { 293 $(this).css("height", "50vh"); 294 }); 295 } 296 297 if (itemWrapper.find(".views-row").length == 1) { 298 itemWrapper.addClass("last-1"); 299 itemWrapper.find(".views-row").each(function () { 300 $(this).css("height", "100vh"); 301 }); 302 } 303 }); 304 }); 305 } 306 }); 307 308 // hidden the inactive slides on moves ending 309 owlHorizontal.on("translated.owl.carousel", function (event) { 310 jQuery(this) 311 .find(".owl-item:not(.active)") 312 .each(function () { 313 jQuery(this).css("opacity", "0"); 314 }); 315 }); 316 owlHorizontal.on("translate.owl.carousel", function (event) { 317 jQuery(this) 318 .find(".owl-item") 319 .each(function () { 320 jQuery(this).css("opacity", "1"); 321 }); 322 }); 323 } 324 }); 325 }, 326 }; 327 328 //custom views : teaser list 329 Drupal.behaviors.TeaserList = { 330 attach: function (context, settings) { 331 jQuery(function () { 332 var items = 0; 333 var cintval = setInterval(function () { 334 items = jQuery( 335 ".teaser-list .views-exposed-form .form-item:first-child" 336 ); 337 if (items.length > 0) { 338 jQuery(".teaser-list .form-item:first-child").each(function () { 339 var placeholder = jQuery(this).find("label").text(); 340 // jQuery(this).find('label').hide(); 341 // jQuery(this).find('input').attr('placeholder', placeholder.toUpperCase()); 342 }); 343 clearInterval(cintval); 344 } 345 }, 500); 346 }); 347 }, 348 }; 349 350 //custom views : resources mosaic 351 Drupal.behaviors.ResourcesMosaic = { 352 attach: function (context, settings) { 353 $(".resources-mosaic .view-content").each(function () { 354 if ($(this).find(".carousel-cern-item").length > 0) { 355 var owlViews = $(this); 356 owlViews.owlCarousel({ 357 loop: false, 358 nav: false, 359 merge: true, 360 mouseDrag: false, 361 items: 1, 362 itemElement: "carousel-cern-item", 363 autoHeight: true, 364 }); 365 // Apply the theme 366 owlViews.addClass("owl-carousel").addClass("owl-theme"); 367 owlViews.on("translate.owl.carousel", function (event) { 368 var position = $(".owl-dot.active").position().left; 369 owlViews.filter(".owl-dots .owl-dot:first-child span").animate( 370 { 371 left: position - 5, 372 }, 373 200, 374 "linear" 375 ); 376 }); 377 // hidden the inactive slides on moves ending 378 owlViews.on("translated.owl.carousel", function (event) { 379 jQuery(this) 380 .find(".owl-item:not(.active)") 381 .each(function () { 382 jQuery(this).css("opacity", "0"); 383 }); 384 }); 385 owlViews.on("translate.owl.carousel", function (event) { 386 jQuery(this) 387 .find(".owl-item") 388 .each(function () { 389 jQuery(this).css("opacity", "1"); 390 }); 391 }); 392 393 var maxHeight = 0; 394 owlViews.find(".views-row").each(function () { 395 maxHeight = 396 $(this).height() > maxHeight ? $(this).height() : maxHeight; 397 }); 398 owlViews 399 .find(".views-row") 400 .find("> div") 401 .css("height", maxHeight + "px"); 402 } 403 }); 404 405 $(function () { 406 setTimeout(function () { 407 jQuery(".view.cern-view-display-block .view-content").each( 408 function () { 409 if (jQuery(this).find(".carousel-cern-item").length > 0) { 410 var owlViews = jQuery(this); 411 owlViews.trigger("refresh.owl.carousel"); 412 } 413 } 414 ); 415 }, 2500); 416 }); 417 jQuery(function () { 418 jQuery(".resources-mosaic .view-content .views-row").each(function () { 419 var element = jQuery(this); 420 var item = jQuery(this).find(".box-pattern").css("background-image"); 421 if (item.indexOf("cds.cern.ch") >= 0) { 422 item = jQuery(this).find(".box-pattern").data("background"); 423 element 424 .find(".box-pattern") 425 .append( 426 '<a href="' + 427 item + 428 '" class="group-story-resources cboxElement cbox-element"></a>' 429 ); 430 } else { 431 item = item 432 .replace("url(", "") 433 .replace(")", "") 434 .replace(/\"/gi, ""); 435 element 436 .find(".box-pattern") 437 .append( 438 '<a href="' + 439 item + 440 '" class="group-story-resources cboxElement cbox-element"></a>' 441 ); 442 } 443 }); 444 445 jQuery(".resources-mosaic").each(function () { 446 var firstItem = jQuery(this).find(".views-row").first(); 447 var firstBG = firstItem.find("a.cboxElement").attr("href"); 448 var textViewSlideshow = jQuery(this).find(".view-header p").text(); 449 jQuery(this) 450 .find(".view-header p") 451 .html( 452 '<a href="' + 453 firstBG + 454 '" class="group-story-resources cboxElement cbox-element-page">' + 455 textViewSlideshow + 456 "</a>" 457 ); 458 firstItem.find("a.cboxElement").removeClass("group-story-resources"); 459 }); 460 461 $("a.group-story-resources").colorbox({ 462 rel: "group-story-resources", 463 transition: "none", 464 width: "70%", 465 height: "70%", 466 scrolling: false, 467 opacity: "0.9", 468 photo: true, 469 onComplete: function () {}, 470 onCleanup: function () {}, 471 }); 472 473 var ua = navigator.userAgent, 474 event = ua.match(/iPad/i) ? "touchstart" : "click"; 475 jQuery(".resources-mosaic").on( 476 event, 477 " .view-content .owl-item .views-row .box-pattern", 478 function () { 479 location.href = jQuery(this) 480 .find(".preview-card__title a") 481 .attr("href"); 482 } 483 ); 484 }); 485 }, 486 }; 487})(jQuery, Drupal);
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.