1var videoads_onyoutubeiframeready; 2var videoads_document_ready = function () { 3 var $ = jQuery; 4 5 checkWidth = $('.cactus-video-content').width(); 6 checkHeight = (checkWidth / 16 * 9); 7 8 /* Video Youtube Iframe */ 9 var tag = document.createElement('script'); 10 tag.src = "https://www.youtube.com/iframe_api"; 11 var firstScriptTag = document.getElementsByTagName('script')[0]; 12 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 13 /* Video Youtube Iframe */ 14 15 var cactusAllVideoList = 'cactus-video-list'; 16 var cactusVideoItem = 'cactus-video-item'; 17 var cactusVideoDetails = 'cactus-video-details'; 18 var cactusVideoContent = 'cactus-video-content-ads-case'; 19 var cactusVideoAds = 'cactus-video-ads'; 20 21 var $global_this = ''; 22 var click_count = []; 23 var flag = []; 24 var flag_vimeo = []; 25 var flag_ads_vimeo = []; 26 27 /* youtube variables */ 28 var cactus_player = []; 29 var cactus_player_Ads = []; 30 var cactus_player_Ads1 = []; 31 32 /* vimeo variables */ 33 var cactus_vimeo_player = []; 34 var cactus_vimeo_player_Ads = []; 35 36 var cactus_main_vimeo = []; 37 var cactus_main_vimeo_player = []; 38 39 var cactus_ads_vimeo_obj = []; 40 var cactus_ads_vimeo_player = []; 41 42 //html5 variable 43 var cactus_html5_player = []; 44 var cactus_html5_player_Ads = []; 45 46 47 var video_last_current_time = 0; 48 var cactus_player_chunk = []; // save the chunk (total continuous minutes that users have watched video) 49 50 /** 51 * Start main youtube video 52 */ 53 var StartVideoNow = function (index) { 54 if (!$('body').hasClass('mobile')) { 55 // on mobile, you cannot autoplay (policy) 56 cactus_player[index].playVideo(); 57 } 58 }; 59 60 /** 61 * Init all global variables 62 */ 63 var init_data = function (index) { 64 divVideoId = cactusVideoItem + '-' + index; 65 AdsVideoId = cactusVideoAds + '-' + index; 66 67 $this = $($('.' + cactusAllVideoList).find('.' + cactusVideoItem)[index]); 68 69 $this.find('.' + cactusVideoDetails).find('.' + cactusVideoContent).attr('id', divVideoId); 70 71 adsID = $this.attr("data-ads-id"); 72 videoWidth = $this.attr("data-width"); 73 videoHeight = $this.attr("data-height"); 74 videoSource = $this.attr("data-source"); 75 videoLink = $this.attr("data-link"); 76 videoAdsType = $this.attr("data-ads-type"); 77 videoAds = $this.attr("data-ads"); 78 videoAdsSource = $this.attr("data-ads-source"); 79 playbackAdsID = $this.attr("playback-data-ads-id"); 80 playbackVideoAdsType = $this.attr("playback-data-ads-type"); 81 playbackVideoAds = $this.attr("playback-data-ads"); 82 playbackVideoAdsSource = $this.attr("playback-data-ads-source"); 83 playbackDataLinkRedirect = $this.attr("playback-data-link-redirect"); 84 videoAutoPlay = $this.attr("data-autoplay"); 85 videoDataTimeHideAds = parseInt($this.attr("data-time-hide-ads")); 86 closeButtonName = $this.attr("data-close-button-name"); 87 videoDataLinkRedirect = $this.attr("data-link-redirect"); 88 videoDataTarget = $this.attr("data-target"); 89 adsDataTimePlayAgain = parseInt($this.attr("ads-play-again-after")); 90 fullBannerDataTimePlayAgain = parseInt($this.attr("full-banner-play-again-after")); 91 topBottomDataTimePlayAgain = parseInt($this.attr("top-bottom-banner-play-again-after")); 92 closeButtonPosition = $this.attr("close-button-position"); 93 isMobileOrTablet = $this.attr("is-mobile-or-tablet"); 94 autoLoadNextVideo = $this.attr("auto-next-video"); 95 autoLoadNextVideoOptions = $this.attr("auto-next-video-options"); 96 autoLoadNextVideoSeconds = $this.attr("auto-load-next-video-seconds"); 97 showSharePopup = $this.attr("show-share-popup"); 98 99 enableBrand = $this.attr("enable-brand"); 100 brandLogo = $this.attr("brand-logo"); 101 brandText = $this.attr("brand-text"); 102 brandPosition = $this.attr("brand-position"); 103 brandColor = $this.attr("brand-color"); 104 brandOpacity = $this.attr("brand-opacity"); 105 106 107 adsImagePosition = $this.attr("ads-image-position"); 108 playbackAdsImagePosition = $this.attr("playback-ads-image-position"); 109 110 yt_onoff_related_yt = $this.attr("yt-onoff_related_yt"); 111 yt_onoff_info_yt = $this.attr("yt-onoff_info_yt"); 112 yt_remove_annotations = $this.attr("yt-remove_annotations"); 113 yt_allow_networking = $this.attr("yt-allow_networking"); 114 yt_interactive_videos = $this.attr("yt-interactive_videos"); 115 yt_html5 = $this.attr("yt-html5"); 116 117 videoDataTimePlayAgain = adsDataTimePlayAgain; 118 119 isClickCloseButtonFirstTime = true; 120 isVimeoPlayback = false;
121 122 cactus_player_chunk[index] = 0; // save the total chunk (number of continuous minutes) that users have been watching 123 } 124 125 /** 126 * Setup Vimeo Video Ad 127 */ 128 var setup_vimeo_ad = function (index) { 129 flag_vimeo[index] = false; 130 $this = $($('.' + cactusAllVideoList).find('.' + cactusVideoItem)[index]); 131 132 mask_button($this, cactusVideoAds, videoAdsSource, videoSource); 133 134 var divVideoAdsId = cactusVideoAds + '-' + index; 135 136 137 $this.find('.' + cactusVideoAds).html('<iframe id="player-vimeo-ad-' + index + '" src="https://player.vimeo.com/video/' + videoAds + '" width="' + checkWidth + '" height="' + checkHeight + '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'); 138 cactus_vimeo_player[index] = $('#player-vimeo-ad-' + index)[0]; 139 cactus_vimeo_player_Ads[index] = new Vimeo.Player(cactus_vimeo_player[index]); 140 141 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, videoAdsSource, videoDataTarget); 142 143 function onFinish(id) { 144 ajax_track(playbackVideoAdsID, vimeoAdsDuration, false, false); 145 $this.find('.' + cactusVideoAds).css({"display": "none"}); 146 147 if (videoSource == 'self-hosted') { 148 control_the_video_player(cactus_player[index].get(0), false); 149 } else if (videoSource == 'youtube') { 150 StartVideoNow(index); 151 } else if (videoSource == 'vimeo') { 152 cactus_main_vimeo_player[index].play(); 153 } 154 } 155 156 function onPlayProgress(data, id) { 157 vimeoAdsDuration = data.duration; 158 159 if (data.seconds > videoDataTimeHideAds && !flag_vimeo[index]) { 160 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 161 "visibility": "visible", 162 "opacity": "1" 163 }).text(closeButtonName); 164 165 currentTimeVideoCheck = data.seconds; 166 167 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeVimeoAds').on('click.closeVimeoAds', function () { 168 //ajax track close here 169 ajax_track(playbackVideoAdsID, currentTimeVideoCheck, true, false); 170 171 $this.find('.' + cactusVideoAds).css({"display": "none"}); 172 cactus_vimeo_player_Ads[index].pause(); 173 174 if (videoSource == 'self-hosted') { 175 control_the_video_player(cactus_player[index].get(0), false); 176 } else if (videoSource == 'youtube') { 177 StartVideoNow(index); 178 } else if (videoSource == 'vimeo') { 179 cactus_main_vimeo_player[index].play(); 180 } 181 182 flag_vimeo[index] = true; 183 184 // reset the chunk count 185 cactus_player_chunk[index] = 0; 186 flag[index] = false; // ad is closed, so set it to false 187 }); 188 189 } 190 } 191 192 cactus_vimeo_player_Ads[index].on('ended', onFinish); 193 var currentTimeVideoCheck = 0; 194 var vimeoAdsDuration = 0; 195 if (isVimeoPlayback == true) { 196 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'vimeo' ? playbackAdsID : adsID; 197 } else { 198 playbackVideoAdsID = adsID; 199 } 200 cactus_vimeo_player_Ads[index].on('timeupdate', onPlayProgress); 201 cactus_vimeo_player_Ads[index].play(); 202 203 $this.find('.' + cactusVideoAds).find(".hide-pause.button-start").click(function () { 204 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 205 //ajax track click to first ads here 206 ajax_track(adsID, 0, false, true); 207 }); 208 209 $this.find('.' + cactusVideoAds).find('.linkads').css({"opacity": "1", "visibility": "visible"}); 210 }); 211 }; 212 213 /** 214 * Setup Self-Hosted Video Ad 215 */ 216 var setup_selfhosted_ad = function (index) { 217 var divVideoAdsId = cactusVideoAds + '-' + index; 218 219 $this.find('.' + cactusVideoAds).html('<video id="player-html5-' + index + '" class="wp-video-shortcode" autoplay="true" preload="auto" style="width:100%"><source src="' + videoAds + '" type="video/mp4"></video><div>'); 220 221 cactus_html5_player_Ads[index] = $this.find('.' + cactusVideoAds).find('.wp-video-shortcode'); 222 223 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 224 225 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 226 //ajax track click to first ads here 227 ajax_track(adsID, 0, false, true); 228 }); 229 230 $this.find('.' + cactusVideoAds).find('.hide-pause').css({"opacity": "0", "cursor": "auto"}); 231 $this.find('.' + cactusVideoAds).find('.linkads').css({"opacity": "1", "visibility": "visible"}); 232 233 // when youtube html 5 ads finish 234 cactus_html5_player_Ads[index].get(0).onended = function (e) { 235 close_the_ads('ended', cactus_html5_player_Ads[index].get(0), cactus_player[index], adsID, index); 236 } 237 238 var html5AdsInterval = null; 239 240 // to check if the Close button needs to be shown 241 function adsPlayCurrentTime_func() { 242 videoHtml5PlayCurrentTime = cactus_html5_player_Ads[index].get(0).currentTime; 243 244 if (videoHtml5PlayCurrentTime >= videoDataTimeHideAds) { 245 // show the "Close" button for the ads, as the ads has appeared enough time (videoDataTimeHideAds) 246 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 247 "visibility": "visible", 248 "opacity": "1" 249 }).text(closeButtonName); 250 251 if (isClickCloseButtonFirstTime) { 252 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 253 close_the_ads('close', cactus_html5_player_Ads[index].get(0), cactus_player[index], null, index); 254 255 // clear the interval. We do not need to check if the "Close" button should be waiting for a period of time (instead, it appears right a way for the next time) 256 if (html5AdsInterval != null) { 257 clearInterval(html5AdsInterval); 258 } 259 isClickCloseButtonFirstTime = false;
260 }); 261 } 262 } 263 }; 264 265 html5AdsInterval = setInterval(adsPlayCurrentTime_func, 500); 266 } 267 268 /** 269 * Close the ad and play main video 270 * 271 * @params 272 * event - string - "ended" or "close" 273 * the_ad - the (self-hosted) video ad 274 */ 275 var close_the_ads = function (event, the_ad, video_player, the_ad_id, index) { 276 videoPlayFullTime = 0; 277 currentTime = 0; 278 if (videoAdsSource == 'self-hosted') { 279 videoPlayFullTime = the_ad.duration; 280 currentTime = the_ad.currentTime; 281 } else if (videoAdsSource == 'youtube' || videoAdsSource == 'vimeo') { 282 videoPlayFullTime = the_ad.getDuration(); 283 currentTime = the_ad.getCurrentTime(); 284 } 285 286 if (the_ad_id == null) the_ad_id = adsID; 287 288 if (event == 'ended') { 289 //ajax track close here when finish ads first time 290 ajax_track(the_ad_id, videoPlayFullTime, false, false); 291 } else { 292 //ajax track close here 293 ajax_track(the_ad_id, currentTime, true, false); 294 } 295 296 if (videoAdsSource == 'self-hosted') { 297 // pause the ad 298 control_the_video_player(the_ad, true, true); 299 } else if (videoAdsSource == 'youtube') { 300 the_ad.stopVideo(); 301 } else if (videoAdsSource == 'vimeo') { 302 the_ad.pause(); 303 } 304 305 // hide the ad 306 $this.find('.' + cactusVideoAds).css({"display": "none"}); 307 308 // reset the chunk count 309 cactus_player_chunk[index] = 0; 310 311 // Ad is closed, so reset the flag 312 flag[index] = false; 313 314 // play main video 315 if (videoSource == 'self-hosted') { 316 if (video_player.tagName == 'VIDEO') 317 video_player.play(); 318 else 319 video_player.get(0).play(); 320 } else if (videoSource == 'youtube') { 321 video_player.playVideo(); 322 } else if (videoSource == 'vimeo') { 323 video_player.play(); 324 } 325 326 } 327 328 /** 329 * Display the Ad 330 * 331 * @params 332 * the_ad - the Ad div 333 * showOrClose - boolean - true to show, false to close 334 */ 335 var show_the_ads = function (the_ad, showOrClose) { 336 the_ad.css({"visibility": "visible", "display": "block"}); 337 } 338 339 /** 340 * Stop or Play the self-hosted (HTML5 Player) video 341 * 342 * @params 343 * 344 * the_player - HTML5 Video Player 345 * stopOrPlay - boolean - true to pause, false to play 346 */ 347 var control_the_video_player = function (the_player, stopOrPlay, restart) { 348 if (stopOrPlay) { 349 the_player.pause(); 350 351 if (restart) { 352 the_player.currentTime = 0; 353 } 354 } else { 355 if (restart) { 356 the_player.currentTime = 0; 357 } 358 359 the_player.play(); 360 } 361 } 362 363 /** 364 * Stop or Play the Vimeo Player 365 * 366 * @params 367 * 368 * the_player - HTML5 Video Player 369 * stopOrPlay - boolean - true to pause, false to play 370 */ 371 var control_the_vimeo_player = function (the_player, stopOrPlay, restart) { 372 if (stopOrPlay) { 373 the_player.pause(); 374 375 if (restart) { 376 the_player.setCurrentTime(0); 377 } 378 } else { 379 if (restart) { 380 the_player.setCurrentTime(0); 381 } 382 383 the_player.play(); 384 } 385 } 386 387 /** 388 * Detect if we need to show the ad 389 * 390 * @params 391 */ 392 var need_repeat_ad = function (repeat_interval, index) { 393 if (cactus_player_chunk[index] > repeat_interval) 394 return true; 395 return false; 396 } 397 398 videoads_onyoutubeiframeready = function () { 399 400 $('.' + cactusAllVideoList).find('.' + cactusVideoItem).each(function (index, element) { 401 var $this = $(this); 402 $global_this = $(this); 403 404 init_data(index); 405 406 if (videoAdsType == 'adsense') { 407 videoAds = videoAds.replace(/@/g, '"'); 408 } 409 410 if (videoAdsType == 'image') { 411 //full banner 412 if (adsImagePosition == 1 || adsImagePosition == '') { 413 videoDataTimePlayAgain = fullBannerDataTimePlayAgain; 414 } 415 //top and bottom banner 416 else { 417 videoDataTimePlayAgain = topBottomDataTimePlayAgain; 418 } 419 } else if (videoAdsType == 'adsense') { 420 videoDataTimePlayAgain = topBottomDataTimePlayAgain; 421 } 422 423 if (videoLink == '@data-link') 424 videoLink = $('input[name=main_video_url]').val(); 425 426 if (videoSource == '@data-source') 427 videoSource = $('input[name=main_video_type]').val(); 428 429 430 $this.css({"width": checkWidth + "px", "height": checkHeight + "px"}); 431 432 //setup branch 433 if (enableBrand == 'yes') { 434 if (brandLogo != '' && brandLogo != undefined) 435 $this.find('.' + cactusVideoDetails).append('<div id="brand-' + index + '"><img src="' + brandLogo + '"/></div>'); 436 else { 437 if (typeof (brandText) == 'undefined') { 438 brandText = ''; 439 } 440 441 $this.find('.' + cactusVideoDetails).append('<div id="brand-' + index + '">' + brandText + '</div>'); 442 $this.find('#brand-' + index).css({opacity: brandOpacity, color: brandColor}); 443 } 444 445 if (brandPosition == 'top-right') { 446 $this.find('#brand-' + index).css({top: '0', right: '0'}); 447 } else if (brandPosition == 'top-left') { 448 $this.find('#brand-' + index).css({top: '0', left: '0'}); 449 } else if (brandPosition == 'bottom-right') { 450 $this.find('#brand-' + index).css({bottom: '0', right: '0'}); 451 } else if (brandPosition == 'bottom-left') { 452 $this.find('#brand-' + index).css({bottom: '0', left: '0'}); 453 } else { 454 $this.find('#brand-' + index).css({top: '0', right: '0'}); 455 } 456 } 457
458 // check browser allow autoplay or not 459 canAutoplay.video({timeout: 1000, muted: false}).then(({result}) => { 460 if (result !== true) { 461 videoAutoPlay = false; 462 } 463 }); 464 465 setTimeout(function () { 466 467 /* Video Youtube Iframe */ 468 if (videoSource == 'youtube') { 469 function onPlayerReady(event) { 470 $this.find('.' + cactusVideoAds).css("visibility", "hidden"); 471 472 var videoDurationAds = 0; 473 var videoPlayCurrentTime = 0; 474 475 if (videoAutoPlay == "1") { 476 if (videoAds != '' && videoAds != null && videoAdsType != '') { 477 $this.find('.' + cactusVideoAds).css("visibility", "visible"); 478 var divVideoAdsId = cactusVideoAds + '-' + index; 479 480 if (videoAdsType == 'video') { 481 482 if (videoAdsSource == 'youtube') { 483 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 484 485 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 486 //ajax track click to first ads here 487 ajax_track(adsID, 0, false, true); 488 }); 489 490 function onPlayerReady_auto(event) { 491 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 492 "opacity": "0", 493 "cursor": "auto" 494 }); 495 $this.find('.' + cactusVideoAds).find('.linkads').css({ 496 "opacity": "1", 497 "visibility": "visible" 498 }); 499 500 var youtubeAdsInterval = null; 501 502 function adsPlayCurrentTime_func() { 503 videoPlayCurrentTime = cactus_player_Ads[index].getCurrentTime(); 504 if (parseInt(videoPlayCurrentTime) >= videoDataTimeHideAds) { 505 506 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 507 "visibility": "visible", 508 "opacity": "1" 509 }).text(closeButtonName); 510 511 if (isClickCloseButtonFirstTime == true) { 512 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 513 514 //ajax track close here 515 ajax_track(adsID, videoPlayCurrentTime, true, false); 516 517 if (youtubeAdsInterval != null) { 518 clearInterval(youtubeAdsInterval); 519 } 520 $this.find('.' + cactusVideoAds).css({"display": "none"}); 521 cactus_player_Ads[index].stopVideo(); 522 StartVideoNow(index); 523 isClickCloseButtonFirstTime = false;
524 }); 525 } 526 527 528 } 529 } 530 531 youtubeAdsInterval = setInterval(adsPlayCurrentTime_func, 500); 532 } 533 534 function onPlayerStateChange_auto(event) { 535 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 536 "opacity": "0", 537 "cursor": "auto" 538 }); 539 $this.find('.' + cactusVideoAds).find('.linkads').css({ 540 "opacity": "1", 541 "visibility": "visible" 542 }); 543 544 // when youtube ads finish 545 if (event.data === 0) { 546 547 videoPlayFullTime = cactus_player_Ads[index].getDuration(); 548 //ajax track close here when finish ads first time 549 ajax_track(adsID, videoPlayFullTime, false, false); 550 551 $this.find('.' + cactusVideoAds).css({"display": "none"}); 552 cactus_player_Ads[index].stopVideo(); 553 StartVideoNow(index); 554 } 555 } 556 557 cactus_player_Ads[index] = new YT.Player(divVideoAdsId, { 558 width: checkWidth, 559 height: checkHeight, 560 videoId: videoAds, 561 playerVars: { 562 controls: 0, 563 showinfo: 0, 564 enablejsapi: 1, 565 autoplay: 1, 566 disablekb: 1, 567 }, 568 events: { 569 'onReady': onPlayerReady_auto, 570 'onStateChange': onPlayerStateChange_auto 571 } 572 }); 573 } else if (videoAdsSource == 'vimeo') { 574 setup_vimeo_ad(index); 575 } else if (videoAdsSource == 'self-hosted') { 576 setup_selfhosted_ad(index); 577 } 578 } else if (videoAdsType == 'image') { 579 //ads images 580 581 // Hidden ads images 582 $this.find('.' + cactusVideoAds).css("visibility", "hidden"); 583 584 //full size 585 if (adsImagePosition == '1' || adsImagePosition == 'undefined' || adsImagePosition == '') { 586 $this.find('.' + cactusVideoAds).css("display", "none"); 587 // prepare ads images 588 $this.find('.' + cactusVideoAds).html('<a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img src="' + videoAds + '"/></a>'); 589 $this.find('.' + cactusVideoAds + ' img').css({ 590 "width": "100%", 591 "height": "100%" 592 }); 593 594 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 595 596 $this.find('.' + cactusVideoAds).find('a img').off('.clickToAds').on('click.clickToAds', function () { 597 //ajax track click to full ads here 598 ajax_track(adsID, 0, false, true); 599 }); 600 601 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 602 "visibility": "visible", 603 "opacity": "1" 604 }).text(closeButtonName); 605 606 607 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').click(function () { 608 //ajax track close full ads here 609 ajax_track(adsID, 0, true, false); 610 $this.find('.' + cactusVideoAds).css({"display": "none"}); 611 StartVideoNow(index); 612 }); 613 } else { 614 // top banner 615 if (adsImagePosition == '2') { 616 // prepare ads images 617 $this.find('.' + cactusVideoAds).css({ 618 "pointer-events": "none", 619 'z-index': '10' 620 }); 621 $('<img src="' + videoAds + '">').load(function () { 622 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>');
623 var playerHeight = checkHeight; 624 var playerWidth = checkWidth; 625 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 626 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 627 628 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 629 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 630 631 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 632 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 633 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 634 'right': dscFromRightPlayertoImg + 10 + 'px' 635 }); 636 637 $(window).resize(function () { 638 setTimeout(function () { 639 playerWidth = $('.cactus-video-content').width(); 640 playerHeight = (checkWidth / 16 * 9); 641 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 642 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 643 dscFromBottomPlayertoImg = playerHeight - imgHeight; 644 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 645 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 646 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 647 'right': dscFromRightPlayertoImg + 10 + 'px' 648 }); 649 }, 400) 650 }); 651 652 653 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 654 //ajax track click to first top ads here 655 ajax_track(adsID, 0, false, true); 656 }); 657 658 659 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 660 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '2') { 661 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 662 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 663 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 664 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 665 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 666 667 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 668 playerWidth = $('.cactus-video-content').width(); 669 playerHe
669ight = (playerWidth / 16 * 9); 670 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 671 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 672 673 dscFromBottomPlayertoImg = playerHeight - imgHeight; 674 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 675 676 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 677 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 678 'right': dscFromRightPlayertoImg + 10 + 'px' 679 }); 680 } else { 681 $this.find('.' + cactusVideoAds).css({"display": "none"}); 682 } 683 if (click_count[index] != '1') { 684 ajax_track(adsID, 0, true, false); 685 } 686 687 click_count[index] = '1'; 688 }); 689 }); 690 } 691 //bottom banner 692 else if (adsImagePosition == '3') { 693 // prepare ads images 694 $this.find('.' + cactusVideoAds).css({ 695 "height": "auto", 696 "top": "0", 697 "pointer-events": "none", 698 'z-index': '10' 699 }); 700 $('<img src="' + videoAds + '">').load(function () { 701 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>'); 702 703 var playerHeight = checkHeight; 704 var playerWidth = checkWidth; 705 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 706 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 707 708 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 709 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 710 711 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 712 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 713 'padding-bottom': '40px', 714 'top': 'auto' 715 }); 716 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 717 'top': '10px', 718 'right': dscFromRightPlayertoImg + 10 + 'px' 719 }); 720 721 $(window).resize(function () { 722 setTimeout(function () { 723 playerWidth = $('.cactus-video-content').width(); 724 playerHe
724ight = (checkWidth / 16 * 9); 725 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 726 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 727 dscFromBottomPlayertoImg = playerHeight - imgHeight; 728 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 729 if (playerWidth < 600) { 730 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': '0'}); 731 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 732 'top': 'auto', 733 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 734 'right': dscFromRightPlayertoImg + 10 + 'px' 735 }); 736 } else { 737 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': 'auto'}); 738 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 739 'top': '10px', 740 'right': dscFromRightPlayertoImg + 10 + 'px' 741 }); 742 } 743 }, 400) 744 }); 745 746 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 747 //ajax track click to first top ads here 748 ajax_track(adsID, 0, false, true); 749 }); 750 751 752 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 753 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '3') { 754 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 755 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 756 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 757 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 758 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 759 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 760 playerWidth = $('.cactus-video-content').width(); 761 playerHeight = (playerWidth / 16 * 9); 762 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 763 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 764 765 dscFromBottomPlayertoImg = playerHeight - imgHeight; 766 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 767 768 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 769 'padding-bottom': '40px', 770 'top': 'auto' 771 }); 772 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 773 'top': '10px', 774 'right': dscFromRightPlayertoImg + 10 + 'px' 775 }); 776 } else { 777 $this.find('.' + cactusVideoAds).css({"display": "none"}); 778 } 779 if (click_count[index] != '1') { 780 ajax_track(adsID, 0, true, false); 781 } 782 click_count[index] = '1'; 783 }); 784 }); 785 } 786 } 787 788 //play youtube video 789 StartVideoNow(index); 790 791 } else if (videoAdsType == 'adsense') { 792 /* HTML Ads */ 793 794 if (adsImagePosition == '1' || adsImagePosition == '') { 795 adsImagePosition = '2'; 796 } 797 798 /* Hidden ads images */ 799 $this.find('.' + cactusVideoAds).css("display", "none"); 800 801 /* top banner */ 802 if (adsImagePosition == '2') { 803 $this.find('.' + cactusVideoAds).css({ 804 "height": "0", 805 "pointer-events": "none", 806 'z-index': '10' 807 }); 808 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 809
810 var playerHeight = checkHeight; 811 var playerWidth = checkWidth; 812 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 813 var imgWidth = $this.find('.' + cactusVideoAds).width(); 814 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 815 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 816 817 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 818 if (playerWidth < 600) { 819 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 820 "width": imgWidth + "px", 821 "height": imgHeight + "px" 822 }); 823 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 824 'top': 'auto', 825 'bottom': '30px', 826 'right': dscFromRightPlayertoImg + 10 + 'px' 827 }); 828 } else { 829 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 830 "width": "728px", 831 "height": imgHeight + "px" 832 }); 833 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 834 'top': '65px', 835 'right': dscFromRightPlayertoImg + 10 + 'px' 836 }); 837 } 838 839 $(window).resize(function () { 840 setTimeout(function () { 841 playerWidth = $('.cactus-video-content').width(); 842 playerHeight = (checkWidth / 16 * 9); 843 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 844 var imgWidth = $this.find('.' + cactusVideoAds).width(); 845 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 846 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 847 if (playerWidth < 600) { 848 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 849 "width": imgWidth + "px", 850 "height": imgHeight + "px" 851 }); 852 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 853 'top': 'auto', 854 'bottom': '30px', 855 'right': dscFromRightPlayertoImg + 10 + 'px' 856 }); 857 } else { 858 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 859 "width": "728px", 860 "height": imgHeight + "px" 861 }); 862 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 863 'top': '65px', 864 'right': dscFromRightPlayertoImg + 10 + 'px' 865 }); 866 } 867 }, 400) 868 }); 869 870 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 871 close_the_ads('close', '.cactusVideoAds', cactus_player[index], adsID, index); 872 }); 873 874 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 875 ajax_track(adsID, 0, false, true); 876 }); 877 878 } 879 /* bottom banner */ 880 else if (adsImagePosition == '3') { 881 $this.find('.' + cactusVideoAds).css({ 882 "height": "auto", 883 "top": "auto", 884 "pointer-events": "none", 885 'z-index': '10' 886 }); 887 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 888 889
890 var playerHeight = checkHeight; 891 var playerWidth = checkWidth; 892 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 893 var imgWidth = $this.find('.' + cactusVideoAds).width(); 894 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 895 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 896 897 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 898 if (playerWidth < 600) { 899 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 900 "width": imgWidth + "px", 901 "height": imgHeight + "px" 902 }); 903 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': 'auto', 'bottom': '30px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 904 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 905 'top': '10px', 906 'right': '10px' 907 }); 908 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 909 } else { 910 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 911 "width": "728px", 912 "height": imgHeight + "px" 913 }); 914 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': '65px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 915 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 916 'top': '10px', 917 'right': '10px' 918 }); 919 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 920 } 921 922 $(window).resize(function () { 923 setTimeout(function () { 924 playerWidth = $('.cactus-video-content').width(); 925 playerHeight = (checkWidth / 16 * 9); 926 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 927 var imgWidth = $this.find('.' + cactusVideoAds).width(); 928 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 929 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 930 if (playerWidth < 600) { 931 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 932 "width": imgWidth + "px", 933 "height": imgHeight + "px" 934 }); 935 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 936 'top': '10px', 937 'right': '10px' 938 }); 939 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 940 } else { 941 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 942 "width": "728px", 943 "height": imgHeight + "px" 944 }); 945 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 946 'top': '10px', 947 'right': '10px' 948 }); 949 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 950 } 951 }, 400) 952 }); 953 954 955 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 956 close_the_ads('close', '.cactusVideoAds', cactus_player[index], adsID, index); 957 }); 958 959 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 960 ajax_track(adsID, 0, false, true); 961 }); 962 } 963 964 /* play youtube video */ 965 StartVideoNow(index); 966 } 967 } else { 968 StartVideoNow(index); 969 } 970 } else { 971 // not auto play 972 if (videoAds != '' && videoAds != null && videoAdsType != '') { 973 $this.find('.' + cactusVideoAds).css("visibility", "visible"); 974 var divVideoAdsId = cactusVideoAds + '-' + index; 975 if (videoAdsType == 'video') { 976 if (videoAdsSource == 'youtube') { 977 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, videoAdsSource, videoDataTarget); 978 979 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 980 //ajax track click to first ads here 981 ajax_track(adsID, 0, false, true); 982 }); 983 984 $this.find('.' + cactusVideoAds).find(".hide-pause.button-start").click(function () { 985 if ($('body').hasClass('mobile')) { 986 $('body').addClass('mobile-clicked'); 987 } 988 989 var $thisads = $(this); 990 991 function onPlayerReady_nauto(event) { 992 $thisads.css({"opacity": "0"}); 993 $this.find('.' + cactusVideoAds).find('.linkads').css({ 994 "opacity": "1", 995 "visibility": "visible" 996 }); 997 } 998 999 function onPlayerStateChange_nauto(event) { 1000 if (event.data === 0) { 1001 videoPlayFullTime = cactus_player_Ads[index].getDuration(); 1002 //ajax track close here when finish ads first time 1003 ajax_track(adsID, videoPlayFullTime, false, false); 1004 1005 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1006 cactus_player_Ads[index].stopVideo(); 1007 StartVideoNow(index); 1008 } 1009 1010 var youtubeAdsInterval = null; 1011 1012 function adsPlayCurrentTime_func() { 1013 videoPlayCurrentTime = cactus_player_Ads[index].getCurrentTime(); 1014 if (parseInt(videoPlayCurrentTime) >= videoDataTimeHideAds) { 1015 clearInterval(adsPlayCurrentTime_func); 1016 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 1017 "visibility": "visible", 1018 "opacity": "1" 1019 }).text(closeButtonName); 1020 1021 if (isClickCloseButtonFirstTime == true) { 1022 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 1023 1024 //ajax track close here 1025 ajax_track(adsID, videoPlayCurrentTime, true, false); 1026 1027 if (youtubeAdsInterval != null) { 1028 clearInterval(youtubeAdsInterval); 1029 } 1030 1031 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1032 cactus_player_Ads[index].stopVideo(); 1033 StartVideoNow(index); 1034 isClickCloseButtonFirstTime = false;
1035 }); 1036 } 1037 } 1038 } 1039 1040 youtubeAdsInterval = setInterval(adsPlayCurrentTime_func, 500) 1041 } 1042 1043 cactus_player_Ads[index] = new YT.Player(divVideoAdsId, { 1044 width: checkWidth, 1045 height: checkHeight, 1046 videoId: videoAds, 1047 playerVars: { 1048 controls: 0, 1049 showinfo: 0, 1050 enablejsapi: 1, 1051 autoplay: 1, 1052 disablekb: 1, 1053 }, 1054 events: { 1055 'onReady': onPlayerReady_nauto, 1056 'onStateChange': onPlayerStateChange_nauto 1057 } 1058 }); 1059 1060 }); 1061 } else if (videoAdsSource == 'vimeo') { 1062 setup_vimeo_ad(index); 1063 } else if (videoAdsSource == 'self-hosted') { 1064 mask_button($this, cactusVideoAds, videoAdsSource, videoSource); 1065 $this.find('.' + cactusVideoAds).find(".hide-pause.button-start").click(function () { 1066 if ($('body').hasClass('mobile')) { 1067 $('body').addClass('mobile-clicked'); 1068 } 1069 $this.find('.' + cactusVideoAds).html('<video id="player-html5-' + index + '" class="wp-video-shortcode" preload="auto" controls="controls" style="width:100%"><source src="' + videoAds + '" type="video/mp4"></video><div>'); 1070 1071 cactus_html5_player_Ads[index] = $this.find('.' + cactusVideoAds).find('.wp-video-shortcode'); 1072 cactus_html5_player_Ads[index].get(0).play(); 1073 1074 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 1075 1076 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 1077 //ajax track click to first ads here 1078 ajax_track(adsID, 0, false, true); 1079 }); 1080 1081 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 1082 "opacity": "0", 1083 "cursor": "auto" 1084 }); 1085 $this.find('.' + cactusVideoAds).find('.linkads').css({ 1086 "opacity": "1", 1087 "visibility": "visible" 1088 }); 1089 1090 // when youtube html 5 ads finish 1091 cactus_html5_player_Ads[index].get(0).onended = function (e) { 1092 // alert('end video'); 1093 videoPlayFullTime = cactus_html5_player_Ads[index].get(0).duration; 1094 //ajax track close here when finish ads first time 1095 ajax_track(adsID, videoPlayFullTime, false, false); 1096 1097 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1098 StartVideoNow(index); 1099 } 1100 1101 var html5AdsInterval = null; 1102 1103 function adsPlayCurrentTime_func() { 1104 videoHtml5PlayCurrentTime = cactus_html5_player_Ads[index].get(0).currentTime; 1105 cactus_html5_player_Ads[index].get(0).addEventListener("timeupdate", function () { 1106 if (videoHtml5PlayCurrentTime >= videoDataTimeHideAds) { 1107 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 1108 "visibility": "visible", 1109 "opacity": "1" 1110 }).text(closeButtonName); 1111 1112 if (isClickCloseButtonFirstTime == true) { 1113 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 1114 1115 //ajax track close here 1116 ajax_track(adsID, videoPlayCurrentTime, true, false); 1117 1118 if (html5AdsInterval != null) { 1119 clearInterval(html5AdsInterval); 1120 } 1121 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1122 cactus_html5_player_Ads[index].get(0).pause(); 1123 StartVideoNow(index); 1124 isClickCloseButtonFirstTime = false;
1125 }); 1126 } 1127 } 1128 }); 1129 } 1130 1131 html5AdsInterval = setInterval(adsPlayCurrentTime_func, 500) 1132 }); 1133 } 1134 } else if (videoAdsType == 'image') { 1135 //ads images 1136 1137 // Hidden ads images 1138 $this.find('.' + cactusVideoAds).css("visibility", "hidden"); 1139 1140 //full size 1141 if (adsImagePosition == '1' || adsImagePosition == 'undefined' || adsImagePosition == '') { 1142 $this.find('.' + cactusVideoAds).css("display", "none"); 1143 // prepare ads images 1144 $this.find('.' + cactusVideoAds).html('<a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img src="' + videoAds + '"/></a>'); 1145 $this.find('.' + cactusVideoAds + ' img').css({ 1146 "width": "100%", 1147 "height": "100%" 1148 }); 1149 1150 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 1151 1152 $this.find('.' + cactusVideoAds).find('a img').off('.clickToAds').on('click.clickToAds', function () { 1153 //ajax track click to full ads here 1154 ajax_track(adsID, 0, false, true); 1155 }); 1156 1157 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 1158 "visibility": "visible", 1159 "opacity": "1" 1160 }).text(closeButtonName); 1161 1162 1163 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').click(function () { 1164 //ajax track close full ads here 1165 ajax_track(adsID, 0, true, false); 1166 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1167 StartVideoNow(index); 1168 }); 1169 } else { 1170 // top banner 1171 if (adsImagePosition == '2') { 1172 // prepare ads images 1173 $this.find('.' + cactusVideoAds).css({ 1174 "pointer-events": "none", 1175 'z-index': '10' 1176 }); 1177 $('<img src="' + videoAds + '">').load(function () { 1178 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>'); 1179 var playerHeight = checkHeight; 1180 var playerWidth = checkWidth; 1181 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 1182 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 1183 1184 var dscFromBottomPlayertoImg = playerHe
1184ight - imgHeight; 1185 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1186 1187 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 1188 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 1189 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 1190 'right': dscFromRightPlayertoImg + 10 + 'px' 1191 }); 1192 1193 $(window).resize(function () { 1194 setTimeout(function () { 1195 playerWidth = $('.cactus-video-content').width(); 1196 playerHeight = (playerWidth / 16 * 9); 1197 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 1198 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 1199 dscFromBottomPlayertoImg = playerHeight - imgHeight; 1200 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1201 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 1202 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 1203 'right': dscFromRightPlayertoImg + 10 + 'px' 1204 }); 1205 }, 400) 1206 }); 1207 1208 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 1209 //ajax track click to first top ads here 1210 ajax_track(adsID, 0, false, true); 1211 }); 1212 1213 1214 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 1215 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '2') { 1216 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 1217 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 1218 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 1219 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 1220 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 1221 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 1222 playerWidth = $('.cactus-video-content').width(); 1223 playerHeight = (playerWidth / 16 * 9); 1224 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 1225 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 1226 1227 dscFromBottomPlayertoImg = playerHe
1227ight - imgHeight; 1228 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1229 1230 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 1231 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 1232 'right': dscFromRightPlayertoImg + 10 + 'px' 1233 }); 1234 } else { 1235 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1236 } 1237 if (click_count[index] != '1') { 1238 ajax_track(adsID, 0, true, false); 1239 } 1240 click_count[index] = '1'; 1241 }); 1242 }); 1243 1244 // $this.find('.'+cactusVideoAds + ' img').css({"width":"100%", "height":"auto"}); 1245 1246 1247 } 1248 //bottom banner 1249 else if (adsImagePosition == '3') { 1250 // prepare ads images 1251 $this.find('.' + cactusVideoAds).css({ 1252 "height": "auto", 1253 "top": "0", 1254 "pointer-events": "none", 1255 'z-index': '10' 1256 }); 1257 $('<img src="' + videoAds + '">').load(function () { 1258 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>'); 1259 1260 var playerHeight = checkHeight; 1261 var playerWidth = checkWidth; 1262 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 1263 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 1264 1265 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 1266 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1267 1268 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 1269 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 1270 'padding-bottom': '40px', 1271 'top': 'auto' 1272 }); 1273 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 1274 'top': '10px', 1275 'right': dscFromRightPlayertoImg + 10 + 'px' 1276 }); 1277 1278 $(window).resize(function () { 1279 setTimeout(function () { 1280 playerWidth = $('.cactus-video-content').width(); 1281 playerHeight = (checkWidth / 16 * 9); 1282 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 1283 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 1284 dscFromBottomPlayertoImg = playerHe
1284ight - imgHeight; 1285 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1286 if (playerWidth < 600) { 1287 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': '0'}); 1288 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 1289 'top': 'auto', 1290 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 1291 'right': dscFromRightPlayertoImg + 10 + 'px' 1292 }); 1293 } else { 1294 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': 'auto'}); 1295 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 1296 'top': '10px', 1297 'right': dscFromRightPlayertoImg + 10 + 'px' 1298 }); 1299 } 1300 }, 400) 1301 }); 1302 1303 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 1304 //ajax track click to first top ads here 1305 ajax_track(adsID, 0, false, true); 1306 }); 1307 1308 1309 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 1310 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '3') { 1311 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 1312 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 1313 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 1314 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 1315 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 1316 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 1317 playerWidth = $('.cactus-video-content').width(); 1318 playerHeight = (playerWidth / 16 * 9); 1319 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 1320 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 1321 1322 dscFromBottomPlayertoImg = playerHeight - imgHeight; 1323 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1324 1325 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 1326 'padding-bottom': '40px', 1327 'top': 'auto' 1328 }); 1329 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 1330 'top': '10px', 1331 'right': dscFromRightPlayertoImg + 10 + 'px' 1332 }); 1333 } else { 1334 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1335 } 1336 if (click_count[index] != '1') { 1337 ajax_track(adsID, 0, true, false); 1338 } 1339 click_count[index] = '1'; 1340 }); 1341 }); 1342 } 1343 1344 } 1345 } else if (videoAdsType == 'adsense') { 1346 // Hidden ads images 1347 $this.find('.' + cactusVideoAds).css("display", "none"); 1348 1349 if (adsImagePosition == '1' || adsImagePosition == '') { 1350 adsImagePosition = '2'; 1351 } 1352 // Hidden ads images 1353 $this.find('.' + cactusVideoAds).css("display", "none"); 1354 1355 // top banner 1356 if (adsImagePosition == '2') { 1357 1358 1359 $this.find('.' + cactusVideoAds).css({ 1360 "height": "0", 1361 "pointer-events": "none", 1362 'z-index': '10' 1363 }); 1364 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 1365
1366 var playerHeight = checkHeight; 1367 var playerWidth = checkWidth; 1368 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 1369 var imgWidth = $this.find('.' + cactusVideoAds).width(); 1370 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 1371 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1372 1373 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 1374 if (playerWidth < 600) { 1375 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 1376 "width": imgWidth + "px", 1377 "height": imgHeight + "px" 1378 }); 1379 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 1380 'top': 'auto', 1381 'bottom': '30px', 1382 'right': dscFromRightPlayertoImg + 10 + 'px' 1383 }); 1384 } else { 1385 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 1386 "width": "728px", 1387 "height": imgHeight + "px" 1388 }); 1389 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 1390 'top': '65px', 1391 'right': dscFromRightPlayertoImg + 10 + 'px' 1392 }); 1393 } 1394 1395 1396 $(window).resize(function () { 1397 setTimeout(function () { 1398 playerWidth = $('.cactus-video-content').width(); 1399 playerHeight = (checkWidth / 16 * 9); 1400 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 1401 var imgWidth = $this.find('.' + cactusVideoAds).width(); 1402 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 1403 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1404 if (playerWidth < 600) { 1405 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 1406 "width": imgWidth + "px", 1407 "height": imgHeight + "px" 1408 }); 1409 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 1410 'top': 'auto', 1411 'bottom': '30px', 1412 'right': dscFromRightPlayertoImg + 10 + 'px' 1413 }); 1414 } else { 1415 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 1416 "width": "728px", 1417 "height": imgHeight + "px" 1418 }); 1419 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 1420 'top': '65px', 1421 'right': dscFromRightPlayertoImg + 10 + 'px' 1422 }); 1423 } 1424 }, 400) 1425 }); 1426 1427 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 1428 close_the_ads('close', '.cactusVideoAds', cactus_player[index], adsID, index); 1429 }); 1430 1431 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 1432 ajax_track(adsID, 0, false, true); 1433 }); 1434 } 1435 //bottom banner 1436 else if (adsImagePosition == '3') { 1437 $this.find('.' + cactusVideoAds).css({ 1438 "height": "auto", 1439 "top": "auto", 1440 "pointer-events": "none", 1441 'z-index': '10' 1442 }); 1443 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 1444 1445
1446 var playerHeight = checkHeight; 1447 var playerWidth = checkWidth; 1448 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 1449 var imgWidth = $this.find('.' + cactusVideoAds).width(); 1450 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 1451 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1452 1453 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 1454 if (playerWidth < 600) { 1455 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 1456 "width": imgWidth + "px", 1457 "height": imgHeight + "px" 1458 }); 1459 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': 'auto', 'bottom': '30px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 1460 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 1461 'top': '10px', 1462 'right': '10px' 1463 }); 1464 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 1465 } else { 1466 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 1467 "width": "728px", 1468 "height": imgHeight + "px" 1469 }); 1470 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': '65px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 1471 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 1472 'top': '10px', 1473 'right': '10px' 1474 }); 1475 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 1476 } 1477 1478 1479 $(window).resize(function () { 1480 setTimeout(function () { 1481 playerWidth = $('.cactus-video-content').width(); 1482 playerHeight = (checkWidth / 16 * 9); 1483 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 1484 var imgWidth = $this.find('.' + cactusVideoAds).width(); 1485 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 1486 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 1487 if (playerWidth < 600) { 1488 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 1489 "width": imgWidth + "px", 1490 "height": imgHeight + "px" 1491 }); 1492 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 1493 'top': '10px', 1494 'right': '10px' 1495 }); 1496 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 1497 } else { 1498 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 1499 "width": "728px", 1500 "height": imgHeight + "px" 1501 }); 1502 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 1503 'top': '10px', 1504 'right': '10px' 1505 }); 1506 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 1507 } 1508 }, 400) 1509 }); 1510 1511 1512 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 1513 close_the_ads('close', '.cactusVideoAds', cactus_player[index], adsID, index); 1514 }); 1515 1516 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 1517 ajax_track(adsID, 0, false, true); 1518 }); 1519 } 1520 } 1521 } else { 1522 cactus_player[index].stopVideo(); 1523 } 1524 } 1525 1526 check_youtube_current_time_interval = setInterval(check_youtube_current_time, 500, index); 1527 } // end onPlayerReady 1528 1529 1530 var done = false;
1531 1532 function onPlayerStateChange(event) { 1533 // when video ends 1534 if (event.data === 0) { 1535 if (showSharePopup == 'on') { 1536 $('body').addClass('popup-share-active'); 1537 } 1538 1539 setTimeout(function () { 1540 if (autoLoadNextVideo != 3) { 1541 var link = $('.prev-post a').attr('href'); 1542 if (autoLoadNextVideoOptions == 1) { 1543 link = $('.next-post a').attr('href'); 1544 } 1545 } else if (autoLoadNextVideo == 3) { 1546 var link = window.location.href; 1547 } 1548 var className = $('#tm-autonext span#autonext').attr('class'); 1549 if (className != '') { 1550 if (link != undefined) { 1551 window.location.href = link; 1552 } 1553 } 1554 }, autoLoadNextVideoSeconds); 1555 } 1556 } 1557 1558 function stopVideo() { 1559 cactus_player[index].stopVideo(); 1560 } 1561 1562 cactus_player[index] = new YT.Player(divVideoId, { 1563 width: checkWidth, 1564 height: checkHeight, 1565 videoId: videoLink, 1566 playerVars: { 1567 //controls: 0, 1568 showinfo: (yt_onoff_info_yt == 1 ? 0 : 1), 1569 enablejsapi: 1, 1570 rel: (yt_onoff_related_yt == 1 ? 0 : 1), 1571 iv_load_policy: (yt_remove_annotations == 1 ? 3 : 1) 1572 }, 1573 events: { 1574 'onReady': onPlayerReady, 1575 'onStateChange': onPlayerStateChange 1576 } 1577 }); 1578 1579 var check_youtube_current_time = function (index) { 1580 videoPlayCurrentTime = parseInt(cactus_player[index].getCurrentTime()); 1581 1582 // increase the chunk count 1583 if (videoPlayCurrentTime > video_last_current_time) { 1584 cactus_player_chunk[index] += videoPlayCurrentTime - video_last_current_time; 1585 } 1586 video_last_current_time = videoPlayCurrentTime; 1587 1588 if (videoPlayCurrentTime > 0 && (videoAdsType == 'image' && (adsImagePosition == '2' || adsImagePosition == '3')) && click_count[index] != 1) { 1589 $global_this.find('.' + cactusVideoAds).css({"visibility": "visible", "display": "block"}); 1590 click_count[index] = 2; 1591 } 1592 1593 if (need_repeat_ad(videoDataTimePlayAgain, index) && !flag[index]) { 1594 flag[index] = true; 1595 1596 //display ads and play it 1597 $global_this.find('.' + cactusVideoAds).css({"visibility": "visible", "display": "block"}); 1598 1599 if (videoAdsType == 'video') { 1600 //pause main video 1601 cactus_player[index].pauseVideo(); 1602 1603 $this.find('.' + cactusVideoAds).find('.linkads').attr("href", playbackDataLinkRedirect); 1604 if (videoAdsSource == 'youtube') { 1605 playbackVideoAdsURL = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'youtube' ? playbackVideoAds : videoAds; 1606 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'youtube' ? playbackAdsID : adsID; 1607 1608 cactus_player_Ads[index].destroy(); 1609 1610 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 1611 1612 //ajax track click to second ads here 1613 ajax_track(playbackVideoAdsID, 0, false, true); 1614 1615 }); 1616 1617 function onPlayerReady_auto1(event) { 1618 1619 if (screenfull.isFullscreen == false) { 1620 cactus_player_Ads[index].seekTo(0, true); 1621 cactus_player_Ads[index].playVideo(); 1622 } else { 1623 cactus_player_Ads[index].stopVideo(); 1624 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1625 cactus_player[index].playVideo(); 1626 } 1627 } 1628 1629 function onPlayerStateChange_auto1(event) { 1630 1631 // $this.find('.'+cactusVideoAds).find('#close-'+AdsVideoId+'').click(function(){ 1632 if (isClickCloseButtonFirstTime == false) { 1633 $this.find('.' + cactusVideoAds).find('#close-' + AdsVideoId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 1634 close_the_ads('close', cactus_player_Ads[index], cactus_player[index], playbackVideoAdsID, index); 1635 }); 1636 } 1637 1638 if (event.data === 0) { 1639 close_the_ads('ended', cactus_player_Ads[index], cactus_player[index], playbackVideoAdsID, index); 1640 } 1641 } 1642 1643 1644 cactus_player_Ads[index] = new YT.Player(AdsVideoId, { 1645 width: checkWidth, 1646 height: checkHeight, 1647 videoId: playbackVideoAdsURL, 1648 playerVars: { 1649 controls: 0, 1650 showinfo: 0, 1651 enablejsapi: 1, 1652 autoplay: 1, 1653 disablekb: 1, 1654 }, 1655 events: { 1656 'onReady': onPlayerReady_auto1, 1657 'onStateChange': onPlayerStateChange_auto1 1658 } 1659 }); 1660 } else if (videoAdsSource == 'vimeo') { 1661 playbackVideoAdsURL = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'vimeo' ? playbackVideoAds : videoAds; 1662 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'vimeo' ? playbackAdsID : adsID; 1663 $global_this.find('.' + cactusVideoAds + ' iframe#player-vimeo-' + index).attr('src', 'https://player.vimeo.com/video/' + playbackVideoAdsURL + '?api=1&player_id=player-vimeo-' + index + '&autoplay=1'); 1664 1665 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 1666 //ajax track click to first ads here 1667 ajax_track(playbackVideoAdsID, 0, false, true); 1668 }); 1669 1670 if (screenfull.isFullscreen == false) { 1671 cactus_vimeo_player_Ads[index].setCurrentTime(0); 1672 cactus_vimeo_player_Ads[index].play(); 1673 } else { 1674 $global_this.find('.' + cactusVideoAds + ' iframe#player-vimeo-' + index).remove(); 1675 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1676 cactus_player[index].playVideo(); 1677 } 1678 1679 isVimeoPlayback = true; 1680 } else if (videoAdsSource == 'self-hosted') { 1681 playbackVideoAdsURL = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'self-hosted' ? playbackVideoAds : videoAds; 1682 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'self-hosted' ? playbackAdsID : adsID; 1683 1684 $this.find('.' + cactusVideoAds + ' video#player-html5-' + index).attr('src', playbackVideoAdsURL); 1685 $this.find('.' + cactusVideoAds).find('.linkads').attr("href", playbackDataLinkRedirect); 1686 1687 cactus_html5_player_Ads[index] = $this.find('.' + cactusVideoAds).find('.wp-video-shortcode'); 1688 1689 if (screenfull.isFullscreen == false) { 1690 cactus_html5_player_Ads[index].get(0).play(); 1691 } else { 1692 cactus_html5_player_Ads[index].get(0).pause(); 1693 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1694 cactus_player[index].playVideo(); 1695 } 1696 1697 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 1698 //ajax track click to first ads here 1699 ajax_track(playbackVideoAdsID, 0, false, true); 1700 }); 1701 1702 // cactus_html5_player_Ads[index].get(0).play(); 1703 } 1704 } else if (videoAdsType == '') { 1705 $global_this.find('.' + cactusVideoAds).css({ 1706 "visibility": "hidden", 1707 "display": "none" 1708 }); 1709 } else if (videoAdsType == 'adsense') { 1710 if (adsImagePosition == '1') 1711 $global_this.find('.' + cactusVideoAds).css({ 1712 "visibility": "hidden", 1713 "display": "none" 1714 }); 1715 } else { 1716 //ads image 1717 if (adsImagePosition == '2' || adsImagePosition == '3') { 1718 cactus_player[index].playVideo(); 1719 playbackVideoAdsID = playbackVideoAds != '' && playbackVideoAdsType == 'image' && (playbackAdsImagePosition == '2' || playbackAdsImagePosition == '3') ? playbackAdsID : adsID; 1720 1721 $this.find('.' + cactusVideoAds).find('.banner-img a img.second-img').off('.clickToSecondAds').on('click.clickToSecondAds', function () { 1722 //ajax track click to second top ads here 1723 ajax_track(playbackVideoAdsID, 0, false, true); 1724 }); 1725 1726 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 1727 ajax_track(playbackVideoAdsID, 0, true, false); 1728 1729 // reset the chunk 1730 cactus_player_chunk[index] = 0; 1731 flag[index] = false;
1732 }); 1733 } else { 1734 //pause main video 1735 cactus_player[index].pauseVideo(); 1736 } 1737 } 1738 } 1739 } 1740 1741 } else if (videoSource == 'vimeo') { 1742 1743 if (flag_vimeo[index] == true) { 1744 flag_vimeo[index] = true; 1745 } else { 1746 flag_vimeo[index] = false; 1747 } 1748 1749 $this.find('.' + cactusVideoDetails).find('.' + cactusVideoContent).html('<iframe id="player-vimeo-' + index + '" src="https://player.vimeo.com/video/' + videoLink + '" width="' + checkWidth + '" height="' + checkHeight + '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'); 1750 1751 cactus_main_vimeo[index] = $('#player-vimeo-' + index)[0]; 1752 cactus_main_vimeo_player[index] = new Vimeo.Player(cactus_main_vimeo[index]); 1753 1754 function onFinish(id) { 1755 // status.text('finished'); 1756 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1757 if (showSharePopup == 'on') { 1758 $('body').addClass('popup-share-active'); 1759 } 1760 1761 setTimeout(function () { 1762 if (autoLoadNextVideo != 3) { 1763 var link = $('.prev-post a').attr('href'); 1764 if (autoLoadNextVideoOptions == 1) { 1765 link = jQuery('.next-post a').attr('href'); 1766 } 1767 } else if (autoLoadNextVideo == 3) { 1768 var link = window.location.href; 1769 } 1770 var className = $('#tm-autonext span#autonext').attr('class'); 1771 //alert(className); 1772 if (className != '') { 1773 if (link != undefined) { 1774 window.location.href = link; 1775 } 1776 } 1777 }, autoLoadNextVideoSeconds); 1778 } 1779 1780 function onPlayProgress(data) { 1781 1782 // status.text(data.seconds + 's played'); 1783 if (data.seconds > 0 && (videoAdsType == 'image' && (adsImagePosition == '2' || adsImagePosition == '3')) && click_count[index] != 1) { 1784 $global_this.find('.' + cactusVideoAds).css({"visibility": "visible", "display": "block"}); 1785 } 1786 1787 videoPlayCurrentTime = data.seconds; 1788 1789 // increase the chunk count 1790 if (videoPlayCurrentTime > video_last_current_time) { 1791 cactus_player_chunk[index] += videoPlayCurrentTime - video_last_current_time; 1792 } 1793 video_last_current_time = videoPlayCurrentTime; 1794 1795 1796 if (need_repeat_ad(videoDataTimePlayAgain, index) && !flag[index]) { 1797 flag[index] = true; 1798 1799 // display ads and play it 1800 setTimeout(show_the_ads, 700, $global_this.find('.' + cactusVideoAds)); 1801 1802 if (videoAdsType == 'video') { 1803 //pause main video 1804 setTimeout(control_the_vimeo_player, 500, cactus_main_vimeo_player[index], true, false); 1805 1806 if (videoAdsSource == 'youtube') { 1807 $this.find('.' + cactusVideoAds).find('.linkads').attr("href", playbackDataLinkRedirect); 1808 playbackVideoAdsURL = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'youtube' ? playbackVideoAds : videoAds; 1809 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'youtube' ? playbackAdsID : adsID; 1810 1811 cactus_player_Ads[index].destroy(); 1812 1813 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 1814 1815 //ajax track click to second ads here 1816 ajax_track(playbackVideoAdsID, 0, false, true); 1817 1818 }); 1819 1820 function onPlayerReady_auto1(event) { 1821 if (screenfull.isFullscreen == false) { 1822 cactus_player_Ads[index].seekTo(0, true); 1823 cactus_player_Ads[index].playVideo(); 1824 } else { 1825 cactus_player_Ads[index].stopVideo(); 1826 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1827 cactus_main_vimeo_player[index].play(); 1828 } 1829 } 1830 1831 function onPlayerStateChange_auto1(event) { 1832 1833 if (isClickCloseButtonFirstTime == false) { 1834 $this.find('.' + cactusVideoAds).find('#close-' + AdsVideoId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 1835 close_the_ads('close', cactus_player_Ads[index], cactus_main_vimeo_player[index], playbackVideoAdsID, index); 1836 }); 1837 } 1838 1839 if (event.data === 0) { 1840 close_the_ads('ended', cactus_player_Ads[index], cactus_main_vimeo_player[index], playbackVideoAdsID, index); 1841 } 1842 } 1843 1844 cactus_player_Ads[index] = new YT.Player(AdsVideoId, { 1845 width: checkWidth, 1846 height: checkHeight, 1847 videoId: playbackVideoAdsURL, 1848 playerVars: { 1849 controls: 0, 1850 showinfo: 0, 1851 enablejsapi: 1, 1852 autoplay: 1, 1853 disablekb: 1, 1854 }, 1855 events: { 1856 'onReady': onPlayerReady_auto1, 1857 'onStateChange': onPlayerStateChange_auto1 1858 } 1859 }); 1860 } else if (videoAdsSource == 'vimeo') { 1861 $this.find('.' + cactusVideoAds).find('.linkads').attr("href", playbackDataLinkRedirect); 1862 playbackVideoAdsURL = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'vimeo' ? playbackVideoAds : videoAds; 1863 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'vimeo' ? playbackAdsID : adsID; 1864 1865 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 1866 //ajax track click to first ads here 1867 ajax_track(playbackVideoAdsID, 0, false, true); 1868 }); 1869 1870 if (screenfull.isFullscreen == false) { 1871 cactus_vimeo_player_Ads[index].setCurrentTime(0); 1872 cactus_vimeo_player_Ads[index].play(); 1873 } else { 1874 $global_this.find('.' + cactusVideoAds + ' iframe#ads-vimeo-player' + index).remove(); 1875 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1876 cactus_main_vimeo_player[index].play(); 1877 } 1878 1879 isVimeoPlayback = true; 1880 } else if (videoAdsSource == 'self-hosted') { 1881 playbackVideoAdsURL = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'self-hosted' ? playbackVideoAds : videoAds; 1882 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'self-hosted' ? playbackAdsID : adsID; 1883 1884 $this.find('.' + cactusVideoAds + ' video#player-html5-' + index).attr('src', playbackVideoAdsURL); 1885 $this.find('.' + cactusVideoAds).find('.linkads').attr("href", playbackDataLinkRedirect); 1886 1887 cactus_html5_player_Ads[index] = $this.find('.' + cactusVideoAds).find('.wp-video-shortcode'); 1888 1889 if (screenfull.isFullscreen == false) { 1890 cactus_html5_player_Ads[index].get(0).play(); 1891 } else { 1892 cactus_html5_player_Ads[index].get(0).pause(); 1893 $this.find('.' + cactusVideoAds).css({"display": "none"}); 1894 cactus_main_vimeo_player[index].play(); 1895 } 1896 1897 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 1898 //ajax track click to first ads here 1899 ajax_track(playbackVideoAdsID, 0, false, true); 1900 }); 1901 1902 } 1903 } else if (videoAdsType == '') { 1904 $global_this.find('.' + cactusVideoAds).css({ 1905 "visibility": "hidden", 1906 "display": "none" 1907 }); 1908 cactus_main_vimeo_player[index].play(); 1909 } else if (videoAdsType == 'adsense') { 1910 // HTML add for Vimeo 1911 if (adsImagePosition == '1') 1912 $global_this.find('.' + cactusVideoAds).css({ 1913 "visibility": "hidden", 1914 "display": "none" 1915 }); 1916 cactus_main_vimeo_player[index].play(); 1917 } else { 1918 if (adsImagePosition == '2' || adsImagePosition == '3') { 1919 //cactus_main_vimeo_player[index].play(); 1920 playbackVideoAdsID = playbackVideoAds != '' && playbackVideoAdsType == 'image' && (playbackAdsImagePosition == '2' || playbackAdsImagePosition == '3') ? playbackAdsID : adsID; 1921 1922 $this.find('.' + cactusVideoAds).find('.banner-img a img.second-img').off('.clickToSecondAds').on('click.clickToSecondAds', function () { 1923 //ajax track click to second top ads here 1924 ajax_track(playbackVideoAdsID, 0, false, true); 1925 }); 1926 1927 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 1928 ajax_track(playbackVideoAdsID, 0, true, false); 1929 1930 // reset the chunk 1931 cactus_player_chunk[index] = 0; 1932 flag[index] = false;
1933 }); 1934 } else { 1935 //pause main video 1936 setTimeout(control_the_vimeo_player, 500, cactus_main_vimeo_player[index], true, false); 1937 } 1938 } 1939 1940 flag_vimeo[index] = true; 1941 } // end of repeat ad 1942 } 1943 1944 1945 // When the cactus_vimeo_player_Ads[index] is ready, add listeners for pause, finish, and playProgress 1946 cactus_main_vimeo_player[index].on('ended', onFinish); 1947 cactus_main_vimeo_player[index].on('timeupdate', onPlayProgress); 1948 if (videoAdsType == '') { 1949 $global_this.find('.' + cactusVideoAds).css({"visibility": "hidden", "display": "none"}); 1950 cactus_main_vimeo_player[index].play(); 1951 } 1952 1953 // Auto Play Vimeo 1954 if (videoAutoPlay == "1") { 1955 if (videoAds != '' && videoAds != null && videoAdsType != '') { 1956 $this.find('.' + cactusVideoAds).css("visibility", "visible"); 1957 var divVideoAdsId = cactusVideoAds + '-' + index; 1958 if (videoAdsType == 'video') { 1959 if (videoAdsSource == 'youtube') { 1960 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 1961 1962 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 1963 //ajax track click to first ads here 1964 ajax_track(adsID, 0, false, true); 1965 }); 1966 1967 function onPlayerReady_auto(event) { 1968 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 1969 "opacity": "0", 1970 "cursor": "auto" 1971 }); 1972 $this.find('.' + cactusVideoAds).find('.linkads').css({ 1973 "opacity": "1", 1974 "visibility": "visible" 1975 }); 1976 1977 var youtubeAdsInterval = null; 1978 1979 function adsPlayCurrentTime_func() { 1980 videoPlayCurrentTime = cactus_player_Ads[index].getCurrentTime(); 1981 if (parseInt(videoPlayCurrentTime) >= videoDataTimeHideAds) { 1982 1983 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 1984 "visibility": "visible", 1985 "opacity": "1" 1986 }).text(closeButtonName); 1987 1988 if (isClickCloseButtonFirstTime == true) { 1989 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 1990 close_the_ads('ended', cactus_player_Ads[index], cactus_main_vimeo_player[index], adsID, index); 1991 1992 if (youtubeAdsInterval != null) { 1993 clearInterval(youtubeAdsInterval); 1994 } 1995 isClickCloseButtonFirstTime = false; 1996 }); 1997 } 1998 1999 } 2000 } 2001 2002 youtubeAdsInterval = setInterval(adsPlayCurrentTime_func, 500); 2003 } 2004 2005 function onPlayerStateChange_auto(event) { 2006 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 2007 "opacity": "0",
2008 "cursor": "auto" 2009 }); 2010 $this.find('.' + cactusVideoAds).find('.linkads').css({ 2011 "opacity": "1", 2012 "visibility": "visible" 2013 }); 2014 2015 if (event.data === 0) { 2016 close_the_ads('ended', cactus_player_Ads[index], cactus_main_vimeo_player[index], adsID, index); 2017 } 2018 } 2019 2020 cactus_player_Ads[index] = new YT.Player(divVideoAdsId, { 2021 width: checkWidth, 2022 height: checkHeight, 2023 videoId: videoAds, 2024 playerVars: { 2025 controls: 0, 2026 showinfo: 0, 2027 enablejsapi: 1, 2028 autoplay: 1, 2029 disablekb: 1, 2030 }, 2031 events: { 2032 'onReady': onPlayerReady_auto, 2033 'onStateChange': onPlayerStateChange_auto 2034 } 2035 }); 2036 } else if (videoAdsSource == 'vimeo') { 2037 setup_vimeo_ad(index); 2038 } else if (videoAdsSource == 'self-hosted') { 2039 cactus_player[index] = cactus_main_vimeo_player[index]; 2040 setup_selfhosted_ad(index); 2041 } 2042 } else { 2043 if (videoAdsType == 'image') 2044 //ads images 2045 { 2046 // Hidden ads images 2047 $this.find('.' + cactusVideoAds).css("visibility", "hidden"); 2048 2049 //full size 2050 if (adsImagePosition == '1' || adsImagePosition == 'undefined' || adsImagePosition == '') { 2051 $this.find('.' + cactusVideoAds).css("display", "none"); 2052 // prepare ads images 2053 $this.find('.' + cactusVideoAds).html('<a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img src="' + videoAds + '"/></a>'); 2054 $this.find('.' + cactusVideoAds + ' img').css({ 2055 "width": "100%", 2056 "height": "100%" 2057 }); 2058 2059 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 2060 2061 $this.find('.' + cactusVideoAds).find('a img').off('.clickToAds').on('click.clickToAds', function () { 2062 //ajax track click to full ads here 2063 ajax_track(adsID, 0, false, true); 2064 }); 2065 2066 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 2067 "visibility": "visible", 2068 "opacity": "1" 2069 }).text(closeButtonName); 2070 2071 2072 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').click(function () { 2073 ajax_track(adsID, 0, true, false); 2074 $this.find('.' + cactusVideoAds).css({"display": "none"}); 2075 cactus_main_vimeo_player[index].play(); 2076 }); 2077 } else { 2078 // top banner 2079 if (adsImagePosition == '2') { 2080 // prepare ads images 2081 $this.find('.' + cactusVideoAds).css({ 2082 "pointer-events": "none", 2083 'z-index': '10' 2084 }); 2085 $('<img src="' + videoAds + '">').load(function () { 2086 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>');
2087 var playerHeight = checkHeight; 2088 var playerWidth = checkWidth; 2089 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2090 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2091 2092 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2093 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2094 2095 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 2096 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2097 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 2098 'right': dscFromRightPlayertoImg + 10 + 'px' 2099 }); 2100 2101 $(window).resize(function () { 2102 setTimeout(function () { 2103 playerWidth = $('.cactus-video-content').width(); 2104 playerHeight = (checkWidth / 16 * 9); 2105 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2106 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2107 dscFromBottomPlayertoImg = playerHeight - imgHeight; 2108 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2109 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2110 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 2111 'right': dscFromRightPlayertoImg + 10 + 'px' 2112 }); 2113 }, 400) 2114 }); 2115 2116 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 2117 //ajax track click to first top ads here 2118 ajax_track(adsID, 0, false, true); 2119 }); 2120 2121 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 2122 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '2') { 2123 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 2124 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 2125 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 2126 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 2127 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 2128 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 2129 playerWidth = $('.cactus-video-content').width(); 2130 playerHe
2130ight = (playerWidth / 16 * 9); 2131 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2132 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2133 2134 dscFromBottomPlayertoImg = playerHeight - imgHeight; 2135 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2136 2137 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2138 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 2139 'right': dscFromRightPlayertoImg + 10 + 'px' 2140 }); 2141 } else { 2142 $this.find('.' + cactusVideoAds).css({"display": "none"}); 2143 } 2144 if (click_count[index] != '1') { 2145 ajax_track(adsID, 0, true, false); 2146 } 2147 click_count[index] = '1'; 2148 }); 2149 }); 2150 2151 // $this.find('.'+cactusVideoAds + ' img').css({"width":"100%", "height":"auto"}); 2152 2153 } 2154 //bottom banner 2155 else if (adsImagePosition == '3') { 2156 // prepare ads images 2157 $this.find('.' + cactusVideoAds).css({ 2158 "height": "auto", 2159 "top": "0", 2160 "pointer-events": "none", 2161 'z-index': '10' 2162 }); 2163 $('<img src="' + videoAds + '">').load(function () { 2164 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>'); 2165 2166 var playerHeight = checkHeight; 2167 var playerWidth = checkWidth; 2168 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2169 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2170 2171 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2172 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2173 2174 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 2175 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 2176 'padding-bottom': '40px', 2177 'top': 'auto' 2178 }); 2179 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2180 'top': '10px', 2181 'right': dscFromRightPlayertoImg + 10 + 'px' 2182 }); 2183 2184 $(window).resize(function () { 2185 setTimeout(function () { 2186 playerWidth = $('.cactus-video-content').width(); 2187 playerHe
2187ight = (checkWidth / 16 * 9); 2188 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2189 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2190 dscFromBottomPlayertoImg = playerHeight - imgHeight; 2191 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2192 if (playerWidth < 600) { 2193 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': '0'}); 2194 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2195 'top': 'auto', 2196 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 2197 'right': dscFromRightPlayertoImg + 10 + 'px' 2198 }); 2199 } else { 2200 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': 'auto'}); 2201 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2202 'top': '10px', 2203 'right': dscFromRightPlayertoImg + 10 + 'px' 2204 }); 2205 } 2206 }, 400) 2207 }); 2208 2209 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 2210 //ajax track click to first top ads here 2211 ajax_track(adsID, 0, false, true); 2212 }); 2213 2214 2215 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 2216 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '3') { 2217 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 2218 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 2219 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 2220 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 2221 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 2222 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 2223 playerWidth = $('.cactus-video-content').width(); 2224 playerHeight = (playerWidth / 16 * 9); 2225 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2226 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2227 2228 dscFromBottomPlayertoImg = playerHeight - imgHeight; 2229 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2230 2231 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 2232 'padding-bottom': '40px', 2233 'top': 'auto' 2234 }); 2235 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2236 'top': '10px', 2237 'right': dscFromRightPlayertoImg + 10 + 'px' 2238 }); 2239 } else { 2240 $this.find('.' + cactusVideoAds).css({"display": "none"}); 2241 } 2242 if (click_count[index] != '1') { 2243 ajax_track(adsID, 0, true, false); 2244 } 2245 click_count[index] = '1'; 2246 }); 2247 }); 2248 } 2249 } 2250 } else if (videoAdsType == 'adsense') { 2251 // HTML Ad on Vimeo. Autoplay case 2252 if (adsImagePosition == '1' || adsImagePosition == '') { 2253 adsImagePosition = '2'; 2254 } 2255 // Hidden ads images 2256 $this.find('.' + cactusVideoAds).css("display", "none"); 2257 2258 // top banner 2259 if (adsImagePosition == '2') { 2260 $this.find('.' + cactusVideoAds).css({ 2261 "height": "0", 2262 "pointer-events": "none", 2263 'z-index': '10' 2264 }); 2265 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 2266
2267 var playerHeight = checkHeight; 2268 var playerWidth = checkWidth; 2269 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 2270 var imgWidth = $this.find('.' + cactusVideoAds).width(); 2271 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2272 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2273 2274 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 2275 if (playerWidth < 600) { 2276 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2277 "width": imgWidth + "px", 2278 "height": imgHeight + "px" 2279 }); 2280 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2281 'top': 'auto', 2282 'bottom': '30px', 2283 'right': dscFromRightPlayertoImg + 10 + 'px' 2284 }); 2285 } else { 2286 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2287 "width": "728px", 2288 "height": imgHeight + "px" 2289 }); 2290 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2291 'top': '65px', 2292 'right': dscFromRightPlayertoImg + 10 + 'px' 2293 }); 2294 } 2295 2296 2297 $(window).resize(function () { 2298 setTimeout(function () { 2299 playerWidth = $('.cactus-video-content').width(); 2300 playerHeight = (checkWidth / 16 * 9); 2301 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 2302 var imgWidth = $this.find('.' + cactusVideoAds).width(); 2303 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2304 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2305 if (playerWidth < 600) { 2306 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2307 "width": imgWidth + "px", 2308 "height": imgHeight + "px" 2309 }); 2310 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2311 'top': 'auto', 2312 'bottom': '30px', 2313 'right': dscFromRightPlayertoImg + 10 + 'px' 2314 }); 2315 } else { 2316 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2317 "width": "728px", 2318 "height": imgHeight + "px" 2319 }); 2320 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2321 'top': '65px', 2322 'right': dscFromRightPlayertoImg + 10 + 'px' 2323 }); 2324 } 2325 }, 400) 2326 }); 2327 2328 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 2329 close_the_ads('close', '.cactusVideoAds', cactus_main_vimeo_player[index], adsID, index); 2330 }); 2331 2332 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 2333 ajax_track(adsID, 0, false, true); 2334 }); 2335 } 2336 //bottom banner 2337 else if (adsImagePosition == '3') { 2338 $this.find('.' + cactusVideoAds).css({ 2339 "height": "auto", 2340 "top": "auto", 2341 "pointer-events": "none", 2342 'z-index': '10' 2343 }); 2344 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 2345 2346
2347 var playerHeight = checkHeight; 2348 var playerWidth = checkWidth; 2349 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 2350 var imgWidth = $this.find('.' + cactusVideoAds).width(); 2351 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2352 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2353 2354 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 2355 if (playerWidth < 600) { 2356 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2357 "width": imgWidth + "px", 2358 "height": imgHeight + "px" 2359 }); 2360 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': 'auto', 'bottom': '30px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 2361 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2362 'top': '10px', 2363 'right': '10px' 2364 }); 2365 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 2366 } else { 2367 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2368 "width": "728px", 2369 "height": imgHeight + "px" 2370 }); 2371 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': '65px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 2372 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2373 'top': '10px', 2374 'right': '10px' 2375 }); 2376 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 2377 } 2378 2379 2380 $(window).resize(function () { 2381 setTimeout(function () { 2382 playerWidth = $('.cactus-video-content').width(); 2383 playerHeight = (checkWidth / 16 * 9); 2384 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 2385 var imgWidth = $this.find('.' + cactusVideoAds).width(); 2386 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2387 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2388 if (playerWidth < 600) { 2389 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2390 "width": imgWidth + "px", 2391 "height": imgHeight + "px" 2392 }); 2393 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2394 'top': '10px', 2395 'right': '10px' 2396 }); 2397 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 2398 } else { 2399 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2400 "width": "728px", 2401 "height": imgHeight + "px" 2402 }); 2403 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2404 'top': '10px', 2405 'right': '10px' 2406 }); 2407 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 2408 2409 } 2410 }, 400) 2411 }); 2412 2413 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 2414 close_the_ads('close', '.cactusVideoAds', cactus_main_vimeo_player[index], adsID, index); 2415 }); 2416 2417 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 2418 ajax_track(adsID, 0, false, true); 2419 }); 2420 2421 } 2422 } 2423 2424 2425 //play vimeo video 2426 cactus_main_vimeo_player[index].play(); 2427 cactus_main_vimeo_player[index].on('ended', onFinish); 2428 cactus_main_vimeo_player[index].on('timeupdate', onPlayProgress); 2429 } 2430 } else { 2431 //play video 2432 cactus_main_vimeo_player[index].play(); 2433 } 2434 } else { 2435 // not autoplay Vimeo player 2436 if (videoAds != '' && videoAds != null && videoAdsType != '') { 2437 $this.find('.' + cactusVideoAds).css("visibility", "hidden"); 2438 var divVideoAdsId = cactusVideoAds + '-' + index; 2439 if (videoAdsType == 'video') { 2440 if (videoAdsSource == 'youtube') { 2441 mask_button($this, cactusVideoAds, videoAdsSource, videoSource); 2442 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 2443 2444 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 2445 //ajax track click to first ads here 2446 ajax_track(adsID, 0, false, true); 2447 }); 2448 2449 $this.find('.' + cactusVideoAds).find(".hide-pause.button-start").click(function () { 2450 if ($('body').hasClass('mobile')) { 2451 $('body').addClass('mobile-clicked'); 2452 } 2453 $this.find('.' + cactusVideoAds).css("visibility", "visible"); 2454 2455 function onPlayerReady_nauto(event) { 2456 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 2457 "opacity": "0",
2458 "cursor": "auto" 2459 }); 2460 $this.find('.' + cactusVideoAds).find('.linkads').css({ 2461 "opacity": "1", 2462 "visibility": "visible" 2463 }); 2464 } 2465 2466 function onPlayerStateChange_nauto(event) { 2467 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 2468 "opacity": "0", 2469 "cursor": "auto" 2470 }); 2471 $this.find('.' + cactusVideoAds).find('.linkads').css({ 2472 "opacity": "1", 2473 "visibility": "visible" 2474 }); 2475 2476 if (event.data === 0) { 2477 close_the_ads('ended', cactus_player_Ads[index], cactus_main_vimeo_player[index], adsID, index); 2478 } 2479 2480 var youtubeAdsInterval = null; 2481 2482 function adsPlayCurrentTime_func() { 2483 videoPlayCurrentTime = cactus_player_Ads[index].getCurrentTime(); 2484 if (parseInt(videoPlayCurrentTime) >= videoDataTimeHideAds) { 2485 clearInterval(adsPlayCurrentTime_func); 2486 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 2487 "visibility": "visible", 2488 "opacity": "1" 2489 }).text(closeButtonName); 2490 2491 if (isClickCloseButtonFirstTime == true) { 2492 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 2493 close_the_ads('close', cactus_player_Ads[index], cactus_main_vimeo_player[index], adsID, index); 2494 }); 2495 } 2496 2497 } 2498 } 2499 2500 youtubeAdsInterval = setInterval(adsPlayCurrentTime_func, 500); 2501 } 2502 2503 cactus_player_Ads[index] = new YT.Player(divVideoAdsId, { 2504 width: checkWidth, 2505 height: checkHeight, 2506 videoId: videoAds, 2507 playerVars: { 2508 controls: 0, 2509 showinfo: 0, 2510 enablejsapi: 1, 2511 autoplay: 1, 2512 disablekb: 1, 2513 }, 2514 events: { 2515 'onReady': onPlayerReady_nauto, 2516 'onStateChange': onPlayerStateChange_nauto 2517 } 2518 }); 2519 }); 2520 } else if (videoAdsSource == 'vimeo') { 2521 if (flag_ads_vimeo[index] == true) { 2522 flag_ads_vimeo[index] = true; 2523 } else { 2524 flag_ads_vimeo[index] = false;
2525 } 2526 2527 mask_button($this, cactusVideoAds, videoAdsSource, videoSource); 2528 2529 2530 $this.find('.' + cactusVideoAds).find(".hide-pause.button-start").click(function () { 2531 if ($('body').hasClass('mobile')) { 2532 $('body').addClass('mobile-clicked'); 2533 } 2534 $this.find('.' + cactusVideoAds).html('<iframe id="ads-vimeo-player' + index + '" src="https://player.vimeo.com/video/' + videoAds + '" width="' + checkWidth + '" height="' + checkHeight + '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'); 2535 2536 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, videoAdsSource, videoDataTarget); 2537 2538 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 2539 //ajax track click to first ads here 2540 ajax_track(adsID, 0, false, true); 2541 }); 2542 2543 $this.find('.' + cactusVideoAds).find('.linkads').css({ 2544 "opacity": "1", 2545 "visibility": "visible" 2546 }); 2547 2548 $this.find('.' + cactusVideoAds).css("visibility", "visible"); 2549 2550 cactus_ads_vimeo_obj[index] = $('#ads-vimeo-player' + index)[0]; 2551 cactus_ads_vimeo_player[index] = new Vimeo.Player(cactus_ads_vimeo_obj[index]); 2552 2553 2554 function onPauseAds(id) { 2555 2556 } 2557 2558 function onFinishAds(id) { 2559 close_the_ads('ended', cactus_ads_vimeo_player[index], cactus_main_vimeo_player[index], playbackVideoAdsID, index); 2560 } 2561 2562 function onPlayProgressAds(data, id) { 2563 2564 vimeoAdsDuration = data.duration; 2565 if (data.seconds > videoDataTimeHideAds && flag_ads_vimeo[index] == false) { 2566 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 2567 "visibility": "visible", 2568 "opacity": "1" 2569 }).text(closeButtonName); 2570 2571 currentTimeVideoCheck = data.seconds; 2572 2573 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeVimeoAds').on('click.closeVimeoAds', function () { 2574 close_the_ads('close', cactus_ads_vimeo_player[index], cactus_main_vimeo_player[index], playbackVideoAdsID, index); 2575 2576 flag_ads_vimeo[index] = true; 2577 }); 2578 } 2579 } 2580 2581 cactus_ads_vimeo_player[index].on('pause', onPauseAds); 2582 cactus_ads_vimeo_player[index].on('ended', onFinishAds); 2583 var currentTimeVideoCheck = 0; 2584 var vimeoAdsDuration = 0; 2585 if (isVimeoPlayback == true) { 2586 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'vimeo' ? playbackAdsID : adsID; 2587 } else { 2588 playbackVideoAdsID = adsID; 2589 } 2590 cactus_ads_vimeo_player[index].on('timeupdate', onPlayProgressAds); 2591 }); 2592 } else if (videoAdsSource == 'self-hosted') { 2593 $this.find('.' + cactusVideoAds).css("visibility", "visible"); 2594 mask_button($this, cactusVideoAds, videoAdsSource, videoSource); 2595 $this.find('.' + cactusVideoAds).find(".hide-pause.button-start").click(function () { 2596 if ($('body').hasClass('mobile')) { 2597 $('body').addClass('mobile-clicked'); 2598 } 2599 $this.find('.' + cactusVideoAds).html('<video id="player-html5-' + index + '" class="wp-video-shortcode" autoplay="true" preload="auto" controls="controls" style="width:100%"><source src="' + videoAds + '" type="video/mp4"></video><div>'); 2600 2601 cactus_html5_player_Ads[index] = $this.find('.' + cactusVideoAds).find('.wp-video-shortcode'); 2602 2603 cactus_html5_player_Ads[index].get(0).play(); 2604 2605 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 2606 2607 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 2608 //ajax track click to first ads here 2609 ajax_track(adsID, 0, false, true); 2610 }); 2611 2612 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 2613 "opacity": "0",
2614 "cursor": "auto" 2615 }); 2616 $this.find('.' + cactusVideoAds).find('.linkads').css({ 2617 "opacity": "1", 2618 "visibility": "visible" 2619 }); 2620 2621 // when youtube html 5 ads finish 2622 cactus_html5_player_Ads[index].get(0).onended = function (e) { 2623 // alert('end video'); 2624 videoPlayFullTime = cactus_html5_player_Ads[index].get(0).duration; 2625 //ajax track close here when finish ads first time 2626 ajax_track(adsID, videoPlayFullTime, false, false); 2627 2628 $this.find('.' + cactusVideoAds).css({"display": "none"}); 2629 cactus_main_vimeo_player[index].play(); 2630 } 2631 2632 var html5AdsInterval = null; 2633 2634 function adsPlayCurrentTime_func() { 2635 videoHtml5PlayCurrentTime = cactus_html5_player_Ads[index].get(0).currentTime; 2636 cactus_html5_player_Ads[index].get(0).addEventListener("timeupdate", function () { 2637 if (videoHtml5PlayCurrentTime >= videoDataTimeHideAds) { 2638 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 2639 "visibility": "visible", 2640 "opacity": "1" 2641 }).text(closeButtonName); 2642 2643 if (isClickCloseButtonFirstTime == true) { 2644 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 2645 close_the_ads('close', cactus_html5_player_Ads[index].get(0), cactus_main_vimeo_player[index], adsID, index); 2646 2647 if (html5AdsInterval != null) { 2648 clearInterval(html5AdsInterval); 2649 } 2650 isClickCloseButtonFirstTime = false; 2651 }); 2652 } 2653 } 2654 }); 2655 } 2656 2657 html5AdsInterval = setInterval(adsPlayCurrentTime_func, 500) 2658 }); 2659 } 2660 } else { 2661 if (videoAdsType == 'image') { 2662 //ads images 2663 2664 // Hidden ads images 2665 $this.find('.' + cactusVideoAds).css("visible", "hidden"); 2666 2667 //full size 2668 if (adsImagePosition == '1' || adsImagePosition == 'undefined' || adsImagePosition == '') { 2669 $this.find('.' + cactusVideoAds).css("display", "none"); 2670 // prepare ads images 2671 $this.find('.' + cactusVideoAds).html('<a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img src="' + videoAds + '"/></a>'); 2672 $this.find('.' + cactusVideoAds + ' img').css({ 2673 "width": "100%", 2674 "height": "100%" 2675 }); 2676 2677 $this.find('.' + cactusVideoAds).find('a img').off('.clickToAds').on('click.clickToAds', function () { 2678 //ajax track click to full ads here 2679 ajax_track(adsID, 0, false, true); 2680 }); 2681 2682 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 2683 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 2684 "visibility": "visible", 2685 "opacity": "1" 2686 }).text(closeButtonName); 2687 2688 2689 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').click(function () { 2690 //ajax track close full ads here 2691 ajax_track(adsID, 0, true, false); 2692 $this.find('.' + cactusVideoAds).css({"display": "none"}); 2693 cactus_main_vimeo_player[index].play(); 2694 }); 2695 } else { 2696 // top banner 2697 if (adsImagePosition == '2') { 2698 // prepare ads images 2699 $this.find('.' + cactusVideoAds).css({ 2700 "pointer-events": "none", 2701 'z-index': '10' 2702 }); 2703 $('<img src="' + videoAds + '">').load(function () { 2704 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>');
2705 var playerHeight = checkHeight; 2706 var playerWidth = checkWidth; 2707 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2708 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2709 2710 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2711 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2712 2713 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 2714 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2715 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 2716 'right': dscFromRightPlayertoImg + 10 + 'px' 2717 }); 2718 2719 $(window).resize(function () { 2720 setTimeout(function () { 2721 playerWidth = $('.cactus-video-content').width(); 2722 playerHeight = (checkWidth / 16 * 9); 2723 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2724 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2725 dscFromBottomPlayertoImg = playerHeight - imgHeight; 2726 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2727 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2728 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 2729 'right': dscFromRightPlayertoImg + 10 + 'px' 2730 }); 2731 }, 400) 2732 }); 2733 2734 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 2735 //ajax track click to first top ads here 2736 ajax_track(adsID, 0, false, true); 2737 }); 2738 2739 2740 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 2741 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '2') { 2742 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 2743 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 2744 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 2745 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 2746 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 2747 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 2748 playerWidth = $('.cactus-video-content').width(); 2749 playerHe
2749ight = (playerWidth / 16 * 9); 2750 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2751 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2752 2753 dscFromBottomPlayertoImg = playerHeight - imgHeight; 2754 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2755 2756 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2757 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 2758 'right': dscFromRightPlayertoImg + 10 + 'px' 2759 }); 2760 } else { 2761 $this.find('.' + cactusVideoAds).css({"display": "none"}); 2762 } 2763 if (click_count[index] != '1') { 2764 ajax_track(adsID, 0, true, false); 2765 } 2766 click_count[index] = '1'; 2767 }); 2768 }); 2769 2770 // $this.find('.'+cactusVideoAds + ' img').css({"width":"100%", "height":"auto"}); 2771 2772 } 2773 //bottom banner 2774 else if (adsImagePosition == '3') { 2775 // prepare ads images 2776 $this.find('.' + cactusVideoAds).css({ 2777 "height": "auto", 2778 "top": "0", 2779 "pointer-events": "none", 2780 'z-index': '10' 2781 }); 2782 $('<img src="' + videoAds + '">').load(function () { 2783 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>'); 2784 2785 var playerHeight = checkHeight; 2786 var playerWidth = checkWidth; 2787 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2788 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2789 2790 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2791 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2792 2793 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 2794 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 2795 'padding-bottom': '40px', 2796 'top': 'auto' 2797 }); 2798 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2799 'top': '10px', 2800 'right': dscFromRightPlayertoImg + 10 + 'px' 2801 }); 2802 2803 $(window).resize(function () { 2804 setTimeout(function () { 2805 playerWidth = $('.cactus-video-content').width(); 2806 playerHe
2806ight = (checkWidth / 16 * 9); 2807 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2808 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2809 dscFromBottomPlayertoImg = playerHeight - imgHeight; 2810 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2811 if (playerWidth < 600) { 2812 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': '0'}); 2813 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2814 'top': 'auto', 2815 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 2816 'right': dscFromRightPlayertoImg + 10 + 'px' 2817 }); 2818 } else { 2819 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': 'auto'}); 2820 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2821 'top': '10px', 2822 'right': dscFromRightPlayertoImg + 10 + 'px' 2823 }); 2824 } 2825 }, 400) 2826 }); 2827 2828 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 2829 //ajax track click to first top ads here 2830 ajax_track(adsID, 0, false, true); 2831 }); 2832 2833 2834 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 2835 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '3') { 2836 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 2837 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 2838 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 2839 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 2840 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 2841 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 2842 playerWidth = $('.cactus-video-content').width(); 2843 playerHeight = (playerWidth / 16 * 9); 2844 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 2845 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 2846 2847 dscFromBottomPlayertoImg = playerHeight - imgHeight; 2848 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2849 2850 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 2851 'padding-bottom': '40px', 2852 'top': 'auto' 2853 }); 2854 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 2855 'top': '10px', 2856 'right': dscFromRightPlayertoImg + 10 + 'px' 2857 }); 2858 } else { 2859 $this.find('.' + cactusVideoAds).css({"display": "none"}); 2860 } 2861 if (click_count[index] != '1') { 2862 ajax_track(adsID, 0, true, false); 2863 } 2864 click_count[index] = '1'; 2865 }); 2866 }); 2867 } 2868 } 2869 } else if (videoAdsType == 'adsense') { 2870 if (adsImagePosition == '1' || adsImagePosition == '') { 2871 adsImagePosition = '2'; 2872 } 2873 // Hidden ads images 2874 $this.find('.' + cactusVideoAds).css("display", "none"); 2875 2876 // top banner 2877 if (adsImagePosition == '2') { 2878 $this.find('.' + cactusVideoAds).css({ 2879 "height": "0", 2880 "pointer-events": "none", 2881 'z-index': '10' 2882 }); 2883 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 2884
2885 var playerHeight = checkHeight; 2886 var playerWidth = checkWidth; 2887 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 2888 var imgWidth = $this.find('.' + cactusVideoAds).width(); 2889 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2890 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2891 2892 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 2893 if (playerWidth < 600) { 2894 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2895 "width": imgWidth + "px", 2896 "height": imgHeight + "px" 2897 }); 2898 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2899 'top': 'auto', 2900 'bottom': '30px', 2901 'right': dscFromRightPlayertoImg + 10 + 'px' 2902 }); 2903 } else { 2904 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2905 "width": "728px", 2906 "height": imgHeight + "px" 2907 }); 2908 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2909 'top': '65px', 2910 'right': dscFromRightPlayertoImg + 10 + 'px' 2911 }); 2912 } 2913 2914 2915 $(window).resize(function () { 2916 setTimeout(function () { 2917 playerWidth = $('.cactus-video-content').width(); 2918 playerHeight = (checkWidth / 16 * 9); 2919 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 2920 var imgWidth = $this.find('.' + cactusVideoAds).width(); 2921 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2922 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2923 if (playerWidth < 600) { 2924 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2925 "width": imgWidth + "px", 2926 "height": imgHeight + "px" 2927 }); 2928 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2929 'top': 'auto', 2930 'bottom': '30px', 2931 'right': dscFromRightPlayertoImg + 10 + 'px' 2932 }); 2933 } else { 2934 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2935 "width": "728px", 2936 "height": imgHeight + "px" 2937 }); 2938 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2939 'top': '65px', 2940 'right': dscFromRightPlayertoImg + 10 + 'px' 2941 }); 2942 } 2943 }, 400) 2944 }); 2945 2946 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 2947 close_the_ads('close', '.cactusVideoAds', cactus_main_vimeo_player[index], adsID, index); 2948 }); 2949 2950 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 2951 ajax_track(adsID, 0, false, true); 2952 }); 2953 2954 } 2955 //bottom banner 2956 else if (adsImagePosition == '3') { 2957 $this.find('.' + cactusVideoAds).css({ 2958 "height": "auto", 2959 "top": "auto", 2960 "pointer-events": "none", 2961 'z-index': '10' 2962 }); 2963 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 2964 2965
2966 var playerHeight = checkHeight; 2967 var playerWidth = checkWidth; 2968 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 2969 var imgWidth = $this.find('.' + cactusVideoAds).width(); 2970 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 2971 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 2972 2973 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 2974 if (playerWidth < 600) { 2975 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2976 "width": imgWidth + "px", 2977 "height": imgHeight + "px" 2978 }); 2979 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': 'auto', 'bottom': '30px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 2980 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2981 'top': '10px', 2982 'right': '10px' 2983 }); 2984 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 2985 } else { 2986 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 2987 "width": "728px", 2988 "height": imgHeight + "px" 2989 }); 2990 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': '65px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 2991 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 2992 'top': '10px', 2993 'right': '10px' 2994 }); 2995 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 2996 } 2997 2998 2999 $(window).resize(function () { 3000 setTimeout(function () { 3001 playerWidth = $('.cactus-video-content').width(); 3002 playerHeight = (checkWidth / 16 * 9); 3003 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 3004 var imgWidth = $this.find('.' + cactusVideoAds).width(); 3005 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3006 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3007 if (playerWidth < 600) { 3008 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3009 "width": imgWidth + "px", 3010 "height": imgHeight + "px" 3011 }); 3012 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3013 'top': '10px', 3014 'right': '10px' 3015 }); 3016 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 3017 } else { 3018 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3019 "width": "728px", 3020 "height": imgHeight + "px" 3021 }); 3022 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3023 'top': '10px', 3024 'right': '10px' 3025 }); 3026 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 3027 3028 } 3029 }, 400) 3030 }); 3031 3032 3033 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 3034 close_the_ads('close', '.cactusVideoAds', cactus_main_vimeo_player[index], adsID, index); 3035 }); 3036 3037 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 3038 ajax_track(adsID, 0, false, true); 3039 }); 3040 } 3041 } 3042 } 3043 } else { 3044 //play video 3045 cactus_main_vimeo_player[index].play(); 3046 } 3047 } 3048 } else if (videoSource == 'self-hosted') { 3049 var videoDurationAds = 0; 3050 var videoPlayCurrentTime = 0; 3051 3052 if (videoAutoPlay == "1") { 3053 if (videoAds != '' && videoAds != null && videoAdsType != '') { 3054 $this.find('.' + cactusVideoAds).css("visibility", "visible"); 3055 var divVideoAdsId = cactusVideoAds + '-' + index; 3056 3057 $this.find('.' + cactusVideoDetails).find('.' + cactusVideoContent).html('<video class="wp-video-shortcode" autoplay="true" preload="auto" controls="controls" style="width:100%;"><source src="' + videoLink + '" type="video/mp4"></video><div>'); 3058 3059 cactus_player[index] = $this.find('.' + cactusVideoDetails).find('.wp-video-shortcode'); 3060 3061 if (videoAdsType == 'video') { 3062 cactus_player[index].get(0).pause(); 3063 3064 if (videoAdsSource == 'youtube') { 3065 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 3066 3067 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 3068 //ajax track click to first ads here 3069 ajax_track(adsID, 0, false, true); 3070 }); 3071 3072 function onPlayerReady_auto_self_hosted(event) { 3073 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 3074 "opacity": "0",
3075 "cursor": "auto" 3076 }); 3077 $this.find('.' + cactusVideoAds).find('.linkads').css({ 3078 "opacity": "1", 3079 "visibility": "visible" 3080 }); 3081 3082 var youtubeAdsInterval = null; 3083 3084 function adsPlayCurrentTime_func() { 3085 videoPlayCurrentTime = cactus_player_Ads[index].getCurrentTime(); 3086 if (parseInt(videoPlayCurrentTime) >= videoDataTimeHideAds) { 3087 3088 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 3089 "visibility": "visible", 3090 "opacity": "1" 3091 }).text(closeButtonName); 3092 3093 if (isClickCloseButtonFirstTime == true) { 3094 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 3095 close_the_ads('close', cactus_player_Ads[index], cactus_player[index].get(0), null, index); 3096 if (youtubeAdsInterval != null) { 3097 clearInterval(youtubeAdsInterval); 3098 } 3099 isClickCloseButtonFirstTime = false; 3100 }); 3101 } 3102 3103 3104 } 3105 } 3106 3107 youtubeAdsInterval = setInterval(adsPlayCurrentTime_func, 500); 3108 } 3109 3110 function onPlayerStateChange_auto_self_hosted(event) { 3111 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 3112 "opacity": "0", 3113 "cursor": "auto" 3114 }); 3115 $this.find('.' + cactusVideoAds).find('.linkads').css({ 3116 "opacity": "1", 3117 "visibility": "visible" 3118 }); 3119 3120 // when youtube ads finish 3121 if (event.data === 0) { 3122 close_the_ads('ended', cactus_player_Ads[index], cactus_player[index].get(0), null, index); 3123 } 3124 } 3125 3126 cactus_player_Ads[index] = new YT.Player(divVideoAdsId, { 3127 width: checkWidth, 3128 height: checkHeight, 3129 videoId: videoAds, 3130 playerVars: { 3131 controls: 0, 3132 showinfo: 0, 3133 enablejsapi: 1, 3134 autoplay: 1, 3135 disablekb: 1, 3136 }, 3137 events: { 3138 'onReady': onPlayerReady_auto_self_hosted, 3139 'onStateChange': onPlayerStateChange_auto_self_hosted 3140 } 3141 }); 3142 } else if (videoAdsSource == 'vimeo') { 3143 setup_vimeo_ad(index); 3144 } else if (videoAdsSource == 'self-hosted') { 3145 setup_selfhosted_ad(index); 3146 } 3147 } else if (videoAdsType == 'image') { 3148 //ads images 3149 3150 // Hidden ads images 3151 $this.find('.' + cactusVideoAds).css("visibility", "hidden"); 3152 3153 //full size 3154 if (adsImagePosition == '1' || adsImagePosition == 'undefined' || adsImagePosition == '') { 3155 cactus_player[index].get(0).pause(); 3156 3157 $this.find('.' + cactusVideoAds).css("display", "none"); 3158 // prepare ads images 3159 $this.find('.' + cactusVideoAds).html('<a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img src="' + videoAds + '"/></a>'); 3160 $this.find('.' + cactusVideoAds + ' img').css({"width": "100%", "height": "100%"}); 3161 3162 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 3163 3164 $this.find('.' + cactusVideoAds).find('a img').off('.clickToAds').on('click.clickToAds', function () { 3165 //ajax track click to full ads here 3166 ajax_track(adsID, 0, false, true); 3167 }); 3168 3169 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 3170 "visibility": "visible", 3171 "opacity": "1" 3172 }).text(closeButtonName); 3173 3174 3175 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').click(function () { 3176 //ajax track close full ads here 3177 ajax_track(adsID, 0, true, false); 3178 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3179 cactus_player[index].get(0).play(); 3180 }); 3181 } else { 3182 // top banner 3183 if (adsImagePosition == '2') { 3184 // prepare ads images 3185 $this.find('.' + cactusVideoAds).css({ 3186 "pointer-events": "none", 3187 'z-index': '10' 3188 }); 3189 $('<img src="' + videoAds + '">').load(function () { 3190 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>');
3191 var playerHeight = checkHeight; 3192 var playerWidth = checkWidth; 3193 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3194 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3195 3196 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3197 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3198 3199 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 3200 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3201 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 3202 'right': dscFromRightPlayertoImg + 10 + 'px' 3203 }); 3204 3205 $(window).resize(function () { 3206 setTimeout(function () { 3207 playerWidth = $('.cactus-video-content').width(); 3208 playerHeight = (checkWidth / 16 * 9); 3209 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3210 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3211 dscFromBottomPlayertoImg = playerHeight - imgHeight; 3212 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3213 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3214 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 3215 'right': dscFromRightPlayertoImg + 10 + 'px' 3216 }); 3217 }, 400) 3218 }); 3219 3220 3221 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 3222 //ajax track click to first top ads here 3223 ajax_track(adsID, 0, false, true); 3224 }); 3225 3226 3227 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 3228 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '2') { 3229 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 3230 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 3231 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 3232 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 3233 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 3234 3235 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 3236 playerWidth = $('.cactus-video-content').width(); 3237 playerHeight = (playerWidth / 16 * 9); 3238 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3239 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3240 3241 dscFromBottomPlayertoImg = playerHe
3241ight - imgHeight; 3242 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3243 3244 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3245 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 3246 'right': dscFromRightPlayertoImg + 10 + 'px' 3247 }); 3248 } else { 3249 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3250 } 3251 if (click_count[index] != '1') { 3252 ajax_track(adsID, 0, true, false); 3253 } 3254 3255 click_count[index] = '1'; 3256 }); 3257 }); 3258 3259 // $this.find('.'+cactusVideoAds + ' img').css({"width":"100%", "height":"auto"}); 3260 3261 3262 } 3263 //bottom banner 3264 else if (adsImagePosition == '3') { 3265 // prepare ads images 3266 $this.find('.' + cactusVideoAds).css({ 3267 "height": "auto", 3268 "top": "0", 3269 "pointer-events": "none", 3270 'z-index': '10' 3271 }); 3272 $('<img src="' + videoAds + '">').load(function () { 3273 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>'); 3274 3275 var playerHeight = checkHeight; 3276 var playerWidth = checkWidth; 3277 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3278 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3279 3280 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3281 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3282 3283 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 3284 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 3285 'padding-bottom': '40px', 3286 'top': 'auto' 3287 }); 3288 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3289 'top': '10px', 3290 'right': dscFromRightPlayertoImg + 10 + 'px' 3291 }); 3292 3293 $(window).resize(function () { 3294 setTimeout(function () { 3295 playerWidth = $('.cactus-video-content').width(); 3296 playerHeight = (checkWidth / 16 * 9); 3297 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3298 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3299 dscFromBottomPlayertoImg = playerHe
3299ight - imgHeight; 3300 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3301 if (playerWidth < 600) { 3302 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': '0'}); 3303 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3304 'top': 'auto', 3305 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 3306 'right': dscFromRightPlayertoImg + 10 + 'px' 3307 }); 3308 } else { 3309 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': 'auto'}); 3310 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3311 'top': '10px', 3312 'right': dscFromRightPlayertoImg + 10 + 'px' 3313 }); 3314 } 3315 }, 400) 3316 }); 3317 3318 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 3319 //ajax track click to first top ads here 3320 ajax_track(adsID, 0, false, true); 3321 }); 3322 3323 3324 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 3325 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '3') { 3326 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 3327 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 3328 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 3329 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 3330 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 3331 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 3332 playerWidth = $('.cactus-video-content').width(); 3333 playerHeight = (playerWidth / 16 * 9); 3334 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3335 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3336 3337 dscFromBottomPlayertoImg = playerHeight - imgHeight; 3338 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3339 3340 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 3341 'padding-bottom': '40px', 3342 'top': 'auto' 3343 }); 3344 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3345 'top': '10px', 3346 'right': dscFromRightPlayertoImg + 10 + 'px' 3347 }); 3348 } else { 3349 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3350 } 3351 if (click_count[index] != '1') { 3352 ajax_track(adsID, 0, true, false); 3353 } 3354 click_count[index] = '1'; 3355 3356 // reset the chunk 3357 flag[index] = false;
3358 cactus_player_chunk[index] = 0; 3359 }); 3360 }); 3361 } 3362 } 3363 } else if (videoAdsType == 'adsense') { 3364 if (adsImagePosition == '1' || adsImagePosition == '') { 3365 adsImagePosition = '2'; 3366 } 3367 // Hidden ads images 3368 $this.find('.' + cactusVideoAds).css("display", "none"); 3369 3370 // top banner 3371 if (adsImagePosition == '2') { 3372 $this.find('.' + cactusVideoAds).css({ 3373 "height": "0", 3374 "pointer-events": "none", 3375 'z-index': '10' 3376 }); 3377 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 3378 3379 var playerHeight = checkHeight; 3380 var playerWidth = checkWidth; 3381 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 3382 var imgWidth = $this.find('.' + cactusVideoAds).width(); 3383 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3384 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3385 3386 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 3387 if (playerWidth < 600) { 3388 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3389 "width": imgWidth + "px", 3390 "height": imgHeight + "px" 3391 }); 3392 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3393 'top': 'auto', 3394 'bottom': '30px', 3395 'right': dscFromRightPlayertoImg + 10 + 'px' 3396 }); 3397 } else { 3398 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3399 "width": "728px", 3400 "height": imgHeight + "px" 3401 }); 3402 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3403 'top': '65px', 3404 'right': dscFromRightPlayertoImg + 10 + 'px' 3405 }); 3406 } 3407 3408 3409 $(window).resize(function () { 3410 setTimeout(function () { 3411 playerWidth = $('.cactus-video-content').width(); 3412 playerHeight = (checkWidth / 16 * 9); 3413 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 3414 var imgWidth = $this.find('.' + cactusVideoAds).width(); 3415 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3416 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3417 if (playerWidth < 600) { 3418 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3419 "width": imgWidth + "px", 3420 "height": imgHeight + "px" 3421 }); 3422 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3423 'top': 'auto', 3424 'bottom': '30px', 3425 'right': dscFromRightPlayertoImg + 10 + 'px' 3426 }); 3427 } else { 3428 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3429 "width": "728px", 3430 "height": imgHeight + "px" 3431 }); 3432 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3433 'top': '65px', 3434 'right': dscFromRightPlayertoImg + 10 + 'px' 3435 }); 3436 } 3437 }, 400) 3438 }); 3439 3440 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 3441 ajax_track(adsID, 0, false, true); 3442 }); 3443 3444 3445 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 3446 close_the_ads('close', '.cactusVideoAds', cactus_player[index].get(0), adsID, index); 3447 click_count[index] = '1'; 3448 3449 // reset the chunk 3450 flag[index] = false;
3451 cactus_player_chunk[index] = 0; 3452 }); 3453 } 3454 //bottom banner 3455 else if (adsImagePosition == '3') { 3456 $this.find('.' + cactusVideoAds).css({ 3457 "height": "auto", 3458 "top": "auto", 3459 "pointer-events": "none", 3460 'z-index': '10' 3461 }); 3462 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 3463 3464 3465 var playerHeight = checkHeight; 3466 var playerWidth = checkWidth; 3467 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 3468 var imgWidth = $this.find('.' + cactusVideoAds).width(); 3469 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3470 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3471 3472 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 3473 if (playerWidth < 600) { 3474 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3475 "width": imgWidth + "px", 3476 "height": imgHeight + "px" 3477 }); 3478 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': 'auto', 'bottom': '30px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 3479 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3480 'top': '10px', 3481 'right': '10px' 3482 }); 3483 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 3484 } else { 3485 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3486 "width": "728px", 3487 "height": imgHeight + "px" 3488 }); 3489 // $this.find('.'+cactusVideoAds + ' .adsense-block .close-banner-button').css({'top': '65px', 'right': dscFromRightPlayertoImg + 10 + 'px' }); 3490 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3491 'top': '10px', 3492 'right': '10px' 3493 }); 3494 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 3495 } 3496 3497 3498 $(window).resize(function () { 3499 setTimeout(function () { 3500 playerWidth = $('.cactus-video-content').width(); 3501 playerHeight = (checkWidth / 16 * 9); 3502 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 3503 var imgWidth = $this.find('.' + cactusVideoAds).width(); 3504 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3505 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3506 if (playerWidth < 600) { 3507 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3508 "width": imgWidth + "px", 3509 "height": imgHeight + "px" 3510 }); 3511 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3512 'top': '10px', 3513 'right': '10px' 3514 }); 3515 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 3516 } else { 3517 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3518 "width": "728px", 3519 "height": imgHeight + "px" 3520 }); 3521 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3522 'top': '10px', 3523 'right': '10px' 3524 }); 3525 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 3526 3527 } 3528 }, 400) 3529 }); 3530 3531 $this.find('.' + cactusVideoAds + ' .adsense-block').on('click', function () { 3532 ajax_track(adsID, 0, false, true); 3533 }); 3534 3535 3536 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 3537 close_the_ads('close', '.cactusVideoAds', cactus_player[index].get(0), adsID, index); 3538 click_count[index] = '1'; 3539 3540 // reset the chunk 3541 flag[index] = false;
3542 cactus_player_chunk[index] = 0; 3543 }); 3544 3545 } 3546 3547 // play main video 3548 cactus_player[index].get(0).play(); 3549 } 3550 } 3551 } else { 3552 if (videoAds != '' && videoAds != null && videoAdsType != '') { 3553 $this.find('.' + cactusVideoAds).css("visibility", "visible"); 3554 var divVideoAdsId = cactusVideoAds + '-' + index; 3555 $this.find('.' + cactusVideoDetails).find('.' + cactusVideoContent).html('<video class="wp-video-shortcode" preload="auto" controls="controls" style="width:100%;" ><source src="' + videoLink + '" type="video/mp4"></video><div>'); 3556 3557 cactus_player[index] = $this.find('.' + cactusVideoDetails).find('.wp-video-shortcode'); 3558 3559 cactus_player[index].get(0).pause(); 3560 3561 3562 if (videoAdsType == 'video') { 3563 if (videoAdsSource == 'youtube') { 3564 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, videoAdsSource, videoDataTarget); 3565 3566 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 3567 //ajax track click to first ads here 3568 ajax_track(adsID, 0, false, true); 3569 }); 3570 3571 $this.find('.' + cactusVideoAds).find(".hide-pause.button-start").click(function () { 3572 if ($('body').hasClass('mobile')) { 3573 $('body').addClass('mobile-clicked'); 3574 } 3575 3576 var $thisads = $(this); 3577 3578 function onPlayerReady_nauto(event) { 3579 $thisads.css({"opacity": "0"}); 3580 $this.find('.' + cactusVideoAds).find('.linkads').css({ 3581 "opacity": "1", 3582 "visibility": "visible" 3583 }); 3584 } 3585 3586 function onPlayerStateChange_nauto(event) { 3587 if (event.data === 0) { 3588 videoPlayFullTime = cactus_player_Ads[index].getDuration(); 3589 //ajax track close here when finish ads first time 3590 ajax_track(adsID, videoPlayFullTime, false, false); 3591 3592 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3593 cactus_player_Ads[index].stopVideo(); 3594 cactus_player[index].get(0).play(); 3595 } 3596 3597 var youtubeAdsInterval = null; 3598 3599 function adsPlayCurrentTime_func() { 3600 videoPlayCurrentTime = cactus_player_Ads[index].getCurrentTime(); 3601 if (parseInt(videoPlayCurrentTime) >= videoDataTimeHideAds) { 3602 clearInterval(adsPlayCurrentTime_func); 3603 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 3604 "visibility": "visible", 3605 "opacity": "1" 3606 }).text(closeButtonName); 3607 3608 if (isClickCloseButtonFirstTime == true) { 3609 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 3610 3611 //ajax track close here 3612 ajax_track(adsID, videoPlayCurrentTime, true, false); 3613 3614 if (youtubeAdsInterval != null) { 3615 clearInterval(youtubeAdsInterval); 3616 } 3617 3618 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3619 cactus_player_Ads[index].stopVideo(); 3620 cactus_player[index].get(0).play(); 3621 isClickCloseButtonFirstTime = false;
3622 }); 3623 } 3624 3625 } 3626 } 3627 3628 youtubeAdsInterval = setInterval(adsPlayCurrentTime_func, 500) 3629 } 3630 3631 cactus_player_Ads[index] = new YT.Player(divVideoAdsId, { 3632 width: checkWidth, 3633 height: checkHeight, 3634 videoId: videoAds, 3635 playerVars: { 3636 controls: 0, 3637 showinfo: 0, 3638 enablejsapi: 1, 3639 autoplay: 1, 3640 disablekb: 1, 3641 }, 3642 events: { 3643 'onReady': onPlayerReady_nauto, 3644 'onStateChange': onPlayerStateChange_nauto 3645 } 3646 }); 3647 3648 }); 3649 } else if (videoAdsSource == 'vimeo') { 3650 setup_vimeo_ad(index); 3651 } else if (videoAdsSource == 'self-hosted') { 3652 // $this.find('.'+cactusVideoAds).css("visibility","visible"); 3653 mask_button($this, cactusVideoAds, videoAdsSource, videoSource); 3654 $this.find('.' + cactusVideoAds).find(".hide-pause.button-start").click(function () { 3655 if ($('body').hasClass('mobile')) { 3656 $('body').addClass('mobile-clicked'); 3657 } 3658 $this.find('.' + cactusVideoAds).html('<video id="player-html5-' + index + '" class="wp-video-shortcode" autoplay="true" preload="auto" controls="controls" style="width:100%"><source src="' + videoAds + '" type="video/mp4"></video><div>'); 3659 3660 cactus_html5_player_Ads[index] = $this.find('.' + cactusVideoAds).find('.wp-video-shortcode'); 3661 3662 cactus_html5_player_Ads[index].get(0).play(); 3663 3664 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 3665 3666 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 3667 //ajax track click to first ads here 3668 ajax_track(adsID, 0, false, true); 3669 }); 3670 3671 $this.find('.' + cactusVideoAds).find('.hide-pause').css({ 3672 "opacity": "0", 3673 "cursor": "auto" 3674 }); 3675 $this.find('.' + cactusVideoAds).find('.linkads').css({ 3676 "opacity": "1", 3677 "visibility": "visible" 3678 }); 3679 3680 // when youtube html 5 ads finish 3681 cactus_html5_player_Ads[index].get(0).onended = function (e) { 3682 videoPlayFullTime = cactus_html5_player_Ads[index].get(0).duration; 3683 //ajax track close here when finish ads first time 3684 ajax_track(adsID, videoPlayFullTime, false, false); 3685 3686 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3687 cactus_player[index].get(0).play(); 3688 } 3689 3690 var html5AdsInterval = null; 3691 3692 function adsPlayCurrentTime_func_self_hosted() { 3693 videoHtml5PlayCurrentTime = cactus_html5_player_Ads[index].get(0).currentTime; 3694 cactus_html5_player_Ads[index].get(0).addEventListener("timeupdate", function () { 3695 if (videoHtml5PlayCurrentTime >= videoDataTimeHideAds) { 3696 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 3697 "visibility": "visible", 3698 "opacity": "1" 3699 }).text(closeButtonName); 3700 3701 if (isClickCloseButtonFirstTime == true) { 3702 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 3703 3704 //ajax track close here 3705 ajax_track(adsID, videoHtml5PlayCurrentTime, true, false); 3706 3707 if (html5AdsInterval != null) { 3708 clearInterval(html5AdsInterval); 3709 } 3710 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3711 cactus_html5_player_Ads[index].get(0).pause(); 3712 cactus_player[index].get(0).play(); 3713 isClickCloseButtonFirstTime = false;
3714 }); 3715 } 3716 } 3717 }); 3718 } 3719 3720 html5AdsInterval = setInterval(adsPlayCurrentTime_func_self_hosted, 500) 3721 }); 3722 } 3723 } else if (videoAdsType == 'image') { 3724 //ads images 3725 3726 // Hidden ads images 3727 $this.find('.' + cactusVideoAds).css("visibility", "hidden"); 3728 3729 //full size 3730 if (adsImagePosition == '1' || adsImagePosition == 'undefined' || adsImagePosition == '') { 3731 $this.find('.' + cactusVideoAds).css("display", "none"); 3732 // prepare ads images 3733 $this.find('.' + cactusVideoAds).html('<a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img src="' + videoAds + '"/></a>'); 3734 $this.find('.' + cactusVideoAds + ' img').css({"width": "100%", "height": "100%"}); 3735 3736 close_button($this, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, '', videoDataTarget); 3737 3738 $this.find('.' + cactusVideoAds).find('a img').off('.clickToAds').on('click.clickToAds', function () { 3739 //ajax track click to full ads here 3740 ajax_track(adsID, 0, false, true); 3741 }); 3742 3743 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').css({ 3744 "visibility": "visible", 3745 "opacity": "1" 3746 }).text(closeButtonName); 3747 3748 3749 $this.find('.' + cactusVideoAds).find('#close-' + divVideoAdsId + '').click(function () { 3750 //ajax track close full ads here 3751 ajax_track(adsID, 0, true, false); 3752 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3753 cactus_player[index].get(0).pause(); 3754 }); 3755 } else { 3756 // top banner 3757 if (adsImagePosition == '2') { 3758 // prepare ads images 3759 $this.find('.' + cactusVideoAds).css({ 3760 "pointer-events": "none", 3761 'z-index': '10' 3762 }); 3763 $('<img src="' + videoAds + '">').load(function () { 3764 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>'); 3765 var playerHeight = checkHeight; 3766 var playerWidth = checkWidth; 3767 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3768 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3769 3770 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3771 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3772 3773 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 3774 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3775 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 3776 'right': dscFromRightPlayertoImg + 10 + 'px' 3777 }); 3778 3779 $(window).resize(function () { 3780 setTimeout(function () { 3781 playerWidth = $('.cactus-video-content').width();
3782 playerHeight = (playerWidth / 16 * 9); 3783 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3784 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3785 dscFromBottomPlayertoImg = playerHeight - imgHeight; 3786 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3787 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3788 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 3789 'right': dscFromRightPlayertoImg + 10 + 'px' 3790 }); 3791 }, 400) 3792 }); 3793 3794 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 3795 //ajax track click to first top ads here 3796 ajax_track(adsID, 0, false, true); 3797 }); 3798 3799 3800 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 3801 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '2') { 3802 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 3803 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 3804 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 3805 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 3806 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 3807 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 3808 playerWidth = $('.cactus-video-content').width(); 3809 playerHeight = (playerWidth / 16 * 9); 3810 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3811 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3812 3813 dscFromBottomPlayertoImg = playerHeight - imgHeight; 3814 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3815 3816 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3817 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 3818 'right': dscFromRightPlayertoImg + 10 + 'px' 3819 }); 3820 } else { 3821 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3822 } 3823 if (click_count[index] != '1') { 3824 ajax_track(adsID, 0, true, false); 3825 } 3826 click_count[index] = '1'; 3827 }); 3828 }); 3829 3830 } 3831 /* bottom banner */ 3832 else if (adsImagePosition == '3') { 3833 /* prepare ads images */ 3834 $this.find('.' + cactusVideoAds).css({ 3835 "height": "auto", 3836 "top": "0", 3837 "pointer-events": "none", 3838 'z-index': '10' 3839 }); 3840 $('<img src="' + videoAds + '">').load(function () { 3841 $this.find('.' + cactusVideoAds).html('<div class="banner-img"><a href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"><img class="main-img" src="' + videoAds + '"/></div></a>'); 3842
3843 var playerHeight = checkHeight; 3844 var playerWidth = checkWidth; 3845 var imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3846 var imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3847 3848 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3849 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3850 3851 $this.find('.' + cactusVideoAds + ' .banner-img').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 3852 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 3853 'padding-bottom': '40px', 3854 'top': 'auto' 3855 }); 3856 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3857 'top': '10px', 3858 'right': dscFromRightPlayertoImg + 10 + 'px' 3859 }); 3860 3861 $(window).resize(function () { 3862 setTimeout(function () { 3863 playerWidth = $('.cactus-video-content').width(); 3864 playerHeight = (checkWidth / 16 * 9); 3865 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3866 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3867 dscFromBottomPlayertoImg = playerHeight - imgHeight; 3868 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3869 if (playerWidth < 600) { 3870 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': '0'}); 3871 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3872 'top': 'auto', 3873 'bottom': dscFromBottomPlayertoImg + 10 + 'px', 3874 'right': dscFromRightPlayertoImg + 10 + 'px' 3875 }); 3876 } else { 3877 $this.find('.' + cactusVideoAds + ' .banner-img').css({'top': 'auto'}); 3878 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3879 'top': '10px', 3880 'right': dscFromRightPlayertoImg + 10 + 'px' 3881 }); 3882 } 3883 }, 400) 3884 }); 3885 3886 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds').on('click.clickToAds', function () { 3887 /* ajax track click to first top ads here */ 3888 ajax_track(adsID, 0, false, true); 3889 }); 3890 3891 3892 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 3893 if (playbackVideoAds != '' && playbackVideoAdsType == 'image' && playbackAdsImagePosition == '3') { 3894 $this.find('.' + cactusVideoAds).css({"visibility": "hidden"}); 3895 $this.find('.' + cactusVideoAds + ' .banner-img img').attr("src", playbackVideoAds); 3896 $this.find('.' + cactusVideoAds).find('.banner-img a img.main-img').off('.clickToAds'); 3897 $this.find('.' + cactusVideoAds + ' .banner-img img').removeClass("main-img"); 3898 $this.find('.' + cactusVideoAds + ' .banner-img img').addClass("second-img"); 3899 $this.find('.' + cactusVideoAds + ' .banner-img a').attr("href", playbackDataLinkRedirect); 3900 playerWidth = $('.cactus-video-content').width();
3901 playerHeight = (playerWidth / 16 * 9); 3902 imgHeight = $this.find('.' + cactusVideoAds + ' .banner-img img').height(); 3903 imgWidth = $this.find('.' + cactusVideoAds + ' .banner-img img').width(); 3904 3905 dscFromBottomPlayertoImg = playerHeight - imgHeight; 3906 dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3907 3908 $this.find('.' + cactusVideoAds + ' .banner-img').css({ 3909 'padding-bottom': '40px', 3910 'top': 'auto' 3911 }); 3912 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').css({ 3913 'top': '10px', 3914 'right': dscFromRightPlayertoImg + 10 + 'px' 3915 }); 3916 } else { 3917 $this.find('.' + cactusVideoAds).css({"display": "none"}); 3918 } 3919 if (click_count[index] != '1') { 3920 ajax_track(adsID, 0, true, false); 3921 } 3922 click_count[index] = '1'; 3923 }); 3924 }); 3925 } 3926 3927 } 3928 } else if (videoAdsType == 'adsense') { 3929 /* Hidden ads images */ 3930 $this.find('.' + cactusVideoAds).css("display", "none"); 3931 3932 if (adsImagePosition == '1' || adsImagePosition == '') { 3933 adsImagePosition = '2'; 3934 } 3935 /* Hidden ads images */ 3936 $this.find('.' + cactusVideoAds).css("display", "none"); 3937 3938 /* top banner */ 3939 if (adsImagePosition == '2') { 3940 3941 3942 $this.find('.' + cactusVideoAds).css({ 3943 "height": "0", 3944 "pointer-events": "none", 3945 'z-index': '10' 3946 }); 3947 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 3948 3949 var playerHeight = checkHeight; 3950 var playerWidth = checkWidth; 3951 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 3952 var imgWidth = $this.find('.' + cactusVideoAds).width(); 3953 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3954 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3955 3956 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 3957 if (playerWidth < 600) { 3958 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3959 "width": imgWidth + "px", 3960 "height": imgHeight + "px" 3961 }); 3962 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3963 'top': 'auto', 3964 'bottom': '30px', 3965 'right': dscFromRightPlayertoImg + 10 + 'px' 3966 }); 3967 } else { 3968 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3969 "width": "728px", 3970 "height": imgHeight + "px" 3971 }); 3972 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3973 'top': '65px', 3974 'right': dscFromRightPlayertoImg + 10 + 'px' 3975 }); 3976 } 3977 3978 3979 $(window).resize(function () { 3980 setTimeout(function () { 3981 playerWidth = $('.cactus-video-content').width();
3982 playerHeight = (checkWidth / 16 * 9); 3983 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 3984 var imgWidth = $this.find('.' + cactusVideoAds).width(); 3985 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 3986 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 3987 if (playerWidth < 600) { 3988 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3989 "width": imgWidth + "px", 3990 "height": imgHeight + "px" 3991 }); 3992 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 3993 'top': 'auto', 3994 'bottom': '30px', 3995 'right': dscFromRightPlayertoImg + 10 + 'px' 3996 }); 3997 } else { 3998 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 3999 "width": "728px", 4000 "height": imgHeight + "px" 4001 }); 4002 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 4003 'top': '65px', 4004 'right': dscFromRightPlayertoImg + 10 + 'px' 4005 }); 4006 } 4007 }, 400) 4008 }); 4009 4010 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 4011 $this.find('.' + cactusVideoAds).css({"display": "none"}); 4012 click_count[index] = '1'; 4013 }); 4014 } 4015 /* bottom banner */ 4016 else if (adsImagePosition == '3') { 4017 $this.find('.' + cactusVideoAds).css({ 4018 "height": "auto", 4019 "top": "auto", 4020 "pointer-events": "none", 4021 'z-index': '10' 4022 }); 4023 $this.find('.' + cactusVideoAds).html('<div class="adsense-block">' + videoAds + '</div>'); 4024 4025 4026 var playerHeight = checkHeight; 4027 var playerWidth = checkWidth; 4028 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 4029 var imgWidth = $this.find('.' + cactusVideoAds).width(); 4030 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 4031 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 4032 4033 $this.find('.' + cactusVideoAds + ' .adsense-block').append('<span class="close-banner-button"><i class="fa fa-times"></i></span>'); 4034 if (playerWidth < 600) { 4035 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 4036 "width": imgWidth + "px", 4037 "height": imgHeight + "px" 4038 }); 4039 4040 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 4041 'top': '10px', 4042 'right': '10px' 4043 }); 4044 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 4045 } else { 4046 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 4047 "width": "728px", 4048 "height": imgHeight + "px" 4049 }); 4050 4051 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 4052 'top': '10px', 4053 'right': '10px' 4054 }); 4055 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 4056 } 4057 4058 4059 $(window).resize(function () { 4060 setTimeout(function () { 4061 playerWidth = $('.cactus-video-content').width();
4062 playerHeight = (checkWidth / 16 * 9); 4063 var imgHeight = $this.find('.' + cactusVideoAds + ' .adsense-block .bsa-block-728--90').height(); 4064 var imgWidth = $this.find('.' + cactusVideoAds).width(); 4065 var dscFromBottomPlayertoImg = playerHeight - imgHeight; 4066 var dscFromRightPlayertoImg = (playerWidth - imgWidth) / 2; 4067 if (playerWidth < 600) { 4068 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 4069 "width": imgWidth + "px", 4070 "height": imgHeight + "px" 4071 }); 4072 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 4073 'top': '10px', 4074 'right': '10px' 4075 }); 4076 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "20px"}); 4077 } else { 4078 $('.cactus-video-list .cactus-video-item .cactus-video-ads .adsense-block .bsa-block-728--90').css({ 4079 "width": "728px", 4080 "height": imgHeight + "px" 4081 }); 4082 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').css({ 4083 'top': '10px', 4084 'right': '10px' 4085 }); 4086 $this.find('.' + cactusVideoAds + ' .adsense-block').css({"padding-bottom": "40px"}); 4087 4088 } 4089 }, 400) 4090 }); 4091 4092 4093 $this.find('.' + cactusVideoAds + ' .adsense-block .close-banner-button').click(function () { 4094 $this.find('.' + cactusVideoAds).css({"display": "none"}); 4095 click_count[index] = '1'; 4096 }); 4097 4098 } 4099 } 4100 } else { 4101 cactus_player[index].get(0).pause(); 4102 } 4103 } 4104 4105 var current_player = cactus_player[index].get(0); 4106 4107 current_player.addEventListener("timeupdate", function () { 4108 videoPlayCurrentTime = parseInt(current_player.currentTime); 4109 4110 /* increase the chunk count */ 4111 if (videoPlayCurrentTime > video_last_current_time) { 4112 cactus_player_chunk[index] += videoPlayCurrentTime - video_last_current_time; 4113 } 4114 video_last_current_time = videoPlayCurrentTime; 4115 4116 if (videoPlayCurrentTime > 0 && (videoAdsType == 'image' && (adsImagePosition == '2' || adsImagePosition == '3')) && click_count[index] != 1) { 4117 $global_this.find('.' + cactusVideoAds).css({"visibility": "visible", "display": "block"}); 4118 click_count[index] = 2; 4119 } 4120 4121 if (need_repeat_ad(videoDataTimePlayAgain, index) && !flag[index]) { 4122 flag[index] = true; 4123 4124 /* display ads and play it */ 4125 setTimeout(show_the_ads, 700, $global_this.find('.' + cactusVideoAds)); 4126 4127 if (!isClickCloseButtonFirstTime) { 4128 /* on button Close clicked */ 4129 $this.find('.' + cactusVideoAds).find('#close-' + AdsVideoId).off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 4130 the_ad = (videoAdsSource == 'youtube' ? cactus_player_Ads[index] : cactus_html5_player_Ads[index].get(0)); 4131 close_the_ads('close', the_ad, current_player, null, index); 4132 }); 4133 } 4134 4135 if (videoAdsType == 'video') { 4136 /* pause main video */ 4137 setTimeout(control_the_video_player, 500, current_player, true, false); 4138 4139 $this.find('.' + cactusVideoAds).find('.linkads').attr("href", playbackDataLinkRedirect); 4140 if (videoAdsSource == 'youtube') { 4141 playbackVideoAdsURL = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'youtube' ? playbackVideoAds : videoAds; 4142 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'youtube' ? playbackAdsID : adsID; 4143 4144 cactus_player_Ads[index].destroy(); 4145 4146 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 4147 4148 /* ajax track click to second ads here */ 4149 ajax_track(playbackVideoAdsID, 0, false, true); 4150 4151 }); 4152 4153 function onPlayerReady_auto1(event) { 4154 4155 if (screenfull.isFullscreen == false) { 4156 cactus_player_Ads[index].seekTo(0, true); 4157 cactus_player_Ads[index].playVideo(); 4158 } else { 4159 cactus_player_Ads[index].stopVideo(); 4160 $this.find('.' + cactusVideoAds).css({"display": "none"}); 4161 current_player.play(); 4162 } 4163 } 4164 4165 function onPlayerStateChange_auto1(event) { 4166 if (isClickCloseButtonFirstTime == false) { 4167 $this.find('.' + cactusVideoAds).find('#close-' + AdsVideoId + '').off('.closeYoutubeAds').on('click.closeYoutubeAds', function () { 4168 close_the_ads('close', cactus_player_Ads[index], current_player, playbackVideoAdsID, index); 4169 }); 4170 } 4171 4172 if (event.data === 0) { 4173 close_the_ads('ended', cactus_player_Ads[index], current_player, playbackVideoAdsID, index); 4174 } 4175 } 4176 4177 cactus_player_Ads[index] = new YT.Player(AdsVideoId, { 4178 width: checkWidth, 4179 height: checkHeight, 4180 videoId: playbackVideoAdsURL, 4181 playerVars: { 4182 controls: 0, 4183 showinfo: 0, 4184 enablejsapi: 1, 4185 autoplay: 1, 4186 disablekb: 1, 4187 }, 4188 events: { 4189 'onReady': onPlayerReady_auto1, 4190 'onStateChange': onPlayerStateChange_auto1 4191 } 4192 }); 4193 } else if (videoAdsSource == 'vimeo') { 4194 playbackVideoAdsURL = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'vimeo' ? playbackVideoAds : videoAds; 4195 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'vimeo' ? playbackAdsID : adsID; 4196 $global_this.find('.' + cactusVideoAds + ' iframe#player-vimeo-' + index).attr('src', 'https://player.vimeo.com/video/' + playbackVideoAdsURL + '?api=1&player_id=player-vimeo-' + index + '&autoplay=1'); 4197 4198 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 4199 4200 /* ajax track click to first ads here */ 4201 ajax_track(playbackVideoAdsID, 0, false, true); 4202 4203 }); 4204 4205 if (screenfull.isFullscreen == false) { 4206 cactus_vimeo_player_Ads[index].setCurrentTime(0); 4207 cactus_vimeo_player_Ads[index].play(); 4208 } else { 4209 $global_this.find('.' + cactusVideoAds + ' iframe#player-vimeo-' + index).remove(); 4210 $this.find('.' + cactusVideoAds).css({"display": "none"}); 4211 current_player.play(); 4212 } 4213 4214 isVimeoPlayback = true; 4215 4216 4217 } else if (videoAdsSource == 'self-hosted') { 4218 playbackVideoAdsID = playbackVideoAdsSource != '' && playbackVideoAdsSource == 'self-hosted' ? playbackAdsID : adsID; 4219 4220 /* when setting 'src' attribute, it has same effect as calling .play(); */ 4221 $this.find('.' + cactusVideoAds).find('.linkads').attr("href", playbackDataLinkRedirect); 4222 4223 cactus_html5_player_Ads[index] = $this.find('.' + cactusVideoAds).find('.wp-video-shortcode'); 4224 4225 if (screenfull.isFullscreen == false) { 4226 /* play the video ads */ 4227 setTimeout(control_the_video_player, 700, cactus_html5_player_Ads[index].get(0), false, true); 4228 } else { 4229 /* pause the ad */ 4230 setTimeout(control_the_video_player, 500, cactus_html5_player_Ads[index].get(0), true, true); 4231 4232 /* play the main player */ 4233 setTimeout(control_the_video_player, 500, current_player, false, false); 4234 4235 $this.find('.' + cactusVideoAds).css({"display": "none"}); 4236 } 4237 4238 $this.find('.' + cactusVideoAds).find('.linkads').off('.clickToAds').on('click.clickToAds', function () { 4239 /* ajax track click to first ads here */ 4240 ajax_track(playbackVideoAdsID, 0, false, true); 4241 }); 4242 } 4243 } else if (videoAdsType == '') { 4244 $global_this.find('.' + cactusVideoAds).css({ 4245 "visibility": "hidden", 4246 "display": "none" 4247 }); 4248 } else if (videoAdsType == 'adsense') { 4249 if (adsImagePosition == '1') 4250 $global_this.find('.' + cactusVideoAds).css({ 4251 "visibility": "hidden", 4252 "display": "none" 4253 }); 4254 } else { 4255 /* ads image */ 4256 if (adsImagePosition == '2' || adsImagePosition == '3') { 4257 playbackVideoAdsID = playbackVideoAds != '' && playbackVideoAdsType == 'image' && (playbackAdsImagePosition == '2' || playbackAdsImagePosition == '3') ? playbackAdsID : adsID; 4258 4259 $this.find('.' + cactusVideoAds).find('.banner-img a img.second-img').off('.clickToSecondAds').on('click.clickToSecondAds', function () { 4260 /* ajax track click to second top ads here */ 4261 ajax_track(playbackVideoAdsID, 0, false, true); 4262 }); 4263 4264 $this.find('.' + cactusVideoAds + ' .banner-img .close-banner-button').click(function () { 4265 ajax_track(playbackVideoAdsID, 0, true, false); 4266 4267 cactus_player_chunk[index] = 0; 4268 flag[index] = false;
4269 }); 4270 } else { 4271 /* pause main video */ 4272 setTimeout(control_the_video_player, 500, current_player, true, false); 4273 } 4274 } 4275 } 4276 }); 4277 4278 cactus_player[index].get(0).onended = function (e) { 4279 $this.find('.' + cactusVideoAds).css({"display": "none"}); 4280 if (showSharePopup == 'on') { 4281 $('body').addClass('popup-share-active'); 4282 } 4283 setTimeout(function () { 4284 if (autoLoadNextVideo != 3) { 4285 var link = $('.prev-post a').attr('href'); 4286 if (autoLoadNextVideoOptions == 1) { 4287 link = jQuery('.next-post a').attr('href'); 4288 } 4289 } else if (autoLoadNextVideo == 3) { 4290 var link = window.location.href; 4291 } 4292 var className = $('#tm-autonext span#autonext').attr('class'); 4293 4294 if (className != '') { 4295 if (link != undefined) { 4296 window.location.href = link; 4297 } 4298 } 4299 }, autoLoadNextVideoSeconds); 4300 } 4301 } 4302 4303 /*Video Youtube Iframe*/ 4304 }, 1001); 4305 4306 }); 4307 } 4308 4309 // if mycred_video is used, we ignore the ads 4310 if ($('.mycred-video').length == 0) { 4311 window.onYouTubeIframeAPIReady = videoads_onyoutubeiframeready; 4312 } 4313}; 4314 4315/* end videoads_document_ready(); */ 4316 4317function close_button(elements, divVideoAdsId, cactusVideoAds, videoDataLinkRedirect, closeButtonPosition, videoAdsSource, videoDataTarget) { 4318 var $this = elements; 4319 4320 videoDataTarget = videoDataLinkRedirect == 'javascript:;' ? '_parent' : '_blank'; 4321 if (videoAdsSource == 'youtube') 4322 $this.find('.' + cactusVideoAds).append('<div id="close-' + divVideoAdsId + '"></div><a class="linkads" href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"></a><div class="hide-pause button-start"></div><div id="' + divVideoAdsId + '"></div>'); 4323 else { 4324 $this.find('.' + cactusVideoAds).append('<div id="close-' + divVideoAdsId + '"></div><a class="linkads" href="' + videoDataLinkRedirect + '" target="' + videoDataTarget + '"></a></div><div id="' + divVideoAdsId + '"></div>'); 4325 } 4326 4327 //set up close position 4328 if (closeButtonPosition == 'right') { 4329 $this.find('#close-' + divVideoAdsId).css({"right": "0"}); 4330 } else { 4331 $this.find('#close-' + divVideoAdsId).css({"left": "0"}); 4332 } 4333} 4334 4335function mask_button(elements, cactusVideoAds, videoAdsSource, videoSource) { 4336 var $this = elements; 4337 if (videoSource == 'youtube') { 4338 $this.find('.' + cactusVideoAds).append('<div class="hide-pause button-start"></div>'); 4339 } else if (videoSource == 'vimeo') { 4340 $this.find('.' + cactusVideoAds).append('<div class="hide-pause button-start non-icon"></div>'); 4341 } else if (videoSource == 'self-hosted') { 4342 $this.find('.' + cactusVideoAds).append('<div class="hide-pause button-start non-icon"></div>'); 4343 } 4344} 4345 4346function ajax_track(ads_id, videoAdsCurrentTime, clickCloseButton, clickToAds) { 4347 $ = jQuery; 4348 4349 $.ajax( 4350 { 4351 type: 'post', 4352 cache: false, 4353 url: cactus.ajaxurl, 4354 data: { 4355 'ads_id': ads_id, 4356 'videoAdsCurrentTime': videoAdsCurrentTime, 4357 'clickCloseButton': clickCloseButton, 4358 'clickToAds': clickToAds, 4359 'action': 'cactus_track_time_when_click_close' 4360 }, 4361 success: function (data) { 4362 } 4363 }); 4364} 4365 4366(function ($) { 4367 var checkWidth = $('.cactus-video-content').width(); 4368 var checkHeight = (checkWidth / 16 * 9); 4369 4370 $(document).ready(function () { 4371 videoads_document_ready(); 4372 }); 4373 4374}(jQuery)); 4375 4376(function ($) { 4377 //function responsive image
4378 $.fn.cactus_ads_responsive_image = function (options) { 4379 var $this = $(this); 4380 4381 var dpr = window.devicePixelRatio; 4382 if (typeof dpr == 'undefined') { 4383 dpr = 1; 4384 } 4385 4386 var width = window.innerWidth * dpr; 4387 4388 $this.each(function (index, element) { 4389 var minWidth1024 = $(this).attr('data-src-1024'); 4390 var minWidth768 = $(this).attr('data-src-768'); 4391 var maxWidth768 = $(this).attr('data-src-lt-768'); 4392 4393 if (width >= 1024) { 4394 if (minWidth1024 != '' && minWidth1024 != null) { 4395 $(this).attr('src', minWidth1024); 4396 } 4397 } else if (width >= 768) { 4398 if (minWidth768 != '' && minWidth768 != null) { 4399 $(this).attr('src', minWidth768); 4400 } 4401 ; 4402 } else { 4403 if (maxWidth768 != '' && maxWidth768 != null) { 4404 $(this).attr('src', maxWidth768); 4405 } 4406 } 4407 4408 }); 4409 4410 }; 4411 $(document).ready(function () { 4412 $('img').cactus_ads_responsive_image({}); 4413 $(window).resize(function () { 4414 $('img').cactus_ads_responsive_image({}); 4415 }); 4416 }); 4417}(jQuery));
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.