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