mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
cleanup, refactoring and added marking of virtual blocks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
568757f9f1
commit
59d28d01ac
@ -1401,6 +1401,14 @@ module.CropActions = actions.Actions({
|
||||
.crop(data, false)
|
||||
-> this
|
||||
|
||||
Make a crop of this[attr] gid list...
|
||||
.crop(attr)
|
||||
-> this
|
||||
|
||||
Make a crop excluding this[attr] gid list...
|
||||
.crop(!attr)
|
||||
-> this
|
||||
|
||||
|
||||
NOTE: this is used as a basis for all the crop operations, so
|
||||
there is no need to bind to anything but this to handle a
|
||||
@ -1412,6 +1420,16 @@ module.CropActions = actions.Actions({
|
||||
{undo: 'uncrop'},
|
||||
function(list, flatten){
|
||||
list = list || this.data.getImages()
|
||||
// gid list attr...
|
||||
list = list in this ?
|
||||
this[list]
|
||||
: list
|
||||
// reverse gid list attr...
|
||||
if(typeof(list) == typeof('str') && list[0] == '!'){
|
||||
var skip = new Set(this[list.slice(1)])
|
||||
list = this.data.order
|
||||
.filter(function(gid){
|
||||
return !skip.has(gid) }) }
|
||||
|
||||
this.crop_stack = this.crop_stack || []
|
||||
this.crop_stack.push(this.data)
|
||||
|
||||
@ -30,6 +30,8 @@ var ui = require('features/ui')
|
||||
// 'ribbon' - current ribbon
|
||||
// ribbon - specific ribbon (gid)
|
||||
// Array
|
||||
// attr
|
||||
// !attr
|
||||
//
|
||||
// NOTE: of no data is defined this will not have any effect...
|
||||
// NOTE: we are not using the vanilla toggler here as it can't handle
|
||||
@ -74,6 +76,17 @@ function makeTagTogglerAction(tag){
|
||||
|
||||
// the action...
|
||||
var action = function(target, action){
|
||||
// gid list attr...
|
||||
target = target in this ?
|
||||
this[target]
|
||||
: target
|
||||
// reverse gid list attr...
|
||||
if(typeof(target) == typeof('str') && target[0] == '!'){
|
||||
var skip = new Set(this[target.slice(1)])
|
||||
target = this.data.order
|
||||
.filter(function(gid){
|
||||
return !skip.has(gid) }) }
|
||||
|
||||
// special case: no data...
|
||||
if(this.data == null){
|
||||
return action == '??' ? ['off', 'on'] : 'off'
|
||||
@ -255,7 +268,8 @@ var ImageMarkActions = actions.Actions({
|
||||
cropMarked: ['Mark|Crop/Crop $marked images',
|
||||
{browseMode: function(target){
|
||||
return this.marked.length == 0 && 'disabled' }},
|
||||
function(flatten){ this.cropTagged('marked', flatten) }],
|
||||
'crop: "marked" ...'],
|
||||
//function(flatten){ this.cropTagged('marked', flatten) }],
|
||||
//function(flatten){ this.cropTagged('marked', 'any', flatten) }],
|
||||
|
||||
removeMarkedFromCrop: ['Mark|Crop/Remove marked from crop',
|
||||
@ -302,20 +316,23 @@ module.ImageMarks = core.ImageGridFeatures.Feature({
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var ImageMarkEditActions = actions.Actions({
|
||||
// Common use-cases:
|
||||
// Toggle mark on current image
|
||||
// .toggleMark()
|
||||
//
|
||||
// Mark current ribbon
|
||||
// .toggleMark('ribbon', 'on')
|
||||
//
|
||||
// Unmark all loaded images
|
||||
// .toggleMark('loaded', 'off')
|
||||
//
|
||||
// Invert marks on current ribbon
|
||||
// .toggleMark('ribbon')
|
||||
//
|
||||
// XXX should this be like .crop(..) and accept attr name???
|
||||
toggleMark: ['Mark|Image/Image $mark',
|
||||
core.doc`
|
||||
|
||||
Toggle mark on current image
|
||||
.toggleMark()
|
||||
|
||||
Mark current ribbon
|
||||
.toggleMark('ribbon', 'on')
|
||||
|
||||
Unmark all loaded images
|
||||
.toggleMark('loaded', 'off')
|
||||
|
||||
Invert marks on current ribbon
|
||||
.toggleMark('ribbon')
|
||||
|
||||
`,
|
||||
undoTag('toggleMark'),
|
||||
makeTagTogglerAction('marked')],
|
||||
toggleMarkBlock: ['Mark/Invert $block marks',
|
||||
@ -518,8 +535,9 @@ var ImageBookmarkActions = actions.Actions({
|
||||
cropBookmarked: ['Bookmark|Crop/Crop $bookmarked images',
|
||||
{browseMode: function(target){
|
||||
return this.bookmarked.length == 0 && 'disabled' }},
|
||||
'crop: "bookmarked" ...'],
|
||||
//function(flatten){ this.cropTagged('bookmark', 'any', flatten) }],
|
||||
function(flatten){ this.cropTagged('bookmark', flatten) }],
|
||||
//function(flatten){ this.cropTagged('bookmark', flatten) }],
|
||||
})
|
||||
|
||||
// NOTE: this is usable without ribbons...
|
||||
|
||||
@ -46,12 +46,6 @@ var VirtualBlocksActions = actions.Actions({
|
||||
.filter(function(gid){
|
||||
img = that.images[gid] || {}
|
||||
return img.type == 'virtual' }) },
|
||||
get nonVirtual(){
|
||||
var that = this
|
||||
return this.data.order
|
||||
.filter(function(gid){
|
||||
img = that.images[gid] || {}
|
||||
return img.type != 'virtual' }) },
|
||||
|
||||
// construction of new "virtual images"...
|
||||
//
|
||||
@ -169,29 +163,18 @@ var VirtualBlocksActions = actions.Actions({
|
||||
this.makeVirtualBlock(ref, offset, img) }],
|
||||
|
||||
// crop...
|
||||
// XXX would be nice to avoid these and just register a list and context...
|
||||
cropVirtualBlocks: ['Virtual block|Crop/$Crop $virtual blocks',
|
||||
core.doc`Crop virtual blocks...
|
||||
|
||||
Crop (keep) virtual blocks...
|
||||
.cropVirtualBlocks()
|
||||
.cropVirtualBlocks('keep')
|
||||
-> this
|
||||
|
||||
Crop virtual bloks out...
|
||||
.cropVirtualBlocks('skip')
|
||||
-> this
|
||||
|
||||
`,
|
||||
{ browseMode: 'makeVirtualBlock' },
|
||||
function(mode){
|
||||
mode = mode || 'keep'
|
||||
return this.crop(
|
||||
mode == 'keep' ?
|
||||
this.virtual
|
||||
: this.nonVirtual) }],
|
||||
'crop: "virtual" ...'],
|
||||
cropVirtualBlocksOut: ['Virtual block|Crop/Crop virtual blocks out',
|
||||
{ browseMode: 'cropVirtualBlocks' },
|
||||
'cropVirtualBlocks: "skip"'],
|
||||
'crop: "!virtual" ...'],
|
||||
|
||||
// marks...
|
||||
toggleMarkVirtualBlocks: ['Virtual block|Mark/-50:Toggle $mark on $virtual blocks',
|
||||
{ browseMode: 'makeVirtualBlock' },
|
||||
'toggleMark: "virtual"'],
|
||||
})
|
||||
|
||||
var VirtualBlocks =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user