added crops and saved crops (no GUI yet)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-09-01 16:15:57 +03:00
parent 3e8ce38d1f
commit fbc7af8c05

View File

@ -1045,6 +1045,11 @@ var Gallery = {
return [...gallery.dom.querySelectorAll('.images img.to-remove')] },
set toBeRemoved(lst){
this.queueRemoval(lst) },
// XXX should this be writable...
get toBeKeept(){
return [...gallery.dom.querySelectorAll('.images img:not(.to-remove)')] },
set toBeKeept(lst){
this.unqueueRemoval(lst) },
queueRemoval: function(...images){
images = images.length == 0 ?
['current']
@ -1091,6 +1096,46 @@ var Gallery = {
this.dom.querySelector('.images').innerHTML = ''
return this },
// crop...
__crop_stack: undefined,
crop: function(lst){
var stack = this.__crop_stack ??= []
var state = this.json()
stack.push(state)
if(lst){
lst = this.getImages(...lst)
// XXX filter state...
// XXX
}
this.load(state)
return this },
uncrop: function(lst){
var state = this.__crop_stack?.pop()
state.length == 0
&& (delete this.__crop_stack)
state
&& this.load(state)
return this },
// named crops...
// XXX add these to serilization...
// XXX TEST...
__saved_crops: undefined,
get savedCropNames(){
return Object.keys(this.__saved_crops ?? {}) },
saveCrop: function(name){
var saved = this.__saved_crops ??= {}
saved[name] = this.json()
return this },
loadCrop: function(name){
var state = (this.__saved_crops ?? {})[name]
state
&& this.load(state)
return this },
removeCrop: function(name){
delete (this.__saved_crops ?? {})[name]
return this },
setup: function(dom){
var that = this
this.dom = dom
@ -1320,7 +1365,6 @@ var Gallery = {
// - press esc to cancel drag
// ...this will leave the dragged-over classes in place...
var cleanupAfterDrag = function(evt){
console.log('11111')
that.dom.classList.remove('dragged-over')
dragged_over
&& dragged_over.classList.remove('dragged-over') }