-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connected pre-loaded images to v2 #436
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,12 +52,12 @@ module.exports = function Interface(options) { | |
"#s_exp": "s", | ||
"#v_exp": "v" | ||
}; | ||
|
||
$("#overlay-slider").val(localStorage.getItem("overlaySize")); | ||
console.log('grid ' + localStorage.getItem("overlaySize")); | ||
setGrid($("#overlay-slider").val()); | ||
|
||
// TODO: broken: | ||
// TODO: broken: | ||
//urlHash.setUrlHashParameter(JSON.stringify(idNameMap)); | ||
src = urlHash.getUrlHashParameter('src'); | ||
if (src) { | ||
|
@@ -68,6 +68,21 @@ module.exports = function Interface(options) { | |
return true; | ||
}); | ||
|
||
$("#sample-image__select").click(function(e){ | ||
e.stopPropagation(); | ||
const img = (e.target.classList.contains('rfi')) ? document.getElementById('rfi') : document.getElementById('bfi'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's another super great line of code - i love that the idea is that you can add the "bfi" or "rfi" classes to switch between. Maybe we should explain this too in a comment! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha - i see now -- we want to click on the thumbnail, but use the big hidden image! I wonder - if we use relatively low res sample images, like, 1024x768 or less, could we simplify things by just skipping thumbnails? JPGs don't weigh that much, you know? Then the logic here can be much simpler - we just display the big images with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So on this line, if we stop using separate thumbnails, we can maybe just skip using red-filter or blue-filter classes completely. Since we'd just select whatever image, and think about what kind of filter later? |
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow i really like this way of doing it. It literally selects the image, same as someone using it! That will mean that we don't have to support (or think about) 2 different means of adding images. Very cool. |
||
fileInput.files = dataTransfer.files; | ||
$(options.fileSelector).trigger("change"); | ||
}) | ||
}); | ||
|
||
$(options.fileSelector).change(function() { | ||
$('.choose-prompt').hide(); | ||
$("#save-modal-btn").show(); | ||
|
@@ -130,7 +145,7 @@ module.exports = function Interface(options) { | |
localStorage.setItem("overlaySize", $("#overlay-slider").val()); | ||
$("#overlay-save-info").show().delay(2000).fadeOut(); | ||
}); | ||
|
||
$("[rel=tooltip]").tooltip() | ||
$("[rel=popover]").popover() | ||
return true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good; it'll only run if there is an HTML DOM element with an id of
sample-image__select
, so this won't break v1. However, 2 thoughts -There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's cool is that this means ANY image could be used as a sample image, it just has to have the id
sample-image__select
. I suggest that we change that to a class, since strictly, ids should be used only once. Then someday someone may want to add, for example, a bunch of different examples in a kind of menu, they could use this. So the class could be maybe....sample-image
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But perhaps that means we should then apply the class to just the individual images, rather than the whole container. Let me make a suggestion!