PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 3.5.1
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v3.5.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 4 years ago preview.js 3 years ago settings.js 6 years ago
front.js
237 lines
1 /**
2 * @package EmbedPress
3 * @author EmbedPress <help@embedpress.com>
4 * @copyright Copyright (C) 2022 EmbedPress. All rights reserved.
5 * @license GPLv2 or later
6 * @since 1.7.0
7 */
8 (function () {
9 'use strict';
10 // function equivalent to jquery ready()
11 function ready(fn) {
12 if (document.readyState !== 'loading'){
13 fn();
14 } else {
15 document.addEventListener('DOMContentLoaded', fn);
16 }
17 }
18
19 ready(function() {
20 let option = {
21 forceObject: true,
22 };
23 let selector = document.querySelectorAll('.embedpress-embed-document-pdf');
24 if (selector.length) {
25 selector.forEach((function(value, index, thisArg) {
26 let id = value.dataset['emid'];
27 let src = value.dataset['emsrc'];
28 PDFObject.embed(src, "."+id, option);
29 }));
30 }
31 youtubeChannelGallery();
32 });
33
34 /**
35 *
36 * Make embeds responsive so they don't overflow their container.
37 */
38
39 /**
40 * Add max-width & max-height to <iframe> elements, depending on their width & height props.
41 *
42 *
43 * @return {void}
44 */
45 function embedPressResponsiveEmbeds() {
46 var proportion, parentWidth;
47
48 // Loop iframe elements.
49 document.querySelectorAll( 'iframe' ).forEach( function( iframe ) {
50 // Only continue if the iframe has a width & height defined.
51 if ( iframe.width && iframe.height ) {
52 // Calculate the proportion/ratio based on the width & height.
53 proportion = parseFloat( iframe.width ) / parseFloat( iframe.height );
54 // Get the parent element's width.
55 parentWidth = parseFloat( window.getComputedStyle( iframe.parentElement, null ).width.replace( 'px', '' ) );
56 // Set the max-width & height.
57 iframe.style.maxWidth = '100%';
58 iframe.style.maxHeight = Math.round( parentWidth / proportion ).toString() + 'px';
59 }
60 } );
61 }
62
63 // Run on initial load.
64 embedPressResponsiveEmbeds();
65
66 // Run on resize.
67 window.onresize = embedPressResponsiveEmbeds;
68
69
70 function hasClass(ele, cls) {
71 return !!ele.className.match(new RegExp("(\\s|^)" + cls + "(\\s|$)"));
72 }
73
74 function addClass(ele, cls) {
75 if (!hasClass(ele, cls)) ele.className += " " + cls;
76 }
77
78 function removeClass(ele, cls) {
79 if (hasClass(ele, cls)) {
80 var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
81 ele.className = ele.className.replace(reg, " ");
82 }
83 }
84 if (!Element.prototype.matches) {
85 Element.prototype.matches =
86 Element.prototype.matchesSelector ||
87 Element.prototype.webkitMatchesSelector ||
88 Element.prototype.mozMatchesSelector ||
89 Element.prototype.msMatchesSelector ||
90 Element.prototype.oMatchesSelector ||
91 function(s) {
92 var matches = (this.document || this.ownerDocument).querySelectorAll(s),
93 i = matches.length;
94 while (--i >= 0 && matches.item(i) !== this) {}
95 return i > -1;
96 };
97 }
98 var delegate = function(el, evt, sel, handler) {
99 el.addEventListener(evt, function(event) {
100 var t = event.target;
101 while (t && t !== this) {
102 if (t.matches(sel)) {
103 handler.call(t, event);
104 }
105 t = t.parentNode;
106 }
107 });
108 };
109
110 function sendRequest(url, postData, callback) {
111 var req = createXMLHTTPObject();
112 if (!req) return;
113 var method = postData ? "POST" : "GET";
114 req.open(method, url, true);
115 if (postData) {
116 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
117 }
118 req.onreadystatechange = function() {
119 if (req.readyState != 4) return;
120 if (req.status != 200 && req.status != 304) {
121 return;
122 }
123 callback(req);
124 };
125 if (req.readyState == 4) return;
126 req.send(postData);
127 }
128
129 var XMLHttpFactories = [
130 function() {
131 return new XMLHttpRequest();
132 },
133 function() {
134 return new ActiveXObject("Msxml3.XMLHTTP");
135 },
136 function() {
137 return new ActiveXObject("Msxml2.XMLHTTP.6.0");
138 },
139 function() {
140 return new ActiveXObject("Msxml2.XMLHTTP.3.0");
141 },
142 function() {
143 return new ActiveXObject("Msxml2.XMLHTTP");
144 },
145 function() {
146 return new ActiveXObject("Microsoft.XMLHTTP");
147 },
148 ];
149
150 function createXMLHTTPObject() {
151 var xmlhttp = false;
152 for (var i = 0; i < XMLHttpFactories.length; i++) {
153 try {
154 xmlhttp = XMLHttpFactories[i]();
155 } catch (e) {
156 continue;
157 }
158 break;
159 }
160 return xmlhttp;
161 }
162 function youtubeChannelGallery() {
163 var playerWraps = document.getElementsByClassName("ep-player-wrap");
164 if (playerWraps && playerWraps.length) {
165 for (var i=0, im=playerWraps.length; im>i; i++) {
166 youtubeChannelEvents(playerWraps[i])
167 }
168 }
169 }
170 function youtubeChannelEvents(playerWrap){
171 delegate(playerWrap, "click", ".item", function(event) {
172 var embed = "https://www.youtube.com/embed/";
173 var vid = this.getAttribute("data-vid");
174 var iframe = playerWrap.getElementsByTagName("iframe");
175 if(vid) {
176 if(iframe){
177 var vidSrc = iframe[0].src.replace(/(.*\/embed\/)([^\?&"'>]+)(.+)?/, `\$1${vid}\$3`);
178 if (vidSrc.indexOf('autoplay') > 0)
179 {
180 vidSrc = vidSrc.replace('autoplay=0', 'autoplay=1');
181 }
182 else
183 {
184 vidSrc += '&autoplay=1';
185 }
186 iframe[0].src = vidSrc;
187 playerWrap.scrollIntoView();
188 }
189 }
190 });
191 var currentPage = 1;
192 delegate(playerWrap, "click", ".ep-next, .ep-prev", function(event) {
193 var isNext = this.classList.contains("ep-next");
194 if (isNext) {
195 currentPage++;
196 } else {
197 currentPage--;
198 }
199 var data = {
200 action: "youtube_rest_api",
201 playlistid: this.getAttribute("data-playlistid"),
202 pagetoken: this.getAttribute("data-pagetoken"),
203 pagesize: this.getAttribute("data-pagesize"),
204 };
205
206 var formBody = [];
207 for (var property in data) {
208 var encodedKey = encodeURIComponent(property);
209 var encodedValue = encodeURIComponent(data[property]);
210 formBody.push(encodedKey + "=" + encodedValue);
211 }
212 formBody = formBody.join("&");
213
214 var loader = playerWrap.getElementsByClassName("ep-loader");
215 var galleryWrapper = playerWrap.getElementsByClassName(
216 "ep-youtube__content__block"
217 );
218 removeClass(loader[0], "hide");
219 addClass(galleryWrapper[0], "loading");
220 sendRequest("/wp-admin/admin-ajax.php", formBody, function(request) {
221 addClass(loader[0], "hide");
222 removeClass(galleryWrapper[0], "loading");
223
224 if (galleryWrapper && galleryWrapper[0] && request.responseText) {
225 var response = JSON.parse(request.responseText);
226 galleryWrapper[0].outerHTML = response.html;
227 var currentPageNode =
228 galleryWrapper[0].getElementsByClassName("current-page");
229 if (currentPageNode && currentPageNode[0]) {
230 currentPageNode[0].textContent = currentPage;
231 }
232 }
233 });
234 });
235 }
236 })();
237