| 1 |
(function (window, $) |
| 2 |
{ |
| 3 |
window._EPYT_ = window._EPYT_ || { |
| 4 |
ajaxurl: "\/wp-admin\/admin-ajax.php", |
| 5 |
security: "", |
| 6 |
gallery_scrolloffset: 100, |
| 7 |
eppathtoscripts: "\/wp-content\/plugins\/youtube-embed-plus\/scripts\/", |
| 8 |
epresponsiveselector: ["iframe.__youtube_prefs_widget__"], |
| 9 |
epdovol: true, |
| 10 |
evselector: 'iframe.__youtube_prefs__[src], iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"]', |
| 11 |
stopMobileBuffer: true, |
| 12 |
usingdefault: true |
| 13 |
}; |
| 14 |
|
| 15 |
window._EPYT_.pageLoaded = false; |
| 16 |
$(window).on('load._EPYT_', function () { |
| 17 |
window._EPYT_.pageLoaded = true; |
| 18 |
}); |
| 19 |
|
| 20 |
if (!document.querySelectorAll) |
| 21 |
{ |
| 22 |
document.querySelectorAll = function (selector) |
| 23 |
{ |
| 24 |
var doc = document, head = doc.documentElement.firstChild, styleTag = doc.createElement('STYLE'); |
| 25 |
head.appendChild(styleTag); |
| 26 |
doc.__qsaels = []; |
| 27 |
styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsaels.push(this))}"; |
| 28 |
window.scrollBy(0, 0); |
| 29 |
return doc.__qsaels; |
| 30 |
}; |
| 31 |
} |
| 32 |
|
| 33 |
if (typeof window._EPADashboard_ === 'undefined') |
| 34 |
{ |
| 35 |
window._EPADashboard_ = |
| 36 |
{ |
| 37 |
initStarted: false, |
| 38 |
checkCount: 0, |
| 39 |
onPlayerReady: function (event) |
| 40 |
{ |
| 41 |
try |
| 42 |
{ |
| 43 |
if (typeof _EPYT_.epdovol !== "undefined" && _EPYT_.epdovol) |
| 44 |
{ |
| 45 |
var vol = parseInt(event.target.getIframe().getAttribute("data-vol")); |
| 46 |
if (!isNaN(vol)) |
| 47 |
{ |
| 48 |
if (vol === 0) |
| 49 |
{ |
| 50 |
event.target.mute(); |
| 51 |
} |
| 52 |
else |
| 53 |
{ |
| 54 |
if (event.target.isMuted()) |
| 55 |
{ |
| 56 |
event.target.unMute(); |
| 57 |
} |
| 58 |
event.target.setVolume(vol); |
| 59 |
} |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
catch (err) { |
| 64 |
} |
| 65 |
|
| 66 |
try { |
| 67 |
var $ifm = $(event.target.getIframe()); |
| 68 |
if ($ifm.hasClass('epyt-lbif') && $ifm.hasClass('epyt-thumbplay') && $ifm.closest('.lity-content').length) |
| 69 |
{ |
| 70 |
// https://github.com/Modernizr/Modernizr/blob/master/feature-detects/video/autoplay.js |
| 71 |
if (!(navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/) && window._EPYT_.stopMobileBuffer)) { |
| 72 |
event.target.playVideo(); |
| 73 |
} |
| 74 |
} |
| 75 |
} |
| 76 |
catch (err2) |
| 77 |
{ |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
setTimeout(function () |
| 82 |
{ |
| 83 |
try |
| 84 |
{ |
| 85 |
var ytid = window._EPADashboard_.justid(event.target.getVideoUrl()); |
| 86 |
window._EPADashboard_.jp("ytid=" + ytid); |
| 87 |
|
| 88 |
} |
| 89 |
catch (err) |
| 90 |
{ |
| 91 |
} |
| 92 |
}, 1700); |
| 93 |
}, |
| 94 |
onPlayerStateChange: function (event) |
| 95 |
{ |
| 96 |
var ifm = event.target.getIframe(); |
| 97 |
if (event.data === window.YT.PlayerState.PLAYING && event.target.ponce !== true && ifm.src.indexOf('autoplay=1') === -1) |
| 98 |
{ |
| 99 |
event.target.ponce = true; |
| 100 |
|
| 101 |
try |
| 102 |
{ |
| 103 |
var ytid = window._EPADashboard_.justid(event.target.getVideoUrl()); |
| 104 |
window._EPADashboard_.jp("ytid=" + ytid + "&p=1"); |
| 105 |
|
| 106 |
} catch (err) |
| 107 |
{ |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
var $gallery = $(ifm).closest('.epyt-gallery'); |
| 112 |
if (!$gallery.length) |
| 113 |
{ |
| 114 |
$gallery = $('#' + $(ifm).data('epytgalleryid')); |
| 115 |
} |
| 116 |
if ($gallery.length) |
| 117 |
{ |
| 118 |
var autonext = $gallery.find('.epyt-pagebutton').first().data('autonext') == '1'; |
| 119 |
if (autonext && event.data === window.YT.PlayerState.ENDED) |
| 120 |
{ |
| 121 |
var $currvid = $gallery.find('.epyt-current-video'); |
| 122 |
if (!$currvid.length) |
| 123 |
{ |
| 124 |
$currvid = $gallery.find('.epyt-gallery-thumb').first(); |
| 125 |
} |
| 126 |
var $nextvid = $currvid.find(' ~ .epyt-gallery-thumb').first(); |
| 127 |
var $lityopen = $('div.lity-wrap[data-lity-close]'); |
| 128 |
if ($nextvid.length) |
| 129 |
{ |
| 130 |
if ($lityopen.length) |
| 131 |
{ |
| 132 |
window._EPADashboard_.lb.close(); |
| 133 |
setTimeout(function () { |
| 134 |
$nextvid.click(); |
| 135 |
}, 1000); |
| 136 |
|
| 137 |
} |
| 138 |
else |
| 139 |
{ |
| 140 |
$nextvid.click(); |
| 141 |
} |
| 142 |
} |
| 143 |
else |
| 144 |
{ |
| 145 |
if ($lityopen.length) |
| 146 |
{ |
| 147 |
window._EPADashboard_.lb.close(); |
| 148 |
setTimeout(function () { |
| 149 |
$gallery.find('.epyt-pagebutton.epyt-next[data-pagetoken!=""][data-pagetoken]').first().click(); |
| 150 |
}, 1000); |
| 151 |
|
| 152 |
} |
| 153 |
else |
| 154 |
{ |
| 155 |
$gallery.find('.epyt-pagebutton.epyt-next[data-pagetoken!=""][data-pagetoken]').first().click(); |
| 156 |
} |
| 157 |
|
| 158 |
} |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
}, |
| 163 |
justid: function (s) |
| 164 |
{ |
| 165 |
return new RegExp("[\\?&]v=([^&#]*)").exec(s)[1]; |
| 166 |
}, |
| 167 |
dynsetupevents: function () |
| 168 |
{ |
| 169 |
if (typeof this.epytsetupdone === 'undefined') |
| 170 |
{ |
| 171 |
return window._EPADashboard_.setupevents(this.id); |
| 172 |
} |
| 173 |
}, |
| 174 |
setupevents: function (iframeid) |
| 175 |
{ |
| 176 |
window._EPADashboard_.log('Setting up YT API events: ' + iframeid); |
| 177 |
if (typeof (window.YT) !== 'undefined' && window.YT !== null && window.YT.loaded) |
| 178 |
{ |
| 179 |
var thisvid = document.getElementById(iframeid); |
| 180 |
thisvid.epytsetupdone = true; |
| 181 |
return new window.YT.Player(iframeid, { |
| 182 |
events: { |
| 183 |
"onReady": window._EPADashboard_.onPlayerReady, |
| 184 |
"onStateChange": window._EPADashboard_.onPlayerStateChange |
| 185 |
} |
| 186 |
}); |
| 187 |
} |
| 188 |
}, |
| 189 |
jp: function (q) |
| 190 |
{ |
| 191 |
if (window._EPYT_.dshpre) |
| 192 |
{ |
| 193 |
var script = document.createElement('script'); |
| 194 |
script.src = "//www.embedplus.com/test-page.aspx?es=w&u=" + |
| 195 |
encodeURIComponent(window.location.href.split("#")[0]) + |
| 196 |
"&" + q + |
| 197 |
(navigator.userAgent.toLowerCase().indexOf('chrome') > -1 ? "&b=c&" : "&b=&"); |
| 198 |
var b = document.getElementsByTagName('head')[0].appendChild(script); |
| 199 |
setTimeout(function () |
| 200 |
{ |
| 201 |
b.parentNode.removeChild(b); |
| 202 |
}, 500); |
| 203 |
} |
| 204 |
}, |
| 205 |
apiInit: function () { |
| 206 |
setTimeout(function () |
| 207 |
{ |
| 208 |
if (typeof (window.YT) !== 'undefined') |
| 209 |
{ |
| 210 |
window._EPADashboard_.initStarted = true; |
| 211 |
var __allytifr = document.querySelectorAll(_EPYT_.evselector); |
| 212 |
for (var i = 0; i < __allytifr.length; i++) |
| 213 |
{ |
| 214 |
if (!__allytifr[i].hasAttribute("id")) |
| 215 |
{ |
| 216 |
__allytifr[i].id = "_dytid_" + Math.round(Math.random() * 8999 + 1000); |
| 217 |
} |
| 218 |
window._EPADashboard_.setupevents(__allytifr[i].id); |
| 219 |
} |
| 220 |
} |
| 221 |
}, 300); |
| 222 |
}, |
| 223 |
log: function (msg) { |
| 224 |
try |
| 225 |
{ |
| 226 |
console.log(msg); |
| 227 |
} |
| 228 |
catch (err) { |
| 229 |
} |
| 230 |
}, |
| 231 |
doubleCheck: function () { |
| 232 |
window._EPADashboard_.checkInterval = setInterval(function () { |
| 233 |
window._EPADashboard_.checkCount++; |
| 234 |
if (window._EPADashboard_.checkCount >= 5 || window._EPADashboard_.initStarted) { |
| 235 |
clearInterval(window._EPADashboard_.checkInterval); |
| 236 |
} |
| 237 |
else { |
| 238 |
window._EPADashboard_.apiInit(); |
| 239 |
window._EPADashboard_.log('YT API init'); |
| 240 |
} |
| 241 |
|
| 242 |
}, 1000); |
| 243 |
}, |
| 244 |
selectText: function (ele) { |
| 245 |
if (document.selection) { |
| 246 |
var range = document.body.createTextRange(); |
| 247 |
range.moveToElementText(ele); |
| 248 |
range.select(); |
| 249 |
} else if (window.getSelection) { |
| 250 |
var range = document.createRange(); |
| 251 |
range.selectNode(ele); |
| 252 |
window.getSelection().addRange(range); |
| 253 |
} |
| 254 |
}, |
| 255 |
lb: typeof (window.lity) !== 'undefined' ? window.lity() : function () { |
| 256 |
} |
| 257 |
|
| 258 |
}; |
| 259 |
} |
| 260 |
|
| 261 |
window.onYouTubeIframeAPIReady = typeof window.onYouTubeIframeAPIReady !== 'undefined' ? window.onYouTubeIframeAPIReady : function () |
| 262 |
{ |
| 263 |
if (window._EPYT_.pageLoaded) |
| 264 |
{ |
| 265 |
window._EPADashboard_.apiInit(); |
| 266 |
window._EPADashboard_.log('YT API ready'); |
| 267 |
} |
| 268 |
else |
| 269 |
{ |
| 270 |
$(window).on('load._EPYT_', function () { |
| 271 |
window._EPADashboard_.apiInit(); |
| 272 |
window._EPADashboard_.log('YT API ready'); |
| 273 |
}); |
| 274 |
} |
| 275 |
}; |
| 276 |
|
| 277 |
if (typeof window.YT === 'undefined') |
| 278 |
{ |
| 279 |
var iapi = document.createElement('script'); |
| 280 |
iapi.src = "//www.youtube.com/iframe_api"; |
| 281 |
iapi.type = "text/javascript"; |
| 282 |
document.getElementsByTagName('head')[0].appendChild(iapi); |
| 283 |
} |
| 284 |
else if (window.YT.loaded) |
| 285 |
{ |
| 286 |
if (window._EPYT_.pageLoaded) |
| 287 |
{ |
| 288 |
window._EPADashboard_.log('YT API available'); |
| 289 |
window._EPADashboard_.apiInit(); |
| 290 |
} |
| 291 |
else |
| 292 |
{ |
| 293 |
$(window).on('load._EPYT_', function () { |
| 294 |
window._EPADashboard_.log('YT API available'); |
| 295 |
window._EPADashboard_.apiInit(); |
| 296 |
}); |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
if (window._EPYT_.pageLoaded) |
| 301 |
{ |
| 302 |
window._EPADashboard_.doubleCheck(); |
| 303 |
} |
| 304 |
else |
| 305 |
{ |
| 306 |
$(window).on('load._EPYT_', function () { |
| 307 |
window._EPADashboard_.doubleCheck(); |
| 308 |
}); |
| 309 |
} |
| 310 |
|
| 311 |
//})(window, jQuery); |
| 312 |
//(function (window, $) { |
| 313 |
$(document).ready(function () { |
| 314 |
$('.epyt-gallery').each(function () { |
| 315 |
var $container = $(this); |
| 316 |
var $iframe = $(this).find('iframe').first(); |
| 317 |
var contentlbid = 'content' + $iframe.attr('id'); |
| 318 |
$container.find('.lity-hide').attr('id', contentlbid); |
| 319 |
var initSrc = $iframe.attr('src'); |
| 320 |
if (!initSrc) |
| 321 |
{ |
| 322 |
initSrc = $iframe.data('ep-src'); |
| 323 |
} |
| 324 |
var firstId = $(this).find('.epyt-gallery-list .epyt-gallery-thumb').first().data('videoid'); |
| 325 |
initSrc = initSrc.replace(firstId, 'GALLERYVIDEOID'); |
| 326 |
$iframe.data('ep-gallerysrc', initSrc); |
| 327 |
|
| 328 |
|
| 329 |
var $listgallery = $container.find('.epyt-gallery-list'); |
| 330 |
var pagenumsalign = function () { |
| 331 |
try { |
| 332 |
if ($listgallery.hasClass('epyt-gallery-style-carousel')) |
| 333 |
{ |
| 334 |
var thumbheight = $($listgallery.find('.epyt-gallery-thumb').get(0)).height(); |
| 335 |
var topval = thumbheight / 2; |
| 336 |
var $pagenums = $listgallery.find('.epyt-pagination:first-child .epyt-pagenumbers'); |
| 337 |
$pagenums.css('top', (topval + 15) + "px"); |
| 338 |
} |
| 339 |
} |
| 340 |
catch (e) { |
| 341 |
} |
| 342 |
}; |
| 343 |
setTimeout(function () { |
| 344 |
pagenumsalign(); |
| 345 |
}, 300); |
| 346 |
$(window).resize(pagenumsalign); |
| 347 |
|
| 348 |
|
| 349 |
$container.on('click', '.epyt-gallery-list .epyt-gallery-thumb', function () { |
| 350 |
$container.find('.epyt-gallery-list .epyt-gallery-thumb').removeClass('epyt-current-video'); |
| 351 |
$(this).addClass('epyt-current-video'); |
| 352 |
var vid = $(this).data('videoid'); |
| 353 |
$container.data('currvid', vid); |
| 354 |
var vidSrc = $iframe.data('ep-gallerysrc').replace('GALLERYVIDEOID', vid); |
| 355 |
|
| 356 |
var thumbplay = $container.find('.epyt-pagebutton').first().data('thumbplay'); |
| 357 |
if (thumbplay !== '0' && thumbplay !== 0) |
| 358 |
{ |
| 359 |
if (vidSrc.indexOf('autoplay') > 0) |
| 360 |
{ |
| 361 |
vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1'); |
| 362 |
} |
| 363 |
else |
| 364 |
{ |
| 365 |
vidSrc += '&autoplay=1'; |
| 366 |
} |
| 367 |
|
| 368 |
$iframe.addClass('epyt-thumbplay'); |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
if ($container.hasClass('epyt-lb')) |
| 373 |
{ |
| 374 |
window._EPADashboard_.lb('#' + contentlbid); |
| 375 |
|
| 376 |
vidSrc = vidSrc.replace('autoplay=1', 'autoplay=0'); |
| 377 |
|
| 378 |
if ($iframe.is('[data-ep-src]')) |
| 379 |
{ |
| 380 |
$iframe.data('ep-src', vidSrc); |
| 381 |
$iframe.attr('data-ep-src', vidSrc); |
| 382 |
|
| 383 |
} |
| 384 |
else |
| 385 |
{ |
| 386 |
$iframe.attr('src', vidSrc); |
| 387 |
var player = window._EPADashboard_.setupevents($iframe.attr('id')); |
| 388 |
} |
| 389 |
|
| 390 |
$('.lity-close').focus(); |
| 391 |
|
| 392 |
} |
| 393 |
else |
| 394 |
{ |
| 395 |
// https://github.com/jquery/jquery-ui/blob/master/ui/scroll-parent.js |
| 396 |
$('html, body').animate({ |
| 397 |
scrollTop: $iframe.offset().top - parseInt(_EPYT_.gallery_scrolloffset) |
| 398 |
}, 500, function () { |
| 399 |
$iframe.attr('src', vidSrc); |
| 400 |
window._EPADashboard_.setupevents($iframe.attr('id')); |
| 401 |
}); |
| 402 |
|
| 403 |
} |
| 404 |
|
| 405 |
}).on('keydown', '.epyt-gallery-list .epyt-gallery-thumb, .epyt-pagebutton', function (e) { |
| 406 |
var code = e.which; |
| 407 |
if ((code === 13) || (code === 32)) { |
| 408 |
e.preventDefault(); |
| 409 |
$(this).click(); |
| 410 |
|
| 411 |
} |
| 412 |
}); |
| 413 |
|
| 414 |
$container.on('mouseenter', '.epyt-gallery-list .epyt-gallery-thumb', function () { |
| 415 |
$(this).addClass('hover'); |
| 416 |
if ($listgallery.hasClass('epyt-gallery-style-carousel') && $container.find('.epyt-pagebutton').first().data('showtitle') == 1) |
| 417 |
{ |
| 418 |
$container.find('.epyt-pagenumbers').addClass('hide'); |
| 419 |
var ttl = $(this).find('.epyt-gallery-notitle span').text(); |
| 420 |
$container.find('.epyt-gallery-rowtitle').text(ttl).addClass('hover'); |
| 421 |
} |
| 422 |
}); |
| 423 |
|
| 424 |
$container.on('mouseleave', '.epyt-gallery-list .epyt-gallery-thumb', function () { |
| 425 |
$(this).removeClass('hover'); |
| 426 |
if ($listgallery.hasClass('epyt-gallery-style-carousel') && $container.find('.epyt-pagebutton').first().data('showtitle') == 1) |
| 427 |
{ |
| 428 |
$container.find('.epyt-gallery-rowtitle').text('').removeClass('hover'); |
| 429 |
if ($container.find('.epyt-pagebutton[data-pagetoken!=""]').length > 0) |
| 430 |
{ |
| 431 |
$container.find('.epyt-pagenumbers').removeClass('hide'); |
| 432 |
} |
| 433 |
} |
| 434 |
}); |
| 435 |
|
| 436 |
$container.on('click', '.epyt-pagebutton', function () { |
| 437 |
var pageData = { |
| 438 |
action: 'my_embedplus_gallery_page', |
| 439 |
security: _EPYT_.security, |
| 440 |
options: { |
| 441 |
playlistId: $(this).data('playlistid'), |
| 442 |
pageToken: $(this).data('pagetoken'), |
| 443 |
pageSize: $(this).data('pagesize'), |
| 444 |
columns: $(this).data('columns'), |
| 445 |
showTitle: $(this).data('showtitle'), |
| 446 |
showPaging: $(this).data('showpaging'), |
| 447 |
autonext: $(this).data('autonext'), |
| 448 |
style: $(this).data('style'), |
| 449 |
thumbcrop: $(this).data('thumbcrop'), |
| 450 |
thumbplay: $(this).data('thumbplay') |
| 451 |
} |
| 452 |
}; |
| 453 |
if ($(this).data('showdsc')) |
| 454 |
{ |
| 455 |
pageData.options.showDsc = $(this).data('showdsc'); |
| 456 |
} |
| 457 |
|
| 458 |
var forward = $(this).hasClass('epyt-next'); |
| 459 |
var currpage = parseInt($container.data('currpage') + ""); |
| 460 |
currpage += forward ? 1 : -1; |
| 461 |
$container.data('currpage', currpage); |
| 462 |
$container.find('.epyt-gallery-list').addClass('epyt-loading'); |
| 463 |
|
| 464 |
$.post(_EPYT_.ajaxurl, pageData, function (response) { |
| 465 |
$container.find('.epyt-gallery-list').html(response); |
| 466 |
$container.find('.epyt-current').each(function () { |
| 467 |
$(this).text($container.data('currpage')); |
| 468 |
}); |
| 469 |
$container.find('.epyt-gallery-thumb[data-videoid="' + $container.data('currvid') + '"]').addClass('epyt-current-video'); |
| 470 |
|
| 471 |
if ($container.find('.epyt-pagebutton').first().data('autonext') == '1') |
| 472 |
{ |
| 473 |
$container.find('.epyt-gallery-thumb').first().click(); |
| 474 |
} |
| 475 |
|
| 476 |
}) |
| 477 |
.fail(function () { |
| 478 |
alert('Sorry, there was an error loading the next page.'); |
| 479 |
}) |
| 480 |
.always(function () { |
| 481 |
$container.find('.epyt-gallery-list').removeClass('epyt-loading'); |
| 482 |
pagenumsalign(); |
| 483 |
// https://github.com/jquery/jquery-ui/blob/master/ui/scroll-parent.js |
| 484 |
$('html, body').animate({ |
| 485 |
scrollTop: $container.find('.epyt-gallery-list').offset().top - parseInt(_EPYT_.gallery_scrolloffset) |
| 486 |
}, 500); |
| 487 |
}); |
| 488 |
|
| 489 |
}); |
| 490 |
|
| 491 |
}); |
| 492 |
}); |
| 493 |
})(window, jQuery); |
| 494 |
|