PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.9.7
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.9.7
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / assets / js / front.js
embedpress / assets / js Last commit date
vendor 7 years ago admin.js 2 years ago ads.js 2 years ago documents-viewer-script.js 3 years ago front.js 2 years ago index.html 7 years ago initplyr.js 2 years ago pdfobject.min.js 3 years ago plyr.polyfilled.js 3 years ago preview.js 3 years ago settings.js 6 years ago vimeo-player.js 2 years ago ytiframeapi.js 2 years ago
front.js
526 lines
1 /**
2 * @package EmbedPress
3 * @author EmbedPress <help@embedpress.com>
4 * @copyright Copyright (C) 2023 EmbedPress. All rights reserved.
5 * @license GPLv2 or later
6 * @since 1.7.0
7 */
8
9
10
11 let epGlobals = {};
12
13 (function ($) {
14 'use strict';
15 // function equivalent to jquery ready()
16 function ready(fn) {
17 if (document.readyState !== 'loading') {
18 fn();
19 } else {
20 document.addEventListener('DOMContentLoaded', fn);
21 }
22 }
23
24 ready(function () {
25 let option = {
26 forceObject: true,
27 };
28 let selector = document.querySelectorAll('.embedpress-embed-document-pdf');
29 if (selector.length) {
30 selector.forEach((function (value, index, thisArg) {
31 let id = value.dataset['emid'];
32 let src = value.dataset['emsrc'];
33 PDFObject.embed(src, "." + id, option);
34 }));
35 }
36 if (typeof epGlobals.youtubeChannelGallery === 'function') {
37 epGlobals.youtubeChannelGallery();
38 }
39 });
40
41 /**
42 *
43 * Make embeds responsive so they don't overflow their container.
44 */
45
46 /**
47 * Add max-width & max-height to <iframe> elements, depending on their width & height props.
48 *
49 *
50 * @return {void}
51 */
52 function embedPressResponsiveEmbeds() {
53 var proportion, parentWidth;
54
55 // Loop iframe elements.
56 document.querySelectorAll('iframe').forEach(function (iframe) {
57 // Only continue if the iframe has a width & height defined.
58 if (iframe.width && iframe.height) {
59 // Calculate the proportion/ratio based on the width & height.
60 proportion = parseFloat(iframe.width) / parseFloat(iframe.height);
61 // Get the parent element's width.
62 parentWidth = parseFloat(window.getComputedStyle(iframe.parentElement, null).width.replace('px', ''));
63 // Set the max-width & height.
64 iframe.style.maxWidth = '100%';
65 iframe.style.maxHeight = Math.round(parentWidth / proportion).toString() + 'px';
66 }
67 });
68 }
69
70 // Run on initial load.
71 embedPressResponsiveEmbeds();
72
73 // Run on resize.
74 window.onresize = embedPressResponsiveEmbeds;
75
76
77 function hasClass(ele, cls) {
78 return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
79 }
80
81 function addClass(ele, cls) {
82 if (!hasClass(ele, cls)) ele.className += " " + cls;
83 }
84
85 function removeClass(ele, cls) {
86 if (hasClass(ele, cls)) {
87 var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
88 ele.className = ele.className.replace(reg, " ");
89 }
90 }
91 if (!Element.prototype.matches) {
92 Element.prototype.matches =
93 Element.prototype.matchesSelector ||
94 Element.prototype.webkitMatchesSelector ||
95 Element.prototype.mozMatchesSelector ||
96 Element.prototype.msMatchesSelector ||
97 Element.prototype.oMatchesSelector ||
98 function (s) {
99 var matches = (this.document || this.ownerDocument).querySelectorAll(s),
100 i = matches.length;
101 while (--i >= 0 && matches.item(i) !== this) { }
102 return i > -1;
103 };
104 }
105 var delegate = function (el, evt, sel, handler) {
106 el.addEventListener(evt, function (event) {
107 var t = event.target;
108 while (t && t !== this) {
109 if (t.matches(sel)) {
110 handler.call(t, event);
111 }
112 t = t.parentNode;
113 }
114 });
115 };
116
117 function sendRequest(url, postData, callback) {
118 var req = createXMLHTTPObject();
119 if (!req) return;
120 var method = postData ? "POST" : "GET";
121 req.open(method, url, true);
122 if (postData) {
123 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
124 }
125 req.onreadystatechange = function () {
126 if (req.readyState != 4) return;
127 if (req.status != 200 && req.status != 304) {
128 return;
129 }
130 callback(req);
131 };
132 if (req.readyState == 4) return;
133 req.send(postData);
134 }
135
136 var XMLHttpFactories = [
137 function () {
138 return new XMLHttpRequest();
139 },
140 function () {
141 return new ActiveXObject("Msxml3.XMLHTTP");
142 },
143 function () {
144 return new ActiveXObject("Msxml2.XMLHTTP.6.0");
145 },
146 function () {
147 return new ActiveXObject("Msxml2.XMLHTTP.3.0");
148 },
149 function () {
150 return new ActiveXObject("Msxml2.XMLHTTP");
151 },
152 function () {
153 return new ActiveXObject("Microsoft.XMLHTTP");
154 },
155 ];
156
157 function createXMLHTTPObject() {
158 var xmlhttp = false;
159 for (var i = 0; i < XMLHttpFactories.length; i++) {
160 try {
161 xmlhttp = XMLHttpFactories[i]();
162 } catch (e) {
163 continue;
164 }
165 break;
166 }
167 return xmlhttp;
168 }
169
170 epGlobals.youtubeChannelGallery = function () {
171 var playerWraps = document.getElementsByClassName("ep-player-wrap");
172 if (playerWraps && playerWraps.length) {
173 for (var i = 0, im = playerWraps.length; im > i; i++) {
174 youtubeChannelEvents(playerWraps[i])
175 }
176 }
177 }
178
179 function youtubeChannelEvents(playerWrap) {
180
181 delegate(playerWrap, "click", ".item", function (event) {
182 var embed = "https://www.youtube.com/embed/";
183 var vid = this.getAttribute("data-vid");
184 var iframe = playerWrap.getElementsByTagName("iframe");
185 if (vid) {
186 if (iframe) {
187 var vidSrc = iframe[0].src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
188 if (vidSrc.indexOf('autoplay') > 0) {
189 vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1');
190 }
191 else {
192 vidSrc += '&autoplay=1';
193 }
194 iframe[0].src = vidSrc;
195 playerWrap.scrollIntoView();
196 }
197 }
198 });
199
200 var currentPage = 1;
201
202 let nearestEpContentId = playerWrap.querySelector('.ep-youtube__content__block').getAttribute('data-unique-id');
203
204 delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event) {
205 const totalPages = event.target.closest('.ose-youtube').getAttribute('data-total-pages');
206 const closestClass = event.target.closest('.ose-youtube').classList;
207
208 const activePage = document.querySelector(`.${closestClass[1]} .embedpress-page-active`);
209 if (activePage) {
210 document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active');
211 }
212
213
214
215 var isNext = this.classList.contains("ep-next");
216
217 if (isNext) {
218 currentPage++;
219 } else {
220 currentPage--;
221 }
222
223 var data = {
224 action: "youtube_rest_api",
225 playlistid: this.getAttribute("data-playlistid"),
226 pagetoken: this.getAttribute("data-pagetoken"),
227 pagesize: this.getAttribute("data-pagesize"),
228 currentpage: currentPage
229 };
230
231 var formBody = [];
232 for (var property in data) {
233 var encodedKey = encodeURIComponent(property);
234 var encodedValue = encodeURIComponent(data[property]);
235 formBody.push(encodedKey + "=" + encodedValue);
236 }
237 formBody = formBody.join("&");
238
239 var galleryWrapper = playerWrap.getElementsByClassName(
240 "ep-youtube__content__block"
241 );
242
243 playerWrap.setAttribute('data-current-page', currentPage);
244
245
246 let x = 1;
247
248 sendRequest("/wp-admin/admin-ajax.php", formBody, function (request) {
249 if (galleryWrapper && galleryWrapper[0] && request.responseText) {
250 var response = JSON.parse(request.responseText);
251 galleryWrapper[0].outerHTML = response.html;
252
253 var currentPageNode =
254 galleryWrapper[0].getElementsByClassName("current-page");
255 if (currentPageNode && currentPageNode[0]) {
256 currentPageNode[0].textContent = currentPage;
257
258 }
259 }
260 });
261
262 const intervalID = setInterval(() => {
263 x++
264
265 if (playerWrap.querySelector('.ep-youtube__content__block')) {
266 const newNearestEpContentId = playerWrap
267 .querySelector('.ep-youtube__content__block')
268 .getAttribute('data-unique-id');
269
270 if (newNearestEpContentId !== nearestEpContentId && playerWrap.querySelector(`[data-page="${currentPage}"]`)) {
271 playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active');
272 nearestEpContentId = newNearestEpContentId;
273 clearInterval(intervalID);
274 }
275 }
276
277 if (x > 100) {
278 clearInterval(intervalID);
279 }
280 }, 100);
281
282 });
283 }
284
285 //Load more for OpenaSea collection
286 const epLoadMore = () => {
287
288 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function () {
289 let selctorEl = `[data-nftid='${$(this).data('nftid')}']`;
290
291 let loadmorelabel = $(selctorEl).data('loadmorelabel');
292 let iconcolor = $(selctorEl + " .nft-loadmore").data('iconcolor');
293
294 let spinicon = `<svg width="18" height="18" fill="${iconcolor || '#fff'}" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_GuJz{transform-origin:center;animation:spinner_STY6 1.5s linear infinite}@keyframes spinner_STY6{100%{transform:rotate(360deg)}}</style><g class="spinner_GuJz"><circle cx="3" cy="12" r="2"/><circle cx="21" cy="12" r="2"/><circle cx="12" cy="21" r="2"/><circle cx="12" cy="3" r="2"/><circle cx="5.64" cy="5.64" r="2"/><circle cx="18.36" cy="18.36" r="2"/><circle cx="5.64" cy="18.36" r="2"/><circle cx="18.36" cy="5.64" r="2"/></g></svg>`;
295
296 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
297 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
298
299 $(selctorEl + " .nft-loadmore").click(function (e) {
300 //change the text of the button
301 $(this).html(loadmorelabel + spinicon);
302 //disable the button
303 $(this).prop("disabled", true);
304 //wait for 1 seconds
305 setTimeout(function () {
306 //change the text back
307 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
308 //enable the button
309 $(selctorEl + " .nft-loadmore").prop("disabled", false);
310 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
311 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
312 $(selctorEl + " .nft-loadmore").fadeOut("slow");
313 }
314 }, 500);
315 });
316 });
317 };
318
319 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
320 epLoadMore();
321 }
322
323 // Content protection system function
324 const unlockSubmitHander = (perentSel, that) => {
325 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
326 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
327 var post_id = jQuery(`input[name="post_id"]`).val();
328 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
329 const unlokingText = jQuery(that).data('unlocking-text');
330
331
332 var data = {
333 'action': 'lock_content_form_handler',
334 'client_id': ep_client_id,
335 'password': password,
336 'post_id': post_id,
337 };
338
339 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
340
341 jQuery.post(eplocalize.ajaxurl, data, function (response) {
342 if (response.success) {
343 if (!response.embedHtml) {
344
345 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
346 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
347 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
348 }
349 else {
350 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
351
352 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
353 epGlobals.youtubeChannelGallery();
354 }
355
356 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
357 epLoadMore();
358 }
359
360 // Custom player initialization when content protection enabled
361 document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').classList.remove('plyr-initialized');
362
363 initPlayer(document.querySelector('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper'));
364
365 if(eplocalize.is_pro_plugin_active){
366 const adIdEl = document.querySelector('#' + perentSel + '-' + ep_client_id + ' [data-ad-id]');
367 adInitialization(adIdEl, adIdEl.getAttribute('data-ad-index'));
368 }
369
370 }
371 } else {
372 jQuery('#password-error_' + ep_client_id).html(response.form);
373 jQuery('#password-error_' + ep_client_id).show();
374 }
375 }, 'json');
376 }
377
378 // unlockSubmitHander called for gutentberg
379 jQuery('.ep-gutenberg-content .password-form').submit(function (e) {
380 e.preventDefault(); // Prevent the default form submission
381 unlockSubmitHander('ep-gutenberg-content', this);
382 });
383
384 window.addEventListener('load', function (e) {
385 const urlParams = new URLSearchParams(window.location.search);
386 const hash = urlParams.get('hash');
387
388 // find the element with the matching id
389 const element = document.getElementById(hash);
390
391 if (element) {
392 element.scrollIntoView({ behavior: 'smooth' });
393 }
394
395 });
396
397
398 })(jQuery);
399
400
401 jQuery(window).on("elementor/frontend/init", function () {
402
403 var filterableGalleryHandler = function ($scope, $) {
404
405 // Get the Elementor unique selector for this widget
406 let classes = $scope[0].className;
407 let selectorEl = '.' + classes.split(' ').join('.');
408
409 const epElLoadMore = () => {
410
411 const spinicon = '<svg width="18" height="18" fill="#fff" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner_GuJz{transform-origin:center;animation:spinner_STY6 1.5s linear infinite}@keyframes spinner_STY6{100%{transform:rotate(360deg)}}</style><g class="spinner_GuJz"><circle cx="3" cy="12" r="2"/><circle cx="21" cy="12" r="2"/><circle cx="12" cy="21" r="2"/><circle cx="12" cy="3" r="2"/><circle cx="5.64" cy="5.64" r="2"/><circle cx="18.36" cy="18.36" r="2"/><circle cx="5.64" cy="18.36" r="2"/><circle cx="18.36" cy="5.64" r="2"/></g></svg>';
412
413 $('.elementor-widget-container .ep-nft-gallery-wrapper').each(function () {
414 let selctorEl = `.elementor-widget-container [data-nftid='${$(this).data('nftid')}']`;
415 let loadmorelabel = $(selctorEl).data('loadmorelabel');
416 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
417 $('.elementor-widget-container .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
418
419 $(selctorEl + " .nft-loadmore").click(function (e) {
420 //change the text of the button
421 $(this).html(loadmorelabel + spinicon);
422
423 //disable the button
424 $(this).prop("disabled", true);
425 //wait for 1 seconds
426 setTimeout(function () {
427 //change the text back
428 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
429 //enable the button
430 $(selctorEl + " .nft-loadmore").prop("disabled", false);
431 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
432 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
433 $(selctorEl + " .nft-loadmore").fadeOut("slow");
434 }
435 }, 500);
436 });
437 });
438 };
439
440 if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
441 epElLoadMore();
442 }
443
444 // Content protection system function
445 const unlockElSubmitHander = (perentSel, that) => {
446 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
447 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
448 var post_id = jQuery(`input[name="post_id"]`).val();
449 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
450 const unlokingText = jQuery(that).data('unlocking-text');
451
452 var data = {
453 'action': 'lock_content_form_handler',
454 'client_id': ep_client_id,
455 'password': password,
456 'post_id': post_id,
457 };
458
459 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
460
461 jQuery.post(eplocalize.ajaxurl, data, function (response) {
462 if (response.success) {
463 if (!response.embedHtml) {
464 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
465 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
466 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
467 }
468 else {
469 if ($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length) {
470 $('.ep-content-locked').removeClass('ep-content-locked');
471 }
472
473 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
474
475 $('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled');
476
477 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
478 epGlobals.youtubeChannelGallery();
479 }
480
481 if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
482 epElLoadMore();
483 }
484 }
485 } else {
486 jQuery('#password-error_' + ep_client_id).html(response.form);
487 jQuery('#password-error_' + ep_client_id).show();
488 }
489 }, 'json');
490 }
491
492 // unlockElSubmitHander called for Elementor
493 jQuery('.ep-elementor-content .password-form').submit(function (e) {
494 e.preventDefault(); // Prevent the default form submission
495 unlockElSubmitHander('ep-elementor-content', this);
496 });
497 };
498
499 const adsHandler = function ($scope, $) {
500 window.epAdIndex = typeof(window.epAdIndex) === 'undefined' ? 0 : window.epAdIndex + 1;
501 console.log(window.epAdIndex);
502 let classes = $scope[0].className;
503 let classJoint = '.' + classes.split(' ').join('.');
504 const selectorEl = document.querySelector(classJoint + ' [data-ad-id]');
505
506
507 console.log(classJoint);
508 if (jQuery('body').hasClass('elementor-editor-active') && eplocalize.is_pro_plugin_active) {
509 adInitialization(selectorEl, window.epAdIndex);
510 }
511
512 }
513
514 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler);
515 elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler);
516 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
517 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", adsHandler);
518 });
519
520
521 // document.addEventListener('DOMContentLoaded', function () {
522 // testHellowWorld();
523 // });
524
525 // testHellowWorld();
526