mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
8a6659383d
commit
559a7a9564
@ -1800,6 +1800,7 @@ module.CropActions = actions.Actions({
|
||||
this.crop(this.data[selector](tags), flatten)
|
||||
}],
|
||||
|
||||
|
||||
// crop edit actions...
|
||||
// XXX BUG? order does odd things...
|
||||
addToCrop: ['- Crop/',
|
||||
@ -1883,21 +1884,7 @@ module.CropActions = actions.Actions({
|
||||
{
|
||||
browseMode: 'uncrop',
|
||||
getUndoState: function(d){
|
||||
d.placements = (d.args[0] instanceof Array ? d.args[0] : [d.args[0]]
|
||||
|| [d.current])
|
||||
.map(function(g){ return [
|
||||
g == null ?
|
||||
d.current
|
||||
// get the images...
|
||||
// NOTE: we store the list if gids and not the
|
||||
// ribbon as when undoing we have no info
|
||||
// on ribbon content...
|
||||
: this.data.ribbons[g] ? this.data.getImages(g) : g,
|
||||
// get ribbon and ribbon order...
|
||||
[this.data.getRibbon(g), this.data.getRibbonOrder(g)],
|
||||
// XXX this is not needed here but is used by .uncollect.undo(..)
|
||||
this.data.order.indexOf(g),
|
||||
] }.bind(this)) },
|
||||
d.placements = this.data.getImagePositions(d.args[0]) },
|
||||
undo: function(d){
|
||||
(d.placements || [])
|
||||
.forEach(function(e){
|
||||
|
||||
@ -977,17 +977,14 @@ var CollectionActions = actions.Actions({
|
||||
`,
|
||||
{
|
||||
browseMode: function(){ return !this.collection && 'disabled' },
|
||||
/*/ XXX two ways to go:
|
||||
// XXX two ways to go:
|
||||
// - .collect(..) + .data.placeImage(..)
|
||||
// - rewrite .collect(..) to use .data.placeImage(..) (like: .addToCrop(..))
|
||||
//getUndoState: 'removeFromCrop',
|
||||
getUndoState: function(d){
|
||||
var base = this.getActionAttr('removeFromCrop', 'getUndoState')
|
||||
base && base.call(this, d)
|
||||
d.placements = this.data.getImagePositions(d.args[0]) },
|
||||
d.collection = d.args[1] || this.collection
|
||||
},
|
||||
// XXX this does not work yet...
|
||||
// XXX this use
|
||||
/*/ XXX this does not work yet...
|
||||
undo: function(d){
|
||||
var that = this
|
||||
var gids = d.args[0] || [d.current]
|
||||
|
||||
@ -1213,6 +1213,58 @@ var DataPrototype = {
|
||||
return res
|
||||
},
|
||||
|
||||
// Get image positions...
|
||||
//
|
||||
// Get current image position...
|
||||
// .getImagePositions()
|
||||
// -> positions
|
||||
//
|
||||
// Get positions of gid(s)...
|
||||
// .getImagePositions(gid)
|
||||
// .getImagePositions(gid, ...)
|
||||
// .getImagePositions([gid, ...])
|
||||
// -> positions
|
||||
//
|
||||
// The resulting positions will be sorted to .order, ribbon gids
|
||||
// are pushed to the end of the list and also sorted to .ribbon_order
|
||||
//
|
||||
// Returns:
|
||||
// [
|
||||
// [<image-gid>,
|
||||
// [<ribbon-gid>, <ribbon-order>]],
|
||||
// <image-order>],
|
||||
// ...
|
||||
// ]
|
||||
//
|
||||
// NOTE: if a ribbon gid is encountered it will be expanded to a
|
||||
// list of image gids...
|
||||
getImagePositions: function(gids){
|
||||
gids = arguments.length > 1 ?
|
||||
[].slice.call(arguments)
|
||||
: (gids || this.current)
|
||||
gids = (gids instanceof Array ? gids : [gids])
|
||||
// sort ribbon gids to .ribbon_order
|
||||
.concat(this.ribbon_order
|
||||
.filter(function(g){
|
||||
var i = gids.indexOf(g)
|
||||
return i >= 0 ? !!gids.splice(i, 1) : false }))
|
||||
return this
|
||||
// sort list...
|
||||
// NOTE: ribbon gids will get pushed to the end...
|
||||
.makeSparseImages(gids)
|
||||
.map(function(g){ return [
|
||||
// get the images...
|
||||
this.ribbons[g] ? this.getImages(g) : g,
|
||||
// get ribbon and ribbon order...
|
||||
[this.getRibbon(g), this.getRibbonOrder(g)],
|
||||
// global order...
|
||||
this.order.indexOf(g),
|
||||
] }.bind(this))
|
||||
// XXX do we need this???
|
||||
// ...removing this would also encode order...
|
||||
.compact()
|
||||
},
|
||||
|
||||
// Get ribbon...
|
||||
//
|
||||
// Get current ribbon:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user