at path:
ROOT
/
wp-content
/
plugins
/
elementor-pro
/
assets
/
js
/
screenshot.js
run:
R
W
Run
notes
DIR
2025-12-13 10:18:35
R
W
Run
packages
DIR
2025-12-13 10:15:57
R
W
Run
36c2990924ec9596ffad.bundle.js
6.09 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
52e03298e7f0852c96a1.bundle.min.js
22.03 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
52e03298e7f0852c96a1.bundle.min.js.LICENSE.txt
188 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
admin.js
56.05 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
admin.min.js
27.6 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
ajax-pagination.2090b5f4906bcda1dcc2.bundle.min.js
2.75 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
ajax-pagination.2390838f542f1a8d5ed4.bundle.js
5.06 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
animated-headline.3eca5f2deb261b97d554.bundle.js
12.51 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
animated-headline.73c41dd605898fe2d075.bundle.min.js
7.68 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
app.js
300.76 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
app.min.js
86.33 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
archive-posts.16a93245d08246e5e540.bundle.min.js
7.92 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
archive-posts.6e398ddd4a81a78bcea3.bundle.js
15.52 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
c62a5d15e98a98580947.bundle.js
65.83 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
carousel.298f1fc9c115422aad0e.bundle.js
9.93 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
carousel.3620fca501cb18163600.bundle.min.js
4.9 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
code-highlight.d4867c919d0858f748df.bundle.js
1022 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
code-highlight.d86022c8668c4b072592.bundle.min.js
472 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
contact-buttons-var-10.83d4216a4d1a44095e5c.bundle.min.js
7.75 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
contact-buttons-var-10.fc383e580d728636b0fa.bundle.js
3.63 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
contact-buttons.5398b922eb2a8fb72fd3.bundle.min.js
13.65 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
contact-buttons.b9e4576d72aaeeaa8e80.bundle.js
12.68 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
countdown.0e9e688751d29d07a8d3.bundle.min.js
2.63 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
countdown.6e87ca40d36793d92aea.bundle.js
4.83 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
custom-code.js
98.53 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
custom-code.min.js
26.87 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
d241154d3774d66da9eb.bundle.min.js
3.17 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
display-conditions.js
234.73 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
display-conditions.min.js
75.2 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
e8a5a32d9cd9fad1244f.bundle.js
11.1 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
editor.js
433.08 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
editor.min.js
168.96 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
editor.min.js.LICENSE.txt
188 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
elements-handlers.js
110.8 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
elements-handlers.min.js
41.79 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
floating-bars-var-2.6e9b0bce703a2a6f2410.bundle.min.js
14.27 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
floating-bars-var-2.c6ca10c575bf96977799.bundle.js
14.05 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
floating-bars-var-3.e3ae97fbef2242a8b036.bundle.min.js
13.77 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
floating-bars-var-3.f126e30880b01ca9a308.bundle.js
13.95 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
form-submission-admin.js
269.88 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
form-submission-admin.min.js
86.82 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
form.3b797cf593ad0ec04b83.bundle.js
32.83 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
form.a8f0864f4b4fda696ad1.bundle.min.js
18.89 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
frontend.js
55.89 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
frontend.min.js
24.46 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
gallery.572e8a2bca1a0b7e4f42.bundle.min.js
5.71 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
gallery.57d49c99a6212add88bf.bundle.js
9.36 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
gutenberg-woocommerce-notice.js
77.9 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
gutenberg-woocommerce-notice.min.js
15.84 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
hotspot.d513dd152bf605a2ffbf.bundle.js
4.89 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
hotspot.fa04300164c35a866a51.bundle.min.js
2.75 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
jszip.vendor.a3c65615c1de5560962d.bundle.js
95.64 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
jszip.vendor.eba4ace24dcc63eadac0.bundle.min.js
95.88 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
jszip.vendor.eba4ace24dcc63eadac0.bundle.min.js.LICENSE.txt
383 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
load-more.141d7f9a8572a75a1d28.bundle.js
9.35 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
load-more.376b5bcb2e56386f470e.bundle.min.js
5.13 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
loop-carousel.5108cb72ebb124297adb.bundle.js
2.77 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
loop-carousel.f8067ec0c24b628c786e.bundle.min.js
1.33 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
loop-filter-editor.46a4c013b80a381a50c9.bundle.js
7.02 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
loop-filter-editor.67dfa5d044d7bd86bd6f.bundle.min.js
3.27 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
loop.8130a6b4d3121c5aaaae.bundle.min.js
8.7 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
loop.da32028bc945271f8c7a.bundle.js
16.76 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
lottie.a02a01f29c0733918ac7.bundle.js
24.41 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
lottie.e74a53bfa4c0bd939250.bundle.min.js
14.07 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
media-carousel.04412cb9b4479aa37408.bundle.js
13.04 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
media-carousel.afbaabb756a7c18ddb09.bundle.min.js
6.84 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
mega-menu-editor.905833fcb6c66b951d7e.bundle.js
17.23 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
mega-menu-editor.da8ac1f6ef887046ecf0.bundle.min.js
7.83 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
mega-menu-stretch-content.0d76e4a3b7bf65ff6f9b.bundle.js
1.82 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
mega-menu-stretch-content.480e081cebe071d683e8.bundle.min.js
1.1 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
mega-menu.271d46d2e5a8185428d0.bundle.js
46.43 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
mega-menu.cd787a5946bfee971978.bundle.min.js
25.06 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
menu-title-keyboard-handler.77332e668c3cf609c924.bundle.js
12.35 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
menu-title-keyboard-handler.dff562edd49e93d1658e.bundle.min.js
7.51 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
nav-menu.997320c05a0d163c76e8.bundle.min.js
4.71 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
nav-menu.d3c84615b4828c150c34.bundle.js
8.91 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
nested-carousel-editor.0df35e0e1a284d4bd18b.bundle.js
1.84 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
nested-carousel-editor.6d7500036d0766bbe2fc.bundle.min.js
623 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
nested-carousel.10dc0cdc82d55919a863.bundle.min.js
3.65 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
nested-carousel.e282a75f865e207e8031.bundle.js
7.13 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
off-canvas-editor.0b71c4c17860dfe25d59.bundle.min.js
2.49 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
off-canvas-editor.3501c11d63bc4f4d5b89.bundle.js
6.15 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
off-canvas.321e93388904636cf8cf.bundle.js
10.2 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
off-canvas.bc9ebf2aa5a940324b7b.bundle.min.js
6.35 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
page-transitions.js
37.79 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
page-transitions.min.js
17.25 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
paypal-button.55ffb013a3fe565f55a5.bundle.js
1.54 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
paypal-button.f4f64e46173f50701949.bundle.min.js
871 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
popup.996738ad83c089bcc0b9.bundle.js
1.51 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
popup.f7b15b2ca565b152bf98.bundle.min.js
752 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
portfolio.4cd5da34009c30cb5d70.bundle.min.js
7.1 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
portfolio.5727b56368be256d0893.bundle.js
12.69 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
posts.aec59265318492b89cb5.bundle.min.js
3.24 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
posts.e99f84b83c36d4568ffe.bundle.js
5.8 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
preview.js
80.64 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
preview.min.js
16.93 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
product-add-to-cart.51a22e1fbd8f914ab3d5.bundle.min.js
3.42 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
product-add-to-cart.d5883897e035f9c53c5e.bundle.js
7.17 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
progress-tracker.8cccdda9737c272489fc.bundle.min.js
5.11 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
progress-tracker.fd1d31a26340ed74e10a.bundle.js
9.21 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
qunit-tests.js
2.65 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
qunit-tests.min.js
283 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
screenshot.js
11.58 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
screenshot.min.js
5.65 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
search-form.8941aba5c12cdb05fb7c.bundle.js
4.4 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
search-form.b7065999d77832a1b764.bundle.min.js
2.07 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
search.8457dd916c5a97a6dc73.bundle.js
19.51 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
search.9686bb2092445d2ad477.bundle.min.js
12.22 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
share-buttons.63d984f8c96d1e053bc0.bundle.min.js
1.54 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
share-buttons.fda49c1691f4a352c7ef.bundle.js
4.27 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
slides.bcd16bbde90338846bd7.bundle.js
7.39 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
slides.c0029640cbdb48199471.bundle.min.js
3.83 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
social.ac16c075939dcb93f70c.bundle.js
1.94 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
social.f215e8a3efafbdbeb7ef.bundle.min.js
1022 By
2024-10-19 01:21:21
R
W
Run
Delete
Rename
stripe-button.61d93594d6b7865f8b3f.bundle.min.js
1.97 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
stripe-button.cf3f67d6b95e0138bb6b.bundle.js
4.18 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
table-of-contents.1cfda3ead7ac082861dd.bundle.min.js
8.15 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
table-of-contents.461c83bbf6bdd6aceaf2.bundle.js
15.73 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
taxonomy-filter.ce05524d53c2d4c5aa24.bundle.js
15.78 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
taxonomy-filter.e839f2be32b7ea832b34.bundle.min.js
7.49 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
video-playlist.9e1bbc4fcb37864c89d6.bundle.js
49 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
video-playlist.af20fd9fd8778929829e.bundle.min.js
22.15 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
webpack-pro.runtime.js
16.3 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
webpack-pro.runtime.min.js
6.07 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-cart.79b5dc500681930471c6.bundle.js
10.51 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-cart.d0d01530f5be6736b5d2.bundle.min.js
5.08 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-checkout-page.10d97c3a8cb77aebc1bf.bundle.js
11.7 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-checkout-page.776b4cec45070fe32636.bundle.min.js
6.36 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-menu-cart.81f5bafc26b94cc86238.bundle.js
8.71 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-menu-cart.eb61fe086245485310a4.bundle.min.js
4.62 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-my-account.4e940a8b4a52d1c98c5c.bundle.min.js
6.08 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-my-account.7a9d36b2c12b970c6616.bundle.js
11.36 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-notices.bcee9b5e1c8f65ac7927.bundle.min.js
1.89 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-notices.ee407e8319d2ee060119.bundle.js
3.04 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-purchase-summary.3676ccd8c29ef0924b84.bundle.min.js
3.42 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
woocommerce-purchase-summary.c8767542fa302a7f351f.bundle.js
7.33 KB
2024-10-19 01:21:21
R
W
Run
Delete
Rename
error_log
up
📄
screenshot.js
Save
/*! elementor-pro - v3.24.0 - 09-10-2024 */ /******/ (() => { // webpackBootstrap /******/ "use strict"; /*!**************************************************************!*\ !*** ../modules/screenshots/assets/js/preview/screenshot.js ***! \**************************************************************/ /* global ElementorScreenshotConfig */ class Screenshot extends elementorModules.ViewModule { getDefaultSettings() { return { empty_content_headline: 'Empty Content.', crop: { width: 1200, height: 1500 }, excluded_external_css_urls: ['https://kit-pro.fontawesome.com'], external_images_urls: ['https://i.ytimg.com' // Youtube images domain. ], timeout: 15000, // Wait until screenshot taken or fail in 15 secs. render_timeout: 5000, // Wait until all the element will be loaded or 5 sec and then take screenshot. timerLabel: null, timer_label: `${ElementorScreenshotConfig.post_id} - timer`, image_placeholder: 'data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', isDebug: elementorCommonConfig.isElementorDebug, isDebugSvg: false, ...ElementorScreenshotConfig }; } getDefaultElements() { const $elementor = jQuery(ElementorScreenshotConfig.selector); const $sections = $elementor.find('.elementor-section-wrap > .elementor-section, .elementor > .elementor-section'); return { $elementor, $sections, $firstSection: $sections.first(), $notElementorElements: elementorCommon.elements.$body.find('> *:not(style, link)').not($elementor), $head: jQuery('head') }; } onInit() { super.onInit(); this.log('Screenshot init', 'time'); /** * Hold the timeout timer * * @type {number|null} */ this.timeoutTimer = setTimeout(this.screenshotFailed.bind(this), this.getSettings('timeout')); return this.captureScreenshot(); } /** * The main method for this class. */ captureScreenshot() { if (!this.elements.$elementor.length) { elementorCommon.helpers.consoleWarn('Screenshots: The content of this page is empty, the module will create a fake conent just for this screenshot.'); this.createFakeContent(); } this.removeUnnecessaryElements(); this.handleIFrames(); this.removeFirstSectionMargin(); this.handleLinks(); this.loadExternalCss(); this.loadExternalImages(); return Promise.resolve().then(this.createImage.bind(this)).then(this.createImageElement.bind(this)).then(this.cropCanvas.bind(this)).then(this.save.bind(this)).then(this.screenshotSucceed.bind(this)).catch(this.screenshotFailed.bind(this)); } /** * Fake content for documents that dont have any content. */ createFakeContent() { this.elements.$elementor = jQuery('<div>').css({ height: this.getSettings('crop.height'), width: this.getSettings('crop.width'), display: 'flex', alignItems: 'center', justifyContent: 'center' }); this.elements.$elementor.append(jQuery('<h1>').css({ fontSize: '85px' }).html(this.getSettings('empty_content_headline'))); document.body.prepend(this.elements.$elementor); } /** * CSS from another server cannot be loaded with the current dom to image library. * this method take all the links from another domain and proxy them. */ loadExternalCss() { const excludedUrls = [this.getSettings('home_url'), ...this.getSettings('excluded_external_css_urls')]; const notSelector = excludedUrls.map(url => `[href^="${url}"]`).join(', '); jQuery('link').not(notSelector).each((index, el) => { const $link = jQuery(el), $newLink = $link.clone(); $newLink.attr('href', this.getScreenshotProxyUrl($link.attr('href'))); this.elements.$head.append($newLink); $link.remove(); }); } /** * Make a proxy to images urls that has some problems with cross origin (like youtube). */ loadExternalImages() { const selector = this.getSettings('external_images_urls').map(url => `img[src^="${url}"]`).join(', '); jQuery(selector).each((index, el) => { const $img = jQuery(el); $img.attr('src', this.getScreenshotProxyUrl($img.attr('src'))); }); } /** * Html to images libraries can not snapshot IFrames * this method convert all the IFrames to some other elements. */ handleIFrames() { this.elements.$elementor.find('iframe').each((index, el) => { const $iframe = jQuery(el), $iframeMask = jQuery('<div />', { css: { background: 'gray', width: $iframe.width(), height: $iframe.height() } }); $iframe.before($iframeMask); $iframe.remove(); }); } /** * Remove all the sections that should not be in the screenshot. */ removeUnnecessaryElements() { let currentHeight = 0; this.elements.$sections.filter((index, el) => { let shouldBeRemoved = false; if (currentHeight >= this.getSettings('crop.height')) { shouldBeRemoved = true; } currentHeight += jQuery(el).outerHeight(); return shouldBeRemoved; }).each((index, el) => { el.remove(); }); // Some 3rd party plugins inject elements into the dom, so this method removes all // the elements that was injected, to make sure that it capture a screenshot only of the post itself. this.elements.$notElementorElements.remove(); } /** * Some urls make some problems to the svg parser. * this method convert all the urls to just '/'. */ handleLinks() { elementorCommon.elements.$body.find('a').attr('href', '/'); } /** * Remove unnecessary margin from the first element of the post (singles and footers). */ removeFirstSectionMargin() { this.elements.$firstSection.css({ marginTop: 0 }); } /** * Creates a png image. * * @return {Promise<unknown>} URI containing image data */ createImage() { const pageLoadedPromise = new Promise(resolve => { window.addEventListener('load', () => { resolve(); }); }); const timeOutPromise = new Promise(resolve => { setTimeout(() => { resolve(); }, this.getSettings('render_timeout')); }); return Promise.race([pageLoadedPromise, timeOutPromise]).then(() => { this.log('Start creating screenshot.'); if (this.getSettings('isDebugSvg')) { domtoimage.toSvg(document.body, { imagePlaceholder: this.getSettings('image_placeholder') }).then(svg => this.download(svg)); return Promise.reject('Debug SVG.'); } // TODO: Extract to util function. const isSafari = /^((?!chrome|android).)*safari/i.test(window.userAgent); // Safari browser has some problems with the images that dom-to-images // library creates, so in this specific case the screenshot uses html2canvas. // Note that dom-to-image creates more accurate screenshot in "not safari" browsers. if (isSafari) { this.log('Creating screenshot with "html2canvas"'); return html2canvas(document.body).then(canvas => { return canvas.toDataURL('image/png'); }); } this.log('Creating screenshot with "dom-to-image"'); return domtoimage.toPng(document.body, { imagePlaceholder: this.getSettings('image_placeholder') }); }); } /** * Download a uri, use for debugging the svg that created from dom to image libraries. * * @param {string} uri */ download(uri) { const $link = jQuery('<a/>', { href: uri, download: 'debugSvg.svg', html: 'Download SVG' }); elementorCommon.elements.$body.append($link); $link.trigger('click'); } /** * Creates fake image element to get the size of the image later on. * * @param {string} dataUrl * @return {Promise<HTMLImageElement>} Image Element */ createImageElement(dataUrl) { const image = new Image(); image.src = dataUrl; return new Promise(resolve => { image.onload = () => resolve(image); }); } /** * Crop the image to requested sizes. * * @param {HTMLImageElement} image * @return {Promise<unknown>} Canvas */ cropCanvas(image) { const width = this.getSettings('crop.width'); const height = this.getSettings('crop.height'); const cropCanvas = document.createElement('canvas'), cropContext = cropCanvas.getContext('2d'), ratio = width / image.width; cropCanvas.width = width; cropCanvas.height = height > image.height ? image.height : height; cropContext.drawImage(image, 0, 0, image.width, image.height, 0, 0, image.width * ratio, image.height * ratio); return Promise.resolve(cropCanvas); } /** * Send the image to the server. * * @param {HTMLCanvasElement} canvas * @return {Promise<unknown>} Screenshot URL */ save(canvas) { return new Promise((resolve, reject) => { elementorCommon.ajax.addRequest('screenshot_save', { data: { post_id: this.getSettings('post_id'), screenshot: canvas.toDataURL('image/png') }, success: url => { this.log(`Screenshot created: ${encodeURI(url)}`); resolve(url); }, error: () => { this.log('Failed to create screenshot.'); reject(); } }); }); } /** * Mark this post screenshot as failed. */ markAsFailed() { return new Promise((resolve, reject) => { elementorCommon.ajax.addRequest('screenshot_failed', { data: { post_id: this.getSettings('post_id') }, success: () => { this.log(`Marked as failed.`); resolve(); }, error: () => { this.log('Failed to mark this screenshot as failed.'); reject(); } }); }); } /** * @param {string} url * @return {string} Screenshot Proxy URL */ getScreenshotProxyUrl(url) { return `${this.getSettings('home_url')}?screenshot_proxy&nonce=${this.getSettings('nonce')}&href=${url}`; } /** * Notify that the screenshot has been succeed. * * @param {string} imageUrl */ screenshotSucceed(imageUrl) { this.screenshotDone(true, imageUrl); } /** * Notify that the screenshot has been failed. * * @param {Error} e */ screenshotFailed(e) { this.log(e, null); this.markAsFailed().then(() => this.screenshotDone(false)); } /** * Final method of the screenshot. * * @param {boolean} success * @param {string} imageUrl */ screenshotDone(success, imageUrl = null) { clearTimeout(this.timeoutTimer); this.timeoutTimer = null; // Send the message to the parent window and not to the top. // e.g: The `Theme builder` is loaded into an iFrame so the message of the screenshot // should be sent to the `Theme builder` window and not to the top window. window.parent.postMessage({ name: 'capture-screenshot-done', success, id: this.getSettings('post_id'), imageUrl }, '*'); this.log(`Screenshot ${success ? 'Succeed' : 'Failed'}.`, 'timeEnd'); } /** * Log messages for debugging. * * @param {any} message * @param {string?} timerMethod */ log(message, timerMethod = 'timeLog') { if (!this.getSettings('isDebug')) { return; } // eslint-disable-next-line no-console console.log('string' === typeof message ? `${this.getSettings('post_id')} - ${message}` : message); if (timerMethod) { // eslint-disable-next-line no-console console[timerMethod](this.getSettings('timer_label')); } } } jQuery(() => { new Screenshot(); }); /******/ })() ; //# sourceMappingURL=screenshot.js.map