From 0086f20982ba2e304f0dd89b4fac40fd298453ba Mon Sep 17 00:00:00 2001 From: Stephanie Date: Thu, 21 Jul 2022 12:58:13 -0500 Subject: [PATCH 1/3] Connected pre-loaded images to v2 --- dist/infragram2.js | 18 ++++++++++++++++++ index2.html | 38 +++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/dist/infragram2.js b/dist/infragram2.js index 5519a959..942c66cc 100644 --- a/dist/infragram2.js +++ b/dist/infragram2.js @@ -1500,6 +1500,24 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i return true; }); + + $("#sample-image__select").click(function(e){ + e.stopPropagation(); + console.dir(e.target.classList) + const img = (e.target.classList.contains('rfi')) ? document.getElementById('rfi') : document.getElementById('bfi'); + console.log(img) + fetch(img.src) + .then(res => res.blob()) + .then(blob => { + const file = new File([blob], img.src, blob) + const fileInput = document.querySelector('input[type="file"]'); + const dataTransfer = new DataTransfer(); + dataTransfer.items.add(file); + fileInput.files = dataTransfer.files; + $(options.fileSelector).trigger("change"); + }) + }); + $(options.fileSelector).change(function () { $('.choose-prompt').hide(); $("#save-modal-btn").show(); diff --git a/index2.html b/index2.html index ad9bcdb2..48fd5fdc 100644 --- a/index2.html +++ b/index2.html @@ -62,22 +62,20 @@

-
- -
-
- + -
- -