| 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 |
usingdefault: true |
| 12 |
}; |
| 13 |
|
| 14 |
if (!document.querySelectorAll) |
| 15 |
{ |
| 16 |
document.querySelectorAll = function (selector) |
| 17 |
{ |
| 18 |
var doc = document, head = doc.documentElement.firstChild, styleTag = doc.createElement('STYLE'); |
| 19 |
head.appendChild(styleTag); |
| 20 |
doc.__qsaels = []; |
| 21 |
styleTag.styleSheet.cssText = selector + "{x:expression(document.__qsaels.push(this))}"; |
| 22 |
window.scrollBy(0, 0); |
| 23 |
return doc.__qsaels; |
| 24 |
}; |
| 25 |
} |
| 26 |
|
| 27 |
if (typeof window._EPADashboard_ === 'undefined') |
| 28 |
{ |
| 29 |
window._EPADashboard_ = |
| 30 |
{ |
| 31 |
initStarted: false, |
| 32 |
checkCount: 0, |
| 33 |
onPlayerReady: function (event) |
| 34 |
{ |
| 35 |
try |
| 36 |
{ |
| 37 |
if (typeof _EPYT_.epdovol !== "undefined" && _EPYT_.epdovol) |
| 38 |
{ |
| 39 |
var vol = parseInt(event.target.getIframe().getAttribute("data-vol")); |
| 40 |
if (!isNaN(vol)) |
| 41 |
{ |
| 42 |
if (vol === 0) |
| 43 |
{ |
| 44 |
event.target.mute(); |
| 45 |
} |
| 46 |
else |
| 47 |
{ |
| 48 |
if (event.target.isMuted()) |
| 49 |
{ |
| 50 |
event.target.unMute(); |
| 51 |
} |
| 52 |
event.target.setVolume(vol); |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
catch (err) { |
| 58 |
} |
| 59 |
|
| 60 |
try { |
| 61 |
var $ifm = $(event.target.getIframe()); |
| 62 |
if ($ifm.hasClass('epyt-lbif') && $ifm.closest('.lity-content').length) |
| 63 |
{ |
| 64 |
// var thumbplay = $container.find('.epyt-pagebutton').first().data('thumbplay'); |
| 65 |
// if (thumbplay !== '0' && thumbplay !== 0) |
| 66 |
event.target.playVideo(); |
| 67 |
//$('body').removeClass('epyt-curtain'); |
| 68 |
} |
| 69 |
} |
| 70 |
catch (err2) |
| 71 |
{ |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
setTimeout(function () |
| 76 |
{ |
| 77 |
try |
| 78 |
{ |
| 79 |
var ytid = _EPADashboard_.justid(event.target.getVideoUrl()); |
| 80 |
_EPADashboard_.jp("ytid=" + ytid); |
| 81 |
|
| 82 |
} |
| 83 |
catch (err) |
| 84 |
{ |
| 85 |
} |
| 86 |
}, 1700); |
| 87 |
}, |
| 88 |
onPlayerStateChange: function (event) |
| 89 |
{ |
| 90 |
var ifm = event.target.getIframe(); |
| 91 |
if (event.data === YT.PlayerState.PLAYING && event.target.ponce !== true && ifm.src.indexOf('autoplay=1') === -1) |
| 92 |
{ |
| 93 |
event.target.ponce = true; |
| 94 |
|
| 95 |
try |
| 96 |
{ |
| 97 |
var ytid = _EPADashboard_.justid(event.target.getVideoUrl()); |
| 98 |
_EPADashboard_.jp("ytid=" + ytid + "&p=1"); |
| 99 |
|
| 100 |
} catch (err) |
| 101 |
{ |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
var $gallery = $(ifm).closest('.epyt-gallery'); |
| 106 |
if ($gallery.length) |
| 107 |
{ |
| 108 |
var autonext = $gallery.find('.epyt-pagebutton').first().data('autonext') == '1'; |
| 109 |
if (autonext && event.data === YT.PlayerState.ENDED) |
| 110 |
{ |
| 111 |
var $currvid = $gallery.find('.epyt-current-video'); |
| 112 |
if (!$currvid.length) |
| 113 |
{ |
| 114 |
$currvid = $gallery.find('.epyt-gallery-thumb').first(); |
| 115 |
} |
| 116 |
var $nextvid = $currvid.find(' ~ .epyt-gallery-thumb').first(); |
| 117 |
if ($nextvid.length) |
| 118 |
{ |
| 119 |
$nextvid.click(); |
| 120 |
} |
| 121 |
else |
| 122 |
{ |
| 123 |
$gallery.find('.epyt-pagebutton.epyt-next[data-pagetoken!=""][data-pagetoken]').first().click(); |
| 124 |
} |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
}, |
| 129 |
justid: function (s) |
| 130 |
{ |
| 131 |
return new RegExp("[\\?&]v=([^&#]*)").exec(s)[1]; |
| 132 |
}, |
| 133 |
dynsetupevents: function () |
| 134 |
{ |
| 135 |
if (typeof this.epytsetupdone === 'undefined') |
| 136 |
{ |
| 137 |
return _EPADashboard_.setupevents(this.id); |
| 138 |
} |
| 139 |
}, |
| 140 |
setupevents: function (iframeid) |
| 141 |
{ |
| 142 |
_EPADashboard_.log('Setting up YT API events: ' + iframeid); |
| 143 |
if (YT.loaded) |
| 144 |
{ |
| 145 |
var thisvid = document.getElementById(iframeid); |
| 146 |
thisvid.epytsetupdone = true; |
| 147 |
return new YT.Player(iframeid, { |
| 148 |
events: { |
| 149 |
"onReady": _EPADashboard_.onPlayerReady, |
| 150 |
"onStateChange": _EPADashboard_.onPlayerStateChange |
| 151 |
} |
| 152 |
}); |
| 153 |
} |
| 154 |
}, |
| 155 |
jp: function (q) |
| 156 |
{ |
| 157 |
//debug |
| 158 |
}, |
| 159 |
apiInit: function () { |
| 160 |
setTimeout(function () |
| 161 |
{ |
| 162 |
if (typeof (YT) !== 'undefined') |
| 163 |
{ |
| 164 |
_EPADashboard_.initStarted = true; |
| 165 |
var __allytifr = document.querySelectorAll(_EPYT_.evselector); |
| 166 |
for (var i = 0; i < __allytifr.length; i++) |
| 167 |
{ |
| 168 |
if (!__allytifr[i].hasAttribute("id")) |
| 169 |
{ |
| 170 |
__allytifr[i].id = "_dytid_" + Math.round(Math.random() * 8999 + 1000); |
| 171 |
} |
| 172 |
_EPADashboard_.setupevents(__allytifr[i].id); |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
} |
| 179 |
}, 300); |
| 180 |
}, |
| 181 |
log: function (msg) { |
| 182 |
try |
| 183 |
{ |
| 184 |
console.log(msg); |
| 185 |
} |
| 186 |
catch (err) { |
| 187 |
} |
| 188 |
}, |
| 189 |
doubleCheck: function () { |
| 190 |
_EPADashboard_.checkInterval = setInterval(function () { |
| 191 |
_EPADashboard_.checkCount++; |
| 192 |
if (_EPADashboard_.checkCount >= 5 || _EPADashboard_.initStarted) { |
| 193 |
clearInterval(_EPADashboard_.checkInterval); |
| 194 |
} |
| 195 |
else { |
| 196 |
_EPADashboard_.apiInit(); |
| 197 |
_EPADashboard_.log('YT API init'); |
| 198 |
} |
| 199 |
|
| 200 |
}, 1000); |
| 201 |
}, |
| 202 |
selectText: function (ele) { |
| 203 |
if (document.selection) { |
| 204 |
var range = document.body.createTextRange(); |
| 205 |
range.moveToElementText(ele); |
| 206 |
range.select(); |
| 207 |
} else if (window.getSelection) { |
| 208 |
var range = document.createRange(); |
| 209 |
range.selectNode(ele); |
| 210 |
window.getSelection().addRange(range); |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
}; |
| 215 |
} |
| 216 |
|
| 217 |
if (typeof window.YT === 'undefined') |
| 218 |
{ |
| 219 |
var iapi = document.createElement('script'); |
| 220 |
iapi.src = "//www.youtube.com/iframe_api"; |
| 221 |
iapi.type = "text/javascript"; |
| 222 |
document.getElementsByTagName('head')[0].appendChild(iapi); |
| 223 |
} |
| 224 |
else if (YT.loaded) |
| 225 |
{ |
| 226 |
_EPADashboard_.apiInit(); |
| 227 |
_EPADashboard_.log('YT API available'); |
| 228 |
} |
| 229 |
|
| 230 |
_EPADashboard_.doubleCheck(); |
| 231 |
|
| 232 |
window.onYouTubeIframeAPIReady = typeof window.onYouTubeIframeAPIReady !== 'undefined' ? window.onYouTubeIframeAPIReady : function () |
| 233 |
{ |
| 234 |
_EPADashboard_.apiInit(); |
| 235 |
_EPADashboard_.log('YT API ready'); |
| 236 |
}; |
| 237 |
|
| 238 |
|
| 239 |
})(window, jQuery); |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
(function ($) { |
| 244 |
$(document).ready(function () { |
| 245 |
$('.epyt-gallery').each(function () { |
| 246 |
var $container = $(this); |
| 247 |
var $iframe = $(this).find('iframe').first(); |
| 248 |
var contentlbid = 'content' + $iframe.attr('id'); |
| 249 |
$container.find('.lity-hide').attr('id', contentlbid); |
| 250 |
var initSrc = $iframe.attr('src'); |
| 251 |
if (!initSrc) |
| 252 |
{ |
| 253 |
initSrc = $iframe.data('ep-src'); |
| 254 |
} |
| 255 |
var firstId = $(this).find('.epyt-gallery-list .epyt-gallery-thumb').first().data('videoid'); |
| 256 |
initSrc = initSrc.replace(firstId, 'GALLERYVIDEOID'); |
| 257 |
$iframe.data('ep-gallerysrc', initSrc); |
| 258 |
|
| 259 |
|
| 260 |
var $listgallery = $container.find('.epyt-gallery-list'); |
| 261 |
var pagenumsalign = function () { |
| 262 |
try { |
| 263 |
if ($listgallery.hasClass('epyt-gallery-style-carousel')) |
| 264 |
{ |
| 265 |
var thumbheight = $($listgallery.find('.epyt-gallery-thumb').get(0)).height(); |
| 266 |
var topval = thumbheight / 2; |
| 267 |
var $pagenums = $listgallery.find('.epyt-pagination:first-child .epyt-pagenumbers'); |
| 268 |
$pagenums.css('top', (topval + 15) + "px"); |
| 269 |
} |
| 270 |
} |
| 271 |
catch (e) { |
| 272 |
} |
| 273 |
}; |
| 274 |
setTimeout(function () { |
| 275 |
pagenumsalign(); |
| 276 |
}, 300); |
| 277 |
$(window).resize(pagenumsalign); |
| 278 |
|
| 279 |
|
| 280 |
$container.on('click', '.epyt-gallery-list .epyt-gallery-thumb', function () { |
| 281 |
$container.find('.epyt-gallery-list .epyt-gallery-thumb').removeClass('epyt-current-video'); |
| 282 |
$(this).addClass('epyt-current-video'); |
| 283 |
var vid = $(this).data('videoid'); |
| 284 |
$container.data('currvid', vid); |
| 285 |
var vidSrc = $iframe.data('ep-gallerysrc').replace('GALLERYVIDEOID', vid); |
| 286 |
|
| 287 |
var thumbplay = $container.find('.epyt-pagebutton').first().data('thumbplay'); |
| 288 |
if (thumbplay !== '0' && thumbplay !== 0) |
| 289 |
{ |
| 290 |
if (vidSrc.indexOf('autoplay') > 0) |
| 291 |
{ |
| 292 |
vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1'); |
| 293 |
} |
| 294 |
else |
| 295 |
{ |
| 296 |
vidSrc += '&autoplay=1'; |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
|
| 301 |
if ($container.hasClass('epyt-lb')) |
| 302 |
{ |
| 303 |
var lb = lity(); |
| 304 |
lb('#' + contentlbid); |
| 305 |
//$('body').addClass('epyt-curtain'); |
| 306 |
|
| 307 |
vidSrc = vidSrc.replace('autoplay=1', 'autoplay=0'); |
| 308 |
$iframe.attr('src', vidSrc); |
| 309 |
var player = _EPADashboard_.setupevents($iframe.attr('id')); |
| 310 |
|
| 311 |
|
| 312 |
} |
| 313 |
else |
| 314 |
{ |
| 315 |
$('html, body').animate({ |
| 316 |
scrollTop: $iframe.offset().top - parseInt(_EPYT_.gallery_scrolloffset) |
| 317 |
}, 500, function () { |
| 318 |
$iframe.attr('src', vidSrc); |
| 319 |
_EPADashboard_.setupevents($iframe.attr('id')); |
| 320 |
}); |
| 321 |
|
| 322 |
} |
| 323 |
|
| 324 |
}); |
| 325 |
|
| 326 |
$container.on('mouseenter', '.epyt-gallery-list .epyt-gallery-thumb', function () { |
| 327 |
$(this).addClass('hover'); |
| 328 |
if ($listgallery.hasClass('epyt-gallery-style-carousel') && $container.find('.epyt-pagebutton').first().data('showtitle') == 1) |
| 329 |
{ |
| 330 |
$container.find('.epyt-pagenumbers').addClass('hide'); |
| 331 |
var ttl = $(this).find('.epyt-gallery-notitle span').text(); |
| 332 |
$container.find('.epyt-gallery-rowtitle').text(ttl).addClass('hover'); |
| 333 |
} |
| 334 |
}); |
| 335 |
|
| 336 |
$container.on('mouseleave', '.epyt-gallery-list .epyt-gallery-thumb', function () { |
| 337 |
$(this).removeClass('hover'); |
| 338 |
if ($listgallery.hasClass('epyt-gallery-style-carousel') && $container.find('.epyt-pagebutton').first().data('showtitle') == 1) |
| 339 |
{ |
| 340 |
$container.find('.epyt-gallery-rowtitle').text('').removeClass('hover'); |
| 341 |
if ($container.find('.epyt-pagebutton[data-pagetoken!=""]').length > 0) |
| 342 |
{ |
| 343 |
$container.find('.epyt-pagenumbers').removeClass('hide'); |
| 344 |
} |
| 345 |
} |
| 346 |
}); |
| 347 |
|
| 348 |
$container.on('click', '.epyt-pagebutton', function () { |
| 349 |
var pageData = { |
| 350 |
action: 'my_embedplus_gallery_page', |
| 351 |
security: _EPYT_.security, |
| 352 |
options: { |
| 353 |
playlistId: $(this).data('playlistid'), |
| 354 |
pageToken: $(this).data('pagetoken'), |
| 355 |
pageSize: $(this).data('pagesize'), |
| 356 |
columns: $(this).data('columns'), |
| 357 |
showTitle: $(this).data('showtitle'), |
| 358 |
showPaging: $(this).data('showpaging'), |
| 359 |
autonext: $(this).data('autonext'), |
| 360 |
style: $(this).data('style'), |
| 361 |
thumbcrop: $(this).data('thumbcrop'), |
| 362 |
thumbplay: $(this).data('thumbplay') |
| 363 |
} |
| 364 |
}; |
| 365 |
if ($(this).data('showdsc')) |
| 366 |
{ |
| 367 |
pageData.options.showDsc = $(this).data('showdsc'); |
| 368 |
} |
| 369 |
|
| 370 |
var forward = $(this).hasClass('epyt-next'); |
| 371 |
var currpage = parseInt($container.data('currpage') + ""); |
| 372 |
currpage += forward ? 1 : -1; |
| 373 |
$container.data('currpage', currpage); |
| 374 |
$container.find('.epyt-gallery-list').addClass('epyt-loading'); |
| 375 |
|
| 376 |
$.post(_EPYT_.ajaxurl, pageData, function (response) { |
| 377 |
$container.find('.epyt-gallery-list').html(response); |
| 378 |
$container.find('.epyt-current').each(function () { |
| 379 |
$(this).text($container.data('currpage')); |
| 380 |
}); |
| 381 |
$container.find('.epyt-gallery-thumb[data-videoid="' + $container.data('currvid') + '"]').addClass('epyt-current-video'); |
| 382 |
|
| 383 |
if ($container.find('.epyt-pagebutton').first().data('autonext') == '1') |
| 384 |
{ |
| 385 |
$container.find('.epyt-gallery-thumb').first().click(); |
| 386 |
} |
| 387 |
|
| 388 |
}) |
| 389 |
.fail(function () { |
| 390 |
alert('Sorry, there was an error loading the next page.'); |
| 391 |
}) |
| 392 |
.always(function () { |
| 393 |
$container.find('.epyt-gallery-list').removeClass('epyt-loading'); |
| 394 |
pagenumsalign(); |
| 395 |
}); |
| 396 |
|
| 397 |
}); |
| 398 |
|
| 399 |
}); |
| 400 |
}); |
| 401 |
})(jQuery); |
| 402 |
|