PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.7.3
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.7.3
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 4 years ago documents-viewer-script.js 3 years ago front.js 3 years ago index.html 7 years ago pdfobject.min.js 3 years ago preview.js 3 years ago settings.js 6 years ago
front.js
495 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 let epGlobals = {};
10
11 (function ($) {
12 'use strict';
13 // function equivalent to jquery ready()
14 function ready(fn) {
15 if (document.readyState !== 'loading') {
16 fn();
17 } else {
18 document.addEventListener('DOMContentLoaded', fn);
19 }
20 }
21
22 ready(function () {
23 let option = {
24 forceObject: true,
25 };
26 let selector = document.querySelectorAll('.embedpress-embed-document-pdf');
27 if (selector.length) {
28 selector.forEach((function (value, index, thisArg) {
29 let id = value.dataset['emid'];
30 let src = value.dataset['emsrc'];
31 PDFObject.embed(src, "." + id, option);
32 }));
33 }
34 if (typeof epGlobals.youtubeChannelGallery === 'function') {
35 epGlobals.youtubeChannelGallery();
36 }
37 });
38
39 /**
40 *
41 * Make embeds responsive so they don't overflow their container.
42 */
43
44 /**
45 * Add max-width & max-height to <iframe> elements, depending on their width & height props.
46 *
47 *
48 * @return {void}
49 */
50 function embedPressResponsiveEmbeds() {
51 var proportion, parentWidth;
52
53 // Loop iframe elements.
54 document.querySelectorAll('iframe').forEach(function (iframe) {
55 // Only continue if the iframe has a width & height defined.
56 if (iframe.width && iframe.height) {
57 // Calculate the proportion/ratio based on the width & height.
58 proportion = parseFloat(iframe.width) / parseFloat(iframe.height);
59 // Get the parent element's width.
60 parentWidth = parseFloat(window.getComputedStyle(iframe.parentElement, null).width.replace('px', ''));
61 // Set the max-width & height.
62 iframe.style.maxWidth = '100%';
63 iframe.style.maxHeight = Math.round(parentWidth / proportion).toString() + 'px';
64 }
65 });
66 }
67
68 // Run on initial load.
69 embedPressResponsiveEmbeds();
70
71 // Run on resize.
72 window.onresize = embedPressResponsiveEmbeds;
73
74
75 function hasClass(ele, cls) {
76 return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
77 }
78
79 function addClass(ele, cls) {
80 if (!hasClass(ele, cls)) ele.className += " " + cls;
81 }
82
83 function removeClass(ele, cls) {
84 if (hasClass(ele, cls)) {
85 var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
86 ele.className = ele.className.replace(reg, " ");
87 }
88 }
89 if (!Element.prototype.matches) {
90 Element.prototype.matches =
91 Element.prototype.matchesSelector ||
92 Element.prototype.webkitMatchesSelector ||
93 Element.prototype.mozMatchesSelector ||
94 Element.prototype.msMatchesSelector ||
95 Element.prototype.oMatchesSelector ||
96 function (s) {
97 var matches = (this.document || this.ownerDocument).querySelectorAll(s),
98 i = matches.length;
99 while (--i >= 0 && matches.item(i) !== this) { }
100 return i > -1;
101 };
102 }
103 var delegate = function (el, evt, sel, handler) {
104 el.addEventListener(evt, function (event) {
105 var t = event.target;
106 while (t && t !== this) {
107 if (t.matches(sel)) {
108 handler.call(t, event);
109 }
110 t = t.parentNode;
111 }
112 });
113 };
114
115 function sendRequest(url, postData, callback) {
116 var req = createXMLHTTPObject();
117 if (!req) return;
118 var method = postData ? "POST" : "GET";
119 req.open(method, url, true);
120 if (postData) {
121 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
122 }
123 req.onreadystatechange = function () {
124 if (req.readyState != 4) return;
125 if (req.status != 200 && req.status != 304) {
126 return;
127 }
128 callback(req);
129 };
130 if (req.readyState == 4) return;
131 req.send(postData);
132 }
133
134 var XMLHttpFactories = [
135 function () {
136 return new XMLHttpRequest();
137 },
138 function () {
139 return new ActiveXObject("Msxml3.XMLHTTP");
140 },
141 function () {
142 return new ActiveXObject("Msxml2.XMLHTTP.6.0");
143 },
144 function () {
145 return new ActiveXObject("Msxml2.XMLHTTP.3.0");
146 },
147 function () {
148 return new ActiveXObject("Msxml2.XMLHTTP");
149 },
150 function () {
151 return new ActiveXObject("Microsoft.XMLHTTP");
152 },
153 ];
154
155 function createXMLHTTPObject() {
156 var xmlhttp = false;
157 for (var i = 0; i < XMLHttpFactories.length; i++) {
158 try {
159 xmlhttp = XMLHttpFactories[i]();
160 } catch (e) {
161 continue;
162 }
163 break;
164 }
165 return xmlhttp;
166 }
167
168 epGlobals.youtubeChannelGallery = function () {
169 var playerWraps = document.getElementsByClassName("ep-player-wrap");
170 if (playerWraps && playerWraps.length) {
171 for (var i = 0, im = playerWraps.length; im > i; i++) {
172 youtubeChannelEvents(playerWraps[i])
173 }
174 }
175 }
176
177 function youtubeChannelEvents(playerWrap) {
178
179 delegate(playerWrap, "click", ".item", function (event) {
180 var embed = "https://www.youtube.com/embed/";
181 var vid = this.getAttribute("data-vid");
182 var iframe = playerWrap.getElementsByTagName("iframe");
183 if (vid) {
184 if (iframe) {
185 var vidSrc = iframe[0].src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
186 if (vidSrc.indexOf('autoplay') > 0) {
187 vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1');
188 }
189 else {
190 vidSrc += '&autoplay=1';
191 }
192 iframe[0].src = vidSrc;
193 playerWrap.scrollIntoView();
194 }
195 }
196 });
197
198 var currentPage = 1;
199
200 let nearestEpContentId = playerWrap.querySelector('.ep-youtube__content__block').getAttribute('data-unique-id');
201
202 delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event) {
203 const totalPages = event.target.closest('.ose-youtube').getAttribute('data-total-pages');
204 const closestClass = event.target.closest('.ose-youtube').classList;
205
206 const activePage = document.querySelector(`.${closestClass[1]} .embedpress-page-active`);
207 if (activePage) {
208 document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active');
209 }
210
211
212
213 var isNext = this.classList.contains("ep-next");
214
215 if (isNext) {
216 currentPage++;
217 } else {
218 currentPage--;
219 }
220
221 var data = {
222 action: "youtube_rest_api",
223 playlistid: this.getAttribute("data-playlistid"),
224 pagetoken: this.getAttribute("data-pagetoken"),
225 pagesize: this.getAttribute("data-pagesize"),
226 currentpage: currentPage
227 };
228
229 var formBody = [];
230 for (var property in data) {
231 var encodedKey = encodeURIComponent(property);
232 var encodedValue = encodeURIComponent(data[property]);
233 formBody.push(encodedKey + "=" + encodedValue);
234 }
235 formBody = formBody.join("&");
236
237 var galleryWrapper = playerWrap.getElementsByClassName(
238 "ep-youtube__content__block"
239 );
240
241 playerWrap.setAttribute('data-current-page', currentPage);
242
243
244 let x = 1;
245
246 sendRequest("/wp-admin/admin-ajax.php", formBody, function (request) {
247 if (galleryWrapper && galleryWrapper[0] && request.responseText) {
248 var response = JSON.parse(request.responseText);
249 galleryWrapper[0].outerHTML = response.html;
250
251 var currentPageNode =
252 galleryWrapper[0].getElementsByClassName("current-page");
253 if (currentPageNode && currentPageNode[0]) {
254 currentPageNode[0].textContent = currentPage;
255
256 }
257 }
258 });
259
260 const intervalID = setInterval(() => {
261 x++
262
263 if (playerWrap.querySelector('.ep-youtube__content__block')) {
264 const newNearestEpContentId = playerWrap
265 .querySelector('.ep-youtube__content__block')
266 .getAttribute('data-unique-id');
267
268 if (newNearestEpContentId !== nearestEpContentId && playerWrap.querySelector(`[data-page="${currentPage}"]`)) {
269 playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active');
270 nearestEpContentId = newNearestEpContentId;
271 clearInterval(intervalID);
272 }
273 }
274
275 if (x > 100) {
276 clearInterval(intervalID);
277 }
278 }, 100);
279
280 });
281 }
282
283 //Load more for OpenaSea collection
284 const epLoadMore = () => {
285
286 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function () {
287 let selctorEl = `[data-nftid='${$(this).data('nftid')}']`;
288
289 let loadmorelabel = $(selctorEl).data('loadmorelabel');
290 let iconcolor = $(selctorEl + " .nft-loadmore").data('iconcolor');
291
292 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>`;
293
294 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
295 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
296
297 $(selctorEl + " .nft-loadmore").click(function (e) {
298 //change the text of the button
299 $(this).html(loadmorelabel + spinicon);
300 //disable the button
301 $(this).prop("disabled", true);
302 //wait for 1 seconds
303 setTimeout(function () {
304 //change the text back
305 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
306 //enable the button
307 $(selctorEl + " .nft-loadmore").prop("disabled", false);
308 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
309 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
310 $(selctorEl + " .nft-loadmore").fadeOut("slow");
311 }
312 }, 500);
313 });
314 });
315 };
316
317 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
318 epLoadMore();
319 }
320
321 // Content protection system function
322 const unlockSubmitHander = (perentSel, that) => {
323 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
324 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
325 var epbase = jQuery(`input[name="ep_base_${ep_client_id}"]`).val();
326 var hash_key = jQuery(`input[name="hash_key_${ep_client_id}"]`).val();
327 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
328 const unlokingText = jQuery(that).data('unlocking-text');
329
330
331 var data = {
332 'action': 'lock_content_form_handler',
333 'client_id': ep_client_id,
334 'password': password,
335 'hash_key': hash_key,
336 'epbase': epbase
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 }
361 } else {
362 jQuery('#password-error_' + ep_client_id).html(response.form);
363 jQuery('#password-error_' + ep_client_id).show();
364 }
365 }, 'json');
366 }
367
368 // unlockSubmitHander called for gutentberg
369 jQuery('.ep-gutenberg-content .password-form').submit(function (e) {
370 e.preventDefault(); // Prevent the default form submission
371 unlockSubmitHander('ep-gutenberg-content', this);
372 });
373
374 window.addEventListener('load', function (e) {
375 const urlParams = new URLSearchParams(window.location.search);
376 const hash = urlParams.get('hash');
377
378 // find the element with the matching id
379 const element = document.getElementById(hash);
380
381 if (element) {
382 element.scrollIntoView({ behavior: 'smooth' });
383 }
384
385 });
386
387
388 })(jQuery);
389
390
391 jQuery(window).on("elementor/frontend/init", function () {
392
393 var filterableGalleryHandler = function ($scope, $) {
394
395 // Get the Elementor unique selector for this widget
396 let classes = $scope[0].className;
397 let selectorEl = '.' + classes.split(' ').join('.');
398
399 const epElLoadMore = () => {
400
401 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>';
402
403 $('.elementor-widget-container .ep-nft-gallery-wrapper').each(function () {
404 let selctorEl = `.elementor-widget-container [data-nftid='${$(this).data('nftid')}']`;
405 let loadmorelabel = $(selctorEl).data('loadmorelabel');
406 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
407 $('.elementor-widget-container .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
408
409 $(selctorEl + " .nft-loadmore").click(function (e) {
410 //change the text of the button
411 $(this).html(loadmorelabel + spinicon);
412
413 //disable the button
414 $(this).prop("disabled", true);
415 //wait for 1 seconds
416 setTimeout(function () {
417 //change the text back
418 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
419 //enable the button
420 $(selctorEl + " .nft-loadmore").prop("disabled", false);
421 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
422 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
423 $(selctorEl + " .nft-loadmore").fadeOut("slow");
424 }
425 }, 500);
426 });
427 });
428 };
429
430 if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
431 epElLoadMore();
432 }
433
434 // Content protection system function
435 const unlockElSubmitHander = (perentSel, that) => {
436 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
437 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
438 var epbase = jQuery(`input[name="ep_base_${ep_client_id}"]`).val();
439 var hash_key = jQuery(`input[name="hash_key_${ep_client_id}"]`).val();
440 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
441 const unlokingText = jQuery(that).data('unlocking-text');
442
443 var data = {
444 'action': 'lock_content_form_handler',
445 'client_id': ep_client_id,
446 'password': password,
447 'hash_key': hash_key,
448 'epbase': epbase
449 };
450
451 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
452
453 jQuery.post(eplocalize.ajaxurl, data, function (response) {
454 if (response.success) {
455 if (!response.embedHtml) {
456 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
457 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
458 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
459 }
460 else {
461 if ($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length) {
462 $('.ep-content-locked').removeClass('ep-content-locked');
463 }
464
465 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
466
467 $('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled');
468
469 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
470 epGlobals.youtubeChannelGallery();
471 }
472
473 if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
474 epElLoadMore();
475 }
476 }
477 } else {
478 jQuery('#password-error_' + ep_client_id).html(response.form);
479 jQuery('#password-error_' + ep_client_id).show();
480 }
481 }, 'json');
482 }
483
484 // unlockElSubmitHander called for Elementor
485 jQuery('.ep-elementor-content .password-form').submit(function (e) {
486 e.preventDefault(); // Prevent the default form submission
487 unlockElSubmitHander('ep-elementor-content', this);
488 });
489 };
490 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler);
491 elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler);
492 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
493 });
494
495