1(function ($, Drupal) { 2 "use strict"; 3 4 $(function () { 5 var bodyH = $("body").height(); 6 var windowH = $(window).height(); 7 8 // $("#cern-global-loading-layout").hide(); 9 10 if (jQuery("#cern-toolbar").length > 0) { 11 jQuery("body").addClass("cern-toolbar"); 12 } 13 14 //sticky header 15 if (bodyH > windowH) { 16 var diffH = bodyH - windowH; 17 if (diffH > 85) { 18 if ($(window).scrollTop() > 1) { 19 $("body").addClass("sticky-header"); 20 //animatePaddingTop("body.sticky-header main", 45); 21 } else { 22 $("body").removeClass("sticky-header"); 23 //animatePaddingTop("body.sticky-header main", 0); 24 } 25 } 26 27 if (diffH < 130) { 28 $("body").addClass("not-enougth-scroll"); 29 } 30 $(window).scroll(function () { 31 if ($(this).scrollTop() > 1) { 32 $("body").addClass("sticky-header"); 33 } else { 34 $("body").removeClass("sticky-header"); 35 } 36 }); 37 /* } else { 38 $(window).scroll(function () { 39 jQuery('body').addClass("nosticky-header"); 40 if (jQuery(window).scrollTop() > 40) { 41 jQuery('body').addClass("nosticky-header-hide-toolbar"); 42 } else { 43 jQuery('body').removeClass("nosticky-header-hide-toolbar"); 44 } 45 }); 46 } */ 47 } 48 49 // has header 50 if ($(".component-row__has-header").length > 0) { 51 $("body").addClass("has-header"); 52 } 53 54 // MAIN MENU active father 55 if (jQuery("nav.main-menu .dropdown-menu").length > 0) { 56 jQuery("nav.main-menu .dropdown-menu li a.is-active").each(function () { 57 jQuery(this).closest("li.dropdown").find(">a").addClass("is-active"); 58 }); 59 } 60 }); 61 62 //sticky header 63 $(window).scroll(function () { 64 var bodyH = $("body").height(); 65 var windowH = $(window).height(); 66 if (bodyH > windowH) { 67 var diffH = bodyH - windowH; 68 69 if (diffH > 85) { 70 // $(window).scroll(function () { 71 if ($(this).scrollTop() > 1) { 72 $("body").addClass("sticky-header"); //toolbar-fixed 73 //animatePaddingTop("body.sticky-header main", 45); 74 $("body").addClass("toolbar-fixed"); 75 } else { 76 $("body").removeClass("sticky-header"); 77 //animatePaddingTop("body.sticky-header main", 0); 78 //$('body').removeClass("toolbar-fixed"); 79 } 80 //}); 81 } else { 82 //$(window).scroll(function () { 83 jQuery("body").addClass("nosticky-header"); 84 if (jQuery(window).scrollTop() > 40) { 85 jQuery("body").addClass("nosticky-header-hide-toolbar"); 86 } else { 87 jQuery("body").removeClass("nosticky-header-hide-toolbar"); 88 jQuery("body").removeClass("sticky-header"); 89 //animatePaddingTop("body.sticky-header main", 0); 90 } 91 // }); 92 } 93 } 94 }); 95 96 /* function animatePaddingTop(item, amount) { 97 $(item).stop().animate({ 98 'padding-top' : amount 99 }, 300); 100 } */ 101 102 /* jQuery(window).scroll(function () { 103 if (jQuery("body").hasClass("toolbar-fixed")) { 104 jQuery("#toolbar-administration").css("top", "0"); 105 } 106 }); */ 107 108 // ckeditor classes 109 if ($(".img-left").length > 0) { 110 $(".img-left").each(function () { 111 $(this).next().addClass("img-left"); 112 $(this).remove(); 113 }); 114 } 115 if ($(".img-right").length > 0) { 116 $(".img-right").each(function () { 117 $(this).next().addClass("img-right"); 118 $(this).remove(); 119 }); 120 } 121 if ($(".img-clear").length > 0) { 122 $(".img-clear").each(function () { 123 $(this).next().addClass("img-clear"); 124 $(this).remove(); 125 }); 126 } 127 if ($(".img-clear-right").length > 0) { 128 $(".img-clear-right").each(function () { 129 $(this).before('<div class="div-clear-right"></div>'); 130 $(this).next().addClass("img-clear-right"); 131 $(this).next().after('<div class="div-clear-right"></div>'); 132 $(this).remove(); 133 }); 134 } 135 if ($(".img-clear-center").length > 0) { 136 $(".img-clear-center").each(function () { 137 $(this).next().addClass("img-clear-center"); 138 $(this).remove(); 139 }); 140 } 141 142 // textarea animation 143 if ($("textarea.form-control").length > 0) { 144 var textareaHeight = $("textarea.form-control").height(); 145 $("textarea.form-control").each(function () { 146 $("textarea.form-control").css("height", "35px"); 147 }); 148 $("textarea.form-control").focus(function () { 149 $(this).animate( 150 { 151 height: textareaHeight, 152 }, 153 400 154 ); 155 }); 156 $("textarea.form-control").blur(function () { 157 $(this).animate( 158 { 159 height: 35, 160 }, 161 400 162 ); 163 }); 164 } 165 166 // language dropdown 167 if ($("#language").length > 0) { 168 } 169 170 // Slider auto-height FIX 171 // - The slider do not initialize with the height of his first slide 172 $(function () { 173 setTimeout(function () { 174 var firstItem = $(".owl-stage-outer.owl-height .owl-item.active"); 175 $(".owl-stage-outer.owl-height").css("height", firstItem.height()); 176 }, 1000); 177 }); 178 179 // Header menu mobile background fill on expand 180 $("header").on("click", ".navbar-header button.navbar-toggle", function () { 181 if ($(this).hasClass("collapsed")) { 182 $("header").addClass("menu-expanded"); 183 } else { 184 $("header").removeClass("menu-expanded"); 185 } 186 }); 187 188 // cds image loading 189 if ($('img[src*="cds.cern.ch"]').length > 0) { 190 $.each($('img[src*="cds.cern.ch"]'), function () { 191 $(this).closest("figure").css("height", "100%"); 192 $(this).closest("figure").css("position", "relative"); 193 $(this).closest("figure").addClass("loading-cds"); 194 }); 195 } 196 $(function () { 197 jQuery("figure.cds-image img").each(function () { 198 if (jQuery(this).prop("complete")) { 199 jQuery(this).prev("span").addClass("cds-background-hidden"); 200 jQuery(this).closest("figure").removeClass("loading-cds"); 201 } 202 }); 203 204 $.each($('img[src*="cds.cern.ch"]'), function () { 205 if (jQuery(this).prop("complete")) { 206 jQuery(this) 207 .prev("span.cds-background") 208 .addClass("cds-background-hidden"); 209 jQuery(this).parent().removeClass("loading-cds"); 210 } 211 }); 212 }); 213 jQuery("figure.cds-image img") 214 .on("load", function () { 215 jQuery(this).prev("span").addClass("cds-background-hidden"); 216 jQuery(this).prev("span").find(".cds-img-error").hide(); 217 jQuery(this).closest("figure").removeClass("loading-cds"); 218 jQuery(this).closest("figure").removeClass("loading-cds-error"); 219 }) 220 .on("error", function () { 221 jQuery(this).prev("span").removeClass("cds-background-hidden"); 222 jQuery(this).closest("figure").addClass("loading-cds-error"); 223 }); 224 225 jQuery('img[src*="cds.cern.ch"]') 226 .on("load", function () { 227 jQuery(this) 228 .prev("span.cds-background") 229 .addClass("cds-background-hidden"); 230 jQuery(this).prev("span").find(".cds-img-error").hide(); 231 jQuery(this).parent().removeClass("loading-cds"); 232 jQuery(this).parent().removeClass("loading-cds-error"); 233 }) 234 .on("error", function () { 235 jQuery(this) 236 .prev("span.cds-background") 237 .removeClass("cds-background-hidden"); 238 jQuery(this).parent().addClass("loading-cds-error"); 239 }); 240 241 // ckeditor cern icon 242 if (jQuery(".cern_full_html").length > 0) { 243 jQuery(".cern_full_html span").each(function () { 244 if ( 245 jQuery(this).css("font-family") == "CernIcons, CernIcons, cern-icons" 246 ) { 247 jQuery(this).closest("a").addClass("linked-cern-icons"); 248 } 249 }); 250 } 251 252 // check if CERN tollbar is ON and put a class on the body 253 jQuery(window).on("load", function (event) { 254 if (jQuery("#cern-toolbar").length > 0) { 255 jQuery("body").addClass("cern-toolbar"); 256 } 257 }); 258 259 // main menu responsive menu scrolling 260 if (jQuery(".main-menu").length > 0) { 261 jQuery(".main-menu").each(function () { 262 jQuery(this) 263 .find(".navbar-toggle") 264 .click(function () { 265 var menuExpanded = jQuery(this).attr("aria-expanded"); 266 if (menuExpanded == "false") { 267 jQuery("body").css("overflow", "hidden"); 268 } 269 if (menuExpanded == "true") { 270 jQuery("body").css("overflow", "initial"); 271 } 272 }); 273 }); 274 } 275 276 // check if ADMIN tollbar is ON 277 if (jQuery("#toolbar-bar").length > 0) { 278 jQuery(".toolbar-item").each(function () { 279 var ToolbarItem = $(this).text().toLowerCase(); 280 $(this).addClass(ToolbarItem); 281 }); 282 } 283 284 // tabs with has-header + is_half_height 285 jQuery(function () { 286 if ( 287 jQuery( 288 ".has-header .layout__region--content .field--items .field--item:first-child .is_half_height" 289 ).length > 0 290 ) { 291 var headerHeight = jQuery( 292 ".has-header .layout__region--content .field--items .field--item:first-child .is_half_height .cern-component-header-blocks.component-header" 293 ).height(); 294 var headerHeight = headerHeight - 25;
295 jQuery(".region-content>.tabs").css("top", headerHeight); 296 } 297 }); 298 299 // 300 jQuery(function () { 301 marginForSocialIcons(); 302 }); 303 jQuery(window).resize(function () { 304 marginForSocialIcons(); 305 }); 306 307 function marginForSocialIcons() { 308 if (jQuery(window).width() >= 1072) { 309 if ( 310 jQuery( 311 "body:not(.page-node-type-story-page):not(.page-node-type-faq-page):not(.page-node-type-landing-page) .block-social-sharing-block" 312 ).length > 0 313 ) { 314 jQuery("main").css("padding-left", "4%"); 315 } 316 } else { 317 if ( 318 jQuery( 319 "body:not(.page-node-type-story-page):not(.page-node-type-faq-page):not(.page-node-type-landing-page) .block-social-sharing-block" 320 ).length > 0 321 ) { 322 jQuery("main").css("padding-left", "0"); 323 } 324 } 325 } 326 327 jQuery(function () { 328 jQuery(".component-preview-cards .preview-card__author a").each( 329 function () { 330 jQuery(this).removeAttr("href"); 331 } 332 ); 333 }); 334 335 // cern toolbar without admin toolbar 336 if ($("#toolbar-administration").length > 0) { 337 } else { 338 $("#cern-toolbar").css("top", "0"); 339 $("#cern-toolbar").css("opacity", "1"); 340 $("body").addClass("no-admin-toolbar"); 341 } 342 343 // header without cern toolbar AND without admin toolbar 344 if ( 345 $("#toolbar-administration").length == 0 && 346 $("#cern-toolbar").length == 0 347 ) { 348 $("header").css("top", "0"); 349 } 350})(jQuery, Drupal); 351 352function openSearch() { 353 document.getElementById("cern-search-overlay").classList.add("active"); 354} 355 356function closeSearch() { 357 document.getElementById("cern-search-overlay").classList.remove("active"); 358}
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.