1let migvimeoplayer = function () { 2 3 4 let dseUrl = window.dseData.url; 5 6 7 8 // CREATE SCRIPT 9 const docHeader = document.getElementsByTagName("head")[0]; 10 let vimeoPy = document.createElement('script'); 11 12 vimeoPy.setAttribute("src", 'https://player.vimeo.com/api/player.js'); 13 vimeoPy.setAttribute("type", 'text/javascript'); 14 15 docHeader.appendChild(vimeoPy); 16 17 //AFTER THE SCRIPT WAS LOADED, RUN THE VIMEO FUNCTION 18 window.addEventListener("load", function (e) { 19 20 21 22 // GET ALL DOCUMENT SELECTORS AND CREATE A VIDEO PLAYER FOR EACHONE 23 let playerContainers = document.querySelectorAll('.divi_se_vimeobg'); 24 25 window.mobileAndTabletCheck = function() { 26 let check = false; 27 (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera); 28 return check; 29 }; 30 playerContainers.forEach(function (thisContainer) { 31 var allData = JSON.parse(thisContainer.getAttribute("data-vimeobg")); 32 var fallback = false; 33 var fallsource = allData.fallsource; 34 var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 35 36 if(fallsource == 'some' && iOS == true){ 37 fallback = true; 38 } 39 if(fallsource == 'all' && document.querySelector('body').classList.contains('et_mobile_device')){ 40 fallback = true; 41 } 42 43 44 45 if(!fallback){ 46 // GET GENERAL SIZES TO ADJUST VALUES LATER DEPENDING ON USER SELECTION 47 let playerContainerWidth = thisContainer.offsetWidth; 48 let playerContainerHeight = thisContainer.offsetHeight; 49 let screenHeight = window.screen.availHeight; 50 51 52 // CREATE AN OUTER AN INNER WRAPPER TO ADJUST THE SIZE TO CONTAINER AND ALSO OVERSIZE THE INNER ONE 53 let videoOuterWrapper = document.createElement("div"); 54 videoOuterWrapper.setAttribute("class", "mig-vimeo-outer-wrapper"); 55 56 57 let vimeoWrapper = document.createElement("div"); 58 vimeoWrapper.setAttribute("class", "mig-vimeo-wrapper"); 59 60 let vimeoOverlay = document.createElement("div"); 61 vimeoOverlay.setAttribute("class", "mig-vimeo-overlay"); 62 63
64 thisContainer.prepend(videoOuterWrapper); 65 66 videoOuterWrapper.prepend(vimeoWrapper); 67 videoOuterWrapper.prepend(vimeoOverlay); 68 69 70 let defaultoptions = { 71 id: "15069551", 72 width: playerContainerWidth, 73 autopause: false, 74 autoplay: true, 75 byline: false, 76 controls: false, 77 height: null, 78 loop: true, 79 maxheight: null, 80 maxwidth: null, 81 playsinline: true, 82 portrait: false, 83 muted: true, 84 title: false, 85 transparent: true, 86 speed: false, 87 }; 88 89 let data, customoptions = {}; 90 if (thisContainer.getAttribute("data-vimeobg") !== null) { 91 data = JSON.parse(thisContainer.getAttribute("data-vimeobg")); 92 customoptions = JSON.parse(thisContainer.getAttribute("data-vimeobg")); 93 delete customoptions.widthT; 94 delete customoptions.widthP; 95 delete customoptions.preloader; 96 97 98 99 // create variable to notify vimeo events when is neccesary apply preloader 100 101 if (data.preloader !== "none" && data.preloader !== undefined) { 102 103 104 customoptions.autoplay = false; 105 let vimeoLoader = document.createElement("div"); 106 vimeoLoader.setAttribute("class", "mig-vimeo-loader"); 107 if (data.preloader !== "black") { 108 vimeoLoader.style.backgroundImage = `url("${dseUrl}/dse-functions/images/${data.preloader}.gif")`; 109 } 110 111 videoOuterWrapper.appendChild(vimeoLoader); 112 } 113 114 115 // FIRST WE ADJUST VALUES DEPENDING ON SCREEN WIDTH 116 if (playerContainerWidth < 980) { 117 118 // adjust preloader position on mobile devices to prevent wrong display on large sections 119 if (thisContainer.querySelector(".mig-vimeo-loader")) { 120 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundPositionY = `${screenHeight / 2}px`; 121 } 122 123 (data.widthP) ? customoptions.width = data.widthP : customoptions.width = data.width; 124 } 125 126 127 // ADJUST VIDEO HEIGHT AND WIDTH 128 if (customoptions.width == "height" || customoptions.width == "regularheight") { 129 let overSizeWidth = playerContainerHeight * 2.65; 130 if(overSizeWidth <= playerContainerWidth){ 131 overSizeWidth = playerContainerWidth; 132 } 133 customoptions.width = overSizeWidth; 134 vimeoWrapper.style.width = overSizeWidth + "px"; 135 136 vimeoWrapper.style.marginLeft = "-" + ((overSizeWidth - playerContainerWidth) / 2 + "px"); 137 138 } 139 else if (customoptions.width == "screen") { 140 let overSizeScreen = screenHeight * 2.65; 141 customoptions.width = overSizeScreen; 142 vimeoWrapper.style.width = overSizeScreen + "px"; 143 144 vimeoWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 145 146 } 147 else if (customoptions.width == "parallax") { 148 let overSizeScreen = screenHeight * 2.65; 149 customoptions.width = overSizeScreen; 150 vimeoWrapper.style.width = overSizeScreen + "px"; 151 152 vimeoWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 153 154 155 window.addEventListener("scroll", function (e) { 156 157 //console.log(window.scrollY); 158 //console.log(thisContainer.offsetTop); 159 160 if (window.scrollY >= thisContainer.offsetTop && 161 window.scrollY <= thisContainer.offsetTop + thisContainer.offsetHeight 162 163 ) { 164 thisContainer.querySelector(".mig-vimeo-wrapper").style.position = "fixed"; 165 } 166 else { 167 thisContainer.querySelector(".mig-vimeo-wrapper").style.position = "relative"; 168 } 169 }) 170 171 } 172 else { 173 delete customoptions.width; 174 } 175 176 177 } 178 179 180 let finaloptions = { ...defaultoptions, ...customoptions }; 181 182 183 let embedHere = thisContainer.querySelector(".mig-vimeo-wrapper"); 184 185 let videoPlayer = new Vimeo.Player(embedHere, finaloptions); 186 187 188 videoPlayer.on("loaded", function () { 189 190 if(data.preloader != "none"){ 191 videoPlayer.play() 192 .then(function(event){}) 193 .catch(function(error){ 194 console.log("error vimeo"); 195 videoPlayer.setVolume(0).then(function(){ 196 videoPlayer.play(); 197 }); 198 199 }); 200 } 201 202 }) 203 204 videoPlayer.on("play", function () { 205 206 if (data.preloader != "none") { 207 if (thisContainer.querySelector(".mig-vimeo-loader")) { 208 setTimeout(function () { 209 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundColor = "transparent"; 210 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundImage = "none"; 211 }, data.delay); 212 } 213 } 214 215 }) 216 217 } // end of if fallback 218 219 }) //end of foreach 220 221 222 }) 223 224 225}; 226migvimeoplayer(); 227 228 229 230 231 232 233 234let migyoutubeplayer = function () { 235 236 237 window.migYtplayersLoaded = {}; 238 239 240 241 const mainWindow = this; 242 243 let dseUrl = window.dseData.url; 244 245 246 247 let migYoutubePlayers = []; 248 window.migYoutubePlayers = migYoutubePlayers; 249 250 //AFTER THE SCRIPT WAS LOADED, RUN THE YOUTUBE FUNCTION 251 window.addEventListener("load", function (e) { 252 // CREATE SCRIPT 253 const docHeader = document.getElementsByTagName("head")[0]; 254 let youtubePy = document.createElement('script'); 255 256 youtubePy.setAttribute("src", 'https://www.youtube.com/iframe_api'); 257 youtubePy.setAttribute("type", 'text/javascript'); 258 259 docHeader.appendChild(youtubePy); 260 261 262 // GET ALL DOCUMENT SELECTORS AND CREATE A VIDEO PLAYER FOR EACHONE 263 let playerContainers = document.querySelectorAll('.divi_se_youtubebgnew'); 264 265
266 playerContainers.forEach(function (thisContainer, index) { 267 var allData = JSON.parse(thisContainer.getAttribute("data-youtubebg")); 268 var fallback = false; 269 var fallsource = allData.fallsource; 270 var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 271 272 if(fallsource == 'some' && iOS == true){ 273 fallback = true; 274 } 275 if(fallsource == 'all' && document.querySelector('body').classList.contains('et_mobile_device')){ 276 fallback = true; 277 } 278 279 280 if(fallback != 'caca'){ 281 // GET GENERAL SIZES TO ADJUST VALUES LATER DEPENDING ON USER SELECTION 282 let playerContainerWidth = thisContainer.offsetWidth; 283 let playerContainerHeight = thisContainer.offsetHeight; 284 let screenHeight = window.screen.availHeight; 285 let background = getComputedStyle( thisContainer ,null).getPropertyValue('background'); 286 287 288 // CREATE AN OUTER AN INNER WRAPPER TO ADJUST THE SIZE TO CONTAINER AND ALSO OVERSIZE THE INNER ONE 289 let videoOuterWrapper = document.createElement("div"); 290 videoOuterWrapper.setAttribute("class", "mig-youtube-outer-wrapper"); 291 292 293 let youtubeWrapper = document.createElement("div"); 294 youtubeWrapper.setAttribute("class", "mig-youtube-wrapper"); 295 296 let youtubeWrapperIframe = document.createElement("div"); 297 youtubeWrapperIframe.setAttribute("class", "mig-youtube-wrapper-iframe"); 298 299 let youtubeOverlay = document.createElement("div"); 300 youtubeOverlay.setAttribute("class", "mig-youtube-overlay"); 301 302 let youtubeCustomOverlay = document.createElement("div"); 303 youtubeCustomOverlay.setAttribute("class", "mig-youtube-customoverlay"); 304 305 306 thisContainer.prepend(videoOuterWrapper); 307 videoOuterWrapper.prepend(youtubeWrapper); 308 309 videoOuterWrapper.prepend(youtubeOverlay); 310 youtubeWrapper.prepend(youtubeWrapperIframe); 311 312 313 314 315 316 317 318 319 let defaultoptions = { 320 height: "100%", 321 width: playerContainerWidth, 322 videoId: 'M7lc1UVf-VE', 323 playerVars: { 324 autoplay: 1, 325 controls: 0, 326 disablekb: 1, 327 enablejsapi: 1, 328 fs: 0, 329 iv_load_policy: 3, 330 loop: 0, 331 modestbranding: 1, 332 origin: window.location.origin, 333 rel: 0, 334 showinfo: 0, 335 start: null, 336 end: null 337 }, 338 339 events: { 340 'onReady': migYTReady, 341 'onStateChange' : migYTPlay, 342 'onError' : migYTError 343 } 344 }; 345 346 let customoptions = {}; 347 if (thisContainer.getAttribute("data-youtubebg") !== null) { 348 customoptions = JSON.parse(thisContainer.getAttribute("data-youtubebg")); 349 350 351 // create variable to notify youtube events when is neccesary apply preloader 352 if(customoptions.bgoverlay == "yes"){ 353 videoOuterWrapper.prepend(youtubeCustomOverlay); 354 youtubeCustomOverlay.style.background = background; 355 } 356 357 358 if (customoptions.preloader !== "none" && customoptions.preloader !== undefined) { 359 360 361 362 let youtubeLoader = document.createElement("div"); 363 youtubeLoader.setAttribute("class", "mig-youtube-loader"); 364 if (customoptions.preloader !== "black") { 365 youtubeLoader.style.backgroundImage = `url("${dseUrl}/dse-functions/images/${customoptions.preloader}.gif")`; 366 } 367 368 videoOuterWrapper.appendChild(youtubeLoader); 369 } 370 371 372 // FIRST WE ADJUST VALUES DEPENDING ON SCREEN WIDTH 373 if (playerContainerWidth < 980) { 374 375 // adjust preloader position on mobile devices to prevent wrong display on large sections 376 if (thisContainer.querySelector(".mig-youtube-loader")) { 377 thisContainer.querySelector(".mig-youtube-loader").style.backgroundPositionY = `${screenHeight / 2}px`; 378 } 379 380 (customoptions.widthP) ? customoptions.width = customoptions.widthP : customoptions.width = customoptions.width; 381 } 382 383 384 // ADJUST VIDEO HEIGHT AND WIDTH 385 if (customoptions.width == "width") { 386 let adjustedHeight = playerContainerWidth * 0.562; 387 388 customoptions.height = adjustedHeight 389 } 390 391 if (customoptions.width == "height") { 392 let overSizeWidth = playerContainerHeight * 2.65; 393 if(overSizeWidth <= playerContainerWidth){ 394 overSizeWidth = playerContainerWidth; 395 } 396 customoptions.width = overSizeWidth; 397 youtubeWrapper.style.width = overSizeWidth + "px"; 398 399 youtubeWrapper.style.marginLeft = "-" + ((overSizeWidth - playerContainerWidth) / 2 + "px"); 400 customoptions.height = playerContainerHeight * 1; 401 } 402 else if (customoptions.width == "regularheight") { 403 customoptions.width = "100%"; 404 customoptions.height = playerContainerHeight; 405 } 406 else if (customoptions.width == "screen") { 407 let overSizeScreen = screenHeight * 2.65; 408 customoptions.width = overSizeScreen;
409 youtubeWrapper.style.width = overSizeScreen + "px"; 410 411 youtubeWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 412 customoptions.height = screenHeight * 1; 413 } 414 else if (customoptions.width == "parallax") { 415 let overSizeScreen = screenHeight * 2.65; 416 customoptions.width = overSizeScreen; 417 youtubeWrapper.style.width = overSizeScreen + "px"; 418 419 youtubeWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 420 customoptions.height = screenHeight * 1.05; 421 422 window.addEventListener("scroll", function (e) { 423 424 //console.log(window.scrollY); 425 //console.log(thisContainer.offsetTop); 426 427 if (window.scrollY >= thisContainer.offsetTop && 428 window.scrollY <= thisContainer.offsetTop + thisContainer.offsetHeight 429 430 ) { 431 thisContainer.querySelector(".mig-youtube-wrapper").style.position = "fixed"; 432 } 433 else { 434 thisContainer.querySelector(".mig-youtube-wrapper").style.position = "relative"; 435 } 436 }) 437 438 } 439 else { 440 delete customoptions.width; 441 } 442 443 444 } 445 446 447 let finaloptions = { ...defaultoptions, ...customoptions }; 448 (customoptions.start !== null)? finaloptions.playerVars.start = customoptions.start : ""; 449 (customoptions.end !== null)? finaloptions.playerVars.end = customoptions.end : ""; 450 if(customoptions.controls === "yes") { 451 finaloptions.playerVars.controls = 2; 452 if(thisContainer.querySelector(".mig-youtube-overlay") != null){ 453 thisContainer.querySelector(".mig-youtube-overlay").style.display = "none"; 454 } 455 456 if(thisContainer.querySelector(".mig-youtube-loader") != null){ 457 thisContainer.querySelector(".mig-youtube-loader").style.display = "none"; 458 } 459 460 } 461 462 463 //ASIGN AN ID INDEX DEPENDENT AND THEN INSERT IN THE MAIN OBJECT LO RESCUE LATER ON YOUTUBE FUNCTION 464 thisContainer.querySelector(".mig-youtube-wrapper").setAttribute("id", `mig-youtube-wrapper-${index}`); 465 466 467 finaloptions.selector = `mig-youtube-wrapper-${index}`; 468 migYoutubePlayers.push(finaloptions); 469 thisContainer.querySelector(".mig-youtube-wrapper-iframe").setAttribute("data-youtubebg", JSON.stringify(finaloptions)); 470 471 } 472 473 }) // end of foreach 474 475 476 mainWindow.onYouTubeIframeAPIReady = function onYouTubeIframeAPIReady() { 477 let ytPlayers = window.migYoutubePlayers; 478 479 ytPlayers.forEach(function(player){ 480 let selector = document.querySelector(`#${player.selector}`).querySelector(".mig-youtube-wrapper-iframe"); 481 let playerOptions = { 482 height: player.height, 483 width: player.width, 484 videoId: player.videoId, 485 playerVars: player.playerVars, 486 events: player.events 487 } 488 489 new YT.Player(selector, playerOptions); 490 }) 491 492 } 493 494 // 4. The API will call this function when the video player is ready. 495 function migYTReady(event) { 496 let windowWidth = window.screen.width; 497 let iframe = event.target.getIframe(); 498 499 500 let data = JSON.parse(iframe.getAttribute("data-youtubebg")); 501 let id = `migYt-${iframe.getAttribute("id")}`; 502 if(data.muted == "true"){ 503 event.target.mute(); 504 } 505 if(windowWidth < 980){ 506 event.target.mute(); 507 } 508 509 510 511 setTimeout(function(){ 512 if(window.migYtplayersLoaded[id] != "loaded"){ 513 console.log("muting video and try to play again"); 514 event.target.mute(); 515 event.target.playVideo(); 516 } 517 518 }, 1500); 519 520 521 event.target.playVideo(); 522 window.migYtplayersLoaded[id] = "unloaded"; 523 524 } 525 526 function migYTPlay(event){ 527 let iframe = event.target.getIframe(); 528 529 var done = false; 530 let data = JSON.parse(iframe.getAttribute("data-youtubebg")); 531 let selector = document.querySelector(`#${data.selector}`); 532 let loaderContainer = selector.nextSibling; 533 let id = `migYt-${iframe.getAttribute("id")}`; 534 535 if (event.data == YT.PlayerState.PLAYING && !done) { 536 537 window.migYtplayersLoaded[id] = "loaded"; 538 539 if (data.preloader != "none") { 540 if (loaderContainer.classList.contains("mig-youtube-loader")) { 541 542 setTimeout(function () { 543 loaderContainer.style.backgroundColor = "transparent"; 544 loaderContainer.style.backgroundImage = "none"; 545 }, data.delay); 546 } 547 } 548 } 549 else if(event.data == 0 && data.loop == "true"){ 550 event.target.seekTo(data.playerVars.start); 551 } 552 553 } 554 555 556 function migYTError(event){ 557 558 } 559 560 }) 561 562 563}; 564migyoutubeplayer(); 565
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.