PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 3.7.1
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v3.7.1
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
492 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 function youtubeChannelEvents(playerWrap) {
177
178 delegate(playerWrap, "click", ".item", function (event) {
179 var embed = "https://www.youtube.com/embed/";
180 var vid = this.getAttribute("data-vid");
181 var iframe = playerWrap.getElementsByTagName("iframe");
182 if (vid) {
183 if (iframe) {
184 var vidSrc = iframe[0].src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
185 if (vidSrc.indexOf('autoplay') > 0) {
186 vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1');
187 }
188 else {
189 vidSrc += '&autoplay=1';
190 }
191 iframe[0].src = vidSrc;
192 playerWrap.scrollIntoView();
193 }
194 }
195 });
196
197 var currentPage = 1;
198
199 let nearestEpContentId = playerWrap.querySelector('.ep-youtube__content__block').getAttribute('data-unique-id');
200
201 delegate(playerWrap, "click", ".ep-next, .ep-prev", function (event) {
202 const totalPages = event.target.closest('.ose-youtube').getAttribute('data-total-pages');
203 const closestClass = event.target.closest('.ose-youtube').classList;
204
205 const activePage = document.querySelector(`.${closestClass[1]} .embedpress-page-active`);
206 if (activePage) {
207 document.querySelector(`.${closestClass[1]} .embedpress-page-active`).classList.remove('embedpress-page-active');
208 }
209
210
211
212 var isNext = this.classList.contains("ep-next");
213
214 if (isNext) {
215 currentPage++;
216 } else {
217 currentPage--;
218 }
219
220 var data = {
221 action: "youtube_rest_api",
222 playlistid: this.getAttribute("data-playlistid"),
223 pagetoken: this.getAttribute("data-pagetoken"),
224 pagesize: this.getAttribute("data-pagesize"),
225 currentpage: currentPage
226 };
227
228 var formBody = [];
229 for (var property in data) {
230 var encodedKey = encodeURIComponent(property);
231 var encodedValue = encodeURIComponent(data[property]);
232 formBody.push(encodedKey + "=" + encodedValue);
233 }
234 formBody = formBody.join("&");
235
236 var galleryWrapper = playerWrap.getElementsByClassName(
237 "ep-youtube__content__block"
238 );
239
240 playerWrap.setAttribute('data-current-page', currentPage);
241
242
243 let x = 1;
244
245 sendRequest("/wp-admin/admin-ajax.php", formBody, function (request) {
246 if (galleryWrapper && galleryWrapper[0] && request.responseText) {
247 var response = JSON.parse(request.responseText);
248 galleryWrapper[0].outerHTML = response.html;
249
250 var currentPageNode =
251 galleryWrapper[0].getElementsByClassName("current-page");
252 if (currentPageNode && currentPageNode[0]) {
253 currentPageNode[0].textContent = currentPage;
254
255 }
256 }
257 });
258
259 const intervalID = setInterval(() => {
260 x++
261
262 if (playerWrap.querySelector('.ep-youtube__content__block')) {
263 const newNearestEpContentId = playerWrap
264 .querySelector('.ep-youtube__content__block')
265 .getAttribute('data-unique-id');
266
267 if (newNearestEpContentId !== nearestEpContentId && playerWrap.querySelector(`[data-page="${currentPage}"]`)) {
268 playerWrap.querySelector(`[data-page="${currentPage}"]`).classList.add('embedpress-page-active');
269 nearestEpContentId = newNearestEpContentId;
270 clearInterval(intervalID);
271 }
272 }
273
274 if (x > 100) {
275 clearInterval(intervalID);
276 }
277 }, 100);
278
279 });
280 }
281
282 //Load more for OpenaSea collection
283 const epLoadMore = () => {
284
285 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').each(function () {
286 let selctorEl = `[data-nftid='${$(this).data('nftid')}']`;
287
288 let loadmorelabel = $(selctorEl).data('loadmorelabel');
289 let iconcolor = $(selctorEl + " .nft-loadmore").data('iconcolor');
290
291 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>`;
292
293 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
294 $('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
295
296 $(selctorEl + " .nft-loadmore").click(function (e) {
297 //change the text of the button
298 $(this).html(loadmorelabel + spinicon);
299 //disable the button
300 $(this).prop("disabled", true);
301 //wait for 1 seconds
302 setTimeout(function () {
303 //change the text back
304 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
305 //enable the button
306 $(selctorEl + " .nft-loadmore").prop("disabled", false);
307 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
308 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
309 $(selctorEl + " .nft-loadmore").fadeOut("slow");
310 }
311 }, 500);
312 });
313 });
314 };
315
316 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
317 epLoadMore();
318 }
319
320 // Content protection system function
321 const unlockSubmitHander = (perentSel, that) => {
322 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
323 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
324 var epbase = jQuery(`input[name="ep_base_${ep_client_id}"]`).val();
325 var hash_key = jQuery(`input[name="hash_key_${ep_client_id}"]`).val();
326 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
327 const unlokingText = jQuery(that).data('unlocking-text');
328
329
330 var data = {
331 'action': 'lock_content_form_handler',
332 'client_id': ep_client_id,
333 'password': password,
334 'hash_key': hash_key,
335 'epbase': epbase
336 };
337
338 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
339
340 jQuery.post(eplocalize.ajaxurl, data, function (response) {
341 if (response.success) {
342 if (!response.embedHtml) {
343
344 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
345 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
346 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
347 }
348 else {
349 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
350
351 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
352 epGlobals.youtubeChannelGallery();
353 }
354
355 if ($('.embedpress-gutenberg-wrapper .ep-nft-gallery-wrapper').length > 0) {
356 epLoadMore();
357 }
358
359 }
360 } else {
361 jQuery('#password-error_' + ep_client_id).html(response.form);
362 jQuery('#password-error_' + ep_client_id).show();
363 }
364 }, 'json');
365 }
366
367 // unlockSubmitHander called for gutentberg
368 jQuery('.ep-gutenberg-content .password-form').submit(function (e) {
369 e.preventDefault(); // Prevent the default form submission
370 unlockSubmitHander('ep-gutenberg-content', this);
371 });
372
373
374
375 window.addEventListener('load', function (e) {
376 const urlParams = new URLSearchParams(window.location.search);
377 const hash = urlParams.get('hash');
378
379 // find the element with the matching id
380 const element = document.getElementById(hash);
381
382 if (element) {
383 element.scrollIntoView({ behavior: 'smooth' });
384 }
385
386 });
387
388
389 })(jQuery);
390
391
392 jQuery(window).on("elementor/frontend/init", function () {
393
394 var filterableGalleryHandler = function ($scope, $) {
395 const epElLoadMore = () => {
396
397 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>';
398
399 $('.elementor-widget-container .ep-nft-gallery-wrapper').each(function () {
400 let selctorEl = `.elementor-widget-container [data-nftid='${$(this).data('nftid')}']`;
401 let loadmorelabel = $(selctorEl).data('loadmorelabel');
402 $(selctorEl + ` .ep_nft_item`).slice(0, $(selctorEl).data('itemparpage')).show();
403 $('.elementor-widget-container .ep-nft-gallery-wrapper .ep-loadmore-wrapper button').css('display', 'flex');
404
405 $(selctorEl + " .nft-loadmore").click(function (e) {
406 //change the text of the button
407 $(this).html(loadmorelabel + spinicon);
408
409 //disable the button
410 $(this).prop("disabled", true);
411 //wait for 1 seconds
412 setTimeout(function () {
413 //change the text back
414 $(selctorEl + " .nft-loadmore").text(loadmorelabel);
415 //enable the button
416 $(selctorEl + " .nft-loadmore").prop("disabled", false);
417 $(selctorEl + " .ep_nft_item:hidden").slice(0, $(selctorEl).data('itemparpage')).fadeIn("slow");
418 if ($(selctorEl + " .ep_nft_item:hidden").length == 0) {
419 $(selctorEl + " .nft-loadmore").fadeOut("slow");
420 }
421 }, 500);
422 });
423 });
424 };
425
426 if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
427 epElLoadMore();
428 }
429
430 // Content protection system function
431 const unlockElSubmitHander = (perentSel, that) => {
432 var ep_client_id = jQuery(that).closest('form').find('input[name="ep_client_id"]').val();
433 var password = jQuery(`input[name="pass_${ep_client_id}"]`).val();
434 var epbase = jQuery(`input[name="ep_base_${ep_client_id}"]`).val();
435 var hash_key = jQuery(`input[name="hash_key_${ep_client_id}"]`).val();
436 const buttonText = jQuery(that).closest('.password-form-container').find('input[type="submit"]').val();
437 const unlokingText = jQuery(that).data('unlocking-text');
438
439 var data = {
440 'action': 'lock_content_form_handler',
441 'client_id': ep_client_id,
442 'password': password,
443 'hash_key': hash_key,
444 'epbase': epbase
445 };
446
447 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(unlokingText);
448
449 jQuery.post(eplocalize.ajaxurl, data, function (response) {
450 if (response.success) {
451 if (!response.embedHtml) {
452 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="submit"]').val(buttonText);
453 jQuery('#' + perentSel + '-' + ep_client_id + ' .password-form input[type="password"]').val('');
454 jQuery(that).closest('.password-form-container').find('.error-message').removeClass('hidden');
455 }
456 else {
457 if ($('.ep-content-locked').has('#' + perentSel + '-' + ep_client_id).length) {
458 $('.ep-content-locked').removeClass('ep-content-locked');
459 }
460
461 jQuery('#' + perentSel + '-' + ep_client_id + ' .ep-embed-content-wraper').html(response.embedHtml);
462
463 $('#' + perentSel + '-' + ep_client_id).removeClass('ep-content-protection-enabled');
464
465 if (jQuery('#' + perentSel + '-' + ep_client_id + ' .ose-youtube').length > 0) {
466 epGlobals.youtubeChannelGallery();
467 }
468
469 if ($('.elementor-widget-container .ep-nft-gallery-wrapper').length > 0) {
470 epElLoadMore();
471 }
472 }
473 } else {
474 jQuery('#password-error_' + ep_client_id).html(response.form);
475 jQuery('#password-error_' + ep_client_id).show();
476 }
477 }, 'json');
478 }
479
480 // unlockElSubmitHander called for Elementor
481 jQuery('.ep-elementor-content .password-form').submit(function (e) {
482 e.preventDefault(); // Prevent the default form submission
483 unlockElSubmitHander('ep-elementor-content', this);
484 });
485
486 };
487 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_elementor.default", filterableGalleryHandler);
488 elementorFrontend.hooks.addAction("frontend/element_ready/embedpress_pdf.default", filterableGalleryHandler);
489 elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler);
490 });
491
492