Spaces:
Sleeping
Sleeping
drakosfire
commited on
Commit
•
26c0802
1
Parent(s):
cf6d81c
Iframe test, inside modal, it's weird but seems to work. Modified storeUI.css to change modal.
Browse files- scripts.js +18 -12
- static/storeUI.css +13 -12
scripts.js
CHANGED
@@ -38,7 +38,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
38 |
return;
|
39 |
}
|
40 |
|
41 |
-
// Event delegation for
|
42 |
document.addEventListener('click', function(event) {
|
43 |
// Log the click event for debugging
|
44 |
console.log('Click detected:', event.target);
|
@@ -194,9 +194,19 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
194 |
function openPrintModal() {
|
195 |
// Clone the original content before modifying
|
196 |
originalContent = document.body.cloneNode(true);
|
197 |
-
|
198 |
var brewRendererContent = document.getElementById('brewRenderer').innerHTML;
|
199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
fetch('/proxy.html', {
|
201 |
method: 'POST',
|
202 |
headers: {
|
@@ -222,7 +232,13 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
222 |
document.getElementsByClassName('close')[0].onclick = function() {
|
223 |
closePrintModal();
|
224 |
};
|
|
|
|
|
|
|
|
|
|
|
225 |
})
|
|
|
226 |
.catch(error => {
|
227 |
console.error('Error loading the print preview:', error);
|
228 |
});
|
@@ -232,18 +248,8 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
232 |
var modal = document.getElementById('printModal');
|
233 |
modal.style.display = "none";
|
234 |
document.getElementById('modalPreviewContent').innerHTML = '';
|
235 |
-
|
236 |
-
// // Restore the original content or state
|
237 |
-
// if (originalContent) {
|
238 |
-
// document.body = originalContent.cloneNode(true);
|
239 |
-
// originalContent = null; // Clear the reference
|
240 |
-
// }
|
241 |
}
|
242 |
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
// Store initial positions of the blocks
|
248 |
function storeInitialPositions() {
|
249 |
const blocks = blockContainer.querySelectorAll('.block-item');
|
|
|
38 |
return;
|
39 |
}
|
40 |
|
41 |
+
// Event delegation for click events
|
42 |
document.addEventListener('click', function(event) {
|
43 |
// Log the click event for debugging
|
44 |
console.log('Click detected:', event.target);
|
|
|
194 |
function openPrintModal() {
|
195 |
// Clone the original content before modifying
|
196 |
originalContent = document.body.cloneNode(true);
|
|
|
197 |
var brewRendererContent = document.getElementById('brewRenderer').innerHTML;
|
198 |
|
199 |
+
// Create a hidden iframe or select an existing one
|
200 |
+
var printIframe = document.createElement('iframe');
|
201 |
+
printIframe.style.position = 'fixed';
|
202 |
+
printIframe.style.width = '0px';
|
203 |
+
printIframe.style.height = '0px';
|
204 |
+
printIframe.style.border = 'none'; // Make the iframe invisible
|
205 |
+
document.body.appendChild(printIframe);
|
206 |
+
// Write the modal content to the iframe
|
207 |
+
var iframeDoc = printIframe.contentWindow.document;
|
208 |
+
iframeDoc.open();
|
209 |
+
|
210 |
fetch('/proxy.html', {
|
211 |
method: 'POST',
|
212 |
headers: {
|
|
|
232 |
document.getElementsByClassName('close')[0].onclick = function() {
|
233 |
closePrintModal();
|
234 |
};
|
235 |
+
iframeDoc.write(document.getElementById('modalPreviewContent').innerHTML);
|
236 |
+
iframeDoc.close();
|
237 |
+
// Wait for the content to load, then trigger the print dialog
|
238 |
+
printIframe.contentWindow.focus();
|
239 |
+
printIframe.contentWindow.print();
|
240 |
})
|
241 |
+
|
242 |
.catch(error => {
|
243 |
console.error('Error loading the print preview:', error);
|
244 |
});
|
|
|
248 |
var modal = document.getElementById('printModal');
|
249 |
modal.style.display = "none";
|
250 |
document.getElementById('modalPreviewContent').innerHTML = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
}
|
252 |
|
|
|
|
|
|
|
|
|
253 |
// Store initial positions of the blocks
|
254 |
function storeInitialPositions() {
|
255 |
const blocks = blockContainer.querySelectorAll('.block-item');
|
static/storeUI.css
CHANGED
@@ -192,24 +192,25 @@
|
|
192 |
}
|
193 |
|
194 |
/* Modal styling */
|
195 |
-
.modal {
|
196 |
-
display: none;
|
197 |
-
position: fixed;
|
198 |
-
|
|
|
199 |
left: 0;
|
200 |
top: 0;
|
201 |
-
width: 100%;
|
202 |
-
height: 100%;
|
203 |
-
overflow: auto;
|
204 |
-
background-color: rgb(0,0,0);
|
205 |
-
background-color: rgba(0,0,0,0.9);
|
206 |
}
|
207 |
|
208 |
.modal-content {
|
209 |
margin: auto;
|
210 |
display: block;
|
211 |
-
width:
|
212 |
-
max-width:
|
213 |
}
|
214 |
|
215 |
.modal-content, #caption {
|
@@ -221,7 +222,7 @@
|
|
221 |
from {transform: scale(0)}
|
222 |
to {transform: scale(1)}
|
223 |
}
|
224 |
-
|
225 |
.close {
|
226 |
position: absolute;
|
227 |
top: 15px;
|
|
|
192 |
}
|
193 |
|
194 |
/* Modal styling */
|
195 |
+
/* .modal {
|
196 |
+
display: none;
|
197 |
+
position: fixed;
|
198 |
+
align-items: center;
|
199 |
+
z-index: 1001;
|
200 |
left: 0;
|
201 |
top: 0;
|
202 |
+
width: 100%;
|
203 |
+
height: 100%;
|
204 |
+
overflow: auto;
|
205 |
+
background-color: rgb(0,0,0);
|
206 |
+
background-color: rgba(0,0,0,0.9);
|
207 |
}
|
208 |
|
209 |
.modal-content {
|
210 |
margin: auto;
|
211 |
display: block;
|
212 |
+
width: 100%;
|
213 |
+
max-width: 730px;
|
214 |
}
|
215 |
|
216 |
.modal-content, #caption {
|
|
|
222 |
from {transform: scale(0)}
|
223 |
to {transform: scale(1)}
|
224 |
}
|
225 |
+
*/
|
226 |
.close {
|
227 |
position: absolute;
|
228 |
top: 15px;
|