mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
minor stuff...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
71ac19f5a0
commit
c6414e7841
@ -163,8 +163,20 @@ var CollectionActions = actions.Actions({
|
|||||||
loadCollection: ['- Collections/',
|
loadCollection: ['- Collections/',
|
||||||
core.doc`Load collection...
|
core.doc`Load collection...
|
||||||
|
|
||||||
This will get collection data and crop into it.
|
Load collection...
|
||||||
|
.loadCollection(collection)
|
||||||
|
-> this
|
||||||
|
|
||||||
|
Force reload current collection...
|
||||||
|
.loadCollection('!')
|
||||||
|
-> this
|
||||||
|
NOTE: this will not call .saveCollection(..) before
|
||||||
|
reloading, thus potentially losing some state that
|
||||||
|
was not explicitly saved.
|
||||||
|
|
||||||
|
|
||||||
|
When loading a collection, previous state is saved.
|
||||||
|
|
||||||
If .data for a collection is not available this will do nothing,
|
If .data for a collection is not available this will do nothing,
|
||||||
this enables extending actions to handle the collection in
|
this enables extending actions to handle the collection in
|
||||||
different ways.
|
different ways.
|
||||||
@ -199,12 +211,17 @@ var CollectionActions = actions.Actions({
|
|||||||
directly the next time.
|
directly the next time.
|
||||||
To invalidate such a cache .data should simply be deleted.
|
To invalidate such a cache .data should simply be deleted.
|
||||||
|
|
||||||
|
|
||||||
NOTE: cached collection state is persistent.
|
NOTE: cached collection state is persistent.
|
||||||
NOTE: when current collection is removed from .collections this
|
NOTE: when current collection is removed from .collections this
|
||||||
will not save state when loading another collection...
|
will not save state when loading another collection...
|
||||||
`,
|
`,
|
||||||
function(collection){
|
function(collection){
|
||||||
var that = this
|
var that = this
|
||||||
|
var force = collection == '!'
|
||||||
|
collection = collection == '!' ?
|
||||||
|
this.collection
|
||||||
|
: collection
|
||||||
if(collection == null
|
if(collection == null
|
||||||
|| this.collections == null
|
|| this.collections == null
|
||||||
|| !(collection in this.collections)){
|
|| !(collection in this.collections)){
|
||||||
@ -233,7 +250,9 @@ var CollectionActions = actions.Actions({
|
|||||||
// collection...
|
// collection...
|
||||||
// NOTE: we only save if the current collection exists, it
|
// NOTE: we only save if the current collection exists, it
|
||||||
// may not exist if it was just removed...
|
// may not exist if it was just removed...
|
||||||
} else if(this.collection in this.collections){
|
} else if(this.collection in this.collections
|
||||||
|
// prevent saving over changed current state...
|
||||||
|
&& !force){
|
||||||
this.saveCollection(
|
this.saveCollection(
|
||||||
this.collection,
|
this.collection,
|
||||||
crop_mode == 'all' ? 'crop': null)
|
crop_mode == 'all' ? 'crop': null)
|
||||||
@ -329,11 +348,9 @@ var CollectionActions = actions.Actions({
|
|||||||
// Not for direct use.
|
// Not for direct use.
|
||||||
})],
|
})],
|
||||||
|
|
||||||
// XXX saving into current collection will leave the viewer in an
|
// XXX should this call .loadCollection('!') when saving to current
|
||||||
// inconsistent state:
|
// collection???
|
||||||
// - collection X is indicated as loaded
|
// ...see comments inside...
|
||||||
// - collection X has different state than what is loaded
|
|
||||||
// ...not sure how to deal with this yet...
|
|
||||||
saveCollection: ['- Collections/',
|
saveCollection: ['- Collections/',
|
||||||
core.doc`Save current state to collection
|
core.doc`Save current state to collection
|
||||||
|
|
||||||
@ -373,11 +390,8 @@ var CollectionActions = actions.Actions({
|
|||||||
|
|
||||||
NOTE: this will overwrite collection .data and .crop_stack only,
|
NOTE: this will overwrite collection .data and .crop_stack only,
|
||||||
the rest of the data is untouched...
|
the rest of the data is untouched...
|
||||||
NOTE: if it is needed to overwrite an existing collection then
|
NOTE: when saving to current collection and maintain consistent
|
||||||
first remove it then save anew:
|
state it may be necessary to .loadCollection('!')
|
||||||
this
|
|
||||||
.removeCollection(x)
|
|
||||||
.saveCollection(x, 'crop')
|
|
||||||
`,
|
`,
|
||||||
function(collection, mode, force){
|
function(collection, mode, force){
|
||||||
var that = this
|
var that = this
|
||||||
@ -436,6 +450,15 @@ var CollectionActions = actions.Actions({
|
|||||||
} else {
|
} else {
|
||||||
delete state.crop_stack
|
delete state.crop_stack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// XXX this leads to recursion????
|
||||||
|
// .loadCollection('X')
|
||||||
|
// -> .saveCollection('current')
|
||||||
|
// -> .loadCollection('!')
|
||||||
|
// XXX should we be doing this here or on case by case basis externally...
|
||||||
|
//collection == this.collection
|
||||||
|
// && this.loadCollection('!')
|
||||||
}],
|
}],
|
||||||
newCollection: ['- Collections/',
|
newCollection: ['- Collections/',
|
||||||
function(collection){ return this.saveCollection(collection, 'empty') }],
|
function(collection){ return this.saveCollection(collection, 'empty') }],
|
||||||
@ -1370,7 +1393,11 @@ var UICollectionActions = actions.Actions({
|
|||||||
saveAsCollection: ['Collections|Crop/$Save as collection...',
|
saveAsCollection: ['Collections|Crop/$Save as collection...',
|
||||||
widgets.uiDialog(function(){
|
widgets.uiDialog(function(){
|
||||||
return this.browseCollections(function(title){
|
return this.browseCollections(function(title){
|
||||||
this.saveCollection(title) }) })],
|
this.saveCollection(title, 'current')
|
||||||
|
// XXX should we be doing this manually here or in .saveCollection(..)
|
||||||
|
title == this.collection
|
||||||
|
&& this.loadCollection('!')
|
||||||
|
}) })],
|
||||||
addToCollection: ['Collections|Crop|Image/Add $image to collection...',
|
addToCollection: ['Collections|Crop|Image/Add $image to collection...',
|
||||||
widgets.uiDialog(function(gids){
|
widgets.uiDialog(function(gids){
|
||||||
return this.browseCollections(function(title){
|
return this.browseCollections(function(title){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user