chunks
1 month ago
vendor
8 months ago
admin.build.js
1 month ago
admin.js
3 months ago
analytics-tracker.js
9 months ago
analytics.build.js
1 month ago
blocks.build.js
1 month ago
carousel.js
1 year ago
custom-player.build.js
1 month ago
documents-viewer-script.js
3 months ago
ep-pdf-lightbox.js
3 months ago
feature-notices.js
7 months ago
front.js
3 months ago
frontend.build.js
3 months ago
gallery-justify.js
9 months ago
gutneberg-script.js
1 month ago
index.html
7 years ago
initCarousel.js
2 years ago
initplyr.js
1 month ago
instafeed.js
1 month ago
instagram-shortcode-generator.js
1 month ago
lazy-load.js
6 months ago
license.js
3 months ago
meetup-timezone.js
3 months ago
onboarding.build.js
1 month ago
pdf-gallery-elementor-editor.js
3 months ago
pdf-gallery.js
3 months ago
preview.js
8 months ago
settings.js
3 months ago
sponsored.js
9 months ago
documents-viewer-script.js
315 lines
| 1 | |
| 2 | const embedpressDocViewer = {}; |
| 3 | |
| 4 | document.addEventListener("fullscreenchange", () => { |
| 5 | if (!document.fullscreenElement) { |
| 6 | const viwerParentEl = document.querySelector('.ep-file-download-option-masked.fullscreen-enabled'); |
| 7 | if (viwerParentEl) { |
| 8 | viwerParentEl.classList.remove("fullscreen-enabled"); |
| 9 | viwerParentEl.querySelector(".ep-doc-minimize-icon").style.display = 'none'; |
| 10 | viwerParentEl.querySelector(".ep-doc-fullscreen-icon").style.display = 'flex'; |
| 11 | } |
| 12 | } |
| 13 | }); |
| 14 | |
| 15 | document.addEventListener("keydown", (event) => { |
| 16 | if (event.key === "Escape") { |
| 17 | const viwerParentEl = document.querySelector('.ep-file-download-option-masked.fullscreen-enabled'); |
| 18 | if (viwerParentEl) { |
| 19 | if (document.exitFullscreen) { |
| 20 | document.exitFullscreen(); |
| 21 | } else if (document.webkitExitFullscreen) { |
| 22 | document.webkitExitFullscreen(); |
| 23 | } else if (document.msExitFullscreen) { |
| 24 | document.msExitFullscreen(); |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | }); |
| 29 | |
| 30 | |
| 31 | embedpressDocViewer.getColorBrightness = (hexColor) => { |
| 32 | const r = parseInt(hexColor.slice(1, 3), 16); |
| 33 | const g = parseInt(hexColor.slice(3, 5), 16); |
| 34 | const b = parseInt(hexColor.slice(5, 7), 16); |
| 35 | |
| 36 | // Convert the RGB color to HSL |
| 37 | const max = Math.max(r, g, b); |
| 38 | const min = Math.min(r, g, b); |
| 39 | const l = (max + min) / 2; |
| 40 | |
| 41 | // Calculate the brightness position in percentage |
| 42 | const brightnessPercentage = Math.round(l / 255 * 100); |
| 43 | |
| 44 | return brightnessPercentage; |
| 45 | } |
| 46 | |
| 47 | embedpressDocViewer.adjustHexColor = (hexColor, percentage) => { |
| 48 | // Convert hex color to RGB values |
| 49 | const r = parseInt(hexColor.slice(1, 3), 16); |
| 50 | const g = parseInt(hexColor.slice(3, 5), 16); |
| 51 | const b = parseInt(hexColor.slice(5, 7), 16); |
| 52 | |
| 53 | // Calculate adjusted RGB values |
| 54 | const adjustment = Math.round((percentage / 100) * 255); |
| 55 | const newR = Math.max(Math.min(r + adjustment, 255), 0); |
| 56 | const newG = Math.max(Math.min(g + adjustment, 255), 0); |
| 57 | const newB = Math.max(Math.min(b + adjustment, 255), 0); |
| 58 | |
| 59 | // Convert adjusted RGB values back to hex color |
| 60 | const newHexColor = '#' + ((1 << 24) + (newR << 16) + (newG << 8) + newB).toString(16).slice(1); |
| 61 | |
| 62 | return newHexColor; |
| 63 | } |
| 64 | |
| 65 | embedpressDocViewer.viewerStyle = () => { |
| 66 | const viwerParentEls = document.querySelectorAll('.ep-file-download-option-masked'); |
| 67 | |
| 68 | let customStyle = document.getElementById('custom-styles') || document.createElement('style'); |
| 69 | customStyle.id = 'custom-styles'; |
| 70 | customStyle.type = 'text/css'; |
| 71 | customStyle.innerHTML = '' |
| 72 | |
| 73 | if (viwerParentEls !== null) { |
| 74 | viwerParentEls.forEach((el) => { |
| 75 | let customColor = el.getAttribute('data-custom-color'); |
| 76 | if (customColor == null) { |
| 77 | return false; |
| 78 | } |
| 79 | let colorBrightness = embedpressDocViewer.getColorBrightness(customColor); |
| 80 | let docId = el.getAttribute('data-id'); |
| 81 | |
| 82 | let iconsColor = '#f2f2f6'; |
| 83 | if (colorBrightness > 60) { |
| 84 | iconsColor = '#343434'; |
| 85 | } |
| 86 | |
| 87 | if (el.getAttribute('data-theme-mode') == 'custom') { |
| 88 | |
| 89 | viewerCustomColor = ` |
| 90 | [data-id='${docId}'][data-theme-mode='custom'] { |
| 91 | --viewer-primary-color: ${customColor}; |
| 92 | --viewer-icons-color: ${iconsColor}; |
| 93 | --viewer-icons-hover-bgcolor: ${embedpressDocViewer.adjustHexColor(customColor, -10)}; |
| 94 | |
| 95 | }`; |
| 96 | customStyle.innerHTML += viewerCustomColor; |
| 97 | } |
| 98 | }); |
| 99 | |
| 100 | document.head.appendChild(customStyle); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | embedpressDocViewer.epDocumentsViewerController = () => { |
| 105 | // Remove previous listeners to prevent duplicates when called multiple times |
| 106 | if (embedpressDocViewer._handleClick) { |
| 107 | document.removeEventListener('click', embedpressDocViewer._handleClick); |
| 108 | } |
| 109 | if (embedpressDocViewer._handleDrawIconClick) { |
| 110 | document.removeEventListener('click', embedpressDocViewer._handleDrawIconClick); |
| 111 | } |
| 112 | if (embedpressDocViewer._handleFullscreenChange) { |
| 113 | document.removeEventListener('fullscreenchange', embedpressDocViewer._handleFullscreenChange); |
| 114 | } |
| 115 | |
| 116 | const viwerParentEls = document.querySelectorAll('.ep-file-download-option-masked'); |
| 117 | |
| 118 | function handleFullscreenChange() { |
| 119 | if (!document.fullscreenElement) { |
| 120 | viwerParentEls.forEach((el) => { |
| 121 | el.classList.remove('fullscreen-enabled'); |
| 122 | el.querySelector('.ep-doc-minimize-icon').style.display = 'none'; |
| 123 | el.querySelector('.ep-doc-fullscreen-icon').style.display = 'flex'; |
| 124 | }); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | function handleClick(event) { |
| 129 | event.stopPropagation(); |
| 130 | |
| 131 | const viwerParentEl = event.target.closest('.ep-file-download-option-masked'); |
| 132 | |
| 133 | if (!viwerParentEl) { return; } |
| 134 | |
| 135 | const viewerIframeEl = viwerParentEl.querySelector('iframe'); |
| 136 | if (!viewerIframeEl) return; |
| 137 | |
| 138 | const iframeSrc = decodeURIComponent(viewerIframeEl.getAttribute('src')); |
| 139 | if (!iframeSrc) return; |
| 140 | |
| 141 | const regex = /(url|src)=([^&]+)/; |
| 142 | const match = iframeSrc.match(regex); |
| 143 | let fileUrl = match && match[2]; |
| 144 | |
| 145 | if (!fileUrl) { |
| 146 | fileUrl = iframeSrc; |
| 147 | } |
| 148 | |
| 149 | const popupIcon = event.target.closest('.ep-doc-popup-icon svg'); |
| 150 | const printIcon = event.target.closest('.ep-doc-print-icon svg'); |
| 151 | const downloadcIcon = event.target.closest('.ep-doc-download-icon svg'); |
| 152 | const minimizeIcon = event.target.closest('.ep-doc-minimize-icon svg'); |
| 153 | const fullscreenIcon = event.target.closest('.ep-doc-fullscreen-icon svg'); |
| 154 | |
| 155 | if (popupIcon instanceof SVGElement) { |
| 156 | window.open(fileUrl, '_blank'); |
| 157 | } else if (printIcon instanceof SVGElement) { |
| 158 | const newTab = window.open(`https://view.officeapps.live.com/op/view.aspx?src=${fileUrl}&wdOrigin=BROWSELINK`, '_blank'); |
| 159 | } else if (downloadcIcon instanceof SVGElement) { |
| 160 | fetch(fileUrl, { mode: 'no-cors' }) |
| 161 | .then(response => { |
| 162 | if (response.ok) { |
| 163 | response.blob().then(blob => { |
| 164 | const url = window.URL.createObjectURL(blob); |
| 165 | const a = document.createElement('a'); |
| 166 | a.href = url; |
| 167 | a.download = fileUrl.substring(fileUrl.lastIndexOf('/') + 1); |
| 168 | document.body.appendChild(a); |
| 169 | a.click(); |
| 170 | a.remove(); |
| 171 | }); |
| 172 | } else { |
| 173 | window.location.href = fileUrl; |
| 174 | } |
| 175 | }) |
| 176 | .catch(error => { |
| 177 | window.location.href = fileUrl; |
| 178 | }); |
| 179 | } else if (minimizeIcon instanceof SVGElement) { |
| 180 | if (document.exitFullscreen) { |
| 181 | document.exitFullscreen(); |
| 182 | } else if (document.webkitExitFullscreen) { |
| 183 | document.webkitExitFullscreen(); |
| 184 | } else if (document.msExitFullscreen) { |
| 185 | document.msExitFullscreen(); |
| 186 | } |
| 187 | } else if (fullscreenIcon instanceof SVGElement) { |
| 188 | if (viwerParentEl.requestFullscreen) { |
| 189 | viwerParentEl.requestFullscreen(); |
| 190 | } else if (viwerParentEl.webkitRequestFullscreen) { |
| 191 | viwerParentEl.webkitRequestFullscreen(); |
| 192 | } else if (viwerParentEl.msRequestFullscreen) { |
| 193 | viwerParentEl.msRequestFullscreen(); |
| 194 | } |
| 195 | |
| 196 | viwerParentEl.querySelector(".ep-doc-minimize-icon").style.display = 'flex'; |
| 197 | viwerParentEl.querySelector(".ep-doc-fullscreen-icon").style.display = 'none'; |
| 198 | viwerParentEl.classList.add("fullscreen-enabled"); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | function handleDrawIconClick(event) { |
| 203 | event.stopPropagation(); |
| 204 | |
| 205 | const drawIcon = event.target.closest('.ep-doc-draw-icon svg'); |
| 206 | if (!drawIcon) return; |
| 207 | |
| 208 | const viwerParentEl = drawIcon.closest('.ep-file-download-option-masked'); |
| 209 | if (!viwerParentEl) return; |
| 210 | |
| 211 | const canvas = viwerParentEl.querySelector(".ep-doc-canvas"); |
| 212 | const drawToggle = viwerParentEl.querySelector(".ep-doc-draw-icon svg"); |
| 213 | if (!canvas || !drawToggle) return; |
| 214 | |
| 215 | const ctx = canvas.getContext("2d"); |
| 216 | let isDrawing = false; |
| 217 | let canDraw = false; |
| 218 | |
| 219 | canvas.addEventListener("mousedown", function (e) { |
| 220 | if (canDraw) { |
| 221 | isDrawing = true; |
| 222 | const rect = canvas.getBoundingClientRect(); |
| 223 | const scrollX = window.pageXOffset || document.documentElement.scrollLeft; |
| 224 | const x = e.pageX - rect.left - scrollX; |
| 225 | const y = e.pageY - rect.top; |
| 226 | ctx.beginPath(); |
| 227 | ctx.moveTo(x, y); |
| 228 | } |
| 229 | }); |
| 230 | |
| 231 | canvas.addEventListener("mousemove", function (e) { |
| 232 | if (isDrawing && canDraw) { |
| 233 | const rect = canvas.getBoundingClientRect(); |
| 234 | const scrollX = window.pageXOffset || document.documentElement.scrollLeft; |
| 235 | const x = e.pageX - rect.left - scrollX; |
| 236 | const y = e.pageY - rect.top; |
| 237 | ctx.lineTo(x, y); |
| 238 | ctx.stroke(); |
| 239 | } |
| 240 | }); |
| 241 | |
| 242 | canvas.addEventListener("mouseup", function (e) { |
| 243 | isDrawing = false; |
| 244 | }); |
| 245 | |
| 246 | |
| 247 | drawToggle.parentNode.classList.toggle("active"); |
| 248 | canDraw = drawToggle.parentNode.classList.contains("active"); |
| 249 | canvas.style.display = canDraw ? "block" : "none"; |
| 250 | } |
| 251 | |
| 252 | embedpressDocViewer._handleClick = handleClick; |
| 253 | embedpressDocViewer._handleDrawIconClick = handleDrawIconClick; |
| 254 | embedpressDocViewer._handleFullscreenChange = handleFullscreenChange; |
| 255 | |
| 256 | document.addEventListener('click', handleClick); |
| 257 | document.addEventListener('click', handleDrawIconClick); |
| 258 | document.addEventListener('fullscreenchange', handleFullscreenChange); |
| 259 | }; |
| 260 | |
| 261 | |
| 262 | if (typeof embedpressDocViewer.epDocumentsViewerController === "function") { |
| 263 | if (jQuery('.wp-block-embedpress-document.embedpress-document-embed').length > 0) { |
| 264 | embedpressDocViewer.epDocumentsViewerController(); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | if (typeof wp !== 'undefined' && typeof wp.editor !== 'undefined') { |
| 269 | if (typeof embedpressDocViewer.viewerStyle === "function") { |
| 270 | embedpressDocViewer.epDocumentsViewerController(); |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | // Initialize for Elementor frontend (non-editor) when document viewers exist on the page |
| 275 | if (typeof embedpressDocViewer.epDocumentsViewerController === "function") { |
| 276 | if (jQuery('.ep-file-download-option-masked').length > 0) { |
| 277 | embedpressDocViewer.epDocumentsViewerController(); |
| 278 | embedpressDocViewer.viewerStyle(); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | if (typeof embedpressDocViewer.viewerStyle === "function") { |
| 283 | if (jQuery('.wp-block-embedpress-document.embedpress-document-embed').length > 0) { |
| 284 | embedpressDocViewer.viewerStyle(); |
| 285 | } |
| 286 | } |
| 287 | jQuery(window).on("elementor/frontend/init", function () { |
| 288 | var filterableGalleryHandler = function ($scope, $) { |
| 289 | if (typeof embedpressDocViewer.epDocumentsViewerController === "function") { |
| 290 | embedpressDocViewer.epDocumentsViewerController(); |
| 291 | } |
| 292 | if (typeof embedpressDocViewer.epDocumentsViewerController === "function") { |
| 293 | embedpressDocViewer.viewerStyle(); |
| 294 | } |
| 295 | |
| 296 | }; |
| 297 | elementorFrontend.hooks.addAction("frontend/element_ready/embedpres_document.default", filterableGalleryHandler); |
| 298 | }); |
| 299 | |
| 300 | |
| 301 | const myDivs = document.querySelectorAll('.ep-file-download-option-masked'); |
| 302 | const canDownloadDivs = document.querySelectorAll('.enabled-file-download'); |
| 303 | |
| 304 | |
| 305 | myDivs.forEach(function (div) { |
| 306 | div.addEventListener('contextmenu', preventRightClick); |
| 307 | }); |
| 308 | |
| 309 | function preventRightClick(event) { |
| 310 | event.preventDefault(); |
| 311 | } |
| 312 | |
| 313 | canDownloadDivs.forEach(function (div) { |
| 314 | div.removeEventListener('contextmenu', preventRightClick); |
| 315 | }); |